primitive-admin 1.1.0-alpha.9 → 1.1.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 +523 -109
- package/assets/skill/skills/primitive-platform/SKILL.md +289 -0
- package/dist/bin/primitive.d.ts +2 -0
- package/dist/bin/primitive.js +372 -21
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.d.ts +2 -0
- package/dist/src/commands/admins.js +136 -30
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/analytics.d.ts +2 -0
- package/dist/src/commands/analytics.js +713 -55
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps.d.ts +2 -0
- package/dist/src/commands/apps.js +65 -100
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth-sessions.d.ts +7 -0
- package/dist/src/commands/auth-sessions.js +144 -0
- package/dist/src/commands/auth-sessions.js.map +1 -0
- package/dist/src/commands/auth.d.ts +2 -0
- package/dist/src/commands/auth.js +238 -108
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.d.ts +2 -0
- package/dist/src/commands/blob-buckets.js +331 -0
- package/dist/src/commands/blob-buckets.js.map +1 -0
- package/dist/src/commands/catalog.d.ts +2 -0
- package/dist/src/commands/catalog.js +63 -48
- package/dist/src/commands/catalog.js.map +1 -1
- package/dist/src/commands/collection-type-configs.d.ts +2 -0
- package/dist/src/commands/collection-type-configs.js +85 -0
- package/dist/src/commands/collection-type-configs.js.map +1 -0
- package/dist/src/commands/collections.d.ts +2 -0
- package/dist/src/commands/collections.js +1282 -0
- package/dist/src/commands/collections.js.map +1 -0
- package/dist/src/commands/comparisons.d.ts +2 -0
- package/dist/src/commands/comparisons.js +6 -6
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/config.d.ts +46 -0
- package/dist/src/commands/config.js +465 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/connections.d.ts +2 -0
- package/dist/src/commands/connections.js +99 -0
- package/dist/src/commands/connections.js.map +1 -0
- package/dist/src/commands/cron-triggers.d.ts +2 -0
- package/dist/src/commands/cron-triggers.js +266 -0
- package/dist/src/commands/cron-triggers.js.map +1 -0
- package/dist/src/commands/database-type-configs.d.ts +2 -0
- package/dist/src/commands/database-type-configs.js +164 -0
- package/dist/src/commands/database-type-configs.js.map +1 -0
- package/dist/src/commands/database-types.d.ts +2 -0
- package/dist/src/commands/database-types.js +471 -0
- package/dist/src/commands/database-types.js.map +1 -0
- package/dist/src/commands/databases.d.ts +65 -0
- package/dist/src/commands/databases.js +1887 -243
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.d.ts +60 -0
- package/dist/src/commands/documents.js +2888 -22
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.d.ts +2 -0
- package/dist/src/commands/email-templates.js +175 -0
- package/dist/src/commands/email-templates.js.map +1 -0
- package/dist/src/commands/env.d.ts +23 -0
- package/dist/src/commands/env.js +395 -0
- package/dist/src/commands/env.js.map +1 -0
- package/dist/src/commands/feature-flags.d.ts +14 -0
- package/dist/src/commands/feature-flags.js +117 -0
- package/dist/src/commands/feature-flags.js.map +1 -0
- package/dist/src/commands/functions.d.ts +20 -0
- package/dist/src/commands/functions.js +1630 -0
- package/dist/src/commands/functions.js.map +1 -0
- package/dist/src/commands/group-type-configs.d.ts +2 -0
- package/dist/src/commands/group-type-configs.js +87 -0
- package/dist/src/commands/group-type-configs.js.map +1 -0
- package/dist/src/commands/groups.d.ts +2 -0
- package/dist/src/commands/groups.js +65 -113
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.d.ts +223 -0
- package/dist/src/commands/guides.js +627 -69
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/init.d.ts +37 -0
- package/dist/src/commands/init.js +1693 -208
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.d.ts +2 -0
- package/dist/src/commands/integrations.js +428 -187
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/llm.d.ts +2 -0
- package/dist/src/commands/llm.js +4 -2
- package/dist/src/commands/llm.js.map +1 -1
- package/dist/src/commands/locks.d.ts +8 -0
- package/dist/src/commands/locks.js +175 -0
- package/dist/src/commands/locks.js.map +1 -0
- package/dist/src/commands/metadata-category-configs.d.ts +12 -0
- package/dist/src/commands/metadata-category-configs.js +113 -0
- package/dist/src/commands/metadata-category-configs.js.map +1 -0
- package/dist/src/commands/metadata.d.ts +2 -0
- package/dist/src/commands/metadata.js +288 -0
- package/dist/src/commands/metadata.js.map +1 -0
- package/dist/src/commands/prompts.d.ts +2 -0
- package/dist/src/commands/prompts.js +322 -634
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +3 -0
- package/dist/src/commands/rule-sets.js +139 -148
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +30 -0
- package/dist/src/commands/scripts.js +688 -0
- package/dist/src/commands/scripts.js.map +1 -0
- package/dist/src/commands/secrets.d.ts +2 -0
- package/dist/src/commands/secrets.js +109 -0
- package/dist/src/commands/secrets.js.map +1 -0
- package/dist/src/commands/sessions.d.ts +2 -0
- package/dist/src/commands/sessions.js +76 -0
- package/dist/src/commands/sessions.js.map +1 -0
- package/dist/src/commands/skill.d.ts +2 -0
- package/dist/src/commands/skill.js +29 -0
- package/dist/src/commands/skill.js.map +1 -0
- package/dist/src/commands/sync-app-settings.d.ts +158 -0
- package/dist/src/commands/sync-app-settings.js +328 -0
- package/dist/src/commands/sync-app-settings.js.map +1 -0
- package/dist/src/commands/sync.d.ts +2670 -0
- package/dist/src/commands/sync.js +17144 -834
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.d.ts +2 -0
- package/dist/src/commands/tokens.js +132 -22
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.d.ts +2 -0
- package/dist/src/commands/users.js +542 -24
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.d.ts +8 -0
- package/dist/src/commands/vars.js +97 -0
- package/dist/src/commands/vars.js.map +1 -0
- package/dist/src/commands/waitlist.d.ts +2 -0
- package/dist/src/commands/waitlist.js +12 -11
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/webhooks.d.ts +31 -0
- package/dist/src/commands/webhooks.js +633 -0
- package/dist/src/commands/webhooks.js.map +1 -0
- package/dist/src/commands/workflows.d.ts +88 -0
- package/dist/src/commands/workflows.js +1568 -742
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/access-rule-display.d.ts +21 -0
- package/dist/src/lib/access-rule-display.js +34 -0
- package/dist/src/lib/access-rule-display.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +2550 -0
- package/dist/src/lib/api-client.js +2503 -160
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
- package/dist/src/lib/app-settings-descriptor.js +583 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -0
- package/dist/src/lib/auth-flow.d.ts +8 -0
- package/dist/src/lib/batch.d.ts +26 -0
- package/dist/src/lib/batch.js +32 -0
- package/dist/src/lib/batch.js.map +1 -0
- package/dist/src/lib/block-layout.d.ts +160 -0
- package/dist/src/lib/block-layout.js +451 -0
- package/dist/src/lib/block-layout.js.map +1 -0
- package/dist/src/lib/block-selector.d.ts +58 -0
- package/dist/src/lib/block-selector.js +92 -0
- package/dist/src/lib/block-selector.js.map +1 -0
- package/dist/src/lib/canonical-json.d.ts +12 -0
- package/dist/src/lib/canonical-json.js +35 -0
- package/dist/src/lib/canonical-json.js.map +1 -0
- package/dist/src/lib/channel.d.ts +30 -0
- package/dist/src/lib/channel.js +68 -0
- package/dist/src/lib/channel.js.map +1 -0
- package/dist/src/lib/cli-manifest.d.ts +68 -0
- package/dist/src/lib/cli-manifest.js +71 -0
- package/dist/src/lib/cli-manifest.js.map +1 -0
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
- package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
- package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +38 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +46 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
- package/dist/src/lib/collection-export.d.ts +184 -0
- package/dist/src/lib/collection-export.js +252 -0
- package/dist/src/lib/collection-export.js.map +1 -0
- package/dist/src/lib/config-json-field.d.ts +28 -0
- package/dist/src/lib/config-json-field.js +56 -0
- package/dist/src/lib/config-json-field.js.map +1 -0
- package/dist/src/lib/config-object-descriptor.d.ts +127 -0
- package/dist/src/lib/config-object-descriptor.js +740 -0
- package/dist/src/lib/config-object-descriptor.js.map +1 -0
- package/dist/src/lib/config-payload.d.ts +92 -0
- package/dist/src/lib/config-payload.js +161 -0
- package/dist/src/lib/config-payload.js.map +1 -0
- package/dist/src/lib/config-surface.d.ts +141 -0
- package/dist/src/lib/config-surface.js +368 -0
- package/dist/src/lib/config-surface.js.map +1 -0
- package/dist/src/lib/config-toml.d.ts +10 -0
- package/dist/src/lib/config-toml.js +42 -0
- package/dist/src/lib/config-toml.js.map +1 -0
- package/dist/src/lib/config.d.ts +71 -0
- package/dist/src/lib/config.js +71 -68
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/confirm-prompt.d.ts +83 -0
- package/dist/src/lib/confirm-prompt.js +110 -0
- package/dist/src/lib/confirm-prompt.js.map +1 -0
- package/dist/src/lib/constants.d.ts +11 -0
- package/dist/src/lib/constants.js +12 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/crash-handlers.d.ts +20 -0
- package/dist/src/lib/crash-handlers.js +49 -0
- package/dist/src/lib/crash-handlers.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +104 -0
- package/dist/src/lib/credentials-store.js +336 -0
- package/dist/src/lib/credentials-store.js.map +1 -0
- package/dist/src/lib/csv.d.ts +47 -0
- package/dist/src/lib/csv.js +172 -0
- package/dist/src/lib/csv.js.map +1 -0
- package/dist/src/lib/data-input.d.ts +23 -0
- package/dist/src/lib/data-input.js +50 -0
- package/dist/src/lib/data-input.js.map +1 -0
- package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
- package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
- package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
- package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
- package/dist/src/lib/db-codegen/dbNaming.js +180 -0
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
- package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js +525 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
- package/dist/src/lib/deprecation.d.ts +22 -0
- package/dist/src/lib/deprecation.js +43 -0
- package/dist/src/lib/deprecation.js.map +1 -0
- package/dist/src/lib/document-export-permissions.d.ts +30 -0
- package/dist/src/lib/document-export-permissions.js +54 -0
- package/dist/src/lib/document-export-permissions.js.map +1 -0
- package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
- package/dist/src/lib/document-ingest-artifact.js +505 -0
- package/dist/src/lib/document-ingest-artifact.js.map +1 -0
- package/dist/src/lib/document-ingest-input.d.ts +51 -0
- package/dist/src/lib/document-ingest-input.js +132 -0
- package/dist/src/lib/document-ingest-input.js.map +1 -0
- package/dist/src/lib/document-ingest-rows.d.ts +137 -0
- package/dist/src/lib/document-ingest-rows.js +181 -0
- package/dist/src/lib/document-ingest-rows.js.map +1 -0
- package/dist/src/lib/document-ingest.d.ts +101 -0
- package/dist/src/lib/document-ingest.js +384 -0
- package/dist/src/lib/document-ingest.js.map +1 -0
- package/dist/src/lib/env-resolver-core.d.ts +258 -0
- package/dist/src/lib/env-resolver-core.js +447 -0
- package/dist/src/lib/env-resolver-core.js.map +1 -0
- package/dist/src/lib/env-resolver.d.ts +99 -0
- package/dist/src/lib/env-resolver.js +153 -0
- package/dist/src/lib/env-resolver.js.map +1 -0
- package/dist/src/lib/fetch.d.ts +5 -0
- package/dist/src/lib/function-bundle.d.ts +147 -0
- package/dist/src/lib/function-bundle.js +341 -0
- package/dist/src/lib/function-bundle.js.map +1 -0
- package/dist/src/lib/function-collect.d.ts +123 -0
- package/dist/src/lib/function-collect.js +610 -0
- package/dist/src/lib/function-collect.js.map +1 -0
- package/dist/src/lib/function-db-types.d.ts +202 -0
- package/dist/src/lib/function-db-types.js +870 -0
- package/dist/src/lib/function-db-types.js.map +1 -0
- package/dist/src/lib/function-document-types.d.ts +144 -0
- package/dist/src/lib/function-document-types.js +370 -0
- package/dist/src/lib/function-document-types.js.map +1 -0
- package/dist/src/lib/function-grants-preflight.d.ts +64 -0
- package/dist/src/lib/function-grants-preflight.js +105 -0
- package/dist/src/lib/function-grants-preflight.js.map +1 -0
- package/dist/src/lib/function-log-lines.d.ts +76 -0
- package/dist/src/lib/function-log-lines.js +160 -0
- package/dist/src/lib/function-log-lines.js.map +1 -0
- package/dist/src/lib/function-log-row.d.ts +29 -0
- package/dist/src/lib/function-log-row.js +73 -0
- package/dist/src/lib/function-log-row.js.map +1 -0
- package/dist/src/lib/function-log-tail.d.ts +132 -0
- package/dist/src/lib/function-log-tail.js +262 -0
- package/dist/src/lib/function-log-tail.js.map +1 -0
- package/dist/src/lib/function-run.d.ts +289 -0
- package/dist/src/lib/function-run.js +389 -0
- package/dist/src/lib/function-run.js.map +1 -0
- package/dist/src/lib/function-schema-codegen.d.ts +143 -0
- package/dist/src/lib/function-schema-codegen.js +420 -0
- package/dist/src/lib/function-schema-codegen.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +459 -0
- package/dist/src/lib/function-sync.js +1258 -0
- package/dist/src/lib/function-sync.js.map +1 -0
- package/dist/src/lib/function-trigger-listing.d.ts +27 -0
- package/dist/src/lib/function-trigger-listing.js +70 -0
- package/dist/src/lib/function-trigger-listing.js.map +1 -0
- package/dist/src/lib/function-typecheck.d.ts +86 -0
- package/dist/src/lib/function-typecheck.js +370 -0
- package/dist/src/lib/function-typecheck.js.map +1 -0
- package/dist/src/lib/function-versions.d.ts +122 -0
- package/dist/src/lib/function-versions.js +182 -0
- package/dist/src/lib/function-versions.js.map +1 -0
- package/dist/src/lib/generated-allowlist.d.ts +28 -0
- package/dist/src/lib/generated-allowlist.js +281 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +2936 -0
- package/dist/src/lib/generated-config-surfaces.js +10569 -0
- package/dist/src/lib/generated-config-surfaces.js.map +1 -0
- package/dist/src/lib/generated-sdk-types.d.ts +12 -0
- package/dist/src/lib/generated-sdk-types.js +13 -0
- package/dist/src/lib/generated-sdk-types.js.map +1 -0
- package/dist/src/lib/generated-template-lint.d.ts +212 -0
- package/dist/src/lib/generated-template-lint.js +624 -0
- package/dist/src/lib/generated-template-lint.js.map +1 -0
- package/dist/src/lib/init-adopt.d.ts +16 -0
- package/dist/src/lib/init-adopt.js +34 -0
- package/dist/src/lib/init-adopt.js.map +1 -0
- package/dist/src/lib/init-assets.d.ts +39 -0
- package/dist/src/lib/init-assets.js +97 -0
- package/dist/src/lib/init-assets.js.map +1 -0
- package/dist/src/lib/init-client-platforms.d.ts +14 -0
- package/dist/src/lib/init-client-platforms.js +71 -0
- package/dist/src/lib/init-client-platforms.js.map +1 -0
- package/dist/src/lib/init-config.d.ts +98 -0
- package/dist/src/lib/init-config.js +186 -0
- package/dist/src/lib/init-config.js.map +1 -0
- package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
- package/dist/src/lib/init-email-redirect-uris.js +46 -0
- package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
- package/dist/src/lib/init-ios-links.d.ts +91 -0
- package/dist/src/lib/init-ios-links.js +219 -0
- package/dist/src/lib/init-ios-links.js.map +1 -0
- package/dist/src/lib/init-plan.d.ts +80 -0
- package/dist/src/lib/init-plan.js +95 -0
- package/dist/src/lib/init-plan.js.map +1 -0
- package/dist/src/lib/init-production-env.d.ts +48 -0
- package/dist/src/lib/init-production-env.js +59 -0
- package/dist/src/lib/init-production-env.js.map +1 -0
- package/dist/src/lib/init-schema.d.ts +74 -0
- package/dist/src/lib/init-schema.js +358 -0
- package/dist/src/lib/init-schema.js.map +1 -0
- package/dist/src/lib/init-xcode.d.ts +34 -0
- package/dist/src/lib/init-xcode.js +138 -0
- package/dist/src/lib/init-xcode.js.map +1 -0
- package/dist/src/lib/integration-request-config.d.ts +30 -0
- package/dist/src/lib/integration-request-config.js +145 -0
- package/dist/src/lib/integration-request-config.js.map +1 -0
- package/dist/src/lib/integration-selector.d.ts +42 -0
- package/dist/src/lib/integration-selector.js +46 -0
- package/dist/src/lib/integration-selector.js.map +1 -0
- package/dist/src/lib/ios-app-id.d.ts +34 -0
- package/dist/src/lib/ios-app-id.js +69 -0
- package/dist/src/lib/ios-app-id.js.map +1 -0
- package/dist/src/lib/list-options.d.ts +68 -0
- package/dist/src/lib/list-options.js +89 -0
- package/dist/src/lib/list-options.js.map +1 -0
- package/dist/src/lib/local-state.d.ts +55 -0
- package/dist/src/lib/local-state.js +167 -0
- package/dist/src/lib/local-state.js.map +1 -0
- package/dist/src/lib/local-test-cases.d.ts +63 -0
- package/dist/src/lib/local-test-cases.js +136 -0
- package/dist/src/lib/local-test-cases.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +715 -0
- package/dist/src/lib/log-inspection.js +816 -0
- package/dist/src/lib/log-inspection.js.map +1 -0
- package/dist/src/lib/logout-admin-session.d.ts +33 -0
- package/dist/src/lib/logout-admin-session.js +70 -0
- package/dist/src/lib/logout-admin-session.js.map +1 -0
- package/dist/src/lib/migration-nag.d.ts +49 -0
- package/dist/src/lib/migration-nag.js +163 -0
- package/dist/src/lib/migration-nag.js.map +1 -0
- package/dist/src/lib/object-status-filter.d.ts +22 -0
- package/dist/src/lib/object-status-filter.js +45 -0
- package/dist/src/lib/object-status-filter.js.map +1 -0
- package/dist/src/lib/output.d.ts +124 -0
- package/dist/src/lib/output.js +219 -8
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/package-manager.d.ts +140 -0
- package/dist/src/lib/package-manager.js +305 -0
- package/dist/src/lib/package-manager.js.map +1 -0
- package/dist/src/lib/paginate.d.ts +98 -0
- package/dist/src/lib/paginate.js +112 -0
- package/dist/src/lib/paginate.js.map +1 -0
- package/dist/src/lib/platform-owned.d.ts +63 -0
- package/dist/src/lib/platform-owned.js +85 -0
- package/dist/src/lib/platform-owned.js.map +1 -0
- package/dist/src/lib/project-config.d.ts +122 -0
- package/dist/src/lib/project-config.js +244 -0
- package/dist/src/lib/project-config.js.map +1 -0
- package/dist/src/lib/prompt-cost-format.d.ts +11 -0
- package/dist/src/lib/prompt-cost-format.js +41 -0
- package/dist/src/lib/prompt-cost-format.js.map +1 -0
- package/dist/src/lib/prompt-schema-codegen.d.ts +147 -0
- package/dist/src/lib/prompt-schema-codegen.js +462 -0
- package/dist/src/lib/prompt-schema-codegen.js.map +1 -0
- package/dist/src/lib/query-operators.d.ts +43 -0
- package/dist/src/lib/query-operators.js +80 -0
- package/dist/src/lib/query-operators.js.map +1 -0
- package/dist/src/lib/record-filter.d.ts +18 -0
- package/dist/src/lib/record-filter.js +55 -0
- package/dist/src/lib/record-filter.js.map +1 -0
- package/dist/src/lib/refresh-admin-credentials.d.ts +73 -0
- package/dist/src/lib/refresh-admin-credentials.js +123 -0
- package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
- package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
- package/dist/src/lib/resolve-init-dev-port.js +55 -0
- package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
- package/dist/src/lib/resolve-init-server.d.ts +64 -0
- package/dist/src/lib/resolve-init-server.js +77 -0
- package/dist/src/lib/resolve-init-server.js.map +1 -0
- package/dist/src/lib/resolve-owner.d.ts +19 -0
- package/dist/src/lib/resolve-owner.js +20 -0
- package/dist/src/lib/resolve-owner.js.map +1 -0
- package/dist/src/lib/resolve-platform.d.ts +74 -0
- package/dist/src/lib/resolve-platform.js +105 -0
- package/dist/src/lib/resolve-platform.js.map +1 -0
- package/dist/src/lib/run-status.d.ts +19 -0
- package/dist/src/lib/run-status.generated.d.ts +39 -0
- package/dist/src/lib/run-status.generated.js +66 -0
- package/dist/src/lib/run-status.generated.js.map +1 -0
- package/dist/src/lib/run-status.js +19 -0
- package/dist/src/lib/run-status.js.map +1 -0
- package/dist/src/lib/server-text-normalization.d.ts +51 -0
- package/dist/src/lib/server-text-normalization.js +90 -0
- package/dist/src/lib/server-text-normalization.js.map +1 -0
- package/dist/src/lib/server-url.d.ts +22 -0
- package/dist/src/lib/server-url.js +33 -0
- package/dist/src/lib/server-url.js.map +1 -0
- package/dist/src/lib/signing-secret-status.d.ts +81 -0
- package/dist/src/lib/signing-secret-status.js +116 -0
- package/dist/src/lib/signing-secret-status.js.map +1 -0
- package/dist/src/lib/skill-installer.d.ts +71 -0
- package/dist/src/lib/skill-installer.js +441 -0
- package/dist/src/lib/skill-installer.js.map +1 -0
- package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
- package/dist/src/lib/snapshot-audit-source.js +58 -0
- package/dist/src/lib/snapshot-audit-source.js.map +1 -0
- package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
- package/dist/src/lib/snapshot-audit-store.js +196 -0
- package/dist/src/lib/snapshot-audit-store.js.map +1 -0
- package/dist/src/lib/snapshot-audit.d.ts +207 -0
- package/dist/src/lib/snapshot-audit.js +431 -0
- package/dist/src/lib/snapshot-audit.js.map +1 -0
- package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
- package/dist/src/lib/snapshot-build-rows.js +87 -0
- package/dist/src/lib/snapshot-build-rows.js.map +1 -0
- package/dist/src/lib/snapshot-build.d.ts +50 -0
- package/dist/src/lib/snapshot-build.js +111 -0
- package/dist/src/lib/snapshot-build.js.map +1 -0
- package/dist/src/lib/snapshot-manifest-layout.d.ts +61 -0
- package/dist/src/lib/snapshot-manifest-layout.js +70 -0
- package/dist/src/lib/snapshot-manifest-layout.js.map +1 -0
- package/dist/src/lib/snapshots.d.ts +98 -0
- package/dist/src/lib/snapshots.js +294 -0
- package/dist/src/lib/snapshots.js.map +1 -0
- package/dist/src/lib/step-run-table.d.ts +43 -0
- package/dist/src/lib/step-run-table.js +129 -0
- package/dist/src/lib/step-run-table.js.map +1 -0
- package/dist/src/lib/storage-pending-retry.d.ts +26 -0
- package/dist/src/lib/storage-pending-retry.js +42 -0
- package/dist/src/lib/storage-pending-retry.js.map +1 -0
- package/dist/src/lib/swift-codegen/agentGenerator.d.ts +42 -0
- package/dist/src/lib/swift-codegen/agentGenerator.js +118 -0
- package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/banners.d.ts +24 -0
- package/dist/src/lib/swift-codegen/banners.js +25 -0
- package/dist/src/lib/swift-codegen/banners.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js +926 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
- package/dist/src/lib/swift-codegen/functionGenerator.d.ts +139 -0
- package/dist/src/lib/swift-codegen/functionGenerator.js +462 -0
- package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/generator.d.ts +100 -0
- package/dist/src/lib/swift-codegen/generator.js +457 -0
- package/dist/src/lib/swift-codegen/generator.js.map +1 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +87 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.js +661 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
- package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
- package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
- package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
- package/dist/src/lib/sync-dir-selector.d.ts +21 -0
- package/dist/src/lib/sync-dir-selector.js +30 -0
- package/dist/src/lib/sync-dir-selector.js.map +1 -0
- package/dist/src/lib/sync-paths.d.ts +128 -0
- package/dist/src/lib/sync-paths.js +195 -0
- package/dist/src/lib/sync-paths.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +563 -0
- package/dist/src/lib/sync-resource-types.js +1073 -0
- package/dist/src/lib/sync-resource-types.js.map +1 -0
- package/dist/src/lib/sync-selectors.d.ts +138 -0
- package/dist/src/lib/sync-selectors.js +289 -0
- package/dist/src/lib/sync-selectors.js.map +1 -0
- package/dist/src/lib/template.d.ts +170 -0
- package/dist/src/lib/template.js +484 -68
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/test-case-file-names.d.ts +40 -0
- package/dist/src/lib/test-case-file-names.js +91 -0
- package/dist/src/lib/test-case-file-names.js.map +1 -0
- package/dist/src/lib/test-case-keys.d.ts +29 -0
- package/dist/src/lib/test-case-keys.js +55 -0
- package/dist/src/lib/test-case-keys.js.map +1 -0
- package/dist/src/lib/test-case-variables.d.ts +29 -0
- package/dist/src/lib/test-case-variables.js +71 -0
- package/dist/src/lib/test-case-variables.js.map +1 -0
- package/dist/src/lib/token-inject.d.ts +56 -0
- package/dist/src/lib/token-inject.js +204 -0
- package/dist/src/lib/token-inject.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +123 -0
- package/dist/src/lib/toml-database-config.js +544 -0
- package/dist/src/lib/toml-database-config.js.map +1 -0
- package/dist/src/lib/toml-metadata-config.d.ts +151 -0
- package/dist/src/lib/toml-metadata-config.js +476 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -0
- package/dist/src/lib/toml-native-form.d.ts +46 -0
- package/dist/src/lib/toml-native-form.js +78 -0
- package/dist/src/lib/toml-native-form.js.map +1 -0
- package/dist/src/lib/toml-params-validator.d.ts +129 -0
- package/dist/src/lib/toml-params-validator.js +298 -0
- package/dist/src/lib/toml-params-validator.js.map +1 -0
- package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
- package/dist/src/lib/toml-scalar-edit.js +283 -0
- package/dist/src/lib/toml-scalar-edit.js.map +1 -0
- package/dist/src/lib/user-selector.d.ts +24 -0
- package/dist/src/lib/user-selector.js +33 -0
- package/dist/src/lib/user-selector.js.map +1 -0
- package/dist/src/lib/version-check.d.ts +35 -0
- package/dist/src/lib/version-check.js +241 -0
- package/dist/src/lib/version-check.js.map +1 -0
- package/dist/src/lib/watch.d.ts +121 -0
- package/dist/src/lib/watch.js +169 -0
- package/dist/src/lib/watch.js.map +1 -0
- package/dist/src/lib/web-url.d.ts +40 -0
- package/dist/src/lib/web-url.js +76 -0
- package/dist/src/lib/web-url.js.map +1 -0
- package/dist/src/lib/webhook-deliver.d.ts +209 -0
- package/dist/src/lib/webhook-deliver.js +519 -0
- package/dist/src/lib/webhook-deliver.js.map +1 -0
- package/dist/src/lib/workflow-apply.d.ts +110 -0
- package/dist/src/lib/workflow-apply.js +164 -0
- package/dist/src/lib/workflow-apply.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
- package/dist/src/lib/workflow-codegen/generator.js +361 -0
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
- package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
- package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
- package/dist/src/lib/workflow-codegen/naming.js +81 -0
- package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/workflow-config-apply.d.ts +70 -0
- package/dist/src/lib/workflow-config-apply.js +137 -0
- package/dist/src/lib/workflow-config-apply.js.map +1 -0
- package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
- package/dist/src/lib/workflow-config-sidecar.js +96 -0
- package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
- package/dist/src/lib/workflow-defaults.d.ts +29 -0
- package/dist/src/lib/workflow-defaults.js +41 -0
- package/dist/src/lib/workflow-defaults.js.map +1 -0
- package/dist/src/lib/workflow-fragments.d.ts +64 -0
- package/dist/src/lib/workflow-fragments.js +342 -0
- package/dist/src/lib/workflow-fragments.js.map +1 -0
- package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
- package/dist/src/lib/workflow-include-preserve.js +286 -0
- package/dist/src/lib/workflow-include-preserve.js.map +1 -0
- package/dist/src/lib/workflow-payload.d.ts +98 -0
- package/dist/src/lib/workflow-payload.js +178 -0
- package/dist/src/lib/workflow-payload.js.map +1 -0
- package/dist/src/lib/workflow-toml-validator.d.ts +211 -0
- package/dist/src/lib/workflow-toml-validator.js +770 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -0
- package/dist/src/lib/workflow-usage.d.ts +196 -0
- package/dist/src/lib/workflow-usage.js +310 -0
- package/dist/src/lib/workflow-usage.js.map +1 -0
- package/dist/src/types/index.d.ts +591 -0
- package/dist/src/validators.d.ts +65 -0
- package/dist/src/validators.js +64 -0
- package/dist/src/validators.js.map +1 -0
- package/package.json +34 -9
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Driving one bulk-load session: create, upload, commit, poll.
|
|
3
|
+
*
|
|
4
|
+
* The artifact is already built and checked by the time anything here runs
|
|
5
|
+
* (`document-ingest-artifact`), so every refusal this module reports comes
|
|
6
|
+
* from the server. What it decides is what to do about one:
|
|
7
|
+
*
|
|
8
|
+
* - a create the server refuses uploads nothing;
|
|
9
|
+
* - an upload that fails ABORTS the session rather than retrying a slot whose
|
|
10
|
+
* reservation this side cannot see — the artifact is deterministic and a
|
|
11
|
+
* re-run is cheap;
|
|
12
|
+
* - Ctrl-C during the uploads aborts too, because the session it was filling
|
|
13
|
+
* is not going to be committed; Ctrl-C while POLLING leaves the session
|
|
14
|
+
* alone, because by then the document is already being changed and giving up
|
|
15
|
+
* on watching is not giving up on the load;
|
|
16
|
+
* - a session READ that fails while polling is retried on a bounded schedule
|
|
17
|
+
* (#3597), for the same reason: the read failing says nothing about the load,
|
|
18
|
+
* and a multi-hour load will meet transient reads. When the bound is spent
|
|
19
|
+
* the wait stops and says the session is still running — it never reports it
|
|
20
|
+
* as cancelled or failed.
|
|
21
|
+
*
|
|
22
|
+
* Exit codes follow `functions runs wait`/`invoke`, as `docs/cli-design.md`
|
|
23
|
+
* records them: 0 completed, 1 failed or refused, 124 a wait that gave up,
|
|
24
|
+
* 130 Ctrl-C. Both ways of giving up on the WATCHING are 124 and both say the
|
|
25
|
+
* session keeps running; only the load itself failing is 1.
|
|
26
|
+
*/
|
|
27
|
+
import fs from "fs";
|
|
28
|
+
/** A plan the operator did not confirm, or cannot be asked about. */
|
|
29
|
+
export class IngestRefusedError extends Error {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "IngestRefusedError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const POLL_FAST_MS = 2_000;
|
|
36
|
+
const POLL_SLOW_MS = 5_000;
|
|
37
|
+
const POLL_SLOWS_AFTER_MS = 60_000;
|
|
38
|
+
/**
|
|
39
|
+
* How long CONSECUTIVE failed session reads may run before the wait gives up
|
|
40
|
+
* (#3597), and the backoff between them.
|
|
41
|
+
*
|
|
42
|
+
* A bound measured in attempts would have been wrong for the load this is for:
|
|
43
|
+
* the 2026-09-18 2 GB validation attempts met reads that failed for MINUTES
|
|
44
|
+
* together through the same route while the session stayed alive and
|
|
45
|
+
* advancing. So the bound is a wall-clock window, and any successful read
|
|
46
|
+
* resets it — an isolated blip costs a multi-hour load nothing at all, and
|
|
47
|
+
* only an outage that never lifts ends the watching.
|
|
48
|
+
*
|
|
49
|
+
* Module constants like the poll cadence above, deliberately: there is no flag
|
|
50
|
+
* for them. The backoff caps rather than doubling forever, because a backoff
|
|
51
|
+
* that silently stops backing off is a poll storm (`function-run.ts`).
|
|
52
|
+
*/
|
|
53
|
+
const POLL_READ_RETRY_WINDOW_MS = 10 * 60_000;
|
|
54
|
+
const POLL_READ_BACKOFF_MS = 1_000;
|
|
55
|
+
const POLL_READ_BACKOFF_CAP_MS = 15_000;
|
|
56
|
+
/**
|
|
57
|
+
* Whether a thrown session read is worth retrying.
|
|
58
|
+
*
|
|
59
|
+
* `ApiClient.request` throws an `ApiError` carrying `statusCode` on any
|
|
60
|
+
* non-2xx, and the fetch under it rejects with no status at all on a dropped
|
|
61
|
+
* connection — so a transport failure, a 5xx, a 408 and a 429 all describe a
|
|
62
|
+
* server that may well answer the next read, and the session goes on either
|
|
63
|
+
* way. Any OTHER 4xx is definitive: the session is gone, or unreadable to this
|
|
64
|
+
* caller, and retrying it only to call it "still running" would misstate it.
|
|
65
|
+
*/
|
|
66
|
+
function isTransientReadError(error) {
|
|
67
|
+
const status = error?.statusCode ?? error?.status;
|
|
68
|
+
if (typeof status !== "number")
|
|
69
|
+
return true;
|
|
70
|
+
if (status >= 500)
|
|
71
|
+
return true;
|
|
72
|
+
return status === 408 || status === 429;
|
|
73
|
+
}
|
|
74
|
+
/** The capped doubling between consecutive failed reads. */
|
|
75
|
+
function readBackoffMs(failures) {
|
|
76
|
+
return Math.min(POLL_READ_BACKOFF_MS * 2 ** (failures - 1), POLL_READ_BACKOFF_CAP_MS);
|
|
77
|
+
}
|
|
78
|
+
/** The plan summary an operator confirms, one line per row. */
|
|
79
|
+
export function summariseIngestPlan(plan) {
|
|
80
|
+
const lines = plan.models.map((model) => ` ${model.model}: ${model.rows} rows, ${model.chunks} chunks, ` +
|
|
81
|
+
`${model.bytes} bytes` +
|
|
82
|
+
(model.deletes > 0 ? `, ${model.deletes} deletes` : ""));
|
|
83
|
+
return [
|
|
84
|
+
`${plan.rows} rows across ${plan.models.length} model(s), ` +
|
|
85
|
+
`${plan.chunks.length} chunks, ${plan.bytes} bytes` +
|
|
86
|
+
(plan.deletes > 0 ? `, ${plan.deletes} deletes` : ""),
|
|
87
|
+
...lines,
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Refuse a run that cannot ask, before it asks the server anything.
|
|
92
|
+
*
|
|
93
|
+
* A bulk load deletes and overwrites a live document's records with no undo,
|
|
94
|
+
* which is what the CLI design's destructive default is for. A pipeline that
|
|
95
|
+
* meant to run one says so with `-y`.
|
|
96
|
+
*/
|
|
97
|
+
export function assertIngestConfirmable(options) {
|
|
98
|
+
if (options.yes || options.isTTY)
|
|
99
|
+
return;
|
|
100
|
+
throw new IngestRefusedError("A bulk load replaces records in a live document and cannot be undone. " +
|
|
101
|
+
"Re-run with -y to confirm it without a prompt.");
|
|
102
|
+
}
|
|
103
|
+
export async function driveDocumentIngest(options) {
|
|
104
|
+
const { client, documentId, plan, concurrency = 4, wait = true, timeoutMs = null, signal, onProgress = () => { }, readChunk = async (chunk) => fs.readFileSync(chunk.file), now = () => Date.now(), sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), } = options;
|
|
105
|
+
// A phase appears only once it has FINISHED (#3598). A create that threw
|
|
106
|
+
// cost time, but not a measurable amount of anything an operator can act
|
|
107
|
+
// on; half an upload has no rate; and a phase the run never reached has
|
|
108
|
+
// nothing to say rather than a zero to say it with.
|
|
109
|
+
const timings = {};
|
|
110
|
+
/** A whole number of milliseconds, never negative. */
|
|
111
|
+
const since = (at) => Math.max(0, now() - at);
|
|
112
|
+
// ── create ──
|
|
113
|
+
let session;
|
|
114
|
+
const createdAt = now();
|
|
115
|
+
try {
|
|
116
|
+
session = await client.createIngest(documentId);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (error?.code === "DOCUMENT_INGEST_ACTIVE") {
|
|
120
|
+
const active = (error.details && error.details.sessionId) ?? "the active session";
|
|
121
|
+
return {
|
|
122
|
+
exitCode: 1,
|
|
123
|
+
sessionId: null,
|
|
124
|
+
session: null,
|
|
125
|
+
timings,
|
|
126
|
+
message: `${error.message}\nThis document already has bulk load ${active}. ` +
|
|
127
|
+
`Watch it with \`primitive documents ingests get ${documentId} ${active}\`, ` +
|
|
128
|
+
`or give it up with \`primitive documents ingests abort\`.`,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
exitCode: 1,
|
|
133
|
+
sessionId: null,
|
|
134
|
+
session: null,
|
|
135
|
+
timings,
|
|
136
|
+
message: String(error?.message ?? error),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
timings.createMs = since(createdAt);
|
|
140
|
+
const sessionId = String(session.sessionId);
|
|
141
|
+
onProgress(`Session ${sessionId} opened.`);
|
|
142
|
+
const giveUp = async (message, exitCode) => {
|
|
143
|
+
try {
|
|
144
|
+
await client.abortIngest(documentId, sessionId);
|
|
145
|
+
onProgress(`Session ${sessionId} aborted; nothing was applied.`);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
onProgress(`Session ${sessionId} could not be aborted: ${error?.message ?? error}`);
|
|
149
|
+
}
|
|
150
|
+
return { exitCode, sessionId, session: null, timings, message };
|
|
151
|
+
};
|
|
152
|
+
// ── upload ──
|
|
153
|
+
const uploadStartedAt = now();
|
|
154
|
+
const queue = [...plan.chunks];
|
|
155
|
+
let uploaded = 0;
|
|
156
|
+
let failure = null;
|
|
157
|
+
const worker = async () => {
|
|
158
|
+
for (;;) {
|
|
159
|
+
if (failure !== null || signal?.aborted)
|
|
160
|
+
return;
|
|
161
|
+
const chunk = queue.shift();
|
|
162
|
+
if (!chunk)
|
|
163
|
+
return;
|
|
164
|
+
try {
|
|
165
|
+
const body = await readChunk(chunk);
|
|
166
|
+
await client.uploadIngestChunk(documentId, sessionId, { ...chunk, body });
|
|
167
|
+
uploaded += 1;
|
|
168
|
+
onProgress(`Uploaded ${uploaded}/${plan.chunks.length} chunks ` +
|
|
169
|
+
`(${chunk.model} ${chunk.index}).`);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
// The first failure wins: the others are the same session going away.
|
|
173
|
+
if (failure === null)
|
|
174
|
+
failure = String(error?.message ?? error);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
await Promise.all(Array.from({ length: Math.max(1, Math.min(concurrency, queue.length || 1)) }, worker));
|
|
180
|
+
if (failure !== null)
|
|
181
|
+
return giveUp(failure, 1);
|
|
182
|
+
if (signal?.aborted) {
|
|
183
|
+
return giveUp("Interrupted while uploading; the session was aborted and nothing was applied.", 130);
|
|
184
|
+
}
|
|
185
|
+
// Every chunk is up, so there is a rate to state. It is measured over the
|
|
186
|
+
// PLAN's stored chunk sizes — what actually went over the wire — rather
|
|
187
|
+
// than over the decompressed total, which is not what was sent.
|
|
188
|
+
const uploadMs = since(uploadStartedAt);
|
|
189
|
+
const uploadedBytes = plan.chunks.reduce((sum, chunk) => sum + chunk.bytes, 0);
|
|
190
|
+
timings.uploadMs = uploadMs;
|
|
191
|
+
timings.uploadedBytes = uploadedBytes;
|
|
192
|
+
onProgress(`Uploaded ${plan.chunks.length} chunks (${uploadedBytes} bytes) in ` +
|
|
193
|
+
`${seconds(uploadMs)}` +
|
|
194
|
+
(uploadMs > 0 ? ` (${megabytesPerSecond(uploadedBytes, uploadMs)}).` : "."));
|
|
195
|
+
// ── commit ──
|
|
196
|
+
const committedAt = now();
|
|
197
|
+
try {
|
|
198
|
+
session = await client.commitIngest(documentId, sessionId);
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
return giveUp(String(error?.message ?? error), 1);
|
|
202
|
+
}
|
|
203
|
+
const commitMs = since(committedAt);
|
|
204
|
+
timings.commitMs = commitMs;
|
|
205
|
+
onProgress(`Session ${sessionId} committed.`);
|
|
206
|
+
onProgress(`Committed in ${seconds(commitMs)}.`);
|
|
207
|
+
if (!wait) {
|
|
208
|
+
// Nothing was waited for, so the wait is zero rather than unknown: the
|
|
209
|
+
// session keeps running and `ingests get` is where its own time is.
|
|
210
|
+
timings.waitMs = 0;
|
|
211
|
+
return { exitCode: 0, sessionId, session, timings, message: undefined };
|
|
212
|
+
}
|
|
213
|
+
// ── poll ──
|
|
214
|
+
//
|
|
215
|
+
// Past this point the session is the server's business: the copy has begun
|
|
216
|
+
// and the document's tables will be swapped whatever this process does. So
|
|
217
|
+
// neither a timeout nor a Ctrl-C nor a read that keeps failing aborts it —
|
|
218
|
+
// each says so and leaves.
|
|
219
|
+
const started = now();
|
|
220
|
+
let reported = null;
|
|
221
|
+
let reportedProgress = "";
|
|
222
|
+
// The current run of consecutive failed reads: how many, when it started on
|
|
223
|
+
// the injected clock, and the last thing the server said. All three reset on
|
|
224
|
+
// any read that answers.
|
|
225
|
+
let readFailures = 0;
|
|
226
|
+
let failingSince = 0;
|
|
227
|
+
let lastReadError = "";
|
|
228
|
+
const stillRunning = () => `The bulk load is still running on the server; read it with ` +
|
|
229
|
+
`\`primitive documents ingests get ${documentId} ${sessionId}\`.`;
|
|
230
|
+
// Every door out of the WATCHING records the wait it is ending (#3598): the
|
|
231
|
+
// time was really spent on the server whichever way the watching stopped,
|
|
232
|
+
// and a load that gave up is exactly when somebody needs that number.
|
|
233
|
+
const interrupted = (view) => {
|
|
234
|
+
timings.waitMs = since(started);
|
|
235
|
+
return {
|
|
236
|
+
exitCode: 130,
|
|
237
|
+
sessionId,
|
|
238
|
+
session: view,
|
|
239
|
+
timings,
|
|
240
|
+
message: `Interrupted. The session keeps running; watch it with ` +
|
|
241
|
+
`\`primitive documents ingests get ${documentId} ${sessionId}\`.`,
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
const timedOut = (view, elapsed) => {
|
|
245
|
+
timings.waitMs = elapsed;
|
|
246
|
+
return {
|
|
247
|
+
exitCode: 124,
|
|
248
|
+
sessionId,
|
|
249
|
+
session: view,
|
|
250
|
+
timings,
|
|
251
|
+
message: `Gave up waiting after ${Math.round(elapsed / 1000)}s. The session ` +
|
|
252
|
+
`keeps running; watch it with \`primitive documents ingests get ` +
|
|
253
|
+
`${documentId} ${sessionId}\`.`,
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
for (;;) {
|
|
257
|
+
let view;
|
|
258
|
+
try {
|
|
259
|
+
view = await client.getIngest(documentId, sessionId);
|
|
260
|
+
if (readFailures > 0) {
|
|
261
|
+
onProgress(`Session ${sessionId} answered again after ${readFailures} ` +
|
|
262
|
+
`unanswered read(s); polling resumed.`);
|
|
263
|
+
readFailures = 0;
|
|
264
|
+
lastReadError = "";
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
const message = String(error?.message ?? error);
|
|
269
|
+
// A refusal is a refusal: it is reported now, exactly as before — and
|
|
270
|
+
// it still carries the wait that preceded it (finding 3598-FROZEN-01),
|
|
271
|
+
// because a load that polled for minutes before the reads stopped
|
|
272
|
+
// answering really did spend those minutes waiting on the server.
|
|
273
|
+
if (!isTransientReadError(error)) {
|
|
274
|
+
timings.waitMs = since(started);
|
|
275
|
+
return { exitCode: 1, sessionId, session: null, timings, message };
|
|
276
|
+
}
|
|
277
|
+
if (readFailures === 0)
|
|
278
|
+
failingSince = now();
|
|
279
|
+
readFailures += 1;
|
|
280
|
+
lastReadError = message;
|
|
281
|
+
const failingFor = now() - failingSince;
|
|
282
|
+
if (failingFor >= POLL_READ_RETRY_WINDOW_MS) {
|
|
283
|
+
// 124, the documented "a wait that gave up" code — never 1. Giving up
|
|
284
|
+
// on the watching is not the load failing, and the operator has to be
|
|
285
|
+
// able to tell them apart by the exit code alone.
|
|
286
|
+
timings.waitMs = since(started);
|
|
287
|
+
return {
|
|
288
|
+
exitCode: 124,
|
|
289
|
+
sessionId,
|
|
290
|
+
session: null,
|
|
291
|
+
timings,
|
|
292
|
+
message: `Stopped watching after ${Math.round(failingFor / 1000)}s of ` +
|
|
293
|
+
`unanswered session reads (${readFailures} attempts). ` +
|
|
294
|
+
`${stillRunning()} Last read error: ${lastReadError}`,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
onProgress(`Session ${sessionId} did not answer (attempt ${readFailures}, ` +
|
|
298
|
+
`unanswered for ${Math.round(failingFor / 1000)}s); retrying` +
|
|
299
|
+
(readFailures === 1 ? `: ${message}` : "."));
|
|
300
|
+
await sleep(readBackoffMs(readFailures));
|
|
301
|
+
// The backoff sleep is part of the wait, so it honours the same two
|
|
302
|
+
// doors the success path does and with the same words: neither aborts.
|
|
303
|
+
if (signal?.aborted)
|
|
304
|
+
return interrupted(null);
|
|
305
|
+
const waited = now() - started;
|
|
306
|
+
if (timeoutMs !== null && waited >= timeoutMs)
|
|
307
|
+
return timedOut(null, waited);
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (view?.state !== reported) {
|
|
311
|
+
reported = view?.state ?? null;
|
|
312
|
+
onProgress(`Session ${sessionId} is ${reported}.`);
|
|
313
|
+
}
|
|
314
|
+
const progress = describeProgress(view?.progress);
|
|
315
|
+
if (progress && progress !== reportedProgress) {
|
|
316
|
+
reportedProgress = progress;
|
|
317
|
+
onProgress(` ${progress}`);
|
|
318
|
+
}
|
|
319
|
+
if (view?.state === "complete") {
|
|
320
|
+
const waitMs = since(started);
|
|
321
|
+
timings.waitMs = waitMs;
|
|
322
|
+
// What the PLATFORM spent, separable from what this side did. The
|
|
323
|
+
// session's own `timings` say where inside the platform it went.
|
|
324
|
+
onProgress(`Server finished in ${seconds(waitMs)}.`);
|
|
325
|
+
return { exitCode: 0, sessionId, session: view, timings };
|
|
326
|
+
}
|
|
327
|
+
if (view?.state === "failed" || view?.state === "aborted") {
|
|
328
|
+
const waitMs = since(started);
|
|
329
|
+
timings.waitMs = waitMs;
|
|
330
|
+
onProgress(`Server finished in ${seconds(waitMs)}.`);
|
|
331
|
+
return {
|
|
332
|
+
exitCode: 1,
|
|
333
|
+
sessionId,
|
|
334
|
+
session: view,
|
|
335
|
+
timings,
|
|
336
|
+
message: describeFailure(view),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
const elapsed = now() - started;
|
|
340
|
+
if (timeoutMs !== null && elapsed >= timeoutMs)
|
|
341
|
+
return timedOut(view, elapsed);
|
|
342
|
+
await sleep(elapsed >= POLL_SLOWS_AFTER_MS ? POLL_SLOW_MS : POLL_FAST_MS);
|
|
343
|
+
if (signal?.aborted)
|
|
344
|
+
return interrupted(view);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/** A duration an operator reads at a glance, never a bare millisecond count. */
|
|
348
|
+
function seconds(ms) {
|
|
349
|
+
return ms < 1000 ? `${Math.round(ms)}ms` : `${(ms / 1000).toFixed(1)}s`;
|
|
350
|
+
}
|
|
351
|
+
/** The unit a bulk load's speed is discussed in. */
|
|
352
|
+
function megabytesPerSecond(bytes, ms) {
|
|
353
|
+
return `${((bytes / 1_000_000 / ms) * 1000).toFixed(2)} MB/s`;
|
|
354
|
+
}
|
|
355
|
+
/** The session's own words for why it stopped. */
|
|
356
|
+
function describeFailure(view) {
|
|
357
|
+
if (view?.state === "aborted")
|
|
358
|
+
return "The session was aborted.";
|
|
359
|
+
const failure = view?.failure;
|
|
360
|
+
if (!failure)
|
|
361
|
+
return "The session failed.";
|
|
362
|
+
// A failure's rows are `{ model, id }` on the wire, and a bounded sample of
|
|
363
|
+
// them; a string is accepted too so a stub or an older server still reads.
|
|
364
|
+
const rows = Array.isArray(failure.rows) && failure.rows.length > 0
|
|
365
|
+
? `\n ${failure.rows
|
|
366
|
+
.map((row) => typeof row === "string" ? row : `${row?.model} ${row?.id}`)
|
|
367
|
+
.join("\n ")}`
|
|
368
|
+
: "";
|
|
369
|
+
return `${failure.code}: ${failure.reason}${rows}`;
|
|
370
|
+
}
|
|
371
|
+
/** One line of counters, or nothing while they are all still zero. */
|
|
372
|
+
function describeProgress(progress) {
|
|
373
|
+
if (!progress)
|
|
374
|
+
return "";
|
|
375
|
+
const copied = progress.rowsCopied ?? 0;
|
|
376
|
+
const chunks = progress.chunksApplied ?? 0;
|
|
377
|
+
const rows = progress.rowsApplied ?? 0;
|
|
378
|
+
const reconciled = progress.recordsReconciled ?? 0;
|
|
379
|
+
if (copied + chunks + rows + reconciled === 0)
|
|
380
|
+
return "";
|
|
381
|
+
return (`copied ${copied} rows, applied ${chunks} chunks / ${rows} rows, ` +
|
|
382
|
+
`reconciled ${reconciled} records`);
|
|
383
|
+
}
|
|
384
|
+
//# sourceMappingURL=document-ingest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-ingest.js","sourceRoot":"","sources":["../../../src/lib/document-ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAOpB,qEAAqE;AACrE,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AA8DD,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC;;;;;;;;;;;;;;GAcG;AACH,MAAM,yBAAyB,GAAG,EAAE,GAAG,MAAM,CAAC;AAC9C,MAAM,oBAAoB,GAAG,KAAK,CAAC;AACnC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAExC;;;;;;;;;GASG;AACH,SAAS,oBAAoB,CAAC,KAAU;IACtC,MAAM,MAAM,GAAG,KAAK,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,CAAC;IAClD,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC;IAC/B,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC;AAC1C,CAAC;AAED,4DAA4D;AAC5D,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,IAAI,CAAC,GAAG,CACb,oBAAoB,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,EAC1C,wBAAwB,CACzB,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,mBAAmB,CAAC,IAAwB;IAC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ointed at:
|
|
5
|
+
* the CLI, the Vue build (`primitive-app`'s `primitiveEnv()` plugin), and the
|
|
6
|
+
* Swift template's pre-build script. This module is the single algorithm they
|
|
7
|
+
* share. The CLI owns it; `packages/primitive-app` carries a byte-identical
|
|
8
|
+
* GENERATED copy (`cli/scripts/gen-primitive-env-resolver.mjs`, checked for
|
|
9
|
+
* freshness by `cli/tests/unit/env-resolver-copy-drift-guard.test.ts`); the
|
|
10
|
+
* Swift script is an independent bash+python3 port pinned by a parity test.
|
|
11
|
+
*
|
|
12
|
+
* ── COPYABILITY (load-bearing) ────────────────────────────────────────────
|
|
13
|
+
* This file MUST stay self-contained: node builtins only, ZERO relative
|
|
14
|
+
* imports. The generator copies it verbatim into a package that cannot depend
|
|
15
|
+
* on the CLI, so any `./x.js` import here would break that copy at runtime.
|
|
16
|
+
* The drift guard asserts this.
|
|
17
|
+
*
|
|
18
|
+
* Scope: config discovery, the schema `version` check, structural validation,
|
|
19
|
+
* the local selection, the precedence, and the http→ws scheme swap. It
|
|
20
|
+
* deliberately does NOT duplicate the CLI's full field-level validation
|
|
21
|
+
* (`validateProjectConfig` in `project-config.ts`) — the CLI wrapper runs that
|
|
22
|
+
* first, and the other readers only need "version understood, shape sane, fail
|
|
23
|
+
* loudly otherwise".
|
|
24
|
+
*
|
|
25
|
+
* Precedence (one order, everywhere):
|
|
26
|
+
* 1. an explicit name (`--env` / `--primitive-env`)
|
|
27
|
+
* 2. PRIMITIVE_ENV (per-invocation intent, keeps CI working)
|
|
28
|
+
* 3. .primitive/local.json (this machine's `primitive env use`)
|
|
29
|
+
* 4. defaultEnvironment (the committed team default)
|
|
30
|
+
* 5. the sole environment, if there is exactly one
|
|
31
|
+
*/
|
|
32
|
+
/** Schema version of `primitive/config.json` this core understands. */
|
|
33
|
+
export declare const PRIMITIVE_CONFIG_VERSION = 1;
|
|
34
|
+
/** Schema version of `.primitive/local.json` this core writes and reads. */
|
|
35
|
+
export declare const PRIMITIVE_LOCAL_STATE_VERSION = 1;
|
|
36
|
+
/**
|
|
37
|
+
* The two directories, split apart by #3153 so one name never means two
|
|
38
|
+
* things: `primitive/` is the COMMITTED tree (the config and every
|
|
39
|
+
* environment's TOML), `.primitive/` is MACHINE-LOCAL state (credentials, this
|
|
40
|
+
* machine's selection, snapshot backups) and is gitignored whole.
|
|
41
|
+
*/
|
|
42
|
+
export declare const PROJECT_TREE_DIR = "primitive";
|
|
43
|
+
export declare const PROJECT_LOCAL_STATE_DIR = ".primitive";
|
|
44
|
+
export declare const PROJECT_CONFIG_FILENAME = "config.json";
|
|
45
|
+
export declare const LOCAL_STATE_FILENAME = "local.json";
|
|
46
|
+
export declare const PROJECT_CONFIG_DISPLAY_NAME = "primitive/config.json";
|
|
47
|
+
export declare const LOCAL_STATE_DISPLAY_NAME = ".primitive/local.json";
|
|
48
|
+
/**
|
|
49
|
+
* The one refusal for a project that never migrated off the pre-#3153 layout:
|
|
50
|
+
* a `.primitive/config.json` with no `primitive/config.json` beside it.
|
|
51
|
+
*
|
|
52
|
+
* That shape is refused rather than walked past because the walk's next stop
|
|
53
|
+
* is the parent directory, and in a nested checkout the parent may be a
|
|
54
|
+
* DIFFERENT project — a command run in the unmigrated one would silently act
|
|
55
|
+
* on the other's app. Nothing else is refused (#3392): anything left under
|
|
56
|
+
* `.primitive/` beside a migrated tree is machine-local junk, not signal.
|
|
57
|
+
*
|
|
58
|
+
* One sentence, naming both halves — the file that was found and the file
|
|
59
|
+
* that is expected — and no document. The migration page this once pointed
|
|
60
|
+
* at was never published (#3155, won't-fix), and every reader that shares
|
|
61
|
+
* this refusal — this core, the generated Vite-plugin copy, the Swift
|
|
62
|
+
* pre-build script, the Vue template's deploy script — says the same thing.
|
|
63
|
+
*/
|
|
64
|
+
export declare function unmigratedProjectMessage(found: string, expected: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* The one refusal for a command run outside a Primitive project (#3154,
|
|
67
|
+
* intent criterion 5).
|
|
68
|
+
*
|
|
69
|
+
* There is exactly one way to resolve the configuration tree, the credentials
|
|
70
|
+
* and the app: the environment named by `primitive/config.json`. Outside a
|
|
71
|
+
* project there is no such thing, and the CLI says so once, in these words,
|
|
72
|
+
* wherever the question is asked — the resolver core, the CLI's
|
|
73
|
+
* `requireCurrentEnvironment()`, and the credentials store.
|
|
74
|
+
*
|
|
75
|
+
* Two constraints on the wording, both test-asserted:
|
|
76
|
+
*
|
|
77
|
+
* - it names `primitive init`, the one command that creates what is missing;
|
|
78
|
+
* - it never names `primitive env add`, which after this change also fails
|
|
79
|
+
* outside a project — an error may only offer an invocation it does not
|
|
80
|
+
* itself block.
|
|
81
|
+
*/
|
|
82
|
+
export declare function missingConfigMessage(where: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Error kinds callers branch on. Every failure is one of these — no reader is
|
|
85
|
+
* ever left guessing what a broken config meant.
|
|
86
|
+
*/
|
|
87
|
+
export type PrimitiveEnvErrorKind = "missing-config" | "malformed-config" | "unsupported-version" | "corrupt-local-state" | "unknown-environment" | "no-selection" | "missing-app-id" | "stale-layout";
|
|
88
|
+
export declare class PrimitiveEnvError extends Error {
|
|
89
|
+
readonly kind: PrimitiveEnvErrorKind;
|
|
90
|
+
readonly path?: string;
|
|
91
|
+
constructor(kind: PrimitiveEnvErrorKind, message: string, path?: string);
|
|
92
|
+
}
|
|
93
|
+
export interface CoreEnvironmentEntry {
|
|
94
|
+
apiUrl: string;
|
|
95
|
+
/**
|
|
96
|
+
* The one app this environment names (#3152). Required: selecting an
|
|
97
|
+
* environment selects exactly one app, so there is no per-machine "current
|
|
98
|
+
* app" for a second reader to disagree with.
|
|
99
|
+
*/
|
|
100
|
+
appId: string;
|
|
101
|
+
appName?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The app's web counterpart for this environment, as a normalized origin
|
|
104
|
+
* (#2982). Read through `normalizeWebOrigin`, so a value this reader carries
|
|
105
|
+
* is always an origin — see that function for why the typed read other
|
|
106
|
+
* fields get is not enough here.
|
|
107
|
+
*/
|
|
108
|
+
webUrl?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The app's web counterpart as a normalized ORIGIN, or undefined when the
|
|
113
|
+
* value cannot be one (#2982).
|
|
114
|
+
*
|
|
115
|
+
* Unlike `appId`/`appName`, a typed read is not enough. This value is not
|
|
116
|
+
* merely carried: the Swift app points its emailed sign-in link at
|
|
117
|
+
* `<webUrl>/oauth/callback` and trusts incoming universal links from the same
|
|
118
|
+
* origin, and BOTH jobs need an origin —
|
|
119
|
+
*
|
|
120
|
+
* - https except loopback, the rule the server applies to every redirect URI
|
|
121
|
+
* (`src/auth/redirect-uri.ts`): an origin that cannot be allow-listed turns
|
|
122
|
+
* every sign-in request into a 400, and a plain-http link would carry the
|
|
123
|
+
* magic token in clear;
|
|
124
|
+
* - no path, query or fragment: the web client serves its callback on its own
|
|
125
|
+
* origin plus `/oauth/callback`, which is also the exact path the
|
|
126
|
+
* `apple-app-site-association` component claims;
|
|
127
|
+
* - no credentials, which have no business in a link that goes out by email.
|
|
128
|
+
*
|
|
129
|
+
* `primitive env add --web-url` and the project-config validation reject those
|
|
130
|
+
* shapes with a field-named error, but neither is on the path from a
|
|
131
|
+
* hand-edited `primitive/config.json` to an Xcode build: the Swift template's
|
|
132
|
+
* pre-build script reads the file directly. So every reader that feeds
|
|
133
|
+
* `primitive.json` applies the contract, and a value that misses it is read as
|
|
134
|
+
* "this environment has no web counterpart" — code-only email, no trusted
|
|
135
|
+
* origin, nothing silently pointed at the wrong URL.
|
|
136
|
+
*
|
|
137
|
+
* The message-producing twin of this rule lives in `cli/src/lib/web-url.ts`;
|
|
138
|
+
* this file cannot import it (see COPYABILITY above), and a test pins that the
|
|
139
|
+
* two agree.
|
|
140
|
+
*/
|
|
141
|
+
export declare function normalizeWebOrigin(value: unknown): string | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* The one remedy for an environment that names no app (#3152), shared by every
|
|
144
|
+
* reader that can hit it: this core, the CLI's `validateProjectConfig`, the
|
|
145
|
+
* Swift template's pre-build script, and the Vue template's cf-deploy.
|
|
146
|
+
*
|
|
147
|
+
* Two constraints on the wording, both test-asserted:
|
|
148
|
+
*
|
|
149
|
+
* - it never says `primitive env add <name>`, which REFUSES an environment
|
|
150
|
+
* name that already exists — the shape this error is always about;
|
|
151
|
+
* - it names no command the failure itself blocks. The CLI validates the
|
|
152
|
+
* project config before any command parses, so every `primitive` command
|
|
153
|
+
* run inside the broken project fails with this same error. The only
|
|
154
|
+
* invocation it may offer is one it says out loud to run elsewhere.
|
|
155
|
+
*/
|
|
156
|
+
export declare function missingAppIdMessage(name: string, configPath?: string): string;
|
|
157
|
+
export interface CoreProjectConfig {
|
|
158
|
+
version: number;
|
|
159
|
+
defaultEnvironment?: string;
|
|
160
|
+
environments: Record<string, CoreEnvironmentEntry>;
|
|
161
|
+
}
|
|
162
|
+
/** Which precedence step picked the environment. Printed in the build banner. */
|
|
163
|
+
export type PrimitiveEnvSource = "explicit" | "env-var" | "local" | "default" | "sole";
|
|
164
|
+
export interface ResolvedPrimitiveEnv {
|
|
165
|
+
name: string;
|
|
166
|
+
apiUrl: string;
|
|
167
|
+
/** Derived from apiUrl by scheme swap — never authored separately. */
|
|
168
|
+
wsUrl: string;
|
|
169
|
+
/** The app this environment names. Always present — see #3152. */
|
|
170
|
+
appId: string;
|
|
171
|
+
appName?: string;
|
|
172
|
+
/** The app's web counterpart for the SELECTED environment, if it has one. */
|
|
173
|
+
webUrl?: string;
|
|
174
|
+
description?: string;
|
|
175
|
+
source: PrimitiveEnvSource;
|
|
176
|
+
configPath: string;
|
|
177
|
+
localStatePath: string;
|
|
178
|
+
projectRoot: string;
|
|
179
|
+
}
|
|
180
|
+
export interface ResolveOptions {
|
|
181
|
+
/** Directory to start the upward walk from. Defaults to process.cwd(). */
|
|
182
|
+
cwd?: string;
|
|
183
|
+
/** Environment variables to read. Defaults to process.env. */
|
|
184
|
+
env?: Record<string, string | undefined>;
|
|
185
|
+
/** An explicit `--env` / `--primitive-env` value, if the caller has one. */
|
|
186
|
+
explicitEnvName?: string | null;
|
|
187
|
+
/** Use this config file instead of discovering one. */
|
|
188
|
+
configPath?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Derives the WebSocket URL from the API URL. Every apiUrl/wsUrl pair in
|
|
192
|
+
* practice is the same host with the scheme swapped, so it is derived rather
|
|
193
|
+
* than authored — one less thing to get out of sync.
|
|
194
|
+
*/
|
|
195
|
+
export declare function deriveWsUrl(apiUrl: string): string;
|
|
196
|
+
/**
|
|
197
|
+
* Finds `primitive/config.json` by walking up from `cwd`, or returns the
|
|
198
|
+
* PRIMITIVE_PROJECT_CONFIG override when it is set (and exists).
|
|
199
|
+
*
|
|
200
|
+
* The override is checked for provenance BEFORE the file is read (#3153, F2):
|
|
201
|
+
* it bypasses the walk, so without this an old-layout config could be handed
|
|
202
|
+
* straight to a reader and defeat the cutover. An override that points inside
|
|
203
|
+
* a `.primitive/` directory IS the old layout, named explicitly.
|
|
204
|
+
*
|
|
205
|
+
* This is the one function every reader goes through — `resolvePrimitiveEnv`
|
|
206
|
+
* and the CLI's own `loadProjectConfig`/`findProjectRoot` alike — so the
|
|
207
|
+
* unmigrated-project refusal lives HERE, in the walk, or the commands that
|
|
208
|
+
* never call `resolvePrimitiveEnv` would walk past the old anchor into the
|
|
209
|
+
* parent directory's project.
|
|
210
|
+
*/
|
|
211
|
+
export declare function findPrimitiveConfigPath(options?: {
|
|
212
|
+
cwd?: string;
|
|
213
|
+
env?: Record<string, string | undefined>;
|
|
214
|
+
}): string | null;
|
|
215
|
+
/**
|
|
216
|
+
* The project root for a config path: the parent of `primitive/`, or the
|
|
217
|
+
* containing directory when the config was pointed at directly (a fixture via
|
|
218
|
+
* PRIMITIVE_PROJECT_CONFIG, which is not inside a `primitive/` directory).
|
|
219
|
+
*/
|
|
220
|
+
export declare function projectRootForConfigPath(configPath: string): string;
|
|
221
|
+
/**
|
|
222
|
+
* Machine-local state lives under the project root's `.primitive/`, not beside
|
|
223
|
+
* the config — the config is committed now, and the two must not share a
|
|
224
|
+
* directory. A fixture-pointed bare config still gets its own `.primitive/`
|
|
225
|
+
* in its own directory, so it never picks up a real project's selection.
|
|
226
|
+
*/
|
|
227
|
+
export declare function localStatePathForConfigPath(configPath: string): string;
|
|
228
|
+
/**
|
|
229
|
+
* Reads and structurally validates `primitive/config.json`. Throws rather
|
|
230
|
+
* than guessing: a config that cannot be understood is always louder than a
|
|
231
|
+
* silent fallback to the wrong backend.
|
|
232
|
+
*/
|
|
233
|
+
export declare function readCoreProjectConfig(configPath: string): CoreProjectConfig;
|
|
234
|
+
/**
|
|
235
|
+
* Reads this machine's selection from `.primitive/local.json`. Returns null
|
|
236
|
+
* when there is no file or no selection in it; throws when the file exists but
|
|
237
|
+
* cannot be read as the shape `primitive env use` writes.
|
|
238
|
+
*/
|
|
239
|
+
export declare function readLocalSelection(configPath: string): string | null;
|
|
240
|
+
/**
|
|
241
|
+
* Applies the precedence to an already-loaded config. Exposed separately so
|
|
242
|
+
* the CLI wrapper can run its own field-level validation first and still share
|
|
243
|
+
* one ordering with every other reader.
|
|
244
|
+
*/
|
|
245
|
+
export declare function selectEnvironmentName(config: CoreProjectConfig, options: {
|
|
246
|
+
explicitEnvName?: string | null;
|
|
247
|
+
envVarName?: string | null;
|
|
248
|
+
localSelection?: string | null;
|
|
249
|
+
configPath?: string;
|
|
250
|
+
}): {
|
|
251
|
+
name: string;
|
|
252
|
+
source: PrimitiveEnvSource;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* The whole algorithm end to end: discover the config, read the selection,
|
|
256
|
+
* apply the precedence, derive the WebSocket URL.
|
|
257
|
+
*/
|
|
258
|
+
export declare function resolvePrimitiveEnv(options?: ResolveOptions): ResolvedPrimitiveEnv;
|