primitive-admin 1.2.0-alpha.9 → 1.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +258 -186
- package/assets/skill/skills/primitive-platform/SKILL.md +93 -27
- package/dist/bin/primitive.js +15 -89
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.js +80 -17
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/agent-sessions.d.ts +129 -0
- package/dist/src/commands/agent-sessions.js +532 -20
- package/dist/src/commands/agent-sessions.js.map +1 -1
- package/dist/src/commands/analytics.js +207 -155
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps-children.js +3 -0
- package/dist/src/commands/apps-children.js.map +1 -1
- package/dist/src/commands/apps-transitions.d.ts +39 -0
- package/dist/src/commands/apps-transitions.js +198 -0
- package/dist/src/commands/apps-transitions.js.map +1 -0
- package/dist/src/commands/apps.d.ts +17 -0
- package/dist/src/commands/apps.js +108 -3
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth-sessions.js +2 -0
- package/dist/src/commands/auth-sessions.js.map +1 -1
- package/dist/src/commands/auth.js +138 -44
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.js +2 -0
- package/dist/src/commands/blob-buckets.js.map +1 -1
- package/dist/src/commands/collections.js +318 -256
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/comparisons.js +2 -0
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/config.d.ts +2 -2
- package/dist/src/commands/config.js +59 -33
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/connections.js +2 -0
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/database-type-configs.js +5 -3
- package/dist/src/commands/database-type-configs.js.map +1 -1
- package/dist/src/commands/databases.js +6 -4
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/db3-types.d.ts +15 -0
- package/dist/src/commands/db3-types.js +159 -0
- package/dist/src/commands/db3-types.js.map +1 -0
- package/dist/src/commands/db3.d.ts +24 -0
- package/dist/src/commands/db3.js +1444 -0
- package/dist/src/commands/db3.js.map +1 -0
- package/dist/src/commands/documents.d.ts +110 -10
- package/dist/src/commands/documents.js +1012 -748
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.js +74 -0
- package/dist/src/commands/email-templates.js.map +1 -1
- package/dist/src/commands/env.js +8 -4
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/function-trigger-commands.d.ts +28 -0
- package/dist/src/commands/function-trigger-commands.js +341 -0
- package/dist/src/commands/function-trigger-commands.js.map +1 -0
- package/dist/src/commands/functions.js +376 -30
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/groups.js +168 -50
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.js +7 -5
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/hosting.d.ts +8 -0
- package/dist/src/commands/hosting.js +346 -0
- package/dist/src/commands/hosting.js.map +1 -0
- package/dist/src/commands/init.js +129 -38
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +82 -53
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/locks.d.ts +5 -3
- package/dist/src/commands/locks.js +19 -61
- package/dist/src/commands/locks.js.map +1 -1
- package/dist/src/commands/metadata-category-configs.d.ts +2 -2
- package/dist/src/commands/metadata-category-configs.js +4 -2
- package/dist/src/commands/metadata-category-configs.js.map +1 -1
- package/dist/src/commands/metadata.js +41 -0
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/prompts.js +75 -52
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rate-counters.d.ts +19 -0
- package/dist/src/commands/rate-counters.js +104 -0
- package/dist/src/commands/rate-counters.js.map +1 -0
- package/dist/src/commands/rule-sets.d.ts +1 -1
- package/dist/src/commands/rule-sets.js +2 -1
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/schemas.d.ts +15 -0
- package/dist/src/commands/schemas.js +122 -0
- package/dist/src/commands/schemas.js.map +1 -0
- package/dist/src/commands/scripts.d.ts +9 -17
- package/dist/src/commands/scripts.js +24 -479
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/secrets.js +47 -3
- package/dist/src/commands/secrets.js.map +1 -1
- package/dist/src/commands/sessions.js +2 -0
- package/dist/src/commands/sessions.js.map +1 -1
- package/dist/src/commands/skill.js +2 -0
- package/dist/src/commands/skill.js.map +1 -1
- package/dist/src/commands/sync-schemas.d.ts +202 -0
- package/dist/src/commands/sync-schemas.js +629 -0
- package/dist/src/commands/sync-schemas.js.map +1 -0
- package/dist/src/commands/sync-user-properties.d.ts +118 -0
- package/dist/src/commands/sync-user-properties.js +276 -0
- package/dist/src/commands/sync-user-properties.js.map +1 -0
- package/dist/src/commands/sync.d.ts +518 -546
- package/dist/src/commands/sync.js +3010 -4877
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.js +5 -3
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/transitions.d.ts +54 -0
- package/dist/src/commands/transitions.js +418 -0
- package/dist/src/commands/transitions.js.map +1 -0
- package/dist/src/commands/usage.d.ts +18 -0
- package/dist/src/commands/usage.js +343 -0
- package/dist/src/commands/usage.js.map +1 -0
- package/dist/src/commands/user-properties.d.ts +14 -0
- package/dist/src/commands/user-properties.js +79 -0
- package/dist/src/commands/user-properties.js.map +1 -0
- package/dist/src/commands/users.js +911 -18
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.js +2 -0
- package/dist/src/commands/vars.js.map +1 -1
- package/dist/src/commands/waitlist.js +39 -4
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/workflows.d.ts +5 -83
- package/dist/src/commands/workflows.js +57 -2282
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/analytics-query.d.ts +58 -0
- package/dist/src/lib/analytics-query.js +134 -0
- package/dist/src/lib/analytics-query.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +1818 -438
- package/dist/src/lib/api-client.js +965 -544
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
- package/dist/src/lib/app-settings-descriptor.js +6 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/auth-fixtures.d.ts +44 -0
- package/dist/src/lib/auth-fixtures.js +61 -0
- package/dist/src/lib/auth-fixtures.js.map +1 -0
- package/dist/src/lib/auth-flow.d.ts +34 -1
- package/dist/src/lib/auth-flow.js +429 -13
- package/dist/src/lib/auth-flow.js.map +1 -1
- package/dist/src/lib/block-layout.d.ts +12 -23
- package/dist/src/lib/block-layout.js +26 -92
- package/dist/src/lib/block-layout.js.map +1 -1
- package/dist/src/lib/block-selector.d.ts +8 -14
- package/dist/src/lib/block-selector.js +8 -19
- package/dist/src/lib/block-selector.js.map +1 -1
- package/dist/src/lib/child-apps-local.d.ts +3 -1
- package/dist/src/lib/child-apps-local.js +9 -1
- package/dist/src/lib/child-apps-local.js.map +1 -1
- package/dist/src/lib/cli-manifest.d.ts +9 -0
- package/dist/src/lib/cli-manifest.js +10 -1
- package/dist/src/lib/cli-manifest.js.map +1 -1
- package/dist/src/lib/cli-version.d.ts +14 -0
- package/dist/src/lib/cli-version.js +38 -0
- package/dist/src/lib/cli-version.js.map +1 -0
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
- package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
- package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
- package/dist/src/lib/collection-export.d.ts +76 -15
- package/dist/src/lib/collection-export.js +116 -23
- package/dist/src/lib/collection-export.js.map +1 -1
- package/dist/src/lib/collection-principal.d.ts +22 -0
- package/dist/src/lib/collection-principal.js +35 -0
- package/dist/src/lib/collection-principal.js.map +1 -0
- package/dist/src/lib/command-groups.d.ts +30 -0
- package/dist/src/lib/command-groups.js +109 -0
- package/dist/src/lib/command-groups.js.map +1 -0
- package/dist/src/lib/command-status.d.ts +147 -0
- package/dist/src/lib/command-status.js +266 -0
- package/dist/src/lib/command-status.js.map +1 -0
- package/dist/src/lib/config-object-descriptor.d.ts +9 -22
- package/dist/src/lib/config-object-descriptor.js +107 -276
- package/dist/src/lib/config-object-descriptor.js.map +1 -1
- package/dist/src/lib/config-surface.d.ts +3 -7
- package/dist/src/lib/config-surface.js +9 -13
- package/dist/src/lib/config-surface.js.map +1 -1
- package/dist/src/lib/config-toml.d.ts +11 -2
- package/dist/src/lib/config-toml.js +25 -2
- package/dist/src/lib/config-toml.js.map +1 -1
- package/dist/src/lib/credentials-home.d.ts +7 -0
- package/dist/src/lib/credentials-home.js +45 -10
- package/dist/src/lib/credentials-home.js.map +1 -1
- package/dist/src/lib/credentials-lock.d.ts +14 -6
- package/dist/src/lib/credentials-lock.js +90 -10
- package/dist/src/lib/credentials-lock.js.map +1 -1
- package/dist/src/lib/credentials-store.d.ts +123 -70
- package/dist/src/lib/credentials-store.js +358 -113
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/custodian.d.ts +8 -0
- package/dist/src/lib/custodian.js +18 -0
- package/dist/src/lib/custodian.js.map +1 -0
- package/dist/src/lib/data-input.d.ts +1 -1
- package/dist/src/lib/data-input.js +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +38 -1
- package/dist/src/lib/db-codegen/dbTypeIR.js +29 -7
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
- package/dist/src/lib/db-type-records.d.ts +106 -0
- package/dist/src/lib/db-type-records.js +224 -0
- package/dist/src/lib/db-type-records.js.map +1 -0
- package/dist/src/lib/db3-export.d.ts +287 -0
- package/dist/src/lib/db3-export.js +647 -0
- package/dist/src/lib/db3-export.js.map +1 -0
- package/dist/src/lib/db3-index-output.d.ts +116 -0
- package/dist/src/lib/db3-index-output.js +223 -0
- package/dist/src/lib/db3-index-output.js.map +1 -0
- package/dist/src/lib/db3-type-models.d.ts +134 -0
- package/dist/src/lib/db3-type-models.js +452 -0
- package/dist/src/lib/db3-type-models.js.map +1 -0
- package/dist/src/lib/deprecation.d.ts +2 -2
- package/dist/src/lib/deprecation.js +2 -2
- package/dist/src/lib/document-ingest-artifact.d.ts +13 -0
- package/dist/src/lib/document-ingest-artifact.js +36 -6
- package/dist/src/lib/document-ingest-artifact.js.map +1 -1
- package/dist/src/lib/document-ingest-format2.d.ts +36 -0
- package/dist/src/lib/document-ingest-format2.js +78 -0
- package/dist/src/lib/document-ingest-format2.js.map +1 -0
- package/dist/src/lib/document-ingest-input.d.ts +9 -0
- package/dist/src/lib/document-ingest-input.js +28 -1
- package/dist/src/lib/document-ingest-input.js.map +1 -1
- package/dist/src/lib/document-ingest.d.ts +11 -1
- package/dist/src/lib/document-ingest.js +16 -0
- package/dist/src/lib/document-ingest.js.map +1 -1
- package/dist/src/lib/document-schema-rows.d.ts +42 -0
- package/dist/src/lib/document-schema-rows.js +53 -0
- package/dist/src/lib/document-schema-rows.js.map +1 -0
- package/dist/src/lib/experimental-apis.d.ts +36 -0
- package/dist/src/lib/experimental-apis.js +46 -0
- package/dist/src/lib/experimental-apis.js.map +1 -0
- package/dist/src/lib/file-attachment.d.ts +24 -0
- package/dist/src/lib/file-attachment.js +31 -0
- package/dist/src/lib/file-attachment.js.map +1 -0
- package/dist/src/lib/function-authorize-check.d.ts +142 -0
- package/dist/src/lib/function-authorize-check.js +311 -0
- package/dist/src/lib/function-authorize-check.js.map +1 -0
- package/dist/src/lib/function-authorize-view.d.ts +27 -0
- package/dist/src/lib/function-authorize-view.js +88 -0
- package/dist/src/lib/function-authorize-view.js.map +1 -0
- package/dist/src/lib/function-bundle.d.ts +27 -5
- package/dist/src/lib/function-bundle.js +142 -7
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +90 -12
- package/dist/src/lib/function-collect.js +482 -12
- package/dist/src/lib/function-collect.js.map +1 -1
- package/dist/src/lib/function-db-types.d.ts +65 -11
- package/dist/src/lib/function-db-types.js +297 -157
- package/dist/src/lib/function-db-types.js.map +1 -1
- package/dist/src/lib/function-document-types.d.ts +19 -7
- package/dist/src/lib/function-document-types.js +24 -12
- package/dist/src/lib/function-document-types.js.map +1 -1
- package/dist/src/lib/function-lint.d.ts +57 -0
- package/dist/src/lib/function-lint.js +234 -0
- package/dist/src/lib/function-lint.js.map +1 -0
- package/dist/src/lib/function-log-row.js +21 -2
- package/dist/src/lib/function-log-row.js.map +1 -1
- package/dist/src/lib/function-run.d.ts +13 -21
- package/dist/src/lib/function-run.js +14 -27
- package/dist/src/lib/function-run.js.map +1 -1
- package/dist/src/lib/function-schema-codegen.d.ts +86 -22
- package/dist/src/lib/function-schema-codegen.js +194 -88
- package/dist/src/lib/function-schema-codegen.js.map +1 -1
- package/dist/src/lib/function-schema-refs.d.ts +98 -0
- package/dist/src/lib/function-schema-refs.js +177 -0
- package/dist/src/lib/function-schema-refs.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +109 -6
- package/dist/src/lib/function-sync.js +179 -26
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/function-trigger-listing.d.ts +11 -6
- package/dist/src/lib/function-trigger-listing.js +32 -11
- package/dist/src/lib/function-trigger-listing.js.map +1 -1
- package/dist/src/lib/function-typecheck.d.ts +52 -0
- package/dist/src/lib/function-typecheck.js +174 -54
- package/dist/src/lib/function-typecheck.js.map +1 -1
- package/dist/src/lib/function-versions.d.ts +2 -0
- package/dist/src/lib/function-versions.js +1 -0
- package/dist/src/lib/function-versions.js.map +1 -1
- package/dist/src/lib/generated-build-flags.d.ts +13 -0
- package/dist/src/lib/generated-build-flags.js +14 -0
- package/dist/src/lib/generated-build-flags.js.map +1 -0
- package/dist/src/lib/generated-command-status.d.ts +6 -0
- package/dist/src/lib/generated-command-status.js +469 -0
- package/dist/src/lib/generated-command-status.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +538 -141
- package/dist/src/lib/generated-config-surfaces.js +1772 -1854
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/lib/hosting-build.d.ts +97 -0
- package/dist/src/lib/hosting-build.js +204 -0
- package/dist/src/lib/hosting-build.js.map +1 -0
- package/dist/src/lib/hosting-client.d.ts +167 -0
- package/dist/src/lib/hosting-client.js +340 -0
- package/dist/src/lib/hosting-client.js.map +1 -0
- package/dist/src/lib/hosting-environments.d.ts +32 -0
- package/dist/src/lib/hosting-environments.js +74 -0
- package/dist/src/lib/hosting-environments.js.map +1 -0
- package/dist/src/lib/hosting-errors.d.ts +30 -0
- package/dist/src/lib/hosting-errors.js +43 -0
- package/dist/src/lib/hosting-errors.js.map +1 -0
- package/dist/src/lib/hosting-token.d.ts +46 -0
- package/dist/src/lib/hosting-token.js +60 -0
- package/dist/src/lib/hosting-token.js.map +1 -0
- package/dist/src/lib/hosting-wait.d.ts +42 -0
- package/dist/src/lib/hosting-wait.js +84 -0
- package/dist/src/lib/hosting-wait.js.map +1 -0
- package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
- package/dist/src/lib/hosting-wfp-upload.js +149 -0
- package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
- package/dist/src/lib/init-assets.d.ts +2 -6
- package/dist/src/lib/init-assets.js +11 -27
- package/dist/src/lib/init-assets.js.map +1 -1
- package/dist/src/lib/init-ios-links.d.ts +11 -7
- package/dist/src/lib/init-ios-links.js +28 -22
- package/dist/src/lib/init-ios-links.js.map +1 -1
- package/dist/src/lib/init-login-note.d.ts +13 -0
- package/dist/src/lib/init-login-note.js +22 -0
- package/dist/src/lib/init-login-note.js.map +1 -0
- package/dist/src/lib/init-schema.d.ts +15 -0
- package/dist/src/lib/init-schema.js +54 -0
- package/dist/src/lib/init-schema.js.map +1 -1
- package/dist/src/lib/integration-test-request.d.ts +54 -0
- package/dist/src/lib/integration-test-request.js +207 -0
- package/dist/src/lib/integration-test-request.js.map +1 -0
- package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
- package/dist/src/lib/invoker-shared-enums.js +98 -0
- package/dist/src/lib/invoker-shared-enums.js.map +1 -0
- package/dist/src/lib/json-value.d.ts +6 -0
- package/dist/src/lib/json-value.js +13 -0
- package/dist/src/lib/json-value.js.map +1 -0
- package/dist/src/lib/load-routes.d.ts +33 -0
- package/dist/src/lib/load-routes.js +35 -0
- package/dist/src/lib/load-routes.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +23 -4
- package/dist/src/lib/log-inspection.js +14 -5
- package/dist/src/lib/log-inspection.js.map +1 -1
- package/dist/src/lib/login-exchange-check.d.ts +18 -0
- package/dist/src/lib/login-exchange-check.js +27 -0
- package/dist/src/lib/login-exchange-check.js.map +1 -0
- package/dist/src/lib/login-scope-lines.d.ts +17 -7
- package/dist/src/lib/login-scope-lines.js +33 -10
- package/dist/src/lib/login-scope-lines.js.map +1 -1
- package/dist/src/lib/metadata-report.d.ts +85 -0
- package/dist/src/lib/metadata-report.js +81 -0
- package/dist/src/lib/metadata-report.js.map +1 -0
- package/dist/src/lib/object-status-filter.d.ts +9 -1
- package/dist/src/lib/object-status-filter.js +9 -1
- package/dist/src/lib/object-status-filter.js.map +1 -1
- package/dist/src/lib/output.d.ts +1 -1
- package/dist/src/lib/output.js +3 -1
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/pin-refusal-hint.d.ts +12 -0
- package/dist/src/lib/pin-refusal-hint.js +35 -0
- package/dist/src/lib/pin-refusal-hint.js.map +1 -0
- package/dist/src/lib/platform-owned.js +5 -0
- package/dist/src/lib/platform-owned.js.map +1 -1
- package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
- package/dist/src/lib/primitive-declaration-names.js +22 -0
- package/dist/src/lib/primitive-declaration-names.js.map +1 -0
- package/dist/src/lib/primitive-declaration.d.ts +174 -0
- package/dist/src/lib/primitive-declaration.js +792 -0
- package/dist/src/lib/primitive-declaration.js.map +1 -0
- package/dist/src/lib/primitive-env-plugin.d.ts +99 -0
- package/dist/src/lib/primitive-env-plugin.js +408 -0
- package/dist/src/lib/primitive-env-plugin.js.map +1 -0
- package/dist/src/lib/project-login-apps.d.ts +8 -0
- package/dist/src/lib/project-login-apps.js +27 -0
- package/dist/src/lib/project-login-apps.js.map +1 -0
- package/dist/src/lib/prompt-schema-codegen.d.ts +36 -12
- package/dist/src/lib/prompt-schema-codegen.js +96 -100
- package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
- package/dist/src/lib/prompt-schema-document.d.ts +35 -0
- package/dist/src/lib/prompt-schema-document.js +92 -0
- package/dist/src/lib/prompt-schema-document.js.map +1 -0
- package/dist/src/lib/prompt-schema-refs.d.ts +173 -0
- package/dist/src/lib/prompt-schema-refs.js +478 -0
- package/dist/src/lib/prompt-schema-refs.js.map +1 -0
- package/dist/src/lib/records-verbs.d.ts +79 -0
- package/dist/src/lib/records-verbs.js +45 -0
- package/dist/src/lib/records-verbs.js.map +1 -0
- package/dist/src/lib/register-commands.d.ts +36 -0
- package/dist/src/lib/register-commands.js +37 -0
- package/dist/src/lib/register-commands.js.map +1 -0
- package/dist/src/lib/retired-imports.d.ts +53 -0
- package/dist/src/lib/retired-imports.js +120 -0
- package/dist/src/lib/retired-imports.js.map +1 -0
- package/dist/src/lib/run-status.d.ts +1 -1
- package/dist/src/lib/run-status.generated.d.ts +2 -2
- package/dist/src/lib/run-status.generated.js +3 -1
- package/dist/src/lib/run-status.generated.js.map +1 -1
- package/dist/src/lib/run-status.js +1 -1
- package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
- package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
- package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.js +227 -0
- package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
- package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +218 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.js +397 -0
- package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
- package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
- package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
- package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +258 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +422 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
- package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
- package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
- package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
- package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
- package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
- package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
- package/dist/src/lib/schema-codegen/naming.d.ts +35 -0
- package/dist/src/lib/schema-codegen/naming.js +83 -0
- package/dist/src/lib/schema-codegen/naming.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
- package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
- package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
- package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
- package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
- package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
- package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
- package/dist/src/lib/schema-codegen/schemaToTs.d.ts +109 -0
- package/dist/src/lib/schema-codegen/schemaToTs.js +269 -0
- package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/schema-codegen/valuesLists.d.ts +48 -0
- package/dist/src/lib/schema-codegen/valuesLists.js +144 -0
- package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
- package/dist/src/lib/schema-family-index.d.ts +228 -0
- package/dist/src/lib/schema-family-index.js +813 -0
- package/dist/src/lib/schema-family-index.js.map +1 -0
- package/dist/src/lib/schema-pins.d.ts +82 -0
- package/dist/src/lib/schema-pins.js +198 -0
- package/dist/src/lib/schema-pins.js.map +1 -0
- package/dist/src/lib/schema-preview.d.ts +244 -0
- package/dist/src/lib/schema-preview.js +498 -0
- package/dist/src/lib/schema-preview.js.map +1 -0
- package/dist/src/lib/scope-request.d.ts +23 -11
- package/dist/src/lib/scope-request.js +69 -31
- package/dist/src/lib/scope-request.js.map +1 -1
- package/dist/src/lib/session-scope.d.ts +26 -0
- package/dist/src/lib/session-scope.js +58 -0
- package/dist/src/lib/session-scope.js.map +1 -0
- package/dist/src/lib/skill-installer.d.ts +2 -2
- package/dist/src/lib/skill-installer.js +2 -21
- package/dist/src/lib/skill-installer.js.map +1 -1
- package/dist/src/lib/step-run-table.d.ts +1 -2
- package/dist/src/lib/step-run-table.js +1 -2
- package/dist/src/lib/step-run-table.js.map +1 -1
- package/dist/src/lib/swift-codegen/agentGenerator.d.ts +2 -1
- package/dist/src/lib/swift-codegen/agentGenerator.js +25 -23
- package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
- package/dist/src/lib/swift-codegen/banners.js +12 -0
- package/dist/src/lib/swift-codegen/banners.js.map +1 -1
- package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
- package/dist/src/lib/swift-codegen/functionGenerator.js +169 -51
- package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +33 -9
- package/dist/src/lib/swift-codegen/schemaToSwift.js +215 -179
- package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
- package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +45 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js +165 -0
- package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/swiftKeys.d.ts +19 -0
- package/dist/src/lib/swift-codegen/swiftKeys.js +31 -0
- package/dist/src/lib/swift-codegen/swiftKeys.js.map +1 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
- package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +117 -31
- package/dist/src/lib/sync-resource-types.js +197 -189
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/sync-selectors.d.ts +7 -0
- package/dist/src/lib/sync-selectors.js +22 -2
- package/dist/src/lib/sync-selectors.js.map +1 -1
- package/dist/src/lib/template.d.ts +39 -3
- package/dist/src/lib/template.js +103 -14
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/test-case-file-names.d.ts +3 -5
- package/dist/src/lib/test-case-file-names.js +3 -5
- package/dist/src/lib/test-case-file-names.js.map +1 -1
- package/dist/src/lib/test-runs.d.ts +45 -0
- package/dist/src/lib/test-runs.js +150 -0
- package/dist/src/lib/test-runs.js.map +1 -0
- package/dist/src/lib/test-users.d.ts +25 -0
- package/dist/src/lib/test-users.js +36 -0
- package/dist/src/lib/test-users.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +4 -2
- package/dist/src/lib/toml-database-config.js +11 -6
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/toml-scalar-edit.js +6 -4
- package/dist/src/lib/toml-scalar-edit.js.map +1 -1
- package/dist/src/lib/transition-warnings.d.ts +21 -0
- package/dist/src/lib/transition-warnings.js +49 -0
- package/dist/src/lib/transition-warnings.js.map +1 -0
- package/dist/src/lib/user-index.d.ts +80 -0
- package/dist/src/lib/user-index.js +166 -0
- package/dist/src/lib/user-index.js.map +1 -0
- package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
- package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
- package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
- package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
- package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
- package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
- package/dist/src/lib/user-walk.d.ts +31 -0
- package/dist/src/lib/user-walk.js +102 -0
- package/dist/src/lib/user-walk.js.map +1 -0
- package/dist/src/lib/webhook-capture.d.ts +43 -0
- package/dist/src/lib/webhook-capture.js +91 -0
- package/dist/src/lib/webhook-capture.js.map +1 -0
- package/dist/src/lib/webhook-deliver.d.ts +18 -20
- package/dist/src/lib/webhook-deliver.js +34 -89
- package/dist/src/lib/webhook-deliver.js.map +1 -1
- package/dist/src/lib/webhook-test-run.d.ts +32 -0
- package/dist/src/lib/webhook-test-run.js +108 -0
- package/dist/src/lib/webhook-test-run.js.map +1 -0
- package/dist/src/lib/worker-perf-format.d.ts +22 -0
- package/dist/src/lib/worker-perf-format.js +27 -0
- package/dist/src/lib/worker-perf-format.js.map +1 -0
- package/dist/src/types/index.d.ts +20 -65
- package/dist/src/validators.d.ts +7 -55
- package/dist/src/validators.js +7 -53
- package/dist/src/validators.js.map +1 -1
- package/dist/src/vite.d.ts +17 -0
- package/dist/src/vite.js +18 -0
- package/dist/src/vite.js.map +1 -0
- package/package.json +20 -9
|
@@ -7,11 +7,13 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Mode A (project mode): credentials live at
|
|
9
9
|
* <projectRoot>/.primitive/credentials.json
|
|
10
|
-
* with per
|
|
10
|
+
* with one login per server (#4512), keyed by normalized server URL:
|
|
11
11
|
* {
|
|
12
|
-
* "
|
|
13
|
-
* "
|
|
14
|
-
*
|
|
12
|
+
* "servers": {
|
|
13
|
+
* "https://api.example.com": {
|
|
14
|
+
* "login": { "accessToken": "...", "refreshToken": "...", ... },
|
|
15
|
+
* "leftovers": { "staging": { ... } }
|
|
16
|
+
* }
|
|
15
17
|
* }
|
|
16
18
|
* }
|
|
17
19
|
*
|
|
@@ -33,24 +35,34 @@
|
|
|
33
35
|
* project either. The last two are the divergence from the intent's "login and
|
|
34
36
|
* init and nothing else", adjudicated on #3154 as finding F1.
|
|
35
37
|
*
|
|
38
|
+
* A fifth, `apps delete`, says it pinned to a server (#4905,
|
|
39
|
+
* `allowGlobalCredentialsForServer()`): the server `PRIMITIVE_SERVER_URL`
|
|
40
|
+
* names, or production when it is unset, as `login` resolves it. The global
|
|
41
|
+
* login is used only when that server issued it, so the command still never
|
|
42
|
+
* acts against whatever server the last `login` targeted.
|
|
43
|
+
*
|
|
36
44
|
* The opt-in is per ACTION, not per argv: `primitive --env prod login` and
|
|
37
45
|
* `primitive login` reach the same line, so there is no flag shape for a
|
|
38
46
|
* pre-parse to miss. And it only PERMITS the global file — inside a project
|
|
39
|
-
* all
|
|
47
|
+
* all five still use the project's file.
|
|
48
|
+
*
|
|
49
|
+
* Every environment on a server — committed or machine-local — reads and
|
|
50
|
+
* writes that server's one login, so one login and one logout cover them all
|
|
51
|
+
* (#4512). A server's `leftovers` are logins an older CLI stored per
|
|
52
|
+
* environment: never read, revoked by `logout`.
|
|
40
53
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* and
|
|
54
|
+
* Before #4512 a login lived in a per-environment slot under `environments`,
|
|
55
|
+
* a child environment (#4511) using its parent's. Such a slot is read only
|
|
56
|
+
* while the file has no entry for its server. The first write for a server
|
|
57
|
+
* creates the entry and moves the server's legacy slots out: a mere copy of
|
|
58
|
+
* the login being written is dropped, any other becomes a leftover. From then
|
|
59
|
+
* on a cleared login stays cleared; no legacy slot is read for that server.
|
|
45
60
|
*
|
|
46
|
-
* A
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* than the slot's environment's are never stored. A slot written before this
|
|
52
|
-
* records no server; it is read against the environment's `apiUrl`, and its
|
|
53
|
-
* next write records one.
|
|
61
|
+
* A login records the server that issued it (#4492), and credentials from
|
|
62
|
+
* another server than the environment's are never stored. A legacy slot
|
|
63
|
+
* recording another server than the invoking environment's is never used (its
|
|
64
|
+
* tokens are not sent); a legacy slot that records no server is read against
|
|
65
|
+
* the environment's `apiUrl`.
|
|
54
66
|
*
|
|
55
67
|
* In a linked git worktree the project's file is the main worktree's
|
|
56
68
|
* (#4492, `credentials-home.ts`), so one login serves every worktree of the
|
|
@@ -63,8 +75,9 @@ import { homedir } from "os";
|
|
|
63
75
|
import { dirname, join } from "path";
|
|
64
76
|
import { getCurrentEnvironment, getProjectConfig, } from "./env-resolver.js";
|
|
65
77
|
import { missingConfigMessage, PROJECT_CONFIG_FILENAME, PROJECT_TREE_DIR, PrimitiveEnvError, readLocalState, } from "./env-resolver-core.js";
|
|
66
|
-
import { DEFAULT_SERVER_URL } from "./constants.js";
|
|
67
|
-
import {
|
|
78
|
+
import { DEFAULT_SERVER_URL, PRODUCTION_SERVER_URL } from "./constants.js";
|
|
79
|
+
import { normalizeServerUrl } from "./channel.js";
|
|
80
|
+
import { credentialsRootFor, ignoredLocalCredentialsFile, oldGitHint, otherSharingProjectRoots, sharedWorktreeCount, } from "./credentials-home.js";
|
|
68
81
|
import { acquireCredentialsLock, fileVersion, replaceFileUnderLock } from "./credentials-lock.js";
|
|
69
82
|
import { sessionIdOfToken } from "./session-id.js";
|
|
70
83
|
export const PROJECT_LOCAL_DIR = ".primitive";
|
|
@@ -123,11 +136,17 @@ export function credentialsFileForProject(projectRoot) {
|
|
|
123
136
|
return join(credentialsRootFor(projectRoot), PROJECT_LOCAL_DIR, PROJECT_CREDENTIALS_FILENAME);
|
|
124
137
|
}
|
|
125
138
|
/**
|
|
126
|
-
* Set by the
|
|
139
|
+
* Set by the actions that may read or write the global credentials file
|
|
127
140
|
* with no project in scope. Process-wide, because one invocation runs one
|
|
128
141
|
* command; never reset, because a command does not stop being `login`.
|
|
129
142
|
*/
|
|
130
143
|
let globalCredentialsAllowed = false;
|
|
144
|
+
/**
|
|
145
|
+
* The server a pinned allowance names (#4905): the global login is used only
|
|
146
|
+
* when this server issued it, and only its credentials are written. Null for
|
|
147
|
+
* the unpinned allowance of the login family.
|
|
148
|
+
*/
|
|
149
|
+
let globalCredentialsServer = null;
|
|
131
150
|
/**
|
|
132
151
|
* Declare that THIS command may fall back to `~/.primitive/credentials.json`
|
|
133
152
|
* when no project is in scope. Called at the top of `login`, `logout`, `init`
|
|
@@ -136,6 +155,17 @@ let globalCredentialsAllowed = false;
|
|
|
136
155
|
export function allowGlobalCredentials() {
|
|
137
156
|
globalCredentialsAllowed = true;
|
|
138
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Declare that THIS command may use the global credentials file when no
|
|
160
|
+
* project is in scope, but only for `serverUrl`: a stored login another server
|
|
161
|
+
* issued is refused with `server-mismatch` before any of its tokens is sent,
|
|
162
|
+
* credentials from another server are never written, and `PRIMITIVE_TOKEN` is
|
|
163
|
+
* sent to `serverUrl`. Called by `apps delete` (#4905), and nowhere else.
|
|
164
|
+
*/
|
|
165
|
+
export function allowGlobalCredentialsForServer(serverUrl) {
|
|
166
|
+
globalCredentialsAllowed = true;
|
|
167
|
+
globalCredentialsServer = trimSlash(serverUrl);
|
|
168
|
+
}
|
|
139
169
|
/**
|
|
140
170
|
* Drop the declaration again. One invocation runs one command, so nothing in
|
|
141
171
|
* the CLI calls this — it exists so a test file can exercise both sides of the
|
|
@@ -143,6 +173,25 @@ export function allowGlobalCredentials() {
|
|
|
143
173
|
*/
|
|
144
174
|
export function resetGlobalCredentialsAllowance() {
|
|
145
175
|
globalCredentialsAllowed = false;
|
|
176
|
+
globalCredentialsServer = null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The login command for the global login of `serverUrl`, up to its `--app`
|
|
180
|
+
* value: prefixed with `PRIMITIVE_SERVER_URL=<server>` unless the server is
|
|
181
|
+
* production, which `login` targets when the variable is unset.
|
|
182
|
+
*/
|
|
183
|
+
export function globalLoginCommand(serverUrl) {
|
|
184
|
+
const prefix = sameServer(serverUrl, PRODUCTION_SERVER_URL) ? "" : `PRIMITIVE_SERVER_URL=${serverUrl} `;
|
|
185
|
+
return `${prefix}primitive login --app`;
|
|
186
|
+
}
|
|
187
|
+
/** The refusal of a global login another server than the pinned one issued. */
|
|
188
|
+
function globalReadMismatch(stored, pinned) {
|
|
189
|
+
const issuer = stored ?? "a server it does not record";
|
|
190
|
+
const target = stored ? ` To target ${stored}, set PRIMITIVE_SERVER_URL=${stored}.` : "";
|
|
191
|
+
return new PrimitiveEnvError("server-mismatch", `The login in ${getLegacyCredentialsFile()} was issued by ${issuer}, but this command targets ` +
|
|
192
|
+
`${pinned} (PRIMITIVE_SERVER_URL, or production when it is unset); its tokens were not sent.` +
|
|
193
|
+
`${target} To sign in to ${pinned}, run '${globalLoginCommand(pinned)} <app-id>' (or --app all); ` +
|
|
194
|
+
`it replaces the stored login.`);
|
|
146
195
|
}
|
|
147
196
|
/**
|
|
148
197
|
* Resolves the current environment. If an environment CAN'T be resolved
|
|
@@ -210,15 +259,24 @@ function legacyCredentialsRecord(credentials) {
|
|
|
210
259
|
function loadProjectCredentialsFile(projectRoot) {
|
|
211
260
|
const path = credentialsFileForProject(projectRoot);
|
|
212
261
|
const data = readJsonFile(path);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
262
|
+
const isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
263
|
+
if (!isRecord(data))
|
|
264
|
+
return { environments: {}, servers: {} };
|
|
265
|
+
const file = {
|
|
266
|
+
environments: isRecord(data.environments) ? data.environments : {},
|
|
267
|
+
servers: isRecord(data.servers) ? data.servers : {},
|
|
268
|
+
};
|
|
216
269
|
// EVERY slot, not just the one about to be written: each write reserializes
|
|
217
270
|
// the whole file, so a stale key anywhere would survive forever.
|
|
218
|
-
for (const slot of Object.values(
|
|
271
|
+
for (const slot of Object.values(file.environments)) {
|
|
219
272
|
stripRetiredCurrentApp(slot);
|
|
220
273
|
}
|
|
221
|
-
|
|
274
|
+
for (const entry of Object.values(file.servers)) {
|
|
275
|
+
stripRetiredCurrentApp(entry?.login);
|
|
276
|
+
for (const slot of Object.values(entry?.leftovers ?? {}))
|
|
277
|
+
stripRetiredCurrentApp(slot);
|
|
278
|
+
}
|
|
279
|
+
return file;
|
|
222
280
|
}
|
|
223
281
|
/**
|
|
224
282
|
* The one way a project's credentials file is written: take the lock, read
|
|
@@ -390,6 +448,80 @@ function dropCopiedChildSlots(projectRoot, file, slot, children) {
|
|
|
390
448
|
// The copies are ignored either way; the next read tries again.
|
|
391
449
|
}
|
|
392
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* The key of `apiUrl`'s login in `servers` (#4512): scheme, host and port,
|
|
453
|
+
* and the path without trailing slashes. A URL that does not parse keys as
|
|
454
|
+
* its trailing-slash-trimmed string.
|
|
455
|
+
*/
|
|
456
|
+
function serverKey(apiUrl) {
|
|
457
|
+
return normalizeServerUrl(apiUrl) ?? trimSlash(apiUrl);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* The server of every environment of the project whose config is at
|
|
461
|
+
* `configPath`, committed and machine-local, by name in config order. Null
|
|
462
|
+
* when the config cannot be read, so a caller never takes "no environment"
|
|
463
|
+
* for an answer it did not get.
|
|
464
|
+
*/
|
|
465
|
+
function environmentServers(configPath) {
|
|
466
|
+
const config = readJsonFile(configPath);
|
|
467
|
+
if (!config?.environments || typeof config.environments !== "object")
|
|
468
|
+
return null;
|
|
469
|
+
const servers = {};
|
|
470
|
+
for (const [name, entry] of Object.entries(config.environments)) {
|
|
471
|
+
if (typeof entry?.apiUrl === "string")
|
|
472
|
+
servers[name] = entry.apiUrl;
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
for (const [name, entry] of Object.entries(readLocalState(configPath).environments)) {
|
|
476
|
+
if (!(name in servers))
|
|
477
|
+
servers[name] = entry.apiUrl;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
catch {
|
|
481
|
+
// An unreadable local state names no machine-local environment.
|
|
482
|
+
}
|
|
483
|
+
return servers;
|
|
484
|
+
}
|
|
485
|
+
/** The project config of a project root, where `init` and `env remove` find it. */
|
|
486
|
+
function configPathOf(projectRoot) {
|
|
487
|
+
return join(projectRoot, PROJECT_TREE_DIR, PROJECT_CONFIG_FILENAME);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* The legacy slots of `file` that belong to `server`: one recording that
|
|
491
|
+
* server, and one named after an environment on it, whatever it records. The
|
|
492
|
+
* latter is the slot that environment read; one recording another server was
|
|
493
|
+
* never used there, and keeps its server so `logout` revokes it where it was
|
|
494
|
+
* issued.
|
|
495
|
+
*/
|
|
496
|
+
function legacySlotsOn(file, server, servers) {
|
|
497
|
+
const on = (apiUrl) => apiUrl !== undefined && serverKey(apiUrl) === server;
|
|
498
|
+
return Object.entries(file.environments)
|
|
499
|
+
.filter(([name, slot]) => on(slot.serverUrl) || on(servers?.[name]))
|
|
500
|
+
.map(([name]) => name);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Create `servers[server]` for the login about to be written, moving the
|
|
504
|
+
* server's legacy slots out of `environments`. A slot holding `login`'s
|
|
505
|
+
* session that nothing a logout needs is dropped (an identical or older
|
|
506
|
+
* refresh token, no live step-up of its own, #4511's rules); any other slot
|
|
507
|
+
* becomes a leftover. No-op once the server has an entry.
|
|
508
|
+
*/
|
|
509
|
+
function migrateServer(file, server, login, servers) {
|
|
510
|
+
const existing = file.servers[server];
|
|
511
|
+
if (existing)
|
|
512
|
+
return existing;
|
|
513
|
+
const leftovers = {};
|
|
514
|
+
for (const name of legacySlotsOn(file, server, servers)) {
|
|
515
|
+
const slot = file.environments[name];
|
|
516
|
+
const copy = sameSession(slot, login) && !outlivesRefresh(slot, login) && !ownStepUp(slot, login);
|
|
517
|
+
if (!copy)
|
|
518
|
+
leftovers[name] = slot;
|
|
519
|
+
delete file.environments[name];
|
|
520
|
+
}
|
|
521
|
+
const entry = Object.keys(leftovers).length > 0 ? { leftovers } : {};
|
|
522
|
+
file.servers[server] = entry;
|
|
523
|
+
return entry;
|
|
524
|
+
}
|
|
393
525
|
/** The variable a CI job puts its admin token in (#3890). */
|
|
394
526
|
export const PRIMITIVE_TOKEN_VAR = "PRIMITIVE_TOKEN";
|
|
395
527
|
/**
|
|
@@ -397,6 +529,14 @@ export const PRIMITIVE_TOKEN_VAR = "PRIMITIVE_TOKEN";
|
|
|
397
529
|
* names one. Deployed servers ignore the header for admin identity.
|
|
398
530
|
*/
|
|
399
531
|
const PARTITION_VAR = "PRIMITIVE_GLOBAL_ADMIN_APP_ID";
|
|
532
|
+
/**
|
|
533
|
+
* The partition a login exchanges in when it builds on no stored login: the
|
|
534
|
+
* one `PRIMITIVE_GLOBAL_ADMIN_APP_ID` names, which only the live test harness
|
|
535
|
+
* sets. Deployed servers ignore the header for admin identity.
|
|
536
|
+
*/
|
|
537
|
+
export function partitionFromEnvironment() {
|
|
538
|
+
return process.env[PARTITION_VAR]?.trim() || undefined;
|
|
539
|
+
}
|
|
400
540
|
/** The token in `PRIMITIVE_TOKEN`, or null when it is unset or blank. */
|
|
401
541
|
export function environmentToken() {
|
|
402
542
|
const value = process.env[PRIMITIVE_TOKEN_VAR]?.trim();
|
|
@@ -436,24 +576,38 @@ function assertStorable(credentials) {
|
|
|
436
576
|
* legacy global file. Returns the standard Credentials shape so existing
|
|
437
577
|
* callers don't need to change.
|
|
438
578
|
*
|
|
439
|
-
* In project mode, we blend the
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
579
|
+
* In project mode, we blend the server's stored login with the serverUrl
|
|
580
|
+
* from primitive/config.json to produce the Credentials the rest of the CLI
|
|
581
|
+
* expects (#4512). Before the server's first write a legacy slot is read
|
|
582
|
+
* instead: the environment's own, or its parent's for a child environment
|
|
583
|
+
* (#4511), and any child slot found to be a copy of that login is removed.
|
|
443
584
|
*
|
|
444
585
|
* `PRIMITIVE_TOKEN` (#3890), when set, takes precedence over any stored
|
|
445
586
|
* login and no file is read. It does not loosen the outside-a-project
|
|
446
587
|
* refusal: the environment is resolved first, exactly as for a stored login.
|
|
588
|
+
*
|
|
589
|
+
* Outside a project under a server pin (#4905), the global login is returned
|
|
590
|
+
* only when the pinned server issued it, and `PRIMITIVE_TOKEN` is for the
|
|
591
|
+
* pinned server.
|
|
447
592
|
*/
|
|
448
593
|
export function loadCredentialsStore() {
|
|
449
594
|
const env = resolveCurrentEnvironment();
|
|
450
|
-
const fromEnvironment = environmentCredentials(env ? env.config.apiUrl : DEFAULT_SERVER_URL.replace(/\/$/, ""));
|
|
595
|
+
const fromEnvironment = environmentCredentials(env ? env.config.apiUrl : globalCredentialsServer ?? DEFAULT_SERVER_URL.replace(/\/$/, ""));
|
|
451
596
|
if (fromEnvironment)
|
|
452
597
|
return fromEnvironment;
|
|
453
598
|
if (!env) {
|
|
454
|
-
|
|
599
|
+
const stored = loadLegacyCredentials();
|
|
600
|
+
if (stored &&
|
|
601
|
+
globalCredentialsServer !== null &&
|
|
602
|
+
(!stored.serverUrl || !sameServer(stored.serverUrl, globalCredentialsServer))) {
|
|
603
|
+
throw globalReadMismatch(stored.serverUrl, globalCredentialsServer);
|
|
604
|
+
}
|
|
605
|
+
return stored;
|
|
455
606
|
}
|
|
456
607
|
const file = loadProjectCredentialsFile(env.projectRoot);
|
|
608
|
+
const entry = file.servers[serverKey(env.config.apiUrl)];
|
|
609
|
+
if (entry)
|
|
610
|
+
return entry.login ? storedCredentials(env.config.apiUrl, entry.login) : null;
|
|
457
611
|
const { slot, children } = loginSlotOf(env);
|
|
458
612
|
const stored = file.environments[slot];
|
|
459
613
|
if (!stored)
|
|
@@ -467,16 +621,20 @@ export function loadCredentialsStore() {
|
|
|
467
621
|
return storedCredentials(env.config.apiUrl, stored);
|
|
468
622
|
}
|
|
469
623
|
/**
|
|
470
|
-
* The current environment's
|
|
471
|
-
* than the environment's, blended with the server it RECORDS; null otherwise
|
|
472
|
-
*
|
|
473
|
-
*
|
|
624
|
+
* The current environment's legacy login when its slot records another server
|
|
625
|
+
* than the environment's, blended with the server it RECORDS; null otherwise,
|
|
626
|
+
* and always once the environment's server has a login entry (#4512). For
|
|
627
|
+
* `logout` alone, which revokes such a login at the server that issued it and
|
|
628
|
+
* so never sends its tokens anywhere else.
|
|
474
629
|
*/
|
|
475
630
|
export function mismatchedLogin() {
|
|
476
631
|
const env = resolveCurrentEnvironment();
|
|
477
632
|
if (!env || environmentToken())
|
|
478
633
|
return null;
|
|
479
|
-
const
|
|
634
|
+
const file = loadProjectCredentialsFile(env.projectRoot);
|
|
635
|
+
if (file.servers[serverKey(env.config.apiUrl)])
|
|
636
|
+
return null;
|
|
637
|
+
const stored = file.environments[loginSlotOf(env).slot];
|
|
480
638
|
if (!stored || !recordsOtherServer(stored, env.config.apiUrl))
|
|
481
639
|
return null;
|
|
482
640
|
return storedCredentials(stored.serverUrl, stored);
|
|
@@ -496,16 +654,22 @@ function storedCredentials(serverUrl, stored) {
|
|
|
496
654
|
};
|
|
497
655
|
}
|
|
498
656
|
/**
|
|
499
|
-
* The environments that share the current environment's login (#
|
|
500
|
-
*
|
|
501
|
-
*
|
|
657
|
+
* The environments that share the current environment's login (#4512): every
|
|
658
|
+
* environment of the project on its server, committed and machine-local, in
|
|
659
|
+
* config order; and the committed environment whose tree the current one
|
|
660
|
+
* uses, which names the login. Null outside a project, where there is one
|
|
661
|
+
* global login.
|
|
502
662
|
*/
|
|
503
663
|
export function loginEnvironments() {
|
|
504
664
|
const env = resolveCurrentEnvironment();
|
|
505
665
|
if (!env)
|
|
506
666
|
return null;
|
|
507
|
-
const
|
|
508
|
-
|
|
667
|
+
const server = serverKey(env.config.apiUrl);
|
|
668
|
+
const servers = environmentServers(env.projectConfigPath) ?? {};
|
|
669
|
+
const environments = Object.entries(servers)
|
|
670
|
+
.filter(([, apiUrl]) => serverKey(apiUrl) === server)
|
|
671
|
+
.map(([name]) => name);
|
|
672
|
+
return { tree: env.tree, environments: environments.length > 0 ? environments : [env.name] };
|
|
509
673
|
}
|
|
510
674
|
/** The current project's root, or null outside a project or when it cannot be resolved. */
|
|
511
675
|
function currentProjectRoot() {
|
|
@@ -551,37 +715,49 @@ export const worktreeLoginNotes = {
|
|
|
551
715
|
},
|
|
552
716
|
};
|
|
553
717
|
/**
|
|
554
|
-
* The logins
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
718
|
+
* The logins on the current environment's server that no command reads: the
|
|
719
|
+
* server's leftovers (#4512), or before its first write the legacy slots on
|
|
720
|
+
* it other than the one the environment reads — sessions signed in to another
|
|
721
|
+
* environment, and copies that kept a step-up or a refresh token of their own
|
|
722
|
+
* (#4511). `logout` revokes them before {@link clearLeftoverLogins} removes
|
|
723
|
+
* them. Empty outside a project.
|
|
559
724
|
*/
|
|
560
|
-
export function
|
|
725
|
+
export function leftoverLogins() {
|
|
561
726
|
const env = resolveCurrentEnvironment();
|
|
562
727
|
if (!env)
|
|
563
728
|
return [];
|
|
564
729
|
const file = loadProjectCredentialsFile(env.projectRoot);
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
|
|
574
|
-
|
|
730
|
+
const server = serverKey(env.config.apiUrl);
|
|
731
|
+
const entry = file.servers[server];
|
|
732
|
+
const stored = entry
|
|
733
|
+
? Object.values(entry.leftovers ?? {})
|
|
734
|
+
: legacyLeftovers(file, env).map((name) => file.environments[name]);
|
|
735
|
+
return stored.map((slot) => storedCredentials(slot.serverUrl ?? env.config.apiUrl, slot));
|
|
736
|
+
}
|
|
737
|
+
/** The legacy slots on `env`'s server other than the one it reads. */
|
|
738
|
+
function legacyLeftovers(file, env) {
|
|
739
|
+
const own = loginSlotOf(env).slot;
|
|
740
|
+
return legacySlotsOn(file, serverKey(env.config.apiUrl), environmentServers(env.projectConfigPath)).filter((name) => name !== own);
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Saves credentials. In project mode, writes the login of the environment's
|
|
744
|
+
* server (#4512), migrating the server's legacy slots at its first write. In
|
|
745
|
+
* legacy mode, writes the global file.
|
|
575
746
|
*
|
|
576
|
-
* In project mode the
|
|
577
|
-
* the same server as the
|
|
578
|
-
*
|
|
579
|
-
*
|
|
747
|
+
* In project mode the login records the incoming `serverUrl`, which must be
|
|
748
|
+
* the same server as the environment's `apiUrl`: credentials from another
|
|
749
|
+
* server are refused with `server-mismatch` and nothing is written (#4492).
|
|
750
|
+
* In legacy mode under a server pin (#4905), so are credentials from another
|
|
751
|
+
* server than the pinned one.
|
|
580
752
|
*/
|
|
581
753
|
export function saveCredentialsStore(credentials) {
|
|
582
754
|
assertStorable(credentials);
|
|
583
755
|
const env = resolveCurrentEnvironment();
|
|
584
756
|
if (!env) {
|
|
757
|
+
if (globalCredentialsServer !== null && !sameServer(credentials.serverUrl, globalCredentialsServer)) {
|
|
758
|
+
throw new PrimitiveEnvError("server-mismatch", `These credentials were issued by ${credentials.serverUrl}, but this command targets ` +
|
|
759
|
+
`${globalCredentialsServer}; nothing was stored.`);
|
|
760
|
+
}
|
|
585
761
|
ensureDir(getLegacyConfigDir());
|
|
586
762
|
writeFileSync(getLegacyCredentialsFile(), JSON.stringify(legacyCredentialsRecord(credentials), null, 2), { mode: 0o600 });
|
|
587
763
|
try {
|
|
@@ -592,23 +768,29 @@ export function saveCredentialsStore(credentials) {
|
|
|
592
768
|
}
|
|
593
769
|
return;
|
|
594
770
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
throw writeMismatch(env.name, credentials.serverUrl, serverUrl);
|
|
771
|
+
if (!sameServer(credentials.serverUrl, env.config.apiUrl)) {
|
|
772
|
+
throw writeMismatch(env.name, credentials.serverUrl, env.config.apiUrl);
|
|
598
773
|
}
|
|
599
|
-
|
|
600
|
-
|
|
774
|
+
writeServerLogin(env.projectRoot, environmentServers(env.projectConfigPath), credentials);
|
|
775
|
+
}
|
|
776
|
+
/** Write `credentials` as their server's login in the project at `projectRoot`. */
|
|
777
|
+
function writeServerLogin(projectRoot, servers, credentials) {
|
|
778
|
+
const record = storedRecord(credentials);
|
|
779
|
+
const server = serverKey(credentials.serverUrl);
|
|
780
|
+
updateProjectCredentialsFile(projectRoot, (file) => {
|
|
781
|
+
migrateServer(file, server, record, servers).login = record;
|
|
601
782
|
return true;
|
|
602
783
|
});
|
|
603
784
|
}
|
|
604
785
|
/**
|
|
605
786
|
* Clears credentials for the current environment (project mode) or
|
|
606
|
-
* deletes the legacy file (legacy mode). In project mode that is the
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
787
|
+
* deletes the legacy file (legacy mode). In project mode that is the login of
|
|
788
|
+
* the environment's server; its entry and leftovers stay, so a legacy slot is
|
|
789
|
+
* never read for the server again (#4512). Before the server's first write it
|
|
790
|
+
* is the legacy slot the environment reads, and the child slots holding only
|
|
791
|
+
* that login's session (#4511), which its caller has just revoked. A slot
|
|
792
|
+
* holding another session or a step-up of its own stays for `logout` to
|
|
793
|
+
* revoke ({@link clearLeftoverLogins}).
|
|
612
794
|
*/
|
|
613
795
|
export function clearCredentialsStore() {
|
|
614
796
|
const env = resolveCurrentEnvironment();
|
|
@@ -625,8 +807,16 @@ export function clearCredentialsStore() {
|
|
|
625
807
|
}
|
|
626
808
|
if (!existsSync(credentialsFileForProject(env.projectRoot)))
|
|
627
809
|
return;
|
|
810
|
+
const server = serverKey(env.config.apiUrl);
|
|
628
811
|
const { slot, children } = loginSlotOf(env);
|
|
629
812
|
updateProjectCredentialsFile(env.projectRoot, (file) => {
|
|
813
|
+
const entry = file.servers[server];
|
|
814
|
+
if (entry) {
|
|
815
|
+
if (!entry.login)
|
|
816
|
+
return false;
|
|
817
|
+
delete entry.login;
|
|
818
|
+
return true;
|
|
819
|
+
}
|
|
630
820
|
const login = file.environments[slot];
|
|
631
821
|
if (!login)
|
|
632
822
|
return false;
|
|
@@ -641,86 +831,141 @@ export function clearCredentialsStore() {
|
|
|
641
831
|
});
|
|
642
832
|
}
|
|
643
833
|
/**
|
|
644
|
-
* Removes
|
|
645
|
-
*
|
|
646
|
-
* outside a project.
|
|
834
|
+
* Removes the logins {@link leftoverLogins} returned, once `logout` has
|
|
835
|
+
* revoked them: the server's leftovers, or before its first write the other
|
|
836
|
+
* legacy slots on it. No-op outside a project.
|
|
647
837
|
*/
|
|
648
|
-
export function
|
|
838
|
+
export function clearLeftoverLogins() {
|
|
649
839
|
const env = resolveCurrentEnvironment();
|
|
650
840
|
if (!env)
|
|
651
841
|
return;
|
|
652
|
-
const
|
|
842
|
+
const server = serverKey(env.config.apiUrl);
|
|
653
843
|
const file = loadProjectCredentialsFile(env.projectRoot);
|
|
654
|
-
|
|
844
|
+
const entry = file.servers[server];
|
|
845
|
+
if (entry ? !entry.leftovers : legacyLeftovers(file, env).length === 0)
|
|
655
846
|
return;
|
|
656
847
|
updateProjectCredentialsFile(env.projectRoot, (current) => {
|
|
657
|
-
const
|
|
658
|
-
|
|
848
|
+
const currentEntry = current.servers[server];
|
|
849
|
+
if (currentEntry) {
|
|
850
|
+
if (!currentEntry.leftovers)
|
|
851
|
+
return false;
|
|
852
|
+
delete currentEntry.leftovers;
|
|
853
|
+
return true;
|
|
854
|
+
}
|
|
855
|
+
const names = legacyLeftovers(current, env);
|
|
856
|
+
for (const name of names)
|
|
659
857
|
delete current.environments[name];
|
|
660
|
-
return
|
|
858
|
+
return names.length > 0;
|
|
661
859
|
});
|
|
662
860
|
}
|
|
663
861
|
/**
|
|
664
|
-
* Removes
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
|
|
669
|
-
|
|
862
|
+
* Removes what a removed environment leaves in a specific project's
|
|
863
|
+
* credentials file, so stale tokens from a previously-removed environment can
|
|
864
|
+
* never be silently re-used if the same name is later added back: a legacy
|
|
865
|
+
* slot or leftover of its name, and the login of the removed environment's
|
|
866
|
+
* server `removedApiUrl` when no remaining environment uses it (#4512). No
|
|
867
|
+
* other server's entry is touched: the file is shared by every worktree
|
|
868
|
+
* (#4492), and a server this worktree does not use may be another worktree's
|
|
869
|
+
* machine-local environment's. For the same reason the removed server's
|
|
870
|
+
* login stays while an environment of any worktree sharing the file uses it,
|
|
871
|
+
* or while that cannot be told. Used by `env remove`, after the environment
|
|
872
|
+
* left the config at `configPath`. Returns whether anything was removed.
|
|
873
|
+
* Never throws.
|
|
874
|
+
*/
|
|
875
|
+
export function clearCredentialsForEnvInProject(projectRoot, envName, configPath = configPathOf(projectRoot), removedApiUrl) {
|
|
670
876
|
try {
|
|
671
|
-
|
|
877
|
+
const removed = removeCredentialsSlotInProject(projectRoot, envName);
|
|
878
|
+
if (removedApiUrl === undefined)
|
|
879
|
+
return removed;
|
|
880
|
+
const server = serverKey(removedApiUrl);
|
|
881
|
+
const others = otherSharingProjectRoots(projectRoot);
|
|
882
|
+
if (!others)
|
|
883
|
+
return removed;
|
|
884
|
+
for (const path of [configPath, ...others.map(configPathOf)]) {
|
|
885
|
+
const servers = environmentServers(path);
|
|
886
|
+
if (!servers)
|
|
887
|
+
return removed;
|
|
888
|
+
if (Object.values(servers).some((apiUrl) => serverKey(apiUrl) === server))
|
|
889
|
+
return removed;
|
|
890
|
+
}
|
|
891
|
+
if (!loadProjectCredentialsFile(projectRoot).servers[server])
|
|
892
|
+
return removed;
|
|
893
|
+
updateProjectCredentialsFile(projectRoot, (file) => {
|
|
894
|
+
if (!file.servers[server])
|
|
895
|
+
return false;
|
|
896
|
+
delete file.servers[server];
|
|
897
|
+
return true;
|
|
898
|
+
});
|
|
899
|
+
return true;
|
|
672
900
|
}
|
|
673
901
|
catch {
|
|
674
902
|
// Best-effort — removal is not a hard requirement for env removal to succeed.
|
|
675
903
|
return false;
|
|
676
904
|
}
|
|
677
905
|
}
|
|
906
|
+
/** Whether `file` holds a legacy slot or a leftover named `envName`. */
|
|
907
|
+
function holdsSlotOf(file, envName) {
|
|
908
|
+
return (file.environments[envName] !== undefined ||
|
|
909
|
+
Object.values(file.servers).some((entry) => entry.leftovers?.[envName] !== undefined));
|
|
910
|
+
}
|
|
678
911
|
/**
|
|
679
|
-
* Removes the
|
|
680
|
-
* project's credentials file
|
|
681
|
-
*
|
|
682
|
-
*
|
|
912
|
+
* Removes the legacy slot and the leftovers named `envName` in a specific
|
|
913
|
+
* project's credentials file; a server's login, which every environment on
|
|
914
|
+
* the server uses, is never one of them (#4512). Returns false when there was
|
|
915
|
+
* none; throws when there was one and the file could not be rewritten, so a
|
|
916
|
+
* caller that must not lose track of a login can tell the two apart.
|
|
683
917
|
*/
|
|
684
918
|
export function removeCredentialsSlotInProject(projectRoot, envName) {
|
|
685
|
-
if (!loadProjectCredentialsFile(projectRoot)
|
|
919
|
+
if (!holdsSlotOf(loadProjectCredentialsFile(projectRoot), envName))
|
|
686
920
|
return false;
|
|
687
921
|
let removed = false;
|
|
688
922
|
updateProjectCredentialsFile(projectRoot, (file) => {
|
|
689
|
-
removed = file
|
|
923
|
+
removed = holdsSlotOf(file, envName);
|
|
690
924
|
delete file.environments[envName];
|
|
925
|
+
for (const entry of Object.values(file.servers)) {
|
|
926
|
+
if (!entry.leftovers?.[envName])
|
|
927
|
+
continue;
|
|
928
|
+
delete entry.leftovers[envName];
|
|
929
|
+
if (Object.keys(entry.leftovers).length === 0)
|
|
930
|
+
delete entry.leftovers;
|
|
931
|
+
}
|
|
691
932
|
return removed;
|
|
692
933
|
});
|
|
693
934
|
return removed;
|
|
694
935
|
}
|
|
695
936
|
/**
|
|
696
|
-
* Writes
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
* in-project CLI command works without a second `primitive login`.
|
|
700
|
-
* records the credentials' server, which must be the named environment's
|
|
701
|
-
* `apiUrl` in the project's config (#4492).
|
|
937
|
+
* Writes `credentials` as their server's login in a specific project's
|
|
938
|
+
* credentials file (#4512). Used by `primitive init` to carry the session it
|
|
939
|
+
* just authenticated into the freshly scaffolded project, so the first
|
|
940
|
+
* in-project CLI command works without a second `primitive login`.
|
|
702
941
|
*/
|
|
703
|
-
export function
|
|
942
|
+
export function seedCredentialsForServerInProject(projectRoot, credentials) {
|
|
704
943
|
assertStorable(credentials);
|
|
705
|
-
|
|
706
|
-
const apiUrl = config?.environments?.[envName]?.apiUrl;
|
|
707
|
-
if (typeof apiUrl === "string" && !sameServer(credentials.serverUrl, apiUrl)) {
|
|
708
|
-
throw writeMismatch(envName, credentials.serverUrl, apiUrl);
|
|
709
|
-
}
|
|
710
|
-
updateProjectCredentialsFile(projectRoot, (file) => {
|
|
711
|
-
file.environments[envName] = storedRecord(credentials);
|
|
712
|
-
return true;
|
|
713
|
-
});
|
|
944
|
+
writeServerLogin(projectRoot, environmentServers(configPathOf(projectRoot)), credentials);
|
|
714
945
|
}
|
|
715
946
|
/**
|
|
716
|
-
* Lists
|
|
717
|
-
*
|
|
947
|
+
* Lists the environments of the project that have a login to use: every
|
|
948
|
+
* environment on a server holding a login, and before a server's first write
|
|
949
|
+
* the environments with a legacy slot of their own. Returns an empty array in
|
|
950
|
+
* legacy mode.
|
|
718
951
|
*/
|
|
719
952
|
export function listAuthenticatedEnvironments() {
|
|
720
953
|
const env = resolveCurrentEnvironment();
|
|
721
954
|
if (!env)
|
|
722
955
|
return [];
|
|
723
956
|
const file = loadProjectCredentialsFile(env.projectRoot);
|
|
724
|
-
|
|
957
|
+
const servers = environmentServers(env.projectConfigPath) ?? {};
|
|
958
|
+
const names = new Set();
|
|
959
|
+
for (const [name, apiUrl] of Object.entries(servers)) {
|
|
960
|
+
const entry = file.servers[serverKey(apiUrl)];
|
|
961
|
+
if (entry ? entry.login : file.environments[name])
|
|
962
|
+
names.add(name);
|
|
963
|
+
}
|
|
964
|
+
for (const name of Object.keys(file.environments)) {
|
|
965
|
+
const apiUrl = servers[name];
|
|
966
|
+
if (apiUrl === undefined || !file.servers[serverKey(apiUrl)])
|
|
967
|
+
names.add(name);
|
|
968
|
+
}
|
|
969
|
+
return [...names];
|
|
725
970
|
}
|
|
726
971
|
//# sourceMappingURL=credentials-store.js.map
|