primitive-admin 1.2.0-alpha.9 → 1.3.0-alpha.1
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 +303 -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 +170 -50
- 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 +42 -0
- package/dist/src/commands/db3-types.js +445 -0
- package/dist/src/commands/db3-types.js.map +1 -0
- package/dist/src/commands/db3.d.ts +38 -0
- package/dist/src/commands/db3.js +2053 -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 +1019 -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 +383 -32
- 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 +509 -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 +55 -6
- 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.d.ts +38 -0
- package/dist/src/commands/secrets.js +148 -6
- 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/spent-tokens.d.ts +19 -0
- package/dist/src/commands/spent-tokens.js +79 -0
- package/dist/src/commands/spent-tokens.js.map +1 -0
- package/dist/src/commands/sync-app-settings.d.ts +58 -0
- package/dist/src/commands/sync-app-settings.js +119 -2
- package/dist/src/commands/sync-app-settings.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 +578 -546
- package/dist/src/commands/sync.js +3516 -5134
- 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 +42 -0
- package/dist/src/commands/usage.js +397 -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 +951 -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 +1976 -431
- package/dist/src/lib/api-client.js +1095 -550
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +14 -2
- package/dist/src/lib/app-settings-descriptor.js +55 -1
- 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 +47 -1
- package/dist/src/lib/auth-flow.js +451 -14
- 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 +111 -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 +113 -277
- 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 +142 -70
- package/dist/src/lib/credentials-store.js +420 -111
- 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 +40 -1
- package/dist/src/lib/db-codegen/dbTypeIR.js +32 -8
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
- package/dist/src/lib/db-type-records.d.ts +125 -0
- package/dist/src/lib/db-type-records.js +237 -0
- package/dist/src/lib/db-type-records.js.map +1 -0
- package/dist/src/lib/db3-export.d.ts +322 -0
- package/dist/src/lib/db3-export.js +767 -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-json-fields.d.ts +49 -0
- package/dist/src/lib/db3-json-fields.js +195 -0
- package/dist/src/lib/db3-json-fields.js.map +1 -0
- package/dist/src/lib/db3-type-archive.d.ts +59 -0
- package/dist/src/lib/db3-type-archive.js +95 -0
- package/dist/src/lib/db3-type-archive.js.map +1 -0
- package/dist/src/lib/db3-type-models.d.ts +148 -0
- package/dist/src/lib/db3-type-models.js +583 -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-export-record-log.d.ts +7 -0
- package/dist/src/lib/document-export-record-log.js +9 -0
- package/dist/src/lib/document-export-record-log.js.map +1 -1
- package/dist/src/lib/document-ingest-artifact.d.ts +19 -0
- package/dist/src/lib/document-ingest-artifact.js +55 -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 +36 -0
- package/dist/src/lib/function-authorize-view.js +110 -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 +112 -12
- package/dist/src/lib/function-collect.js +601 -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 +326 -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-grants-preflight.d.ts +99 -0
- package/dist/src/lib/function-grants-preflight.js +154 -2
- package/dist/src/lib/function-grants-preflight.js.map +1 -1
- package/dist/src/lib/function-lint.d.ts +85 -0
- package/dist/src/lib/function-lint.js +442 -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 +120 -6
- package/dist/src/lib/function-sync.js +217 -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 +502 -0
- package/dist/src/lib/generated-command-status.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +804 -140
- package/dist/src/lib/generated-config-surfaces.js +2491 -1806
- 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-trust-step.d.ts +67 -0
- package/dist/src/lib/hosting-trust-step.js +279 -0
- package/dist/src/lib/hosting-trust-step.js.map +1 -0
- package/dist/src/lib/hosting-trust.d.ts +77 -0
- package/dist/src/lib/hosting-trust.js +194 -0
- package/dist/src/lib/hosting-trust.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 +871 -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/refresh-admin-credentials.d.ts +34 -4
- package/dist/src/lib/refresh-admin-credentials.js +85 -29
- package/dist/src/lib/refresh-admin-credentials.js.map +1 -1
- package/dist/src/lib/refresh-stored-login.d.ts +85 -0
- package/dist/src/lib/refresh-stored-login.js +233 -0
- package/dist/src/lib/refresh-stored-login.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/row-field-rename.d.ts +18 -0
- package/dist/src/lib/row-field-rename.js +32 -0
- package/dist/src/lib/row-field-rename.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 +229 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.js +420 -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-defs-module.d.ts +29 -0
- package/dist/src/lib/schema-defs-module.js +103 -0
- package/dist/src/lib/schema-defs-module.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 +51 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js +239 -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-list-edit.d.ts +33 -0
- package/dist/src/lib/toml-list-edit.js +481 -0
- package/dist/src/lib/toml-list-edit.js.map +1 -0
- package/dist/src/lib/toml-scalar-edit.d.ts +9 -0
- package/dist/src/lib/toml-scalar-edit.js +73 -5
- 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/usage-meters.d.ts +16 -0
- package/dist/src/lib/usage-meters.js +52 -0
- package/dist/src/lib/usage-meters.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,9 +1,14 @@
|
|
|
1
1
|
import { loadCredentials, saveCredentials, isTokenExpiringSoon, } from "./config.js";
|
|
2
|
-
import {
|
|
2
|
+
import { reportTransitionWarnings } from "./transition-warnings.js";
|
|
3
|
+
import { getCurrentEnvNameSafe, getProjectConfig } from "./env-resolver.js";
|
|
4
|
+
import { pinRefusalHint } from "./pin-refusal-hint.js";
|
|
3
5
|
import { fetchWithTLS } from "./fetch.js";
|
|
6
|
+
import { CLI_VERSION_HEADER, cliVersionHeaderValue } from "./cli-version.js";
|
|
4
7
|
import { paginateAll, normalizeCliListEnvelope } from "./paginate.js";
|
|
5
|
-
import { RefreshError
|
|
6
|
-
import {
|
|
8
|
+
import { RefreshError } from "./refresh-admin-credentials.js";
|
|
9
|
+
import { refreshFromStoredLogin } from "./refresh-stored-login.js";
|
|
10
|
+
/** The `X-Primitive-CLI-Version` value, read from the package file once per process. */
|
|
11
|
+
let cliVersion;
|
|
7
12
|
/**
|
|
8
13
|
* Page size the admin per-user inventories are asked for (#3399).
|
|
9
14
|
*
|
|
@@ -48,6 +53,15 @@ export class ApiError extends Error {
|
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
}
|
|
56
|
+
/** The project's committed environments, or null outside a readable project. */
|
|
57
|
+
function projectEnvironments() {
|
|
58
|
+
try {
|
|
59
|
+
return getProjectConfig()?.environments ?? null;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
51
65
|
export class ConflictError extends ApiError {
|
|
52
66
|
serverModifiedAt;
|
|
53
67
|
expectedModifiedAt;
|
|
@@ -157,6 +171,11 @@ export class TomlParseError extends ApiError {
|
|
|
157
171
|
return typeof d?.column === "number" ? d.column : undefined;
|
|
158
172
|
}
|
|
159
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* The query a db3 record call carries so a renamed field is answered under
|
|
176
|
+
* its current name, the name the type file gives it.
|
|
177
|
+
*/
|
|
178
|
+
const DB3_CURRENT_NAMES = "?names=current";
|
|
160
179
|
export class ApiClient {
|
|
161
180
|
/**
|
|
162
181
|
* Loaded on first use (`ensureAuthenticated`), never in a constructor.
|
|
@@ -202,9 +221,9 @@ export class ApiClient {
|
|
|
202
221
|
throw new ApiError("Not logged in. Run 'primitive login' first.", 401);
|
|
203
222
|
}
|
|
204
223
|
try {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
224
|
+
// #5926 — refresh from the login stored now, not the copy loaded at
|
|
225
|
+
// start: another process may have rotated its refresh token.
|
|
226
|
+
this.credentials = await refreshFromStoredLogin(this.credentials);
|
|
208
227
|
}
|
|
209
228
|
catch (err) {
|
|
210
229
|
if (err instanceof RefreshError) {
|
|
@@ -230,6 +249,8 @@ export class ApiClient {
|
|
|
230
249
|
Authorization: `Bearer ${accessToken}`,
|
|
231
250
|
"Content-Type": "application/json",
|
|
232
251
|
...(options.headers || {}),
|
|
252
|
+
// #5532 — every request names the CLI version that sent it.
|
|
253
|
+
[CLI_VERSION_HEADER]: (cliVersion ??= cliVersionHeaderValue()),
|
|
233
254
|
};
|
|
234
255
|
// Include globalAdminAppId if available (required for admin API calls)
|
|
235
256
|
if (credentials.globalAdminAppId) {
|
|
@@ -247,10 +268,17 @@ export class ApiClient {
|
|
|
247
268
|
// one. A retry refused 401 means the step-up is gone (revoked or expired
|
|
248
269
|
// early): drop it and show the original refusal. The retry's own refusal
|
|
249
270
|
// (say, a step-up without the scope this command needs) is shown as it is.
|
|
271
|
+
// #5822 — a successful write's platform transition warnings are printed.
|
|
272
|
+
const answered = (body) => {
|
|
273
|
+
const parsed = body ? JSON.parse(body) : null;
|
|
274
|
+
reportTransitionWarnings(options.method, parsed);
|
|
275
|
+
return parsed;
|
|
276
|
+
};
|
|
250
277
|
if (response.status === 403 && this.stepUpApplies(response, text, path)) {
|
|
251
278
|
const retried = await send(credentials.stepUp.accessToken);
|
|
252
279
|
if (retried.response.ok) {
|
|
253
|
-
|
|
280
|
+
this.lastStatus = retried.response.status;
|
|
281
|
+
return answered(retried.text);
|
|
254
282
|
}
|
|
255
283
|
if (retried.response.status === 401) {
|
|
256
284
|
this.dropStepUp();
|
|
@@ -262,8 +290,11 @@ export class ApiClient {
|
|
|
262
290
|
if (!response.ok) {
|
|
263
291
|
throw this.responseError(response, text, path);
|
|
264
292
|
}
|
|
265
|
-
|
|
293
|
+
this.lastStatus = response.status;
|
|
294
|
+
return answered(text);
|
|
266
295
|
}
|
|
296
|
+
/** The HTTP status of the last request `request` answered without throwing. */
|
|
297
|
+
lastStatus;
|
|
267
298
|
/**
|
|
268
299
|
* Whether a 403 should be retried with the stored step-up: it names
|
|
269
300
|
* `admin` among the missing scopes, or it is a protected app's refusal of
|
|
@@ -340,7 +371,9 @@ export class ApiClient {
|
|
|
340
371
|
if (response.status === 400 && parsed.code === "TOML_PARSE_ERROR") {
|
|
341
372
|
return new TomlParseError(parsed.message, detailsRecord);
|
|
342
373
|
}
|
|
343
|
-
|
|
374
|
+
// #4512 — a pin refusal on another environment's app names its login.
|
|
375
|
+
const hint = pinRefusalHint(parsed, this.credentials?.serverUrl ?? "", projectEnvironments());
|
|
376
|
+
return new ApiError(hint ? `${parsed.message} ${hint}` : parsed.message, response.status, parsed.code, parsed.details);
|
|
344
377
|
}
|
|
345
378
|
/**
|
|
346
379
|
* `POST /admin/api/auth/token` — derive a token no wider than the stored
|
|
@@ -350,6 +383,60 @@ export class ApiClient {
|
|
|
350
383
|
async exchangeToken(body) {
|
|
351
384
|
return this.post("/admin/api/auth/token", body);
|
|
352
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* #5787 — what `primitive hosting` may send for the current credentials:
|
|
388
|
+
* a CI token as it is (it cannot derive), or else nothing until a token is
|
|
389
|
+
* derived; and whether an unexpired step-up that may reach `appId` is
|
|
390
|
+
* stored. Throws the usual not-logged-in refusal.
|
|
391
|
+
*/
|
|
392
|
+
async hostingCredentials(appId) {
|
|
393
|
+
const credentials = await this.ensureAuthenticated();
|
|
394
|
+
const stepUp = credentials.stepUp;
|
|
395
|
+
const usable = Boolean(stepUp?.accessToken) &&
|
|
396
|
+
new Date(stepUp.expiresAt).getTime() > Date.now() &&
|
|
397
|
+
(stepUp.apps.length === 0 || stepUp.apps.includes(appId));
|
|
398
|
+
// An opaque CI token (`primadm_…`, #3890) is no JWT and cannot derive.
|
|
399
|
+
const ci = credentials.accessToken.startsWith("primadm_");
|
|
400
|
+
return { ciToken: ci ? credentials.accessToken : null, stepUp: usable };
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* #5787 — `POST /admin/api/auth/token` for hosting: a `write`-only token of
|
|
404
|
+
* 15 minutes derived from the login, or from the stored step-up on a
|
|
405
|
+
* protected app, pinned to `appId` when that bearer is pinned and unpinned
|
|
406
|
+
* otherwise. Sent with exactly that bearer and never retried with another.
|
|
407
|
+
*/
|
|
408
|
+
async deriveHostingToken(input) {
|
|
409
|
+
const credentials = await this.ensureAuthenticated();
|
|
410
|
+
const bearer = input.from === "step-up" ? credentials.stepUp?.accessToken : credentials.accessToken;
|
|
411
|
+
if (!bearer)
|
|
412
|
+
throw new ApiError("No step-up is stored for this login.", 403, "PROTECTED_APP_STEP_UP_REQUIRED");
|
|
413
|
+
let pins;
|
|
414
|
+
try {
|
|
415
|
+
pins = JSON.parse(Buffer.from(bearer.split(".")[1] ?? "", "base64url").toString("utf-8"))?.apps;
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
pins = undefined;
|
|
419
|
+
}
|
|
420
|
+
const pinned = Array.isArray(pins) && pins.length > 0;
|
|
421
|
+
const path = "/admin/api/auth/token";
|
|
422
|
+
const headers = {
|
|
423
|
+
Authorization: `Bearer ${bearer}`,
|
|
424
|
+
"Content-Type": "application/json",
|
|
425
|
+
[CLI_VERSION_HEADER]: (cliVersion ??= cliVersionHeaderValue()),
|
|
426
|
+
};
|
|
427
|
+
if (credentials.globalAdminAppId)
|
|
428
|
+
headers["X-Global-Admin-App-Id"] = credentials.globalAdminAppId;
|
|
429
|
+
const response = await fetchWithTLS(`${credentials.serverUrl}${path}`, {
|
|
430
|
+
method: "POST",
|
|
431
|
+
headers,
|
|
432
|
+
body: JSON.stringify({ scope: ["write"], ...(pinned ? { apps: [input.appId] } : {}), ttl: "15m" }),
|
|
433
|
+
});
|
|
434
|
+
const text = await response.text();
|
|
435
|
+
if (!response.ok)
|
|
436
|
+
throw this.responseError(response, text, path);
|
|
437
|
+
const derived = JSON.parse(text);
|
|
438
|
+
return { accessToken: derived.accessToken, expiresAt: derived.expiresAt };
|
|
439
|
+
}
|
|
353
440
|
// Helper for GET requests with query params
|
|
354
441
|
async get(path, params) {
|
|
355
442
|
let fullPath = path;
|
|
@@ -436,38 +523,6 @@ export class ApiClient {
|
|
|
436
523
|
});
|
|
437
524
|
return { apps };
|
|
438
525
|
}
|
|
439
|
-
/**
|
|
440
|
-
* Every app on the server, not just the caller's own.
|
|
441
|
-
*
|
|
442
|
-
* Deliberately separate from `listApps()`, whose contract is "apps assigned
|
|
443
|
-
* to me" (`GET /admin/api/admins/me/apps`, backed by `admin.queryApps()`) —
|
|
444
|
-
* the contract every other command depends on. `analytics workflow-usage
|
|
445
|
-
* --all-apps` has to reach apps nobody is assigned to, which is the global
|
|
446
|
-
* route `GET /admin/api/apps` (`App.iterateAll()`), and that route
|
|
447
|
-
* identifies an app as `appId` rather than `id` (D3130-001).
|
|
448
|
-
*
|
|
449
|
-
* One drain of that route is lossy — its cursor re-scans `App.iterateAll()`
|
|
450
|
-
* from the start of each page, so a list that changes under it both repeats
|
|
451
|
-
* and drops rows — so the walk is the union of repeated drains
|
|
452
|
-
* (`drainAppsUntilConverged`, which carries the measurement).
|
|
453
|
-
*/
|
|
454
|
-
async listAllAppsGlobal() {
|
|
455
|
-
const drainOnce = () => paginateAll(async (cursor) => {
|
|
456
|
-
const qs = new URLSearchParams({ limit: "100" });
|
|
457
|
-
if (cursor)
|
|
458
|
-
qs.set("cursor", cursor);
|
|
459
|
-
const resp = await this.get(`/admin/api/apps?${qs.toString()}`);
|
|
460
|
-
const rows = resp.items ?? [];
|
|
461
|
-
return {
|
|
462
|
-
items: rows.map((row) => ({
|
|
463
|
-
appId: String(row.appId ?? row.id ?? ""),
|
|
464
|
-
name: String(row.name ?? ""),
|
|
465
|
-
})),
|
|
466
|
-
nextCursor: resp.nextCursor,
|
|
467
|
-
};
|
|
468
|
-
});
|
|
469
|
-
return drainAppsUntilConverged(drainOnce);
|
|
470
|
-
}
|
|
471
526
|
/**
|
|
472
527
|
* Create an app. An ordinary app takes `name` (and, for a super-admin,
|
|
473
528
|
* `initialAdminEmail`). A child app takes `parentAppId` and `childSlug`
|
|
@@ -537,6 +592,15 @@ export class ApiClient {
|
|
|
537
592
|
async addUserByEmail(appId, data) {
|
|
538
593
|
return this.post(`/admin/api/apps/${appId}/users/add-by-email`, data);
|
|
539
594
|
}
|
|
595
|
+
/**
|
|
596
|
+
* Invite an email to the app as a console admin
|
|
597
|
+
* (`POST /admin/api/apps/:appId/users/invite`): the invitation, with its
|
|
598
|
+
* `inviteToken` and the `initialProperties` it gives the invitee at
|
|
599
|
+
* acceptance (filling only what they have not set).
|
|
600
|
+
*/
|
|
601
|
+
async inviteUser(appId, data) {
|
|
602
|
+
return this.post(`/admin/api/apps/${appId}/users/invite`, data);
|
|
603
|
+
}
|
|
540
604
|
/**
|
|
541
605
|
* Set a member's display name and/or avatar URL
|
|
542
606
|
* (`PATCH /admin/api/apps/:appId/users/:userId/profile`). An omitted field
|
|
@@ -551,6 +615,172 @@ export class ApiClient {
|
|
|
551
615
|
async rebuildUserSearchText(appId) {
|
|
552
616
|
return this.post(`/admin/api/apps/${appId}/users/rebuild-search-text`, {});
|
|
553
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* One page of an app's users from the user index
|
|
620
|
+
* (`POST /admin/api/apps/:appId/users/query`): the records-query filter and
|
|
621
|
+
* sort over base fields and `properties.<name>`, at most 1,000 per page.
|
|
622
|
+
*/
|
|
623
|
+
async queryUsers(appId, body) {
|
|
624
|
+
return this.post(`/admin/api/apps/${appId}/users/query`, body);
|
|
625
|
+
}
|
|
626
|
+
/** How many of an app's users match (`POST /admin/api/apps/:appId/users/count`). */
|
|
627
|
+
async countUsers(appId, body) {
|
|
628
|
+
return this.post(`/admin/api/apps/${appId}/users/count`, body);
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* The state of an app's user index (`GET /admin/api/apps/:appId/users/index`):
|
|
632
|
+
* the generation, each shard with its bound and counts, superseded
|
|
633
|
+
* generations, a rebuild in progress, queued applies, the last apply and
|
|
634
|
+
* reconciliation, the limits and whether the shard ceiling is reached.
|
|
635
|
+
*/
|
|
636
|
+
async getUserIndexStatus(appId) {
|
|
637
|
+
return this.get(`/admin/api/apps/${appId}/users/index`);
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Start a report of which user metadata categories still hold rows on the
|
|
641
|
+
* app's current members (`POST /admin/api/apps/:appId/users/metadata-report`).
|
|
642
|
+
*/
|
|
643
|
+
async startUserMetadataReport(appId) {
|
|
644
|
+
return this.post(`/admin/api/apps/${appId}/users/metadata-report`, {});
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Read a user metadata report run, or the app's newest when `runId` is
|
|
648
|
+
* absent (`GET /admin/api/apps/:appId/users/metadata-report`).
|
|
649
|
+
*/
|
|
650
|
+
async getUserMetadataReport(appId, runId) {
|
|
651
|
+
const query = runId ? `?runId=${encodeURIComponent(runId)}` : "";
|
|
652
|
+
return this.get(`/admin/api/apps/${appId}/users/metadata-report${query}`);
|
|
653
|
+
}
|
|
654
|
+
/** Start building the next generation of an app's user index (`POST /admin/api/apps/:appId/users/index/rebuild`). */
|
|
655
|
+
async rebuildUserIndex(appId) {
|
|
656
|
+
return this.post(`/admin/api/apps/${appId}/users/index/rebuild`, {});
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Run one revalidation slice of an app's user index now
|
|
660
|
+
* (`POST /admin/api/apps/:appId/users/index/reconcile`), answered when it is
|
|
661
|
+
* done; `started: false` while the app is being deleted.
|
|
662
|
+
*/
|
|
663
|
+
async reconcileUserIndex(appId) {
|
|
664
|
+
return this.post(`/admin/api/apps/${appId}/users/index/reconcile`, {});
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Start (or find) a walk over an app's users with the admin as its starter
|
|
668
|
+
* (`POST /admin/api/apps/:appId/users/walks`); `existing` says the key named
|
|
669
|
+
* a walk that already existed.
|
|
670
|
+
*/
|
|
671
|
+
async startUserWalk(appId, body) {
|
|
672
|
+
return this.post(`/admin/api/apps/${appId}/users/walks`, body);
|
|
673
|
+
}
|
|
674
|
+
/** A users walk by its run id (`GET /admin/api/apps/:appId/users/walks/:runId`). */
|
|
675
|
+
async getUserWalk(appId, runId) {
|
|
676
|
+
return this.get(`/admin/api/apps/${appId}/users/walks/${encodeURIComponent(runId)}`);
|
|
677
|
+
}
|
|
678
|
+
/** A rate counter's state by key (`GET /admin/api/apps/:appId/rate-counters/:key`). */
|
|
679
|
+
async getRateCounter(appId, key) {
|
|
680
|
+
return this.get(`/admin/api/apps/${appId}/rate-counters/${encodeURIComponent(key)}`);
|
|
681
|
+
}
|
|
682
|
+
/** A spent token of the app by id (`GET /admin/api/apps/:appId/spent-tokens/:tokenId`); 404 when it has not been used. */
|
|
683
|
+
async getSpentToken(appId, tokenId) {
|
|
684
|
+
return this.get(`/admin/api/apps/${appId}/spent-tokens/${encodeURIComponent(tokenId)}`);
|
|
685
|
+
}
|
|
686
|
+
/** Stop a users walk (`POST /admin/api/apps/:appId/users/walks/:runId/terminate`); batches in flight finish. */
|
|
687
|
+
async terminateUserWalk(appId, runId) {
|
|
688
|
+
return this.post(`/admin/api/apps/${appId}/users/walks/${encodeURIComponent(runId)}/terminate`, {});
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* An app's user index limit overrides and the limits in effect, with the
|
|
692
|
+
* property caps beside them (`GET /admin/api/apps/:appId/users/index/limits`).
|
|
693
|
+
*/
|
|
694
|
+
async getUserIndexLimits(appId) {
|
|
695
|
+
return this.get(`/admin/api/apps/${appId}/users/index/limits`);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Set (a positive integer) or clear (`null`) an app's user index limit
|
|
699
|
+
* overrides (`PATCH /admin/api/apps/:appId/users/index/limits`).
|
|
700
|
+
*/
|
|
701
|
+
async patchUserIndexLimits(appId, body) {
|
|
702
|
+
return this.patch(`/admin/api/apps/${appId}/users/index/limits`, body);
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* An app's user properties schema (`GET /admin/api/apps/:appId/users/properties`):
|
|
706
|
+
* the active version, a push being validated, the removed fields and the caps.
|
|
707
|
+
* While a push validates, this read also resumes its walk.
|
|
708
|
+
*/
|
|
709
|
+
async getUserProperties(appId) {
|
|
710
|
+
return this.get(`/admin/api/apps/${appId}/users/properties`);
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Push the text of `user-properties.toml` (`PUT /admin/api/apps/:appId/users/properties`):
|
|
714
|
+
* 200 `published` or `unchanged`, 400 when refused; `dryRun` judges it and
|
|
715
|
+
* writes nothing.
|
|
716
|
+
*/
|
|
717
|
+
async pushUserProperties(appId, body, options = {}) {
|
|
718
|
+
return this.put(`/admin/api/apps/${appId}/users/properties${options.dryRun ? "?dryRun=true" : ""}`, body);
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* The current version of each of an app's `schemas/` files
|
|
722
|
+
* (`GET /admin/api/apps/:appId/schemas`); a tombstoned file only with
|
|
723
|
+
* `includeTombstoned`.
|
|
724
|
+
*/
|
|
725
|
+
async listSchemaFiles(appId, options = {}) {
|
|
726
|
+
return this.get(`/admin/api/apps/${appId}/schemas${options.includeTombstoned ? "?includeTombstoned=true" : ""}`);
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* One version of a `schemas/` file, the current one unless `version` names
|
|
730
|
+
* another (`GET /admin/api/apps/:appId/schemas/:file`); 404
|
|
731
|
+
* `SCHEMA_FILE_NOT_FOUND` or `SCHEMA_VERSION_NOT_FOUND`.
|
|
732
|
+
*/
|
|
733
|
+
async getSchemaFile(appId, file, options = {}) {
|
|
734
|
+
const query = options.version !== undefined ? `?version=${encodeURIComponent(String(options.version))}` : "";
|
|
735
|
+
return this.get(`/admin/api/apps/${appId}/schemas/${encodeURIComponent(file)}${query}`);
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Push the text of `schemas/<file>.toml` with its compiled defs
|
|
739
|
+
* (`PUT /admin/api/apps/:appId/schemas/:file`): `created` or `unchanged`;
|
|
740
|
+
* 409 `CONFLICT` when the current version is not `expectedVersion`.
|
|
741
|
+
*/
|
|
742
|
+
async pushSchemaFile(appId, file, body) {
|
|
743
|
+
return this.put(`/admin/api/apps/${appId}/schemas/${encodeURIComponent(file)}`, body);
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Write a tombstone version of a `schemas/` file (`PUT
|
|
747
|
+
* /admin/api/apps/:appId/schemas/:file` with `{ tombstone: true }`), pinned
|
|
748
|
+
* to `expectedVersion` when given.
|
|
749
|
+
*/
|
|
750
|
+
async tombstoneSchemaFile(appId, file, expectedVersion) {
|
|
751
|
+
return this.put(`/admin/api/apps/${appId}/schemas/${encodeURIComponent(file)}`, {
|
|
752
|
+
tombstone: true,
|
|
753
|
+
...(expectedVersion !== undefined ? { expectedVersion } : {}),
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* The source of every live `schemas/` file, or of `files` only
|
|
758
|
+
* (`POST /admin/api/apps/:appId/schemas/pull`); a named file with no live
|
|
759
|
+
* version is listed under `missing`.
|
|
760
|
+
*/
|
|
761
|
+
async pullSchemaFiles(appId, files) {
|
|
762
|
+
return this.post(`/admin/api/apps/${appId}/schemas/pull`, files ? { files } : {});
|
|
763
|
+
}
|
|
764
|
+
/** One member with their properties (`GET /admin/api/apps/:appId/users/:userId`); 404 `USER_NOT_FOUND` for a user who is no member. */
|
|
765
|
+
async getAppUser(appId, userId) {
|
|
766
|
+
return this.get(`/admin/api/apps/${appId}/users/${userId}`);
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* The member who holds a unique property value or a unique constraint's
|
|
770
|
+
* values (`POST /admin/api/apps/:appId/users/get-by`): `{ user }`, null when
|
|
771
|
+
* no member holds it.
|
|
772
|
+
*/
|
|
773
|
+
async getAppUserBy(appId, selector) {
|
|
774
|
+
return this.post(`/admin/api/apps/${appId}/users/get-by`, selector);
|
|
775
|
+
}
|
|
776
|
+
/** Apply a property write to one member (`PATCH /admin/api/apps/:appId/users/:userId/properties`); answers the member after it. */
|
|
777
|
+
async setAppUserProperties(appId, userId, body) {
|
|
778
|
+
return this.patch(`/admin/api/apps/${appId}/users/${userId}/properties`, body);
|
|
779
|
+
}
|
|
780
|
+
/** An aggregate over an app's users (`POST /admin/api/apps/:appId/users/aggregate`). */
|
|
781
|
+
async aggregateUsers(appId, body) {
|
|
782
|
+
return this.post(`/admin/api/apps/${appId}/users/aggregate`, body);
|
|
783
|
+
}
|
|
554
784
|
async listUsers(appId, params) {
|
|
555
785
|
const query = new URLSearchParams();
|
|
556
786
|
if (params?.name)
|
|
@@ -563,6 +793,8 @@ export class ApiClient {
|
|
|
563
793
|
query.set("limit", String(params.limit));
|
|
564
794
|
if (params?.cursor)
|
|
565
795
|
query.set("cursor", params.cursor);
|
|
796
|
+
if (params?.testUsers)
|
|
797
|
+
query.set("testUsers", params.testUsers);
|
|
566
798
|
const path = query.toString()
|
|
567
799
|
? `/app/${appId}/api/users?${query.toString()}`
|
|
568
800
|
: `/app/${appId}/api/users`;
|
|
@@ -573,6 +805,8 @@ export class ApiClient {
|
|
|
573
805
|
// page boundary rather than inferring one from the cursor (#3646).
|
|
574
806
|
hasMore: result?.hasMore,
|
|
575
807
|
nextCursor: result?.nextCursor ?? null,
|
|
808
|
+
// Rows a `testUsers` filtered read examined (#5104); absent otherwise.
|
|
809
|
+
...(typeof result?.scanned === "number" ? { scanned: result.scanned } : {}),
|
|
576
810
|
};
|
|
577
811
|
}
|
|
578
812
|
/**
|
|
@@ -591,36 +825,21 @@ export class ApiClient {
|
|
|
591
825
|
async setUserAvailability(appId, userId, action) {
|
|
592
826
|
return this.put(`/admin/api/apps/${appId}/users/${userId}/${action}`, {});
|
|
593
827
|
}
|
|
594
|
-
// ============================================
|
|
595
|
-
// FEATURE FLAGS (super-admin)
|
|
596
|
-
// ============================================
|
|
597
|
-
/**
|
|
598
|
-
* #2803 — the platform's feature flags. A server-owned admin toggle with a
|
|
599
|
-
* console but, until now, no CLI: the same "one control, both surfaces" rule
|
|
600
|
-
* the carrying types get.
|
|
601
|
-
*/
|
|
602
|
-
async listFeatureFlags() {
|
|
603
|
-
return this.get(`/admin/api/flags`);
|
|
604
|
-
}
|
|
605
|
-
/**
|
|
606
|
-
* The flag itself, not the `{ flag }` envelope the route answers with —
|
|
607
|
-
* `feature-flags get` prints the key, the enabled state and the per-app
|
|
608
|
-
* overrides, and reading them off the envelope printed a blank row.
|
|
609
|
-
*/
|
|
610
|
-
async getFeatureFlag(flagKey) {
|
|
611
|
-
const result = await this.get(`/admin/api/flags/${flagKey}`);
|
|
612
|
-
return result?.flag ?? result;
|
|
613
|
-
}
|
|
614
|
-
/** Same envelope, same unwrap: `enable`/`disable` print the updated flag. */
|
|
615
|
-
async setFeatureFlagEnabled(flagKey, enabled) {
|
|
616
|
-
const result = await this.put(`/admin/api/flags/${flagKey}`, { enabled });
|
|
617
|
-
return result?.flag ?? result;
|
|
618
|
-
}
|
|
619
828
|
async updateUserRole(appId, userId, role) {
|
|
620
829
|
return this.put(`/app/${appId}/api/users/${userId}/role`, { role });
|
|
621
830
|
}
|
|
831
|
+
/**
|
|
832
|
+
* Make the app user with `newOwnerEmail` the app's owner; the previous
|
|
833
|
+
* owner becomes an admin. The email resolves to a userId through
|
|
834
|
+
* {@link lookupUserByEmail}, and an email no user of the app has rejects
|
|
835
|
+
* with a message naming it.
|
|
836
|
+
*/
|
|
622
837
|
async transferOwnership(appId, newOwnerEmail) {
|
|
623
|
-
|
|
838
|
+
const lookup = await this.lookupUserByEmail(appId, newOwnerEmail);
|
|
839
|
+
if (!lookup.exists || !lookup.user?.userId) {
|
|
840
|
+
throw new Error(`No user with email ${newOwnerEmail} in app ${appId}`);
|
|
841
|
+
}
|
|
842
|
+
return this.post(`/admin/api/apps/${appId}/users/${lookup.user.userId}/transfer-ownership`, {});
|
|
624
843
|
}
|
|
625
844
|
async transferAdminOwnership(appId, adminId) {
|
|
626
845
|
return this.post(`/admin/api/apps/${appId}/admins/transfer-ownership`, { adminId });
|
|
@@ -656,6 +875,21 @@ export class ApiClient {
|
|
|
656
875
|
hasMore: result?.hasMore ?? nextCursor != null,
|
|
657
876
|
};
|
|
658
877
|
}
|
|
878
|
+
/**
|
|
879
|
+
* `GET /app/{appId}/api/invitations/{invitationId}` — one invitation with
|
|
880
|
+
* its `inviteToken` (the bearer credential an accept link carries) and its
|
|
881
|
+
* `status`. Readable by an app admin/owner or the inviter.
|
|
882
|
+
*/
|
|
883
|
+
/**
|
|
884
|
+
* What an invitation shows before anyone signs in (#5848), by its token.
|
|
885
|
+
* The route reads no credential.
|
|
886
|
+
*/
|
|
887
|
+
async previewInvitation(appId, inviteToken) {
|
|
888
|
+
return this.get(`/app/${appId}/api/invitations/preview`, { inviteToken });
|
|
889
|
+
}
|
|
890
|
+
async getInvitation(appId, invitationId) {
|
|
891
|
+
return this.get(`/app/${appId}/api/invitations/${encodeURIComponent(invitationId)}`);
|
|
892
|
+
}
|
|
659
893
|
async createInvitation(appId, data) {
|
|
660
894
|
return this.post(`/app/${appId}/api/invitations`, data);
|
|
661
895
|
}
|
|
@@ -704,14 +938,14 @@ export class ApiClient {
|
|
|
704
938
|
nextCursor: result?.nextCursor ?? null,
|
|
705
939
|
};
|
|
706
940
|
}
|
|
707
|
-
/** Integration detail (
|
|
941
|
+
/** Integration detail (`requestConfig` is on the detail, not the list summary). */
|
|
708
942
|
async getIntegration(appId, integrationId) {
|
|
709
943
|
return this.get(`/admin/api/apps/${appId}/integrations/${integrationId}`);
|
|
710
944
|
}
|
|
711
945
|
/**
|
|
712
946
|
* An integration's named configs. Test cases pin a config by NAME so the
|
|
713
947
|
* sidecar is portable across apps (#2769); this is the map pull and push
|
|
714
|
-
* resolve that name through, the same way prompts
|
|
948
|
+
* resolve that name through, the same way prompts do.
|
|
715
949
|
*/
|
|
716
950
|
async listIntegrationConfigs(appId, integrationId) {
|
|
717
951
|
const result = await this.get(`/admin/api/apps/${appId}/integrations/${integrationId}/configs`);
|
|
@@ -744,10 +978,6 @@ export class ApiClient {
|
|
|
744
978
|
const result = await this.get(`/admin/api/apps/${appId}/integrations/${integrationId}/logs`, params);
|
|
745
979
|
return result?.items ?? [];
|
|
746
980
|
}
|
|
747
|
-
async listWorkflowRunIntegrationLogs(appId, runId, params) {
|
|
748
|
-
const result = await this.get(`/admin/api/apps/${appId}/workflows/runs/${runId}/integration-logs`, params);
|
|
749
|
-
return result?.items ?? [];
|
|
750
|
-
}
|
|
751
981
|
// ============================================
|
|
752
982
|
// APP SECRETS
|
|
753
983
|
// ============================================
|
|
@@ -767,6 +997,14 @@ export class ApiClient {
|
|
|
767
997
|
async deleteAppSecret(appId, secretId) {
|
|
768
998
|
return this.delete(`/admin/api/apps/${appId}/secrets/${secretId}`);
|
|
769
999
|
}
|
|
1000
|
+
/**
|
|
1001
|
+
* What in the app's configuration names a secret key (#5845, beta): `{ key,
|
|
1002
|
+
* reserved, stored, references: [{ kind, id, name, field }], truncated }`.
|
|
1003
|
+
* Answers for any key, stored or not; never a value.
|
|
1004
|
+
*/
|
|
1005
|
+
async getAppSecretReferences(appId, key) {
|
|
1006
|
+
return this.get(`/admin/api/apps/${appId}/secrets/by-key/${encodeURIComponent(key)}/references`);
|
|
1007
|
+
}
|
|
770
1008
|
// ============================================
|
|
771
1009
|
// APP CONFIG VARS (issue #1364 — non-secret twin of secrets)
|
|
772
1010
|
// ============================================
|
|
@@ -807,52 +1045,18 @@ export class ApiClient {
|
|
|
807
1045
|
// ============================================
|
|
808
1046
|
// WEBHOOKS
|
|
809
1047
|
// ============================================
|
|
810
|
-
async listWebhooks(appId, params) {
|
|
811
|
-
const result = await this.get(`/admin/api/apps/${appId}/webhooks`, params);
|
|
812
|
-
return {
|
|
813
|
-
items: result?.items ?? [],
|
|
814
|
-
hasMore: result?.hasMore,
|
|
815
|
-
nextCursor: result?.nextCursor ?? null,
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
async getWebhook(appId, webhookId) {
|
|
819
|
-
return this.get(`/admin/api/apps/${appId}/webhooks/${webhookId}`);
|
|
820
|
-
}
|
|
821
|
-
async createWebhook(appId, payload) {
|
|
822
|
-
return this.post(`/admin/api/apps/${appId}/webhooks`, payload);
|
|
823
|
-
}
|
|
824
|
-
async updateWebhook(appId, webhookId, payload, expectedModifiedAt) {
|
|
825
|
-
const body = expectedModifiedAt ? { ...payload, expectedModifiedAt } : payload;
|
|
826
|
-
return this.patch(`/admin/api/apps/${appId}/webhooks/${webhookId}`, body);
|
|
827
|
-
}
|
|
828
|
-
/**
|
|
829
|
-
* Delete a webhook. Archives it by default; `hard` hard-deletes the row
|
|
830
|
-
* instead (#2232), which is what frees a slot under the per-app webhook cap
|
|
831
|
-
* and releases the webhook key for reuse. Same `?hard=true` verb the admin
|
|
832
|
-
* integrations delete uses.
|
|
833
|
-
*/
|
|
834
|
-
async deleteWebhook(appId, webhookId, options) {
|
|
835
|
-
const query = options?.hard ? "?hard=true" : "";
|
|
836
|
-
return this.delete(`/admin/api/apps/${appId}/webhooks/${webhookId}${query}`);
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* #2803 — the operational verb pair for a webhook. It posts to the
|
|
840
|
-
* enable/disable route rather than PATCHing `status`, which is server-owned
|
|
841
|
-
* and refused on every configuration write path.
|
|
842
|
-
*/
|
|
843
|
-
async setWebhookAvailability(appId, webhookId, action) {
|
|
844
|
-
return this.post(`/admin/api/apps/${appId}/webhooks/${webhookId}/${action}`, {});
|
|
845
|
-
}
|
|
846
1048
|
// ── Server functions (#3179) ─────────────────────────────────────────
|
|
847
1049
|
//
|
|
848
|
-
// The `functions` family
|
|
849
|
-
//
|
|
850
|
-
//
|
|
851
|
-
//
|
|
1050
|
+
// The `functions` family is a header with the gate and the entry, and
|
|
1051
|
+
// append-only immutable config versions carrying the authored TOML bytes,
|
|
1052
|
+
// the sources and the built bundle. The listing drains server-side, so it
|
|
1053
|
+
// has no cursor.
|
|
1054
|
+
/** Every function of the app; each item carries {@link FunctionActiveInputFields}. */
|
|
852
1055
|
async listFunctions(appId) {
|
|
853
1056
|
const result = await this.get(`/admin/api/apps/${appId}/functions`);
|
|
854
1057
|
return { items: result?.items ?? [] };
|
|
855
1058
|
}
|
|
1059
|
+
/** One function; the answer carries {@link FunctionActiveInputFields}. */
|
|
856
1060
|
async getFunction(appId, functionId) {
|
|
857
1061
|
return this.get(`/admin/api/apps/${appId}/functions/${functionId}`);
|
|
858
1062
|
}
|
|
@@ -887,6 +1091,38 @@ export class ApiClient {
|
|
|
887
1091
|
const result = await this.get(`/admin/api/apps/${appId}/functions/${functionId}/runs`, params);
|
|
888
1092
|
return { items: result?.items ?? [], nextCursor: result?.nextCursor ?? null };
|
|
889
1093
|
}
|
|
1094
|
+
// ── A function's trigger operations (#3190) ──
|
|
1095
|
+
// The operational home of a function's webhook and cron triggers, keyed by
|
|
1096
|
+
// the function and a cron entry's name rather than a trigger row's id.
|
|
1097
|
+
functionTriggersPath(appId, functionId) {
|
|
1098
|
+
return `/admin/api/apps/${appId}/functions/${encodeURIComponent(functionId)}/triggers`;
|
|
1099
|
+
}
|
|
1100
|
+
/** The function's webhook delivery log, newest first. */
|
|
1101
|
+
async listFunctionWebhookEvents(appId, functionId, params) {
|
|
1102
|
+
const result = await this.get(`${this.functionTriggersPath(appId, functionId)}/webhook/events`, params);
|
|
1103
|
+
const nextCursor = result?.nextCursor ?? null;
|
|
1104
|
+
return {
|
|
1105
|
+
items: result?.items ?? [],
|
|
1106
|
+
hasMore: result?.hasMore ?? !!nextCursor,
|
|
1107
|
+
nextCursor,
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
/** Sign a preview delivery for the function's webhook trigger. */
|
|
1111
|
+
async testFunctionWebhook(appId, functionId, payload) {
|
|
1112
|
+
return this.post(`${this.functionTriggersPath(appId, functionId)}/webhook/test`, payload || {});
|
|
1113
|
+
}
|
|
1114
|
+
/** Check captured headers and a captured body against the trigger's verifier. */
|
|
1115
|
+
async verifyFunctionWebhook(appId, functionId, payload) {
|
|
1116
|
+
return this.post(`${this.functionTriggersPath(appId, functionId)}/webhook/verify`, payload);
|
|
1117
|
+
}
|
|
1118
|
+
/** Point the trigger's `signingSecret` at a new `{{secrets.KEY}}` reference. */
|
|
1119
|
+
async rotateFunctionWebhookSecret(appId, functionId, payload) {
|
|
1120
|
+
return this.post(`${this.functionTriggersPath(appId, functionId)}/webhook/rotate-secret`, payload);
|
|
1121
|
+
}
|
|
1122
|
+
/** One cron entry verb: `fire`, `fire-scheduled`, `enable` or `disable`. */
|
|
1123
|
+
async functionCronEntryAction(appId, functionId, name, action) {
|
|
1124
|
+
return this.post(`${this.functionTriggersPath(appId, functionId)}/cron/${encodeURIComponent(name)}/${action}`, {});
|
|
1125
|
+
}
|
|
890
1126
|
/**
|
|
891
1127
|
* A function run's step trace — #3348.
|
|
892
1128
|
*
|
|
@@ -900,6 +1136,16 @@ export class ApiClient {
|
|
|
900
1136
|
const result = await this.get(`/admin/api/apps/${appId}/functions/${functionId}/runs/${runId}/steps`);
|
|
901
1137
|
return { items: result?.items ?? [] };
|
|
902
1138
|
}
|
|
1139
|
+
/**
|
|
1140
|
+
* The integration calls one function run made — #3190.
|
|
1141
|
+
*
|
|
1142
|
+
* The run → integration-logs pivot, addressed by the function that owns the
|
|
1143
|
+
* run (it was `workflows/runs/{runId}/integration-logs`).
|
|
1144
|
+
*/
|
|
1145
|
+
async listFunctionRunIntegrationLogs(appId, functionId, runId, options) {
|
|
1146
|
+
const result = await this.get(`/admin/api/apps/${appId}/functions/${functionId}/runs/${runId}/integration-logs`, options?.limit !== undefined ? { limit: options.limit } : undefined);
|
|
1147
|
+
return { items: result?.items ?? [] };
|
|
1148
|
+
}
|
|
903
1149
|
/**
|
|
904
1150
|
* End a function run that will not settle — #3348.
|
|
905
1151
|
*
|
|
@@ -972,9 +1218,10 @@ export class ApiClient {
|
|
|
972
1218
|
async invokeFunction(appId, functionKey, body, options) {
|
|
973
1219
|
const credentials = await this.ensureAuthenticated();
|
|
974
1220
|
const base = `/app/${appId}/api/functions/${encodeURIComponent(functionKey)}`;
|
|
1221
|
+
const task = options?.runtime === "task";
|
|
975
1222
|
const path = options?.asSystem
|
|
976
|
-
? `${base}
|
|
977
|
-
:
|
|
1223
|
+
? `${base}/${task ? "start-as-system" : "invoke-as-system"}`
|
|
1224
|
+
: task
|
|
978
1225
|
? `${base}/start`
|
|
979
1226
|
: base;
|
|
980
1227
|
const init = (bearer) => {
|
|
@@ -1014,13 +1261,46 @@ export class ApiClient {
|
|
|
1014
1261
|
body: parsed,
|
|
1015
1262
|
};
|
|
1016
1263
|
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Run only a function's `authorize` and hand back the ANSWER, whatever its
|
|
1266
|
+
* HTTP status — #4732. Like `invokeFunction`, it returns a refusal rather
|
|
1267
|
+
* than throwing it, so `functions authorize` renders the server's own
|
|
1268
|
+
* answer (and a case run records it as a failed row); it throws only when
|
|
1269
|
+
* the request did not complete. The CLI's own credentials, with the
|
|
1270
|
+
* step-up retry a protected app's refusal asks for.
|
|
1271
|
+
*/
|
|
1272
|
+
async authorizeFunction(appId, functionId, body) {
|
|
1273
|
+
const credentials = await this.ensureAuthenticated();
|
|
1274
|
+
const path = `/admin/api/apps/${appId}/functions/${encodeURIComponent(functionId)}/authorize`;
|
|
1275
|
+
const init = (bearer) => {
|
|
1276
|
+
const headers = {
|
|
1277
|
+
Authorization: `Bearer ${bearer}`,
|
|
1278
|
+
"Content-Type": "application/json",
|
|
1279
|
+
};
|
|
1280
|
+
if (credentials.globalAdminAppId) {
|
|
1281
|
+
headers["X-Global-Admin-App-Id"] = credentials.globalAdminAppId;
|
|
1282
|
+
}
|
|
1283
|
+
return { method: "POST", headers, body: JSON.stringify(body) };
|
|
1284
|
+
};
|
|
1285
|
+
const response = await this.fetchWithStepUp(`${credentials.serverUrl}${path}`, path, credentials.accessToken, init);
|
|
1286
|
+
const text = await response.text();
|
|
1287
|
+
let parsed = null;
|
|
1288
|
+
try {
|
|
1289
|
+
parsed = text ? JSON.parse(text) : null;
|
|
1290
|
+
}
|
|
1291
|
+
catch {
|
|
1292
|
+
parsed = { error: text };
|
|
1293
|
+
}
|
|
1294
|
+
return { httpStatus: response.status, body: parsed };
|
|
1295
|
+
}
|
|
1017
1296
|
/**
|
|
1018
1297
|
* A function's versions, newest first (#3462).
|
|
1019
1298
|
*
|
|
1020
1299
|
* Paging is opt-in on the server: with no `limit` and no `cursor` every
|
|
1021
1300
|
* version comes back, which is what this method did before paging existed and
|
|
1022
1301
|
* what an already-installed CLI still asks for. A caller that passes either
|
|
1023
|
-
* gets the shared `{ items, hasMore, nextCursor }` page.
|
|
1302
|
+
* gets the shared `{ items, hasMore, nextCursor }` page. Each item carries
|
|
1303
|
+
* {@link FunctionVersionInputFields}.
|
|
1024
1304
|
*/
|
|
1025
1305
|
async listFunctionConfigs(appId, functionId, options = {}) {
|
|
1026
1306
|
const query = new URLSearchParams();
|
|
@@ -1044,6 +1324,7 @@ export class ApiClient {
|
|
|
1044
1324
|
async activateFunctionConfig(appId, functionId, configId) {
|
|
1045
1325
|
return this.post(`/admin/api/apps/${appId}/functions/${functionId}/configs/${configId}/activate`, {});
|
|
1046
1326
|
}
|
|
1327
|
+
/** One version; the answer carries {@link FunctionVersionInputFields}. */
|
|
1047
1328
|
async getFunctionConfig(appId, functionId, configId) {
|
|
1048
1329
|
return this.get(`/admin/api/apps/${appId}/functions/${functionId}/configs/${configId}`);
|
|
1049
1330
|
}
|
|
@@ -1066,18 +1347,6 @@ export class ApiClient {
|
|
|
1066
1347
|
async setIntegrationAvailability(appId, integrationId, action) {
|
|
1067
1348
|
return this.post(`/admin/api/apps/${appId}/integrations/${integrationId}/${action}`, {});
|
|
1068
1349
|
}
|
|
1069
|
-
async rotateWebhookSecret(appId, webhookId, payload) {
|
|
1070
|
-
return this.post(`/admin/api/apps/${appId}/webhooks/${webhookId}/rotate-secret`, payload);
|
|
1071
|
-
}
|
|
1072
|
-
async listWebhookEvents(appId, webhookId, params) {
|
|
1073
|
-
const result = await this.get(`/admin/api/apps/${appId}/webhooks/${webhookId}/events`, params);
|
|
1074
|
-
const nextCursor = result?.nextCursor ?? null;
|
|
1075
|
-
return {
|
|
1076
|
-
items: result?.items ?? [],
|
|
1077
|
-
hasMore: result?.hasMore ?? !!nextCursor,
|
|
1078
|
-
nextCursor,
|
|
1079
|
-
};
|
|
1080
|
-
}
|
|
1081
1350
|
// ============================================
|
|
1082
1351
|
// CONNECTIONS INSPECTION (#1968)
|
|
1083
1352
|
// ============================================
|
|
@@ -1148,20 +1417,6 @@ export class ApiClient {
|
|
|
1148
1417
|
async revokeAdminSession(sessionId) {
|
|
1149
1418
|
return this.delete(`/admin/api/auth/sessions/${encodeURIComponent(sessionId)}`);
|
|
1150
1419
|
}
|
|
1151
|
-
async testWebhook(appId, webhookId, payload) {
|
|
1152
|
-
return this.post(`/admin/api/apps/${appId}/webhooks/${webhookId}/test`, payload || {});
|
|
1153
|
-
}
|
|
1154
|
-
/**
|
|
1155
|
-
* Run a webhook's configured verifier over headers and a body captured from
|
|
1156
|
-
* a real delivery, and report whether that signature checks out (#2445).
|
|
1157
|
-
*
|
|
1158
|
-
* `headers` is sent as ordered `[name, value]` pairs so a capture carrying a
|
|
1159
|
-
* field name on more than one line survives the round trip. Nothing is
|
|
1160
|
-
* delivered: no delivery record, no workflow run.
|
|
1161
|
-
*/
|
|
1162
|
-
async verifyWebhook(appId, webhookId, payload) {
|
|
1163
|
-
return this.post(`/admin/api/apps/${appId}/webhooks/${webhookId}/verify`, payload);
|
|
1164
|
-
}
|
|
1165
1420
|
// ============================================
|
|
1166
1421
|
// NAMED LOCKS (#1518)
|
|
1167
1422
|
// ============================================
|
|
@@ -1173,70 +1428,15 @@ export class ApiClient {
|
|
|
1173
1428
|
return this.post(`/app/${appId}/api/locks/status`, { key });
|
|
1174
1429
|
}
|
|
1175
1430
|
/**
|
|
1176
|
-
* #
|
|
1177
|
-
*
|
|
1431
|
+
* #4959 — free a key whose lease is live, with no handle (admin). Acquire,
|
|
1432
|
+
* renew and release are server-function-only, so the CLI has no door to them.
|
|
1178
1433
|
*/
|
|
1179
|
-
async
|
|
1180
|
-
return this.post(`/app/${appId}/api/locks/
|
|
1181
|
-
key,
|
|
1182
|
-
ttlMs,
|
|
1183
|
-
...(owner !== undefined ? { owner } : {}),
|
|
1184
|
-
});
|
|
1185
|
-
}
|
|
1186
|
-
async releaseLock(appId, key, handleId) {
|
|
1187
|
-
return this.post(`/app/${appId}/api/locks/release`, {
|
|
1188
|
-
key,
|
|
1189
|
-
handle: { handleId },
|
|
1190
|
-
});
|
|
1434
|
+
async forceReleaseLock(appId, key) {
|
|
1435
|
+
return this.post(`/app/${appId}/api/locks/force-release`, { key });
|
|
1191
1436
|
}
|
|
1192
1437
|
// ============================================
|
|
1193
1438
|
// CRON TRIGGERS
|
|
1194
1439
|
// ============================================
|
|
1195
|
-
async listCronTriggers(appId) {
|
|
1196
|
-
const result = await this.get(`/app/${appId}/api/cron-triggers`);
|
|
1197
|
-
return { items: result?.items ?? [] };
|
|
1198
|
-
}
|
|
1199
|
-
async getCronTrigger(appId, triggerId) {
|
|
1200
|
-
return this.get(`/app/${appId}/api/cron-triggers/${triggerId}`);
|
|
1201
|
-
}
|
|
1202
|
-
async createCronTrigger(appId, payload) {
|
|
1203
|
-
return this.post(`/app/${appId}/api/cron-triggers`, payload);
|
|
1204
|
-
}
|
|
1205
|
-
async updateCronTrigger(appId, triggerId, payload) {
|
|
1206
|
-
return this.put(`/app/${appId}/api/cron-triggers/${triggerId}`, payload);
|
|
1207
|
-
}
|
|
1208
|
-
/**
|
|
1209
|
-
* Retire a cron trigger. The default soft-deletes (writes the `archived`
|
|
1210
|
-
* tombstone); `{ hard: true }` destroys the row, which is what
|
|
1211
|
-
* `config push --prune` passes (#2803) so a pruned trigger stops consuming
|
|
1212
|
-
* the per-app cap and holding its key.
|
|
1213
|
-
*/
|
|
1214
|
-
async deleteCronTrigger(appId, triggerId, options = {}) {
|
|
1215
|
-
const query = options.hard ? "?hard=true" : "";
|
|
1216
|
-
return this.delete(`/app/${appId}/api/cron-triggers/${triggerId}${query}`);
|
|
1217
|
-
}
|
|
1218
|
-
async disableCronTrigger(appId, triggerId) {
|
|
1219
|
-
return this.post(`/app/${appId}/api/cron-triggers/${triggerId}/disable`, {});
|
|
1220
|
-
}
|
|
1221
|
-
async enableCronTrigger(appId, triggerId) {
|
|
1222
|
-
return this.post(`/app/${appId}/api/cron-triggers/${triggerId}/enable`, {});
|
|
1223
|
-
}
|
|
1224
|
-
async testCronTrigger(appId, triggerId) {
|
|
1225
|
-
return this.post(`/app/${appId}/api/cron-triggers/${triggerId}/test`, {});
|
|
1226
|
-
}
|
|
1227
|
-
// ============================================
|
|
1228
|
-
// ITERATIONS (iterate-users introspection / reset — #1209)
|
|
1229
|
-
// ============================================
|
|
1230
|
-
async listIterations(appId) {
|
|
1231
|
-
const result = await this.get(`/app/${appId}/api/iterations`);
|
|
1232
|
-
return { items: result?.items ?? [] };
|
|
1233
|
-
}
|
|
1234
|
-
async getIteration(appId, iterationName) {
|
|
1235
|
-
return this.get(`/app/${appId}/api/iterations/${encodeURIComponent(iterationName)}`);
|
|
1236
|
-
}
|
|
1237
|
-
async resetIteration(appId, iterationName) {
|
|
1238
|
-
return this.post(`/app/${appId}/api/iterations/${encodeURIComponent(iterationName)}/reset`, {});
|
|
1239
|
-
}
|
|
1240
1440
|
// ============================================
|
|
1241
1441
|
// RESOURCE METADATA (values — issue #1352)
|
|
1242
1442
|
// ============================================
|
|
@@ -1340,86 +1540,11 @@ export class ApiClient {
|
|
|
1340
1540
|
async duplicatePromptConfig(appId, promptId, configId, payload) {
|
|
1341
1541
|
return this.post(`/admin/api/apps/${appId}/prompts/${promptId}/configs/${configId}/duplicate`, payload || {});
|
|
1342
1542
|
}
|
|
1343
|
-
// ============================================
|
|
1344
|
-
// SCRIPTS (Rhai transforms) — #1000 (prompt-model convergence)
|
|
1345
|
-
// ============================================
|
|
1346
|
-
//
|
|
1347
|
-
// The `Script` model is the authoring surface for `script` workflow
|
|
1348
|
-
// steps. A `Script` is a HEADER (name/description/activeConfigId); the
|
|
1349
|
-
// Rhai body lives on versioned `ScriptConfig` rows resolved LIVE at run
|
|
1350
|
-
// time. CLI `config push` reads `transforms/*.rhai` files and reconciles
|
|
1351
|
-
// them: a new file → create script (mints a default config); a changed
|
|
1352
|
-
// file → create a new config + activate it (zero fan-out — referencing
|
|
1353
|
-
// workflows pick up the new body on their next run).
|
|
1354
|
-
async listScripts(appId) {
|
|
1355
|
-
const result = await this.get(`/admin/api/apps/${appId}/scripts`);
|
|
1356
|
-
return { items: result?.items ?? [] };
|
|
1357
|
-
}
|
|
1358
|
-
async getScript(appId, scriptId) {
|
|
1359
|
-
return this.get(`/admin/api/apps/${appId}/scripts/${scriptId}`);
|
|
1360
|
-
}
|
|
1361
|
-
/**
|
|
1362
|
-
* List a script's versioned configs (the `ScriptConfig` rows). Each config
|
|
1363
|
-
* is a distinct block version: `configId` is the stable version selector,
|
|
1364
|
-
* `contentHash` is its content identity, and `status` reports whether it is
|
|
1365
|
-
* `active`/`draft`/`archived`. The script header's `activeConfigId` names
|
|
1366
|
-
* the live version. Used by `scripts configs list` and by the script test
|
|
1367
|
-
* commands to run against a specific pinned version.
|
|
1368
|
-
*/
|
|
1369
|
-
async listScriptConfigs(appId, scriptId) {
|
|
1370
|
-
const result = await this.get(`/admin/api/apps/${appId}/scripts/${scriptId}/configs`);
|
|
1371
|
-
return { items: result?.items ?? [] };
|
|
1372
|
-
}
|
|
1373
|
-
async createScript(appId, payload) {
|
|
1374
|
-
// Mints the script header + a default `active` config carrying the body.
|
|
1375
|
-
return this.post(`/admin/api/apps/${appId}/scripts`, payload);
|
|
1376
|
-
}
|
|
1377
|
-
/**
|
|
1378
|
-
* Push a new body for an existing script by creating a new `ScriptConfig`
|
|
1379
|
-
* and activating it (the prompt-model "edit → activate" flow). Referencing
|
|
1380
|
-
* workflows pick up the new body on their next run with no fan-out. The
|
|
1381
|
-
* config name is unique per script, so we mint a timestamped name.
|
|
1382
|
-
*/
|
|
1383
|
-
async pushScriptBody(appId, scriptId, body,
|
|
1384
|
-
/**
|
|
1385
|
-
* The active state the caller believes holds right now (#2731 B10).
|
|
1386
|
-
* Creating an inactive config races nothing, so the guard sits on the
|
|
1387
|
-
* ACTIVATION step: if the active config has moved since the caller read it,
|
|
1388
|
-
* the server rejects with a 409 instead of overwriting a concurrent script
|
|
1389
|
-
* change. It takes BOTH halves of "what is active", because a config's body
|
|
1390
|
-
* can be edited in place without the active id changing — the id alone
|
|
1391
|
-
* would let such an edit through. Omitted (e.g. `--force`) means activate
|
|
1392
|
-
* unconditionally.
|
|
1393
|
-
*/
|
|
1394
|
-
expectedActive) {
|
|
1395
|
-
const configName = `sync-${Date.now()}`;
|
|
1396
|
-
const config = await this.post(`/admin/api/apps/${appId}/scripts/${scriptId}/configs`, { configName, body });
|
|
1397
|
-
const activateBody = {};
|
|
1398
|
-
if (expectedActive?.configId) {
|
|
1399
|
-
activateBody.expectedActiveConfigId = expectedActive.configId;
|
|
1400
|
-
}
|
|
1401
|
-
if (expectedActive?.modifiedAt) {
|
|
1402
|
-
activateBody.expectedActiveModifiedAt = expectedActive.modifiedAt;
|
|
1403
|
-
}
|
|
1404
|
-
await this.post(`/admin/api/apps/${appId}/scripts/${scriptId}/configs/${config.configId}/activate`, activateBody);
|
|
1405
|
-
return config;
|
|
1406
|
-
}
|
|
1407
|
-
/**
|
|
1408
|
-
* Delete a script header (cascades its configs). `force` overrides the
|
|
1409
|
-
* server's guard against deleting a script that an active workflow still
|
|
1410
|
-
* references by name — without it the server answers 409.
|
|
1411
|
-
*/
|
|
1412
|
-
async deleteScript(appId, scriptId, force) {
|
|
1413
|
-
const path = force
|
|
1414
|
-
? `/admin/api/apps/${appId}/scripts/${scriptId}?force=true`
|
|
1415
|
-
: `/admin/api/apps/${appId}/scripts/${scriptId}`;
|
|
1416
|
-
return this.delete(path);
|
|
1417
|
-
}
|
|
1418
1543
|
async getPromptSchema(appId, promptId) {
|
|
1419
1544
|
return this.get(`/admin/api/apps/${appId}/prompts/${promptId}/schema`);
|
|
1420
1545
|
}
|
|
1421
1546
|
// ============================================
|
|
1422
|
-
// BLOCK TEST CASES (Prompts, Integrations
|
|
1547
|
+
// BLOCK TEST CASES (Prompts, Integrations)
|
|
1423
1548
|
// ============================================
|
|
1424
1549
|
/**
|
|
1425
1550
|
* One page of a block's test cases. The endpoint paginates (default 50, cap
|
|
@@ -1587,188 +1712,171 @@ export class ApiClient {
|
|
|
1587
1712
|
async runAllTestCases(appId, blockType, blockId, payload) {
|
|
1588
1713
|
return this.post(`/admin/api/apps/${appId}/blocks/${blockType}/${blockId}/test-all`, payload || {});
|
|
1589
1714
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1715
|
+
/**
|
|
1716
|
+
* One page of a block's test runs, newest first. The endpoint paginates
|
|
1717
|
+
* (default 50, cap 100) and reports `nextCursor`.
|
|
1718
|
+
*/
|
|
1719
|
+
async listTestRuns(appId, blockType, blockId, params = {}) {
|
|
1720
|
+
const query = new URLSearchParams();
|
|
1721
|
+
if (params.limit !== undefined)
|
|
1722
|
+
query.set("limit", String(params.limit));
|
|
1723
|
+
if (params.cursor)
|
|
1724
|
+
query.set("cursor", params.cursor);
|
|
1725
|
+
const suffix = query.toString() ? `?${query.toString()}` : "";
|
|
1726
|
+
const result = await this.get(`/admin/api/apps/${appId}/blocks/${blockType}/${blockId}/runs${suffix}`);
|
|
1599
1727
|
return {
|
|
1600
1728
|
items: result?.items ?? [],
|
|
1601
1729
|
hasMore: result?.hasMore,
|
|
1602
|
-
nextCursor: result?.nextCursor ??
|
|
1730
|
+
nextCursor: result?.nextCursor ?? undefined,
|
|
1603
1731
|
};
|
|
1604
1732
|
}
|
|
1605
|
-
async getWorkflow(appId, workflowId) {
|
|
1606
|
-
return this.get(`/admin/api/apps/${appId}/workflows/${workflowId}`);
|
|
1607
|
-
}
|
|
1608
1733
|
/**
|
|
1609
|
-
* One
|
|
1610
|
-
*
|
|
1611
|
-
*
|
|
1612
|
-
* window, so the server applies its own default rather than the CLI
|
|
1613
|
-
* restating it on the wire.
|
|
1734
|
+
* One of a block's test runs: the object `listTestRuns` lists for it. The
|
|
1735
|
+
* run id travels as one path segment, so a `/`, `?` or `#` in it can never
|
|
1736
|
+
* reach the listing or the query.
|
|
1614
1737
|
*/
|
|
1615
|
-
async
|
|
1616
|
-
return this.get(`/admin/api/apps/${appId}/
|
|
1617
|
-
}
|
|
1618
|
-
async createWorkflow(appId, payload) {
|
|
1619
|
-
return this.post(`/admin/api/apps/${appId}/workflows`, payload);
|
|
1738
|
+
async getTestRun(appId, blockType, blockId, runId) {
|
|
1739
|
+
return this.get(`/admin/api/apps/${appId}/blocks/${blockType}/${blockId}/runs/${encodeURIComponent(runId)}`);
|
|
1620
1740
|
}
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1741
|
+
// ============================================
|
|
1742
|
+
// ANALYTICS
|
|
1743
|
+
// ============================================
|
|
1744
|
+
async getAnalyticsTopUsers(appId, params) {
|
|
1745
|
+
return this.get(`/app/${appId}/api/analytics/users/top`, params);
|
|
1624
1746
|
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
*
|
|
1628
|
-
* The plain call ARCHIVES: the definition row stays, so its runs, revisions
|
|
1629
|
-
* and test cases keep resolving. `{ hard: true }` performs the full cascade
|
|
1630
|
-
* and is what releases the `workflowKey` — the flag `config push --prune`
|
|
1631
|
-
* sends, for the same reason it sends it for webhooks and integrations.
|
|
1632
|
-
*/
|
|
1633
|
-
async deleteWorkflow(appId, workflowId, options) {
|
|
1634
|
-
const path = `/admin/api/apps/${appId}/workflows/${workflowId}`;
|
|
1635
|
-
return this.delete(options?.hard ? `${path}?hard=true` : path);
|
|
1747
|
+
async getAnalyticsIntegrationMetrics(appId, params) {
|
|
1748
|
+
return this.get(`/app/${appId}/api/analytics/integrations`, params);
|
|
1636
1749
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
* PATCH: `config push` owns every configuration field, and taking a workflow
|
|
1640
|
-
* out of service must not touch one, or an operator's action would show up as
|
|
1641
|
-
* drift against the repo. Same route shape as `cron-triggers pause|resume`.
|
|
1642
|
-
*/
|
|
1643
|
-
async disableWorkflow(appId, workflowId) {
|
|
1644
|
-
return this.post(`/app/${appId}/api/workflows/${workflowId}/disable`, {});
|
|
1750
|
+
async getAnalyticsOverviewDau(appId, params) {
|
|
1751
|
+
return this.get(`/app/${appId}/api/analytics/overview/dau`, params);
|
|
1645
1752
|
}
|
|
1646
|
-
async
|
|
1647
|
-
return this.
|
|
1753
|
+
async getAnalyticsOverviewWau(appId, params) {
|
|
1754
|
+
return this.get(`/app/${appId}/api/analytics/overview/wau`, params);
|
|
1648
1755
|
}
|
|
1649
|
-
async
|
|
1650
|
-
return this.
|
|
1756
|
+
async getAnalyticsOverviewMau(appId, params) {
|
|
1757
|
+
return this.get(`/app/${appId}/api/analytics/overview/mau`, params);
|
|
1651
1758
|
}
|
|
1652
|
-
async
|
|
1653
|
-
return this.
|
|
1759
|
+
async getAnalyticsOverviewGrowth(appId, params) {
|
|
1760
|
+
return this.get(`/app/${appId}/api/analytics/overview/growth`, params);
|
|
1654
1761
|
}
|
|
1655
|
-
async
|
|
1656
|
-
return this.get(`/
|
|
1762
|
+
async getAnalyticsDailyActive(appId, params) {
|
|
1763
|
+
return this.get(`/app/${appId}/api/analytics/daily-active`, params);
|
|
1657
1764
|
}
|
|
1658
|
-
async
|
|
1659
|
-
|
|
1660
|
-
const nextCursor = result?.nextCursor ?? null;
|
|
1661
|
-
return {
|
|
1662
|
-
items: result?.items ?? [],
|
|
1663
|
-
hasMore: result?.hasMore,
|
|
1664
|
-
nextCursor,
|
|
1665
|
-
resumeAfter: result?.resumeAfter,
|
|
1666
|
-
scanned: typeof result?.scanned === "number" ? result.scanned : undefined,
|
|
1667
|
-
};
|
|
1765
|
+
async getAnalyticsRollingActive(appId, params) {
|
|
1766
|
+
return this.get(`/app/${appId}/api/analytics/rolling-active`, params);
|
|
1668
1767
|
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
* Backed by `GET /admin/api/apps/{appId}/users/{userId}/workflow-runs`,
|
|
1672
|
-
* which resolves the app user before querying the `runsByUser` index.
|
|
1673
|
-
*/
|
|
1674
|
-
async listUserWorkflowRuns(appId, userId, params) {
|
|
1675
|
-
const result = await this.get(`/admin/api/apps/${appId}/users/${encodeURIComponent(userId)}/workflow-runs`, params);
|
|
1676
|
-
const nextCursor = result?.nextCursor ?? null;
|
|
1677
|
-
return {
|
|
1678
|
-
items: result?.items ?? [],
|
|
1679
|
-
hasMore: result?.hasMore,
|
|
1680
|
-
nextCursor,
|
|
1681
|
-
scanned: typeof result?.scanned === "number" ? result.scanned : undefined,
|
|
1682
|
-
};
|
|
1768
|
+
async getAnalyticsCohortRetention(appId, params) {
|
|
1769
|
+
return this.get(`/app/${appId}/api/analytics/cohort-retention`, params);
|
|
1683
1770
|
}
|
|
1684
|
-
async
|
|
1685
|
-
return this.get(`/
|
|
1771
|
+
async getAnalyticsUserSearch(appId, params) {
|
|
1772
|
+
return this.get(`/app/${appId}/api/analytics/users/search`, params);
|
|
1686
1773
|
}
|
|
1687
|
-
async
|
|
1688
|
-
|
|
1689
|
-
return { items: result?.items ?? [] };
|
|
1774
|
+
async getAnalyticsUserDetail(appId, userUlid, params) {
|
|
1775
|
+
return this.get(`/app/${appId}/api/analytics/users/${userUlid}/detail`, params);
|
|
1690
1776
|
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1777
|
+
async getAnalyticsUserSnapshot(appId, userUlid, params) {
|
|
1778
|
+
return this.get(`/app/${appId}/api/analytics/users/${userUlid}/snapshot`, params);
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* #5251 — `path` with `params` set as `get` sets them, then one appended
|
|
1782
|
+
* `filter[<field>][<operator>]` entry per filter, in order. `get`'s record
|
|
1783
|
+
* cannot hold two entries under one key; the server ANDs them all.
|
|
1784
|
+
*/
|
|
1785
|
+
analyticsFilteredGet(path, params, filters) {
|
|
1786
|
+
if (!filters || filters.length === 0)
|
|
1787
|
+
return this.get(path, params);
|
|
1788
|
+
const query = new URLSearchParams();
|
|
1789
|
+
for (const [key, value] of Object.entries(params ?? {})) {
|
|
1790
|
+
if (value !== undefined && value !== null) {
|
|
1791
|
+
query.set(key, String(value));
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
for (const filter of filters) {
|
|
1795
|
+
query.append(`filter[${filter.field}][${filter.operator}]`, filter.value);
|
|
1796
|
+
}
|
|
1797
|
+
return this.get(`${path}?${query.toString()}`);
|
|
1700
1798
|
}
|
|
1701
|
-
async
|
|
1702
|
-
return this.
|
|
1799
|
+
async getAnalyticsEvents(appId, params, filters) {
|
|
1800
|
+
return this.analyticsFilteredGet(`/app/${appId}/api/analytics/events`, params, filters);
|
|
1703
1801
|
}
|
|
1704
|
-
async
|
|
1705
|
-
return this.
|
|
1802
|
+
async getAnalyticsEventsGrouped(appId, params, filters) {
|
|
1803
|
+
return this.analyticsFilteredGet(`/app/${appId}/api/analytics/events/grouped`, params, filters);
|
|
1706
1804
|
}
|
|
1707
|
-
async
|
|
1708
|
-
return this.
|
|
1805
|
+
async getAnalyticsErrorsGroups(appId, params, filters) {
|
|
1806
|
+
return this.analyticsFilteredGet(`/app/${appId}/api/analytics/errors/groups`, params, filters);
|
|
1709
1807
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1808
|
+
/** The app's db3 query shapes that read the most rows (#5244). */
|
|
1809
|
+
async getAnalyticsDb3Queries(appId, params) {
|
|
1810
|
+
return this.get(`/app/${appId}/api/analytics/db3/queries`, params);
|
|
1712
1811
|
}
|
|
1713
|
-
|
|
1714
|
-
|
|
1812
|
+
/** The app's request wall time and DynamoDB round trips per endpoint and function (#5244). */
|
|
1813
|
+
async getAnalyticsRequests(appId, params) {
|
|
1814
|
+
return this.get(`/app/${appId}/api/analytics/requests`, params);
|
|
1715
1815
|
}
|
|
1716
|
-
async
|
|
1717
|
-
return this.
|
|
1816
|
+
async getAnalyticsTopPrompts(appId, params) {
|
|
1817
|
+
return this.get(`/app/${appId}/api/analytics/prompts/top`, params);
|
|
1718
1818
|
}
|
|
1719
1819
|
// ============================================
|
|
1720
|
-
//
|
|
1820
|
+
// PLATFORM TRANSITIONS (#5821)
|
|
1721
1821
|
// ============================================
|
|
1722
|
-
|
|
1723
|
-
|
|
1822
|
+
/** An app's platform transitions: each one's value and where it came from. */
|
|
1823
|
+
async getAppTransitions(appId) {
|
|
1824
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/transitions`);
|
|
1724
1825
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
async getAnalyticsOverviewDau(appId) {
|
|
1729
|
-
return this.get(`/app/${appId}/api/analytics/overview/dau`);
|
|
1826
|
+
/** Set one platform transition on one app, with a reason (super-admin). */
|
|
1827
|
+
async setAppTransition(appId, transition, body) {
|
|
1828
|
+
return this.put(`/super-admin/api/apps/${encodeURIComponent(appId)}/transitions/${encodeURIComponent(transition)}`, body);
|
|
1730
1829
|
}
|
|
1731
|
-
|
|
1732
|
-
|
|
1830
|
+
/** One page of an app's transition changes, newest first (super-admin). */
|
|
1831
|
+
async listAppTransitionChanges(appId, params) {
|
|
1832
|
+
return this.get(`/super-admin/api/apps/${encodeURIComponent(appId)}/transitions/changes`, params);
|
|
1733
1833
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
async getAnalyticsOverviewGrowth(appId, params) {
|
|
1738
|
-
return this.get(`/app/${appId}/api/analytics/overview/growth`, params);
|
|
1739
|
-
}
|
|
1740
|
-
async getAnalyticsDailyActive(appId, params) {
|
|
1741
|
-
return this.get(`/app/${appId}/api/analytics/daily-active`, params);
|
|
1834
|
+
/** The registered transitions, with apps per value from one budgeted walk (super-admin). */
|
|
1835
|
+
async listTransitions(params) {
|
|
1836
|
+
return this.get(`/super-admin/api/transitions`, params);
|
|
1742
1837
|
}
|
|
1743
|
-
|
|
1744
|
-
|
|
1838
|
+
/** One page of a transition's report: each app's state, use by call site and eligible date (super-admin). */
|
|
1839
|
+
async getTransitionReport(transition, params) {
|
|
1840
|
+
return this.get(`/super-admin/api/transitions/${encodeURIComponent(transition)}/report`, params);
|
|
1745
1841
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1842
|
+
/** One page of a transition's move plan: what the daily move step would do with each unit (super-admin, #5824). */
|
|
1843
|
+
async getTransitionMovePlan(transition, params) {
|
|
1844
|
+
return this.get(`/super-admin/api/transitions/${encodeURIComponent(transition)}/move-plan`, params);
|
|
1748
1845
|
}
|
|
1749
|
-
|
|
1750
|
-
|
|
1846
|
+
/** Recent calls to deprecated operations, by app, operation, source and client (super-admin). */
|
|
1847
|
+
async getDeprecatedCalls(params) {
|
|
1848
|
+
return this.get(`/super-admin/api/transitions/deprecated-calls`, params);
|
|
1751
1849
|
}
|
|
1752
|
-
|
|
1753
|
-
|
|
1850
|
+
// ============================================
|
|
1851
|
+
// USAGE (#5713)
|
|
1852
|
+
// ============================================
|
|
1853
|
+
/** An app's usage and estimated cost for `month` (`YYYY-MM`, default the current month). */
|
|
1854
|
+
async getAppUsage(appId, params) {
|
|
1855
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/usage`, params);
|
|
1754
1856
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1857
|
+
/** An app's top users over a window, by a meter's quantity or by cost. */
|
|
1858
|
+
async getAppUsageTopUsers(appId, params) {
|
|
1859
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/usage/users`, params);
|
|
1757
1860
|
}
|
|
1758
|
-
|
|
1759
|
-
|
|
1861
|
+
/** One user's usage over a window and the bytes they own. */
|
|
1862
|
+
async getAppUsageUser(appId, userId, params) {
|
|
1863
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/usage/users/${encodeURIComponent(userId)}`, params);
|
|
1760
1864
|
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1865
|
+
/** An app's system usage over a window, by origin, source, resource and meter. */
|
|
1866
|
+
async getAppUsageSystem(appId, params) {
|
|
1867
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/usage/system`, params);
|
|
1763
1868
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1869
|
+
/** The top apps by estimated cost, month to date (super-admin). */
|
|
1870
|
+
async listUsageTopApps(params) {
|
|
1871
|
+
return this.get("/super-admin/api/maintenance/usage/apps", params);
|
|
1766
1872
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1873
|
+
/** The top developers by estimated cost, month to date (super-admin). */
|
|
1874
|
+
async listUsageTopDevelopers(params) {
|
|
1875
|
+
return this.get("/super-admin/api/maintenance/usage/developers", params);
|
|
1769
1876
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1877
|
+
/** The usage jobs' state (super-admin). */
|
|
1878
|
+
async getUsageJobs() {
|
|
1879
|
+
return this.get("/super-admin/api/maintenance/usage/jobs");
|
|
1772
1880
|
}
|
|
1773
1881
|
// ============================================
|
|
1774
1882
|
// SUPER ADMIN: ADMINS
|
|
@@ -1784,7 +1892,7 @@ export class ApiClient {
|
|
|
1784
1892
|
return this.get("/admin/api/me");
|
|
1785
1893
|
}
|
|
1786
1894
|
async listAllAdmins(params) {
|
|
1787
|
-
const result = await this.get("/admin/api/admins", params);
|
|
1895
|
+
const result = await this.get("/super-admin/api/admins", params);
|
|
1788
1896
|
const nextCursor = result?.nextCursor ?? null;
|
|
1789
1897
|
const items = result?.items ?? [];
|
|
1790
1898
|
return {
|
|
@@ -1794,70 +1902,32 @@ export class ApiClient {
|
|
|
1794
1902
|
};
|
|
1795
1903
|
}
|
|
1796
1904
|
async searchAdminByEmail(email) {
|
|
1797
|
-
return this.get("/admin/api/admins/search", { email });
|
|
1905
|
+
return this.get("/super-admin/api/admins/search", { email });
|
|
1798
1906
|
}
|
|
1799
1907
|
async getAdminApps(email) {
|
|
1800
|
-
return this.get(`/admin/api/admins/${encodeURIComponent(email)}/apps`);
|
|
1908
|
+
return this.get(`/super-admin/api/admins/${encodeURIComponent(email)}/apps`);
|
|
1801
1909
|
}
|
|
1802
1910
|
async updateAdminSettings(adminId, data) {
|
|
1803
|
-
return this.patch(`/admin/api/admins/${adminId}`, data);
|
|
1911
|
+
return this.patch(`/super-admin/api/admins/${adminId}`, data);
|
|
1804
1912
|
}
|
|
1805
1913
|
async reindexAdmin(adminId) {
|
|
1806
|
-
return this.post(`/admin/api/admins/${adminId}/reindex`, {});
|
|
1914
|
+
return this.post(`/super-admin/api/admins/${adminId}/reindex`, {});
|
|
1915
|
+
}
|
|
1916
|
+
/** `reindexAdmin` with the route's answer, for callers that print it. */
|
|
1917
|
+
async reindexAdminWithResult(adminId) {
|
|
1918
|
+
return this.post(`/super-admin/api/admins/${adminId}/reindex`, {});
|
|
1807
1919
|
}
|
|
1808
1920
|
// Admin Invitations
|
|
1809
|
-
|
|
1810
|
-
|
|
1921
|
+
/** One address's pending admin invitations; the route requires the address. */
|
|
1922
|
+
async listAllAdminInvitations(email) {
|
|
1923
|
+
const result = await this.get("/super-admin/api/admins/invitations", { email });
|
|
1811
1924
|
return result?.invitations ?? [];
|
|
1812
1925
|
}
|
|
1813
1926
|
async createGlobalAdminInvitation(data) {
|
|
1814
|
-
return this.post("/admin/api/admins/invitations", data);
|
|
1927
|
+
return this.post("/super-admin/api/admins/invitations", data);
|
|
1815
1928
|
}
|
|
1816
1929
|
async deleteGlobalAdminInvitation(invitationId) {
|
|
1817
|
-
return this.delete(`/admin/api/admins/invitations/${invitationId}`);
|
|
1818
|
-
}
|
|
1819
|
-
// ============================================
|
|
1820
|
-
// SUPER ADMIN: CATALOG
|
|
1821
|
-
// ============================================
|
|
1822
|
-
async listPromptCatalog(params) {
|
|
1823
|
-
const result = await this.get("/admin/api/catalog/prompts", params);
|
|
1824
|
-
return {
|
|
1825
|
-
items: result?.items ?? [],
|
|
1826
|
-
hasMore: result?.hasMore,
|
|
1827
|
-
nextCursor: result?.nextCursor ?? null,
|
|
1828
|
-
};
|
|
1829
|
-
}
|
|
1830
|
-
async getPromptCatalogItem(catalogId) {
|
|
1831
|
-
return this.get(`/admin/api/catalog/prompts/${catalogId}`);
|
|
1832
|
-
}
|
|
1833
|
-
async createPromptCatalogItem(payload) {
|
|
1834
|
-
return this.post("/admin/api/catalog/prompts", payload);
|
|
1835
|
-
}
|
|
1836
|
-
async updatePromptCatalogItem(catalogId, payload) {
|
|
1837
|
-
return this.patch(`/admin/api/catalog/prompts/${catalogId}`, payload);
|
|
1838
|
-
}
|
|
1839
|
-
async deletePromptCatalogItem(catalogId) {
|
|
1840
|
-
return this.delete(`/admin/api/catalog/prompts/${catalogId}`);
|
|
1841
|
-
}
|
|
1842
|
-
async listIntegrationCatalog(params) {
|
|
1843
|
-
const result = await this.get("/admin/api/catalog/integrations", params);
|
|
1844
|
-
return {
|
|
1845
|
-
items: result?.items ?? [],
|
|
1846
|
-
hasMore: result?.hasMore,
|
|
1847
|
-
nextCursor: result?.nextCursor ?? null,
|
|
1848
|
-
};
|
|
1849
|
-
}
|
|
1850
|
-
async getIntegrationCatalogItem(catalogId) {
|
|
1851
|
-
return this.get(`/admin/api/catalog/integrations/${catalogId}`);
|
|
1852
|
-
}
|
|
1853
|
-
async createIntegrationCatalogItem(payload) {
|
|
1854
|
-
return this.post("/admin/api/catalog/integrations", payload);
|
|
1855
|
-
}
|
|
1856
|
-
async updateIntegrationCatalogItem(catalogId, payload) {
|
|
1857
|
-
return this.patch(`/admin/api/catalog/integrations/${catalogId}`, payload);
|
|
1858
|
-
}
|
|
1859
|
-
async deleteIntegrationCatalogItem(catalogId) {
|
|
1860
|
-
return this.delete(`/admin/api/catalog/integrations/${catalogId}`);
|
|
1930
|
+
return this.delete(`/super-admin/api/admins/invitations/${invitationId}`);
|
|
1861
1931
|
}
|
|
1862
1932
|
// ============================================
|
|
1863
1933
|
// BATCH TEST EXECUTION
|
|
@@ -1904,6 +1974,15 @@ export class ApiClient {
|
|
|
1904
1974
|
async testEmailTemplate(appId, emailType, payload) {
|
|
1905
1975
|
return this.post(`/admin/api/apps/${appId}/email-templates/${emailType}/test`, payload || {});
|
|
1906
1976
|
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Render the saved template (or the built-in default) for an email type
|
|
1979
|
+
* without sending it. `variables` override the type's sample values. The
|
|
1980
|
+
* app id and the type are each encoded as one path segment, so no value of
|
|
1981
|
+
* either can select another route.
|
|
1982
|
+
*/
|
|
1983
|
+
async previewEmailTemplate(appId, emailType, payload) {
|
|
1984
|
+
return this.post(`/admin/api/apps/${encodeURIComponent(appId)}/email-templates/${encodeURIComponent(emailType)}/preview`, payload || {});
|
|
1985
|
+
}
|
|
1907
1986
|
// ============================================
|
|
1908
1987
|
// ACCESS TOKENS
|
|
1909
1988
|
// ============================================
|
|
@@ -2115,13 +2194,18 @@ export class ApiClient {
|
|
|
2115
2194
|
const query = options?.dryRun ? "?dryRun=true" : "";
|
|
2116
2195
|
return this.post(`/app/${appId}/api/databases/types${query}`, data);
|
|
2117
2196
|
}
|
|
2118
|
-
async updateDatabaseTypeConfig(appId, databaseType, data, expectedModifiedAt,
|
|
2197
|
+
async updateDatabaseTypeConfig(appId, databaseType, data, expectedModifiedAt,
|
|
2198
|
+
// #6019: `allowFieldRemoval` asks for the append-only override, which the
|
|
2199
|
+
// server takes only on an app whose stored settings enable it.
|
|
2200
|
+
options) {
|
|
2119
2201
|
const body = expectedModifiedAt ? { ...data, expectedModifiedAt } : data;
|
|
2120
2202
|
const qs = new URLSearchParams();
|
|
2121
2203
|
if (options?.dryRun)
|
|
2122
2204
|
qs.set("dryRun", "true");
|
|
2123
2205
|
if (options?.acceptWarnings)
|
|
2124
2206
|
qs.set("acceptWarnings", "true");
|
|
2207
|
+
if (options?.allowFieldRemoval)
|
|
2208
|
+
qs.set("allowFieldRemoval", "true");
|
|
2125
2209
|
const query = qs.toString();
|
|
2126
2210
|
const path = `/app/${appId}/api/databases/types/${encodeURIComponent(databaseType)}${query ? `?${query}` : ""}`;
|
|
2127
2211
|
return this.patch(path, body);
|
|
@@ -2150,31 +2234,55 @@ export class ApiClient {
|
|
|
2150
2234
|
hasMore: result?.hasMore ?? nextCursor != null,
|
|
2151
2235
|
};
|
|
2152
2236
|
}
|
|
2237
|
+
/** One page of one custodian's groups (`app` or `user:<userId>`), through the admin API. */
|
|
2238
|
+
async listGroupsByCustodian(appId, custodian, params) {
|
|
2239
|
+
const result = await this.get(`/admin/api/apps/${appId}/groups`, { custodian, ...(params ?? {}) });
|
|
2240
|
+
const nextCursor = result?.nextCursor;
|
|
2241
|
+
return {
|
|
2242
|
+
items: result?.items ?? [],
|
|
2243
|
+
nextCursor,
|
|
2244
|
+
hasMore: result?.hasMore ?? nextCursor != null,
|
|
2245
|
+
};
|
|
2246
|
+
}
|
|
2247
|
+
/** Transfer a group to `to` (`app` or `user:<userId>`) through the admin API. */
|
|
2248
|
+
async transferGroup(appId, groupId, to) {
|
|
2249
|
+
return this.post(`/admin/api/apps/${appId}/groups/${encodeURIComponent(groupId)}/transfer`, { to });
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Create a group through the admin API; `custodian` is `app` or
|
|
2253
|
+
* `user:<userId>`. The server mints the group's id and answers it as
|
|
2254
|
+
* `groupId`.
|
|
2255
|
+
*/
|
|
2153
2256
|
async createGroup(appId, data) {
|
|
2154
|
-
return this.post(`/
|
|
2257
|
+
return this.post(`/admin/api/apps/${appId}/groups`, data);
|
|
2155
2258
|
}
|
|
2156
|
-
|
|
2157
|
-
|
|
2259
|
+
/**
|
|
2260
|
+
* A group by id. `groupType` looks a group written before groups were
|
|
2261
|
+
* addressed by id up by its type first (the routes' deprecated
|
|
2262
|
+
* `?groupType=`), as an exported collection's grants still name them.
|
|
2263
|
+
*/
|
|
2264
|
+
async getGroup(appId, groupId, options) {
|
|
2265
|
+
return this.get(`/app/${appId}/api/groups/${encodeURIComponent(groupId)}`, options?.groupType ? { groupType: options.groupType } : undefined);
|
|
2158
2266
|
}
|
|
2159
|
-
async updateGroup(appId,
|
|
2160
|
-
return this.patch(`/app/${appId}/api/groups/${
|
|
2267
|
+
async updateGroup(appId, groupId, data) {
|
|
2268
|
+
return this.patch(`/app/${appId}/api/groups/${encodeURIComponent(groupId)}`, data);
|
|
2161
2269
|
}
|
|
2162
|
-
async deleteGroup(appId,
|
|
2163
|
-
return this.delete(`/app/${appId}/api/groups/${
|
|
2270
|
+
async deleteGroup(appId, groupId) {
|
|
2271
|
+
return this.delete(`/app/${appId}/api/groups/${encodeURIComponent(groupId)}`);
|
|
2164
2272
|
}
|
|
2165
2273
|
// ============================================
|
|
2166
2274
|
// GROUP MEMBERS
|
|
2167
2275
|
// ============================================
|
|
2168
2276
|
/**
|
|
2169
|
-
* One page of a group's members.
|
|
2277
|
+
* One page of a group's members, with their roles.
|
|
2170
2278
|
*
|
|
2171
2279
|
* The route paginates cursor-style (no default limit, cap 200) and reports
|
|
2172
2280
|
* the boundary, so `groups members list` carries `--limit`/`--cursor` and
|
|
2173
2281
|
* forwards them (#3646) rather than printing a first page that claims to be
|
|
2174
2282
|
* the whole membership.
|
|
2175
2283
|
*/
|
|
2176
|
-
async listGroupMembers(appId,
|
|
2177
|
-
const result = await this.get(`/app/${appId}/api/groups/${
|
|
2284
|
+
async listGroupMembers(appId, groupId, options) {
|
|
2285
|
+
const result = await this.get(`/app/${appId}/api/groups/${encodeURIComponent(groupId)}/members`, {
|
|
2178
2286
|
...(options?.include ? { include: options.include } : {}),
|
|
2179
2287
|
...(options?.limit !== undefined ? { limit: options.limit } : {}),
|
|
2180
2288
|
...(options?.cursor ? { cursor: options.cursor } : {}),
|
|
@@ -2186,17 +2294,23 @@ export class ApiClient {
|
|
|
2186
2294
|
hasMore: result?.hasMore ?? nextCursor != null,
|
|
2187
2295
|
};
|
|
2188
2296
|
}
|
|
2189
|
-
|
|
2190
|
-
|
|
2297
|
+
/** Add a member through the admin API; `role: "owner"` restores the custodian's owner row. */
|
|
2298
|
+
async addGroupMember(appId, groupId, data) {
|
|
2299
|
+
return this.post(`/admin/api/apps/${appId}/groups/${encodeURIComponent(groupId)}/members`, data);
|
|
2300
|
+
}
|
|
2301
|
+
/** Change a member's role through the admin API, the owner row's included. */
|
|
2302
|
+
async setGroupMemberRole(appId, groupId, userId, role) {
|
|
2303
|
+
return this.patch(`/admin/api/apps/${appId}/groups/${encodeURIComponent(groupId)}/members/${encodeURIComponent(userId)}`, { role });
|
|
2191
2304
|
}
|
|
2192
|
-
|
|
2193
|
-
|
|
2305
|
+
/** Remove a member through the admin API, the owner row included. */
|
|
2306
|
+
async removeGroupMember(appId, groupId, userId) {
|
|
2307
|
+
return this.delete(`/admin/api/apps/${appId}/groups/${encodeURIComponent(groupId)}/members/${encodeURIComponent(userId)}`);
|
|
2194
2308
|
}
|
|
2195
2309
|
// ============================================
|
|
2196
2310
|
// GROUP RESOURCE LISTINGS
|
|
2197
2311
|
// ============================================
|
|
2198
|
-
async listGroupDocuments(appId,
|
|
2199
|
-
return this.get(`/app/${appId}/api/groups/${
|
|
2312
|
+
async listGroupDocuments(appId, groupId) {
|
|
2313
|
+
return this.get(`/app/${appId}/api/groups/${encodeURIComponent(groupId)}/documents`);
|
|
2200
2314
|
}
|
|
2201
2315
|
// ============================================
|
|
2202
2316
|
// USER MEMBERSHIPS
|
|
@@ -2250,6 +2364,33 @@ export class ApiClient {
|
|
|
2250
2364
|
async createCollection(appId, data) {
|
|
2251
2365
|
return this.post(`/app/${appId}/api/collections`, data);
|
|
2252
2366
|
}
|
|
2367
|
+
/** One page of one custodian's collections (`app` or `user:<userId>`), through the admin API. */
|
|
2368
|
+
async listCollectionsByCustodian(appId, custodian, params) {
|
|
2369
|
+
const query = { custodian };
|
|
2370
|
+
if (params?.limit !== undefined)
|
|
2371
|
+
query.limit = params.limit;
|
|
2372
|
+
if (params?.cursor)
|
|
2373
|
+
query.cursor = params.cursor;
|
|
2374
|
+
const result = await this.get(`/admin/api/apps/${appId}/collections`, query);
|
|
2375
|
+
const nextCursor = result?.nextCursor;
|
|
2376
|
+
return {
|
|
2377
|
+
items: result?.items ?? [],
|
|
2378
|
+
nextCursor,
|
|
2379
|
+
hasMore: result?.hasMore ?? nextCursor != null,
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
/** Transfer a collection to `to` (`app` or `user:<userId>`) through the admin API. */
|
|
2383
|
+
async transferCollection(appId, collectionId, to) {
|
|
2384
|
+
return this.post(`/admin/api/apps/${appId}/collections/${encodeURIComponent(collectionId)}/transfer`, { to });
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
* Create a collection through the admin API, for `custodian` (`app` or
|
|
2388
|
+
* `user:<userId>`; a user custodian holds the owner row). Spends no
|
|
2389
|
+
* create budget.
|
|
2390
|
+
*/
|
|
2391
|
+
async createCollectionAsAdmin(appId, data) {
|
|
2392
|
+
return this.post(`/admin/api/apps/${appId}/collections`, data);
|
|
2393
|
+
}
|
|
2253
2394
|
async getCollection(appId, collectionId) {
|
|
2254
2395
|
return this.get(`/app/${appId}/api/collections/${collectionId}`);
|
|
2255
2396
|
}
|
|
@@ -2296,41 +2437,30 @@ export class ApiClient {
|
|
|
2296
2437
|
};
|
|
2297
2438
|
}
|
|
2298
2439
|
// ============================================
|
|
2299
|
-
// COLLECTION
|
|
2440
|
+
// COLLECTION MEMBERS (USERS + GROUPS)
|
|
2300
2441
|
// ============================================
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
return this.delete(`/app/${appId}/api/collections/${collectionId}/group-permissions/${groupType}/${groupId}`);
|
|
2442
|
+
/**
|
|
2443
|
+
* Every member of a collection, users and groups as principals with their
|
|
2444
|
+
* roles, in one answer.
|
|
2445
|
+
*/
|
|
2446
|
+
async listCollectionMembers(appId, collectionId) {
|
|
2447
|
+
const result = await this.get(`/app/${appId}/api/collections/${encodeURIComponent(collectionId)}/members`);
|
|
2448
|
+
return { items: result?.items ?? [], hasMore: Boolean(result?.hasMore) };
|
|
2309
2449
|
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Add a user or a group to a collection through the admin API, with a role;
|
|
2452
|
+
* `role: "owner"` restores the custodian's owner row.
|
|
2453
|
+
*/
|
|
2310
2454
|
async addCollectionMember(appId, collectionId, data) {
|
|
2311
|
-
return this.post(`/
|
|
2312
|
-
}
|
|
2313
|
-
async removeCollectionMember(appId, collectionId, userId) {
|
|
2314
|
-
return this.delete(`/app/${appId}/api/collections/${collectionId}/members/${userId}`);
|
|
2315
|
-
}
|
|
2316
|
-
// ============================================
|
|
2317
|
-
// COLLECTION TYPE CONFIGS
|
|
2318
|
-
// ============================================
|
|
2319
|
-
async listCollectionTypeConfigs(appId) {
|
|
2320
|
-
return this.get(`/app/${appId}/api/collection-type-configs`);
|
|
2321
|
-
}
|
|
2322
|
-
async getCollectionTypeConfig(appId, collectionType) {
|
|
2323
|
-
return this.get(`/app/${appId}/api/collection-type-configs/${collectionType}`);
|
|
2455
|
+
return this.post(`/admin/api/apps/${appId}/collections/${encodeURIComponent(collectionId)}/members`, data);
|
|
2324
2456
|
}
|
|
2325
|
-
|
|
2326
|
-
|
|
2457
|
+
/** Change a member's role through the admin API, the owner row's included. */
|
|
2458
|
+
async setCollectionMemberRole(appId, collectionId, principal, role) {
|
|
2459
|
+
return this.patch(`/admin/api/apps/${appId}/collections/${encodeURIComponent(collectionId)}/members/${encodeURIComponent(principal)}`, { role });
|
|
2327
2460
|
}
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
return this.
|
|
2331
|
-
}
|
|
2332
|
-
async deleteCollectionTypeConfig(appId, collectionType) {
|
|
2333
|
-
return this.delete(`/app/${appId}/api/collection-type-configs/${collectionType}`);
|
|
2461
|
+
/** Remove a user or `group:<groupId>` through the admin API, the owner row included. */
|
|
2462
|
+
async removeCollectionMember(appId, collectionId, principal) {
|
|
2463
|
+
return this.delete(`/admin/api/apps/${appId}/collections/${encodeURIComponent(collectionId)}/members/${encodeURIComponent(principal)}`);
|
|
2334
2464
|
}
|
|
2335
2465
|
// ============================================
|
|
2336
2466
|
// METADATA CATEGORY CONFIGS (issue #1304, P-B)
|
|
@@ -2401,25 +2531,6 @@ export class ApiClient {
|
|
|
2401
2531
|
return this.post(`/app/${appId}/api/rule-sets/debug`, data);
|
|
2402
2532
|
}
|
|
2403
2533
|
// ============================================
|
|
2404
|
-
// GROUP TYPE CONFIGS
|
|
2405
|
-
// ============================================
|
|
2406
|
-
async listGroupTypeConfigs(appId) {
|
|
2407
|
-
return this.get(`/app/${appId}/api/group-type-configs`);
|
|
2408
|
-
}
|
|
2409
|
-
async getGroupTypeConfig(appId, groupType) {
|
|
2410
|
-
return this.get(`/app/${appId}/api/group-type-configs/${groupType}`);
|
|
2411
|
-
}
|
|
2412
|
-
async createGroupTypeConfig(appId, data) {
|
|
2413
|
-
return this.post(`/app/${appId}/api/group-type-configs`, data);
|
|
2414
|
-
}
|
|
2415
|
-
async updateGroupTypeConfig(appId, groupType, data, expectedModifiedAt) {
|
|
2416
|
-
const body = expectedModifiedAt ? { ...data, expectedModifiedAt } : data;
|
|
2417
|
-
return this.patch(`/app/${appId}/api/group-type-configs/${groupType}`, body);
|
|
2418
|
-
}
|
|
2419
|
-
async deleteGroupTypeConfig(appId, groupType) {
|
|
2420
|
-
return this.delete(`/app/${appId}/api/group-type-configs/${groupType}`);
|
|
2421
|
-
}
|
|
2422
|
-
// ============================================
|
|
2423
2534
|
// DOCUMENT EXPORT / IMPORT
|
|
2424
2535
|
// ============================================
|
|
2425
2536
|
async exportDocumentState(appId, documentId) {
|
|
@@ -2504,6 +2615,8 @@ export class ApiClient {
|
|
|
2504
2615
|
query.filter = JSON.stringify(queryOptions.filter);
|
|
2505
2616
|
if (queryOptions?.sort !== undefined)
|
|
2506
2617
|
query.sort = JSON.stringify(queryOptions.sort);
|
|
2618
|
+
if (queryOptions?.include !== undefined)
|
|
2619
|
+
query.include = JSON.stringify(queryOptions.include);
|
|
2507
2620
|
if (queryOptions?.documentFormat !== undefined) {
|
|
2508
2621
|
query.documentFormat = queryOptions.documentFormat;
|
|
2509
2622
|
}
|
|
@@ -2532,13 +2645,14 @@ export class ApiClient {
|
|
|
2532
2645
|
/**
|
|
2533
2646
|
* Aggregate records in a document model (issue #2437) — the documents twin
|
|
2534
2647
|
* of {@link aggregateDatabaseRecords}. `POST documents/:id/records/:model/aggregate`
|
|
2535
|
-
* with `{ options: { operations, groupBy?, filter? } }`,
|
|
2536
|
-
* in the same shape as the database endpoint.
|
|
2648
|
+
* with `{ options: { operations, groupBy?, filter?, sort?, limit? } }`,
|
|
2649
|
+
* answering `{ result }` in the same shape as the database endpoint.
|
|
2537
2650
|
*
|
|
2538
2651
|
* `groupBy` takes plain field names and period levels `{ field, period }`
|
|
2539
|
-
* (keyed `<field>_<period>` in a row's `group`)
|
|
2540
|
-
*
|
|
2541
|
-
*
|
|
2652
|
+
* (keyed `<field>_<period>` in a row's `group`). On a db3 (a format-3
|
|
2653
|
+
* document) a StringSet field name is a facet, `{ field, contains }` a
|
|
2654
|
+
* membership, and `sort` and `limit` order and bound the groups; a format-1
|
|
2655
|
+
* document refuses those four with a 400.
|
|
2542
2656
|
*/
|
|
2543
2657
|
async aggregateDocumentRecords(appId, documentId, modelName, options, extra) {
|
|
2544
2658
|
return this.post(`/app/${appId}/api/documents/${documentId}/records/${encodeURIComponent(modelName)}/aggregate` +
|
|
@@ -2618,6 +2732,10 @@ export class ApiClient {
|
|
|
2618
2732
|
* would name one the body does not use.
|
|
2619
2733
|
*/
|
|
2620
2734
|
async uploadDocumentIngestChunk(appId, documentId, sessionId, chunk) {
|
|
2735
|
+
return this.uploadIngestChunkAt(`/app/${appId}/api/documents/${documentId}`, sessionId, chunk);
|
|
2736
|
+
}
|
|
2737
|
+
/** A chunk upload to `<base>/ingest/<session>/chunks`: the documents route or its db3 mount. */
|
|
2738
|
+
async uploadIngestChunkAt(base, sessionId, chunk) {
|
|
2621
2739
|
const credentials = await this.ensureAuthenticated();
|
|
2622
2740
|
const form = new FormData();
|
|
2623
2741
|
form.set("model", chunk.model);
|
|
@@ -2629,8 +2747,7 @@ export class ApiClient {
|
|
|
2629
2747
|
form.set("firstId", chunk.firstId);
|
|
2630
2748
|
form.set("lastId", chunk.lastId);
|
|
2631
2749
|
form.set("chunk", new Blob([chunk.body]), `${chunk.index}.ndjson.gz`);
|
|
2632
|
-
const url = `${credentials.serverUrl}
|
|
2633
|
-
`/ingest/${encodeURIComponent(sessionId)}/chunks`;
|
|
2750
|
+
const url = `${credentials.serverUrl}${base}/ingest/${encodeURIComponent(sessionId)}/chunks`;
|
|
2634
2751
|
const response = await this.fetchWithStepUp(url, url, credentials.accessToken, (bearer) => {
|
|
2635
2752
|
const headers = {
|
|
2636
2753
|
Authorization: `Bearer ${bearer}`,
|
|
@@ -2706,14 +2823,434 @@ export class ApiClient {
|
|
|
2706
2823
|
}
|
|
2707
2824
|
/**
|
|
2708
2825
|
* Apply an ordered multi-model create/patch/delete blob atomically (issue
|
|
2709
|
-
* #1964 Phase 4, wrapping the #1517 `bulkUpdate` facade)
|
|
2710
|
-
*
|
|
2711
|
-
* `{ applied, added,
|
|
2826
|
+
* #1964 Phase 4, wrapping the #1517 `bulkUpdate` facade): `POST
|
|
2827
|
+
* records/batch`, at most 100 operations. All-or-nothing: a validation
|
|
2828
|
+
* failure commits nothing. Returns the facade's `{ applied, added,
|
|
2829
|
+
* updated, deleted }`, and on a db3 `reads` when the batch carried reads.
|
|
2712
2830
|
*/
|
|
2713
|
-
async
|
|
2714
|
-
return this.post(`/app/${appId}/api/documents/${documentId}/records/
|
|
2831
|
+
async batchDocumentRecords(appId, documentId, operations, extra) {
|
|
2832
|
+
return this.post(`/app/${appId}/api/documents/${documentId}/records/batch` +
|
|
2715
2833
|
this.documentFormatQuery(extra?.documentFormat), { operations });
|
|
2716
2834
|
}
|
|
2835
|
+
// ============================================
|
|
2836
|
+
// DB3 (format-3 documents)
|
|
2837
|
+
// ============================================
|
|
2838
|
+
/** `/app/<app>/api/db3/<id>`, the id encoded: every `db3.*` route's prefix. */
|
|
2839
|
+
db3Path(appId, db3Id) {
|
|
2840
|
+
return `/app/${appId}/api/db3/${encodeURIComponent(db3Id)}`;
|
|
2841
|
+
}
|
|
2842
|
+
/** `GET db3/:id/indexes` → `{ indexes }`, sorted by name. */
|
|
2843
|
+
async listDb3Indexes(appId, db3Id) {
|
|
2844
|
+
return this.get(`${this.db3Path(appId, db3Id)}/indexes`);
|
|
2845
|
+
}
|
|
2846
|
+
/**
|
|
2847
|
+
* `POST db3/:id/indexes` with `{ model, field | fields, unique?, name? }`,
|
|
2848
|
+
* `{ model, field, members: true }` for a member index, or `{ model, field
|
|
2849
|
+
* | fields, kind: "text", on, text? }` for a text index → `{ index }`. The
|
|
2850
|
+
* route applies the registration rules.
|
|
2851
|
+
*/
|
|
2852
|
+
async registerDb3Index(appId, db3Id, body) {
|
|
2853
|
+
return this.post(`${this.db3Path(appId, db3Id)}/indexes`, body);
|
|
2854
|
+
}
|
|
2855
|
+
/** `DELETE db3/:id/indexes/:name` → `{ ok, name }`. */
|
|
2856
|
+
async dropDb3Index(appId, db3Id, name) {
|
|
2857
|
+
return this.delete(`${this.db3Path(appId, db3Id)}/indexes/${encodeURIComponent(name)}`);
|
|
2858
|
+
}
|
|
2859
|
+
/**
|
|
2860
|
+
* `GET db3/:id/indexes/:name/model` (#5229): a vector index's shared model,
|
|
2861
|
+
* its bytes as uploaded and the `X-Index-Model-*` headers it was uploaded
|
|
2862
|
+
* with.
|
|
2863
|
+
*/
|
|
2864
|
+
async fetchDb3IndexModel(appId, db3Id, name) {
|
|
2865
|
+
const credentials = await this.ensureAuthenticated();
|
|
2866
|
+
const url = `${credentials.serverUrl}${this.db3Path(appId, db3Id)}/indexes/${encodeURIComponent(name)}/model`;
|
|
2867
|
+
const headers = { Authorization: `Bearer ${credentials.accessToken}` };
|
|
2868
|
+
if (credentials.globalAdminAppId)
|
|
2869
|
+
headers["X-Global-Admin-App-Id"] = credentials.globalAdminAppId;
|
|
2870
|
+
const response = await fetchWithTLS(url, { method: "GET", headers });
|
|
2871
|
+
if (!response.ok) {
|
|
2872
|
+
const text = await response.text();
|
|
2873
|
+
const parsed = parseErrorResponse(response, text, url);
|
|
2874
|
+
throw new ApiError(parsed.message, response.status, parsed.code, parsed.details);
|
|
2875
|
+
}
|
|
2876
|
+
const header = (key) => response.headers.get(`X-Index-Model-${key}`) ?? "";
|
|
2877
|
+
return {
|
|
2878
|
+
data: Buffer.from(await response.arrayBuffer()),
|
|
2879
|
+
generation: Number(header("Generation")),
|
|
2880
|
+
revision: Number(header("Revision")),
|
|
2881
|
+
rows: Number(header("Rows")),
|
|
2882
|
+
trainedAt: header("Trained-At"),
|
|
2883
|
+
format: header("Format"),
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2886
|
+
/**
|
|
2887
|
+
* `DELETE db3/:id/indexes/:name/model` (#5229) → `{ ok, name, revision }`:
|
|
2888
|
+
* the model (or an upload under way) gone, `revision` the index's new one.
|
|
2889
|
+
*/
|
|
2890
|
+
async deleteDb3IndexModel(appId, db3Id, name) {
|
|
2891
|
+
return this.delete(`${this.db3Path(appId, db3Id)}/indexes/${encodeURIComponent(name)}/model`);
|
|
2892
|
+
}
|
|
2893
|
+
/** The db3 mount of {@link queryDocumentRecords}: `GET db3/:id/records/:model`. */
|
|
2894
|
+
async queryDb3Records(appId, db3Id, modelName, queryOptions) {
|
|
2895
|
+
const query = {};
|
|
2896
|
+
if (queryOptions?.filter)
|
|
2897
|
+
query.filter = JSON.stringify(queryOptions.filter);
|
|
2898
|
+
if (queryOptions?.sort !== undefined)
|
|
2899
|
+
query.sort = JSON.stringify(queryOptions.sort);
|
|
2900
|
+
if (queryOptions?.include !== undefined)
|
|
2901
|
+
query.include = JSON.stringify(queryOptions.include);
|
|
2902
|
+
if (queryOptions?.limit !== undefined)
|
|
2903
|
+
query.limit = queryOptions.limit;
|
|
2904
|
+
if (queryOptions?.cursor)
|
|
2905
|
+
query.cursor = queryOptions.cursor;
|
|
2906
|
+
// #6022 — the CLI prints a renamed field under its current name.
|
|
2907
|
+
query.names = "current";
|
|
2908
|
+
const raw = await this.get(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}`, query);
|
|
2909
|
+
return normalizeCliListEnvelope(raw);
|
|
2910
|
+
}
|
|
2911
|
+
/** The db3 mount of {@link countDocumentRecords}: `GET db3/:id/records/:model/count`. */
|
|
2912
|
+
async countDb3Records(appId, db3Id, modelName, queryOptions) {
|
|
2913
|
+
const query = {};
|
|
2914
|
+
if (queryOptions?.filter)
|
|
2915
|
+
query.filter = JSON.stringify(queryOptions.filter);
|
|
2916
|
+
query.names = "current";
|
|
2917
|
+
return this.get(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/count`, query);
|
|
2918
|
+
}
|
|
2919
|
+
/** The db3 mount of {@link aggregateDocumentRecords}: `POST db3/:id/records/:model/aggregate`. */
|
|
2920
|
+
async aggregateDb3Records(appId, db3Id, modelName, options) {
|
|
2921
|
+
return this.post(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/aggregate${DB3_CURRENT_NAMES}`, { options });
|
|
2922
|
+
}
|
|
2923
|
+
/**
|
|
2924
|
+
* `POST db3/:id/records/:model/explain` (#5240): run a query, count or
|
|
2925
|
+
* aggregate on the server, forced onto `index` (or off indexes, `"none"`)
|
|
2926
|
+
* when given, and answer how it read.
|
|
2927
|
+
*/
|
|
2928
|
+
async explainDb3Read(appId, db3Id, modelName, body) {
|
|
2929
|
+
return this.post(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/explain`, body);
|
|
2930
|
+
}
|
|
2931
|
+
/** The db3 mount of {@link saveDocumentRecord}: `POST db3/:id/records/:model`. */
|
|
2932
|
+
async saveDb3Record(appId, db3Id, modelName, body) {
|
|
2933
|
+
return this.post(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}${DB3_CURRENT_NAMES}`, body);
|
|
2934
|
+
}
|
|
2935
|
+
/** The db3 mount of {@link patchDocumentRecord}: `PATCH db3/:id/records/:model/:recordId`. */
|
|
2936
|
+
async patchDb3Record(appId, db3Id, modelName, recordId, body) {
|
|
2937
|
+
return this.patch(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/${encodeURIComponent(recordId)}${DB3_CURRENT_NAMES}`, body);
|
|
2938
|
+
}
|
|
2939
|
+
/** The db3 mount of {@link deleteDocumentRecord}: `DELETE db3/:id/records/:model/:recordId`. */
|
|
2940
|
+
async deleteDb3Record(appId, db3Id, modelName, recordId) {
|
|
2941
|
+
return this.delete(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/${encodeURIComponent(recordId)}`);
|
|
2942
|
+
}
|
|
2943
|
+
/** The db3 mount of {@link batchDocumentRecords}: `POST db3/:id/records/batch`. */
|
|
2944
|
+
async batchDb3Records(appId, db3Id, operations) {
|
|
2945
|
+
return this.post(`${this.db3Path(appId, db3Id)}/records/batch${DB3_CURRENT_NAMES}`, { operations });
|
|
2946
|
+
}
|
|
2947
|
+
/**
|
|
2948
|
+
* Several reads of a db3 in one request (#5243): `POST db3/:id/records/batch-read`,
|
|
2949
|
+
* each answered at its index from one state of the db3. `atomic: false`
|
|
2950
|
+
* answers a refused read in its place rather than refusing the request.
|
|
2951
|
+
*/
|
|
2952
|
+
async batchReadDb3Records(appId, db3Id, operations, options = {}) {
|
|
2953
|
+
return this.post(`${this.db3Path(appId, db3Id)}/records/batch-read${DB3_CURRENT_NAMES}`, {
|
|
2954
|
+
operations,
|
|
2955
|
+
...(options.atomic === false ? { atomic: false } : {}),
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
/** The db3 mount of {@link getDocumentSchema}: `GET db3/:id/schema`. */
|
|
2959
|
+
async getDb3Schema(appId, db3Id) {
|
|
2960
|
+
return this.get(`${this.db3Path(appId, db3Id)}/schema`);
|
|
2961
|
+
}
|
|
2962
|
+
/** `?limit=&cursor=` for a listing. */
|
|
2963
|
+
pageQuery(options = {}) {
|
|
2964
|
+
const params = new URLSearchParams();
|
|
2965
|
+
if (options.limit !== undefined)
|
|
2966
|
+
params.set("limit", String(options.limit));
|
|
2967
|
+
if (options.cursor)
|
|
2968
|
+
params.set("cursor", options.cursor);
|
|
2969
|
+
const query = params.toString();
|
|
2970
|
+
return query ? `?${query}` : "";
|
|
2971
|
+
}
|
|
2972
|
+
/** `GET db3/:id/ingest` (#4889): a db3's bulk-load sessions, newest first. */
|
|
2973
|
+
async listDb3Ingests(appId, db3Id, options = {}) {
|
|
2974
|
+
return this.get(`${this.db3Path(appId, db3Id)}/ingest${this.pageQuery(options)}`);
|
|
2975
|
+
}
|
|
2976
|
+
/** `GET db3/:id/ingest/:sessionId` (#4889). */
|
|
2977
|
+
async getDb3Ingest(appId, db3Id, sessionId) {
|
|
2978
|
+
return this.get(`${this.db3Path(appId, db3Id)}/ingest/${encodeURIComponent(sessionId)}`);
|
|
2979
|
+
}
|
|
2980
|
+
/** `POST db3/:id/ingest` (#4889): open a bulk-load session; `{}` keeps the defaults. */
|
|
2981
|
+
async createDb3Ingest(appId, db3Id, options = {}) {
|
|
2982
|
+
return this.post(`${this.db3Path(appId, db3Id)}/ingest`, options);
|
|
2983
|
+
}
|
|
2984
|
+
/** `POST db3/:id/ingest/:sessionId/chunks` (#4889): one chunk, multipart, as the documents upload sends it. */
|
|
2985
|
+
async uploadDb3IngestChunk(appId, db3Id, sessionId, chunk) {
|
|
2986
|
+
return this.uploadIngestChunkAt(this.db3Path(appId, db3Id), sessionId, chunk);
|
|
2987
|
+
}
|
|
2988
|
+
/** `POST db3/:id/ingest/:sessionId/commit` (#4889). */
|
|
2989
|
+
async commitDb3Ingest(appId, db3Id, sessionId) {
|
|
2990
|
+
return this.post(`${this.db3Path(appId, db3Id)}/ingest/${encodeURIComponent(sessionId)}/commit`, {});
|
|
2991
|
+
}
|
|
2992
|
+
/** `POST db3/:id/ingest/:sessionId/abort` (#4889). */
|
|
2993
|
+
async abortDb3Ingest(appId, db3Id, sessionId) {
|
|
2994
|
+
return this.post(`${this.db3Path(appId, db3Id)}/ingest/${encodeURIComponent(sessionId)}/abort`, {});
|
|
2995
|
+
}
|
|
2996
|
+
/** `GET db3/:id/snapshots` (#4889): a db3's segment exports, newest first. */
|
|
2997
|
+
async listDb3Snapshots(appId, db3Id, options = {}) {
|
|
2998
|
+
return this.get(`${this.db3Path(appId, db3Id)}/snapshots${this.pageQuery(options)}`);
|
|
2999
|
+
}
|
|
3000
|
+
/** `GET db3/:id/snapshots/:segmentId` (#4889). */
|
|
3001
|
+
async getDb3Snapshot(appId, db3Id, segmentId) {
|
|
3002
|
+
return this.get(`${this.db3Path(appId, db3Id)}/snapshots/${encodeURIComponent(segmentId)}`);
|
|
3003
|
+
}
|
|
3004
|
+
/** `POST db3/:id/snapshots` (#4889): start a segment export. */
|
|
3005
|
+
async requestDb3Snapshot(appId, db3Id) {
|
|
3006
|
+
return this.post(`${this.db3Path(appId, db3Id)}/snapshots`, {});
|
|
3007
|
+
}
|
|
3008
|
+
/** `GET db3/:id/export/chain` (#4889): the current segment, signed for download. */
|
|
3009
|
+
async exportDb3Chain(appId, db3Id) {
|
|
3010
|
+
return this.get(`${this.db3Path(appId, db3Id)}/export/chain`);
|
|
3011
|
+
}
|
|
3012
|
+
/** `GET db3/:id/blobs` (#4889): one page of a db3's blobs. */
|
|
3013
|
+
async listDb3Blobs(appId, db3Id, params) {
|
|
3014
|
+
return this.get(`${this.db3Path(appId, db3Id)}/blobs`, params);
|
|
3015
|
+
}
|
|
3016
|
+
/** `GET db3/:id/blobs/:blobId/download` (#4889): a blob's bytes. */
|
|
3017
|
+
async downloadDb3Blob(appId, db3Id, blobId) {
|
|
3018
|
+
return this.downloadBlobAt(this.db3Path(appId, db3Id), blobId);
|
|
3019
|
+
}
|
|
3020
|
+
/** `PUT db3/:id/blobs/:blobId` (#4889): a blob under its own id, as the documents upload sends it. */
|
|
3021
|
+
async uploadDb3Blob(appId, db3Id, blobId, data, meta) {
|
|
3022
|
+
return this.uploadBlobAt(this.db3Path(appId, db3Id), blobId, data, meta);
|
|
3023
|
+
}
|
|
3024
|
+
/** The db3 mount of {@link getDocumentRoom}: `GET db3/:id/room`. App admins only. */
|
|
3025
|
+
async getDb3Room(appId, db3Id, query = {}) {
|
|
3026
|
+
const params = new URLSearchParams();
|
|
3027
|
+
if (query.refused !== undefined)
|
|
3028
|
+
params.set("refused", query.refused);
|
|
3029
|
+
if (query.limit !== undefined)
|
|
3030
|
+
params.set("limit", String(query.limit));
|
|
3031
|
+
if (query.cursor !== undefined)
|
|
3032
|
+
params.set("cursor", query.cursor);
|
|
3033
|
+
const search = params.toString();
|
|
3034
|
+
return this.get(`${this.db3Path(appId, db3Id)}/room${search ? `?${search}` : ""}`);
|
|
3035
|
+
}
|
|
3036
|
+
/**
|
|
3037
|
+
* `POST db3` (#4804): create a db3 and answer it, `{ id, title, createdBy,
|
|
3038
|
+
* createdAt, modifiedAt, custodian, sync, type, tags }`. Without `custodian`
|
|
3039
|
+
* an admin token's create is held by the app. `id` keeps a caller-chosen id
|
|
3040
|
+
* (#4921), refused `DB3_ID_EXISTS` when the app holds it.
|
|
3041
|
+
*/
|
|
3042
|
+
async createDb3(appId, body) {
|
|
3043
|
+
return this.post(`/app/${appId}/api/db3`, body);
|
|
3044
|
+
}
|
|
3045
|
+
/** `GET db3/:id` (#4804): the db3, with the caller's grant when it reads it through one. */
|
|
3046
|
+
async getDb3(appId, db3Id) {
|
|
3047
|
+
return this.get(this.db3Path(appId, db3Id));
|
|
3048
|
+
}
|
|
3049
|
+
/**
|
|
3050
|
+
* `PUT db3/:id` (#5890): rename a db3, answered as `getDb3` answers it with
|
|
3051
|
+
* the new title.
|
|
3052
|
+
*/
|
|
3053
|
+
async updateDb3(appId, db3Id, body) {
|
|
3054
|
+
return this.put(this.db3Path(appId, db3Id), body);
|
|
3055
|
+
}
|
|
3056
|
+
/** `DELETE db3/:id` (#4804): the documents delete for a db3. */
|
|
3057
|
+
async deleteDb3(appId, db3Id) {
|
|
3058
|
+
return this.delete(this.db3Path(appId, db3Id));
|
|
3059
|
+
}
|
|
3060
|
+
/** The db3 mount of {@link getDocumentStats}: `GET db3/:id/stats`. */
|
|
3061
|
+
async getDb3Stats(appId, db3Id) {
|
|
3062
|
+
return this.get(`${this.db3Path(appId, db3Id)}/stats`);
|
|
3063
|
+
}
|
|
3064
|
+
/**
|
|
3065
|
+
* `POST db3/:id/records/:model/:recordId/increment` (#4797): add each of
|
|
3066
|
+
* `fields` to the record's field, answering `{ record, values }`.
|
|
3067
|
+
*/
|
|
3068
|
+
async incrementDb3Record(appId, db3Id, modelName, recordId, body) {
|
|
3069
|
+
return this.post(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/${encodeURIComponent(recordId)}/increment${DB3_CURRENT_NAMES}`, body);
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* `POST db3/:id/records/:model/clear` (#5994): empty one model in one
|
|
3073
|
+
* operation; `{ ok, model, rows, lsn, epoch, dropped, cost }`.
|
|
3074
|
+
*/
|
|
3075
|
+
async clearDb3Model(appId, db3Id, modelName, body = {}) {
|
|
3076
|
+
return this.post(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/clear`, body);
|
|
3077
|
+
}
|
|
3078
|
+
/** `GET db3/:id/sync` (#4799): `{ id, sync }`. */
|
|
3079
|
+
async getDb3Sync(appId, db3Id) {
|
|
3080
|
+
return this.get(`${this.db3Path(appId, db3Id)}/sync`);
|
|
3081
|
+
}
|
|
3082
|
+
/** `PUT db3/:id/sync` (#4799): `{ id, sync, changed }`. */
|
|
3083
|
+
async setDb3Sync(appId, db3Id, sync) {
|
|
3084
|
+
return this.put(`${this.db3Path(appId, db3Id)}/sync`, { sync });
|
|
3085
|
+
}
|
|
3086
|
+
/** `GET db3/:id/app-access` (#4801): `{ id, level }`, the level every user of the app holds, or null. */
|
|
3087
|
+
async getDb3AppAccess(appId, db3Id) {
|
|
3088
|
+
return this.get(`${this.db3Path(appId, db3Id)}/app-access`);
|
|
3089
|
+
}
|
|
3090
|
+
/** `PUT db3/:id/app-access` (#4801): grant the db3 to every user of the app, or remove the grant with null. */
|
|
3091
|
+
async setDb3AppAccess(appId, db3Id, level) {
|
|
3092
|
+
return this.put(`${this.db3Path(appId, db3Id)}/app-access`, { level });
|
|
3093
|
+
}
|
|
3094
|
+
/**
|
|
3095
|
+
* `PUT db3/:id/public-access` (#5842): mark the db3 public at `reader`, or
|
|
3096
|
+
* clear it with null; `signedOutAccess` is the app's setting, which decides
|
|
3097
|
+
* whether the value is honoured yet.
|
|
3098
|
+
*/
|
|
3099
|
+
async setDb3PublicAccess(appId, db3Id, level) {
|
|
3100
|
+
return this.put(`${this.db3Path(appId, db3Id)}/public-access`, { level });
|
|
3101
|
+
}
|
|
3102
|
+
/** `GET db3/:id/link-access`: `{ documentId, linkAccess, … }`, `linkAccess` null when off. */
|
|
3103
|
+
async getDb3LinkAccess(appId, db3Id) {
|
|
3104
|
+
return this.get(`${this.db3Path(appId, db3Id)}/link-access`);
|
|
3105
|
+
}
|
|
3106
|
+
/** `PUT db3/:id/link-access`: let anyone in the app with the id open the db3 at `level`. */
|
|
3107
|
+
async setDb3LinkAccess(appId, db3Id, level) {
|
|
3108
|
+
return this.put(`${this.db3Path(appId, db3Id)}/link-access`, { level });
|
|
3109
|
+
}
|
|
3110
|
+
/** `DELETE db3/:id/link-access`: turn the db3's link access off. */
|
|
3111
|
+
async clearDb3LinkAccess(appId, db3Id) {
|
|
3112
|
+
return this.delete(`${this.db3Path(appId, db3Id)}/link-access`);
|
|
3113
|
+
}
|
|
3114
|
+
/** `GET db3/:id/permissions`: the db3's user grants, a bare array of `{ userId, email, name, permission, grantedAt }`. */
|
|
3115
|
+
async listDb3Permissions(appId, db3Id) {
|
|
3116
|
+
return this.get(`${this.db3Path(appId, db3Id)}/permissions`);
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* `PUT db3/:id/permissions`: grant one user, named by `userId` or `email`,
|
|
3120
|
+
* a level; `sendEmail` tells them, with `documentUrl` and `note` in the email.
|
|
3121
|
+
*/
|
|
3122
|
+
async grantDb3Permission(appId, db3Id, entry, email) {
|
|
3123
|
+
return this.put(`${this.db3Path(appId, db3Id)}/permissions`, { permissions: [entry], ...(email ?? {}) });
|
|
3124
|
+
}
|
|
3125
|
+
/** `DELETE db3/:id/permissions/:userId`, or `DELETE db3/:id/permissions?email=` for an email: revoke one user's grant. */
|
|
3126
|
+
async revokeDb3Permission(appId, db3Id, target) {
|
|
3127
|
+
if (target.email) {
|
|
3128
|
+
return this.delete(`${this.db3Path(appId, db3Id)}/permissions?email=${encodeURIComponent(target.email)}`);
|
|
3129
|
+
}
|
|
3130
|
+
if (!target.userId)
|
|
3131
|
+
throw new Error("revokeDb3Permission: userId or email is required");
|
|
3132
|
+
return this.delete(`${this.db3Path(appId, db3Id)}/permissions/${encodeURIComponent(target.userId)}`);
|
|
3133
|
+
}
|
|
3134
|
+
/** `GET db3/:id/group-permissions`: the db3's group grants, a bare array; `includeSystem` adds system groups'. */
|
|
3135
|
+
async listDb3GroupPermissions(appId, db3Id, options) {
|
|
3136
|
+
return this.get(`${this.db3Path(appId, db3Id)}/group-permissions`, options?.includeSystem ? { includeSystem: "true" } : undefined);
|
|
3137
|
+
}
|
|
3138
|
+
/** `POST db3/:id/group-permissions`: grant a group, named by its id, a level. */
|
|
3139
|
+
async grantDb3GroupPermission(appId, db3Id, groupId, permission) {
|
|
3140
|
+
return this.post(`${this.db3Path(appId, db3Id)}/group-permissions`, { groupId, permission });
|
|
3141
|
+
}
|
|
3142
|
+
/** `DELETE db3/:id/group-permissions/:groupId`: revoke a group's grant. */
|
|
3143
|
+
async revokeDb3GroupPermission(appId, db3Id, groupId) {
|
|
3144
|
+
return this.delete(`${this.db3Path(appId, db3Id)}/group-permissions/${encodeURIComponent(groupId)}`);
|
|
3145
|
+
}
|
|
3146
|
+
/** `GET db3/:id/pending-invitations`: `{ items }`, the grants waiting for an address to join the app. */
|
|
3147
|
+
async listDb3PendingInvitations(appId, db3Id) {
|
|
3148
|
+
return this.get(`${this.db3Path(appId, db3Id)}/pending-invitations`);
|
|
3149
|
+
}
|
|
3150
|
+
/** `DELETE db3/:id/pending-invitations/:invitationId`: cancel a pending invitation's grants on this db3. */
|
|
3151
|
+
async revokeDb3PendingInvitation(appId, db3Id, invitationId) {
|
|
3152
|
+
return this.delete(`${this.db3Path(appId, db3Id)}/pending-invitations/${encodeURIComponent(invitationId)}`);
|
|
3153
|
+
}
|
|
3154
|
+
/** `GET db3/:id/access-requests`: the pending access requests, a bare array. */
|
|
3155
|
+
async listDb3AccessRequests(appId, db3Id) {
|
|
3156
|
+
return this.get(`${this.db3Path(appId, db3Id)}/access-requests`);
|
|
3157
|
+
}
|
|
3158
|
+
/**
|
|
3159
|
+
* `POST db3/:id/access-requests`: the signed-in caller asks for access.
|
|
3160
|
+
* `created` is true when the request is new (201) and false when the
|
|
3161
|
+
* caller's pending request was updated (200).
|
|
3162
|
+
*/
|
|
3163
|
+
async createDb3AccessRequest(appId, db3Id, body) {
|
|
3164
|
+
const answer = await this.post(`${this.db3Path(appId, db3Id)}/access-requests`, body);
|
|
3165
|
+
return { answer, created: this.lastStatus === 201 };
|
|
3166
|
+
}
|
|
3167
|
+
/** `POST db3/:id/access-requests/:requestId/approve`: grant the requested level, or `permission`. */
|
|
3168
|
+
async approveDb3AccessRequest(appId, db3Id, requestId, body = {}) {
|
|
3169
|
+
return this.post(`${this.db3Path(appId, db3Id)}/access-requests/${encodeURIComponent(requestId)}/approve`, body);
|
|
3170
|
+
}
|
|
3171
|
+
/** `POST db3/:id/access-requests/:requestId/deny`: deny the request. */
|
|
3172
|
+
async denyDb3AccessRequest(appId, db3Id, requestId, body = {}) {
|
|
3173
|
+
return this.post(`${this.db3Path(appId, db3Id)}/access-requests/${encodeURIComponent(requestId)}/deny`, body);
|
|
3174
|
+
}
|
|
3175
|
+
/** `POST db3/:id/validate-access` with `{ userId }`: a named user's effective access to the db3. */
|
|
3176
|
+
async validateDb3AccessForUser(appId, db3Id, userId) {
|
|
3177
|
+
return this.post(`${this.db3Path(appId, db3Id)}/validate-access`, { userId });
|
|
3178
|
+
}
|
|
3179
|
+
/** One custodian's db3s through the admin API (#4800): `custodian` is `app` or `user:<userId>`. */
|
|
3180
|
+
async listDb3ByCustodian(appId, custodian, params) {
|
|
3181
|
+
const result = await this.get(`/admin/api/apps/${appId}/db3`, { custodian, ...(params ?? {}) });
|
|
3182
|
+
const nextCursor = result?.nextCursor;
|
|
3183
|
+
return { items: result?.items ?? [], nextCursor, hasMore: result?.hasMore ?? nextCursor != null };
|
|
3184
|
+
}
|
|
3185
|
+
/**
|
|
3186
|
+
* Every db3 a member reaches through the admin API (#5253): held, shared
|
|
3187
|
+
* with them, then app access, each row with its `via`; `via` narrows to
|
|
3188
|
+
* some of the three ways.
|
|
3189
|
+
*/
|
|
3190
|
+
async listDb3ForUser(appId, userId, params) {
|
|
3191
|
+
const result = await this.get(`/admin/api/apps/${appId}/users/${encodeURIComponent(userId)}/db3`, {
|
|
3192
|
+
...(params?.via ? { via: params.via.join(",") } : {}),
|
|
3193
|
+
...(params?.limit !== undefined ? { limit: params.limit } : {}),
|
|
3194
|
+
...(params?.cursor ? { cursor: params.cursor } : {}),
|
|
3195
|
+
});
|
|
3196
|
+
const nextCursor = result?.nextCursor;
|
|
3197
|
+
return { items: result?.items ?? [], nextCursor, hasMore: result?.hasMore ?? nextCursor != null };
|
|
3198
|
+
}
|
|
3199
|
+
/** Transfer a db3 to `to` (`app` or `user:<userId>`) through the admin API (#4804). */
|
|
3200
|
+
async transferDb3(appId, db3Id, to) {
|
|
3201
|
+
return this.post(`/admin/api/apps/${appId}/db3/${encodeURIComponent(db3Id)}/transfer`, { to });
|
|
3202
|
+
}
|
|
3203
|
+
/** Remove or restore a db3's owner row through the admin API (#4804): `{ id, custodian, ownerRow, changed }`. */
|
|
3204
|
+
async setDb3OwnerRow(appId, db3Id, present) {
|
|
3205
|
+
return this.put(`/admin/api/apps/${appId}/db3/${encodeURIComponent(db3Id)}/owner-row`, { present });
|
|
3206
|
+
}
|
|
3207
|
+
/** `GET db3/:id/type` (#4802): the type the db3's row names, its revision, and what its room holds. */
|
|
3208
|
+
async getDb3Type(appId, db3Id) {
|
|
3209
|
+
return this.get(`${this.db3Path(appId, db3Id)}/type`);
|
|
3210
|
+
}
|
|
3211
|
+
/** `PUT db3/:id/type` (#4802): attach a type, installing its current revision whole or refusing it whole. */
|
|
3212
|
+
async attachDb3Type(appId, db3Id, type) {
|
|
3213
|
+
return this.put(`${this.db3Path(appId, db3Id)}/type`, { type });
|
|
3214
|
+
}
|
|
3215
|
+
/** `/app/<app>/api/db3-types/<name>`, the name encoded (#4802). */
|
|
3216
|
+
db3TypePath(appId, name) {
|
|
3217
|
+
return `/app/${appId}/api/db3-types/${encodeURIComponent(name)}`;
|
|
3218
|
+
}
|
|
3219
|
+
/** `GET db3-types` (#4802): the app's db3 types, each with its revision. */
|
|
3220
|
+
async listDb3Types(appId) {
|
|
3221
|
+
return this.get(`/app/${appId}/api/db3-types`);
|
|
3222
|
+
}
|
|
3223
|
+
/** `GET db3-types/:name` (#4802). */
|
|
3224
|
+
async getDb3TypeConfig(appId, name) {
|
|
3225
|
+
return this.get(this.db3TypePath(appId, name));
|
|
3226
|
+
}
|
|
3227
|
+
/**
|
|
3228
|
+
* `PUT db3-types/:name` (#4802): create or update the type, and push its new
|
|
3229
|
+
* revision to every db3 of it. `dryRun` judges the body and persists nothing;
|
|
3230
|
+
* `allowFieldRemoval` asks for the append-only override (#6019), which the
|
|
3231
|
+
* server takes only on an app whose stored settings enable it.
|
|
3232
|
+
*/
|
|
3233
|
+
async pushDb3Type(appId, name, data, options) {
|
|
3234
|
+
const qs = new URLSearchParams();
|
|
3235
|
+
if (options?.dryRun)
|
|
3236
|
+
qs.set("dryRun", "true");
|
|
3237
|
+
if (options?.allowFieldRemoval)
|
|
3238
|
+
qs.set("allowFieldRemoval", "true");
|
|
3239
|
+
const query = qs.toString();
|
|
3240
|
+
return this.put(`${this.db3TypePath(appId, name)}${query ? `?${query}` : ""}`, data);
|
|
3241
|
+
}
|
|
3242
|
+
/** `DELETE db3-types/:name` (#4802): refused while a db3 is of the type. */
|
|
3243
|
+
async deleteDb3Type(appId, name) {
|
|
3244
|
+
return this.delete(this.db3TypePath(appId, name));
|
|
3245
|
+
}
|
|
3246
|
+
/** `GET db3-types/:name/push-status` (#4802): a push's outcome per db3; the latest without `runId`. */
|
|
3247
|
+
async getDb3TypePushStatus(appId, name, runId) {
|
|
3248
|
+
return this.get(`${this.db3TypePath(appId, name)}/push-status${runId ? `?runId=${encodeURIComponent(runId)}` : ""}`);
|
|
3249
|
+
}
|
|
3250
|
+
/** `POST db3-types/:name/push?runId=` (#4802): push the current revision again to a run's refused and failed db3s. */
|
|
3251
|
+
async retryDb3TypePush(appId, name, runId) {
|
|
3252
|
+
return this.post(`${this.db3TypePath(appId, name)}/push?runId=${encodeURIComponent(runId)}`, {});
|
|
3253
|
+
}
|
|
2717
3254
|
async createDocument(appId, data) {
|
|
2718
3255
|
return this.post(`/app/${appId}/api/documents`, data);
|
|
2719
3256
|
}
|
|
@@ -2778,8 +3315,12 @@ export class ApiClient {
|
|
|
2778
3315
|
return this.get(`/app/${appId}/api/documents/${documentId}/blobs`, params);
|
|
2779
3316
|
}
|
|
2780
3317
|
async downloadBlob(appId, documentId, blobId) {
|
|
3318
|
+
return this.downloadBlobAt(`/app/${appId}/api/documents/${documentId}`, blobId);
|
|
3319
|
+
}
|
|
3320
|
+
/** A blob's bytes from `<base>/blobs/<id>/download`: the documents route or its db3 mount. */
|
|
3321
|
+
async downloadBlobAt(base, blobId) {
|
|
2781
3322
|
const credentials = await this.ensureAuthenticated();
|
|
2782
|
-
const url = `${credentials.serverUrl}
|
|
3323
|
+
const url = `${credentials.serverUrl}${base}/blobs/${blobId}/download`;
|
|
2783
3324
|
const headers = {
|
|
2784
3325
|
Authorization: `Bearer ${credentials.accessToken}`,
|
|
2785
3326
|
};
|
|
@@ -2794,8 +3335,12 @@ export class ApiClient {
|
|
|
2794
3335
|
return Buffer.from(arrayBuffer);
|
|
2795
3336
|
}
|
|
2796
3337
|
async uploadBlob(appId, documentId, blobId, data, meta) {
|
|
3338
|
+
return this.uploadBlobAt(`/app/${appId}/api/documents/${documentId}`, blobId, data, meta);
|
|
3339
|
+
}
|
|
3340
|
+
/** A blob PUT to `<base>/blobs/<id>`: the documents route or its db3 mount. */
|
|
3341
|
+
async uploadBlobAt(base, blobId, data, meta) {
|
|
2797
3342
|
const credentials = await this.ensureAuthenticated();
|
|
2798
|
-
const url = `${credentials.serverUrl}
|
|
3343
|
+
const url = `${credentials.serverUrl}${base}/blobs/${blobId}`;
|
|
2799
3344
|
const response = await this.fetchWithStepUp(url, url, credentials.accessToken, (bearer) => {
|
|
2800
3345
|
const headers = {
|
|
2801
3346
|
Authorization: `Bearer ${bearer}`,
|