primitive-admin 1.2.0-alpha.14 → 1.2.0-alpha.16
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 +181 -73
- package/assets/skill/skills/primitive-platform/SKILL.md +87 -23
- package/dist/bin/primitive.js +11 -82
- 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.js +2 -0
- package/dist/src/commands/agent-sessions.js.map +1 -1
- package/dist/src/commands/analytics.js +181 -12
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps-children.js +2 -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 +11 -0
- package/dist/src/commands/apps.js +65 -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 +16 -1
- 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 +2 -0
- 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 +1 -1
- package/dist/src/commands/config.js +42 -9
- 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.js +2 -0
- package/dist/src/commands/db3-types.js.map +1 -1
- package/dist/src/commands/db3.d.ts +12 -0
- package/dist/src/commands/db3.js +408 -31
- package/dist/src/commands/db3.js.map +1 -1
- package/dist/src/commands/documents.d.ts +52 -12
- package/dist/src/commands/documents.js +120 -29
- 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 +2 -0
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/functions.js +90 -11
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/groups.js +20 -3
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.js +2 -0
- 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 +9 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +82 -47
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/locks.js +2 -0
- package/dist/src/commands/locks.js.map +1 -1
- package/dist/src/commands/metadata-category-configs.js +2 -0
- 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 -47
- 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.js +2 -0
- 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/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 +344 -14
- package/dist/src/commands/sync.js +1834 -345
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.js +2 -0
- 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 +878 -16
- 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/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 +1354 -97
- package/dist/src/lib/api-client.js +513 -164
- 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-flow.d.ts +33 -0
- package/dist/src/lib/auth-flow.js +404 -13
- package/dist/src/lib/auth-flow.js.map +1 -1
- package/dist/src/lib/block-selector.d.ts +9 -15
- package/dist/src/lib/block-selector.js +9 -20
- package/dist/src/lib/block-selector.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/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 +6 -0
- package/dist/src/lib/config-object-descriptor.js +71 -1
- package/dist/src/lib/config-object-descriptor.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/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 +18 -1
- package/dist/src/lib/db-codegen/dbTypeIR.js +14 -5
- 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 +51 -14
- package/dist/src/lib/db3-export.js +136 -28
- package/dist/src/lib/db3-export.js.map +1 -1
- package/dist/src/lib/db3-index-output.d.ts +92 -4
- package/dist/src/lib/db3-index-output.js +183 -11
- package/dist/src/lib/db3-index-output.js.map +1 -1
- package/dist/src/lib/db3-type-models.d.ts +49 -7
- package/dist/src/lib/db3-type-models.js +159 -28
- package/dist/src/lib/db3-type-models.js.map +1 -1
- package/dist/src/lib/deprecation.d.ts +2 -2
- package/dist/src/lib/deprecation.js +2 -2
- 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 +1 -1
- package/dist/src/lib/function-authorize-check.js +2 -1
- package/dist/src/lib/function-authorize-check.js.map +1 -1
- package/dist/src/lib/function-authorize-view.d.ts +12 -0
- package/dist/src/lib/function-authorize-view.js +38 -0
- package/dist/src/lib/function-authorize-view.js.map +1 -1
- package/dist/src/lib/function-bundle.d.ts +27 -5
- package/dist/src/lib/function-bundle.js +106 -7
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +15 -0
- package/dist/src/lib/function-collect.js +73 -14
- package/dist/src/lib/function-collect.js.map +1 -1
- package/dist/src/lib/function-db-types.d.ts +63 -40
- package/dist/src/lib/function-db-types.js +289 -293
- 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 +24 -1
- package/dist/src/lib/function-lint.js +123 -1
- package/dist/src/lib/function-lint.js.map +1 -1
- package/dist/src/lib/function-run.d.ts +1 -1
- package/dist/src/lib/function-run.js +1 -1
- package/dist/src/lib/function-run.js.map +1 -1
- package/dist/src/lib/function-schema-codegen.d.ts +85 -21
- package/dist/src/lib/function-schema-codegen.js +191 -85
- 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 +38 -4
- package/dist/src/lib/function-sync.js +91 -14
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/function-typecheck.d.ts +52 -0
- package/dist/src/lib/function-typecheck.js +171 -54
- package/dist/src/lib/function-typecheck.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 +239 -14
- package/dist/src/lib/generated-config-surfaces.js +670 -85
- 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/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/log-inspection.d.ts +4 -1
- package/dist/src/lib/log-inspection.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/output.d.ts +1 -1
- package/dist/src/lib/output.js +1 -1
- 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/prompt-schema-codegen.d.ts +36 -12
- package/dist/src/lib/prompt-schema-codegen.js +94 -98
- 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 +12 -2
- package/dist/src/lib/records-verbs.js +7 -2
- package/dist/src/lib/records-verbs.js.map +1 -1
- 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/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 +129 -0
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +154 -1
- package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -1
- 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/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 +40 -13
- package/dist/src/lib/schema-codegen/schemaToTs.js +124 -160
- package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -1
- 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/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 +24 -22
- 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 +168 -50
- package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +31 -7
- package/dist/src/lib/swift-codegen/schemaToSwift.js +213 -177
- 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/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 +37 -5
- package/dist/src/lib/sync-resource-types.js +50 -5
- 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/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/toml-database-config.d.ts +2 -1
- package/dist/src/lib/toml-database-config.js +7 -4
- 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/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 +13 -34
- package/package.json +5 -3
|
@@ -19,22 +19,25 @@
|
|
|
19
19
|
*
|
|
20
20
|
* - `primitive-db-types.d.ts` — the app's database types, and the module
|
|
21
21
|
* augmentation that binds them to `ctx.db`;
|
|
22
|
-
* - `primitive-db3-types.d.ts` (#4803) — the app's db3 types, from
|
|
23
|
-
* `db3-types/` and `database-type-configs/`, and the `Db3Schemas`
|
|
24
|
-
* augmentation that types `ctx.db3(db3Id, "<type>").model("<Model>")`;
|
|
25
22
|
* - `primitive-functions.d.ts` — the SDK's own types. The package is not on
|
|
26
23
|
* npm yet, and even when it is, a config tree is not an npm project:
|
|
27
24
|
* without this the bare `primitive-functions` specifier every function
|
|
28
25
|
* imports would not resolve at all, and the augmentation would have
|
|
29
26
|
* nothing to augment;
|
|
30
|
-
* - `primitive
|
|
31
|
-
* `function
|
|
32
|
-
*
|
|
33
|
-
*
|
|
27
|
+
* - `primitive.d.ts` (#5544, rendered by `primitive-declaration.ts`) —
|
|
28
|
+
* every `schemas/` def, function, prompt, db3 model and user property
|
|
29
|
+
* type under one namespace per family, and the augmentations that type
|
|
30
|
+
* `defineFunction`, `ctx.prompts.run`, `ctx.db3` and `ctx.users`. It
|
|
31
|
+
* replaced four per-family files (`RETIRED_DECLARATIONS`), which are
|
|
32
|
+
* removed;
|
|
34
33
|
* - `primitive-document-types.d.ts` (#3281, rendered by
|
|
35
34
|
* `function-document-types.ts`) — the project's document models from
|
|
36
35
|
* `models/models.toml`, and the `DocumentSchemas` augmentation that types
|
|
37
|
-
* `ctx.doc(documentId).model("<Model>")`;
|
|
36
|
+
* `ctx.doc(documentId).model("<Model>")`; not written when the project has
|
|
37
|
+
* none (#5206), and dropped from an explicit tsconfig `files` list then.
|
|
38
|
+
* #5208 — inside a project it is typed from `models/models.toml` only,
|
|
39
|
+
* and the generated schema copy a pull or push once wrote beside it is
|
|
40
|
+
* removed (`plannedRemovals`);
|
|
38
41
|
* - `generated/<key>.generated.ts` (#3281, same renderer) — the per-key
|
|
39
42
|
* CLIENT invoker, carrying every verb since #3482. Excluded from
|
|
40
43
|
* the scaffolded program (it imports `js-bao-wss-client`), and written to
|
|
@@ -58,18 +61,19 @@
|
|
|
58
61
|
*/
|
|
59
62
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, } from "fs";
|
|
60
63
|
import { basename, dirname, join, relative, resolve, sep } from "path";
|
|
61
|
-
import { parseConfigToml
|
|
62
|
-
import {
|
|
63
|
-
import { FUNCTION_INVOKERS_DIR, FUNCTION_TYPES_DECLARATION_FILE, GENERATED_FILE_SUFFIX, functionSchemaSources, renderFunctionInvokers, renderFunctionSchemasDeclaration, } from "./function-schema-codegen.js";
|
|
64
|
+
import { parseConfigToml } from "./config-toml.js";
|
|
65
|
+
import { FUNCTION_INVOKERS_DIR, FunctionSchemaCodegenError, GENERATED_FILE_SUFFIX, functionSchemaSources, } from "./function-schema-codegen.js";
|
|
64
66
|
import { DOCUMENT_TYPES_DECLARATION_FILE, DOCUMENT_SCHEMA_TREE_FILE, resolveDocumentSchema, renderDocumentTypesDeclaration, } from "./function-document-types.js";
|
|
65
|
-
import { AGENT_CLIENT_FILE_SUFFIX,
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
67
|
+
import { AGENT_CLIENT_FILE_SUFFIX, promptSchemaSources, renderAgentClientFiles, } from "./prompt-schema-codegen.js";
|
|
68
|
+
import { typeEntries } from "./db-type-records.js";
|
|
69
|
+
import { primitiveDeclarationInputs, renderPrimitiveDeclaration } from "./primitive-declaration.js";
|
|
70
|
+
import { renderFunctionInvokerSet } from "./invoker-shared-enums.js";
|
|
71
|
+
import { PRIMITIVE_DECLARATION_FILE, PRIMITIVE_DECLARATION_SPECIFIER, RETIRED_DECLARATIONS, } from "./primitive-declaration-names.js";
|
|
69
72
|
import { SDK_TYPES_SOURCE } from "./generated-sdk-types.js";
|
|
73
|
+
import { USER_PROPERTIES_CLIENT_FILE, USER_PROPERTIES_FILE, renderUserPropertiesClientTypes, treeHasUserProperties, userPropertiesSource, } from "./user-properties/user-properties-codegen.js";
|
|
74
|
+
export { db3TypeSources } from "./db-type-records.js";
|
|
75
|
+
export { PRIMITIVE_DECLARATION_FILE, RETIRED_DECLARATIONS } from "./primitive-declaration-names.js";
|
|
70
76
|
export const DB_TYPES_DECLARATION_FILE = "primitive-db-types.d.ts";
|
|
71
|
-
/** #4803 — the db3 types' declaration, binding `ctx.db3`. */
|
|
72
|
-
export const DB3_TYPES_DECLARATION_FILE = "primitive-db3-types.d.ts";
|
|
73
77
|
export const SDK_TYPES_FILE = "primitive-functions.d.ts";
|
|
74
78
|
export const FUNCTIONS_TSCONFIG_FILE = "tsconfig.json";
|
|
75
79
|
/**
|
|
@@ -82,14 +86,12 @@ export const FUNCTIONS_TSCONFIG_FILE = "tsconfig.json";
|
|
|
82
86
|
export const REGENERATED_DECLARATIONS = [
|
|
83
87
|
DB_TYPES_DECLARATION_FILE,
|
|
84
88
|
SDK_TYPES_FILE,
|
|
85
|
-
|
|
89
|
+
// #5544 — every function, prompt, schemas/ def, db3 and user property type.
|
|
90
|
+
PRIMITIVE_DECLARATION_FILE,
|
|
86
91
|
DOCUMENT_TYPES_DECLARATION_FILE,
|
|
87
|
-
// #3330 — the prompt output types, from the tree's `prompts/*.toml`.
|
|
88
|
-
PROMPT_TYPES_DECLARATION_FILE,
|
|
89
|
-
// #4803 — `ctx.db3`'s model types, from `db3-types/` and
|
|
90
|
-
// `database-type-configs/`.
|
|
91
|
-
DB3_TYPES_DECLARATION_FILE,
|
|
92
92
|
];
|
|
93
|
+
/** Every declaration codegen ever writes or once wrote. */
|
|
94
|
+
const ALL_DECLARATIONS = [...REGENERATED_DECLARATIONS, ...RETIRED_DECLARATIONS.map((retired) => retired.file)];
|
|
93
95
|
/** The scaffold's exclusion for the client invokers (#3281). */
|
|
94
96
|
export const GENERATED_EXCLUDE = `${FUNCTION_INVOKERS_DIR}/**`;
|
|
95
97
|
const HEADER = `// GENERATED by \`primitive config push\` from database-type-configs/*.toml.
|
|
@@ -103,31 +105,6 @@ const HEADER = `// GENERATED by \`primitive config push\` from database-type-con
|
|
|
103
105
|
// platform owns rather than the schema, added by the SDK's own row type, so it
|
|
104
106
|
// is not repeated per model here whether or not a model declares one.
|
|
105
107
|
`;
|
|
106
|
-
function quote(value) {
|
|
107
|
-
return JSON.stringify(value);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* A model or field name as a TYPE member key.
|
|
111
|
-
*
|
|
112
|
-
* Model and field names are whatever the TOML says — js-bao preserves them
|
|
113
|
-
* verbatim — so `Order-Item` and `first-name` are ordinary schemas and are not
|
|
114
|
-
* TypeScript identifiers. Emitting one raw makes the whole declaration a syntax
|
|
115
|
-
* error, which breaks the editor and `tsc` wiring for every OTHER type in the
|
|
116
|
-
* tree too. The client generators' own `objectPropertyKey` answers this,
|
|
117
|
-
* except that its `__proto__` case is a computed key — legal in an object
|
|
118
|
-
* literal, not in a type member — so that one is quoted instead.
|
|
119
|
-
*/
|
|
120
|
-
function memberKey(name) {
|
|
121
|
-
const key = objectPropertyKey(name);
|
|
122
|
-
return key.startsWith("[") ? quote(name) : key;
|
|
123
|
-
}
|
|
124
|
-
/** A TS string-literal union, or `string` when there is nothing to narrow to. */
|
|
125
|
-
function fieldType(type, enumValues) {
|
|
126
|
-
if (type === "string" && Array.isArray(enumValues) && enumValues.length > 0) {
|
|
127
|
-
return enumValues.map((v) => quote(v)).join(" | ");
|
|
128
|
-
}
|
|
129
|
-
return tsTypeForDbFieldType(type);
|
|
130
|
-
}
|
|
131
108
|
/**
|
|
132
109
|
* The declaration for a whole config tree's database types.
|
|
133
110
|
*
|
|
@@ -158,129 +135,13 @@ export function renderDbTypesDeclaration(sources) {
|
|
|
158
135
|
return lines.join("\n");
|
|
159
136
|
}
|
|
160
137
|
/**
|
|
161
|
-
*
|
|
162
|
-
* models and their fields as `describeDbType` reads them. Shared by the
|
|
163
|
-
* database declaration and the db3 one (#4803), so the two can never disagree
|
|
164
|
-
* on what a type's TOML declares.
|
|
138
|
+
* The scaffolded compiler wiring. Written once; an author owns it after.
|
|
165
139
|
*
|
|
166
|
-
* `
|
|
167
|
-
*
|
|
168
|
-
* one makes them required on every model in the timestamps' scope, because a
|
|
169
|
-
* db3 room writes them on every create and write there — epoch milliseconds,
|
|
170
|
-
* so `number` unless the model declares the field.
|
|
171
|
-
*/
|
|
172
|
-
function typeEntries(types, timestamps) {
|
|
173
|
-
const lines = [];
|
|
174
|
-
for (const source of types) {
|
|
175
|
-
let records = [];
|
|
176
|
-
try {
|
|
177
|
-
const ir = describeDbType({
|
|
178
|
-
databaseType: source.key,
|
|
179
|
-
tomlPath: source.tomlPath,
|
|
180
|
-
tomlContent: source.tomlContent,
|
|
181
|
-
table: source.table,
|
|
182
|
-
});
|
|
183
|
-
records = [...ir.records]
|
|
184
|
-
.sort((a, b) => (a.modelName < b.modelName ? -1 : 1))
|
|
185
|
-
.map((record) => {
|
|
186
|
-
const required = requiredStamps(ir.timestamps, record.modelName, timestamps);
|
|
187
|
-
const declared = new Set();
|
|
188
|
-
const members = [];
|
|
189
|
-
for (const field of record.fields) {
|
|
190
|
-
declared.add(field.name);
|
|
191
|
-
members.push(` ${memberKey(field.name)}${field.required || required.has(field.name) ? "" : "?"}: ${fieldType(field.type, field.enum)};`);
|
|
192
|
-
}
|
|
193
|
-
// Server-stamped fields exist on a read row but not on one a
|
|
194
|
-
// function just built, so they are optional — the same call the
|
|
195
|
-
// client renderer makes — except a db3 type's timestamps, which
|
|
196
|
-
// every row in scope carries. Writes take the SDK's write type,
|
|
197
|
-
// which leaves every field optional.
|
|
198
|
-
for (const stamped of [...ir.stampedFields].sort()) {
|
|
199
|
-
if (declared.has(stamped))
|
|
200
|
-
continue;
|
|
201
|
-
declared.add(stamped);
|
|
202
|
-
members.push(required.has(stamped)
|
|
203
|
-
? ` ${memberKey(stamped)}: number;`
|
|
204
|
-
: ` ${memberKey(stamped)}?: string;`);
|
|
205
|
-
}
|
|
206
|
-
return { modelName: record.modelName, members };
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
catch {
|
|
210
|
-
// A type whose TOML this renderer cannot describe contributes no models
|
|
211
|
-
// rather than failing the push: its own preflight reports the file, and
|
|
212
|
-
// an untyped handle is what a schemaless type gets anyway.
|
|
213
|
-
records = [];
|
|
214
|
-
}
|
|
215
|
-
if (records.length === 0) {
|
|
216
|
-
lines.push(` ${quote(source.key)}: {};`);
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
lines.push(` ${quote(source.key)}: {`);
|
|
220
|
-
for (const record of records) {
|
|
221
|
-
if (record.members.length === 0) {
|
|
222
|
-
lines.push(` ${memberKey(record.modelName)}: Record<string, unknown>;`);
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
lines.push(` ${memberKey(record.modelName)}: {`);
|
|
226
|
-
lines.push(...record.members);
|
|
227
|
-
lines.push(` };`);
|
|
228
|
-
}
|
|
229
|
-
lines.push(` };`);
|
|
230
|
-
}
|
|
231
|
-
return lines;
|
|
232
|
-
}
|
|
233
|
-
/** The stamp names a model's read rows always carry under this rendering. */
|
|
234
|
-
function requiredStamps(stamps, modelName, timestamps) {
|
|
235
|
-
if (timestamps === "optional")
|
|
236
|
-
return new Set();
|
|
237
|
-
if (stamps.models !== null && !stamps.models.includes(modelName))
|
|
238
|
-
return new Set();
|
|
239
|
-
return new Set([stamps.create, stamps.update].filter((name) => name !== null));
|
|
240
|
-
}
|
|
241
|
-
const DB3_HEADER = `// GENERATED by \`primitive config push\` from db3-types/*.toml and
|
|
242
|
-
// database-type-configs/*.toml. DO NOT EDIT — your changes are overwritten on
|
|
243
|
-
// the next push.
|
|
244
|
-
//
|
|
245
|
-
// It gives \`ctx.db3(db3Id, "<type>").model("<Model>")\` the model names and
|
|
246
|
-
// field types this app's db3 types declare. The two directories are one
|
|
247
|
-
// namespace: a name both hold is read from its db3-types/ file.
|
|
248
|
-
//
|
|
249
|
-
// A row a READ hands back also carries \`id: string\` — the record identity the
|
|
250
|
-
// platform owns rather than the schema, added by the SDK's own row type.
|
|
251
|
-
//
|
|
252
|
-
// A type's timestamps are required on a read row, epoch milliseconds unless the
|
|
253
|
-
// model declares the field: the room stamps every write. A row written
|
|
254
|
-
// before the db3 was typed may lack them.
|
|
255
|
-
`;
|
|
256
|
-
/**
|
|
257
|
-
* The declaration for a whole config tree's db3 types (#4803), rendered over
|
|
258
|
-
* the same `describeDbType` IR the database declaration is, and sorted the
|
|
259
|
-
* same way so the bytes depend on the schemas alone.
|
|
140
|
+
* `absent` names the regenerated declarations the tree does not get, which
|
|
141
|
+
* the scaffold leaves out of `include` (#5898).
|
|
260
142
|
*/
|
|
261
|
-
export function
|
|
262
|
-
const
|
|
263
|
-
const lines = [DB3_HEADER, "export interface PrimitiveDb3Schemas {"];
|
|
264
|
-
lines.push(...typeEntries(types.map((source) => ({
|
|
265
|
-
key: source.type,
|
|
266
|
-
tomlPath: source.tomlPath,
|
|
267
|
-
tomlContent: source.tomlContent,
|
|
268
|
-
table: source.directory === "db3-types" ? "db3" : "database",
|
|
269
|
-
})), "required"));
|
|
270
|
-
lines.push("}");
|
|
271
|
-
lines.push("");
|
|
272
|
-
// Only when there is something to bind, as for the database declaration:
|
|
273
|
-
// an empty augmentation would close `ctx.db3`'s type key to nothing.
|
|
274
|
-
if (types.length > 0) {
|
|
275
|
-
lines.push(`declare module "primitive-functions" {`);
|
|
276
|
-
lines.push(` interface Db3Schemas extends PrimitiveDb3Schemas {}`);
|
|
277
|
-
lines.push(`}`);
|
|
278
|
-
lines.push("");
|
|
279
|
-
}
|
|
280
|
-
return lines.join("\n");
|
|
281
|
-
}
|
|
282
|
-
/** The scaffolded compiler wiring. Written once; an author owns it after. */
|
|
283
|
-
export function renderFunctionsTsconfig() {
|
|
143
|
+
export function renderFunctionsTsconfig(absent = []) {
|
|
144
|
+
const declarations = REGENERATED_DECLARATIONS.filter((file) => !absent.includes(file));
|
|
284
145
|
return (JSON.stringify({
|
|
285
146
|
// Scaffolded by `primitive config push` (#3182). Yours to adjust — push
|
|
286
147
|
// writes it once and then leaves it alone. What it must keep doing is
|
|
@@ -307,7 +168,7 @@ export function renderFunctionsTsconfig() {
|
|
|
307
168
|
"primitive-functions": [`./${SDK_TYPES_FILE}`],
|
|
308
169
|
},
|
|
309
170
|
},
|
|
310
|
-
include: ["**/*.ts", ...
|
|
171
|
+
include: ["**/*.ts", ...declarations.map((file) => `./${file}`)],
|
|
311
172
|
// The client invokers (#3281) import `js-bao-wss-client`, which a
|
|
312
173
|
// config tree does not install: they are for the app's client code,
|
|
313
174
|
// and an editor program that swept them in would report every one of
|
|
@@ -391,6 +252,10 @@ function isGlobEntry(entry) {
|
|
|
391
252
|
function isDeclarationEntry(entry, file) {
|
|
392
253
|
return entry === `./${file}` || entry === file;
|
|
393
254
|
}
|
|
255
|
+
/** The retired declaration an entry names (#5544), or null. */
|
|
256
|
+
function retiredEntryOf(entry) {
|
|
257
|
+
return RETIRED_DECLARATIONS.find((retired) => isDeclarationEntry(entry, retired.file)) ?? null;
|
|
258
|
+
}
|
|
394
259
|
/** `"./**\/*.ts"` and `"**\/*.ts"` name the same set; read them the same way. */
|
|
395
260
|
function normalizeEntry(entry) {
|
|
396
261
|
return entry.startsWith("./") ? entry.slice(2) : entry;
|
|
@@ -437,7 +302,7 @@ function coversSubdirectories(entry) {
|
|
|
437
302
|
function isSourceEntry(entry) {
|
|
438
303
|
if (typeof entry !== "string")
|
|
439
304
|
return false;
|
|
440
|
-
if (
|
|
305
|
+
if (ALL_DECLARATIONS.some((file) => isDeclarationEntry(entry, file))) {
|
|
441
306
|
return false;
|
|
442
307
|
}
|
|
443
308
|
return isGlobEntry(entry) || entry.endsWith(".ts");
|
|
@@ -485,11 +350,17 @@ function tsconfigWiringGaps(parsed, context) {
|
|
|
485
350
|
const declarationsCovered = listed.some(coversDeclarations);
|
|
486
351
|
const reachesSubdirectories = listed.some(coversSubdirectories);
|
|
487
352
|
const exclude = Array.isArray(parsed.exclude) ? parsed.exclude : [];
|
|
353
|
+
const absent = context.absentDeclarations ?? [];
|
|
488
354
|
return {
|
|
489
355
|
mapping: !mapped.includes(`./${SDK_TYPES_FILE}`),
|
|
490
356
|
missingDeclarations: implicitlyAll || declarationsCovered
|
|
491
357
|
? []
|
|
492
|
-
: REGENERATED_DECLARATIONS.filter((file) => !listed.some((entry) => isDeclarationEntry(entry, file))),
|
|
358
|
+
: REGENERATED_DECLARATIONS.filter((file) => !absent.includes(file) && !listed.some((entry) => isDeclarationEntry(entry, file))),
|
|
359
|
+
absentFiles: files.filter((entry) => typeof entry === "string" && absent.some((file) => isDeclarationEntry(entry, file))),
|
|
360
|
+
retiredEntries: [
|
|
361
|
+
...include.filter((entry) => retiredEntryOf(entry)).map((entry) => ({ list: "include", entry: entry })),
|
|
362
|
+
...files.filter((entry) => retiredEntryOf(entry)).map((entry) => ({ list: "files", entry: entry })),
|
|
363
|
+
],
|
|
493
364
|
sources: !implicitlyAll && !declarationsCovered && !listed.some(isSourceEntry),
|
|
494
365
|
// Only a program that would SEE the directory needs the exclusion: an
|
|
495
366
|
// explicit list that reaches no subdirectory never sweeps it in.
|
|
@@ -499,7 +370,12 @@ function tsconfigWiringGaps(parsed, context) {
|
|
|
499
370
|
};
|
|
500
371
|
}
|
|
501
372
|
function hasGaps(gaps) {
|
|
502
|
-
return (gaps.mapping ||
|
|
373
|
+
return (gaps.mapping ||
|
|
374
|
+
gaps.missingDeclarations.length > 0 ||
|
|
375
|
+
gaps.sources ||
|
|
376
|
+
gaps.generatedExclusion ||
|
|
377
|
+
gaps.absentFiles.length > 0 ||
|
|
378
|
+
gaps.retiredEntries.length > 0);
|
|
503
379
|
}
|
|
504
380
|
function describeGaps(gaps) {
|
|
505
381
|
const problems = [];
|
|
@@ -519,6 +395,17 @@ function describeGaps(gaps) {
|
|
|
519
395
|
problems.push(`\`exclude\` does not cover "${GENERATED_EXCLUDE}", so the generated client ` +
|
|
520
396
|
"invokers (which import `js-bao-wss-client`) are swept into the program");
|
|
521
397
|
}
|
|
398
|
+
if (gaps.absentFiles.length > 0) {
|
|
399
|
+
problems.push(`\`files\` names ${gaps.absentFiles
|
|
400
|
+
.map((entry) => `"${entry}"`)
|
|
401
|
+
.join(", ")}, which codegen no longer writes, so the compiler reports it missing`);
|
|
402
|
+
}
|
|
403
|
+
for (const { list, entry } of gaps.retiredEntries) {
|
|
404
|
+
const retired = retiredEntryOf(entry);
|
|
405
|
+
problems.push(`\`${list}\` names "${entry}", which codegen no longer writes: its types are in ` +
|
|
406
|
+
`"./${PRIMITIVE_DECLARATION_FILE}" under ${retired.namespace}, so remove the entry` +
|
|
407
|
+
(list === "files" ? ` and list "./${PRIMITIVE_DECLARATION_FILE}"` : ""));
|
|
408
|
+
}
|
|
522
409
|
return problems;
|
|
523
410
|
}
|
|
524
411
|
/**
|
|
@@ -544,7 +431,7 @@ function describeGaps(gaps) {
|
|
|
544
431
|
*/
|
|
545
432
|
export function inspectFunctionsTsconfig(existing, context = { generatedDirExists: false }) {
|
|
546
433
|
if (existing === null) {
|
|
547
|
-
return { repaired: renderFunctionsTsconfig(), problems: [] };
|
|
434
|
+
return { repaired: renderFunctionsTsconfig(context.absentDeclarations), problems: [] };
|
|
548
435
|
}
|
|
549
436
|
let parsed;
|
|
550
437
|
let plainJson = true;
|
|
@@ -594,6 +481,20 @@ export function inspectFunctionsTsconfig(existing, context = { generatedDirExist
|
|
|
594
481
|
: [];
|
|
595
482
|
paths[SDK_MODULE_SPECIFIER] = [...mapped, `./${SDK_TYPES_FILE}`];
|
|
596
483
|
}
|
|
484
|
+
if (gaps.retiredEntries.length > 0) {
|
|
485
|
+
// #5544 — a retired declaration's entry goes; its replacement comes back
|
|
486
|
+
// through the missing-declaration repair below, and a `files` list the
|
|
487
|
+
// removal empties goes with it, the sources then coming through `include`.
|
|
488
|
+
for (const list of ["include", "files"]) {
|
|
489
|
+
if (!Array.isArray(parsed[list]))
|
|
490
|
+
continue;
|
|
491
|
+
const kept = parsed[list].filter((entry) => !retiredEntryOf(entry));
|
|
492
|
+
if (list === "files" && kept.length === 0)
|
|
493
|
+
delete parsed.files;
|
|
494
|
+
else
|
|
495
|
+
parsed[list] = kept;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
597
498
|
if (gaps.missingDeclarations.length > 0 || gaps.sources) {
|
|
598
499
|
const include = Array.isArray(parsed.include) ? parsed.include : [];
|
|
599
500
|
const added = [];
|
|
@@ -613,6 +514,15 @@ export function inspectFunctionsTsconfig(existing, context = { generatedDirExist
|
|
|
613
514
|
const exclude = Array.isArray(parsed.exclude) ? parsed.exclude : [];
|
|
614
515
|
parsed.exclude = [...exclude, GENERATED_EXCLUDE];
|
|
615
516
|
}
|
|
517
|
+
if (gaps.absentFiles.length > 0 && Array.isArray(parsed.files)) {
|
|
518
|
+
// #5206 — a root that no longer exists is dropped; an emptied list goes
|
|
519
|
+
// with it, since the sources then come through `include`.
|
|
520
|
+
const files = parsed.files.filter((entry) => !gaps.absentFiles.includes(entry));
|
|
521
|
+
if (files.length > 0)
|
|
522
|
+
parsed.files = files;
|
|
523
|
+
else
|
|
524
|
+
delete parsed.files;
|
|
525
|
+
}
|
|
616
526
|
return { repaired: JSON.stringify(parsed, null, 2) + "\n", problems: [] };
|
|
617
527
|
}
|
|
618
528
|
/**
|
|
@@ -682,57 +592,6 @@ export function databaseTypeSources(configDir) {
|
|
|
682
592
|
}
|
|
683
593
|
return sources;
|
|
684
594
|
}
|
|
685
|
-
/**
|
|
686
|
-
* Every db3 type a config tree declares (#4803): `db3-types/*.toml` (named by
|
|
687
|
-
* `[type] name`, else the file name) and `database-type-configs/*.toml` (named
|
|
688
|
-
* by `[type] databaseType`, else the file name), one namespace with one entry
|
|
689
|
-
* per name. A `db3-types/` file naming models declared in another file of the
|
|
690
|
-
* directory (`[type] models`) is read with them, resolved (#5025). A name both
|
|
691
|
-
* directories hold is read from its `db3-types/` file:
|
|
692
|
-
* `config push` refuses a pair that differ before anything is written, so the
|
|
693
|
-
* two agree whenever this runs on a pushable tree.
|
|
694
|
-
*/
|
|
695
|
-
export function db3TypeSources(configDir) {
|
|
696
|
-
const byType = new Map();
|
|
697
|
-
// #5025 — a db3 type naming models declared in another file of its
|
|
698
|
-
// directory is typed with them: its content is the resolved document.
|
|
699
|
-
const resolved = resolveDb3TypeModels(join(configDir, "db3-types"));
|
|
700
|
-
const read = (directory, key) => {
|
|
701
|
-
const dir = join(configDir, directory);
|
|
702
|
-
if (!existsSync(dir))
|
|
703
|
-
return;
|
|
704
|
-
for (const file of readdirSync(dir).filter((f) => f.endsWith(".toml")).sort()) {
|
|
705
|
-
const tomlPath = join(dir, file);
|
|
706
|
-
let tomlContent;
|
|
707
|
-
try {
|
|
708
|
-
tomlContent = readFileSync(tomlPath, "utf-8");
|
|
709
|
-
}
|
|
710
|
-
catch {
|
|
711
|
-
continue;
|
|
712
|
-
}
|
|
713
|
-
let declared = null;
|
|
714
|
-
try {
|
|
715
|
-
const parsed = parseConfigToml(tomlContent);
|
|
716
|
-
if (parsed?.type?.[key])
|
|
717
|
-
declared = String(parsed.type[key]);
|
|
718
|
-
}
|
|
719
|
-
catch {
|
|
720
|
-
// Its own preflight reports a file that does not parse.
|
|
721
|
-
}
|
|
722
|
-
const type = declared || basename(file, ".toml");
|
|
723
|
-
if (directory === "db3-types" && resolved.referencing.has(file)) {
|
|
724
|
-
const document = resolved.documents.get(file);
|
|
725
|
-
if (document)
|
|
726
|
-
tomlContent = stringifyConfigToml(document);
|
|
727
|
-
}
|
|
728
|
-
if (!byType.has(type))
|
|
729
|
-
byType.set(type, { type, tomlPath, tomlContent, directory });
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
read("db3-types", "name");
|
|
733
|
-
read("database-type-configs", "databaseType");
|
|
734
|
-
return [...byType.values()];
|
|
735
|
-
}
|
|
736
595
|
/**
|
|
737
596
|
* Whether the tree has a `functions/` directory of its own — one holding
|
|
738
597
|
* anything besides the `generated/` directory codegen itself writes.
|
|
@@ -767,44 +626,74 @@ function planAgentClientArtifacts(configDir, options) {
|
|
|
767
626
|
};
|
|
768
627
|
});
|
|
769
628
|
}
|
|
629
|
+
/**
|
|
630
|
+
* The app's client types of `user-properties.toml` (#5385), where the
|
|
631
|
+
* invokers go: client code needs them whether or not the tree has functions.
|
|
632
|
+
*/
|
|
633
|
+
function planUserPropertiesClientArtifacts(configDir, options, userProperties) {
|
|
634
|
+
if (!userProperties)
|
|
635
|
+
return [];
|
|
636
|
+
const absolute = join(functionInvokerDir(configDir, options), USER_PROPERTIES_CLIENT_FILE);
|
|
637
|
+
return [
|
|
638
|
+
{
|
|
639
|
+
relative: reportedPath(configDir, absolute),
|
|
640
|
+
absolute,
|
|
641
|
+
contents: renderUserPropertiesClientTypes(userProperties),
|
|
642
|
+
regenerated: true,
|
|
643
|
+
source: USER_PROPERTIES_FILE,
|
|
644
|
+
},
|
|
645
|
+
];
|
|
646
|
+
}
|
|
770
647
|
/**
|
|
771
648
|
* What push would write, without writing it.
|
|
772
649
|
*
|
|
773
|
-
* Only the
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
* needs no compiler wiring.
|
|
650
|
+
* Only the client artifacts — the agents' (#3798, DSO-3798-005) and the user
|
|
651
|
+
* property types (#5385) — when the tree has no `functions/` directory, and
|
|
652
|
+
* nothing at all when it has none of them: the other artifacts exist to type
|
|
653
|
+
* function sources, and a tree with none needs no compiler wiring.
|
|
777
654
|
*/
|
|
778
655
|
export function planFunctionTypeArtifacts(configDir, sdkTypes, options = {}) {
|
|
779
656
|
const functionsDir = join(configDir, "functions");
|
|
780
657
|
const agentArtifacts = planAgentClientArtifacts(configDir, options);
|
|
781
|
-
if (!treeHasFunctionsDir(configDir))
|
|
782
|
-
|
|
783
|
-
|
|
658
|
+
if (!treeHasFunctionsDir(configDir)) {
|
|
659
|
+
const clientArtifacts = [
|
|
660
|
+
...planUserPropertiesClientArtifacts(configDir, options, userPropertiesSource(configDir)),
|
|
661
|
+
...agentArtifacts,
|
|
662
|
+
];
|
|
663
|
+
refuseSharedDestinations(clientArtifacts);
|
|
664
|
+
return clientArtifacts;
|
|
665
|
+
}
|
|
666
|
+
// #3455 — one resolution for the document declaration below.
|
|
784
667
|
const documentSchema = resolveDocumentSchema(configDir);
|
|
785
|
-
|
|
786
|
-
//
|
|
668
|
+
// #5898 — `ctx.db`'s declaration only for a tree with database types: with
|
|
669
|
+
// none it would be an empty interface, and the one an earlier run wrote goes
|
|
670
|
+
// (`retiredFunctionTypeArtifacts`). The handle stays open without it.
|
|
671
|
+
const databaseTypes = databaseTypeSources(configDir);
|
|
672
|
+
// #5544 — every function, prompt, schemas/ def, db3 and user property type
|
|
673
|
+
// in one declaration, and the per-key invokers from the same
|
|
787
674
|
// `functions/*.toml`. A malformed schema throws naming the file: the honest
|
|
788
675
|
// `unknown` is for an absent schema, and typing a broken one as anything
|
|
789
676
|
// would be a declaration that lies.
|
|
790
677
|
const functionSources = functionSchemaSources(configDir);
|
|
791
|
-
const
|
|
678
|
+
const primitiveDeclaration = renderPrimitiveDeclaration(primitiveDeclarationInputs(configDir));
|
|
792
679
|
const invokerDir = functionInvokerDir(configDir, options);
|
|
793
|
-
|
|
680
|
+
// #5896 — with the shared `schemas/` enums they use, declared once beside them.
|
|
681
|
+
const invokerSet = renderFunctionInvokerSet(configDir, functionSources);
|
|
682
|
+
const invokers = invokerSet.invokers;
|
|
683
|
+
// #5385 — the user property types, only for a tree that declares them. A
|
|
684
|
+
// file that does not parse throws naming it, like a malformed function schema.
|
|
685
|
+
const userProperties = userPropertiesSource(configDir);
|
|
794
686
|
const artifacts = [
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
contents: renderDb3TypesDeclaration(db3TypeSources(configDir)),
|
|
806
|
-
regenerated: true,
|
|
807
|
-
},
|
|
687
|
+
...(databaseTypes.length > 0
|
|
688
|
+
? [
|
|
689
|
+
{
|
|
690
|
+
relative: `functions/${DB_TYPES_DECLARATION_FILE}`,
|
|
691
|
+
absolute: join(functionsDir, DB_TYPES_DECLARATION_FILE),
|
|
692
|
+
contents: renderDbTypesDeclaration(databaseTypes),
|
|
693
|
+
regenerated: true,
|
|
694
|
+
},
|
|
695
|
+
]
|
|
696
|
+
: []),
|
|
808
697
|
{
|
|
809
698
|
relative: `functions/${SDK_TYPES_FILE}`,
|
|
810
699
|
absolute: join(functionsDir, SDK_TYPES_FILE),
|
|
@@ -812,50 +701,37 @@ export function planFunctionTypeArtifacts(configDir, sdkTypes, options = {}) {
|
|
|
812
701
|
regenerated: true,
|
|
813
702
|
},
|
|
814
703
|
{
|
|
815
|
-
relative: `functions/${
|
|
816
|
-
absolute: join(functionsDir,
|
|
817
|
-
contents:
|
|
704
|
+
relative: `functions/${PRIMITIVE_DECLARATION_FILE}`,
|
|
705
|
+
absolute: join(functionsDir, PRIMITIVE_DECLARATION_FILE),
|
|
706
|
+
contents: primitiveDeclaration,
|
|
818
707
|
regenerated: true,
|
|
819
708
|
},
|
|
820
709
|
// #3281 — the document handle's declaration, from the project's
|
|
821
|
-
// `models/models.toml
|
|
710
|
+
// `models/models.toml`.
|
|
822
711
|
//
|
|
823
712
|
// #3455 (D3455-009) — through the SAME resolution push and diff use, so a
|
|
824
713
|
// tree pulled into a project with no `models/models.toml` is typed from
|
|
825
714
|
// the schema its active version was pushed with rather than losing its
|
|
826
715
|
// types the moment it is pulled.
|
|
827
|
-
{
|
|
828
|
-
relative: `functions/${DOCUMENT_TYPES_DECLARATION_FILE}`,
|
|
829
|
-
absolute: join(functionsDir, DOCUMENT_TYPES_DECLARATION_FILE),
|
|
830
|
-
contents: renderDocumentTypesDeclaration(documentSchema.declarationSource),
|
|
831
|
-
regenerated: true,
|
|
832
|
-
},
|
|
833
|
-
// #3330 — `ctx.prompts.run`'s output types, from this tree's
|
|
834
|
-
// `prompts/*.toml` (open when the tree declares none).
|
|
835
|
-
{
|
|
836
|
-
relative: `functions/${PROMPT_TYPES_DECLARATION_FILE}`,
|
|
837
|
-
absolute: join(functionsDir, PROMPT_TYPES_DECLARATION_FILE),
|
|
838
|
-
contents: renderPromptSchemasDeclaration(promptSchemaSources(configDir)),
|
|
839
|
-
regenerated: true,
|
|
840
|
-
},
|
|
841
|
-
// #3455 (D3455-009) — the project's document schema, copied into the tree
|
|
842
|
-
// so a fresh `config pull` into a project that has no `models/models.toml`
|
|
843
|
-
// still rebuilds the same envelope and reads Synced.
|
|
844
716
|
//
|
|
845
|
-
//
|
|
846
|
-
//
|
|
847
|
-
// (
|
|
848
|
-
|
|
849
|
-
...(documentSchema.origin === "project" && documentSchema.source
|
|
717
|
+
// #5206 — none when no schema file resolves: an app with no documents
|
|
718
|
+
// gets no document declaration, and the one an earlier run wrote goes
|
|
719
|
+
// (`retiredFunctionTypeArtifacts`). The handle stays open without it.
|
|
720
|
+
...(documentSchema.declarationSource
|
|
850
721
|
? [
|
|
851
722
|
{
|
|
852
|
-
relative: `functions/${
|
|
853
|
-
absolute: join(functionsDir,
|
|
854
|
-
contents: documentSchema.
|
|
723
|
+
relative: `functions/${DOCUMENT_TYPES_DECLARATION_FILE}`,
|
|
724
|
+
absolute: join(functionsDir, DOCUMENT_TYPES_DECLARATION_FILE),
|
|
725
|
+
contents: renderDocumentTypesDeclaration(documentSchema.declarationSource),
|
|
855
726
|
regenerated: true,
|
|
856
727
|
},
|
|
857
728
|
]
|
|
858
729
|
: []),
|
|
730
|
+
// #5208 — the generated schema copy (D3455-009) is never planned: inside
|
|
731
|
+
// a project `models/models.toml` is the only document schema, so a copy
|
|
732
|
+
// there is a planned removal; outside one, a copy is itself the
|
|
733
|
+
// resolution (rule 2), and rewriting a file from itself would be a second
|
|
734
|
+
// source of truth.
|
|
859
735
|
...invokers.map((invoker) => {
|
|
860
736
|
const absolute = join(invokerDir, invoker.fileName);
|
|
861
737
|
return {
|
|
@@ -863,8 +739,25 @@ export function planFunctionTypeArtifacts(configDir, sdkTypes, options = {}) {
|
|
|
863
739
|
absolute,
|
|
864
740
|
contents: invoker.content,
|
|
865
741
|
regenerated: true,
|
|
742
|
+
source: `function ${invoker.fileName.slice(0, -GENERATED_FILE_SUFFIX.length)}`,
|
|
866
743
|
};
|
|
867
744
|
}),
|
|
745
|
+
// #5896 — after the invokers, so a function keyed `shared-enums` is the
|
|
746
|
+
// one a refusal names first.
|
|
747
|
+
...(invokerSet.sharedEnums
|
|
748
|
+
? [
|
|
749
|
+
{
|
|
750
|
+
relative: reportedPath(configDir, join(invokerDir, invokerSet.sharedEnums.fileName)),
|
|
751
|
+
absolute: join(invokerDir, invokerSet.sharedEnums.fileName),
|
|
752
|
+
contents: invokerSet.sharedEnums.content,
|
|
753
|
+
regenerated: true,
|
|
754
|
+
source: `the shared enums of ${invokerSet.sharedEnums.sources.join(", ")}`,
|
|
755
|
+
},
|
|
756
|
+
]
|
|
757
|
+
: []),
|
|
758
|
+
// #5385 — `UserProperties` and `ClientUserProperties` for the app's client
|
|
759
|
+
// code (beside the invokers); the functions' are in `primitive.d.ts`.
|
|
760
|
+
...planUserPropertiesClientArtifacts(configDir, options, userProperties),
|
|
868
761
|
// #3798 — each agent's client-side types, beside the invokers and owned
|
|
869
762
|
// by the same plan (so the orphan sweep keeps them while the agent does).
|
|
870
763
|
...agentArtifacts,
|
|
@@ -891,8 +784,27 @@ export function planFunctionTypeArtifacts(configDir, sdkTypes, options = {}) {
|
|
|
891
784
|
regenerated: false,
|
|
892
785
|
});
|
|
893
786
|
}
|
|
787
|
+
refuseSharedDestinations(artifacts);
|
|
894
788
|
return artifacts;
|
|
895
789
|
}
|
|
790
|
+
/**
|
|
791
|
+
* Refuse a plan in which two artifacts name one file (#5385): a function
|
|
792
|
+
* keyed `user-properties` writes its invoker where the user property client
|
|
793
|
+
* types go, and either would silently overwrite the other. Judged on the
|
|
794
|
+
* absolute paths, so a `-o` directory is judged as written.
|
|
795
|
+
*/
|
|
796
|
+
function refuseSharedDestinations(artifacts) {
|
|
797
|
+
const byPath = new Map();
|
|
798
|
+
for (const artifact of artifacts) {
|
|
799
|
+
const prior = byPath.get(artifact.absolute);
|
|
800
|
+
if (prior) {
|
|
801
|
+
throw new FunctionSchemaCodegenError(`${artifact.relative} would be generated twice — from ${prior.source ?? prior.relative} and from ` +
|
|
802
|
+
`${artifact.source ?? artifact.relative} — and one would overwrite the other. Rename the function ` +
|
|
803
|
+
"(its key names its generated file) so the two differ.");
|
|
804
|
+
}
|
|
805
|
+
byPath.set(artifact.absolute, artifact);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
896
808
|
/**
|
|
897
809
|
* The tsconfig wiring push could not repair, phrased for the author.
|
|
898
810
|
*
|
|
@@ -921,13 +833,21 @@ export function functionTypeWiringProblems(configDir, options = {}) {
|
|
|
921
833
|
/**
|
|
922
834
|
* What the inspection knows about the directory: whether `generated/` will
|
|
923
835
|
* exist beside the tsconfig once this plan is written (it exists now, or this
|
|
924
|
-
* plan writes an invoker into the default location)
|
|
836
|
+
* plan writes an invoker into the default location), and which declarations
|
|
837
|
+
* the plan leaves out (#5206, #5898).
|
|
925
838
|
*/
|
|
926
839
|
function tsconfigContext(configDir, options) {
|
|
927
840
|
const defaultDir = join(configDir, "functions", FUNCTION_INVOKERS_DIR);
|
|
841
|
+
const userProperties = treeHasUserProperties(configDir);
|
|
928
842
|
const writesThere = functionInvokerDir(configDir, options) === defaultDir &&
|
|
929
|
-
functionSchemaSources(configDir).length > 0;
|
|
930
|
-
return {
|
|
843
|
+
(functionSchemaSources(configDir).length > 0 || userProperties);
|
|
844
|
+
return {
|
|
845
|
+
generatedDirExists: existsSync(defaultDir) || writesThere,
|
|
846
|
+
absentDeclarations: [
|
|
847
|
+
...(databaseTypeSources(configDir).length > 0 ? [] : [DB_TYPES_DECLARATION_FILE]),
|
|
848
|
+
...(resolveDocumentSchema(configDir).declarationSource ? [] : [DOCUMENT_TYPES_DECLARATION_FILE]),
|
|
849
|
+
],
|
|
850
|
+
};
|
|
931
851
|
}
|
|
932
852
|
/**
|
|
933
853
|
* Invokers in the plan's directory that the plan no longer writes — a
|
|
@@ -941,20 +861,88 @@ function orphanedInvokers(configDir, planned, options) {
|
|
|
941
861
|
const keep = new Set(planned.map((a) => a.absolute));
|
|
942
862
|
// #3798 (CSO-3798-003) — with no `functions/` at all, an agent's client
|
|
943
863
|
// artifact is the only thing a run could have written here (an `-o`
|
|
944
|
-
// directory the functions run never owned before), so only those are swept
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
864
|
+
// directory the functions run never owned before), so only those are swept
|
|
865
|
+
// — and (#5385) the user property client types.
|
|
866
|
+
const owned = existsSync(join(configDir, "functions"))
|
|
867
|
+
? (f) => f.endsWith(GENERATED_FILE_SUFFIX)
|
|
868
|
+
: (f) => f.endsWith(AGENT_CLIENT_FILE_SUFFIX) || f === USER_PROPERTIES_CLIENT_FILE;
|
|
948
869
|
return readdirSync(dir)
|
|
949
|
-
.filter(
|
|
870
|
+
.filter(owned)
|
|
950
871
|
.map((f) => join(dir, f))
|
|
951
872
|
.filter((absolute) => !keep.has(absolute));
|
|
952
873
|
}
|
|
953
|
-
/**
|
|
954
|
-
|
|
874
|
+
/**
|
|
875
|
+
* Declarations a plan may leave out: the database declaration exists only
|
|
876
|
+
* while the tree has database types (#5898), and the document declaration
|
|
877
|
+
* only while a document schema resolves (#5206).
|
|
878
|
+
*/
|
|
879
|
+
const OPTIONAL_DECLARATIONS = [DB_TYPES_DECLARATION_FILE, DOCUMENT_TYPES_DECLARATION_FILE];
|
|
880
|
+
/**
|
|
881
|
+
* The generated files on disk that `planned` no longer writes: a database
|
|
882
|
+
* or document declaration an earlier run wrote, once the tree's database
|
|
883
|
+
* types (#5898) or document schema (#5206) are gone, the four declarations `primitive.d.ts` replaced (#5544), and,
|
|
884
|
+
* inside a project, the generated schema copy no resolution there reads
|
|
885
|
+
* (#5208).
|
|
886
|
+
*/
|
|
887
|
+
export function retiredFunctionTypeArtifacts(configDir, planned) {
|
|
888
|
+
if (!treeHasFunctionsDir(configDir))
|
|
889
|
+
return [];
|
|
890
|
+
const keep = new Set(planned.map((a) => a.absolute));
|
|
891
|
+
const staleCopy = resolveDocumentSchema(configDir).staleTreeCopy;
|
|
892
|
+
return [
|
|
893
|
+
...OPTIONAL_DECLARATIONS.map((file) => join(configDir, "functions", file)),
|
|
894
|
+
...RETIRED_DECLARATIONS.map((retired) => join(configDir, "functions", retired.file)),
|
|
895
|
+
...(staleCopy ? [staleCopy] : []),
|
|
896
|
+
].filter((absolute) => !keep.has(absolute) && existsSync(absolute));
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Every file a write of `planned` removes, as absolute paths (#5208): the
|
|
900
|
+
* invokers of removed functions, and the retired generated files. The one
|
|
901
|
+
* list the write, `--check`, the dry-run typechecker and the removal lines
|
|
902
|
+
* all read, so they cannot disagree about what goes.
|
|
903
|
+
*/
|
|
904
|
+
export function plannedRemovals(configDir, planned, options = {}) {
|
|
905
|
+
return [
|
|
906
|
+
...orphanedInvokers(configDir, planned, options),
|
|
907
|
+
...retiredFunctionTypeArtifacts(configDir, planned),
|
|
908
|
+
];
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* The line a command prints for a file a write removed (#5208), given its
|
|
912
|
+
* tree-relative path. The schema copy's names where the document schema
|
|
913
|
+
* lives and how to get it back; it never sends the author to the copy.
|
|
914
|
+
*/
|
|
915
|
+
export function functionTypeRemovalLine(relative) {
|
|
916
|
+
if (relative.endsWith(`/${DOCUMENT_SCHEMA_TREE_FILE}`)) {
|
|
917
|
+
return (`Removed ${relative}: inside a project the document schema is models/models.toml, and this ` +
|
|
918
|
+
"generated file is no longer read. To keep the schema, restore models/models.toml from version " +
|
|
919
|
+
"control (the generated file was committed beside your functions); the running version keeps " +
|
|
920
|
+
"the schema until a push without it.");
|
|
921
|
+
}
|
|
922
|
+
if (relative.endsWith(`/${DOCUMENT_TYPES_DECLARATION_FILE}`)) {
|
|
923
|
+
return `Removed ${relative}: no document schema resolves, so ctx.doc's models are untyped.`;
|
|
924
|
+
}
|
|
925
|
+
if (relative.endsWith(`/${DB_TYPES_DECLARATION_FILE}`)) {
|
|
926
|
+
return `Removed ${relative}: the tree has no database-type-configs/*.toml, so ctx.db's models are untyped.`;
|
|
927
|
+
}
|
|
928
|
+
// #5544 — a declaration `primitive.d.ts` replaced names where its types went.
|
|
929
|
+
const retired = RETIRED_DECLARATIONS.find((entry) => relative.endsWith(`/${entry.file}`));
|
|
930
|
+
if (retired) {
|
|
931
|
+
return (`Removed ${relative}: its types are in functions/${PRIMITIVE_DECLARATION_FILE} under ${retired.namespace}; ` +
|
|
932
|
+
`import type { ${retired.namespace} } from "${PRIMITIVE_DECLARATION_SPECIFIER}".`);
|
|
933
|
+
}
|
|
934
|
+
// #5385 — the user property client types go with user-properties.toml.
|
|
935
|
+
if (relative.endsWith(`/${USER_PROPERTIES_CLIENT_FILE}`)) {
|
|
936
|
+
return `Removed ${relative}: the tree has no ${USER_PROPERTIES_FILE}, so UserProperties declares no field.`;
|
|
937
|
+
}
|
|
938
|
+
return `Removed ${relative}: no function declares it any more.`;
|
|
939
|
+
}
|
|
940
|
+
/** Write them, and report what was written and what was removed. */
|
|
941
|
+
export function applyFunctionTypeArtifacts(configDir, sdkTypes, options = {}) {
|
|
955
942
|
// No early return for an empty plan (CSO-3798-003): removing a tree's last
|
|
956
943
|
// agent (or its last function) plans nothing, and its artifacts still go.
|
|
957
944
|
const artifacts = planFunctionTypeArtifacts(configDir, sdkTypes, options);
|
|
945
|
+
const removals = plannedRemovals(configDir, artifacts, options);
|
|
958
946
|
const written = [];
|
|
959
947
|
for (const artifact of artifacts) {
|
|
960
948
|
const exists = existsSync(artifact.absolute);
|
|
@@ -969,10 +957,18 @@ export function writeFunctionTypeArtifacts(configDir, sdkTypes, options = {}) {
|
|
|
969
957
|
// A removed function's invoker goes with it (#3281): a stale generated file
|
|
970
958
|
// an app still imports is a compile error naming a function that no longer
|
|
971
959
|
// exists, which is the right failure, but one left behind forever is not.
|
|
972
|
-
|
|
973
|
-
|
|
960
|
+
const removed = [];
|
|
961
|
+
for (const absolute of removals) {
|
|
962
|
+
if (!existsSync(absolute))
|
|
963
|
+
continue;
|
|
964
|
+
rmSync(absolute, { force: true });
|
|
965
|
+
removed.push(reportedPath(configDir, absolute));
|
|
974
966
|
}
|
|
975
|
-
return written;
|
|
967
|
+
return { written, removed };
|
|
968
|
+
}
|
|
969
|
+
/** Write them, and report the tree-relative paths that changed on disk. */
|
|
970
|
+
export function writeFunctionTypeArtifacts(configDir, sdkTypes, options = {}) {
|
|
971
|
+
return applyFunctionTypeArtifacts(configDir, sdkTypes, options).written;
|
|
976
972
|
}
|
|
977
973
|
/**
|
|
978
974
|
* The artifacts a `--check` run would rewrite: the freshness answer for CI and
|
|
@@ -995,8 +991,8 @@ export function staleFunctionTypeArtifacts(configDir, options = {}) {
|
|
|
995
991
|
stale.push(artifact.relative);
|
|
996
992
|
}
|
|
997
993
|
}
|
|
998
|
-
for (const
|
|
999
|
-
stale.push(reportedPath(configDir,
|
|
994
|
+
for (const removal of plannedRemovals(configDir, planned, options)) {
|
|
995
|
+
stale.push(reportedPath(configDir, removal));
|
|
1000
996
|
}
|
|
1001
997
|
return stale;
|
|
1002
998
|
}
|