primitive-admin 1.1.0-alpha.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +523 -109
- package/assets/skill/skills/primitive-platform/SKILL.md +289 -0
- package/dist/bin/primitive.d.ts +2 -0
- package/dist/bin/primitive.js +372 -21
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.d.ts +2 -0
- package/dist/src/commands/admins.js +136 -30
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/analytics.d.ts +2 -0
- package/dist/src/commands/analytics.js +713 -55
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps.d.ts +2 -0
- package/dist/src/commands/apps.js +65 -100
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth-sessions.d.ts +7 -0
- package/dist/src/commands/auth-sessions.js +144 -0
- package/dist/src/commands/auth-sessions.js.map +1 -0
- package/dist/src/commands/auth.d.ts +2 -0
- package/dist/src/commands/auth.js +238 -108
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.d.ts +2 -0
- package/dist/src/commands/blob-buckets.js +331 -0
- package/dist/src/commands/blob-buckets.js.map +1 -0
- package/dist/src/commands/catalog.d.ts +2 -0
- package/dist/src/commands/catalog.js +63 -48
- package/dist/src/commands/catalog.js.map +1 -1
- package/dist/src/commands/collection-type-configs.d.ts +2 -0
- package/dist/src/commands/collection-type-configs.js +85 -0
- package/dist/src/commands/collection-type-configs.js.map +1 -0
- package/dist/src/commands/collections.d.ts +2 -0
- package/dist/src/commands/collections.js +1282 -0
- package/dist/src/commands/collections.js.map +1 -0
- package/dist/src/commands/comparisons.d.ts +2 -0
- package/dist/src/commands/comparisons.js +6 -6
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/config.d.ts +46 -0
- package/dist/src/commands/config.js +465 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/connections.d.ts +2 -0
- package/dist/src/commands/connections.js +99 -0
- package/dist/src/commands/connections.js.map +1 -0
- package/dist/src/commands/cron-triggers.d.ts +2 -0
- package/dist/src/commands/cron-triggers.js +266 -0
- package/dist/src/commands/cron-triggers.js.map +1 -0
- package/dist/src/commands/database-type-configs.d.ts +2 -0
- package/dist/src/commands/database-type-configs.js +164 -0
- package/dist/src/commands/database-type-configs.js.map +1 -0
- package/dist/src/commands/database-types.d.ts +2 -0
- package/dist/src/commands/database-types.js +471 -0
- package/dist/src/commands/database-types.js.map +1 -0
- package/dist/src/commands/databases.d.ts +65 -0
- package/dist/src/commands/databases.js +1887 -243
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.d.ts +60 -0
- package/dist/src/commands/documents.js +2888 -22
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.d.ts +2 -0
- package/dist/src/commands/email-templates.js +175 -0
- package/dist/src/commands/email-templates.js.map +1 -0
- package/dist/src/commands/env.d.ts +23 -0
- package/dist/src/commands/env.js +395 -0
- package/dist/src/commands/env.js.map +1 -0
- package/dist/src/commands/feature-flags.d.ts +14 -0
- package/dist/src/commands/feature-flags.js +117 -0
- package/dist/src/commands/feature-flags.js.map +1 -0
- package/dist/src/commands/functions.d.ts +20 -0
- package/dist/src/commands/functions.js +1630 -0
- package/dist/src/commands/functions.js.map +1 -0
- package/dist/src/commands/group-type-configs.d.ts +2 -0
- package/dist/src/commands/group-type-configs.js +87 -0
- package/dist/src/commands/group-type-configs.js.map +1 -0
- package/dist/src/commands/groups.d.ts +2 -0
- package/dist/src/commands/groups.js +65 -113
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.d.ts +223 -0
- package/dist/src/commands/guides.js +627 -69
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/init.d.ts +37 -0
- package/dist/src/commands/init.js +1693 -208
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.d.ts +2 -0
- package/dist/src/commands/integrations.js +428 -187
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/llm.d.ts +2 -0
- package/dist/src/commands/llm.js +4 -2
- package/dist/src/commands/llm.js.map +1 -1
- package/dist/src/commands/locks.d.ts +8 -0
- package/dist/src/commands/locks.js +175 -0
- package/dist/src/commands/locks.js.map +1 -0
- package/dist/src/commands/metadata-category-configs.d.ts +12 -0
- package/dist/src/commands/metadata-category-configs.js +113 -0
- package/dist/src/commands/metadata-category-configs.js.map +1 -0
- package/dist/src/commands/metadata.d.ts +2 -0
- package/dist/src/commands/metadata.js +288 -0
- package/dist/src/commands/metadata.js.map +1 -0
- package/dist/src/commands/prompts.d.ts +2 -0
- package/dist/src/commands/prompts.js +322 -634
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +3 -0
- package/dist/src/commands/rule-sets.js +139 -148
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +30 -0
- package/dist/src/commands/scripts.js +688 -0
- package/dist/src/commands/scripts.js.map +1 -0
- package/dist/src/commands/secrets.d.ts +2 -0
- package/dist/src/commands/secrets.js +109 -0
- package/dist/src/commands/secrets.js.map +1 -0
- package/dist/src/commands/sessions.d.ts +2 -0
- package/dist/src/commands/sessions.js +76 -0
- package/dist/src/commands/sessions.js.map +1 -0
- package/dist/src/commands/skill.d.ts +2 -0
- package/dist/src/commands/skill.js +29 -0
- package/dist/src/commands/skill.js.map +1 -0
- package/dist/src/commands/sync-app-settings.d.ts +158 -0
- package/dist/src/commands/sync-app-settings.js +328 -0
- package/dist/src/commands/sync-app-settings.js.map +1 -0
- package/dist/src/commands/sync.d.ts +2670 -0
- package/dist/src/commands/sync.js +17144 -834
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.d.ts +2 -0
- package/dist/src/commands/tokens.js +132 -22
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.d.ts +2 -0
- package/dist/src/commands/users.js +542 -24
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.d.ts +8 -0
- package/dist/src/commands/vars.js +97 -0
- package/dist/src/commands/vars.js.map +1 -0
- package/dist/src/commands/waitlist.d.ts +2 -0
- package/dist/src/commands/waitlist.js +12 -11
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/webhooks.d.ts +31 -0
- package/dist/src/commands/webhooks.js +633 -0
- package/dist/src/commands/webhooks.js.map +1 -0
- package/dist/src/commands/workflows.d.ts +88 -0
- package/dist/src/commands/workflows.js +1568 -742
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/access-rule-display.d.ts +21 -0
- package/dist/src/lib/access-rule-display.js +34 -0
- package/dist/src/lib/access-rule-display.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +2550 -0
- package/dist/src/lib/api-client.js +2503 -160
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
- package/dist/src/lib/app-settings-descriptor.js +583 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -0
- package/dist/src/lib/auth-flow.d.ts +8 -0
- package/dist/src/lib/batch.d.ts +26 -0
- package/dist/src/lib/batch.js +32 -0
- package/dist/src/lib/batch.js.map +1 -0
- package/dist/src/lib/block-layout.d.ts +160 -0
- package/dist/src/lib/block-layout.js +451 -0
- package/dist/src/lib/block-layout.js.map +1 -0
- package/dist/src/lib/block-selector.d.ts +58 -0
- package/dist/src/lib/block-selector.js +92 -0
- package/dist/src/lib/block-selector.js.map +1 -0
- package/dist/src/lib/canonical-json.d.ts +12 -0
- package/dist/src/lib/canonical-json.js +35 -0
- package/dist/src/lib/canonical-json.js.map +1 -0
- package/dist/src/lib/channel.d.ts +30 -0
- package/dist/src/lib/channel.js +68 -0
- package/dist/src/lib/channel.js.map +1 -0
- package/dist/src/lib/cli-manifest.d.ts +68 -0
- package/dist/src/lib/cli-manifest.js +71 -0
- package/dist/src/lib/cli-manifest.js.map +1 -0
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
- package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
- package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +38 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +46 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
- package/dist/src/lib/collection-export.d.ts +184 -0
- package/dist/src/lib/collection-export.js +252 -0
- package/dist/src/lib/collection-export.js.map +1 -0
- package/dist/src/lib/config-json-field.d.ts +28 -0
- package/dist/src/lib/config-json-field.js +56 -0
- package/dist/src/lib/config-json-field.js.map +1 -0
- package/dist/src/lib/config-object-descriptor.d.ts +127 -0
- package/dist/src/lib/config-object-descriptor.js +740 -0
- package/dist/src/lib/config-object-descriptor.js.map +1 -0
- package/dist/src/lib/config-payload.d.ts +92 -0
- package/dist/src/lib/config-payload.js +161 -0
- package/dist/src/lib/config-payload.js.map +1 -0
- package/dist/src/lib/config-surface.d.ts +141 -0
- package/dist/src/lib/config-surface.js +368 -0
- package/dist/src/lib/config-surface.js.map +1 -0
- package/dist/src/lib/config-toml.d.ts +10 -0
- package/dist/src/lib/config-toml.js +42 -0
- package/dist/src/lib/config-toml.js.map +1 -0
- package/dist/src/lib/config.d.ts +71 -0
- package/dist/src/lib/config.js +71 -68
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/confirm-prompt.d.ts +83 -0
- package/dist/src/lib/confirm-prompt.js +110 -0
- package/dist/src/lib/confirm-prompt.js.map +1 -0
- package/dist/src/lib/constants.d.ts +11 -0
- package/dist/src/lib/constants.js +12 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/crash-handlers.d.ts +20 -0
- package/dist/src/lib/crash-handlers.js +49 -0
- package/dist/src/lib/crash-handlers.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +104 -0
- package/dist/src/lib/credentials-store.js +336 -0
- package/dist/src/lib/credentials-store.js.map +1 -0
- package/dist/src/lib/csv.d.ts +47 -0
- package/dist/src/lib/csv.js +172 -0
- package/dist/src/lib/csv.js.map +1 -0
- package/dist/src/lib/data-input.d.ts +23 -0
- package/dist/src/lib/data-input.js +50 -0
- package/dist/src/lib/data-input.js.map +1 -0
- package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
- package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
- package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
- package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
- package/dist/src/lib/db-codegen/dbNaming.js +180 -0
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
- package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js +525 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
- package/dist/src/lib/deprecation.d.ts +22 -0
- package/dist/src/lib/deprecation.js +43 -0
- package/dist/src/lib/deprecation.js.map +1 -0
- package/dist/src/lib/document-export-permissions.d.ts +30 -0
- package/dist/src/lib/document-export-permissions.js +54 -0
- package/dist/src/lib/document-export-permissions.js.map +1 -0
- package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
- package/dist/src/lib/document-ingest-artifact.js +505 -0
- package/dist/src/lib/document-ingest-artifact.js.map +1 -0
- package/dist/src/lib/document-ingest-input.d.ts +51 -0
- package/dist/src/lib/document-ingest-input.js +132 -0
- package/dist/src/lib/document-ingest-input.js.map +1 -0
- package/dist/src/lib/document-ingest-rows.d.ts +137 -0
- package/dist/src/lib/document-ingest-rows.js +181 -0
- package/dist/src/lib/document-ingest-rows.js.map +1 -0
- package/dist/src/lib/document-ingest.d.ts +101 -0
- package/dist/src/lib/document-ingest.js +384 -0
- package/dist/src/lib/document-ingest.js.map +1 -0
- package/dist/src/lib/env-resolver-core.d.ts +258 -0
- package/dist/src/lib/env-resolver-core.js +447 -0
- package/dist/src/lib/env-resolver-core.js.map +1 -0
- package/dist/src/lib/env-resolver.d.ts +99 -0
- package/dist/src/lib/env-resolver.js +153 -0
- package/dist/src/lib/env-resolver.js.map +1 -0
- package/dist/src/lib/fetch.d.ts +5 -0
- package/dist/src/lib/function-bundle.d.ts +147 -0
- package/dist/src/lib/function-bundle.js +341 -0
- package/dist/src/lib/function-bundle.js.map +1 -0
- package/dist/src/lib/function-collect.d.ts +123 -0
- package/dist/src/lib/function-collect.js +610 -0
- package/dist/src/lib/function-collect.js.map +1 -0
- package/dist/src/lib/function-db-types.d.ts +202 -0
- package/dist/src/lib/function-db-types.js +870 -0
- package/dist/src/lib/function-db-types.js.map +1 -0
- package/dist/src/lib/function-document-types.d.ts +144 -0
- package/dist/src/lib/function-document-types.js +370 -0
- package/dist/src/lib/function-document-types.js.map +1 -0
- package/dist/src/lib/function-grants-preflight.d.ts +64 -0
- package/dist/src/lib/function-grants-preflight.js +105 -0
- package/dist/src/lib/function-grants-preflight.js.map +1 -0
- package/dist/src/lib/function-log-lines.d.ts +76 -0
- package/dist/src/lib/function-log-lines.js +160 -0
- package/dist/src/lib/function-log-lines.js.map +1 -0
- package/dist/src/lib/function-log-row.d.ts +29 -0
- package/dist/src/lib/function-log-row.js +73 -0
- package/dist/src/lib/function-log-row.js.map +1 -0
- package/dist/src/lib/function-log-tail.d.ts +132 -0
- package/dist/src/lib/function-log-tail.js +262 -0
- package/dist/src/lib/function-log-tail.js.map +1 -0
- package/dist/src/lib/function-run.d.ts +289 -0
- package/dist/src/lib/function-run.js +389 -0
- package/dist/src/lib/function-run.js.map +1 -0
- package/dist/src/lib/function-schema-codegen.d.ts +143 -0
- package/dist/src/lib/function-schema-codegen.js +420 -0
- package/dist/src/lib/function-schema-codegen.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +459 -0
- package/dist/src/lib/function-sync.js +1258 -0
- package/dist/src/lib/function-sync.js.map +1 -0
- package/dist/src/lib/function-trigger-listing.d.ts +27 -0
- package/dist/src/lib/function-trigger-listing.js +70 -0
- package/dist/src/lib/function-trigger-listing.js.map +1 -0
- package/dist/src/lib/function-typecheck.d.ts +86 -0
- package/dist/src/lib/function-typecheck.js +370 -0
- package/dist/src/lib/function-typecheck.js.map +1 -0
- package/dist/src/lib/function-versions.d.ts +122 -0
- package/dist/src/lib/function-versions.js +182 -0
- package/dist/src/lib/function-versions.js.map +1 -0
- package/dist/src/lib/generated-allowlist.d.ts +28 -0
- package/dist/src/lib/generated-allowlist.js +281 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +2936 -0
- package/dist/src/lib/generated-config-surfaces.js +10569 -0
- package/dist/src/lib/generated-config-surfaces.js.map +1 -0
- package/dist/src/lib/generated-sdk-types.d.ts +12 -0
- package/dist/src/lib/generated-sdk-types.js +13 -0
- package/dist/src/lib/generated-sdk-types.js.map +1 -0
- package/dist/src/lib/generated-template-lint.d.ts +212 -0
- package/dist/src/lib/generated-template-lint.js +624 -0
- package/dist/src/lib/generated-template-lint.js.map +1 -0
- package/dist/src/lib/init-adopt.d.ts +16 -0
- package/dist/src/lib/init-adopt.js +34 -0
- package/dist/src/lib/init-adopt.js.map +1 -0
- package/dist/src/lib/init-assets.d.ts +39 -0
- package/dist/src/lib/init-assets.js +97 -0
- package/dist/src/lib/init-assets.js.map +1 -0
- package/dist/src/lib/init-client-platforms.d.ts +14 -0
- package/dist/src/lib/init-client-platforms.js +71 -0
- package/dist/src/lib/init-client-platforms.js.map +1 -0
- package/dist/src/lib/init-config.d.ts +98 -0
- package/dist/src/lib/init-config.js +186 -0
- package/dist/src/lib/init-config.js.map +1 -0
- package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
- package/dist/src/lib/init-email-redirect-uris.js +46 -0
- package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
- package/dist/src/lib/init-ios-links.d.ts +91 -0
- package/dist/src/lib/init-ios-links.js +219 -0
- package/dist/src/lib/init-ios-links.js.map +1 -0
- package/dist/src/lib/init-plan.d.ts +80 -0
- package/dist/src/lib/init-plan.js +95 -0
- package/dist/src/lib/init-plan.js.map +1 -0
- package/dist/src/lib/init-production-env.d.ts +48 -0
- package/dist/src/lib/init-production-env.js +59 -0
- package/dist/src/lib/init-production-env.js.map +1 -0
- package/dist/src/lib/init-schema.d.ts +74 -0
- package/dist/src/lib/init-schema.js +358 -0
- package/dist/src/lib/init-schema.js.map +1 -0
- package/dist/src/lib/init-xcode.d.ts +34 -0
- package/dist/src/lib/init-xcode.js +138 -0
- package/dist/src/lib/init-xcode.js.map +1 -0
- package/dist/src/lib/integration-request-config.d.ts +30 -0
- package/dist/src/lib/integration-request-config.js +145 -0
- package/dist/src/lib/integration-request-config.js.map +1 -0
- package/dist/src/lib/integration-selector.d.ts +42 -0
- package/dist/src/lib/integration-selector.js +46 -0
- package/dist/src/lib/integration-selector.js.map +1 -0
- package/dist/src/lib/ios-app-id.d.ts +34 -0
- package/dist/src/lib/ios-app-id.js +69 -0
- package/dist/src/lib/ios-app-id.js.map +1 -0
- package/dist/src/lib/list-options.d.ts +68 -0
- package/dist/src/lib/list-options.js +89 -0
- package/dist/src/lib/list-options.js.map +1 -0
- package/dist/src/lib/local-state.d.ts +55 -0
- package/dist/src/lib/local-state.js +167 -0
- package/dist/src/lib/local-state.js.map +1 -0
- package/dist/src/lib/local-test-cases.d.ts +63 -0
- package/dist/src/lib/local-test-cases.js +136 -0
- package/dist/src/lib/local-test-cases.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +715 -0
- package/dist/src/lib/log-inspection.js +816 -0
- package/dist/src/lib/log-inspection.js.map +1 -0
- package/dist/src/lib/logout-admin-session.d.ts +33 -0
- package/dist/src/lib/logout-admin-session.js +70 -0
- package/dist/src/lib/logout-admin-session.js.map +1 -0
- package/dist/src/lib/migration-nag.d.ts +49 -0
- package/dist/src/lib/migration-nag.js +163 -0
- package/dist/src/lib/migration-nag.js.map +1 -0
- package/dist/src/lib/object-status-filter.d.ts +22 -0
- package/dist/src/lib/object-status-filter.js +45 -0
- package/dist/src/lib/object-status-filter.js.map +1 -0
- package/dist/src/lib/output.d.ts +124 -0
- package/dist/src/lib/output.js +219 -8
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/package-manager.d.ts +140 -0
- package/dist/src/lib/package-manager.js +305 -0
- package/dist/src/lib/package-manager.js.map +1 -0
- package/dist/src/lib/paginate.d.ts +98 -0
- package/dist/src/lib/paginate.js +112 -0
- package/dist/src/lib/paginate.js.map +1 -0
- package/dist/src/lib/platform-owned.d.ts +63 -0
- package/dist/src/lib/platform-owned.js +85 -0
- package/dist/src/lib/platform-owned.js.map +1 -0
- package/dist/src/lib/project-config.d.ts +122 -0
- package/dist/src/lib/project-config.js +244 -0
- package/dist/src/lib/project-config.js.map +1 -0
- package/dist/src/lib/prompt-cost-format.d.ts +11 -0
- package/dist/src/lib/prompt-cost-format.js +41 -0
- package/dist/src/lib/prompt-cost-format.js.map +1 -0
- package/dist/src/lib/prompt-schema-codegen.d.ts +147 -0
- package/dist/src/lib/prompt-schema-codegen.js +462 -0
- package/dist/src/lib/prompt-schema-codegen.js.map +1 -0
- package/dist/src/lib/query-operators.d.ts +43 -0
- package/dist/src/lib/query-operators.js +80 -0
- package/dist/src/lib/query-operators.js.map +1 -0
- package/dist/src/lib/record-filter.d.ts +18 -0
- package/dist/src/lib/record-filter.js +55 -0
- package/dist/src/lib/record-filter.js.map +1 -0
- package/dist/src/lib/refresh-admin-credentials.d.ts +73 -0
- package/dist/src/lib/refresh-admin-credentials.js +123 -0
- package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
- package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
- package/dist/src/lib/resolve-init-dev-port.js +55 -0
- package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
- package/dist/src/lib/resolve-init-server.d.ts +64 -0
- package/dist/src/lib/resolve-init-server.js +77 -0
- package/dist/src/lib/resolve-init-server.js.map +1 -0
- package/dist/src/lib/resolve-owner.d.ts +19 -0
- package/dist/src/lib/resolve-owner.js +20 -0
- package/dist/src/lib/resolve-owner.js.map +1 -0
- package/dist/src/lib/resolve-platform.d.ts +74 -0
- package/dist/src/lib/resolve-platform.js +105 -0
- package/dist/src/lib/resolve-platform.js.map +1 -0
- package/dist/src/lib/run-status.d.ts +19 -0
- package/dist/src/lib/run-status.generated.d.ts +39 -0
- package/dist/src/lib/run-status.generated.js +66 -0
- package/dist/src/lib/run-status.generated.js.map +1 -0
- package/dist/src/lib/run-status.js +19 -0
- package/dist/src/lib/run-status.js.map +1 -0
- package/dist/src/lib/server-text-normalization.d.ts +51 -0
- package/dist/src/lib/server-text-normalization.js +90 -0
- package/dist/src/lib/server-text-normalization.js.map +1 -0
- package/dist/src/lib/server-url.d.ts +22 -0
- package/dist/src/lib/server-url.js +33 -0
- package/dist/src/lib/server-url.js.map +1 -0
- package/dist/src/lib/signing-secret-status.d.ts +81 -0
- package/dist/src/lib/signing-secret-status.js +116 -0
- package/dist/src/lib/signing-secret-status.js.map +1 -0
- package/dist/src/lib/skill-installer.d.ts +71 -0
- package/dist/src/lib/skill-installer.js +441 -0
- package/dist/src/lib/skill-installer.js.map +1 -0
- package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
- package/dist/src/lib/snapshot-audit-source.js +58 -0
- package/dist/src/lib/snapshot-audit-source.js.map +1 -0
- package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
- package/dist/src/lib/snapshot-audit-store.js +196 -0
- package/dist/src/lib/snapshot-audit-store.js.map +1 -0
- package/dist/src/lib/snapshot-audit.d.ts +207 -0
- package/dist/src/lib/snapshot-audit.js +431 -0
- package/dist/src/lib/snapshot-audit.js.map +1 -0
- package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
- package/dist/src/lib/snapshot-build-rows.js +87 -0
- package/dist/src/lib/snapshot-build-rows.js.map +1 -0
- package/dist/src/lib/snapshot-build.d.ts +50 -0
- package/dist/src/lib/snapshot-build.js +111 -0
- package/dist/src/lib/snapshot-build.js.map +1 -0
- package/dist/src/lib/snapshot-manifest-layout.d.ts +61 -0
- package/dist/src/lib/snapshot-manifest-layout.js +70 -0
- package/dist/src/lib/snapshot-manifest-layout.js.map +1 -0
- package/dist/src/lib/snapshots.d.ts +98 -0
- package/dist/src/lib/snapshots.js +294 -0
- package/dist/src/lib/snapshots.js.map +1 -0
- package/dist/src/lib/step-run-table.d.ts +43 -0
- package/dist/src/lib/step-run-table.js +129 -0
- package/dist/src/lib/step-run-table.js.map +1 -0
- package/dist/src/lib/storage-pending-retry.d.ts +26 -0
- package/dist/src/lib/storage-pending-retry.js +42 -0
- package/dist/src/lib/storage-pending-retry.js.map +1 -0
- package/dist/src/lib/swift-codegen/agentGenerator.d.ts +42 -0
- package/dist/src/lib/swift-codegen/agentGenerator.js +118 -0
- package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/banners.d.ts +24 -0
- package/dist/src/lib/swift-codegen/banners.js +25 -0
- package/dist/src/lib/swift-codegen/banners.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js +926 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
- package/dist/src/lib/swift-codegen/functionGenerator.d.ts +139 -0
- package/dist/src/lib/swift-codegen/functionGenerator.js +462 -0
- package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/generator.d.ts +100 -0
- package/dist/src/lib/swift-codegen/generator.js +457 -0
- package/dist/src/lib/swift-codegen/generator.js.map +1 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +87 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.js +661 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
- package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
- package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
- package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
- package/dist/src/lib/sync-dir-selector.d.ts +21 -0
- package/dist/src/lib/sync-dir-selector.js +30 -0
- package/dist/src/lib/sync-dir-selector.js.map +1 -0
- package/dist/src/lib/sync-paths.d.ts +128 -0
- package/dist/src/lib/sync-paths.js +195 -0
- package/dist/src/lib/sync-paths.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +563 -0
- package/dist/src/lib/sync-resource-types.js +1073 -0
- package/dist/src/lib/sync-resource-types.js.map +1 -0
- package/dist/src/lib/sync-selectors.d.ts +138 -0
- package/dist/src/lib/sync-selectors.js +289 -0
- package/dist/src/lib/sync-selectors.js.map +1 -0
- package/dist/src/lib/template.d.ts +170 -0
- package/dist/src/lib/template.js +484 -68
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/test-case-file-names.d.ts +40 -0
- package/dist/src/lib/test-case-file-names.js +91 -0
- package/dist/src/lib/test-case-file-names.js.map +1 -0
- package/dist/src/lib/test-case-keys.d.ts +29 -0
- package/dist/src/lib/test-case-keys.js +55 -0
- package/dist/src/lib/test-case-keys.js.map +1 -0
- package/dist/src/lib/test-case-variables.d.ts +29 -0
- package/dist/src/lib/test-case-variables.js +71 -0
- package/dist/src/lib/test-case-variables.js.map +1 -0
- package/dist/src/lib/token-inject.d.ts +56 -0
- package/dist/src/lib/token-inject.js +204 -0
- package/dist/src/lib/token-inject.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +123 -0
- package/dist/src/lib/toml-database-config.js +544 -0
- package/dist/src/lib/toml-database-config.js.map +1 -0
- package/dist/src/lib/toml-metadata-config.d.ts +151 -0
- package/dist/src/lib/toml-metadata-config.js +476 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -0
- package/dist/src/lib/toml-native-form.d.ts +46 -0
- package/dist/src/lib/toml-native-form.js +78 -0
- package/dist/src/lib/toml-native-form.js.map +1 -0
- package/dist/src/lib/toml-params-validator.d.ts +129 -0
- package/dist/src/lib/toml-params-validator.js +298 -0
- package/dist/src/lib/toml-params-validator.js.map +1 -0
- package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
- package/dist/src/lib/toml-scalar-edit.js +283 -0
- package/dist/src/lib/toml-scalar-edit.js.map +1 -0
- package/dist/src/lib/user-selector.d.ts +24 -0
- package/dist/src/lib/user-selector.js +33 -0
- package/dist/src/lib/user-selector.js.map +1 -0
- package/dist/src/lib/version-check.d.ts +35 -0
- package/dist/src/lib/version-check.js +241 -0
- package/dist/src/lib/version-check.js.map +1 -0
- package/dist/src/lib/watch.d.ts +121 -0
- package/dist/src/lib/watch.js +169 -0
- package/dist/src/lib/watch.js.map +1 -0
- package/dist/src/lib/web-url.d.ts +40 -0
- package/dist/src/lib/web-url.js +76 -0
- package/dist/src/lib/web-url.js.map +1 -0
- package/dist/src/lib/webhook-deliver.d.ts +209 -0
- package/dist/src/lib/webhook-deliver.js +519 -0
- package/dist/src/lib/webhook-deliver.js.map +1 -0
- package/dist/src/lib/workflow-apply.d.ts +110 -0
- package/dist/src/lib/workflow-apply.js +164 -0
- package/dist/src/lib/workflow-apply.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
- package/dist/src/lib/workflow-codegen/generator.js +361 -0
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
- package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
- package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
- package/dist/src/lib/workflow-codegen/naming.js +81 -0
- package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/workflow-config-apply.d.ts +70 -0
- package/dist/src/lib/workflow-config-apply.js +137 -0
- package/dist/src/lib/workflow-config-apply.js.map +1 -0
- package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
- package/dist/src/lib/workflow-config-sidecar.js +96 -0
- package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
- package/dist/src/lib/workflow-defaults.d.ts +29 -0
- package/dist/src/lib/workflow-defaults.js +41 -0
- package/dist/src/lib/workflow-defaults.js.map +1 -0
- package/dist/src/lib/workflow-fragments.d.ts +64 -0
- package/dist/src/lib/workflow-fragments.js +342 -0
- package/dist/src/lib/workflow-fragments.js.map +1 -0
- package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
- package/dist/src/lib/workflow-include-preserve.js +286 -0
- package/dist/src/lib/workflow-include-preserve.js.map +1 -0
- package/dist/src/lib/workflow-payload.d.ts +98 -0
- package/dist/src/lib/workflow-payload.js +178 -0
- package/dist/src/lib/workflow-payload.js.map +1 -0
- package/dist/src/lib/workflow-toml-validator.d.ts +211 -0
- package/dist/src/lib/workflow-toml-validator.js +770 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -0
- package/dist/src/lib/workflow-usage.d.ts +196 -0
- package/dist/src/lib/workflow-usage.js +310 -0
- package/dist/src/lib/workflow-usage.js.map +1 -0
- package/dist/src/types/index.d.ts +591 -0
- package/dist/src/validators.d.ts +65 -0
- package/dist/src/validators.js +64 -0
- package/dist/src/validators.js.map +1 -0
- package/package.json +34 -9
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure string templates for the `databases codegen` generator (issue #814).
|
|
3
|
+
*
|
|
4
|
+
* FORMATTING CONTRACT (#1565): the emitted TypeScript must be a fixed point of
|
|
5
|
+
* Prettier's DEFAULT config — `prettier --write` over a generated file must
|
|
6
|
+
* leave it byte-for-byte unchanged, because `--check` byte-compares. There is
|
|
7
|
+
* no Prettier dependency and no automated round-trip test to catch a
|
|
8
|
+
* regression, so any edit here that changes line shapes must be verified by
|
|
9
|
+
* hand (regenerate a representative output, run Prettier over it, confirm no
|
|
10
|
+
* diff). Wrap long constructs through `codegen-shared/prettierStable.ts` rather
|
|
11
|
+
* than hand-joining strings — see that file's header for the full contract.
|
|
12
|
+
*
|
|
13
|
+
* Mirrors the codegen-v2 template style
|
|
14
|
+
* (`packages/js-bao/src/cli/v2/templates.ts`): total functions (no I/O, no
|
|
15
|
+
* hidden state), an auto-generated banner + fingerprint header, and
|
|
16
|
+
* deterministic ordering so `--check` can compare byte-for-byte.
|
|
17
|
+
*
|
|
18
|
+
* Diverges from codegen-v2 in two ways:
|
|
19
|
+
* 1. Database-DO records are schemaless documents, NOT `BaseModel` ORM
|
|
20
|
+
* classes — so we emit plain `export interface` types with no class
|
|
21
|
+
* shell, no barrel registration, and `import type` only.
|
|
22
|
+
* 2. We add an OPERATIONS half codegen-v2 has no analog for: per-op
|
|
23
|
+
* input-params interfaces + per-op result aliases. The alias for an op
|
|
24
|
+
* is derived from `op.type` AND, where it matters, the op's parsed
|
|
25
|
+
* `definition`: a query op's `projection` (#1439), a mutation op's step
|
|
26
|
+
* kinds (#1438), and a pipeline op's `return` step (#1437). The generator
|
|
27
|
+
* resolves those into the small descriptors below; the templates stay pure
|
|
28
|
+
* string-emitters.
|
|
29
|
+
*/
|
|
30
|
+
import { typeNodeForDbField, typeNodeForDbParamType } from "./dbTsTypes.js";
|
|
31
|
+
import { atom, generic, recordOf, renderArrowProperty, renderMember, renderParenList, renderTypeAlias, tsStringLiteral, union, } from "../codegen-shared/prettierStable.js";
|
|
32
|
+
const HEADER_BANNER = "// AUTO-GENERATED FROM database-type-configs TOML — DO NOT EDIT.";
|
|
33
|
+
const REGEN_INSTRUCTION = "// Run `primitive databases codegen <database-type>` to regenerate.";
|
|
34
|
+
/**
|
|
35
|
+
* The shared generic result shapes referenced by the per-op aliases. These
|
|
36
|
+
* mirror the runtime result shapes produced by the database-operations
|
|
37
|
+
* controller; per-op aliases point at them (and, where the definition makes the
|
|
38
|
+
* shape derivable, at a narrowed form — see `renderOpResultAlias`).
|
|
39
|
+
*/
|
|
40
|
+
export const RESULT_ALIASES_BLOCK = `// Generic per-op result shapes. These mirror the runtime result shapes
|
|
41
|
+
// produced by the database-operations controller; per-op aliases reference
|
|
42
|
+
// them (or a narrowed form when the op definition makes the shape derivable).
|
|
43
|
+
|
|
44
|
+
/** \`query\` ops return a page of records. */
|
|
45
|
+
export interface QueryResult<T = Record<string, unknown>> {
|
|
46
|
+
data: T[];
|
|
47
|
+
hasMore?: boolean;
|
|
48
|
+
nextCursor?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* One step's result inside a \`mutation\` op's uniform response (#1458).
|
|
53
|
+
* \`op\` is the step kind; \`id\` is the record id (the resolved canonical id for
|
|
54
|
+
* \`upsertOn\` saves). \`values\` carries an \`increment\` step's post-increment
|
|
55
|
+
* counters; \`error\` a per-step failure string.
|
|
56
|
+
*/
|
|
57
|
+
export interface MutationStepResult {
|
|
58
|
+
op: "save" | "patch" | "delete" | "increment" | "addToSet" | "removeFromSet";
|
|
59
|
+
success: boolean;
|
|
60
|
+
id: string;
|
|
61
|
+
values?: Record<string, number>;
|
|
62
|
+
error?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Every \`mutation\` op returns a uniform \`{ results: MutationStepResult[] }\`
|
|
67
|
+
* in DEFINITION-STEP order — one entry per step, tagged with its \`op\` kind and
|
|
68
|
+
* record \`id\` (#1458). This is a SUCCESS-PATH guarantee: a step that fails at
|
|
69
|
+
* the HTTP level surfaces as an error, and committed sibling writes in the same
|
|
70
|
+
* op are not reported (the ops are not yet executed atomically — see #1478).
|
|
71
|
+
*/
|
|
72
|
+
export interface MutationResult {
|
|
73
|
+
results: MutationStepResult[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** \`count\` ops return a single count. */
|
|
77
|
+
export interface CountResult {
|
|
78
|
+
count: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** \`aggregate\` ops return a single result object. */
|
|
82
|
+
export interface AggregateResult {
|
|
83
|
+
result: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** \`applyToQuery\` ops return match/affect/fail counts. */
|
|
87
|
+
export interface ApplyToQueryResult {
|
|
88
|
+
matched: number;
|
|
89
|
+
affected: number;
|
|
90
|
+
failed: number;
|
|
91
|
+
sample?: unknown[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** \`pipeline\` ops return per-step results keyed by step name. */
|
|
95
|
+
export interface PipelineResult {
|
|
96
|
+
steps: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
/**
|
|
100
|
+
* Render the header (banner + regen hint + fingerprint).
|
|
101
|
+
*/
|
|
102
|
+
export function renderHeader(fingerprint) {
|
|
103
|
+
return [
|
|
104
|
+
HEADER_BANNER,
|
|
105
|
+
REGEN_INSTRUCTION,
|
|
106
|
+
`// fingerprint: ${fingerprint}`,
|
|
107
|
+
].join("\n");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Render a single record interface (read shape). Stamped fields
|
|
111
|
+
* (`createdAt`, `modifiedAt`, `ownerId`, …) are appended as OPTIONAL props
|
|
112
|
+
* if not already present in `fields`.
|
|
113
|
+
*/
|
|
114
|
+
export function renderRecordInterface(input) {
|
|
115
|
+
const { interfaceName, fields, stampedFields } = input;
|
|
116
|
+
const memberLines = [];
|
|
117
|
+
const declared = new Set();
|
|
118
|
+
for (const f of fields) {
|
|
119
|
+
declared.add(f.name);
|
|
120
|
+
memberLines.push(renderMember(1, f.name, !f.required, typeNodeForDbField(f.type, f.enum)));
|
|
121
|
+
}
|
|
122
|
+
// Server-stamped fields appear on the read interface as optional —
|
|
123
|
+
// the runtime populates them, but a freshly-built object may not have
|
|
124
|
+
// them yet, so claiming them as required would be a type lie.
|
|
125
|
+
for (const stamped of stampedFields) {
|
|
126
|
+
if (declared.has(stamped))
|
|
127
|
+
continue;
|
|
128
|
+
declared.add(stamped);
|
|
129
|
+
memberLines.push(` ${stamped}?: string;`);
|
|
130
|
+
}
|
|
131
|
+
// A record with no fields and no stamped fields would render an empty
|
|
132
|
+
// `interface X {}`, which trips `@typescript-eslint/no-empty-object-type`.
|
|
133
|
+
// Emit a `Record<string, unknown>` type alias instead. Database-DO records
|
|
134
|
+
// are SCHEMALESS — arbitrary runtime keys can exist — so the empty-schema
|
|
135
|
+
// shape must stay OPEN (`Record<string, unknown>`), NOT `Record<string,
|
|
136
|
+
// never>`. `Record<string, never>` forbids every key, which would make real
|
|
137
|
+
// returned records unassignable to `QueryResult<X>` and unusable in TS.
|
|
138
|
+
// (Contrast with the no-param-op case in `renderOpParamsInterface`, where
|
|
139
|
+
// `Record<string, never>` is correct: it means "no params allowed".)
|
|
140
|
+
if (memberLines.length === 0) {
|
|
141
|
+
return renderTypeAlias(interfaceName, recordOf("unknown"));
|
|
142
|
+
}
|
|
143
|
+
const lines = [];
|
|
144
|
+
lines.push(`export interface ${interfaceName} {`);
|
|
145
|
+
lines.push(...memberLines);
|
|
146
|
+
lines.push(`}`);
|
|
147
|
+
return lines.join("\n");
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Render a single op-input-params interface (write shape). `required: true`
|
|
151
|
+
* params are non-optional; others are optional. `object` params render as
|
|
152
|
+
* `Record<string, any>`.
|
|
153
|
+
*/
|
|
154
|
+
export function renderOpParamsInterface(input) {
|
|
155
|
+
const { interfaceName, params } = input;
|
|
156
|
+
// An op with no declared params has no input shape. Emitting an empty
|
|
157
|
+
// `interface X {}` trips `@typescript-eslint/no-empty-object-type`, so
|
|
158
|
+
// render a `Record<string, never>` type alias instead — it types "no
|
|
159
|
+
// params allowed" and stays call-site compatible (`op({})`).
|
|
160
|
+
if (params.length === 0) {
|
|
161
|
+
return renderTypeAlias(interfaceName, recordOf("never"));
|
|
162
|
+
}
|
|
163
|
+
const lines = [];
|
|
164
|
+
lines.push(`export interface ${interfaceName} {`);
|
|
165
|
+
for (const p of params) {
|
|
166
|
+
lines.push(renderMember(1, p.name, !p.required, typeNodeForDbParamType(p.type, p.enum, p.items)));
|
|
167
|
+
}
|
|
168
|
+
lines.push(`}`);
|
|
169
|
+
return lines.join("\n");
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Compute the generic argument for a `QueryResult<...>` from the op's record
|
|
173
|
+
* interface + projection classification (#1439). Reused for a pipeline op's
|
|
174
|
+
* returning `query` step (#1437), so both type identically to a plain query.
|
|
175
|
+
*
|
|
176
|
+
* A null record interface (the op's model has no `[models.*]` schema) has
|
|
177
|
+
* nothing to `Pick` from, so it always falls back to
|
|
178
|
+
* `Record<string, unknown>` regardless of any projection.
|
|
179
|
+
*/
|
|
180
|
+
function queryResultGeneric(recordInterfaceName, projection) {
|
|
181
|
+
if (recordInterfaceName === null)
|
|
182
|
+
return recordOf("unknown");
|
|
183
|
+
const record = atom(recordInterfaceName);
|
|
184
|
+
const p = projection ?? { kind: "full" };
|
|
185
|
+
switch (p.kind) {
|
|
186
|
+
case "full":
|
|
187
|
+
return record;
|
|
188
|
+
case "partial":
|
|
189
|
+
return generic("Partial", [record]);
|
|
190
|
+
case "pick": {
|
|
191
|
+
// The generator guarantees a non-empty, field-guarded, sorted list; a
|
|
192
|
+
// defensive empty check keeps this total. Field names are emitted as TS
|
|
193
|
+
// string literals via JSON.stringify.
|
|
194
|
+
if (p.fields.length === 0)
|
|
195
|
+
return record;
|
|
196
|
+
return generic("Pick", [record, fieldNameUnion(p.fields)]);
|
|
197
|
+
}
|
|
198
|
+
case "omit": {
|
|
199
|
+
// Static all-exclusion over known members (id/type already filtered out by
|
|
200
|
+
// the generator). The classifier guarantees a non-empty, sorted, member-
|
|
201
|
+
// guarded list; the defensive empty check keeps this total. Same literal
|
|
202
|
+
// emission style as `pick`.
|
|
203
|
+
if (p.fields.length === 0)
|
|
204
|
+
return record;
|
|
205
|
+
return generic("Omit", [record, fieldNameUnion(p.fields)]);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/** A `Pick`/`Omit` key union (`"a" | "b"`), wrappable when it gets long. */
|
|
210
|
+
export function fieldNameUnion(fields) {
|
|
211
|
+
return union(fields.map((f) => atom(JSON.stringify(f))));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Render a per-op result alias. The alias is derived from `op.type` and, where
|
|
215
|
+
* the shape is derivable from the parsed op definition, a narrowed form:
|
|
216
|
+
* - `query` → `QueryResult<M>`, narrowed by the op `projection` (#1439).
|
|
217
|
+
* - `mutation` → `MutationResult` — every mutation op returns the uniform
|
|
218
|
+
* `{ results: MutationStepResult[] }` in definition order (#1458).
|
|
219
|
+
* - `pipeline` → the returned step's result type (#1437); `return: "all"` /
|
|
220
|
+
* no-return / unresolvable keep the generic `PipelineResult`.
|
|
221
|
+
*/
|
|
222
|
+
export function renderOpResultAlias(input) {
|
|
223
|
+
const { aliasName, opType, recordInterfaceName, projection } = input;
|
|
224
|
+
const alias = (node) => renderTypeAlias(aliasName, node);
|
|
225
|
+
switch (opType) {
|
|
226
|
+
case "query":
|
|
227
|
+
return alias(generic("QueryResult", [
|
|
228
|
+
queryResultGeneric(recordInterfaceName, projection),
|
|
229
|
+
]));
|
|
230
|
+
case "mutation":
|
|
231
|
+
// Every mutation op returns the uniform `{ results: MutationStepResult[] }`
|
|
232
|
+
// in definition-step order (#1458) — no more per-category flat shapes.
|
|
233
|
+
return alias(atom("MutationResult"));
|
|
234
|
+
case "count":
|
|
235
|
+
return alias(atom("CountResult"));
|
|
236
|
+
case "aggregate":
|
|
237
|
+
return alias(atom("AggregateResult"));
|
|
238
|
+
case "applyToQuery":
|
|
239
|
+
return alias(atom("ApplyToQueryResult"));
|
|
240
|
+
case "pipeline": {
|
|
241
|
+
const d = input.pipelineReturn ?? { kind: "opaque" };
|
|
242
|
+
switch (d.kind) {
|
|
243
|
+
case "query":
|
|
244
|
+
return alias(generic("QueryResult", [
|
|
245
|
+
queryResultGeneric(d.recordInterfaceName, d.projection),
|
|
246
|
+
]));
|
|
247
|
+
case "count":
|
|
248
|
+
return alias(atom("CountResult"));
|
|
249
|
+
case "aggregate":
|
|
250
|
+
return alias(atom("AggregateResult"));
|
|
251
|
+
// `opaque` — `return: "all"`, no `return`, or a step the generator
|
|
252
|
+
// couldn't resolve — keeps the generic `PipelineResult` (unchanged).
|
|
253
|
+
case "opaque":
|
|
254
|
+
default:
|
|
255
|
+
return alias(atom("PipelineResult"));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
default:
|
|
259
|
+
// Unknown op type — emit a permissive alias rather than throwing,
|
|
260
|
+
// so one stray op doesn't block codegen for the whole file.
|
|
261
|
+
return alias(atom("unknown"));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// The `databases.executeOperation<R>` member on the structural client shape.
|
|
265
|
+
// `object` (not `Record<string, unknown>`) so a strict generated `<Op>Params`
|
|
266
|
+
// interface — which has no index signature — is still assignable here.
|
|
267
|
+
const EXECUTE_OPERATION_MEMBER = [
|
|
268
|
+
" executeOperation<R>(",
|
|
269
|
+
" databaseId: string,",
|
|
270
|
+
" name: string,",
|
|
271
|
+
" options?: {",
|
|
272
|
+
" params?: object;",
|
|
273
|
+
" limit?: number;",
|
|
274
|
+
" cursor?: string;",
|
|
275
|
+
" direction?: 1 | -1;",
|
|
276
|
+
" timing?: boolean;",
|
|
277
|
+
" },",
|
|
278
|
+
" ): Promise<R>;",
|
|
279
|
+
];
|
|
280
|
+
// The `databases.subscribe<T>` member on the structural client shape
|
|
281
|
+
// (#1544 Phase 2). Mirrors the client's `subscribe<T, P>` closely enough that
|
|
282
|
+
// the real `JsBaoClient` satisfies it structurally; `P` defaults there so the
|
|
283
|
+
// single generic here is compatible.
|
|
284
|
+
const SUBSCRIBE_MEMBER = [
|
|
285
|
+
" subscribe<T>(",
|
|
286
|
+
" databaseId: string,",
|
|
287
|
+
" subscriptionKey: string,",
|
|
288
|
+
" options: SubscribeOptions<T>,",
|
|
289
|
+
" ): () => void;",
|
|
290
|
+
];
|
|
291
|
+
// Non-param options (pagination + diagnostics) each ops factory method accepts.
|
|
292
|
+
const OPS_CALL_OPTIONS_BLOCK = [
|
|
293
|
+
"// Non-param options (pagination + diagnostics) each factory method accepts",
|
|
294
|
+
"// alongside its params, passed straight through to `executeOperation`.",
|
|
295
|
+
"interface OpsCallOptions {",
|
|
296
|
+
" limit?: number;",
|
|
297
|
+
" cursor?: string;",
|
|
298
|
+
" direction?: 1 | -1;",
|
|
299
|
+
" timing?: boolean;",
|
|
300
|
+
"}",
|
|
301
|
+
].join("\n");
|
|
302
|
+
// Inlined structural subscribe types (#1544 Phase 2) — import-free mirrors of
|
|
303
|
+
// the client's `DatabaseSubscribeOptions` / `DatabaseChangePayload` /
|
|
304
|
+
// `DatabaseChangeEvent`. `T` is the record type bound to each change; a
|
|
305
|
+
// projected subscription binds `T` to a `Pick<Record, …select>`.
|
|
306
|
+
const SUBSCRIBE_TYPES_BLOCK = [
|
|
307
|
+
"interface SubscribeOptions<T> {",
|
|
308
|
+
" params?: Record<string, any>;",
|
|
309
|
+
" onChange: (event: SubscribeChangePayload<T>) => void;",
|
|
310
|
+
"}",
|
|
311
|
+
"interface SubscribeChangePayload<T> {",
|
|
312
|
+
' type: "db.change";',
|
|
313
|
+
" databaseId: string;",
|
|
314
|
+
" subscriptionKey: string;",
|
|
315
|
+
" changes: SubscribeChangeEvent<T>[];",
|
|
316
|
+
" timestamp: string;",
|
|
317
|
+
" originConnectionId: string | null;",
|
|
318
|
+
" originUserId: string | null;",
|
|
319
|
+
" isOrigin: boolean;",
|
|
320
|
+
" isOriginUser: boolean;",
|
|
321
|
+
"}",
|
|
322
|
+
"interface SubscribeChangeEvent<T> {",
|
|
323
|
+
' changeType?: "enter" | "update" | "leave";',
|
|
324
|
+
' op: "save" | "patch" | "delete" | "increment" | "addToSet" | "removeFromSet";',
|
|
325
|
+
" modelName: string;",
|
|
326
|
+
" id: string;",
|
|
327
|
+
" data?: T | null;",
|
|
328
|
+
" previousData?: T | null;",
|
|
329
|
+
"}",
|
|
330
|
+
].join("\n");
|
|
331
|
+
/**
|
|
332
|
+
* The inlined structural client shape, carrying whichever members the file
|
|
333
|
+
* needs (`executeOperation` for ops, `subscribe` for subscriptions). One shared
|
|
334
|
+
* `OpsClient` interface serves both the `<type>Ops` and `<type>Subscriptions`
|
|
335
|
+
* factories so the file never declares the interface twice.
|
|
336
|
+
*/
|
|
337
|
+
function renderClientInterface(members) {
|
|
338
|
+
return [
|
|
339
|
+
"// Minimal structural client shape — inlined so this file stays import-free",
|
|
340
|
+
"// and carries no runtime dependency on the client package. The real",
|
|
341
|
+
"// `JsBaoClient` satisfies it structurally.",
|
|
342
|
+
"interface OpsClient {",
|
|
343
|
+
" databases: {",
|
|
344
|
+
...members,
|
|
345
|
+
" };",
|
|
346
|
+
"}",
|
|
347
|
+
].join("\n");
|
|
348
|
+
}
|
|
349
|
+
/** One factory method per op, pairing `<Op>Params` in with `<Op>Result` out. */
|
|
350
|
+
function opsMethodLines(ops) {
|
|
351
|
+
return ops.map((op) => {
|
|
352
|
+
const nameLiteral = JSON.stringify(op.opName);
|
|
353
|
+
// No declared params: the method takes only the optional options object, so
|
|
354
|
+
// it stays callable with no arguments (`ops.foo()`).
|
|
355
|
+
const params = op.hasParams
|
|
356
|
+
? [`params: ${op.paramsInterfaceName}`, "options?: OpsCallOptions"]
|
|
357
|
+
: ["options?: OpsCallOptions"];
|
|
358
|
+
return renderArrowProperty({
|
|
359
|
+
level: 2,
|
|
360
|
+
key: op.propertyKey,
|
|
361
|
+
params,
|
|
362
|
+
signatureTail: `: Promise<${op.resultAliasName}> =>`,
|
|
363
|
+
callee: generic("client.databases.executeOperation", [
|
|
364
|
+
atom(op.resultAliasName),
|
|
365
|
+
]),
|
|
366
|
+
leadingArgs: ["databaseId", nameLiteral],
|
|
367
|
+
objectMembers: op.hasParams ? ["params", "...options"] : ["...options"],
|
|
368
|
+
tail: ",",
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
/** The `export function <type>Ops(...)` factory body. */
|
|
373
|
+
function opsFactoryBlock(factoryName, databaseType, ops) {
|
|
374
|
+
return [
|
|
375
|
+
`/** Typed accessor for \`${databaseType}\` operations. */`,
|
|
376
|
+
renderParenList(`export function ${factoryName}`, ["client: OpsClient", "databaseId: string"], " {", 0),
|
|
377
|
+
" return {",
|
|
378
|
+
...opsMethodLines(ops),
|
|
379
|
+
" };",
|
|
380
|
+
"}",
|
|
381
|
+
].join("\n");
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Render the typed-operations factory (#1441): an inlined structural client
|
|
385
|
+
* interface + a shared call-options type + the `export function <type>Ops`
|
|
386
|
+
* factory. Each method pairs an op's `<Op>Params` input with its `<Op>Result`
|
|
387
|
+
* output and calls `client.databases.executeOperation<<Op>Result>(...)`, so the
|
|
388
|
+
* generated code carries no `as` cast and no import — the real `JsBaoClient`
|
|
389
|
+
* satisfies the structural `OpsClient` param.
|
|
390
|
+
*
|
|
391
|
+
* Returns "" for a database type with no operations, so the caller can omit the
|
|
392
|
+
* factory entirely rather than emit an empty function.
|
|
393
|
+
*/
|
|
394
|
+
export function renderOpsFactory(input) {
|
|
395
|
+
const { factoryName, databaseType, ops } = input;
|
|
396
|
+
if (ops.length === 0)
|
|
397
|
+
return "";
|
|
398
|
+
return [
|
|
399
|
+
renderClientInterface(EXECUTE_OPERATION_MEMBER),
|
|
400
|
+
OPS_CALL_OPTIONS_BLOCK,
|
|
401
|
+
opsFactoryBlock(factoryName, databaseType, ops),
|
|
402
|
+
].join("\n\n");
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* The `export function <type>Subscriptions(...)` factory body.
|
|
406
|
+
*
|
|
407
|
+
* Each method is a `key: (options) => client.databases.subscribe<T>(...)` arrow
|
|
408
|
+
* routed through `renderArrowProperty` (#1678), so its signature and the
|
|
409
|
+
* `subscribe(...)` call are a fixed point of Prettier's default config at every
|
|
410
|
+
* subscription-key length. The `subscribe` call carries NO trailing object-
|
|
411
|
+
* literal argument (`objectMembers` omitted); `eventType` is a `TypeNode`, so a
|
|
412
|
+
* `Pick<...>` projection breaks inside `SubscribeOptions<...>` / the type
|
|
413
|
+
* argument the way Prettier breaks it. The subscription key literal uses
|
|
414
|
+
* `tsStringLiteral` (Prettier's fewer-escapes quote choice), not
|
|
415
|
+
* `JSON.stringify`.
|
|
416
|
+
*/
|
|
417
|
+
function subscriptionsFactoryBlock(factoryName, databaseType, subscriptions) {
|
|
418
|
+
const methodLines = subscriptions.map((sub) => renderArrowProperty({
|
|
419
|
+
level: 2,
|
|
420
|
+
key: sub.propertyKey,
|
|
421
|
+
params: [{ name: "options", type: generic("SubscribeOptions", [sub.eventType]) }],
|
|
422
|
+
signatureTail: ": (() => void) =>",
|
|
423
|
+
callee: generic("client.databases.subscribe", [sub.eventType]),
|
|
424
|
+
leadingArgs: [
|
|
425
|
+
"databaseId",
|
|
426
|
+
tsStringLiteral(sub.subscriptionKey),
|
|
427
|
+
"options",
|
|
428
|
+
],
|
|
429
|
+
tail: ",",
|
|
430
|
+
}));
|
|
431
|
+
return [
|
|
432
|
+
`/** Typed accessor for \`${databaseType}\` realtime subscriptions. */`,
|
|
433
|
+
renderParenList(`export function ${factoryName}`, ["client: OpsClient", "databaseId: string"], " {", 0),
|
|
434
|
+
" return {",
|
|
435
|
+
...methodLines,
|
|
436
|
+
" };",
|
|
437
|
+
"}",
|
|
438
|
+
].join("\n");
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Render the typed-ops factory (#1441) and the typed-subscriptions factory
|
|
442
|
+
* (#1544 Phase 2) for one database type, sharing a single structural `OpsClient`
|
|
443
|
+
* interface (Fork 4 = A).
|
|
444
|
+
*
|
|
445
|
+
* With no subscriptions this is byte-identical to {@link renderOpsFactory}, so
|
|
446
|
+
* every existing generated file (none of which has subscriptions) is unchanged.
|
|
447
|
+
* When subscriptions exist, the shared `OpsClient` gains a `subscribe<T>`
|
|
448
|
+
* member, the inlined subscribe types are emitted once, and a separate
|
|
449
|
+
* `<type>Subscriptions` factory follows the ops factory. The file stays
|
|
450
|
+
* import-free (behavior 10).
|
|
451
|
+
*
|
|
452
|
+
* Returns "" when the type has neither ops nor subscriptions.
|
|
453
|
+
*/
|
|
454
|
+
export function renderFactories(input) {
|
|
455
|
+
const { databaseType, ops, subscriptions } = input;
|
|
456
|
+
// No subscriptions → identical to the standalone ops factory (keeps every
|
|
457
|
+
// pre-#1544 generated file byte-for-byte unchanged).
|
|
458
|
+
if (subscriptions.length === 0) {
|
|
459
|
+
return renderOpsFactory({
|
|
460
|
+
factoryName: input.opsFactoryName,
|
|
461
|
+
databaseType,
|
|
462
|
+
ops,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
const hasOps = ops.length > 0;
|
|
466
|
+
const members = [
|
|
467
|
+
...(hasOps ? EXECUTE_OPERATION_MEMBER : []),
|
|
468
|
+
...SUBSCRIBE_MEMBER,
|
|
469
|
+
];
|
|
470
|
+
const blocks = [renderClientInterface(members)];
|
|
471
|
+
if (hasOps)
|
|
472
|
+
blocks.push(OPS_CALL_OPTIONS_BLOCK);
|
|
473
|
+
blocks.push(SUBSCRIBE_TYPES_BLOCK);
|
|
474
|
+
if (hasOps) {
|
|
475
|
+
blocks.push(opsFactoryBlock(input.opsFactoryName, databaseType, ops));
|
|
476
|
+
}
|
|
477
|
+
blocks.push(subscriptionsFactoryBlock(input.subscriptionsFactoryName, databaseType, subscriptions));
|
|
478
|
+
return blocks.join("\n\n");
|
|
479
|
+
}
|
|
480
|
+
//# sourceMappingURL=dbTemplates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbTemplates.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbTemplates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,KAAK,GAEN,MAAM,qCAAqC,CAAC;AAE7C,MAAM,aAAa,GACjB,kEAAkE,CAAC;AACrE,MAAM,iBAAiB,GACrB,qEAAqE,CAAC;AAqHxE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;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,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map database-type TOML field/param types → TypeScript types for the
|
|
3
|
+
* `databases codegen` generator (issue #814).
|
|
4
|
+
*
|
|
5
|
+
* The record-interface half reuses the SAME `FieldType` vocabulary that
|
|
6
|
+
* powers the document-model codegen-v2 generator
|
|
7
|
+
* (`packages/js-bao/src/cli/v2/tsTypes.ts`): the database-type
|
|
8
|
+
* `[models.<m>.fields.<f>]` blocks round-trip through the same
|
|
9
|
+
* `loadSchemaFromTomlString` loader, so the field→TS mapping is identical
|
|
10
|
+
* (`string|id|date → string`, `number → number`, `boolean → boolean`,
|
|
11
|
+
* `stringset → StringSet`).
|
|
12
|
+
*
|
|
13
|
+
* The op-params half maps the operation `params.{type}` vocabulary
|
|
14
|
+
* (`string|number|boolean|object`, validated server-side in
|
|
15
|
+
* `database-type-operations-controller.ts`). `object` has no field-type
|
|
16
|
+
* analog and carries no nested schema, so it renders as `Record<string, unknown>`.
|
|
17
|
+
*
|
|
18
|
+
* NOTE (#842 — infer required record fields from operation params): when that
|
|
19
|
+
* issue is scheduled, the op-params analysis it needs (which fields a `$params.X`
|
|
20
|
+
* binding writes, and whether the param is `required`) already exists in
|
|
21
|
+
* `inferParamFieldTypes(op)` in
|
|
22
|
+
* `src/app-api/controllers/database-type-config-controller.ts` (issue #845 /
|
|
23
|
+
* #812 Phase 2). Its return shape was deliberately made growable (it can carry
|
|
24
|
+
* a `requiredInThisOp` flag) so it can be lifted into a shared `analyzeOpParams`
|
|
25
|
+
* pass consumed by BOTH the scaffold (#845, field *type*) and codegen (#842,
|
|
26
|
+
* field *required-ness*). Lift it rather than re-walking the ops here.
|
|
27
|
+
*/
|
|
28
|
+
import { type TypeNode } from "../codegen-shared/prettierStable.js";
|
|
29
|
+
/**
|
|
30
|
+
* Field types accepted in a database-type `[models.*]` schema. Mirrors
|
|
31
|
+
* `FieldType` in `packages/js-bao/src/types/ormTypes.ts`. Declared locally
|
|
32
|
+
* (rather than imported from `js-bao`) because `FieldType` is not part of
|
|
33
|
+
* the published `js-bao` entry point and the CLI does not depend on the
|
|
34
|
+
* library's internal type paths.
|
|
35
|
+
*/
|
|
36
|
+
export type DbFieldType = "string" | "number" | "boolean" | "date" | "id" | "stringset";
|
|
37
|
+
/**
|
|
38
|
+
* Param types accepted in an `[[operations]]` `params` block. `array` (#1488)
|
|
39
|
+
* carries a scalar `items` element type; `integer` (also surfaced in #1488 when
|
|
40
|
+
* reconciling the registration/runtime type lists) maps to `number`.
|
|
41
|
+
*/
|
|
42
|
+
export type DbParamType = "string" | "number" | "boolean" | "integer" | "object" | "array";
|
|
43
|
+
/**
|
|
44
|
+
* Returns the TS type expression for a record field type. Unknown types
|
|
45
|
+
* fall back to `unknown` rather than throwing: the database-type TOML is
|
|
46
|
+
* author-curated and may legitimately carry a field type the CLI's vendored
|
|
47
|
+
* vocabulary predates, and a hard throw would block codegen for the whole
|
|
48
|
+
* file over one unrecognized field.
|
|
49
|
+
*/
|
|
50
|
+
export declare function tsTypeForDbFieldType(fieldType: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the TS type expression for a record field as a wrappable node,
|
|
53
|
+
* honoring an optional string `enum` allowed-value set (#843). A non-empty
|
|
54
|
+
* `enum` on a `string` field renders a string-literal union (a long one in
|
|
55
|
+
* Prettier's leading-pipe form, #1565); otherwise falls back to the base
|
|
56
|
+
* `tsTypeForDbFieldType` mapping.
|
|
57
|
+
*/
|
|
58
|
+
export declare function typeNodeForDbField(fieldType: string, enumValues?: string[]): TypeNode;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the TS type expression for an op param as a wrappable node, honoring
|
|
61
|
+
* an optional string `enum` allowed-value set (#861). A non-empty `enum` on a
|
|
62
|
+
* `string` param renders a string-literal union (`"a" | "b"`; a long one in
|
|
63
|
+
* Prettier's leading-pipe form, #1565); otherwise falls back to the base
|
|
64
|
+
* param-type mapping below. Mirrors `typeNodeForDbField` (the record-field
|
|
65
|
+
* sibling) and reuses `unionNodeFromEnum` for a single escaping implementation.
|
|
66
|
+
*
|
|
67
|
+
* Unlike the record-field path (validated upstream by `parseFieldOptions`,
|
|
68
|
+
* which throws), op-param enum *shape* is validated server-side in
|
|
69
|
+
* `validateParams` at config-push time. So this renderer just falls back to
|
|
70
|
+
* the base type for a non-string param or an empty enum rather than throwing —
|
|
71
|
+
* the server is the source of truth for rejecting a malformed param `enum`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function typeNodeForDbParamType(paramType: string, enumValues?: string[], items?: string): TypeNode;
|