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,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short fingerprint for a database-type TOML string (issue #814).
|
|
3
|
+
*
|
|
4
|
+
* Stamped in the header of every generated file so a human (or the
|
|
5
|
+
* `--check` CI guard) can tell at a glance whether the source TOML and the
|
|
6
|
+
* generated output are in sync. Mirrors codegen-v2's `fingerprintToml`
|
|
7
|
+
* (`packages/js-bao/src/cli/v2/fingerprint.ts`): 16 hex chars of SHA-256 —
|
|
8
|
+
* enough for a sanity check, short enough to fit on one comment line.
|
|
9
|
+
*/
|
|
10
|
+
import { createHash } from "crypto";
|
|
11
|
+
export function fingerprintToml(tomlContent) {
|
|
12
|
+
return createHash("sha256")
|
|
13
|
+
.update(tomlContent, "utf-8")
|
|
14
|
+
.digest("hex")
|
|
15
|
+
.slice(0, 16);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=dbFingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbFingerprint.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbFingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,UAAU,eAAe,CAAC,WAAmB;IACjD,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC;SAC5B,MAAM,CAAC,KAAK,CAAC;SACb,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `databases codegen` orchestrator (issue #814).
|
|
3
|
+
*
|
|
4
|
+
* Pure-ish core: given a set of database-type TOML strings + a target
|
|
5
|
+
* output dir, decides what `*.generated.ts` files to write (in memory),
|
|
6
|
+
* then either (a) writes them, or (b) compares them against on-disk for
|
|
7
|
+
* `--check`. No commander dependency, no `process.exit`.
|
|
8
|
+
*
|
|
9
|
+
* The op/record RESOLUTION (parse, schema load, required-ness inference, op
|
|
10
|
+
* params, and per-op result descriptors) lives in the shared, naming-neutral
|
|
11
|
+
* `describeDbType` IR (`dbTypeIR.ts`) — the SAME source the Swift renderer
|
|
12
|
+
* (`swift-codegen/dbGenerator.ts`) consumes (issue #1547 binding 5). This file
|
|
13
|
+
* is now purely the TS *rendering* half: it applies TS identifier naming
|
|
14
|
+
* (`resolveRecordInterfaceName`, `opParamsInterfaceName`, …) to that IR and
|
|
15
|
+
* emits `*.generated.ts` via the pure `dbTemplates` string-emitters. The
|
|
16
|
+
* emitted bytes are unchanged from the former inline implementation.
|
|
17
|
+
*/
|
|
18
|
+
import { type GeneratedFileMismatch } from "../codegen-shared/generatedFiles.js";
|
|
19
|
+
import { type DbCodegenInput } from "./dbTypeIR.js";
|
|
20
|
+
export type { DbCodegenInput } from "./dbTypeIR.js";
|
|
21
|
+
export { inferArrayParamElementTypes, inferRequiredRecordFields, type InferredRecordModelInfo, } from "./dbTypeIR.js";
|
|
22
|
+
export interface GenerateDbTypesOptions {
|
|
23
|
+
/** One entry per database-type TOML file to generate from. */
|
|
24
|
+
inputs: DbCodegenInput[];
|
|
25
|
+
/** Directory where `<type>.generated.ts` files are written. */
|
|
26
|
+
outputDir: string;
|
|
27
|
+
/**
|
|
28
|
+
* If true, do not write to disk. Compare the would-be output to what's on
|
|
29
|
+
* disk and return a non-empty `mismatches` list if any file would change.
|
|
30
|
+
*/
|
|
31
|
+
check?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Set when the run was filtered to a single database type (the
|
|
34
|
+
* `primitive databases codegen <type>` argument). The `inputs` set is then
|
|
35
|
+
* PARTIAL — it does not represent the full set of owned generated files — so
|
|
36
|
+
* stale-output cleanup (and `--check` stale detection) must be scoped to the
|
|
37
|
+
* filtered type's own file and must NOT touch / flag sibling types'
|
|
38
|
+
* `*.generated.ts` files. The unfiltered "generate all" run leaves this unset
|
|
39
|
+
* and keeps full orphan cleanup.
|
|
40
|
+
*/
|
|
41
|
+
singleType?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface DbCodegenResult {
|
|
44
|
+
/** Files written (or that would be written under `--check`). */
|
|
45
|
+
writtenFiles: string[];
|
|
46
|
+
/** Stale `*.generated.ts` files deleted (or flagged stale under `--check`). */
|
|
47
|
+
deletedFiles: string[];
|
|
48
|
+
/** Only populated under `--check`: files whose on-disk content is out of date. */
|
|
49
|
+
mismatches: DbCheckMismatch[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Re-exported from the shared generated-file module so existing importers keep
|
|
53
|
+
* a stable type. The write/`--check`/cleanup lifecycle now lives in
|
|
54
|
+
* `codegen-shared/generatedFiles.ts` (shared with `workflows codegen`).
|
|
55
|
+
*/
|
|
56
|
+
export type DbCheckMismatch = GeneratedFileMismatch;
|
|
57
|
+
/**
|
|
58
|
+
* Render the in-memory `.generated.ts` content for a single database-type
|
|
59
|
+
* TOML. Exported so tests can assert on the rendered string directly.
|
|
60
|
+
*/
|
|
61
|
+
export declare function renderDbTypeFile(input: DbCodegenInput): string;
|
|
62
|
+
/**
|
|
63
|
+
* Run codegen end-to-end across one or more database-type TOML inputs. The
|
|
64
|
+
* disk lifecycle (write / `--check` / stale cleanup) is delegated to the
|
|
65
|
+
* shared `writeOrCheckGeneratedFiles` (shared with `workflows codegen`).
|
|
66
|
+
*/
|
|
67
|
+
export declare function generateDbTypes(options: GenerateDbTypesOptions): Promise<DbCodegenResult>;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `databases codegen` orchestrator (issue #814).
|
|
3
|
+
*
|
|
4
|
+
* Pure-ish core: given a set of database-type TOML strings + a target
|
|
5
|
+
* output dir, decides what `*.generated.ts` files to write (in memory),
|
|
6
|
+
* then either (a) writes them, or (b) compares them against on-disk for
|
|
7
|
+
* `--check`. No commander dependency, no `process.exit`.
|
|
8
|
+
*
|
|
9
|
+
* The op/record RESOLUTION (parse, schema load, required-ness inference, op
|
|
10
|
+
* params, and per-op result descriptors) lives in the shared, naming-neutral
|
|
11
|
+
* `describeDbType` IR (`dbTypeIR.ts`) — the SAME source the Swift renderer
|
|
12
|
+
* (`swift-codegen/dbGenerator.ts`) consumes (issue #1547 binding 5). This file
|
|
13
|
+
* is now purely the TS *rendering* half: it applies TS identifier naming
|
|
14
|
+
* (`resolveRecordInterfaceName`, `opParamsInterfaceName`, …) to that IR and
|
|
15
|
+
* emits `*.generated.ts` via the pure `dbTemplates` string-emitters. The
|
|
16
|
+
* emitted bytes are unchanged from the former inline implementation.
|
|
17
|
+
*/
|
|
18
|
+
import * as path from "path";
|
|
19
|
+
import { writeOrCheckGeneratedFiles, } from "../codegen-shared/generatedFiles.js";
|
|
20
|
+
import { describeDbType, } from "./dbTypeIR.js";
|
|
21
|
+
import { resolveRecordInterfaceName, opParamsInterfaceName, opResultAliasName, opsFactoryName, subscriptionsFactoryName, objectPropertyKey, } from "./dbNaming.js";
|
|
22
|
+
import { renderHeader, renderRecordInterface, renderOpParamsInterface, renderOpResultAlias, renderFactories, fieldNameUnion, RESULT_ALIASES_BLOCK, } from "./dbTemplates.js";
|
|
23
|
+
import { atom, generic } from "../codegen-shared/prettierStable.js";
|
|
24
|
+
export { inferArrayParamElementTypes, inferRequiredRecordFields, } from "./dbTypeIR.js";
|
|
25
|
+
const GENERATED_FILE_SUFFIX = ".generated.ts";
|
|
26
|
+
/**
|
|
27
|
+
* Map the naming-neutral pipeline-return IR to the interface-named descriptor
|
|
28
|
+
* the TS `renderOpResultAlias` template consumes.
|
|
29
|
+
*/
|
|
30
|
+
function mapPipelineReturn(ir, recordInterfaceByModel) {
|
|
31
|
+
switch (ir.kind) {
|
|
32
|
+
case "query":
|
|
33
|
+
return {
|
|
34
|
+
kind: "query",
|
|
35
|
+
recordInterfaceName: ir.modelName
|
|
36
|
+
? recordInterfaceByModel[ir.modelName] ?? null
|
|
37
|
+
: null,
|
|
38
|
+
projection: ir.projection,
|
|
39
|
+
};
|
|
40
|
+
case "count":
|
|
41
|
+
return { kind: "count" };
|
|
42
|
+
case "aggregate":
|
|
43
|
+
return { kind: "aggregate" };
|
|
44
|
+
case "opaque":
|
|
45
|
+
default:
|
|
46
|
+
return { kind: "opaque" };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Render the in-memory `.generated.ts` content for a single database-type
|
|
51
|
+
* TOML. Exported so tests can assert on the rendered string directly.
|
|
52
|
+
*/
|
|
53
|
+
export function renderDbTypeFile(input) {
|
|
54
|
+
const ir = describeDbType(input);
|
|
55
|
+
// model name → resolved record interface name (used by query result aliases),
|
|
56
|
+
// with the same collision guard the inline implementation had.
|
|
57
|
+
const recordInterfaceByModel = {};
|
|
58
|
+
const seenInterfaceNames = new Map(); // interfaceName → modelName
|
|
59
|
+
for (const rec of ir.records) {
|
|
60
|
+
const ifaceName = resolveRecordInterfaceName(rec.modelName, rec.className);
|
|
61
|
+
const prior = seenInterfaceNames.get(ifaceName);
|
|
62
|
+
if (prior !== undefined && prior !== rec.modelName) {
|
|
63
|
+
throw new Error(`Record-interface name collision: models "${prior}" and ` +
|
|
64
|
+
`"${rec.modelName}" both produce interface "${ifaceName}". Add a ` +
|
|
65
|
+
`class_name override to one of them.`);
|
|
66
|
+
}
|
|
67
|
+
seenInterfaceNames.set(ifaceName, rec.modelName);
|
|
68
|
+
recordInterfaceByModel[rec.modelName] = ifaceName;
|
|
69
|
+
}
|
|
70
|
+
const blocks = [];
|
|
71
|
+
blocks.push(renderHeader(ir.fingerprint));
|
|
72
|
+
blocks.push(RESULT_ALIASES_BLOCK.trimEnd());
|
|
73
|
+
// Record interfaces, sorted by interface name for deterministic output.
|
|
74
|
+
const sortedRecords = [...ir.records].sort((a, b) => recordInterfaceByModel[a.modelName].localeCompare(recordInterfaceByModel[b.modelName]));
|
|
75
|
+
for (const rec of sortedRecords) {
|
|
76
|
+
blocks.push(renderRecordInterface({
|
|
77
|
+
interfaceName: recordInterfaceByModel[rec.modelName],
|
|
78
|
+
modelName: rec.modelName,
|
|
79
|
+
fields: rec.fields,
|
|
80
|
+
stampedFields: ir.stampedFields,
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
// Operation interfaces + result aliases, already sorted by op name in the IR.
|
|
84
|
+
// Descriptors for the typed-ops factory (#1441), collected in the same order.
|
|
85
|
+
const factoryOps = [];
|
|
86
|
+
for (const op of ir.ops) {
|
|
87
|
+
blocks.push(renderOpParamsInterface({
|
|
88
|
+
interfaceName: opParamsInterfaceName(op.opName),
|
|
89
|
+
opName: op.opName,
|
|
90
|
+
params: op.params,
|
|
91
|
+
}));
|
|
92
|
+
factoryOps.push({
|
|
93
|
+
propertyKey: objectPropertyKey(op.opName),
|
|
94
|
+
opName: op.opName,
|
|
95
|
+
paramsInterfaceName: opParamsInterfaceName(op.opName),
|
|
96
|
+
resultAliasName: opResultAliasName(op.opName),
|
|
97
|
+
hasParams: op.hasParams,
|
|
98
|
+
});
|
|
99
|
+
const recordInterfaceName = op.resultModelName
|
|
100
|
+
? recordInterfaceByModel[op.resultModelName] ?? null
|
|
101
|
+
: null;
|
|
102
|
+
const pipelineReturn = op.pipelineReturn
|
|
103
|
+
? mapPipelineReturn(op.pipelineReturn, recordInterfaceByModel)
|
|
104
|
+
: undefined;
|
|
105
|
+
blocks.push(renderOpResultAlias({
|
|
106
|
+
aliasName: opResultAliasName(op.opName),
|
|
107
|
+
opName: op.opName,
|
|
108
|
+
opType: op.opType,
|
|
109
|
+
recordInterfaceName,
|
|
110
|
+
projection: op.projection,
|
|
111
|
+
pipelineReturn,
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
// Typed-subscriptions descriptors (#1544 Phase 2): map each subscription's
|
|
115
|
+
// model to its record interface (or a `Pick` when it declares `select`). The
|
|
116
|
+
// IR already validated that every model resolves and every select field is a
|
|
117
|
+
// known member, so this mapping never fails.
|
|
118
|
+
const factorySubscriptions = ir.subscriptions.map((sub) => {
|
|
119
|
+
const interfaceName = recordInterfaceByModel[sub.modelName];
|
|
120
|
+
// `Pick<Record, "a" | "b">` when the subscription projects fields, else
|
|
121
|
+
// the bare record interface — built as a `TypeNode` (mirroring
|
|
122
|
+
// `queryResultGeneric`'s projection) so the emitter can break it the way
|
|
123
|
+
// Prettier would inside `SubscribeOptions<...>` / `subscribe<...>`.
|
|
124
|
+
const eventType = sub.select && sub.select.length > 0
|
|
125
|
+
? generic("Pick", [atom(interfaceName), fieldNameUnion(sub.select)])
|
|
126
|
+
: atom(interfaceName);
|
|
127
|
+
return {
|
|
128
|
+
propertyKey: objectPropertyKey(sub.subscriptionKey),
|
|
129
|
+
subscriptionKey: sub.subscriptionKey,
|
|
130
|
+
eventType,
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
// Typed-ops factory (#1441) + typed-subscriptions factory (#1544 Phase 2),
|
|
134
|
+
// sharing one structural client interface. Omitted entirely for a type with
|
|
135
|
+
// neither ops nor subscriptions.
|
|
136
|
+
if (factoryOps.length > 0 || factorySubscriptions.length > 0) {
|
|
137
|
+
blocks.push(renderFactories({
|
|
138
|
+
databaseType: input.databaseType,
|
|
139
|
+
opsFactoryName: opsFactoryName(input.databaseType),
|
|
140
|
+
subscriptionsFactoryName: subscriptionsFactoryName(input.databaseType),
|
|
141
|
+
ops: factoryOps,
|
|
142
|
+
subscriptions: factorySubscriptions,
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
// Single trailing newline; blocks separated by a blank line.
|
|
146
|
+
return blocks.join("\n\n") + "\n";
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Run codegen end-to-end across one or more database-type TOML inputs. The
|
|
150
|
+
* disk lifecycle (write / `--check` / stale cleanup) is delegated to the
|
|
151
|
+
* shared `writeOrCheckGeneratedFiles` (shared with `workflows codegen`).
|
|
152
|
+
*/
|
|
153
|
+
export async function generateDbTypes(options) {
|
|
154
|
+
const outAbs = path.resolve(options.outputDir);
|
|
155
|
+
const filesToWrite = new Map();
|
|
156
|
+
for (const input of options.inputs) {
|
|
157
|
+
const filePath = path.join(outAbs, `${input.databaseType}${GENERATED_FILE_SUFFIX}`);
|
|
158
|
+
filesToWrite.set(filePath, renderDbTypeFile(input));
|
|
159
|
+
}
|
|
160
|
+
return await writeOrCheckGeneratedFiles({
|
|
161
|
+
outputDir: outAbs,
|
|
162
|
+
filesToWrite,
|
|
163
|
+
check: options.check,
|
|
164
|
+
// A single-type filter run owns only a subset of the generated files, so
|
|
165
|
+
// orphan cleanup / stale detection must be scoped to the filtered file.
|
|
166
|
+
fullOwnership: options.singleType !== true,
|
|
167
|
+
generatedSuffix: GENERATED_FILE_SUFFIX,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=dbGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbGenerator.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,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;SACpC,CAAC,CACH,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAA+B;IAE/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAE/C,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC/C,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CACxB,MAAM,EACN,GAAG,KAAK,CAAC,YAAY,GAAG,qBAAqB,EAAE,CAChD,CAAC;QACF,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,MAAM,0BAA0B,CAAC;QACtC,SAAS,EAAE,MAAM;QACjB,YAAY;QACZ,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,yEAAyE;QACzE,wEAAwE;QACxE,aAAa,EAAE,OAAO,CAAC,UAAU,KAAK,IAAI;QAC1C,eAAe,EAAE,qBAAqB;KACvC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifier-naming helpers for the `databases codegen` generator (issue #814).
|
|
3
|
+
*
|
|
4
|
+
* Record interfaces mirror codegen-v2's class-name resolution
|
|
5
|
+
* (`packages/js-bao/src/cli/v2/pluralization.ts`): honor a `class_name`
|
|
6
|
+
* override, else singularize a snake_case plural to PascalCase. The
|
|
7
|
+
* singularization algorithm below is a faithful copy of codegen-v2's
|
|
8
|
+
* `singularizeToPascalCase`; it is inlined rather than imported because the
|
|
9
|
+
* CLI builds standalone (`tsc -p cli/tsconfig.json`, `rootDir: "."`) and
|
|
10
|
+
* cannot reach into the vendored `packages/js-bao/src` tree.
|
|
11
|
+
*
|
|
12
|
+
* It DIVERGES in the fallback: codegen-v2 THROWS when a model name doesn't
|
|
13
|
+
* look like a recognizable plural (ORM models are expected to be plural).
|
|
14
|
+
* Database-type model names are author-curated and frequently already
|
|
15
|
+
* singular / PascalCase (e.g. `[models.User]`), so we PascalCase the name
|
|
16
|
+
* verbatim rather than failing the whole run.
|
|
17
|
+
*
|
|
18
|
+
* Op interfaces/aliases derive from the operation name (PascalCase) +
|
|
19
|
+
* `Params` / `Result` suffix (e.g. `saveAccount` → `SaveAccountParams`,
|
|
20
|
+
* `SaveAccountResult`).
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the record-interface name for a model. Honors a `class_name`
|
|
24
|
+
* override, then tries plural→singular Pascal, then falls back to a verbatim
|
|
25
|
+
* PascalCase of the model name (no throw).
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveRecordInterfaceName(modelName: string, classNameOverride: string | undefined): string;
|
|
28
|
+
/** `saveAccount` → `SaveAccountParams`. */
|
|
29
|
+
export declare function opParamsInterfaceName(opName: string): string;
|
|
30
|
+
/** `saveAccount` → `SaveAccountResult`. */
|
|
31
|
+
export declare function opResultAliasName(opName: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Name of the generated typed-operations factory for a database type (#1441).
|
|
34
|
+
* `securities-ref` → `securitiesRefOps`, `portfolio` → `portfolioOps`. A type
|
|
35
|
+
* whose camelCased name would start with a digit (e.g. `2fa`) gets a leading
|
|
36
|
+
* `_` so the emitted `export function` name is a valid JS identifier.
|
|
37
|
+
*/
|
|
38
|
+
export declare function opsFactoryName(databaseType: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Name of the generated typed-subscriptions factory for a database type
|
|
41
|
+
* (#1544 Phase 2). Same casing + leading-digit guard as {@link opsFactoryName}:
|
|
42
|
+
* `tasks-db` → `tasksDbSubscriptions`, `2fa` → `_2faSubscriptions`. Kept a
|
|
43
|
+
* separate export from `<type>Ops` (Fork 4 = A): realtime subscriptions are a
|
|
44
|
+
* different surface than HTTP `executeOperation`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function subscriptionsFactoryName(databaseType: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* camelCase an identifier: splits on non-alphanumeric separators, lower-cases
|
|
49
|
+
* the first segment's first char and PascalCases the rest
|
|
50
|
+
* (`securities-ref` → `securitiesRef`, `save_account` → `saveAccount`). Existing
|
|
51
|
+
* internal casing after the first char is preserved.
|
|
52
|
+
*/
|
|
53
|
+
export declare function camelCase(name: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Render a name (an operation name #1441, or a subscription key #1544 Phase 2)
|
|
56
|
+
* as an object-literal property key. A name that is a plain, non-reserved JS
|
|
57
|
+
* identifier is emitted bare (`getX:`); anything else — a hyphen, a leading
|
|
58
|
+
* digit, or a reserved word — is emitted as a quoted key (`"get-x":`,
|
|
59
|
+
* `"delete":`) so the factory stays valid TypeScript. The original name string
|
|
60
|
+
* passed to `executeOperation` / `subscribe` is always the exact original name.
|
|
61
|
+
*
|
|
62
|
+
* `__proto__` is a special case. The factory return value is a *runtime* object
|
|
63
|
+
* literal, and in that position both the bare `__proto__:` form AND the quoted
|
|
64
|
+
* `"__proto__":` form set the object's prototype instead of defining an own
|
|
65
|
+
* method — silently dropping that operation. Only a computed key
|
|
66
|
+
* (`["__proto__"]:`) defines a normal own property, so emit that form.
|
|
67
|
+
*
|
|
68
|
+
* A quoted key uses `tsStringLiteral` (Prettier's fewer-escapes quote choice),
|
|
69
|
+
* not `JSON.stringify`, so a quote-bearing op name / subscription key (e.g.
|
|
70
|
+
* `weird"key` → `'weird"key':`) stays a fixed point of Prettier's default
|
|
71
|
+
* config (#1678). For identifier and quote-free keys the two are identical.
|
|
72
|
+
*/
|
|
73
|
+
export declare function objectPropertyKey(name: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Convert a snake_case plural model name (`user_prefs`, `categories`) into a
|
|
76
|
+
* PascalCase singular interface name (`UserPref`, `Category`). Returns null
|
|
77
|
+
* if no suffix rule matches the input. Faithful copy of codegen-v2's
|
|
78
|
+
* `singularizeToPascalCase`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function singularizeToPascalCase(snakePlural: string): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* PascalCase an identifier: splits on non-alphanumeric separators
|
|
83
|
+
* (`_`, `-`, spaces) and capitalizes each segment, preserving any existing
|
|
84
|
+
* internal casing (`saveAccount` → `SaveAccount`, `save_account` →
|
|
85
|
+
* `SaveAccount`).
|
|
86
|
+
*/
|
|
87
|
+
export declare function pascalCase(name: string): string;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifier-naming helpers for the `databases codegen` generator (issue #814).
|
|
3
|
+
*
|
|
4
|
+
* Record interfaces mirror codegen-v2's class-name resolution
|
|
5
|
+
* (`packages/js-bao/src/cli/v2/pluralization.ts`): honor a `class_name`
|
|
6
|
+
* override, else singularize a snake_case plural to PascalCase. The
|
|
7
|
+
* singularization algorithm below is a faithful copy of codegen-v2's
|
|
8
|
+
* `singularizeToPascalCase`; it is inlined rather than imported because the
|
|
9
|
+
* CLI builds standalone (`tsc -p cli/tsconfig.json`, `rootDir: "."`) and
|
|
10
|
+
* cannot reach into the vendored `packages/js-bao/src` tree.
|
|
11
|
+
*
|
|
12
|
+
* It DIVERGES in the fallback: codegen-v2 THROWS when a model name doesn't
|
|
13
|
+
* look like a recognizable plural (ORM models are expected to be plural).
|
|
14
|
+
* Database-type model names are author-curated and frequently already
|
|
15
|
+
* singular / PascalCase (e.g. `[models.User]`), so we PascalCase the name
|
|
16
|
+
* verbatim rather than failing the whole run.
|
|
17
|
+
*
|
|
18
|
+
* Op interfaces/aliases derive from the operation name (PascalCase) +
|
|
19
|
+
* `Params` / `Result` suffix (e.g. `saveAccount` → `SaveAccountParams`,
|
|
20
|
+
* `SaveAccountResult`).
|
|
21
|
+
*/
|
|
22
|
+
import { tsStringLiteral } from "../codegen-shared/prettierStable.js";
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the record-interface name for a model. Honors a `class_name`
|
|
25
|
+
* override, then tries plural→singular Pascal, then falls back to a verbatim
|
|
26
|
+
* PascalCase of the model name (no throw).
|
|
27
|
+
*/
|
|
28
|
+
export function resolveRecordInterfaceName(modelName, classNameOverride) {
|
|
29
|
+
if (classNameOverride && classNameOverride.length > 0) {
|
|
30
|
+
return classNameOverride;
|
|
31
|
+
}
|
|
32
|
+
const singular = singularizeToPascalCase(modelName);
|
|
33
|
+
if (singular !== null)
|
|
34
|
+
return singular;
|
|
35
|
+
// Fallback: PascalCase the model name as-is (handles already-singular and
|
|
36
|
+
// already-PascalCase names like `User`, `Account`).
|
|
37
|
+
return pascalCase(modelName);
|
|
38
|
+
}
|
|
39
|
+
/** `saveAccount` → `SaveAccountParams`. */
|
|
40
|
+
export function opParamsInterfaceName(opName) {
|
|
41
|
+
return `${pascalCase(opName)}Params`;
|
|
42
|
+
}
|
|
43
|
+
/** `saveAccount` → `SaveAccountResult`. */
|
|
44
|
+
export function opResultAliasName(opName) {
|
|
45
|
+
return `${pascalCase(opName)}Result`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Name of the generated typed-operations factory for a database type (#1441).
|
|
49
|
+
* `securities-ref` → `securitiesRefOps`, `portfolio` → `portfolioOps`. A type
|
|
50
|
+
* whose camelCased name would start with a digit (e.g. `2fa`) gets a leading
|
|
51
|
+
* `_` so the emitted `export function` name is a valid JS identifier.
|
|
52
|
+
*/
|
|
53
|
+
export function opsFactoryName(databaseType) {
|
|
54
|
+
const base = camelCase(databaseType);
|
|
55
|
+
const safe = /^[0-9]/.test(base) ? `_${base}` : base;
|
|
56
|
+
return `${safe}Ops`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Name of the generated typed-subscriptions factory for a database type
|
|
60
|
+
* (#1544 Phase 2). Same casing + leading-digit guard as {@link opsFactoryName}:
|
|
61
|
+
* `tasks-db` → `tasksDbSubscriptions`, `2fa` → `_2faSubscriptions`. Kept a
|
|
62
|
+
* separate export from `<type>Ops` (Fork 4 = A): realtime subscriptions are a
|
|
63
|
+
* different surface than HTTP `executeOperation`.
|
|
64
|
+
*/
|
|
65
|
+
export function subscriptionsFactoryName(databaseType) {
|
|
66
|
+
const base = camelCase(databaseType);
|
|
67
|
+
const safe = /^[0-9]/.test(base) ? `_${base}` : base;
|
|
68
|
+
return `${safe}Subscriptions`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* camelCase an identifier: splits on non-alphanumeric separators, lower-cases
|
|
72
|
+
* the first segment's first char and PascalCases the rest
|
|
73
|
+
* (`securities-ref` → `securitiesRef`, `save_account` → `saveAccount`). Existing
|
|
74
|
+
* internal casing after the first char is preserved.
|
|
75
|
+
*/
|
|
76
|
+
export function camelCase(name) {
|
|
77
|
+
const pascal = pascalCase(name);
|
|
78
|
+
if (pascal.length === 0)
|
|
79
|
+
return pascal;
|
|
80
|
+
return pascal.charAt(0).toLowerCase() + pascal.slice(1);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* JS reserved words. Used as object-literal property keys these are actually
|
|
84
|
+
* legal unquoted, but quoting them keeps the generated output unambiguous and
|
|
85
|
+
* matches the "non-identifier op name -> quoted key" behavior (#1441).
|
|
86
|
+
*/
|
|
87
|
+
const RESERVED_WORDS = new Set([
|
|
88
|
+
"break", "case", "catch", "class", "const", "continue", "debugger",
|
|
89
|
+
"default", "delete", "do", "else", "enum", "export", "extends", "false",
|
|
90
|
+
"finally", "for", "function", "if", "import", "in", "instanceof", "new",
|
|
91
|
+
"null", "return", "super", "switch", "this", "throw", "true", "try",
|
|
92
|
+
"typeof", "var", "void", "while", "with", "yield", "let", "static",
|
|
93
|
+
"implements", "interface", "package", "private", "protected", "public",
|
|
94
|
+
]);
|
|
95
|
+
/**
|
|
96
|
+
* Render a name (an operation name #1441, or a subscription key #1544 Phase 2)
|
|
97
|
+
* as an object-literal property key. A name that is a plain, non-reserved JS
|
|
98
|
+
* identifier is emitted bare (`getX:`); anything else — a hyphen, a leading
|
|
99
|
+
* digit, or a reserved word — is emitted as a quoted key (`"get-x":`,
|
|
100
|
+
* `"delete":`) so the factory stays valid TypeScript. The original name string
|
|
101
|
+
* passed to `executeOperation` / `subscribe` is always the exact original name.
|
|
102
|
+
*
|
|
103
|
+
* `__proto__` is a special case. The factory return value is a *runtime* object
|
|
104
|
+
* literal, and in that position both the bare `__proto__:` form AND the quoted
|
|
105
|
+
* `"__proto__":` form set the object's prototype instead of defining an own
|
|
106
|
+
* method — silently dropping that operation. Only a computed key
|
|
107
|
+
* (`["__proto__"]:`) defines a normal own property, so emit that form.
|
|
108
|
+
*
|
|
109
|
+
* A quoted key uses `tsStringLiteral` (Prettier's fewer-escapes quote choice),
|
|
110
|
+
* not `JSON.stringify`, so a quote-bearing op name / subscription key (e.g.
|
|
111
|
+
* `weird"key` → `'weird"key':`) stays a fixed point of Prettier's default
|
|
112
|
+
* config (#1678). For identifier and quote-free keys the two are identical.
|
|
113
|
+
*/
|
|
114
|
+
export function objectPropertyKey(name) {
|
|
115
|
+
if (name === "__proto__")
|
|
116
|
+
return `[${tsStringLiteral(name)}]`;
|
|
117
|
+
const isPlainIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
|
118
|
+
if (isPlainIdentifier && !RESERVED_WORDS.has(name))
|
|
119
|
+
return name;
|
|
120
|
+
return tsStringLiteral(name);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Convert a snake_case plural model name (`user_prefs`, `categories`) into a
|
|
124
|
+
* PascalCase singular interface name (`UserPref`, `Category`). Returns null
|
|
125
|
+
* if no suffix rule matches the input. Faithful copy of codegen-v2's
|
|
126
|
+
* `singularizeToPascalCase`.
|
|
127
|
+
*/
|
|
128
|
+
export function singularizeToPascalCase(snakePlural) {
|
|
129
|
+
if (!snakePlural || snakePlural.length === 0)
|
|
130
|
+
return null;
|
|
131
|
+
const parts = snakePlural.split("_");
|
|
132
|
+
if (parts.some((p) => p.length === 0))
|
|
133
|
+
return null;
|
|
134
|
+
const last = parts[parts.length - 1];
|
|
135
|
+
const singularizedLast = singularizeWord(last);
|
|
136
|
+
if (singularizedLast === null)
|
|
137
|
+
return null;
|
|
138
|
+
parts[parts.length - 1] = singularizedLast;
|
|
139
|
+
return parts.map(pascalSegment).join("");
|
|
140
|
+
}
|
|
141
|
+
/** Singularize a single plural word via simple suffix rules; null if none. */
|
|
142
|
+
function singularizeWord(word) {
|
|
143
|
+
if (!word)
|
|
144
|
+
return null;
|
|
145
|
+
if (!word.endsWith("s"))
|
|
146
|
+
return null;
|
|
147
|
+
if (word.endsWith("ies") && word.length > 3)
|
|
148
|
+
return word.slice(0, -3) + "y";
|
|
149
|
+
if (word.endsWith("xes") && word.length > 3)
|
|
150
|
+
return word.slice(0, -2);
|
|
151
|
+
if (word.endsWith("ses") && word.length > 3)
|
|
152
|
+
return word.slice(0, -2);
|
|
153
|
+
if (word.endsWith("shes") && word.length > 4)
|
|
154
|
+
return word.slice(0, -2);
|
|
155
|
+
if (word.endsWith("ches") && word.length > 4)
|
|
156
|
+
return word.slice(0, -2);
|
|
157
|
+
if (word.endsWith("s") && word.length > 1)
|
|
158
|
+
return word.slice(0, -1);
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
function pascalSegment(segment) {
|
|
162
|
+
if (!segment)
|
|
163
|
+
return segment;
|
|
164
|
+
return segment.charAt(0).toUpperCase() + segment.slice(1);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* PascalCase an identifier: splits on non-alphanumeric separators
|
|
168
|
+
* (`_`, `-`, spaces) and capitalizes each segment, preserving any existing
|
|
169
|
+
* internal casing (`saveAccount` → `SaveAccount`, `save_account` →
|
|
170
|
+
* `SaveAccount`).
|
|
171
|
+
*/
|
|
172
|
+
export function pascalCase(name) {
|
|
173
|
+
const segments = name.split(/[^A-Za-z0-9]+/).filter((s) => s.length > 0);
|
|
174
|
+
if (segments.length === 0)
|
|
175
|
+
return name;
|
|
176
|
+
return segments
|
|
177
|
+
.map((seg) => seg.charAt(0).toUpperCase() + seg.slice(1))
|
|
178
|
+
.join("");
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=dbNaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbNaming.js","sourceRoot":"","sources":["../../../../src/lib/db-codegen/dbNaming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,SAAiB,EACjB,iBAAqC;IAErC,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACpD,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IACvC,0EAA0E;IAC1E,oDAAoD;IACpD,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;AACvC,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB;IACjD,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,I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