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
|
@@ -4,19 +4,173 @@
|
|
|
4
4
|
* its `message [CODE] (status)` line. Pure, so each is checked without a
|
|
5
5
|
* server holding a registry in the right state.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* The kinds `--kind` lists (#5220), as the CLI spells them: a string-set
|
|
9
|
+
* field's index is `set-elements` (#5890), which is `members` on the wire.
|
|
10
|
+
* `--kind members` is still accepted, as a deprecated spelling.
|
|
11
|
+
*/
|
|
12
|
+
export const DB3_INDEX_KINDS = ["scalar", "set-elements", "text", "vector"];
|
|
13
|
+
/** The kind a `--kind` spelling sends: `set-elements` and `members` both send `members`. */
|
|
14
|
+
export function db3IndexKindOnTheWire(spelling) {
|
|
15
|
+
return spelling === "set-elements" ? "members" : spelling;
|
|
16
|
+
}
|
|
17
|
+
/** A listed kind as the CLI prints it: `members` reads `set-elements` (#5890). */
|
|
18
|
+
export function db3IndexKindText(kind) {
|
|
19
|
+
return kind === "members" ? "set-elements" : kind;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A refused index call's sentence as the CLI prints it (#5890). The server's
|
|
23
|
+
* sentences use the API's words (the field is `members`); the CLI calls the
|
|
24
|
+
* index a set-element index and names its own flag. For a `DB3_INDEX_*` code,
|
|
25
|
+
* `member index` (either case of its first letter) reads `set-element index`,
|
|
26
|
+
* `with members: true to index its members` reads `with --set-elements to
|
|
27
|
+
* index its elements`, and `without members` reads `without <spelling>`, the
|
|
28
|
+
* spelling the user typed. Any other sentence is returned as it is.
|
|
29
|
+
*/
|
|
30
|
+
export function db3IndexRefusalSentence(message, code, spelling) {
|
|
31
|
+
if (typeof code !== "string" || !code.startsWith("DB3_INDEX_"))
|
|
32
|
+
return message;
|
|
33
|
+
return message
|
|
34
|
+
.replace(/with members: true to index its members/g, "with --set-elements to index its elements")
|
|
35
|
+
.replace(/without members\b/g, `without ${spelling}`)
|
|
36
|
+
.replace(/\b([Mm])ember index/g, (_match, first) => (first === "M" ? "Set-element index" : "set-element index"));
|
|
37
|
+
}
|
|
38
|
+
/** The placements `--on` accepts (#5220). */
|
|
39
|
+
export const DB3_INDEX_PLACEMENTS = ["server", "device", "both"];
|
|
40
|
+
/** The distances `--distance` accepts (#5225). */
|
|
41
|
+
export const VECTOR_DISTANCES = ["cos", "l2"];
|
|
42
|
+
/** The searches `--index` accepts (#5225). */
|
|
43
|
+
export const VECTOR_INDEX_MODES = ["exact", "ann"];
|
|
44
|
+
/** The quantizers `--quantizer` accepts (#5225). */
|
|
45
|
+
export const VECTOR_QUANTIZERS = ["pq", "opq", "bq"];
|
|
46
|
+
/**
|
|
47
|
+
* A `vector` registration's options from `db3 indexes register`'s flags
|
|
48
|
+
* (#5225), or the one line refusing them: a vector flag without `--kind
|
|
49
|
+
* vector`, an ann flag without `--index ann`, or a value outside a flag's
|
|
50
|
+
* set. No options when no vector flag is given.
|
|
51
|
+
*/
|
|
52
|
+
export function vectorIndexOptions(flags, kind) {
|
|
53
|
+
const given = ["distance", "index", "nbucket", "codesize", "quantizer"].filter((flag) => flags[flag] !== undefined);
|
|
54
|
+
if (!given.length)
|
|
55
|
+
return {};
|
|
56
|
+
if (kind !== "vector")
|
|
57
|
+
return { problem: `--${given[0]} applies to a vector index: give --kind vector` };
|
|
58
|
+
const ann = ["nbucket", "codesize", "quantizer"].find((flag) => flags[flag] !== undefined);
|
|
59
|
+
if (ann && flags.index !== "ann")
|
|
60
|
+
return { problem: `--${ann} applies to an ann vector index: give --index ann` };
|
|
61
|
+
if (flags.distance !== undefined && !VECTOR_DISTANCES.includes(flags.distance)) {
|
|
62
|
+
return { problem: `--distance must be one of ${VECTOR_DISTANCES.join(", ")}` };
|
|
63
|
+
}
|
|
64
|
+
if (flags.index !== undefined && !VECTOR_INDEX_MODES.includes(flags.index)) {
|
|
65
|
+
return { problem: `--index must be one of ${VECTOR_INDEX_MODES.join(", ")}` };
|
|
66
|
+
}
|
|
67
|
+
const positive = (flag) => {
|
|
68
|
+
const text = flags[flag];
|
|
69
|
+
if (text === undefined)
|
|
70
|
+
return undefined;
|
|
71
|
+
return /^[1-9][0-9]*$/.test(text) ? Number(text) : null;
|
|
72
|
+
};
|
|
73
|
+
const nbucket = positive("nbucket");
|
|
74
|
+
if (nbucket === null)
|
|
75
|
+
return { problem: "--nbucket must be a positive integer" };
|
|
76
|
+
const codesize = positive("codesize");
|
|
77
|
+
if (codesize === null)
|
|
78
|
+
return { problem: "--codesize must be a positive integer" };
|
|
79
|
+
if (flags.quantizer !== undefined && !VECTOR_QUANTIZERS.includes(flags.quantizer)) {
|
|
80
|
+
return { problem: `--quantizer must be one of ${VECTOR_QUANTIZERS.join(", ")}` };
|
|
81
|
+
}
|
|
82
|
+
const index = flags.index === "ann"
|
|
83
|
+
? {
|
|
84
|
+
mode: "ann",
|
|
85
|
+
...(nbucket !== undefined ? { nbucket } : {}),
|
|
86
|
+
...(codesize !== undefined ? { codesize } : {}),
|
|
87
|
+
...(flags.quantizer !== undefined ? { quantizer: flags.quantizer } : {}),
|
|
88
|
+
}
|
|
89
|
+
: flags.index === "exact"
|
|
90
|
+
? "exact"
|
|
91
|
+
: undefined;
|
|
92
|
+
return {
|
|
93
|
+
options: {
|
|
94
|
+
...(flags.distance !== undefined ? { distance: flags.distance } : {}),
|
|
95
|
+
...(index !== undefined ? { index } : {}),
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** The tokenizers `--tokenizer` accepts (#5222). */
|
|
100
|
+
export const DB3_TEXT_TOKENIZERS = ["unicode61", "porter"];
|
|
101
|
+
/**
|
|
102
|
+
* A text index's options out of `--tokenizer`, `--prefix` (comma-separated
|
|
103
|
+
* lengths) and repeated `--weight <field>=<weight>` (#5222), only the ones
|
|
104
|
+
* given; or the one-line refusal for a value the room could not take. The
|
|
105
|
+
* room judges the rest (a weight on a field the index does not cover, a
|
|
106
|
+
* length past 32).
|
|
107
|
+
*/
|
|
108
|
+
export function db3TextOptionsOf(options) {
|
|
109
|
+
const text = {};
|
|
110
|
+
if (options.tokenizer !== undefined) {
|
|
111
|
+
if (!DB3_TEXT_TOKENIZERS.includes(options.tokenizer)) {
|
|
112
|
+
return { refusal: `--tokenizer must be one of ${DB3_TEXT_TOKENIZERS.join(", ")}` };
|
|
113
|
+
}
|
|
114
|
+
text.tokenizer = options.tokenizer;
|
|
115
|
+
}
|
|
116
|
+
if (options.prefix !== undefined) {
|
|
117
|
+
const lengths = options.prefix.split(",").map((part) => part.trim());
|
|
118
|
+
if (lengths.some((part) => !/^[0-9]+$/.test(part) || Number(part) < 1 || Number(part) > 32)) {
|
|
119
|
+
return { refusal: `--prefix takes prefix lengths, integers from 1 to 32, comma-separated (e.g. --prefix 2,3)` };
|
|
120
|
+
}
|
|
121
|
+
text.prefix = lengths.map(Number);
|
|
122
|
+
}
|
|
123
|
+
for (const pair of options.weight ?? []) {
|
|
124
|
+
const match = /^([A-Za-z_][A-Za-z0-9_]*)=([0-9]+(?:\.[0-9]+)?)$/.exec(pair);
|
|
125
|
+
if (!match)
|
|
126
|
+
return { refusal: `--weight takes <field>=<weight>, a positive number (e.g. --weight title=2); got ${JSON.stringify(pair)}` };
|
|
127
|
+
text.weights = { ...(text.weights ?? {}), [match[1]]: Number(match[2]) };
|
|
128
|
+
}
|
|
129
|
+
return { text };
|
|
130
|
+
}
|
|
131
|
+
/** Whether a list holds a vector index, and so the `ANN MODEL` column (#5229): a list with none prints as before. */
|
|
132
|
+
export function listsVectorIndex(indexes) {
|
|
133
|
+
return indexes.some((index) => index.kind === "vector");
|
|
134
|
+
}
|
|
135
|
+
/** A vector index's shared model as the `ANN MODEL` column prints it (#5229). */
|
|
136
|
+
export function annModelText(index) {
|
|
137
|
+
if (index.kind !== "vector")
|
|
138
|
+
return "-";
|
|
139
|
+
if (index.annModel)
|
|
140
|
+
return `r${index.annModel.revision}, ${index.annModel.rows} rows`;
|
|
141
|
+
return typeof index.vector?.index === "object" && index.vector.index.mode === "ann" ? "none" : "-";
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* An index's kind and placement, as a server from before #5220 meant them
|
|
145
|
+
* when it listed neither: a member index on the server, any other scalar on
|
|
146
|
+
* both.
|
|
147
|
+
*/
|
|
148
|
+
export function db3IndexKindAndPlacement(index) {
|
|
149
|
+
const kind = index.kind ?? (index.members === true ? "members" : "scalar");
|
|
150
|
+
return { kind, on: index.on ?? (kind === "members" ? "server" : "both") };
|
|
151
|
+
}
|
|
7
152
|
/** An origin as one word: its kind, `(unique)` appended when it asks for uniqueness. */
|
|
8
153
|
function originText(origin) {
|
|
9
154
|
return origin.unique ? `${origin.kind} (unique)` : origin.kind;
|
|
10
155
|
}
|
|
11
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* The `indexes list` table's rows, in the route's order; a set-element
|
|
158
|
+
* index's fields end `(set elements)` and its kind reads `set-elements` (#5890).
|
|
159
|
+
*/
|
|
12
160
|
export function db3IndexTableRows(indexes) {
|
|
13
|
-
return indexes.map((index) =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
161
|
+
return indexes.map((index) => {
|
|
162
|
+
const { kind, on } = db3IndexKindAndPlacement(index);
|
|
163
|
+
return {
|
|
164
|
+
name: index.name,
|
|
165
|
+
model: index.model,
|
|
166
|
+
fields: index.members ? `${index.fields.join(", ")} (set elements)` : index.fields.join(", "),
|
|
167
|
+
unique: index.unique ? "Yes" : "No",
|
|
168
|
+
origins: index.origins.map(originText).join(", "),
|
|
169
|
+
kind: db3IndexKindText(kind),
|
|
170
|
+
on,
|
|
171
|
+
...(listsVectorIndex(indexes) ? { annModel: annModelText(index) } : {}),
|
|
172
|
+
};
|
|
173
|
+
});
|
|
20
174
|
}
|
|
21
175
|
/** A key value as an operator reads it: a string as written, anything else as JSON. */
|
|
22
176
|
function valueText(value) {
|
|
@@ -25,8 +179,9 @@ function valueText(value) {
|
|
|
25
179
|
/**
|
|
26
180
|
* The lines a refusal's `details` add, by its code: each duplicate key and
|
|
27
181
|
* how many records share it, each origin still keeping the index, the index
|
|
28
|
-
* a name or field already belongs to
|
|
29
|
-
*
|
|
182
|
+
* a name or field already belongs to (and where it lives, when a placement
|
|
183
|
+
* conflicts), the kind and placement no side builds, the field a set or a
|
|
184
|
+
* member index is refused for, the stored format.
|
|
30
185
|
* Nothing for a code that names nothing.
|
|
31
186
|
*/
|
|
32
187
|
export function db3IndexRefusalLines(err) {
|
|
@@ -38,7 +193,24 @@ export function db3IndexRefusalLines(err) {
|
|
|
38
193
|
return (Array.isArray(details.origins) ? details.origins : []).map((origin) => `Kept by: ${originText(origin)}`);
|
|
39
194
|
case "DB3_INDEX_EXISTS":
|
|
40
195
|
case "DB3_INDEX_NAME_TAKEN":
|
|
41
|
-
return
|
|
196
|
+
return [
|
|
197
|
+
...(typeof details.index === "string" ? [`Index: ${details.index}`] : []),
|
|
198
|
+
...(typeof details.on === "string" ? [`On: ${details.on}`] : []),
|
|
199
|
+
];
|
|
200
|
+
case "DB3_INDEX_PLACEMENT_UNSUPPORTED":
|
|
201
|
+
return [
|
|
202
|
+
...(typeof details.kind === "string" ? [`Kind: ${details.kind}`] : []),
|
|
203
|
+
`On: ${typeof details.on === "string" ? details.on : "(not given)"}`,
|
|
204
|
+
// A device that cannot build the index names its engine and why (#5222).
|
|
205
|
+
...(typeof details.engine === "string" ? [`Engine: ${details.engine}`] : []),
|
|
206
|
+
...(typeof details.reason === "string" ? [`Reason: ${details.reason}`] : []),
|
|
207
|
+
];
|
|
208
|
+
// #5240 — an explain's force that cannot serve the read, and why.
|
|
209
|
+
case "DB3_INDEX_CANNOT_SERVE":
|
|
210
|
+
return [
|
|
211
|
+
...(typeof details.index === "string" ? [`Index: ${details.index}`] : []),
|
|
212
|
+
...(typeof details.reason === "string" ? [`Reason: ${details.reason}`] : []),
|
|
213
|
+
];
|
|
42
214
|
case "DB3_INDEX_SET_FIELD":
|
|
43
215
|
case "DB3_INDEX_NOT_SET_FIELD":
|
|
44
216
|
return typeof details.field === "string" ? [`Field: ${details.field}`] : [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db3-index-output.js","sourceRoot":"","sources":["../../../src/lib/db3-index-output.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"db3-index-output.js","sourceRoot":"","sources":["../../../src/lib/db3-index-output.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,cAA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AAC,CAAC,CAAC,CAAC,WAAW,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aAC7E,CAAC;QACJ,KAAK,qBAAqB,CAAC;QAC3B,KAAK,yBAAyB;YAC5B,OAAO,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,KAAK,WAAW;YACd,OAAO,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,kBAAkB,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAClG;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -15,18 +15,42 @@
|
|
|
15
15
|
* declaration copied verbatim, with `type.models` removed. Every CLI reader of
|
|
16
16
|
* a type file reads it, so the server receives one whole `schema` per type and
|
|
17
17
|
* never sees the key.
|
|
18
|
+
*
|
|
19
|
+
* A field may also `ref` a shared enum in the `schemas/` directory beside
|
|
20
|
+
* `db3-types/` (#5545): the resolved document holds `type = "string"` and the
|
|
21
|
+
* enum's values where the `ref` was, in every declaration that carries it.
|
|
18
22
|
*/
|
|
23
|
+
import { type SharedEnumKeys, type SharedEnumRef } from "js-bao";
|
|
19
24
|
/** One refusal: the sentence, and the files (by name in `db3-types/`) it is about. */
|
|
20
25
|
export interface Db3TypeModelsRefusal {
|
|
21
26
|
files: string[];
|
|
22
27
|
message: string;
|
|
23
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* #5896 — the shared enum each field's `ref` named, by model then field. Codegen only: the expanded document, which
|
|
31
|
+
* push sends, carries no trace of it.
|
|
32
|
+
*/
|
|
33
|
+
export type Db3EnumRefs = Map<string, Map<string, SharedEnumRef>>;
|
|
24
34
|
export interface Db3TypeModelsResolution {
|
|
25
35
|
/** Per file name, the resolved document. A refused file is absent. */
|
|
26
36
|
documents: Map<string, any>;
|
|
27
37
|
refusals: Db3TypeModelsRefusal[];
|
|
28
|
-
/** The files that name at least one shared model. */
|
|
38
|
+
/** The files that name at least one shared model, or whose fields ref a shared enum. */
|
|
29
39
|
referencing: Set<string>;
|
|
40
|
+
/**
|
|
41
|
+
* #5896 — per resolved file that holds one, each model field that refs a shared enum, with its def; a model the file
|
|
42
|
+
* names through `[type] models` brings the declaring file's.
|
|
43
|
+
*/
|
|
44
|
+
enumRefs: Map<string, Db3EnumRefs>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* What a field's shared-enum `ref` resolves against (#5545): the `schemas/`
|
|
48
|
+
* files by stem (`null` when the directory is missing), and the other
|
|
49
|
+
* families' keys by tree stem, as the schema family index names them.
|
|
50
|
+
*/
|
|
51
|
+
export interface Db3TypeContext {
|
|
52
|
+
schemas: Map<string, string> | null;
|
|
53
|
+
keys: SharedEnumKeys;
|
|
30
54
|
}
|
|
31
55
|
/**
|
|
32
56
|
* A deep copy of a parsed TOML value that keeps each date and time its kind.
|
|
@@ -35,21 +59,33 @@ export interface Db3TypeModelsResolution {
|
|
|
35
59
|
* come out of the referencing type as `2020-01-01T00:00:00.000Z`.
|
|
36
60
|
*/
|
|
37
61
|
export declare function cloneTomlValue<T>(value: T): T;
|
|
62
|
+
/**
|
|
63
|
+
* The shared-enum context of a config tree: `schemas/`, and the keys of
|
|
64
|
+
* `functions/` (declaration files), `prompts/`, and the db3 types of
|
|
65
|
+
* `db3-types/` (`[type] name`) and `database-type-configs/`
|
|
66
|
+
* (`[type] databaseType`), each else by stem. The tree only: a type the
|
|
67
|
+
* server holds and the tree does not is no key here. `db3Types` stands in
|
|
68
|
+
* for the `db3-types/` files on disk (a pull's prospective directory).
|
|
69
|
+
*/
|
|
70
|
+
export declare function readDb3TypeContext(configDir: string, db3Types?: Map<string, string>): Db3TypeContext;
|
|
38
71
|
/**
|
|
39
72
|
* Resolve every file of a `db3-types/` directory, given as parsed documents
|
|
40
73
|
* keyed by file name. Files are read in name order.
|
|
41
74
|
*/
|
|
42
|
-
export declare function resolveDb3TypeModelsFrom(
|
|
43
|
-
/**
|
|
44
|
-
|
|
75
|
+
export declare function resolveDb3TypeModelsFrom(parsedFiles: Map<string, any>, context?: Db3TypeContext | (() => Db3TypeContext)): Db3TypeModelsResolution;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve a directory given as file contents (the pull's prospective
|
|
78
|
+
* `db3-types/`), field refs against `context`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveAgainst(prospective: Map<string, string>, context?: Db3TypeContext | (() => Db3TypeContext)): Db3TypeModelsResolution;
|
|
45
81
|
/** The `*.toml` files of a `db3-types/` directory, by name, with their contents. */
|
|
46
82
|
export declare function readDb3TypesDir(db3TypesDir: string): Map<string, string>;
|
|
47
|
-
/** Resolve every file of the `db3-types/` directory on disk. */
|
|
83
|
+
/** Resolve every file of the `db3-types/` directory on disk, field refs against its tree. */
|
|
48
84
|
export declare function resolveDb3TypeModels(db3TypesDir: string): Db3TypeModelsResolution;
|
|
49
85
|
/**
|
|
50
86
|
* The resolved document of one file of `db3TypesDir`, read as `parsed`. A file
|
|
51
|
-
* naming no shared model, or one the resolution refuses
|
|
52
|
-
* it), is returned as given.
|
|
87
|
+
* naming no shared model and no shared enum, or one the resolution refuses
|
|
88
|
+
* (the preflight reports it), is returned as given.
|
|
53
89
|
*/
|
|
54
90
|
export declare function resolveDb3TypeDocument(db3TypesDir: string, file: string, parsed: any): any;
|
|
55
91
|
/** The pull's decision for the reference-form files of `db3-types/`. */
|
|
@@ -89,4 +125,10 @@ export declare function planDb3TypePull(input: {
|
|
|
89
125
|
* server): a declaration they hold is not in the directory the pull leaves.
|
|
90
126
|
*/
|
|
91
127
|
removed?: Iterable<string>;
|
|
128
|
+
/**
|
|
129
|
+
* #5545 — what a field's shared-enum ref resolves against: the tree as the
|
|
130
|
+
* pull leaves it. A function is given the `db3-types/` files the pull leaves,
|
|
131
|
+
* so a type it adds or removes counts as a db3 key.
|
|
132
|
+
*/
|
|
133
|
+
context?: Db3TypeContext | ((db3Types: Map<string, string>) => Db3TypeContext);
|
|
92
134
|
}): Db3TypePullPlan;
|
|
@@ -15,11 +15,17 @@
|
|
|
15
15
|
* declaration copied verbatim, with `type.models` removed. Every CLI reader of
|
|
16
16
|
* a type file reads it, so the server receives one whole `schema` per type and
|
|
17
17
|
* never sees the key.
|
|
18
|
+
*
|
|
19
|
+
* A field may also `ref` a shared enum in the `schemas/` directory beside
|
|
20
|
+
* `db3-types/` (#5545): the resolved document holds `type = "string"` and the
|
|
21
|
+
* enum's values where the `ref` was, in every declaration that carries it.
|
|
18
22
|
*/
|
|
19
23
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
20
|
-
import { join } from "path";
|
|
24
|
+
import { basename, dirname, join } from "path";
|
|
21
25
|
import { TomlDate } from "smol-toml";
|
|
26
|
+
import { expandSharedEnumField, readSharedEnumFiles, sharedEnumResolver } from "js-bao";
|
|
22
27
|
import { parseConfigToml } from "./config-toml.js";
|
|
28
|
+
import { isFunctionDeclarationFile } from "./function-document-types.js";
|
|
23
29
|
const DIR = "db3-types";
|
|
24
30
|
function isTable(value) {
|
|
25
31
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -104,12 +110,98 @@ function referencesOf(file, parsed) {
|
|
|
104
110
|
}
|
|
105
111
|
return { names: [...raw] };
|
|
106
112
|
}
|
|
113
|
+
/** The `*.toml` files of `dir` that `keep` admits, by name, with their contents. */
|
|
114
|
+
function tomlFiles(dir, keep = (name) => name.endsWith(".toml")) {
|
|
115
|
+
const contents = new Map();
|
|
116
|
+
if (!existsSync(dir))
|
|
117
|
+
return contents;
|
|
118
|
+
for (const file of readdirSync(dir).filter(keep).sort()) {
|
|
119
|
+
try {
|
|
120
|
+
contents.set(file, readFileSync(join(dir, file), "utf-8"));
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// An unreadable file is the push preflight's to report.
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return contents;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The shared-enum context of a config tree: `schemas/`, and the keys of
|
|
130
|
+
* `functions/` (declaration files), `prompts/`, and the db3 types of
|
|
131
|
+
* `db3-types/` (`[type] name`) and `database-type-configs/`
|
|
132
|
+
* (`[type] databaseType`), each else by stem. The tree only: a type the
|
|
133
|
+
* server holds and the tree does not is no key here. `db3Types` stands in
|
|
134
|
+
* for the `db3-types/` files on disk (a pull's prospective directory).
|
|
135
|
+
*/
|
|
136
|
+
export function readDb3TypeContext(configDir, db3Types) {
|
|
137
|
+
const stems = (files) => [...files.keys()].map((file) => basename(file, ".toml"));
|
|
138
|
+
const db3 = new Set();
|
|
139
|
+
for (const [dir, key] of [["db3-types", "name"], ["database-type-configs", "databaseType"]]) {
|
|
140
|
+
for (const [file, content] of (dir === DIR && db3Types) || tomlFiles(join(configDir, dir))) {
|
|
141
|
+
let declared;
|
|
142
|
+
try {
|
|
143
|
+
declared = parseConfigToml(content)?.type?.[key];
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// Its own preflight reports a file that does not parse.
|
|
147
|
+
}
|
|
148
|
+
db3.add(typeof declared === "string" && declared ? declared : basename(file, ".toml"));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const schemasDir = join(configDir, "schemas");
|
|
152
|
+
return {
|
|
153
|
+
schemas: existsSync(schemasDir) ? new Map([...tomlFiles(schemasDir)].map(([file, text]) => [basename(file, ".toml"), text])) : null,
|
|
154
|
+
keys: {
|
|
155
|
+
db3: [...db3].sort(),
|
|
156
|
+
function: stems(tomlFiles(join(configDir, "functions"), isFunctionDeclarationFile)),
|
|
157
|
+
prompt: stems(tomlFiles(join(configDir, "prompts"))),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/** Whether a parsed type document has a field carrying `ref`. */
|
|
162
|
+
function hasFieldRef(parsed) {
|
|
163
|
+
const models = isTable(parsed?.models) ? Object.values(parsed.models) : [];
|
|
164
|
+
return models.some((model) => isTable(model?.fields) && Object.values(model.fields).some((field) => isTable(field) && "ref" in field));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* `parsed` with every field's shared-enum `ref` expanded, a copy; the parsed
|
|
168
|
+
* object itself when no field has one; or the refusal for the first that
|
|
169
|
+
* does not resolve.
|
|
170
|
+
*/
|
|
171
|
+
function expandFieldRefs(file, parsed, resolve) {
|
|
172
|
+
if (!hasFieldRef(parsed))
|
|
173
|
+
return { document: parsed };
|
|
174
|
+
const enumRefs = new Map();
|
|
175
|
+
// Entries, not assignment, so a model or field named `__proto__` stays an own key.
|
|
176
|
+
const models = [];
|
|
177
|
+
for (const [model, declaration] of Object.entries(parsed.models)) {
|
|
178
|
+
if (!isTable(declaration?.fields)) {
|
|
179
|
+
models.push([model, declaration]);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const fields = [];
|
|
183
|
+
for (const [field, raw] of Object.entries(declaration.fields)) {
|
|
184
|
+
const expanded = isTable(raw) && "ref" in raw ? expandSharedEnumField(raw, resolve()) : null;
|
|
185
|
+
if (expanded && "message" in expanded) {
|
|
186
|
+
return { refusal: `${DIR}/${file}: [models.${model}.fields.${field}] ref ${JSON.stringify(raw.ref)}: ${expanded.message}` };
|
|
187
|
+
}
|
|
188
|
+
fields.push([field, expanded && "field" in expanded ? expanded.field : raw]);
|
|
189
|
+
if (expanded && "sharedEnum" in expanded && expanded.sharedEnum) {
|
|
190
|
+
if (!enumRefs.has(model))
|
|
191
|
+
enumRefs.set(model, new Map());
|
|
192
|
+
enumRefs.get(model).set(field, expanded.sharedEnum);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
models.push([model, { ...declaration, fields: Object.fromEntries(fields) }]);
|
|
196
|
+
}
|
|
197
|
+
return { document: { ...parsed, models: Object.fromEntries(models) }, enumRefs };
|
|
198
|
+
}
|
|
107
199
|
/**
|
|
108
200
|
* Resolve every file of a `db3-types/` directory, given as parsed documents
|
|
109
201
|
* keyed by file name. Files are read in name order.
|
|
110
202
|
*/
|
|
111
|
-
export function resolveDb3TypeModelsFrom(
|
|
112
|
-
const names = [...
|
|
203
|
+
export function resolveDb3TypeModelsFrom(parsedFiles, context) {
|
|
204
|
+
const names = [...parsedFiles.keys()].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
113
205
|
const refusals = [];
|
|
114
206
|
const refused = new Set();
|
|
115
207
|
const refuse = (involved, message) => {
|
|
@@ -117,6 +209,29 @@ export function resolveDb3TypeModelsFrom(files) {
|
|
|
117
209
|
for (const file of involved)
|
|
118
210
|
refused.add(file);
|
|
119
211
|
};
|
|
212
|
+
// #5545 — each field's shared-enum ref first, so a declaration is copied
|
|
213
|
+
// and compared expanded. `schemas/` is read only when a field has a ref.
|
|
214
|
+
let resolver;
|
|
215
|
+
const resolve = () => {
|
|
216
|
+
if (resolver)
|
|
217
|
+
return resolver;
|
|
218
|
+
const { schemas, keys } = (typeof context === "function" ? context() : context) ?? { schemas: null, keys: { db3: [], function: [], prompt: [] } };
|
|
219
|
+
return (resolver = sharedEnumResolver(readSharedEnumFiles(schemas ?? undefined, "schemas/"), keys));
|
|
220
|
+
};
|
|
221
|
+
const files = new Map();
|
|
222
|
+
const expandedFiles = new Set();
|
|
223
|
+
const ownEnumRefs = new Map();
|
|
224
|
+
for (const file of names) {
|
|
225
|
+
const parsed = parsedFiles.get(file);
|
|
226
|
+
const expanded = expandFieldRefs(file, parsed, resolve);
|
|
227
|
+
if ("refusal" in expanded)
|
|
228
|
+
refuse([file], expanded.refusal);
|
|
229
|
+
else if (expanded.document !== parsed)
|
|
230
|
+
expandedFiles.add(file);
|
|
231
|
+
if ("enumRefs" in expanded && expanded.enumRefs?.size)
|
|
232
|
+
ownEnumRefs.set(file, expanded.enumRefs);
|
|
233
|
+
files.set(file, "document" in expanded ? expanded.document : parsed);
|
|
234
|
+
}
|
|
120
235
|
// One namespace of declarations, the first file by name winning. Only a
|
|
121
236
|
// directory that shares models holds its files to one shape per model.
|
|
122
237
|
const sharing = names.some((file) => {
|
|
@@ -167,10 +282,21 @@ export function resolveDb3TypeModelsFrom(files) {
|
|
|
167
282
|
references.set(file, listed);
|
|
168
283
|
}
|
|
169
284
|
const documents = new Map();
|
|
285
|
+
const enumRefs = new Map();
|
|
170
286
|
for (const file of names) {
|
|
171
287
|
if (refused.has(file))
|
|
172
288
|
continue;
|
|
173
289
|
const parsed = files.get(file);
|
|
290
|
+
// #5896 — the file's own fields' defs, then each listed model's from the file that declares it.
|
|
291
|
+
const refs = new Map(ownEnumRefs.get(file) ?? []);
|
|
292
|
+
for (const model of references.get(file) ?? []) {
|
|
293
|
+
const owner = declared.get(model);
|
|
294
|
+
const theirs = owner && ownEnumRefs.get(owner.file)?.get(model);
|
|
295
|
+
if (theirs)
|
|
296
|
+
refs.set(model, new Map(theirs));
|
|
297
|
+
}
|
|
298
|
+
if (refs.size > 0)
|
|
299
|
+
enumRefs.set(file, refs);
|
|
174
300
|
if (!referencing.has(file)) {
|
|
175
301
|
documents.set(file, parsed);
|
|
176
302
|
continue;
|
|
@@ -185,7 +311,9 @@ export function resolveDb3TypeModelsFrom(files) {
|
|
|
185
311
|
resolved.models = models;
|
|
186
312
|
documents.set(file, resolved);
|
|
187
313
|
}
|
|
188
|
-
|
|
314
|
+
for (const file of expandedFiles)
|
|
315
|
+
referencing.add(file);
|
|
316
|
+
return { documents, refusals, referencing, enumRefs };
|
|
189
317
|
}
|
|
190
318
|
/** Parse each content; a file that does not parse is left out (its own preflight reports it). */
|
|
191
319
|
function parsedFiles(contents) {
|
|
@@ -200,40 +328,32 @@ function parsedFiles(contents) {
|
|
|
200
328
|
}
|
|
201
329
|
return files;
|
|
202
330
|
}
|
|
203
|
-
/**
|
|
204
|
-
|
|
205
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Resolve a directory given as file contents (the pull's prospective
|
|
333
|
+
* `db3-types/`), field refs against `context`.
|
|
334
|
+
*/
|
|
335
|
+
export function resolveAgainst(prospective, context) {
|
|
336
|
+
return resolveDb3TypeModelsFrom(parsedFiles(prospective), context);
|
|
206
337
|
}
|
|
207
338
|
/** The `*.toml` files of a `db3-types/` directory, by name, with their contents. */
|
|
208
339
|
export function readDb3TypesDir(db3TypesDir) {
|
|
209
|
-
|
|
210
|
-
if (!existsSync(db3TypesDir))
|
|
211
|
-
return contents;
|
|
212
|
-
for (const file of readdirSync(db3TypesDir).filter((f) => f.endsWith(".toml")).sort()) {
|
|
213
|
-
try {
|
|
214
|
-
contents.set(file, readFileSync(join(db3TypesDir, file), "utf-8"));
|
|
215
|
-
}
|
|
216
|
-
catch {
|
|
217
|
-
// An unreadable file is the push preflight's to report.
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return contents;
|
|
340
|
+
return tomlFiles(db3TypesDir);
|
|
221
341
|
}
|
|
222
|
-
/** Resolve every file of the `db3-types/` directory on disk. */
|
|
342
|
+
/** Resolve every file of the `db3-types/` directory on disk, field refs against its tree. */
|
|
223
343
|
export function resolveDb3TypeModels(db3TypesDir) {
|
|
224
|
-
return resolveAgainst(readDb3TypesDir(db3TypesDir));
|
|
344
|
+
return resolveAgainst(readDb3TypesDir(db3TypesDir), () => readDb3TypeContext(dirname(db3TypesDir)));
|
|
225
345
|
}
|
|
226
346
|
/**
|
|
227
347
|
* The resolved document of one file of `db3TypesDir`, read as `parsed`. A file
|
|
228
|
-
* naming no shared model, or one the resolution refuses
|
|
229
|
-
* it), is returned as given.
|
|
348
|
+
* naming no shared model and no shared enum, or one the resolution refuses
|
|
349
|
+
* (the preflight reports it), is returned as given.
|
|
230
350
|
*/
|
|
231
351
|
export function resolveDb3TypeDocument(db3TypesDir, file, parsed) {
|
|
232
|
-
if (!isTable(parsed?.type) || parsed.type.models === undefined)
|
|
352
|
+
if ((!isTable(parsed?.type) || parsed.type.models === undefined) && !hasFieldRef(parsed))
|
|
233
353
|
return parsed;
|
|
234
354
|
const files = parsedFiles(readDb3TypesDir(db3TypesDir));
|
|
235
355
|
files.set(file, parsed);
|
|
236
|
-
return resolveDb3TypeModelsFrom(files).documents.get(file) ?? parsed;
|
|
356
|
+
return resolveDb3TypeModelsFrom(files, () => readDb3TypeContext(dirname(db3TypesDir))).documents.get(file) ?? parsed;
|
|
237
357
|
}
|
|
238
358
|
/**
|
|
239
359
|
* Plan `config pull` for the local reference-form files of `db3-types/`.
|
|
@@ -266,7 +386,7 @@ export function planDb3TypePull(input) {
|
|
|
266
386
|
catch {
|
|
267
387
|
continue;
|
|
268
388
|
}
|
|
269
|
-
if (isTable(localParsed?.type) && localParsed.type.models !== undefined)
|
|
389
|
+
if ((isTable(localParsed?.type) && localParsed.type.models !== undefined) || hasFieldRef(localParsed))
|
|
270
390
|
keep.add(file);
|
|
271
391
|
}
|
|
272
392
|
// The kept files are judged together, in the directory the pull leaves: a
|
|
@@ -279,7 +399,8 @@ export function planDb3TypePull(input) {
|
|
|
279
399
|
const around = new Map(prospective);
|
|
280
400
|
for (const file of keep)
|
|
281
401
|
around.set(file, input.local.get(file));
|
|
282
|
-
const
|
|
402
|
+
const context = input.context;
|
|
403
|
+
const { documents } = resolveAgainst(around, typeof context === "function" ? () => context(around) : context);
|
|
283
404
|
const failing = [...keep].filter((file) => {
|
|
284
405
|
const resolved = documents.get(file);
|
|
285
406
|
return !resolved || !input.same(input.server.get(file), resolved);
|
|
@@ -298,7 +419,17 @@ export function planDb3TypePull(input) {
|
|
|
298
419
|
after.set(file, input.local.get(file));
|
|
299
420
|
const afterParsed = parsedFiles(after);
|
|
300
421
|
for (const file of rewritten) {
|
|
301
|
-
const
|
|
422
|
+
const local = parseConfigToml(input.local.get(file));
|
|
423
|
+
for (const [model, declaration] of Object.entries(isTable(local?.models) ? local.models : {})) {
|
|
424
|
+
for (const [field, raw] of Object.entries(isTable(declaration?.fields) ? declaration.fields : {})) {
|
|
425
|
+
if (!isTable(raw) || !("ref" in raw))
|
|
426
|
+
continue;
|
|
427
|
+
notes.push(`${DIR}/${file} was written in full, as the server holds it: [models.${model}.fields.${field}] ref ` +
|
|
428
|
+
`${JSON.stringify(raw.ref)} no longer expands to the stored values. Update the def in schemas/, then ` +
|
|
429
|
+
`write the ref again, before the next \`config push\`.`);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const listed = referencesOf(file, local).names;
|
|
302
433
|
const written = afterParsed.get(file)?.models;
|
|
303
434
|
for (const model of listed) {
|
|
304
435
|
const owner = [...afterParsed.keys()]
|