Skip to content

Rows as optional data in a manifest #3452

Todo

Description

@rubenvdlinde

Is your feature request related to a problem? Please describe.

  • An application with empty choice lists is not usable after install.
Why this is needed

Describe the solution you'd like

  • The manifest export can include the rows of chosen tables, and the import can load them, so an application can ship with its lists of values or demo data.
Diagram
sequenceDiagram
    actor M as Manager
    participant API as api/2 manifest routes (new, #3450 and #3451)
    participant S as ContextService
    participant DB as rows of the chosen tables
    M->>API: export, with the list of tables whose rows go along
    API->>S: build the manifest
    S->>DB: read the rows in the object shape (3096)
    S-->>M: manifest with rows, relation cells as row uuids
    M->>API: import the manifest on another instance
    API->>S: look up each row by its uuid
    S->>DB: insert the rows whose uuid is missing
    S->>DB: leave rows with a known uuid alone
Loading
Acceptance Criteria
  • Export takes a list of tables whose rows are included.
  • Rows are written in the object shape (Option to return rows as objects and accept object-shape writes to API/2 #3096), with relations by row uuid (UUIDs for rows #3093).
  • Import inserts rows that are missing by uuid and leaves existing rows alone.
  • Unit tests.
  • The route declares its permission with #[RequirePermission] using a fixed node type, and the service checks the same right (create rows on every target table) before it inserts; a test runs every write as a reader and expects 403 (or 404 where the reader may not know the object exists).
  • The export holds only rows the exporting user may read.
Out of scope

Describe alternatives you've considered

Questions for maintainers

  1. What happens on import when a row with the same uuid exists but its values differ? (a) leave it alone, (b) overwrite it, (c) an explicit option on the import. We would go with (a) by default and (c) later, because an import must not overwrite data users changed.
  2. Which tables ship their rows? (a) a list passed on each export call, (b) a flag stored on the table inside the application. We would go with (a), because it needs no new stored field; templates (Save an application as a template and create from it #3457) can add (b) if they need it.
  3. Rows use the object shape of Option to return rows as objects and accept object-shape writes to API/2 #3096, keyed by the column's technical name. Should relation cells inside the manifest name their target by row uuid (as drafted) or by a label value? We would go with the uuid, because labels are not unique.

Additional context

Linking to other objects
Relevant files:
Related issues

Drafted with AI assistance from the project plan; @rjzondervan reviews it. Part of #3419.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions