Skip to content

Import a manifest with a preview of the changes #3451

Todo

Description

@rubenvdlinde

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

  • Importing into an instance that already has an older version of the application must not surprise anyone.
Why this is needed

Describe the solution you'd like

  • An api/2 route that imports a manifest, and a dry run that lists what an import would create, change or leave alone, like the scheme preview-changes route.
Diagram
sequenceDiagram
    actor M as Manager
    participant API as New manifest import route
    participant IS as New manifest import service
    participant DB as Database
    M->>API: POST the manifest as a dry run
    API->>IS: match by slug, columns and views by technical name
    IS->>DB: read the current application
    IS-->>API: per item create, change or keep
    API-->>M: preview
    M->>API: POST the manifest to import
    API->>IS: the same plan
    IS->>DB: begin a transaction
    IS->>DB: create missing, update changed, delete only with the option
    IS->>DB: commit, or roll back on failure
    API-->>M: result
Loading
Acceptance Criteria
  • The dry run lists per table, column, page and menu item: create, change or keep.
  • The import creates what is missing and updates what changed, matched by slug (columns and views by their existing technical name).
  • Nothing is deleted without an explicit option.
  • A failed import leaves nothing half done.
  • Unit tests, and an import of the example from Export an application as a manifest on api/2 #3450.
  • The import into an existing application: the route declares its permission with #[RequirePermission] (manage on the application) using a fixed node type (context), and the service checks the same right before it writes (as agreed on UUIDs for rows #3093 and in the review of feat(contexts): give applications a menu with its own API #3135). A test runs every write as a reader and expects 403, or 404 where the reader may not know the object exists. Importing as a new application needs no rights beyond an account.
  • A delete with the explicit option removes what depends on the deleted item (widgets, menu items, links of Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468) in the same transaction as the rest of the import.
Out of scope

Describe alternatives you've considered

Questions for maintainers

  1. A column in the manifest with the same technical name but another type than on the instance: change the type, or refuse and report it in the dry run? We would go with refusing, because a type change can lose data in the cells.
  2. The dry run: a flag on the import route, or its own route like the scheme's preview-changes? We would go with its own route, to match the scheme routes that exist.
  3. Who may import into an existing application: its owner only, or anyone with manage rights on it? We would go with manage rights, the same right that edits its pages today.

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