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
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A function file's schemas, compiled the way the server compiles them.
|
|
3
|
+
*
|
|
4
|
+
* A function schema may define shapes under `$defs` and use them with local
|
|
5
|
+
* `$ref`s, and (#5533) ref shared defs in the tree's `schemas/` files. The
|
|
6
|
+
* server inlines every ref whose target exists when it stores the schema, so
|
|
7
|
+
* every LOCAL reader that pushes or compares a function file has to see that
|
|
8
|
+
* same compiled document: the local side of `config diff` and the push gate,
|
|
9
|
+
* the preflight, the build's warnings, and the configs push's compiled
|
|
10
|
+
* payload and provenance. The header bodies carry the AUTHORED schemas
|
|
11
|
+
* (`authoredFunctionTable`), which the server compiles from source against
|
|
12
|
+
* its stored rows. Codegen reads the authored schemas, so generated types are
|
|
13
|
+
* unchanged by refs. `compileFunctionToml` runs right after the file is
|
|
14
|
+
* parsed, with the vendored copy of the server's compiler.
|
|
15
|
+
*
|
|
16
|
+
* Never run it on a document built from a STORED row: the stored side is
|
|
17
|
+
* compared exactly as stored, so a schema stored before refs resolved reads as
|
|
18
|
+
* a change until it is pushed again.
|
|
19
|
+
*/
|
|
20
|
+
import { type SchemaFamilyIndex, type SchemaRefResolution } from "./schema-codegen/generated-schema-refs.js";
|
|
21
|
+
import { type SchemaProvenance } from "./schema-codegen/generated-schema-provenance.js";
|
|
22
|
+
/**
|
|
23
|
+
* The warning for a JSON-Schema slot whose root carries field-table keys
|
|
24
|
+
* (#5541): accepted as annotations, as before, but probably meant as a field
|
|
25
|
+
* table under the field-table key. Null when it carries none.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fieldTableKeyWarning(where: string, schema: unknown, slot: string): string | null;
|
|
28
|
+
/** The family index a compile resolves shared refs against, or the loader that reads it when a schema needs it. */
|
|
29
|
+
export type SchemaFamilySource = SchemaFamilyIndex | (() => SchemaFamilyIndex);
|
|
30
|
+
/** A function file's parsed document with its two schemas compiled. */
|
|
31
|
+
export interface CompiledFunctionToml {
|
|
32
|
+
/**
|
|
33
|
+
* The parsed document, with `function.inputSchema` and `function.outputSchema`
|
|
34
|
+
* replaced by their compiled form where the compile changed them. The same
|
|
35
|
+
* object as the input when nothing changed.
|
|
36
|
+
*/
|
|
37
|
+
parsed: any;
|
|
38
|
+
/** One line per inert `$ref`: `<file>: <field> #<path>: $ref "<ref>" stays inert (<reason>)`. */
|
|
39
|
+
warnings: string[];
|
|
40
|
+
/** The first compile refusal, naming the file, or null. */
|
|
41
|
+
refusal: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* The function row budget's refusal, naming the file, or null: the two
|
|
44
|
+
* compiled schemas a push stores together, when either inlined a ref. The
|
|
45
|
+
* push sends both schemas (a schema the file omits is cleared), so the file
|
|
46
|
+
* decides it. Not a compile refusal.
|
|
47
|
+
*/
|
|
48
|
+
budgetRefusal: string | null;
|
|
49
|
+
/** Each schema as compiled, null where the file declares none (or one that is not a JSON Schema object). */
|
|
50
|
+
schemas: {
|
|
51
|
+
inputSchema: Record<string, unknown> | null;
|
|
52
|
+
outputSchema: Record<string, unknown> | null;
|
|
53
|
+
};
|
|
54
|
+
/** What each compile resolved, for its provenance. */
|
|
55
|
+
resolved: {
|
|
56
|
+
inputSchema: SchemaRefResolution[];
|
|
57
|
+
outputSchema: SchemaRefResolution[];
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** The tree-relative spelling of a function file (`functions/<key>.toml`), for messages. */
|
|
61
|
+
export declare function functionFileLabel(filePath: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* The `[function]` table whose schemas a header create or update sends: the
|
|
64
|
+
* authored table a compiled one came from (#5533), or the table itself. The
|
|
65
|
+
* server compiles a header's schema from source against its stored rows, so
|
|
66
|
+
* the body must not carry the CLI's compile: a shared def's dangling
|
|
67
|
+
* `#/$defs/<X>` would resolve against the function's own `$defs` if compiled
|
|
68
|
+
* twice.
|
|
69
|
+
*/
|
|
70
|
+
export declare function authoredFunctionTable(table: any): any;
|
|
71
|
+
/**
|
|
72
|
+
* Compile the refs of a parsed `functions/<key>.toml`. A schema written as a
|
|
73
|
+
* JSON string is read the way the server reads it. A schema the compile
|
|
74
|
+
* leaves unchanged keeps its authored spelling.
|
|
75
|
+
*
|
|
76
|
+
* With `families` (#5533), shared refs resolve against the tree's `schemas/`
|
|
77
|
+
* files (#5540: and db3 types); a loader is called only when a schema writes a family-spelled ref.
|
|
78
|
+
* Without it, shared refs stay inert as in the release before.
|
|
79
|
+
*/
|
|
80
|
+
export declare function compileFunctionToml(file: string, parsed: any, families?: SchemaFamilySource): CompiledFunctionToml;
|
|
81
|
+
/** What a configs push carries beside the envelope's source (#5533): each schema as compiled, and its provenance. */
|
|
82
|
+
export interface FunctionSchemaPayload {
|
|
83
|
+
compiled: {
|
|
84
|
+
inputSchema: Record<string, unknown> | null;
|
|
85
|
+
outputSchema: Record<string, unknown> | null;
|
|
86
|
+
};
|
|
87
|
+
provenance: {
|
|
88
|
+
inputSchema: SchemaProvenance;
|
|
89
|
+
outputSchema: SchemaProvenance;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The compiled payload a configs push sends for a compiled function file:
|
|
94
|
+
* the two compiled schemas (null where the file declares none) and the
|
|
95
|
+
* provenance of each, which the server recompiles and compares. The compile
|
|
96
|
+
* must have run with a family index.
|
|
97
|
+
*/
|
|
98
|
+
export declare function functionSchemaPayload(compiled: CompiledFunctionToml): Promise<FunctionSchemaPayload>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A function file's schemas, compiled the way the server compiles them.
|
|
3
|
+
*
|
|
4
|
+
* A function schema may define shapes under `$defs` and use them with local
|
|
5
|
+
* `$ref`s, and (#5533) ref shared defs in the tree's `schemas/` files. The
|
|
6
|
+
* server inlines every ref whose target exists when it stores the schema, so
|
|
7
|
+
* every LOCAL reader that pushes or compares a function file has to see that
|
|
8
|
+
* same compiled document: the local side of `config diff` and the push gate,
|
|
9
|
+
* the preflight, the build's warnings, and the configs push's compiled
|
|
10
|
+
* payload and provenance. The header bodies carry the AUTHORED schemas
|
|
11
|
+
* (`authoredFunctionTable`), which the server compiles from source against
|
|
12
|
+
* its stored rows. Codegen reads the authored schemas, so generated types are
|
|
13
|
+
* unchanged by refs. `compileFunctionToml` runs right after the file is
|
|
14
|
+
* parsed, with the vendored copy of the server's compiler.
|
|
15
|
+
*
|
|
16
|
+
* Never run it on a document built from a STORED row: the stored side is
|
|
17
|
+
* compared exactly as stored, so a schema stored before refs resolved reads as
|
|
18
|
+
* a change until it is pushed again.
|
|
19
|
+
*/
|
|
20
|
+
import { compileSchemaRefs, functionSchemaRowBudgetRefusal, schemaFamilyRefsIn, } from "./schema-codegen/generated-schema-refs.js";
|
|
21
|
+
import { schemaProvenanceOf } from "./schema-codegen/generated-schema-provenance.js";
|
|
22
|
+
import { fieldTableMarkerKeys } from "./schema-codegen/generated-field-table.js";
|
|
23
|
+
/**
|
|
24
|
+
* The warning for a JSON-Schema slot whose root carries field-table keys
|
|
25
|
+
* (#5541): accepted as annotations, as before, but probably meant as a field
|
|
26
|
+
* table under the field-table key. Null when it carries none.
|
|
27
|
+
*/
|
|
28
|
+
export function fieldTableKeyWarning(where, schema, slot) {
|
|
29
|
+
const keys = fieldTableMarkerKeys(schema);
|
|
30
|
+
if (keys.length === 0)
|
|
31
|
+
return null;
|
|
32
|
+
const which = keys.length === 1 ? `${keys[0]}, a field-table key` : `${keys.join(", ")}, field-table keys`;
|
|
33
|
+
return `${where} carries ${which}; to write a field table, move it to ${slot}`;
|
|
34
|
+
}
|
|
35
|
+
const FIELDS = ["inputSchema", "outputSchema"];
|
|
36
|
+
/** Results by the document they compiled (and produced), per family source, so a second call is free. */
|
|
37
|
+
const compiledDocuments = new WeakMap();
|
|
38
|
+
/** A compiled `[function]` table → the authored table it was compiled from. */
|
|
39
|
+
const authoredTables = new WeakMap();
|
|
40
|
+
/** The key a compile without a family index is cached under. */
|
|
41
|
+
const PHASE_TWO = Symbol("no family index");
|
|
42
|
+
/** The index a schema with no family-spelled ref compiles against: it reads nothing. */
|
|
43
|
+
const NO_FAMILIES = Object.freeze({ files: new Map() });
|
|
44
|
+
function isPlainObject(value) {
|
|
45
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
46
|
+
}
|
|
47
|
+
/** The tree-relative spelling of a function file (`functions/<key>.toml`), for messages. */
|
|
48
|
+
export function functionFileLabel(filePath) {
|
|
49
|
+
const posix = filePath.replace(/\\/g, "/");
|
|
50
|
+
const at = posix.lastIndexOf("/functions/");
|
|
51
|
+
return at >= 0 ? posix.slice(at + 1) : posix;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The `[function]` table whose schemas a header create or update sends: the
|
|
55
|
+
* authored table a compiled one came from (#5533), or the table itself. The
|
|
56
|
+
* server compiles a header's schema from source against its stored rows, so
|
|
57
|
+
* the body must not carry the CLI's compile: a shared def's dangling
|
|
58
|
+
* `#/$defs/<X>` would resolve against the function's own `$defs` if compiled
|
|
59
|
+
* twice.
|
|
60
|
+
*/
|
|
61
|
+
export function authoredFunctionTable(table) {
|
|
62
|
+
return (isPlainObject(table) && authoredTables.get(table)) || table;
|
|
63
|
+
}
|
|
64
|
+
/** A schema as the push reads it: a JSON-string spelling parsed; anything else not an object is no schema. */
|
|
65
|
+
function schemaValue(value) {
|
|
66
|
+
let schema = value;
|
|
67
|
+
if (typeof schema === "string") {
|
|
68
|
+
try {
|
|
69
|
+
schema = JSON.parse(schema);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return isPlainObject(schema) ? schema : null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Compile the refs of a parsed `functions/<key>.toml`. A schema written as a
|
|
79
|
+
* JSON string is read the way the server reads it. A schema the compile
|
|
80
|
+
* leaves unchanged keeps its authored spelling.
|
|
81
|
+
*
|
|
82
|
+
* With `families` (#5533), shared refs resolve against the tree's `schemas/`
|
|
83
|
+
* files (#5540: and db3 types); a loader is called only when a schema writes a family-spelled ref.
|
|
84
|
+
* Without it, shared refs stay inert as in the release before.
|
|
85
|
+
*/
|
|
86
|
+
export function compileFunctionToml(file, parsed, families) {
|
|
87
|
+
if (!isPlainObject(parsed) || !isPlainObject(parsed.function)) {
|
|
88
|
+
return {
|
|
89
|
+
parsed,
|
|
90
|
+
warnings: [],
|
|
91
|
+
refusal: null,
|
|
92
|
+
budgetRefusal: null,
|
|
93
|
+
schemas: { inputSchema: null, outputSchema: null },
|
|
94
|
+
resolved: { inputSchema: [], outputSchema: [] },
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const cacheKey = families ?? PHASE_TWO;
|
|
98
|
+
const known = compiledDocuments.get(parsed)?.get(cacheKey);
|
|
99
|
+
if (known)
|
|
100
|
+
return known;
|
|
101
|
+
const table = parsed.function;
|
|
102
|
+
let compiledTable = table;
|
|
103
|
+
const warnings = [];
|
|
104
|
+
let refusal = null;
|
|
105
|
+
const resolved = { inputSchema: [], outputSchema: [] };
|
|
106
|
+
const schemas = { inputSchema: null, outputSchema: null };
|
|
107
|
+
const values = FIELDS.map((field) => schemaValue(table[field]));
|
|
108
|
+
let index;
|
|
109
|
+
if (families) {
|
|
110
|
+
const scans = values.map((value) => schemaFamilyRefsIn(value));
|
|
111
|
+
const needed = scans.some((scan) => scan.edges.length > 0 || scan.db3.length > 0 || scan.shortForms || scan.reserved);
|
|
112
|
+
index = !needed ? NO_FAMILIES : typeof families === "function" ? families() : families;
|
|
113
|
+
}
|
|
114
|
+
FIELDS.forEach((field, at) => {
|
|
115
|
+
const schema = values[at];
|
|
116
|
+
if (!schema)
|
|
117
|
+
return;
|
|
118
|
+
const misplaced = fieldTableKeyWarning(field, schema, field === "inputSchema" ? "[function.input]" : "[function.output]");
|
|
119
|
+
if (misplaced)
|
|
120
|
+
warnings.push(`${file}: ${misplaced}`);
|
|
121
|
+
// #5540 — the field is the position: a db3 ref gets the row in outputSchema.
|
|
122
|
+
const compiled = compileSchemaRefs(schema, { field, position: field === "outputSchema" ? "output" : "input", ...(index ? { families: index } : {}) });
|
|
123
|
+
if (compiled.refusal) {
|
|
124
|
+
refusal ??= `${file}: ${compiled.refusal.message}`;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
for (const warning of compiled.warnings)
|
|
128
|
+
warnings.push(`${file}: ${warning.message}`);
|
|
129
|
+
resolved[field] = compiled.resolved;
|
|
130
|
+
schemas[field] = compiled.schema;
|
|
131
|
+
if (JSON.stringify(compiled.schema) !== JSON.stringify(schema)) {
|
|
132
|
+
if (compiledTable === table)
|
|
133
|
+
compiledTable = { ...table };
|
|
134
|
+
compiledTable[field] = compiled.schema;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
// The bytes the server stores for each schema the push sends.
|
|
138
|
+
const stored = (value) => value === undefined || value === null || value === "" ? null : typeof value === "string" ? value : JSON.stringify(value);
|
|
139
|
+
const budget = refusal
|
|
140
|
+
? null
|
|
141
|
+
: functionSchemaRowBudgetRefusal(stored(compiledTable.inputSchema), stored(compiledTable.outputSchema), resolved);
|
|
142
|
+
const result = {
|
|
143
|
+
parsed: compiledTable === table ? parsed : { ...parsed, function: compiledTable },
|
|
144
|
+
warnings,
|
|
145
|
+
refusal,
|
|
146
|
+
budgetRefusal: budget ? `${file}: ${budget.message}` : null,
|
|
147
|
+
schemas,
|
|
148
|
+
resolved,
|
|
149
|
+
};
|
|
150
|
+
if (compiledTable !== table)
|
|
151
|
+
authoredTables.set(compiledTable, table);
|
|
152
|
+
for (const document of [parsed, result.parsed]) {
|
|
153
|
+
let byKey = compiledDocuments.get(document);
|
|
154
|
+
if (!byKey) {
|
|
155
|
+
byKey = new Map();
|
|
156
|
+
compiledDocuments.set(document, byKey);
|
|
157
|
+
}
|
|
158
|
+
byKey.set(cacheKey, result);
|
|
159
|
+
}
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The compiled payload a configs push sends for a compiled function file:
|
|
164
|
+
* the two compiled schemas (null where the file declares none) and the
|
|
165
|
+
* provenance of each, which the server recompiles and compares. The compile
|
|
166
|
+
* must have run with a family index.
|
|
167
|
+
*/
|
|
168
|
+
export async function functionSchemaPayload(compiled) {
|
|
169
|
+
return {
|
|
170
|
+
compiled: { inputSchema: compiled.schemas.inputSchema, outputSchema: compiled.schemas.outputSchema },
|
|
171
|
+
provenance: {
|
|
172
|
+
inputSchema: await schemaProvenanceOf(compiled.resolved.inputSchema),
|
|
173
|
+
outputSchema: await schemaProvenanceOf(compiled.resolved.outputSchema),
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=function-schema-refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-schema-refs.js","sourceRoot":"","sources":["../../../src/lib/function-schema-refs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,iBAAiB,EACjB,8BAA8B,EAC9B,kBAAkB,GAGnB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,iDAAiD,CAAC;AAC5G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAE,MAAe,EAAE,IAAY;IAC/E,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC;IAC3G,OAAO,GAAG,KAAK,YAAY,KAAK,wCAAwC,IAAI,EAAE,CAAC;AACjF,CAAC;AA8BD,MAAM,MAAM,GAAG,CAAC,aAAa,EAAE,cAAc,CAAU,CAAC;AAExD,yGAAyG;AACzG,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAA8C,CAAC;AACpF,+EAA+E;AAC/E,MAAM,cAAc,GAAG,IAAI,OAAO,EAAe,CAAC;AAClD,gEAAgE;AAChE,MAAM,SAAS,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC5C,wFAAwF;AACxF,MAAM,WAAW,GAAsB,MA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AK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI;QAC3D,OAAO;QACP,QAAQ;KACT,CAAC;IACF,IAAI,aAAa,KAAK,KAAK;QAAE,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACtE,KAAK,MAAM,QAAQ,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,IAAI,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;YAClB,iBAAiB,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAQD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAA8B;IACxE,OAAO;QACL,QAAQ,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE;QACpG,UAAU,EAAE;YACV,WAAW,EAAE,MAAM,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;YACpE,YAAY,EAAE,MAAM,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC;SACvE;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
* time and refuses a destination that lands outside the real root.
|
|
33
33
|
*/
|
|
34
34
|
import { type TriggerDeclaration } from "./generated-config-surfaces.js";
|
|
35
|
+
import { type CompiledFunctionToml, type FunctionSchemaPayload, type SchemaFamilySource } from "./function-schema-refs.js";
|
|
35
36
|
import { type PullWriteTally } from "./pull-write.js";
|
|
36
37
|
import { type CollectedFunction, type FunctionManifest as CollectedManifest } from "./function-collect.js";
|
|
37
38
|
/**
|
|
@@ -107,6 +108,21 @@ export interface FunctionConfigPush {
|
|
|
107
108
|
* can seed a model's metadata on a function's first write.
|
|
108
109
|
*/
|
|
109
110
|
documentSchema?: string;
|
|
111
|
+
/**
|
|
112
|
+
* #5533 — the TOML's two schemas as this CLI compiled them (null where the
|
|
113
|
+
* file declares none). The server recompiles them from the TOML against its
|
|
114
|
+
* stored `schemas/` files and refuses the push if they differ.
|
|
115
|
+
*/
|
|
116
|
+
compiled: FunctionSchemaPayload["compiled"];
|
|
117
|
+
/** #5533 — where each compiled schema inlined refs, and each def's hash; inside the envelope and `envelopeHash`. */
|
|
118
|
+
provenance: FunctionSchemaPayload["provenance"];
|
|
119
|
+
/**
|
|
120
|
+
* #5547 — the advisory typecheck's lines for this version, when the typed
|
|
121
|
+
* `ctx.db3` handles refuse something in it; absent otherwise. Outside the
|
|
122
|
+
* envelope and `envelopeHash`: the server counts them in its log and stores
|
|
123
|
+
* nothing.
|
|
124
|
+
*/
|
|
125
|
+
db3FilterAdvisories?: string[];
|
|
110
126
|
}
|
|
111
127
|
/**
|
|
112
128
|
* Everything about one `functions/<key>.toml` that `config push` can decide
|
|
@@ -136,6 +152,8 @@ export declare function functionTomlPreflightErrors(options: {
|
|
|
136
152
|
functionKey: string;
|
|
137
153
|
/** The already-parsed document, so the file is read once. */
|
|
138
154
|
tomlData: any;
|
|
155
|
+
/** #5533 — what shared refs resolve against; the file's own tree by default. */
|
|
156
|
+
families?: SchemaFamilySource;
|
|
139
157
|
}): string[];
|
|
140
158
|
/**
|
|
141
159
|
* Build everything the config-version route needs for one function file.
|
|
@@ -196,6 +214,8 @@ export declare function buildFunctionConfigPushDetailed(options: {
|
|
|
196
214
|
tomlData: any;
|
|
197
215
|
/** The declared `functionSources` directories; see `buildFunctionBundle`. */
|
|
198
216
|
sourceRoots?: readonly string[];
|
|
217
|
+
/** #5533 — what shared refs resolve against; the tree's own `schemas/` by default. */
|
|
218
|
+
families?: SchemaFamilySource;
|
|
199
219
|
}): Promise<DetailedFunctionConfigPush>;
|
|
200
220
|
/**
|
|
201
221
|
* The per-function failure when a server DID NOT retain the document schema it
|
|
@@ -254,8 +274,7 @@ export declare function documentSchemaDropAnswer(documentSchemaModels: unknown):
|
|
|
254
274
|
* Says ONCE — for the whole push, not once per function — that this push drops
|
|
255
275
|
* a document schema a running version carries (#3455, D3455-004).
|
|
256
276
|
*
|
|
257
|
-
* Removing `models/models.toml`
|
|
258
|
-
* edit, so it is a warning and not a refusal; but it turns first-writer seeding
|
|
277
|
+
* Removing `models/models.toml` is a legitimate edit, so it is a warning and not a refusal; but it turns first-writer seeding
|
|
259
278
|
* off for every document these functions touch, and that must not be silent.
|
|
260
279
|
*
|
|
261
280
|
* The state this holds is "has the run been told yet", and the rule is that
|
|
@@ -274,6 +293,11 @@ export declare function createDocumentSchemaDropWarner(deps: {
|
|
|
274
293
|
/** Where the sentence goes. */
|
|
275
294
|
warn: (message: string) => void;
|
|
276
295
|
}): (functionId: string, activeConfigId: string | undefined) => Promise<void>;
|
|
296
|
+
/**
|
|
297
|
+
* The compiled payload a configs push carries for a compiled function file
|
|
298
|
+
* (#5533): the two compiled schemas and their provenance.
|
|
299
|
+
*/
|
|
300
|
+
export declare function functionConfigSchemaPayload(compiled: CompiledFunctionToml): Promise<FunctionSchemaPayload>;
|
|
277
301
|
/**
|
|
278
302
|
* The create body. `functionKey` is attached here rather than spread from the
|
|
279
303
|
* table: the identity comes from the file name, exactly as it does for every
|
|
@@ -321,8 +345,9 @@ export interface FunctionPushPreRefusalInput {
|
|
|
321
345
|
export declare function functionPushPreRefusal(input: FunctionPushPreRefusalInput): string | null;
|
|
322
346
|
/**
|
|
323
347
|
* The message `config push` records for a refused version: the server's two
|
|
324
|
-
* break refusals
|
|
325
|
-
* everything else reads as it
|
|
348
|
+
* break refusals and its compiled-payload mismatch (#5533) carry the file
|
|
349
|
+
* they are about, as the pre-refusal does; everything else reads as it
|
|
350
|
+
* always did.
|
|
326
351
|
*/
|
|
327
352
|
export declare function functionVersionRefusalMessage(functionKey: string, err: unknown): string;
|
|
328
353
|
/**
|
|
@@ -517,12 +542,19 @@ export interface DocumentSchemaPullPlan {
|
|
|
517
542
|
* file cannot reproduce two envelopes, so an operator is told which
|
|
518
543
|
* function the tree now speaks for and which ones will read Modified until
|
|
519
544
|
* they are pushed again.
|
|
545
|
+
*
|
|
546
|
+
* Those rules are for a tree outside any project (#5208). Inside a project
|
|
547
|
+
* the copy is never read, so the pull writes none and removes one it finds,
|
|
548
|
+
* whatever it learned; and when a pulled version carries a schema the
|
|
549
|
+
* project has no file for, it says once what follows and how to keep it.
|
|
520
550
|
*/
|
|
521
551
|
export declare function planDocumentSchemaPull(options: {
|
|
522
552
|
configDir: string;
|
|
523
553
|
functions: readonly PulledFunctionSchema[];
|
|
524
554
|
/** True when the pull read every active function the app has. */
|
|
525
555
|
coversEveryFunction: boolean;
|
|
556
|
+
/** Whether the tree belongs to a project; defaults to `projectRootFor`'s answer. */
|
|
557
|
+
inProject?: boolean;
|
|
526
558
|
}): DocumentSchemaPullPlan;
|
|
527
559
|
/** What one `applyFunctionPull` actually did. */
|
|
528
560
|
export interface FunctionPullOutcome {
|
|
@@ -530,6 +562,8 @@ export interface FunctionPullOutcome {
|
|
|
530
562
|
writtenSources: string[];
|
|
531
563
|
/** One line per file the write step refused. */
|
|
532
564
|
refusals: string[];
|
|
565
|
+
/** The tree-relative paths a planned removal deleted (#5208). */
|
|
566
|
+
removed: string[];
|
|
533
567
|
}
|
|
534
568
|
/**
|
|
535
569
|
* Write a plan's files, creating the directories they need.
|
|
@@ -34,10 +34,12 @@
|
|
|
34
34
|
import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, rmSync, } from "fs";
|
|
35
35
|
import { dirname, isAbsolute, join, posix as posixPath, relative, resolve, sep, } from "path";
|
|
36
36
|
import { parseConfigToml, stringifyConfigToml } from "./config-toml.js";
|
|
37
|
-
import { DOCUMENT_SCHEMA_TREE_FILE, resolveDocumentSchema, } from "./function-document-types.js";
|
|
37
|
+
import { DOCUMENT_SCHEMA_TREE_FILE, documentSchemaSource, projectRootFor, resolveDocumentSchema, } from "./function-document-types.js";
|
|
38
38
|
import { SERVER_FUNCTION_TABLE } from "./config-surface.js";
|
|
39
39
|
import { checkCronTriggerEntry, hasDeclaredTriggers, hasRetiredDatabaseTriggerBlock, refusedFunctionKeys, refusedFunctionKeyMessages, retiredDatabaseTriggerTypes, normalizeTriggerDeclaration, RETIRED_FUNCTION_RUNTIME_KEYS, TriggerDeclarationError, validateSigningSecretDeclaration, declaredPublicOf, publicWriterRefusal, accessAmbiguousMessage, authorizeRequiredMessage, } from "./generated-config-surfaces.js";
|
|
40
40
|
import { flaggedPushWarnings } from "./function-lint.js";
|
|
41
|
+
import { authoredFunctionTable, compileFunctionToml, functionFileLabel, functionSchemaPayload, } from "./function-schema-refs.js";
|
|
42
|
+
import { schemaFamilyIndexLoader } from "./schema-family-index.js";
|
|
41
43
|
import { canonicalJsonStringify } from "./canonical-json.js";
|
|
42
44
|
import { writePulledFile } from "./pull-write.js";
|
|
43
45
|
import { buildPayloadFromToml, projectRecordToToml, tomlOwned } from "./config-payload.js";
|
|
@@ -106,6 +108,10 @@ export function normalizeFunctionTriggers(functionTable) {
|
|
|
106
108
|
return null;
|
|
107
109
|
return declaration;
|
|
108
110
|
}
|
|
111
|
+
/** The tree a function file belongs to: `<configDir>/functions/<key>.toml`. */
|
|
112
|
+
function configDirOf(filePath) {
|
|
113
|
+
return resolve(dirname(filePath), "..");
|
|
114
|
+
}
|
|
109
115
|
/** The `entry` refusal, or null. One spelling, two readers. */
|
|
110
116
|
function functionEntryError(functionKey, table) {
|
|
111
117
|
if (String(table?.entry ?? "").trim())
|
|
@@ -151,6 +157,14 @@ export function functionTomlPreflightErrors(options) {
|
|
|
151
157
|
const entryError = functionEntryError(functionKey, table);
|
|
152
158
|
if (entryError)
|
|
153
159
|
errors.push(entryError);
|
|
160
|
+
// #5531 — a schema whose refs cannot be compiled (a constraint beside a
|
|
161
|
+
// resolved `$ref`, an expansion over a limit), by the server's own compiler,
|
|
162
|
+
// and two compiled schemas over the row budget the server holds them to.
|
|
163
|
+
const compiledSchemas = compileFunctionToml(functionFileLabel(options.filePath), tomlData, options.families ?? schemaFamilyIndexLoader(configDirOf(options.filePath)));
|
|
164
|
+
if (compiledSchemas.refusal)
|
|
165
|
+
errors.push(compiledSchemas.refusal);
|
|
166
|
+
if (compiledSchemas.budgetRefusal)
|
|
167
|
+
errors.push(compiledSchemas.budgetRefusal);
|
|
154
168
|
// #4730 — `public` is the public-writer opt-in, and a boolean.
|
|
155
169
|
const declaredPublic = declaredPublicOf(table);
|
|
156
170
|
if (declaredPublic.ok === false) {
|
|
@@ -219,12 +233,17 @@ export async function buildFunctionConfigPush(options) {
|
|
|
219
233
|
*/
|
|
220
234
|
export async function buildFunctionConfigPushDetailed(options) {
|
|
221
235
|
const { configDir, functionKey, filePath, tomlData, sourceRoots } = options;
|
|
222
|
-
const
|
|
236
|
+
const families = options.families ?? schemaFamilyIndexLoader(configDir);
|
|
237
|
+
// #5531 — the schemas as the server will store them: local refs inlined;
|
|
238
|
+
// #5533 — and shared refs, against the tree's `schemas/` files.
|
|
239
|
+
const compiled = compileFunctionToml(functionFileLabel(filePath), tomlData, families);
|
|
240
|
+
const table = compiled.parsed?.function ?? {};
|
|
223
241
|
const entry = String(table.entry ?? "").trim();
|
|
224
242
|
const preflight = functionTomlPreflightErrors({
|
|
225
243
|
filePath,
|
|
226
244
|
functionKey,
|
|
227
245
|
tomlData,
|
|
246
|
+
families,
|
|
228
247
|
});
|
|
229
248
|
if (preflight.length > 0)
|
|
230
249
|
throw new FunctionBuildError(preflight[0]);
|
|
@@ -241,6 +260,9 @@ export async function buildFunctionConfigPushDetailed(options) {
|
|
|
241
260
|
let manifest = null;
|
|
242
261
|
let authorize = false;
|
|
243
262
|
let collectedManifest = null;
|
|
263
|
+
// #5904 — what the overlap lint reads, beside the manifest and never in it.
|
|
264
|
+
let collectedInput = null;
|
|
265
|
+
let collectedAuthorizeSources = [];
|
|
244
266
|
try {
|
|
245
267
|
const collected = await collectForBundle({
|
|
246
268
|
configDir,
|
|
@@ -251,6 +273,8 @@ export async function buildFunctionConfigPushDetailed(options) {
|
|
|
251
273
|
});
|
|
252
274
|
authorize = collected.authorize;
|
|
253
275
|
collectedManifest = collected.manifest;
|
|
276
|
+
collectedInput = collected.input ?? null;
|
|
277
|
+
collectedAuthorizeSources = collected.authorizeSources ?? [];
|
|
254
278
|
manifest = Buffer.from(JSON.stringify(collected.manifest), "utf-8").toString("base64");
|
|
255
279
|
}
|
|
256
280
|
catch (error) {
|
|
@@ -259,10 +283,11 @@ export async function buildFunctionConfigPushDetailed(options) {
|
|
|
259
283
|
}
|
|
260
284
|
throw error;
|
|
261
285
|
}
|
|
286
|
+
// #5531 — every build reports the refs its schemas leave inert.
|
|
262
287
|
// #4730 — a flagged build's lints. The public writer is refused here,
|
|
263
288
|
// before any request, by the rule the server applies at push; the rest are
|
|
264
289
|
// warnings the push prints and proceeds past.
|
|
265
|
-
|
|
290
|
+
const warnings = [...compiled.warnings];
|
|
266
291
|
if (authorize) {
|
|
267
292
|
const declaredPublic = declaredPublicOf(table);
|
|
268
293
|
const publicWriter = publicWriterRefusal({
|
|
@@ -273,13 +298,19 @@ export async function buildFunctionConfigPushDetailed(options) {
|
|
|
273
298
|
});
|
|
274
299
|
if (publicWriter)
|
|
275
300
|
throw new FunctionBuildError(publicWriter);
|
|
276
|
-
warnings
|
|
301
|
+
warnings.push(...flaggedPushWarnings(functionKey, collectedManifest, table.inputSchema ?? null, {
|
|
302
|
+
input: collectedInput,
|
|
303
|
+
authorizeSources: collectedAuthorizeSources,
|
|
304
|
+
}));
|
|
277
305
|
}
|
|
278
306
|
// The AUTHORED bytes. Read from disk rather than re-serialized, so the round
|
|
279
307
|
// trip is byte-identical (F-009).
|
|
280
308
|
const authored = readFileSync(filePath);
|
|
281
309
|
// #3455 — the document schema this version is pushed with.
|
|
282
310
|
const documentSchemaResolution = resolveDocumentSchema(configDir);
|
|
311
|
+
// #5533 — the compiled schemas and their provenance, which the server
|
|
312
|
+
// recompiles from the TOML and compares; the provenance is in the envelope.
|
|
313
|
+
const schemaPayload = await functionSchemaPayload(compiled);
|
|
283
314
|
const limits = normalizeLimits(table.limits);
|
|
284
315
|
const push = {
|
|
285
316
|
entry: built.entry,
|
|
@@ -303,6 +334,8 @@ export async function buildFunctionConfigPushDetailed(options) {
|
|
|
303
334
|
documentSchema: Buffer.from(documentSchemaResolution.source.content, "utf-8").toString("base64"),
|
|
304
335
|
}
|
|
305
336
|
: {}),
|
|
337
|
+
compiled: schemaPayload.compiled,
|
|
338
|
+
provenance: schemaPayload.provenance,
|
|
306
339
|
};
|
|
307
340
|
push.envelopeHash = functionEnvelopeHash({
|
|
308
341
|
schemaVersion: FUNCTION_ENVELOPE_SCHEMA_VERSION,
|
|
@@ -312,6 +345,7 @@ export async function buildFunctionConfigPushDetailed(options) {
|
|
|
312
345
|
bundle: push.bundle,
|
|
313
346
|
manifest: push.manifest,
|
|
314
347
|
documentSchema: push.documentSchema,
|
|
348
|
+
provenance: push.provenance,
|
|
315
349
|
});
|
|
316
350
|
return { push, projectSources: built.projectSources, authorize, warnings };
|
|
317
351
|
}
|
|
@@ -352,9 +386,10 @@ export function documentSchemaDropAnswer(documentSchemaModels) {
|
|
|
352
386
|
outcome: "drops",
|
|
353
387
|
message: `This push DROPS the document schema the running version ` +
|
|
354
388
|
`carries (${models.length > 0 ? models.join(", ") : "no models"}): ` +
|
|
355
|
-
`
|
|
356
|
-
`
|
|
357
|
-
`
|
|
389
|
+
`no models/models.toml resolves for this tree, so a function's ` +
|
|
390
|
+
`first write can no longer seed a document model's metadata. To ` +
|
|
391
|
+
`keep the schema, restore models/models.toml from version control ` +
|
|
392
|
+
`and push again.`,
|
|
358
393
|
};
|
|
359
394
|
}
|
|
360
395
|
if (documentSchemaModels === null)
|
|
@@ -365,8 +400,7 @@ export function documentSchemaDropAnswer(documentSchemaModels) {
|
|
|
365
400
|
* Says ONCE — for the whole push, not once per function — that this push drops
|
|
366
401
|
* a document schema a running version carries (#3455, D3455-004).
|
|
367
402
|
*
|
|
368
|
-
* Removing `models/models.toml`
|
|
369
|
-
* edit, so it is a warning and not a refusal; but it turns first-writer seeding
|
|
403
|
+
* Removing `models/models.toml` is a legitimate edit, so it is a warning and not a refusal; but it turns first-writer seeding
|
|
370
404
|
* off for every document these functions touch, and that must not be silent.
|
|
371
405
|
*
|
|
372
406
|
* The state this holds is "has the run been told yet", and the rule is that
|
|
@@ -417,13 +451,31 @@ function normalizeLimits(value) {
|
|
|
417
451
|
return undefined;
|
|
418
452
|
return value;
|
|
419
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* `table` with the schemas a header body sends: the authored ones (#5533),
|
|
456
|
+
* which the server compiles from source against its stored rows, even when
|
|
457
|
+
* `table` is the compiled table the push gate compares.
|
|
458
|
+
*/
|
|
459
|
+
function withAuthoredSchemas(table) {
|
|
460
|
+
const authored = authoredFunctionTable(table ?? {});
|
|
461
|
+
if (authored === table || table === null || typeof table !== "object")
|
|
462
|
+
return table ?? {};
|
|
463
|
+
return { ...table, inputSchema: authored.inputSchema, outputSchema: authored.outputSchema };
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* The compiled payload a configs push carries for a compiled function file
|
|
467
|
+
* (#5533): the two compiled schemas and their provenance.
|
|
468
|
+
*/
|
|
469
|
+
export async function functionConfigSchemaPayload(compiled) {
|
|
470
|
+
return functionSchemaPayload(compiled);
|
|
471
|
+
}
|
|
420
472
|
/**
|
|
421
473
|
* The create body. `functionKey` is attached here rather than spread from the
|
|
422
474
|
* table: the identity comes from the file name, exactly as it does for every
|
|
423
475
|
* other keyed type.
|
|
424
476
|
*/
|
|
425
477
|
export function buildFunctionCreatePayload(functionKey, table) {
|
|
426
|
-
const payload = buildPayloadFromToml(SERVER_FUNCTION_TABLE, table
|
|
478
|
+
const payload = buildPayloadFromToml(SERVER_FUNCTION_TABLE, withAuthoredSchemas(table), {
|
|
427
479
|
mode: "create",
|
|
428
480
|
values: { description: tomlOwned },
|
|
429
481
|
});
|
|
@@ -446,7 +498,7 @@ export function buildFunctionCreatePayload(functionKey, table) {
|
|
|
446
498
|
* server refuses a body that names it.
|
|
447
499
|
*/
|
|
448
500
|
export function buildFunctionUpdatePayload(table) {
|
|
449
|
-
const payload = buildPayloadFromToml(SERVER_FUNCTION_TABLE, table
|
|
501
|
+
const payload = buildPayloadFromToml(SERVER_FUNCTION_TABLE, withAuthoredSchemas(table), {
|
|
450
502
|
mode: "update",
|
|
451
503
|
values: {
|
|
452
504
|
description: tomlOwned,
|
|
@@ -479,8 +531,9 @@ export function functionPushPreRefusal(input) {
|
|
|
479
531
|
}
|
|
480
532
|
/**
|
|
481
533
|
* The message `config push` records for a refused version: the server's two
|
|
482
|
-
* break refusals
|
|
483
|
-
* everything else reads as it
|
|
534
|
+
* break refusals and its compiled-payload mismatch (#5533) carry the file
|
|
535
|
+
* they are about, as the pre-refusal does; everything else reads as it
|
|
536
|
+
* always did.
|
|
484
537
|
*/
|
|
485
538
|
export function functionVersionRefusalMessage(functionKey, err) {
|
|
486
539
|
const message = String(err?.message ?? err);
|
|
@@ -488,6 +541,11 @@ export function functionVersionRefusalMessage(functionKey, err) {
|
|
|
488
541
|
if (code === "FUNCTION_AUTHORIZE_REQUIRED" || code === "FUNCTION_ACCESS_AMBIGUOUS") {
|
|
489
542
|
return `functions/${functionKey}.toml: ${message}`;
|
|
490
543
|
}
|
|
544
|
+
// #5533 — a schemas/ file this function refs changed on the server after
|
|
545
|
+
// this push compiled it; the server's own message says to push again, and
|
|
546
|
+
// the next push reconciles the header.
|
|
547
|
+
if (code === "FUNCTION_SCHEMA_COMPILED_MISMATCH")
|
|
548
|
+
return `functions/${functionKey}.toml: ${message}`;
|
|
491
549
|
return message;
|
|
492
550
|
}
|
|
493
551
|
/**
|
|
@@ -1208,6 +1266,11 @@ export function planFunctionPull(options) {
|
|
|
1208
1266
|
* file cannot reproduce two envelopes, so an operator is told which
|
|
1209
1267
|
* function the tree now speaks for and which ones will read Modified until
|
|
1210
1268
|
* they are pushed again.
|
|
1269
|
+
*
|
|
1270
|
+
* Those rules are for a tree outside any project (#5208). Inside a project
|
|
1271
|
+
* the copy is never read, so the pull writes none and removes one it finds,
|
|
1272
|
+
* whatever it learned; and when a pulled version carries a schema the
|
|
1273
|
+
* project has no file for, it says once what follows and how to keep it.
|
|
1211
1274
|
*/
|
|
1212
1275
|
export function planDocumentSchemaPull(options) {
|
|
1213
1276
|
const root = resolve(options.configDir);
|
|
@@ -1222,6 +1285,19 @@ export function planDocumentSchemaPull(options) {
|
|
|
1222
1285
|
// Sorted by key so the schema a mixed tree keeps is a property of the app,
|
|
1223
1286
|
// not of the order the listing happened to come back in.
|
|
1224
1287
|
const pulled = [...options.functions].sort((a, b) => a.functionKey.localeCompare(b.functionKey));
|
|
1288
|
+
if (options.inProject ?? projectRootFor(root) !== null) {
|
|
1289
|
+
if (existsSync(absolute))
|
|
1290
|
+
plan.removals.push({ relative: relativePath, absolute });
|
|
1291
|
+
const carrierKeys = pulled.filter((f) => !!f.documentSchema).map((f) => f.functionKey);
|
|
1292
|
+
if (carrierKeys.length > 0 && documentSchemaSource(root) === null) {
|
|
1293
|
+
plan.warnings.push(`${carrierKeys.join(", ")} ${carrierKeys.length === 1 ? "runs a version that carries" : "run versions that carry"} ` +
|
|
1294
|
+
"a document schema, but this project has no models/models.toml, and inside a project the schema is " +
|
|
1295
|
+
"read from nothing else: `config diff` reads " +
|
|
1296
|
+
`${carrierKeys.length === 1 ? "it" : "them"} Modified and the next \`config push\` drops the schema. ` +
|
|
1297
|
+
"To keep it, restore models/models.toml from version control.");
|
|
1298
|
+
}
|
|
1299
|
+
return plan;
|
|
1300
|
+
}
|
|
1225
1301
|
if (pulled.length === 0)
|
|
1226
1302
|
return plan;
|
|
1227
1303
|
const carriers = pulled.filter((f) => !!f.documentSchema);
|
|
@@ -1300,7 +1376,7 @@ function unsafeDestination(realRoot, absolute) {
|
|
|
1300
1376
|
* is the version's file either way — while `writes` counts it as unchanged.
|
|
1301
1377
|
*/
|
|
1302
1378
|
export function applyFunctionPull(plan, writes) {
|
|
1303
|
-
const outcome = { writtenSources: [], refusals: [] };
|
|
1379
|
+
const outcome = { writtenSources: [], refusals: [], removed: [] };
|
|
1304
1380
|
let realRoot;
|
|
1305
1381
|
try {
|
|
1306
1382
|
realRoot = realpathSync(plan.configDir);
|
|
@@ -1336,6 +1412,7 @@ export function applyFunctionPull(plan, writes) {
|
|
|
1336
1412
|
}
|
|
1337
1413
|
try {
|
|
1338
1414
|
rmSync(removal.absolute);
|
|
1415
|
+
outcome.removed.push(removal.relative);
|
|
1339
1416
|
}
|
|
1340
1417
|
catch (error) {
|
|
1341
1418
|
outcome.refusals.push(`failed removing '${removal.relative}': ${String(error?.message ?? error)}`);
|