primitive-admin 1.2.0-alpha.9 → 1.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +258 -186
- package/assets/skill/skills/primitive-platform/SKILL.md +93 -27
- package/dist/bin/primitive.js +15 -89
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.js +80 -17
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/agent-sessions.d.ts +129 -0
- package/dist/src/commands/agent-sessions.js +532 -20
- package/dist/src/commands/agent-sessions.js.map +1 -1
- package/dist/src/commands/analytics.js +207 -155
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps-children.js +3 -0
- package/dist/src/commands/apps-children.js.map +1 -1
- package/dist/src/commands/apps-transitions.d.ts +39 -0
- package/dist/src/commands/apps-transitions.js +198 -0
- package/dist/src/commands/apps-transitions.js.map +1 -0
- package/dist/src/commands/apps.d.ts +17 -0
- package/dist/src/commands/apps.js +108 -3
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth-sessions.js +2 -0
- package/dist/src/commands/auth-sessions.js.map +1 -1
- package/dist/src/commands/auth.js +138 -44
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.js +2 -0
- package/dist/src/commands/blob-buckets.js.map +1 -1
- package/dist/src/commands/collections.js +318 -256
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/comparisons.js +2 -0
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/config.d.ts +2 -2
- package/dist/src/commands/config.js +59 -33
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/connections.js +2 -0
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/database-type-configs.js +5 -3
- package/dist/src/commands/database-type-configs.js.map +1 -1
- package/dist/src/commands/databases.js +6 -4
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/db3-types.d.ts +15 -0
- package/dist/src/commands/db3-types.js +159 -0
- package/dist/src/commands/db3-types.js.map +1 -0
- package/dist/src/commands/db3.d.ts +24 -0
- package/dist/src/commands/db3.js +1444 -0
- package/dist/src/commands/db3.js.map +1 -0
- package/dist/src/commands/documents.d.ts +110 -10
- package/dist/src/commands/documents.js +1012 -748
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.js +74 -0
- package/dist/src/commands/email-templates.js.map +1 -1
- package/dist/src/commands/env.js +8 -4
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/function-trigger-commands.d.ts +28 -0
- package/dist/src/commands/function-trigger-commands.js +341 -0
- package/dist/src/commands/function-trigger-commands.js.map +1 -0
- package/dist/src/commands/functions.js +376 -30
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/groups.js +168 -50
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.js +7 -5
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/hosting.d.ts +8 -0
- package/dist/src/commands/hosting.js +346 -0
- package/dist/src/commands/hosting.js.map +1 -0
- package/dist/src/commands/init.js +129 -38
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +82 -53
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/locks.d.ts +5 -3
- package/dist/src/commands/locks.js +19 -61
- package/dist/src/commands/locks.js.map +1 -1
- package/dist/src/commands/metadata-category-configs.d.ts +2 -2
- package/dist/src/commands/metadata-category-configs.js +4 -2
- package/dist/src/commands/metadata-category-configs.js.map +1 -1
- package/dist/src/commands/metadata.js +41 -0
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/prompts.js +75 -52
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rate-counters.d.ts +19 -0
- package/dist/src/commands/rate-counters.js +104 -0
- package/dist/src/commands/rate-counters.js.map +1 -0
- package/dist/src/commands/rule-sets.d.ts +1 -1
- package/dist/src/commands/rule-sets.js +2 -1
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/schemas.d.ts +15 -0
- package/dist/src/commands/schemas.js +122 -0
- package/dist/src/commands/schemas.js.map +1 -0
- package/dist/src/commands/scripts.d.ts +9 -17
- package/dist/src/commands/scripts.js +24 -479
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/secrets.js +47 -3
- package/dist/src/commands/secrets.js.map +1 -1
- package/dist/src/commands/sessions.js +2 -0
- package/dist/src/commands/sessions.js.map +1 -1
- package/dist/src/commands/skill.js +2 -0
- package/dist/src/commands/skill.js.map +1 -1
- package/dist/src/commands/sync-schemas.d.ts +202 -0
- package/dist/src/commands/sync-schemas.js +629 -0
- package/dist/src/commands/sync-schemas.js.map +1 -0
- package/dist/src/commands/sync-user-properties.d.ts +118 -0
- package/dist/src/commands/sync-user-properties.js +276 -0
- package/dist/src/commands/sync-user-properties.js.map +1 -0
- package/dist/src/commands/sync.d.ts +518 -546
- package/dist/src/commands/sync.js +3010 -4877
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.js +5 -3
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/transitions.d.ts +54 -0
- package/dist/src/commands/transitions.js +418 -0
- package/dist/src/commands/transitions.js.map +1 -0
- package/dist/src/commands/usage.d.ts +18 -0
- package/dist/src/commands/usage.js +343 -0
- package/dist/src/commands/usage.js.map +1 -0
- package/dist/src/commands/user-properties.d.ts +14 -0
- package/dist/src/commands/user-properties.js +79 -0
- package/dist/src/commands/user-properties.js.map +1 -0
- package/dist/src/commands/users.js +911 -18
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.js +2 -0
- package/dist/src/commands/vars.js.map +1 -1
- package/dist/src/commands/waitlist.js +39 -4
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/workflows.d.ts +5 -83
- package/dist/src/commands/workflows.js +57 -2282
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/analytics-query.d.ts +58 -0
- package/dist/src/lib/analytics-query.js +134 -0
- package/dist/src/lib/analytics-query.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +1818 -438
- package/dist/src/lib/api-client.js +965 -544
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
- package/dist/src/lib/app-settings-descriptor.js +6 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/auth-fixtures.d.ts +44 -0
- package/dist/src/lib/auth-fixtures.js +61 -0
- package/dist/src/lib/auth-fixtures.js.map +1 -0
- package/dist/src/lib/auth-flow.d.ts +34 -1
- package/dist/src/lib/auth-flow.js +429 -13
- package/dist/src/lib/auth-flow.js.map +1 -1
- package/dist/src/lib/block-layout.d.ts +12 -23
- package/dist/src/lib/block-layout.js +26 -92
- package/dist/src/lib/block-layout.js.map +1 -1
- package/dist/src/lib/block-selector.d.ts +8 -14
- package/dist/src/lib/block-selector.js +8 -19
- package/dist/src/lib/block-selector.js.map +1 -1
- package/dist/src/lib/child-apps-local.d.ts +3 -1
- package/dist/src/lib/child-apps-local.js +9 -1
- package/dist/src/lib/child-apps-local.js.map +1 -1
- package/dist/src/lib/cli-manifest.d.ts +9 -0
- package/dist/src/lib/cli-manifest.js +10 -1
- package/dist/src/lib/cli-manifest.js.map +1 -1
- package/dist/src/lib/cli-version.d.ts +14 -0
- package/dist/src/lib/cli-version.js +38 -0
- package/dist/src/lib/cli-version.js.map +1 -0
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
- package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
- package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
- package/dist/src/lib/collection-export.d.ts +76 -15
- package/dist/src/lib/collection-export.js +116 -23
- package/dist/src/lib/collection-export.js.map +1 -1
- package/dist/src/lib/collection-principal.d.ts +22 -0
- package/dist/src/lib/collection-principal.js +35 -0
- package/dist/src/lib/collection-principal.js.map +1 -0
- package/dist/src/lib/command-groups.d.ts +30 -0
- package/dist/src/lib/command-groups.js +109 -0
- package/dist/src/lib/command-groups.js.map +1 -0
- package/dist/src/lib/command-status.d.ts +147 -0
- package/dist/src/lib/command-status.js +266 -0
- package/dist/src/lib/command-status.js.map +1 -0
- package/dist/src/lib/config-object-descriptor.d.ts +9 -22
- package/dist/src/lib/config-object-descriptor.js +107 -276
- package/dist/src/lib/config-object-descriptor.js.map +1 -1
- package/dist/src/lib/config-surface.d.ts +3 -7
- package/dist/src/lib/config-surface.js +9 -13
- package/dist/src/lib/config-surface.js.map +1 -1
- package/dist/src/lib/config-toml.d.ts +11 -2
- package/dist/src/lib/config-toml.js +25 -2
- package/dist/src/lib/config-toml.js.map +1 -1
- package/dist/src/lib/credentials-home.d.ts +7 -0
- package/dist/src/lib/credentials-home.js +45 -10
- package/dist/src/lib/credentials-home.js.map +1 -1
- package/dist/src/lib/credentials-lock.d.ts +14 -6
- package/dist/src/lib/credentials-lock.js +90 -10
- package/dist/src/lib/credentials-lock.js.map +1 -1
- package/dist/src/lib/credentials-store.d.ts +123 -70
- package/dist/src/lib/credentials-store.js +358 -113
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/custodian.d.ts +8 -0
- package/dist/src/lib/custodian.js +18 -0
- package/dist/src/lib/custodian.js.map +1 -0
- package/dist/src/lib/data-input.d.ts +1 -1
- package/dist/src/lib/data-input.js +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +38 -1
- package/dist/src/lib/db-codegen/dbTypeIR.js +29 -7
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
- package/dist/src/lib/db-type-records.d.ts +106 -0
- package/dist/src/lib/db-type-records.js +224 -0
- package/dist/src/lib/db-type-records.js.map +1 -0
- package/dist/src/lib/db3-export.d.ts +287 -0
- package/dist/src/lib/db3-export.js +647 -0
- package/dist/src/lib/db3-export.js.map +1 -0
- package/dist/src/lib/db3-index-output.d.ts +116 -0
- package/dist/src/lib/db3-index-output.js +223 -0
- package/dist/src/lib/db3-index-output.js.map +1 -0
- package/dist/src/lib/db3-type-models.d.ts +134 -0
- package/dist/src/lib/db3-type-models.js +452 -0
- package/dist/src/lib/db3-type-models.js.map +1 -0
- package/dist/src/lib/deprecation.d.ts +2 -2
- package/dist/src/lib/deprecation.js +2 -2
- package/dist/src/lib/document-ingest-artifact.d.ts +13 -0
- package/dist/src/lib/document-ingest-artifact.js +36 -6
- package/dist/src/lib/document-ingest-artifact.js.map +1 -1
- package/dist/src/lib/document-ingest-format2.d.ts +36 -0
- package/dist/src/lib/document-ingest-format2.js +78 -0
- package/dist/src/lib/document-ingest-format2.js.map +1 -0
- package/dist/src/lib/document-ingest-input.d.ts +9 -0
- package/dist/src/lib/document-ingest-input.js +28 -1
- package/dist/src/lib/document-ingest-input.js.map +1 -1
- package/dist/src/lib/document-ingest.d.ts +11 -1
- package/dist/src/lib/document-ingest.js +16 -0
- package/dist/src/lib/document-ingest.js.map +1 -1
- package/dist/src/lib/document-schema-rows.d.ts +42 -0
- package/dist/src/lib/document-schema-rows.js +53 -0
- package/dist/src/lib/document-schema-rows.js.map +1 -0
- package/dist/src/lib/experimental-apis.d.ts +36 -0
- package/dist/src/lib/experimental-apis.js +46 -0
- package/dist/src/lib/experimental-apis.js.map +1 -0
- package/dist/src/lib/file-attachment.d.ts +24 -0
- package/dist/src/lib/file-attachment.js +31 -0
- package/dist/src/lib/file-attachment.js.map +1 -0
- package/dist/src/lib/function-authorize-check.d.ts +142 -0
- package/dist/src/lib/function-authorize-check.js +311 -0
- package/dist/src/lib/function-authorize-check.js.map +1 -0
- package/dist/src/lib/function-authorize-view.d.ts +27 -0
- package/dist/src/lib/function-authorize-view.js +88 -0
- package/dist/src/lib/function-authorize-view.js.map +1 -0
- package/dist/src/lib/function-bundle.d.ts +27 -5
- package/dist/src/lib/function-bundle.js +142 -7
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +90 -12
- package/dist/src/lib/function-collect.js +482 -12
- package/dist/src/lib/function-collect.js.map +1 -1
- package/dist/src/lib/function-db-types.d.ts +65 -11
- package/dist/src/lib/function-db-types.js +297 -157
- package/dist/src/lib/function-db-types.js.map +1 -1
- package/dist/src/lib/function-document-types.d.ts +19 -7
- package/dist/src/lib/function-document-types.js +24 -12
- package/dist/src/lib/function-document-types.js.map +1 -1
- package/dist/src/lib/function-lint.d.ts +57 -0
- package/dist/src/lib/function-lint.js +234 -0
- package/dist/src/lib/function-lint.js.map +1 -0
- package/dist/src/lib/function-log-row.js +21 -2
- package/dist/src/lib/function-log-row.js.map +1 -1
- package/dist/src/lib/function-run.d.ts +13 -21
- package/dist/src/lib/function-run.js +14 -27
- package/dist/src/lib/function-run.js.map +1 -1
- package/dist/src/lib/function-schema-codegen.d.ts +86 -22
- package/dist/src/lib/function-schema-codegen.js +194 -88
- package/dist/src/lib/function-schema-codegen.js.map +1 -1
- package/dist/src/lib/function-schema-refs.d.ts +98 -0
- package/dist/src/lib/function-schema-refs.js +177 -0
- package/dist/src/lib/function-schema-refs.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +109 -6
- package/dist/src/lib/function-sync.js +179 -26
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/function-trigger-listing.d.ts +11 -6
- package/dist/src/lib/function-trigger-listing.js +32 -11
- package/dist/src/lib/function-trigger-listing.js.map +1 -1
- package/dist/src/lib/function-typecheck.d.ts +52 -0
- package/dist/src/lib/function-typecheck.js +174 -54
- package/dist/src/lib/function-typecheck.js.map +1 -1
- package/dist/src/lib/function-versions.d.ts +2 -0
- package/dist/src/lib/function-versions.js +1 -0
- package/dist/src/lib/function-versions.js.map +1 -1
- package/dist/src/lib/generated-build-flags.d.ts +13 -0
- package/dist/src/lib/generated-build-flags.js +14 -0
- package/dist/src/lib/generated-build-flags.js.map +1 -0
- package/dist/src/lib/generated-command-status.d.ts +6 -0
- package/dist/src/lib/generated-command-status.js +469 -0
- package/dist/src/lib/generated-command-status.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +538 -141
- package/dist/src/lib/generated-config-surfaces.js +1772 -1854
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/lib/hosting-build.d.ts +97 -0
- package/dist/src/lib/hosting-build.js +204 -0
- package/dist/src/lib/hosting-build.js.map +1 -0
- package/dist/src/lib/hosting-client.d.ts +167 -0
- package/dist/src/lib/hosting-client.js +340 -0
- package/dist/src/lib/hosting-client.js.map +1 -0
- package/dist/src/lib/hosting-environments.d.ts +32 -0
- package/dist/src/lib/hosting-environments.js +74 -0
- package/dist/src/lib/hosting-environments.js.map +1 -0
- package/dist/src/lib/hosting-errors.d.ts +30 -0
- package/dist/src/lib/hosting-errors.js +43 -0
- package/dist/src/lib/hosting-errors.js.map +1 -0
- package/dist/src/lib/hosting-token.d.ts +46 -0
- package/dist/src/lib/hosting-token.js +60 -0
- package/dist/src/lib/hosting-token.js.map +1 -0
- package/dist/src/lib/hosting-wait.d.ts +42 -0
- package/dist/src/lib/hosting-wait.js +84 -0
- package/dist/src/lib/hosting-wait.js.map +1 -0
- package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
- package/dist/src/lib/hosting-wfp-upload.js +149 -0
- package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
- package/dist/src/lib/init-assets.d.ts +2 -6
- package/dist/src/lib/init-assets.js +11 -27
- package/dist/src/lib/init-assets.js.map +1 -1
- package/dist/src/lib/init-ios-links.d.ts +11 -7
- package/dist/src/lib/init-ios-links.js +28 -22
- package/dist/src/lib/init-ios-links.js.map +1 -1
- package/dist/src/lib/init-login-note.d.ts +13 -0
- package/dist/src/lib/init-login-note.js +22 -0
- package/dist/src/lib/init-login-note.js.map +1 -0
- package/dist/src/lib/init-schema.d.ts +15 -0
- package/dist/src/lib/init-schema.js +54 -0
- package/dist/src/lib/init-schema.js.map +1 -1
- package/dist/src/lib/integration-test-request.d.ts +54 -0
- package/dist/src/lib/integration-test-request.js +207 -0
- package/dist/src/lib/integration-test-request.js.map +1 -0
- package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
- package/dist/src/lib/invoker-shared-enums.js +98 -0
- package/dist/src/lib/invoker-shared-enums.js.map +1 -0
- package/dist/src/lib/json-value.d.ts +6 -0
- package/dist/src/lib/json-value.js +13 -0
- package/dist/src/lib/json-value.js.map +1 -0
- package/dist/src/lib/load-routes.d.ts +33 -0
- package/dist/src/lib/load-routes.js +35 -0
- package/dist/src/lib/load-routes.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +23 -4
- package/dist/src/lib/log-inspection.js +14 -5
- package/dist/src/lib/log-inspection.js.map +1 -1
- package/dist/src/lib/login-exchange-check.d.ts +18 -0
- package/dist/src/lib/login-exchange-check.js +27 -0
- package/dist/src/lib/login-exchange-check.js.map +1 -0
- package/dist/src/lib/login-scope-lines.d.ts +17 -7
- package/dist/src/lib/login-scope-lines.js +33 -10
- package/dist/src/lib/login-scope-lines.js.map +1 -1
- package/dist/src/lib/metadata-report.d.ts +85 -0
- package/dist/src/lib/metadata-report.js +81 -0
- package/dist/src/lib/metadata-report.js.map +1 -0
- package/dist/src/lib/object-status-filter.d.ts +9 -1
- package/dist/src/lib/object-status-filter.js +9 -1
- package/dist/src/lib/object-status-filter.js.map +1 -1
- package/dist/src/lib/output.d.ts +1 -1
- package/dist/src/lib/output.js +3 -1
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/pin-refusal-hint.d.ts +12 -0
- package/dist/src/lib/pin-refusal-hint.js +35 -0
- package/dist/src/lib/pin-refusal-hint.js.map +1 -0
- package/dist/src/lib/platform-owned.js +5 -0
- package/dist/src/lib/platform-owned.js.map +1 -1
- package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
- package/dist/src/lib/primitive-declaration-names.js +22 -0
- package/dist/src/lib/primitive-declaration-names.js.map +1 -0
- package/dist/src/lib/primitive-declaration.d.ts +174 -0
- package/dist/src/lib/primitive-declaration.js +792 -0
- package/dist/src/lib/primitive-declaration.js.map +1 -0
- package/dist/src/lib/primitive-env-plugin.d.ts +99 -0
- package/dist/src/lib/primitive-env-plugin.js +408 -0
- package/dist/src/lib/primitive-env-plugin.js.map +1 -0
- package/dist/src/lib/project-login-apps.d.ts +8 -0
- package/dist/src/lib/project-login-apps.js +27 -0
- package/dist/src/lib/project-login-apps.js.map +1 -0
- package/dist/src/lib/prompt-schema-codegen.d.ts +36 -12
- package/dist/src/lib/prompt-schema-codegen.js +96 -100
- package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
- package/dist/src/lib/prompt-schema-document.d.ts +35 -0
- package/dist/src/lib/prompt-schema-document.js +92 -0
- package/dist/src/lib/prompt-schema-document.js.map +1 -0
- package/dist/src/lib/prompt-schema-refs.d.ts +173 -0
- package/dist/src/lib/prompt-schema-refs.js +478 -0
- package/dist/src/lib/prompt-schema-refs.js.map +1 -0
- package/dist/src/lib/records-verbs.d.ts +79 -0
- package/dist/src/lib/records-verbs.js +45 -0
- package/dist/src/lib/records-verbs.js.map +1 -0
- package/dist/src/lib/register-commands.d.ts +36 -0
- package/dist/src/lib/register-commands.js +37 -0
- package/dist/src/lib/register-commands.js.map +1 -0
- package/dist/src/lib/retired-imports.d.ts +53 -0
- package/dist/src/lib/retired-imports.js +120 -0
- package/dist/src/lib/retired-imports.js.map +1 -0
- package/dist/src/lib/run-status.d.ts +1 -1
- package/dist/src/lib/run-status.generated.d.ts +2 -2
- package/dist/src/lib/run-status.generated.js +3 -1
- package/dist/src/lib/run-status.generated.js.map +1 -1
- package/dist/src/lib/run-status.js +1 -1
- package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
- package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
- package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.js +227 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +218 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.js +397 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
- package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
- package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +258 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +422 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
- package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
- package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
- package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
- package/dist/src/lib/schema-codegen/naming.d.ts +35 -0
- package/dist/src/lib/schema-codegen/naming.js +83 -0
- package/dist/src/lib/schema-codegen/naming.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
- package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
- package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
- package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
- package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
- package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
- package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaToTs.d.ts +109 -0
- package/dist/src/lib/schema-codegen/schemaToTs.js +269 -0
- package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/schema-codegen/valuesLists.d.ts +48 -0
- package/dist/src/lib/schema-codegen/valuesLists.js +144 -0
- package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
- package/dist/src/lib/schema-family-index.d.ts +228 -0
- package/dist/src/lib/schema-family-index.js +813 -0
- package/dist/src/lib/schema-family-index.js.map +1 -0
- package/dist/src/lib/schema-pins.d.ts +82 -0
- package/dist/src/lib/schema-pins.js +198 -0
- package/dist/src/lib/schema-pins.js.map +1 -0
- package/dist/src/lib/schema-preview.d.ts +244 -0
- package/dist/src/lib/schema-preview.js +498 -0
- package/dist/src/lib/schema-preview.js.map +1 -0
- package/dist/src/lib/scope-request.d.ts +23 -11
- package/dist/src/lib/scope-request.js +69 -31
- package/dist/src/lib/scope-request.js.map +1 -1
- package/dist/src/lib/session-scope.d.ts +26 -0
- package/dist/src/lib/session-scope.js +58 -0
- package/dist/src/lib/session-scope.js.map +1 -0
- package/dist/src/lib/skill-installer.d.ts +2 -2
- package/dist/src/lib/skill-installer.js +2 -21
- package/dist/src/lib/skill-installer.js.map +1 -1
- package/dist/src/lib/step-run-table.d.ts +1 -2
- package/dist/src/lib/step-run-table.js +1 -2
- package/dist/src/lib/step-run-table.js.map +1 -1
- package/dist/src/lib/swift-codegen/agentGenerator.d.ts +2 -1
- package/dist/src/lib/swift-codegen/agentGenerator.js +25 -23
- package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
- package/dist/src/lib/swift-codegen/banners.js +12 -0
- package/dist/src/lib/swift-codegen/banners.js.map +1 -1
- package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
- package/dist/src/lib/swift-codegen/functionGenerator.js +169 -51
- package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +33 -9
- package/dist/src/lib/swift-codegen/schemaToSwift.js +215 -179
- package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
- package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +45 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js +165 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/swiftKeys.d.ts +19 -0
- package/dist/src/lib/swift-codegen/swiftKeys.js +31 -0
- package/dist/src/lib/swift-codegen/swiftKeys.js.map +1 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +117 -31
- package/dist/src/lib/sync-resource-types.js +197 -189
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/sync-selectors.d.ts +7 -0
- package/dist/src/lib/sync-selectors.js +22 -2
- package/dist/src/lib/sync-selectors.js.map +1 -1
- package/dist/src/lib/template.d.ts +39 -3
- package/dist/src/lib/template.js +103 -14
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/test-case-file-names.d.ts +3 -5
- package/dist/src/lib/test-case-file-names.js +3 -5
- package/dist/src/lib/test-case-file-names.js.map +1 -1
- package/dist/src/lib/test-runs.d.ts +45 -0
- package/dist/src/lib/test-runs.js +150 -0
- package/dist/src/lib/test-runs.js.map +1 -0
- package/dist/src/lib/test-users.d.ts +25 -0
- package/dist/src/lib/test-users.js +36 -0
- package/dist/src/lib/test-users.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +4 -2
- package/dist/src/lib/toml-database-config.js +11 -6
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/toml-scalar-edit.js +6 -4
- package/dist/src/lib/toml-scalar-edit.js.map +1 -1
- package/dist/src/lib/transition-warnings.d.ts +21 -0
- package/dist/src/lib/transition-warnings.js +49 -0
- package/dist/src/lib/transition-warnings.js.map +1 -0
- package/dist/src/lib/user-index.d.ts +80 -0
- package/dist/src/lib/user-index.js +166 -0
- package/dist/src/lib/user-index.js.map +1 -0
- package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
- package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
- package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
- package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
- package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
- package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
- package/dist/src/lib/user-walk.d.ts +31 -0
- package/dist/src/lib/user-walk.js +102 -0
- package/dist/src/lib/user-walk.js.map +1 -0
- package/dist/src/lib/webhook-capture.d.ts +43 -0
- package/dist/src/lib/webhook-capture.js +91 -0
- package/dist/src/lib/webhook-capture.js.map +1 -0
- package/dist/src/lib/webhook-deliver.d.ts +18 -20
- package/dist/src/lib/webhook-deliver.js +34 -89
- package/dist/src/lib/webhook-deliver.js.map +1 -1
- package/dist/src/lib/webhook-test-run.d.ts +32 -0
- package/dist/src/lib/webhook-test-run.js +108 -0
- package/dist/src/lib/webhook-test-run.js.map +1 -0
- package/dist/src/lib/worker-perf-format.d.ts +22 -0
- package/dist/src/lib/worker-perf-format.js +27 -0
- package/dist/src/lib/worker-perf-format.js.map +1 -0
- package/dist/src/types/index.d.ts +20 -65
- package/dist/src/validators.d.ts +7 -55
- package/dist/src/validators.js +7 -53
- package/dist/src/validators.js.map +1 -1
- package/dist/src/vite.d.ts +17 -0
- package/dist/src/vite.js +18 -0
- package/dist/src/vite.js.map +1 -0
- package/package.json +20 -9
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { commandStatus } from "../lib/command-status.js";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { ApiClient } from "../lib/api-client.js";
|
|
@@ -7,7 +8,9 @@ import { confirmPrompt } from "../lib/confirm-prompt.js";
|
|
|
7
8
|
import { pageCursorOption, pageLimitOption, parsePageLimit, printEmptyPage, printPageHint, } from "../lib/list-options.js";
|
|
8
9
|
import { normalizeCliListEnvelope, wholeListEnvelope, } from "../lib/paginate.js";
|
|
9
10
|
import { resolveOwnerUserId } from "../lib/resolve-owner.js";
|
|
10
|
-
import {
|
|
11
|
+
import { parseCustodianOrExit } from "../lib/custodian.js";
|
|
12
|
+
import { parseCollectionPrincipal, parseCollectionRole } from "../lib/collection-principal.js";
|
|
13
|
+
import { COLLECTION_EXPORT_FILENAME, COLLECTION_EXPORT_VERSION, duplicateNameSources, emptyImportSummary, grantDisposition, grantUpdateLine, sameGrantGroup, groupTargetsByName, importExitCode, planCollection, readCollectionExportFile, rowCustodian, custodianUserId, permissionForRole, serverReason, } from "../lib/collection-export.js";
|
|
11
14
|
export function registerCollectionsCommands(program) {
|
|
12
15
|
const collections = program
|
|
13
16
|
.command("collections")
|
|
@@ -18,14 +21,17 @@ Examples:
|
|
|
18
21
|
$ primitive collections create "Sprint 12"
|
|
19
22
|
$ primitive collections create "Sprint 12" --owner user@example.com
|
|
20
23
|
$ primitive collections get <collection-id>
|
|
24
|
+
$ primitive collections list --custodian user:<user-id>
|
|
25
|
+
$ primitive collections transfer <collection-id> user:<user-id>
|
|
21
26
|
$ primitive collections documents list <collection-id>
|
|
22
27
|
$ primitive collections documents add <collection-id> <document-id>
|
|
23
|
-
$ primitive collections access <collection-id>
|
|
24
|
-
$ primitive collections share <collection-id> --group team/engineering --permission read-write
|
|
25
28
|
$ primitive collections members list <collection-id>
|
|
26
|
-
$ primitive collections members add <collection-id> <user-id> --
|
|
29
|
+
$ primitive collections members add <collection-id> <user-id> --role contributor
|
|
30
|
+
$ primitive collections members add <collection-id> group:<group-id> --role viewer
|
|
31
|
+
$ primitive collections members set-role <collection-id> <user-id> editor
|
|
27
32
|
$ primitive collections for-document <document-id>
|
|
28
33
|
`);
|
|
34
|
+
commandStatus(collections, { stability: "production" });
|
|
29
35
|
// List collections
|
|
30
36
|
collections
|
|
31
37
|
.command("list")
|
|
@@ -34,18 +40,26 @@ Examples:
|
|
|
34
40
|
.argument("[app-id]", "App ID (uses current app if not specified)")
|
|
35
41
|
.option("--app <app-id>", "App ID")
|
|
36
42
|
.option("--all", "List every collection in the app (admin-only). Default is collections you're a direct member of.")
|
|
43
|
+
.option("--custodian <custodian>", 'Only this custodian\'s collections: "app" or "user:<user-id>" (needs an admin token)')
|
|
37
44
|
.addOption(pageLimitOption())
|
|
38
45
|
.addOption(pageCursorOption())
|
|
39
46
|
.option("--json", "Output as JSON")
|
|
40
47
|
.action(async (appId, options) => {
|
|
41
48
|
const limit = parsePageLimit(options.limit);
|
|
49
|
+
const custodian = options.custodian === undefined ? undefined : parseCustodianOrExit(options.custodian, "--custodian");
|
|
50
|
+
if (custodian && options.all) {
|
|
51
|
+
error("--custodian and --all are alternatives; pass one.");
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
42
54
|
const resolvedAppId = resolveAppId(appId, options);
|
|
43
55
|
const client = new ApiClient();
|
|
44
56
|
try {
|
|
45
57
|
const params = { limit, cursor: options.cursor };
|
|
46
|
-
const page = normalizeCliListEnvelope(
|
|
47
|
-
? await client.
|
|
48
|
-
:
|
|
58
|
+
const page = normalizeCliListEnvelope(custodian
|
|
59
|
+
? await client.listCollectionsByCustodian(resolvedAppId, custodian, params)
|
|
60
|
+
: options.all
|
|
61
|
+
? await client.listAllCollections(resolvedAppId, params)
|
|
62
|
+
: await client.listCollections(resolvedAppId, params));
|
|
49
63
|
const list = page.items;
|
|
50
64
|
if (options.json) {
|
|
51
65
|
json(page);
|
|
@@ -63,7 +77,10 @@ Examples:
|
|
|
63
77
|
{ header: "CREATED", key: "createdAt", format: formatDate },
|
|
64
78
|
];
|
|
65
79
|
// `permission` is only returned by the default list() endpoint
|
|
66
|
-
if (
|
|
80
|
+
if (custodian) {
|
|
81
|
+
columns.splice(2, 0, { header: "CUSTODIAN", key: "custodian" });
|
|
82
|
+
}
|
|
83
|
+
else if (!options.all) {
|
|
67
84
|
columns.splice(4, 0, { header: "PERMISSION", key: "permission", format: (v) => v || "—" });
|
|
68
85
|
}
|
|
69
86
|
console.log(formatTable(list, columns));
|
|
@@ -82,25 +99,21 @@ Examples:
|
|
|
82
99
|
// Create collection
|
|
83
100
|
collections
|
|
84
101
|
.command("create")
|
|
85
|
-
.description("Create a new collection")
|
|
102
|
+
.description("Create a new collection, held by the caller or by --owner")
|
|
86
103
|
.argument("<name>", "Collection name")
|
|
87
104
|
.option("--description <description>", "Collection description")
|
|
88
|
-
.option("--initial-metadata <json>", "Create-time resource metadata as JSON, keyed by category name
|
|
105
|
+
.option("--initial-metadata <json>", "Create-time resource metadata as JSON, keyed by category name")
|
|
89
106
|
.option("--app <app-id>", "App ID")
|
|
90
|
-
.option("--owner <userId-or-email>", "
|
|
107
|
+
.option("--owner <userId-or-email>", "The user who holds the collection (its custodian and owner); needs an admin token")
|
|
91
108
|
.option("--json", "Output as JSON")
|
|
92
109
|
.addHelpText("after", `
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
The owner is the collection's creator, so under the default rules they — and
|
|
102
|
-
no other non-admin — can edit it, delete it, and manage its documents and
|
|
103
|
-
members.
|
|
110
|
+
Custody:
|
|
111
|
+
Without --owner the caller holds the new collection: an app user's token
|
|
112
|
+
makes them its custodian and owner; a console admin's token gives the app
|
|
113
|
+
custody.
|
|
114
|
+
With --owner the collection is created through the admin API for that user,
|
|
115
|
+
who becomes its custodian and owner; this needs an admin token assigned to
|
|
116
|
+
the app.
|
|
104
117
|
|
|
105
118
|
An email given to --owner is resolved to a user id before anything is
|
|
106
119
|
created; a user who is not in the app fails the command without creating a
|
|
@@ -111,7 +124,7 @@ Ownership:
|
|
|
111
124
|
const client = new ApiClient();
|
|
112
125
|
// Resolve --owner to a userId through the one shared lookup (#2763),
|
|
113
126
|
// before the create: an email nobody answers to must fail with nothing
|
|
114
|
-
// created
|
|
127
|
+
// created.
|
|
115
128
|
let ownerUserId;
|
|
116
129
|
if (options.owner) {
|
|
117
130
|
try {
|
|
@@ -124,8 +137,6 @@ Ownership:
|
|
|
124
137
|
}
|
|
125
138
|
try {
|
|
126
139
|
const data = { name };
|
|
127
|
-
if (ownerUserId)
|
|
128
|
-
data.createdBy = ownerUserId;
|
|
129
140
|
if (options.description)
|
|
130
141
|
data.description = options.description;
|
|
131
142
|
// Create-time per-category ResourceMetadata rows (issue #1420).
|
|
@@ -138,7 +149,9 @@ Ownership:
|
|
|
138
149
|
process.exit(1);
|
|
139
150
|
}
|
|
140
151
|
}
|
|
141
|
-
const result =
|
|
152
|
+
const result = ownerUserId
|
|
153
|
+
? await client.createCollectionAsAdmin(resolvedAppId, { ...data, custodian: `user:${ownerUserId}` })
|
|
154
|
+
: await client.createCollection(resolvedAppId, data);
|
|
142
155
|
if (options.json) {
|
|
143
156
|
json(result);
|
|
144
157
|
return;
|
|
@@ -146,9 +159,8 @@ Ownership:
|
|
|
146
159
|
success("Collection created.");
|
|
147
160
|
keyValue("Collection ID", result.collectionId);
|
|
148
161
|
keyValue("Name", result.name);
|
|
149
|
-
// Read back from the RESPONSE
|
|
150
|
-
|
|
151
|
-
keyValue("Owner", result.createdBy);
|
|
162
|
+
// Read back from the RESPONSE: who holds it is the server's answer.
|
|
163
|
+
keyValue("Custodian", result.custodian ?? "(none)");
|
|
152
164
|
if (result.description)
|
|
153
165
|
keyValue("Description", result.description);
|
|
154
166
|
}
|
|
@@ -184,6 +196,38 @@ Ownership:
|
|
|
184
196
|
process.exit(1);
|
|
185
197
|
}
|
|
186
198
|
});
|
|
199
|
+
// Transfer collection
|
|
200
|
+
collections
|
|
201
|
+
.command("transfer")
|
|
202
|
+
.description("Transfer a collection to another user or to the app")
|
|
203
|
+
.argument("<collection-id>", "Collection ID")
|
|
204
|
+
.argument("<custodian>", '"user:<user-id>" (a member of the app) or "app"')
|
|
205
|
+
.option("--app <app-id>", "App ID")
|
|
206
|
+
.option("--json", "Output as JSON")
|
|
207
|
+
.allowExcessArguments(false)
|
|
208
|
+
.addHelpText("after", `
|
|
209
|
+
The custodian and the owner row move together: the new custodian holds the
|
|
210
|
+
owner role, the previous owner stays as a manager (or, moving to the app,
|
|
211
|
+
loses the owner row), and no other role changes.
|
|
212
|
+
`)
|
|
213
|
+
.action(async (collectionId, custodianArg, options) => {
|
|
214
|
+
const to = parseCustodianOrExit(custodianArg, "custodian");
|
|
215
|
+
const resolvedAppId = resolveAppId(undefined, options);
|
|
216
|
+
const client = new ApiClient();
|
|
217
|
+
try {
|
|
218
|
+
const result = await client.transferCollection(resolvedAppId, collectionId, to);
|
|
219
|
+
if (options.json) {
|
|
220
|
+
json(result);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
success(`Collection ${collectionId} transferred.`);
|
|
224
|
+
printResult("Custodian", result.custodian);
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
error(err.message);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
187
231
|
// Update collection
|
|
188
232
|
collections
|
|
189
233
|
.command("update")
|
|
@@ -259,130 +303,6 @@ Ownership:
|
|
|
259
303
|
process.exit(1);
|
|
260
304
|
}
|
|
261
305
|
});
|
|
262
|
-
// ---- Access command ----
|
|
263
|
-
collections
|
|
264
|
-
.command("access")
|
|
265
|
-
.description("Combined view of the groups and members with access to a collection " +
|
|
266
|
-
"(members only: 'collections members list'; group grants: 'collections share'/'unshare')")
|
|
267
|
-
.argument("<collection-id>", "Collection ID")
|
|
268
|
-
.option("--app <app-id>", "App ID")
|
|
269
|
-
.option("--json", "Output as JSON")
|
|
270
|
-
.action(async (collectionId, options) => {
|
|
271
|
-
const resolvedAppId = resolveAppId(undefined, options);
|
|
272
|
-
const client = new ApiClient();
|
|
273
|
-
try {
|
|
274
|
-
const result = await client.getCollectionAccess(resolvedAppId, collectionId);
|
|
275
|
-
if (options.json) {
|
|
276
|
-
json(result);
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
const groups = result.groups || [];
|
|
280
|
-
const members = result.members || [];
|
|
281
|
-
if (groups.length === 0 && members.length === 0) {
|
|
282
|
-
info("No groups or members have access to this collection.");
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
if (groups.length > 0) {
|
|
286
|
-
console.log("\nGroups:");
|
|
287
|
-
console.log(formatTable(groups, [
|
|
288
|
-
{ header: "TYPE", key: "groupType" },
|
|
289
|
-
{ header: "ID", key: "groupId" },
|
|
290
|
-
{ header: "PERMISSION", key: "permission" },
|
|
291
|
-
{ header: "GRANTED", key: "grantedAt", format: formatDate },
|
|
292
|
-
]));
|
|
293
|
-
}
|
|
294
|
-
if (members.length > 0) {
|
|
295
|
-
console.log("\nMembers:");
|
|
296
|
-
console.log(formatTable(members, [
|
|
297
|
-
{ header: "USER_ID", key: "userId", format: formatId },
|
|
298
|
-
{ header: "PERMISSION", key: "permission" },
|
|
299
|
-
]));
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
catch (err) {
|
|
303
|
-
error(err.message);
|
|
304
|
-
process.exit(1);
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
// ---- Share / unshare (group permissions) ----
|
|
308
|
-
collections
|
|
309
|
-
.command("share")
|
|
310
|
-
.description("Grant a group access to a collection")
|
|
311
|
-
.argument("<collection-id>", "Collection ID")
|
|
312
|
-
.requiredOption("--group <group>", "Group in format type/id (e.g. team/engineering)")
|
|
313
|
-
.requiredOption("--permission <permission>", "Permission level (reader or read-write)")
|
|
314
|
-
.option("--app <app-id>", "App ID")
|
|
315
|
-
.option("--json", "Output as JSON")
|
|
316
|
-
.action(async (collectionId, options) => {
|
|
317
|
-
const resolvedAppId = resolveAppId(undefined, options);
|
|
318
|
-
const client = new ApiClient();
|
|
319
|
-
const parts = options.group.split("/");
|
|
320
|
-
if (parts.length !== 2) {
|
|
321
|
-
error("Group must be in format type/id (e.g. team/engineering).");
|
|
322
|
-
process.exit(1);
|
|
323
|
-
}
|
|
324
|
-
const [groupType, groupId] = parts;
|
|
325
|
-
try {
|
|
326
|
-
const result = await client.grantCollectionGroupPermission(resolvedAppId, collectionId, {
|
|
327
|
-
groupType,
|
|
328
|
-
groupId,
|
|
329
|
-
permission: options.permission,
|
|
330
|
-
});
|
|
331
|
-
if (options.json) {
|
|
332
|
-
json(result);
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
success(`Granted ${options.permission} access to ${groupType}/${groupId} on collection.`);
|
|
336
|
-
}
|
|
337
|
-
catch (err) {
|
|
338
|
-
error(err.message);
|
|
339
|
-
process.exit(1);
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
collections
|
|
343
|
-
.command("unshare")
|
|
344
|
-
.description("Revoke a group's access to a collection")
|
|
345
|
-
.argument("<collection-id>", "Collection ID")
|
|
346
|
-
.requiredOption("--group <group>", "Group in format type/id (e.g. team/engineering)")
|
|
347
|
-
.option("--app <app-id>", "App ID")
|
|
348
|
-
.option("-y, --yes", "Skip confirmation prompt")
|
|
349
|
-
.option("--json", "Output as JSON")
|
|
350
|
-
.action(async (collectionId, options) => {
|
|
351
|
-
const resolvedAppId = resolveAppId(undefined, options);
|
|
352
|
-
const parts = options.group.split("/");
|
|
353
|
-
if (parts.length !== 2) {
|
|
354
|
-
error("Group must be in format type/id (e.g. team/engineering).");
|
|
355
|
-
process.exit(1);
|
|
356
|
-
}
|
|
357
|
-
const [groupType, groupId] = parts;
|
|
358
|
-
if (!options.yes) {
|
|
359
|
-
let confirm;
|
|
360
|
-
try {
|
|
361
|
-
confirm = await confirmPrompt(`Revoke ${groupType}/${groupId} access to collection ${collectionId}?`);
|
|
362
|
-
}
|
|
363
|
-
catch (err) {
|
|
364
|
-
error(err.message);
|
|
365
|
-
process.exit(1);
|
|
366
|
-
}
|
|
367
|
-
if (!confirm) {
|
|
368
|
-
info("Cancelled.");
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
const client = new ApiClient();
|
|
373
|
-
try {
|
|
374
|
-
await client.revokeCollectionGroupPermission(resolvedAppId, collectionId, groupType, groupId);
|
|
375
|
-
if (options.json) {
|
|
376
|
-
json({ success: true, collectionId, groupType, groupId });
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
success(`Revoked ${groupType}/${groupId} access from collection.`);
|
|
380
|
-
}
|
|
381
|
-
catch (err) {
|
|
382
|
-
error(err.message);
|
|
383
|
-
process.exit(1);
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
306
|
// ---- Documents subcommand group ----
|
|
387
307
|
const documents = collections
|
|
388
308
|
.command("documents")
|
|
@@ -526,18 +446,17 @@ Ownership:
|
|
|
526
446
|
}
|
|
527
447
|
});
|
|
528
448
|
// ---- Members subcommand group ----
|
|
449
|
+
//
|
|
450
|
+
// The one home for who holds a role on a collection: users and groups,
|
|
451
|
+
// addressed as principals (`<user-id>`, `group:<group-id>`). Writes go
|
|
452
|
+
// through the admin API, as the console's do, so the owner row can be
|
|
453
|
+
// restored and demoted from here.
|
|
529
454
|
const members = collections
|
|
530
455
|
.command("members")
|
|
531
|
-
.description("Manage
|
|
532
|
-
// List members
|
|
533
|
-
//
|
|
534
|
-
// The server has no GET /collections/:id/members route — membership is read
|
|
535
|
-
// from the access endpoint, which returns groups and members together. This
|
|
536
|
-
// command is the members half of it, so reading "who is on this collection"
|
|
537
|
-
// doesn't require knowing about a command named for neither (#2764).
|
|
456
|
+
.description("Manage a collection's members — users and groups — and their roles");
|
|
538
457
|
members
|
|
539
458
|
.command("list")
|
|
540
|
-
.description("List users
|
|
459
|
+
.description("List a collection's members, users and groups, with their roles")
|
|
541
460
|
.argument("<collection-id>", "Collection ID")
|
|
542
461
|
.option("--app <app-id>", "App ID")
|
|
543
462
|
.option("--json", "Output as JSON")
|
|
@@ -545,21 +464,20 @@ Ownership:
|
|
|
545
464
|
const resolvedAppId = resolveAppId(undefined, options);
|
|
546
465
|
const client = new ApiClient();
|
|
547
466
|
try {
|
|
548
|
-
const
|
|
549
|
-
const list = result.members ?? [];
|
|
467
|
+
const { items } = await client.listCollectionMembers(resolvedAppId, collectionId);
|
|
550
468
|
if (options.json) {
|
|
551
|
-
// The
|
|
552
|
-
|
|
553
|
-
json(wholeListEnvelope(list));
|
|
469
|
+
// The whole membership, in the one list envelope (#3646).
|
|
470
|
+
json(wholeListEnvelope(items));
|
|
554
471
|
return;
|
|
555
472
|
}
|
|
556
|
-
if (
|
|
557
|
-
info("No
|
|
473
|
+
if (items.length === 0) {
|
|
474
|
+
info("No user or group holds a role on this collection.");
|
|
558
475
|
return;
|
|
559
476
|
}
|
|
560
|
-
console.log(formatTable(
|
|
561
|
-
{ header: "
|
|
562
|
-
{ header: "
|
|
477
|
+
console.log(formatTable(items, [
|
|
478
|
+
{ header: "PRINCIPAL", key: "principal" },
|
|
479
|
+
{ header: "ROLE", key: "role" },
|
|
480
|
+
{ header: "ADDED", key: "addedAt", format: formatDate },
|
|
563
481
|
]));
|
|
564
482
|
}
|
|
565
483
|
catch (err) {
|
|
@@ -567,49 +485,97 @@ Ownership:
|
|
|
567
485
|
process.exit(1);
|
|
568
486
|
}
|
|
569
487
|
});
|
|
570
|
-
// Add member
|
|
571
488
|
members
|
|
572
489
|
.command("add")
|
|
573
|
-
.description("
|
|
490
|
+
.description("Give a user or a group a role on a collection")
|
|
574
491
|
.argument("<collection-id>", "Collection ID")
|
|
575
|
-
.argument("<
|
|
576
|
-
.requiredOption("--
|
|
492
|
+
.argument("<principal>", "A user id, or group:<group-id>")
|
|
493
|
+
.requiredOption("--role <role>", "viewer, contributor, editor or manager (a group holds up to manager); owner restores the custodian's owner row")
|
|
577
494
|
.option("--app <app-id>", "App ID")
|
|
578
495
|
.option("--json", "Output as JSON")
|
|
579
|
-
.
|
|
496
|
+
.allowExcessArguments(false)
|
|
497
|
+
.action(async (collectionId, principalArg, options) => {
|
|
498
|
+
let principal;
|
|
499
|
+
let role;
|
|
500
|
+
try {
|
|
501
|
+
principal = parseCollectionPrincipal(principalArg);
|
|
502
|
+
role = parseCollectionRole(options.role);
|
|
503
|
+
}
|
|
504
|
+
catch (err) {
|
|
505
|
+
error(err.message);
|
|
506
|
+
process.exit(1);
|
|
507
|
+
}
|
|
580
508
|
const resolvedAppId = resolveAppId(undefined, options);
|
|
581
509
|
const client = new ApiClient();
|
|
582
510
|
try {
|
|
583
|
-
const result = await client.addCollectionMember(resolvedAppId, collectionId, {
|
|
584
|
-
userId,
|
|
585
|
-
permission: options.permission,
|
|
586
|
-
});
|
|
511
|
+
const result = await client.addCollectionMember(resolvedAppId, collectionId, { ...principal, role: role });
|
|
587
512
|
if (options.json) {
|
|
588
513
|
json(result);
|
|
589
514
|
return;
|
|
590
515
|
}
|
|
591
|
-
success(
|
|
516
|
+
success(`${principalArg} holds ${result.role ?? role} on collection ${collectionId}.`);
|
|
517
|
+
}
|
|
518
|
+
catch (err) {
|
|
519
|
+
error(err.message);
|
|
520
|
+
process.exit(1);
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
members
|
|
524
|
+
.command("set-role")
|
|
525
|
+
.description("Change a collection member's role")
|
|
526
|
+
.argument("<collection-id>", "Collection ID")
|
|
527
|
+
.argument("<principal>", "A user id, or group:<group-id>")
|
|
528
|
+
.argument("<role>", "owner, manager, editor, contributor or viewer")
|
|
529
|
+
.option("--app <app-id>", "App ID")
|
|
530
|
+
.option("--json", "Output as JSON")
|
|
531
|
+
.allowExcessArguments(false)
|
|
532
|
+
.action(async (collectionId, principalArg, roleArg, options) => {
|
|
533
|
+
let role;
|
|
534
|
+
try {
|
|
535
|
+
parseCollectionPrincipal(principalArg);
|
|
536
|
+
role = parseCollectionRole(roleArg);
|
|
537
|
+
}
|
|
538
|
+
catch (err) {
|
|
539
|
+
error(err.message);
|
|
540
|
+
process.exit(1);
|
|
541
|
+
}
|
|
542
|
+
const resolvedAppId = resolveAppId(undefined, options);
|
|
543
|
+
const client = new ApiClient();
|
|
544
|
+
try {
|
|
545
|
+
const result = await client.setCollectionMemberRole(resolvedAppId, collectionId, principalArg, role);
|
|
546
|
+
if (options.json) {
|
|
547
|
+
json(result);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
success(`${principalArg} is now ${result.role ?? role} on collection ${collectionId}.`);
|
|
592
551
|
}
|
|
593
552
|
catch (err) {
|
|
594
553
|
error(err.message);
|
|
595
554
|
process.exit(1);
|
|
596
555
|
}
|
|
597
556
|
});
|
|
598
|
-
// Remove member
|
|
599
557
|
members
|
|
600
558
|
.command("remove")
|
|
601
|
-
.description("Remove a user from a collection")
|
|
559
|
+
.description("Remove a user or a group from a collection")
|
|
602
560
|
.argument("<collection-id>", "Collection ID")
|
|
603
|
-
.argument("<
|
|
561
|
+
.argument("<principal>", "A user id, or group:<group-id>")
|
|
604
562
|
.option("--app <app-id>", "App ID")
|
|
605
563
|
.option("-y, --yes", "Skip confirmation prompt")
|
|
606
564
|
.option("--json", "Output as JSON")
|
|
607
|
-
.
|
|
565
|
+
.allowExcessArguments(false)
|
|
566
|
+
.action(async (collectionId, principalArg, options) => {
|
|
567
|
+
try {
|
|
568
|
+
parseCollectionPrincipal(principalArg);
|
|
569
|
+
}
|
|
570
|
+
catch (err) {
|
|
571
|
+
error(err.message);
|
|
572
|
+
process.exit(1);
|
|
573
|
+
}
|
|
608
574
|
const resolvedAppId = resolveAppId(undefined, options);
|
|
609
575
|
if (!options.yes) {
|
|
610
576
|
let confirm;
|
|
611
577
|
try {
|
|
612
|
-
confirm = await confirmPrompt(`Remove
|
|
578
|
+
confirm = await confirmPrompt(`Remove ${principalArg} from collection ${collectionId}?`);
|
|
613
579
|
}
|
|
614
580
|
catch (err) {
|
|
615
581
|
error(err.message);
|
|
@@ -622,12 +588,12 @@ Ownership:
|
|
|
622
588
|
}
|
|
623
589
|
const client = new ApiClient();
|
|
624
590
|
try {
|
|
625
|
-
await client.removeCollectionMember(resolvedAppId, collectionId,
|
|
591
|
+
await client.removeCollectionMember(resolvedAppId, collectionId, principalArg);
|
|
626
592
|
if (options.json) {
|
|
627
|
-
json({ success: true, collectionId,
|
|
593
|
+
json({ success: true, collectionId, principal: principalArg });
|
|
628
594
|
return;
|
|
629
595
|
}
|
|
630
|
-
success(
|
|
596
|
+
success(`${principalArg} removed from collection.`);
|
|
631
597
|
}
|
|
632
598
|
catch (err) {
|
|
633
599
|
error(err.message);
|
|
@@ -648,12 +614,13 @@ Ownership:
|
|
|
648
614
|
* whole app. Owner and member identities travel as EMAILS wherever the server
|
|
649
615
|
* can resolve one: users are app-scoped (`models.yaml`), so the same person is
|
|
650
616
|
* a different userId in every app and a recorded source userId means nothing
|
|
651
|
-
* in the target.
|
|
617
|
+
* in the target. Custody and roles travel as they are: `app` or the owner,
|
|
618
|
+
* and each member's and group's role.
|
|
652
619
|
*/
|
|
653
620
|
function registerCollectionsExport(collections) {
|
|
654
621
|
collections
|
|
655
622
|
.command("export")
|
|
656
|
-
.description("Export every collection in an app (name,
|
|
623
|
+
.description("Export every collection in an app (name, custodian, members and groups with roles, documents)")
|
|
657
624
|
.option("--app <app-id>", "App ID")
|
|
658
625
|
.option("--output <dir>", "Output directory", "./primitive-export")
|
|
659
626
|
.option("--json", "Output as JSON")
|
|
@@ -665,6 +632,9 @@ that 'documents export-all' writes, so one directory is one app's migration.
|
|
|
665
632
|
Import it with 'primitive collections import' AFTER 'documents import', which
|
|
666
633
|
preserves document ids.
|
|
667
634
|
|
|
635
|
+
The file records each collection's custodian (the app, or the user holding
|
|
636
|
+
the owner row), its settings, and every member's and group's role.
|
|
637
|
+
|
|
668
638
|
Owner and member identities are recorded as emails wherever the server can
|
|
669
639
|
resolve one — users are app-scoped, so a source app's userId means nothing in
|
|
670
640
|
the target. A userId with no resolvable email is recorded as-is and will only
|
|
@@ -750,30 +720,34 @@ async function exportCollections(client, appId, options) {
|
|
|
750
720
|
const collectionId = row.collectionId;
|
|
751
721
|
try {
|
|
752
722
|
const documents = await readAllCollectionDocuments(client, appId, collectionId);
|
|
753
|
-
const
|
|
723
|
+
const roster = await client.listCollectionMembers(appId, collectionId);
|
|
754
724
|
const members = [];
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
725
|
+
const groups = [];
|
|
726
|
+
for (const m of roster.items) {
|
|
727
|
+
// `permission` and `groupType` stay beside `role`: a CLI written
|
|
728
|
+
// before roles reads them, and a group written before the role model
|
|
729
|
+
// resolves only with its type.
|
|
730
|
+
const permission = m.permission ?? permissionForRole(m.role);
|
|
731
|
+
if (m.groupId) {
|
|
732
|
+
// The server already leaves system groups out of the member list.
|
|
733
|
+
groups.push({ groupType: m.groupType, groupId: m.groupId, permission, role: m.role });
|
|
734
|
+
}
|
|
735
|
+
else if (m.userId) {
|
|
736
|
+
members.push({ ...(await identity(m.userId)), permission, role: m.role });
|
|
737
|
+
}
|
|
760
738
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
.filter((g) => !String(g.groupType).startsWith("_"))
|
|
765
|
-
.map((g) => ({
|
|
766
|
-
groupType: g.groupType,
|
|
767
|
-
groupId: g.groupId,
|
|
768
|
-
permission: g.permission,
|
|
769
|
-
}));
|
|
739
|
+
// A row created before custody has none (null); its creator holds the
|
|
740
|
+
// owner row and is recorded as the owner.
|
|
741
|
+
const ownerUserId = custodianUserId(rowCustodian(row));
|
|
770
742
|
exported.push({
|
|
771
743
|
collectionId,
|
|
772
744
|
name: row.name,
|
|
773
745
|
description: row.description ?? null,
|
|
774
746
|
collectionType: row.collectionType ?? null,
|
|
775
747
|
createdAt: row.createdAt ?? null,
|
|
776
|
-
|
|
748
|
+
custodian: typeof row.custodian === "string" && row.custodian ? row.custodian : null,
|
|
749
|
+
owner: ownerUserId ? await identity(ownerUserId) : null,
|
|
750
|
+
settings: row.settings ?? null,
|
|
777
751
|
documents,
|
|
778
752
|
members,
|
|
779
753
|
groups,
|
|
@@ -845,21 +819,34 @@ async function exportCollections(client, appId, options) {
|
|
|
845
819
|
* go first ON PURPOSE: `addDocument` materializes every existing grant
|
|
846
820
|
* onto a newly added document, so a fresh collection's access never
|
|
847
821
|
* depends on the grant's own fan-out over the document list (F4).
|
|
822
|
+
*
|
|
823
|
+
* A collection is created through the admin route with its custodian — the
|
|
824
|
+
* owner resolved by email, or the app — so the server writes the owner row;
|
|
825
|
+
* members and groups are then replayed by role through the admin member
|
|
826
|
+
* route (#4731).
|
|
848
827
|
*/
|
|
849
828
|
function registerCollectionsImport(collections) {
|
|
850
829
|
collections
|
|
851
830
|
.command("import")
|
|
852
|
-
.description("Recreate collections from a collections.json export (
|
|
831
|
+
.description("Recreate collections from a collections.json export (custodian, members and groups with roles, documents)")
|
|
853
832
|
.argument("<path>", "Export directory holding collections.json, or the file itself")
|
|
854
833
|
.option("--app <app-id>", "App ID")
|
|
855
|
-
.option("--owner <userId-or-email>", "
|
|
834
|
+
.option("--owner <userId-or-email>", "Give every imported collection this user as custodian and owner, instead of the custodian each one records")
|
|
856
835
|
.option("--overwrite", "Merge into a collection that already carries the same name")
|
|
857
836
|
.option("--dry-run", "Show the plan and the problems without writing anything")
|
|
858
837
|
.option("--json", "Output as JSON")
|
|
859
838
|
.addHelpText("after", `
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
839
|
+
Needs an admin token assigned to the app, checked before anything is read or
|
|
840
|
+
written: each collection is created through the admin API with the custodian
|
|
841
|
+
the file records — the app, or the owner, who holds the owner row — and
|
|
842
|
+
members and groups are added at the role the file records, through the admin
|
|
843
|
+
member routes. The custodian's own row follows the file too: a role below
|
|
844
|
+
owner is replayed, and a newly created collection whose file records no row
|
|
845
|
+
for its custodian has the owner row removed again. A member recorded as owner
|
|
846
|
+
who is not the custodian (with --owner, the recorded owner) is reported as an
|
|
847
|
+
'owner' problem and not imported. A file written before roles is read with
|
|
848
|
+
reader as viewer and read-write as editor, and its owner's own read-write row
|
|
849
|
+
as the owner row.
|
|
863
850
|
|
|
864
851
|
Run 'primitive documents import' FIRST: it preserves document ids, which is
|
|
865
852
|
what the collections file refers to.
|
|
@@ -869,16 +856,16 @@ app's userId means nothing here. A recorded userId is used only when the file
|
|
|
869
856
|
came from this same app.
|
|
870
857
|
|
|
871
858
|
Matching is by name. Without --overwrite a name already in the target is
|
|
872
|
-
skipped; with it, the collection is merged — but only when its
|
|
873
|
-
|
|
859
|
+
skipped; with it, the collection is merged — but only when its custodian and
|
|
860
|
+
type match, since neither can be changed by a merge.
|
|
874
861
|
A name more than one collection in the target carries is ambiguous: that
|
|
875
862
|
collection is refused as a 'collection' problem naming every matching id, with
|
|
876
863
|
or without --overwrite, and nothing is written for it. A name repeated inside
|
|
877
864
|
the file is refused for the second and later occurrences, since matching by
|
|
878
865
|
name could not tell them apart.
|
|
879
866
|
|
|
880
|
-
A group
|
|
881
|
-
the file records, and what the group can reach follows the change. On a
|
|
867
|
+
A group or member the target already holds at another role is UPDATED to the
|
|
868
|
+
role the file records, and what the group can reach follows the change. On a
|
|
882
869
|
collection holding more than 200 documents the server refuses a collection-wide
|
|
883
870
|
group change whole (COLLECTION_FANOUT_LIMIT): that is reported as a 'group'
|
|
884
871
|
problem, and the rest of the collection is still merged.
|
|
@@ -905,8 +892,39 @@ Exit code 1 when any per-item problem was reported. A skip is not a problem.
|
|
|
905
892
|
function isNotFound(err) {
|
|
906
893
|
return err?.statusCode === 404;
|
|
907
894
|
}
|
|
895
|
+
/**
|
|
896
|
+
* The recorded type of a grant's group, sent beside its id: a group written
|
|
897
|
+
* before the role model carries no public id, and resolves only by its type.
|
|
898
|
+
*/
|
|
899
|
+
function groupTypeOf(grant) {
|
|
900
|
+
return grant.groupType ? { groupType: grant.groupType } : {};
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* The import's writes all go through the admin API, so an app user's token —
|
|
904
|
+
* the app owner's included — could apply only part of a file (a merge's
|
|
905
|
+
* documents through the app route, and nothing else). Refused before any read
|
|
906
|
+
* of the target app (E14). The probe is one row of an admin-API read on the
|
|
907
|
+
* app, behind the same app-assignment gate as the admin create.
|
|
908
|
+
*/
|
|
909
|
+
async function requireAdminAppAccess(client, appId) {
|
|
910
|
+
try {
|
|
911
|
+
await client.listGroupsByCustodian(appId, "app", { limit: 1 });
|
|
912
|
+
}
|
|
913
|
+
catch (err) {
|
|
914
|
+
const status = err?.statusCode;
|
|
915
|
+
if (status === 401 || status === 403 || status === 404) {
|
|
916
|
+
throw new Error(`collections import needs an admin token assigned to app ${appId}: it ` +
|
|
917
|
+
`creates collections and replays members through the admin API ` +
|
|
918
|
+
`(${serverReason(err)}). Log in as an admin of the app and re-run. ` +
|
|
919
|
+
`Nothing has been written.`);
|
|
920
|
+
}
|
|
921
|
+
throw new Error(`Checking admin access to app ${appId} failed: ${err?.message ?? err}. ` +
|
|
922
|
+
`Nothing has been written.`);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
908
925
|
async function importCollections(client, appId, importPath, options) {
|
|
909
926
|
const file = readCollectionExportFile(importPath);
|
|
927
|
+
await requireAdminAppAccess(client, appId);
|
|
910
928
|
// A file exported before the platform removed collection `contextId` (#3926)
|
|
911
929
|
// still carries it. Said once for the run, on stderr, and never sent: the
|
|
912
930
|
// server refuses the key, and the binding belongs in a metadata category.
|
|
@@ -1033,7 +1051,9 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1033
1051
|
};
|
|
1034
1052
|
let ownerUserId = explicitOwnerUserId ?? null;
|
|
1035
1053
|
let ownerReason;
|
|
1036
|
-
|
|
1054
|
+
// App custody needs no owner; `--owner` gives every collection one.
|
|
1055
|
+
const appCustody = !explicitOwnerUserId && source.custodian === "app";
|
|
1056
|
+
if (!ownerUserId && !appCustody) {
|
|
1037
1057
|
try {
|
|
1038
1058
|
const resolved = await resolveIdentity(source.owner);
|
|
1039
1059
|
ownerUserId = resolved.userId;
|
|
@@ -1047,6 +1067,7 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1047
1067
|
const row = planCollection(source, {
|
|
1048
1068
|
ownerUserId,
|
|
1049
1069
|
ownerReason,
|
|
1070
|
+
appCustody,
|
|
1050
1071
|
existing: matches.length === 1 ? matches[0] : null,
|
|
1051
1072
|
ambiguousTargetIds: matches.length > 1 ? matches.map((m) => m.collectionId) : null,
|
|
1052
1073
|
duplicateOfSourceId: duplicates.get(source.collectionId) ?? null,
|
|
@@ -1058,33 +1079,36 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1058
1079
|
planned.push({ row, source, grants: [], members: [], documents: [] });
|
|
1059
1080
|
continue;
|
|
1060
1081
|
}
|
|
1061
|
-
// What the target already grants, so a merge can compare
|
|
1082
|
+
// What the target already grants, so a merge can compare roles.
|
|
1062
1083
|
let targetGrants = [];
|
|
1063
1084
|
if (row.action === "merge" && row.targetCollectionId) {
|
|
1064
1085
|
try {
|
|
1065
|
-
const
|
|
1066
|
-
targetGrants =
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1086
|
+
const roster = await client.listCollectionMembers(appId, row.targetCollectionId);
|
|
1087
|
+
targetGrants = roster.items
|
|
1088
|
+
.filter((m) => m.groupId)
|
|
1089
|
+
.map((m) => ({
|
|
1090
|
+
groupId: m.groupId,
|
|
1091
|
+
...(m.groupType ? { groupType: m.groupType } : {}),
|
|
1092
|
+
role: m.role,
|
|
1070
1093
|
}));
|
|
1071
1094
|
}
|
|
1072
1095
|
catch (err) {
|
|
1073
|
-
fatal(`the
|
|
1096
|
+
fatal(`the members of ${row.targetCollectionId}`, err);
|
|
1074
1097
|
}
|
|
1075
1098
|
}
|
|
1076
1099
|
const grants = [];
|
|
1077
1100
|
for (const grant of source.groups ?? []) {
|
|
1078
|
-
const label =
|
|
1079
|
-
// The server reserves the `_` prefix for its own system
|
|
1080
|
-
// export never writes one, and re-granting one is a 400.
|
|
1081
|
-
|
|
1082
|
-
|
|
1101
|
+
const label = `group:${grant.groupId}`;
|
|
1102
|
+
// The server reserves the `_` group-type prefix for its own system
|
|
1103
|
+
// groups; an export never writes one, and re-granting one is a 400. A
|
|
1104
|
+
// group id may start with `_` (only the type is reserved).
|
|
1105
|
+
if (String(grant.groupType ?? "").startsWith("_")) {
|
|
1106
|
+
warn(`${source.name}: skipping the reserved group ${grant.groupType ? `type ${grant.groupType} ` : ""}` +
|
|
1083
1107
|
`(${label}); the server manages those itself.`);
|
|
1084
1108
|
continue;
|
|
1085
1109
|
}
|
|
1086
1110
|
try {
|
|
1087
|
-
await client.getGroup(appId, grant.
|
|
1111
|
+
await client.getGroup(appId, grant.groupId, groupTypeOf(grant));
|
|
1088
1112
|
}
|
|
1089
1113
|
catch (err) {
|
|
1090
1114
|
if (isNotFound(err)) {
|
|
@@ -1094,14 +1118,16 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1094
1118
|
fatal(`group ${label}`, err);
|
|
1095
1119
|
}
|
|
1096
1120
|
const disposition = grantDisposition(grant, targetGrants);
|
|
1097
|
-
const existing = targetGrants.find((g) => g
|
|
1121
|
+
const existing = targetGrants.find((g) => sameGrantGroup(g, grant));
|
|
1098
1122
|
grants.push({
|
|
1099
1123
|
grant,
|
|
1100
1124
|
disposition,
|
|
1101
|
-
...(existing ? {
|
|
1125
|
+
...(existing ? { existingRole: existing.role } : {}),
|
|
1102
1126
|
});
|
|
1103
1127
|
}
|
|
1128
|
+
const custodianUser = row.custodian ? custodianUserId(row.custodian) : null;
|
|
1104
1129
|
const members = [];
|
|
1130
|
+
let custodianRecorded = false;
|
|
1105
1131
|
for (const member of source.members ?? []) {
|
|
1106
1132
|
let resolved;
|
|
1107
1133
|
try {
|
|
@@ -1115,8 +1141,32 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1115
1141
|
note("member", resolved.id, resolved.reason);
|
|
1116
1142
|
continue;
|
|
1117
1143
|
}
|
|
1118
|
-
|
|
1144
|
+
if (resolved.userId === custodianUser) {
|
|
1145
|
+
// The custodian's own row is replayed as the file records it: a role
|
|
1146
|
+
// below owner demotes the owner row custody wrote, and on a merge an
|
|
1147
|
+
// owner entry restores it. A create's owner entry is already written.
|
|
1148
|
+
custodianRecorded = true;
|
|
1149
|
+
if (row.action === "create" && member.role === "owner")
|
|
1150
|
+
continue;
|
|
1151
|
+
members.push({ userId: resolved.userId, role: member.role });
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
if (member.role === "owner") {
|
|
1155
|
+
// The owner row is the custodian's alone; anyone else recorded as
|
|
1156
|
+
// owner is invalid data, reported rather than granted another role.
|
|
1157
|
+
note("owner", resolved.id, `recorded as owner, but the owner row belongs to the custodian ` +
|
|
1158
|
+
`(${row.custodian}); not imported`);
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
members.push({ userId: resolved.userId, role: member.role });
|
|
1119
1162
|
}
|
|
1163
|
+
// A user custodian the file records no row for had it removed in the
|
|
1164
|
+
// source; a create writes one, so it goes again. `--owner` names a new
|
|
1165
|
+
// custodian the file cannot speak for, and a merge leaves rows it does not
|
|
1166
|
+
// record alone.
|
|
1167
|
+
const removeOwnerRowOf = row.action === "create" && custodianUser && !custodianRecorded && !explicitOwnerUserId
|
|
1168
|
+
? custodianUser
|
|
1169
|
+
: undefined;
|
|
1120
1170
|
const documents = [];
|
|
1121
1171
|
for (const document of source.documents ?? []) {
|
|
1122
1172
|
try {
|
|
@@ -1132,7 +1182,7 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1132
1182
|
}
|
|
1133
1183
|
documents.push(document.documentId);
|
|
1134
1184
|
}
|
|
1135
|
-
planned.push({ row, source, grants, members, documents });
|
|
1185
|
+
planned.push({ row, source, grants, members, ...(removeOwnerRowOf ? { removeOwnerRowOf } : {}), documents });
|
|
1136
1186
|
}
|
|
1137
1187
|
// ── Apply phase ────────────────────────────────────────────────────────
|
|
1138
1188
|
for (const entry of planned) {
|
|
@@ -1167,38 +1217,41 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1167
1217
|
summary.merged += 1;
|
|
1168
1218
|
info(`[dry-run] Would merge ${source.name} into ${row.targetCollectionId}`);
|
|
1169
1219
|
}
|
|
1170
|
-
for (const { grant, disposition,
|
|
1220
|
+
for (const { grant, disposition, existingRole } of entry.grants) {
|
|
1171
1221
|
if (disposition === "already-applied")
|
|
1172
1222
|
continue;
|
|
1173
|
-
const label =
|
|
1223
|
+
const label = `group:${grant.groupId}`;
|
|
1174
1224
|
info(disposition === "update"
|
|
1175
|
-
? `[dry-run] Would update ${grantUpdateLine(label,
|
|
1176
|
-
: `[dry-run] Would grant ${label} ${grant.
|
|
1225
|
+
? `[dry-run] Would update ${grantUpdateLine(label, existingRole, grant.role)}`
|
|
1226
|
+
: `[dry-run] Would grant ${label} ${grant.role}`);
|
|
1177
1227
|
summary.groupsGranted += 1;
|
|
1178
1228
|
}
|
|
1179
1229
|
summary.membersAdded += entry.members.length;
|
|
1230
|
+
if (entry.removeOwnerRowOf) {
|
|
1231
|
+
info(`[dry-run] Would remove the owner row of ${entry.removeOwnerRowOf} ` +
|
|
1232
|
+
`(the export records no membership for the custodian)`);
|
|
1233
|
+
}
|
|
1180
1234
|
summary.documentsAdded += entry.documents.length;
|
|
1181
1235
|
continue;
|
|
1182
1236
|
}
|
|
1183
1237
|
let targetCollectionId = row.targetCollectionId;
|
|
1184
1238
|
if (row.action === "create") {
|
|
1185
1239
|
try {
|
|
1186
|
-
const created = await client.
|
|
1240
|
+
const created = await client.createCollectionAsAdmin(appId, {
|
|
1187
1241
|
name: source.name,
|
|
1188
1242
|
...(source.description ? { description: source.description } : {}),
|
|
1189
1243
|
...(source.collectionType ? { collectionType: source.collectionType } : {}),
|
|
1190
|
-
|
|
1244
|
+
custodian: row.custodian,
|
|
1245
|
+
...(source.settings ? { settings: source.settings } : {}),
|
|
1191
1246
|
});
|
|
1192
1247
|
targetCollectionId = created.collectionId;
|
|
1193
1248
|
row.targetCollectionId = targetCollectionId;
|
|
1194
1249
|
summary.created += 1;
|
|
1195
1250
|
info(`Created ${source.name} as ${targetCollectionId}`);
|
|
1196
|
-
//
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
`${created.createdBy}); the token is not an admin one, or the ` +
|
|
1201
|
-
`server predates #3641`);
|
|
1251
|
+
// The custodian the server RECORDED is the answer.
|
|
1252
|
+
if (created.custodian && created.custodian !== row.custodian) {
|
|
1253
|
+
note("owner", row.custodian, `the server recorded ${created.custodian} as custodian, not ` +
|
|
1254
|
+
`${row.custodian}`);
|
|
1202
1255
|
}
|
|
1203
1256
|
}
|
|
1204
1257
|
catch (err) {
|
|
@@ -1210,21 +1263,21 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1210
1263
|
summary.merged += 1;
|
|
1211
1264
|
info(`Merged ${source.name} into ${targetCollectionId}`);
|
|
1212
1265
|
}
|
|
1213
|
-
for (const { grant, disposition,
|
|
1266
|
+
for (const { grant, disposition, existingRole } of entry.grants) {
|
|
1214
1267
|
if (disposition === "already-applied")
|
|
1215
1268
|
continue;
|
|
1216
|
-
const label =
|
|
1269
|
+
const label = `group:${grant.groupId}`;
|
|
1217
1270
|
try {
|
|
1218
|
-
await client.
|
|
1219
|
-
groupType: grant.groupType,
|
|
1271
|
+
await client.addCollectionMember(appId, targetCollectionId, {
|
|
1220
1272
|
groupId: grant.groupId,
|
|
1221
|
-
|
|
1273
|
+
...groupTypeOf(grant),
|
|
1274
|
+
role: grant.role,
|
|
1222
1275
|
});
|
|
1223
1276
|
summary.groupsGranted += 1;
|
|
1224
|
-
// A
|
|
1277
|
+
// A role change is worth saying out loud: it is the one grant write
|
|
1225
1278
|
// that can take access away from people who already had it.
|
|
1226
1279
|
if (disposition === "update") {
|
|
1227
|
-
info(`Updated ${grantUpdateLine(label,
|
|
1280
|
+
info(`Updated ${grantUpdateLine(label, existingRole, grant.role)}`);
|
|
1228
1281
|
}
|
|
1229
1282
|
}
|
|
1230
1283
|
catch (err) {
|
|
@@ -1235,10 +1288,9 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1235
1288
|
try {
|
|
1236
1289
|
const result = await client.addCollectionMember(appId, targetCollectionId, {
|
|
1237
1290
|
userId: member.userId,
|
|
1238
|
-
|
|
1291
|
+
role: member.role,
|
|
1239
1292
|
});
|
|
1240
|
-
// `already_member` is the server saying it
|
|
1241
|
-
// the owner's own `_col-writer` enrolment, which every export records.
|
|
1293
|
+
// `already_member` is the server saying it already held that role.
|
|
1242
1294
|
if (result?.status !== "already_member")
|
|
1243
1295
|
summary.membersAdded += 1;
|
|
1244
1296
|
}
|
|
@@ -1246,6 +1298,16 @@ async function importCollections(client, appId, importPath, options) {
|
|
|
1246
1298
|
note("member", member.userId, serverReason(err));
|
|
1247
1299
|
}
|
|
1248
1300
|
}
|
|
1301
|
+
if (entry.removeOwnerRowOf) {
|
|
1302
|
+
try {
|
|
1303
|
+
await client.removeCollectionMember(appId, targetCollectionId, entry.removeOwnerRowOf);
|
|
1304
|
+
info(`Removed the owner row of ${entry.removeOwnerRowOf} from ${source.name}: ` +
|
|
1305
|
+
`the export records no membership for the custodian`);
|
|
1306
|
+
}
|
|
1307
|
+
catch (err) {
|
|
1308
|
+
note("owner", entry.removeOwnerRowOf, serverReason(err));
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1249
1311
|
for (const documentId of entry.documents) {
|
|
1250
1312
|
try {
|
|
1251
1313
|
await client.addCollectionDocument(appId, targetCollectionId, { documentId });
|