Skip to content

feat: allow scoped spreadsheet imports#2

Merged
marianfoo merged 2 commits into
mainfrom
codex/allow-selected-import-entities
Jun 16, 2026
Merged

feat: allow scoped spreadsheet imports#2
marianfoo merged 2 commits into
mainfrom
codex/allow-selected-import-entities

Conversation

@marianfoo

@marianfoo marianfoo commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #1 by adding an opt-in scope for spreadsheet imports.

  • Adds support for @spreadsheetimporter.enabled on CDS entities and service projections.
  • Keeps existing behavior when no entities are annotated, so current projects continue to allow all imports by default.
  • When at least one entity is annotated, rejects non-enabled entities with 403 SPREADSHEET_IMPORT_ENTITY_NOT_ENABLED before reading/parsing the upload stream.
  • Resolves annotated service projections to their persistence entity so existing URLs such as Spreadsheet(entity='my.bookshop.Books')/content keep working.
  • Preserves CAP entity lookup behavior for short names such as Books via cds.entities() while using compiled model definitions for projection/source resolution.
  • Documents that the plugin annotation controls target-entity eligibility only; user/role authorization should stay in CAP annotations such as @requires or @restrict.
  • Adds unit coverage plus CAP OData integration coverage for fully qualified names, service projection names, short names, disabled entities, and unknown entities.

Root Cause

The importer previously trusted the entity URL parameter, resolved it directly from the CAP entity lookup, and inserted through cds.db. That bypassed normal service-level restrictions such as @readonly on exposed service entities, so there was no way to enable the importer for only selected entities.

CAP Practice Applied

  • Model-level eligibility is expressed through a CDS annotation, matching CAP's annotation-driven modeling style.
  • Role/user authorization is intentionally left to CAP's built-in @requires and @restrict annotations instead of being reimplemented in the importer.
  • Request failures use req.reject(...), which CAP documents as the preferred request rejection path.
  • Tests use cds.test(...).in(...) so CAP test servers are isolated and no external localhost server is required.

Validation

  • node -c importer-service.js
  • git diff --check
  • npm test -- --runInBand — 3 suites, 12 tests passing

@marianfoo marianfoo changed the title [codex] allow scoped spreadsheet imports feat: allow scoped spreadsheet imports Jun 16, 2026
@marianfoo marianfoo marked this pull request as ready for review June 16, 2026 19:11
@marianfoo marianfoo merged commit 05e9b2f into main Jun 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only allow selected Entities

1 participant