primitive-admin 1.1.0-alpha.7 → 1.1.0-alpha.71
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 +404 -80
- package/assets/skill/skills/primitive-platform/SKILL.md +808 -0
- package/dist/bin/primitive.d.ts +2 -0
- package/dist/bin/primitive.js +294 -21
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.d.ts +2 -0
- package/dist/src/commands/admins.js +138 -19
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/analytics.d.ts +2 -0
- package/dist/src/commands/analytics.js +544 -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 +51 -96
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth.d.ts +2 -0
- package/dist/src/commands/auth.js +177 -7
- 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 +330 -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 +37 -38
- 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 +92 -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 +565 -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 +479 -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 +100 -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 +265 -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 +171 -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 +2140 -112
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.d.ts +2 -0
- package/dist/src/commands/documents.js +1357 -19
- 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 +174 -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 +333 -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 +116 -0
- package/dist/src/commands/feature-flags.js.map +1 -0
- package/dist/src/commands/group-type-configs.d.ts +2 -0
- package/dist/src/commands/group-type-configs.js +86 -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 +38 -99
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.d.ts +223 -0
- package/dist/src/commands/guides.js +617 -65
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/init.d.ts +25 -0
- package/dist/src/commands/init.js +1605 -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 +380 -178
- 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 +160 -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 +112 -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 +281 -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 +225 -584
- 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 +272 -0
- package/dist/src/commands/rule-sets.js.map +1 -0
- package/dist/src/commands/scripts.d.ts +20 -0
- package/dist/src/commands/scripts.js +554 -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 +108 -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 +75 -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 +330 -0
- package/dist/src/commands/sync-app-settings.js.map +1 -0
- package/dist/src/commands/sync.d.ts +2323 -0
- package/dist/src/commands/sync.js +15065 -843
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.d.ts +2 -0
- package/dist/src/commands/tokens.js +130 -21
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.d.ts +2 -0
- package/dist/src/commands/users.js +532 -23
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.d.ts +8 -0
- package/dist/src/commands/vars.js +96 -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 +10 -10
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/webhooks.d.ts +2 -0
- package/dist/src/commands/webhooks.js +562 -0
- package/dist/src/commands/webhooks.js.map +1 -0
- package/dist/src/commands/workflows.d.ts +116 -0
- package/dist/src/commands/workflows.js +1583 -681
- 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 +1936 -0
- package/dist/src/lib/api-client.js +1826 -138
- 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 +575 -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/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 +68 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +168 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
- package/dist/src/lib/config-object-descriptor.d.ts +127 -0
- package/dist/src/lib/config-object-descriptor.js +658 -0
- package/dist/src/lib/config-object-descriptor.js.map +1 -0
- package/dist/src/lib/config-payload.d.ts +85 -0
- package/dist/src/lib/config-payload.js +116 -0
- package/dist/src/lib/config-payload.js.map +1 -0
- package/dist/src/lib/config-surface.d.ts +130 -0
- package/dist/src/lib/config-surface.js +300 -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 +53 -0
- package/dist/src/lib/config.js +92 -53
- 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 +89 -0
- package/dist/src/lib/credentials-store.js +330 -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 +517 -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/env-resolver-core.d.ts +147 -0
- package/dist/src/lib/env-resolver-core.js +265 -0
- package/dist/src/lib/env-resolver-core.js.map +1 -0
- package/dist/src/lib/env-resolver.d.ts +84 -0
- package/dist/src/lib/env-resolver.js +133 -0
- package/dist/src/lib/env-resolver.js.map +1 -0
- package/dist/src/lib/fetch.d.ts +5 -0
- package/dist/src/lib/generated-allowlist.d.ts +28 -0
- package/dist/src/lib/generated-allowlist.js +277 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +682 -0
- package/dist/src/lib/generated-config-surfaces.js +4058 -0
- package/dist/src/lib/generated-config-surfaces.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-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-ios-links.d.ts +50 -0
- package/dist/src/lib/init-ios-links.js +153 -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 +33 -0
- package/dist/src/lib/init-xcode.js +114 -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/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/log-inspection.d.ts +568 -0
- package/dist/src/lib/log-inspection.js +639 -0
- package/dist/src/lib/log-inspection.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 +109 -0
- package/dist/src/lib/output.js +191 -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 +83 -0
- package/dist/src/lib/paginate.js +95 -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 +97 -0
- package/dist/src/lib/project-config.js +217 -0
- package/dist/src/lib/project-config.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 +65 -0
- package/dist/src/lib/refresh-admin-credentials.js +103 -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-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 +25 -0
- package/dist/src/lib/skill-installer.js +266 -0
- package/dist/src/lib/skill-installer.js.map +1 -0
- package/dist/src/lib/snapshots.d.ts +99 -0
- package/dist/src/lib/snapshots.js +357 -0
- package/dist/src/lib/snapshots.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js +914 -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/generator.d.ts +94 -0
- package/dist/src/lib/swift-codegen/generator.js +440 -0
- package/dist/src/lib/swift-codegen/generator.js.map +1 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +72 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.js +644 -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 +111 -0
- package/dist/src/lib/sync-paths.js +198 -0
- package/dist/src/lib/sync-paths.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +544 -0
- package/dist/src/lib/sync-resource-types.js +975 -0
- package/dist/src/lib/sync-resource-types.js.map +1 -0
- package/dist/src/lib/sync-selectors.d.ts +95 -0
- package/dist/src/lib/sync-selectors.js +228 -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-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 +15 -0
- package/dist/src/lib/test-case-variables.js +29 -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 +527 -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/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 +202 -0
- package/dist/src/lib/workflow-toml-validator.js +757 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -0
- package/dist/src/types/index.d.ts +581 -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 +32 -8
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `workflows codegen` orchestrator (issue #1442).
|
|
3
|
+
*
|
|
4
|
+
* Reads synced workflow TOMLs (`.primitive/sync/<env>/<appId>/workflows/*.toml`)
|
|
5
|
+
* and emits ONE generated file per workflow —
|
|
6
|
+
* `workflows/generated/<key>.generated.ts` — each containing the workflow's
|
|
7
|
+
* `<Key>Input`/`<Key>Output` types plus a typed `<key>(client)` invoker factory
|
|
8
|
+
* returning `{ runSync?, start, getStatus }`. This mirrors `databases codegen`'s per-type
|
|
9
|
+
* `<Type>.generated.ts` layout (#1441's `<type>Ops`): per-file artifacts keep
|
|
10
|
+
* team merges conflict-free and let a `[workflow-key]` filter regenerate exactly
|
|
11
|
+
* one file.
|
|
12
|
+
*
|
|
13
|
+
* Design decisions (see the plan of record on #1442, post-pivot):
|
|
14
|
+
* - Schemas are interpreted through the SHARED descriptor
|
|
15
|
+
* (`generated-schema-descriptor.ts`, a vendored copy of the server's
|
|
16
|
+
* `schema-validation` descriptor) so the generated types match runtime
|
|
17
|
+
* validation exactly. A malformed schema throws (fail-and-exit).
|
|
18
|
+
* - `.runSync` is emitted only for `syncCallable: true` workflows (the server
|
|
19
|
+
* rejects run-sync otherwise); `.start`, `.getStatus`, and `.terminate` for
|
|
20
|
+
* every non-reserved workflow (the typed async path, issue #1512 —
|
|
21
|
+
* async-only workflows are exactly the ones that need a typed `getStatus` /
|
|
22
|
+
* `terminate`). `.terminate` binds `<Key>Output` (a terminated run can carry
|
|
23
|
+
* partial output); issue #1543 added the member, reversing #1512's
|
|
24
|
+
* start/status-only decision.
|
|
25
|
+
* - `.define` is emitted only for an apply-mode workflow
|
|
26
|
+
* (`requiresClientApply !== false`, the server's default). It binds
|
|
27
|
+
* `<Key>Output` so the `onApply` handler's `output` is the workflow's real
|
|
28
|
+
* output type rather than `any` (issue #1543, on top of #1542's
|
|
29
|
+
* `define<O>` / `WorkflowDefineOptions<O>` generics). `getPendingApplies`
|
|
30
|
+
* gets no member — #1542 made it a concrete `PendingApply[]` with no output
|
|
31
|
+
* to bind, and it is scoped to a document rather than a workflow.
|
|
32
|
+
* - `.cronTriggers.{create,update}` bind `<Key>Input` to the trigger's
|
|
33
|
+
* `rootInput` and pin `workflowKey`, so a cron helper can't be redirected at
|
|
34
|
+
* another workflow (issue #1543). `rootInput` is `Partial<<Key>Input>` for
|
|
35
|
+
* an object-shaped input schema (an `inputMapping` may supply the rest) and
|
|
36
|
+
* the full `<Key>Input` otherwise.
|
|
37
|
+
* - `input` is a REQUIRED option iff the schema rejects `{}` (the client's
|
|
38
|
+
* `input ?? {}` fallback would fail validation); otherwise `input?`.
|
|
39
|
+
* - The runtime call always passes the ORIGINAL key string; only identifiers
|
|
40
|
+
* are sanitized. `workflowKey` is set AFTER spreading `opts`, so a caller
|
|
41
|
+
* cannot override it.
|
|
42
|
+
* - Disk lifecycle (write / `--check` / suffix-based cleanup) delegates to the
|
|
43
|
+
* shared `writeOrCheckGeneratedFiles`, exactly like `databases codegen`.
|
|
44
|
+
*
|
|
45
|
+
* FORMATTING CONTRACT (#1565): the emitted TypeScript must be a fixed point of
|
|
46
|
+
* Prettier's DEFAULT config — `prettier --write` over a generated file must
|
|
47
|
+
* leave it byte-for-byte unchanged, because `--check` byte-compares. There is
|
|
48
|
+
* no Prettier dependency and no automated round-trip test to catch a
|
|
49
|
+
* regression, so any edit here that changes line shapes must be verified by
|
|
50
|
+
* hand (regenerate a representative output, run Prettier over it, confirm no
|
|
51
|
+
* diff). Wrap long constructs through `codegen-shared/prettierStable.ts` rather
|
|
52
|
+
* than hand-joining strings — see that file's header for the full contract.
|
|
53
|
+
*/
|
|
54
|
+
import * as path from "path";
|
|
55
|
+
import { writeOrCheckGeneratedFiles, } from "../codegen-shared/generatedFiles.js";
|
|
56
|
+
import { fingerprintToml } from "../db-codegen/dbFingerprint.js";
|
|
57
|
+
import { atom, generic, indent, intersection, objectType, printType, renderArrowCall, renderArrowProperty, renderParenList, renderTypeAlias, tsStringLiteral, union, } from "../codegen-shared/prettierStable.js";
|
|
58
|
+
import { schemaToTypeNode } from "./schemaToTs.js";
|
|
59
|
+
import { describeSchema } from "./generated-schema-descriptor.js";
|
|
60
|
+
import { describeWorkflowInvoker } from "./invokerIR.js";
|
|
61
|
+
import { workflowInputTypeName, workflowOutputTypeName, workflowFactoryName, } from "./naming.js";
|
|
62
|
+
/** Suffix identifying a generated file (shared with `databases codegen`). */
|
|
63
|
+
export const GENERATED_FILE_SUFFIX = ".generated.ts";
|
|
64
|
+
/** The client package the generated file imports its types from. */
|
|
65
|
+
const CLIENT_PACKAGE = "js-bao-wss-client";
|
|
66
|
+
/**
|
|
67
|
+
* Render a top-level `<Name>Input`/`<Name>Output` declaration. An absent schema
|
|
68
|
+
* → `unknown`. A plain object type → an `interface`; anything else → a `type`
|
|
69
|
+
* alias.
|
|
70
|
+
*
|
|
71
|
+
* A discriminated-union (`oneOf`) output renders as `{…} | {…}`, which begins
|
|
72
|
+
* with `{` too — but it must be a `type` alias, not `interface Foo {…} | {…}`
|
|
73
|
+
* (invalid TS). Decide via the shared descriptor (`describeSchema(...).oneOf`),
|
|
74
|
+
* not the `startsWith("{")` heuristic (#1511).
|
|
75
|
+
*/
|
|
76
|
+
function renderTypeDecl(name, schema) {
|
|
77
|
+
if (schema === undefined) {
|
|
78
|
+
// Through `renderTypeAlias`, not hand-joined: a long enough workflow key
|
|
79
|
+
// pushes `export type <Key>Output = unknown;` past the print width, and
|
|
80
|
+
// Prettier then moves the `unknown` below the `=` (#1565).
|
|
81
|
+
return renderTypeAlias(name, atom("unknown"));
|
|
82
|
+
}
|
|
83
|
+
const node = schemaToTypeNode(schema);
|
|
84
|
+
if (node.kind === "block" && !describeSchema(schema).oneOf) {
|
|
85
|
+
return `export interface ${name} ${printType(node, 0, 0)}`;
|
|
86
|
+
}
|
|
87
|
+
return renderTypeAlias(name, node);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Parse a single workflow TOML into the data the emitter needs. Throws on
|
|
91
|
+
* malformed schema JSON (fail-and-exit) — the honest `unknown` fallback is for
|
|
92
|
+
* valid-but-untypeable schemas only. Returns null for a reserved workflow.
|
|
93
|
+
*
|
|
94
|
+
* The operation metadata (key, `syncCallable`, required-vs-optional `input`,
|
|
95
|
+
* parsed schemas) comes from the SHARED `describeWorkflowInvoker` IR so the TS
|
|
96
|
+
* and Swift invokers can never disagree (#1547 binding item 5). Only the
|
|
97
|
+
* TS-specific naming + type-declaration rendering happens here.
|
|
98
|
+
*/
|
|
99
|
+
function parseWorkflow(input) {
|
|
100
|
+
// #1464 removed `@iarna/toml`; #1446 makes `config pull` emit schemas as native
|
|
101
|
+
// TOML tables (incl. mixed-type enums like `enum = ["ok", 1]`, TOML 1.0). The
|
|
102
|
+
// shared IR uses `parseConfigToml` + `safeJsonParse` under the hood.
|
|
103
|
+
const ir = describeWorkflowInvoker({
|
|
104
|
+
fileStem: input.fileStem,
|
|
105
|
+
tomlContent: input.tomlContent,
|
|
106
|
+
});
|
|
107
|
+
if (!ir)
|
|
108
|
+
return null; // reserved workflow
|
|
109
|
+
const inputTypeName = workflowInputTypeName(ir.key);
|
|
110
|
+
const outputTypeName = workflowOutputTypeName(ir.key);
|
|
111
|
+
return {
|
|
112
|
+
key: ir.key,
|
|
113
|
+
syncCallable: ir.syncCallable,
|
|
114
|
+
inputTypeName,
|
|
115
|
+
outputTypeName,
|
|
116
|
+
factoryName: workflowFactoryName(ir.key),
|
|
117
|
+
inputDecl: renderTypeDecl(inputTypeName, ir.inputSchema),
|
|
118
|
+
outputDecl: renderTypeDecl(outputTypeName, ir.outputSchema),
|
|
119
|
+
inputRequired: ir.inputRequired,
|
|
120
|
+
// Object-shaped only when the schema declares exactly `type: "object"` —
|
|
121
|
+
// the one case where `Partial<<Key>Input>` is a sound cron `rootInput`
|
|
122
|
+
// type. Schema-less / union / scalar / array → not object-shaped. Decided
|
|
123
|
+
// in the SHARED IR (#2806) so the Swift cron helper cannot disagree.
|
|
124
|
+
inputIsObjectShaped: ir.inputIsObjectShaped,
|
|
125
|
+
requiresClientApply: ir.requiresClientApply,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Render the typed invoker factory for one workflow.
|
|
130
|
+
*
|
|
131
|
+
* Every line shape here is emitted the way Prettier's default config would
|
|
132
|
+
* print it (#1565) — see `codegen-shared/prettierStable.ts`. `runSync`/`start`
|
|
133
|
+
* always break their parameter list: the shortest possible
|
|
134
|
+
* `opts: {…} & Omit<…>` parameter is already wider than the 80-column budget,
|
|
135
|
+
* so there is no width decision to make there.
|
|
136
|
+
*/
|
|
137
|
+
function renderFactory(wf) {
|
|
138
|
+
const keyLiteral = tsStringLiteral(wf.key);
|
|
139
|
+
const inputMember = wf.inputRequired
|
|
140
|
+
? `input: ${wf.inputTypeName}`
|
|
141
|
+
: `input?: ${wf.inputTypeName}`;
|
|
142
|
+
const lines = [
|
|
143
|
+
renderParenList(`export function ${wf.factoryName}`, ["client: JsBaoClient"], " {", 0),
|
|
144
|
+
` return {`,
|
|
145
|
+
];
|
|
146
|
+
// `opts: { input: X } & Omit<<Options>, "workflowKey" | "input">` — the
|
|
147
|
+
// intersection breaks inside the `Omit<...>` when it overflows.
|
|
148
|
+
const optsParam = (optionsTypeName) => {
|
|
149
|
+
const node = intersection([
|
|
150
|
+
objectType([inputMember]),
|
|
151
|
+
generic("Omit", [
|
|
152
|
+
atom(optionsTypeName),
|
|
153
|
+
union([atom(`"workflowKey"`), atom(`"input"`)]),
|
|
154
|
+
]),
|
|
155
|
+
]);
|
|
156
|
+
const head = `${indent(3)}opts: `;
|
|
157
|
+
return `${head}${printType(node, head.length, 3, 1)},`;
|
|
158
|
+
};
|
|
159
|
+
// Spread `opts` FIRST, then set `workflowKey` LAST, so the factory's intended
|
|
160
|
+
// key always wins. `Omit<..., "workflowKey">` only rejects an excess
|
|
161
|
+
// `workflowKey` on object literals; a caller passing an options *variable*
|
|
162
|
+
// carrying an extra `workflowKey` (or any untyped JS caller) would otherwise
|
|
163
|
+
// override the key and invoke the wrong workflow if the spread came last.
|
|
164
|
+
const invocation = (method, typeArgs, optionsTypeName) => renderArrowCall({
|
|
165
|
+
head: [
|
|
166
|
+
`${indent(2)}${method}: (`,
|
|
167
|
+
optsParam(optionsTypeName),
|
|
168
|
+
`${indent(2)}) =>`,
|
|
169
|
+
].join("\n"),
|
|
170
|
+
callee: generic(`client.workflows.${method}`, typeArgs.map(atom)),
|
|
171
|
+
leadingArgs: [],
|
|
172
|
+
objectMembers: ["...opts", { key: "workflowKey", value: keyLiteral }],
|
|
173
|
+
level: 3,
|
|
174
|
+
tail: ",",
|
|
175
|
+
});
|
|
176
|
+
if (wf.syncCallable) {
|
|
177
|
+
lines.push(invocation("runSync", [wf.inputTypeName, wf.outputTypeName], "RunSyncWorkflowOptions"));
|
|
178
|
+
}
|
|
179
|
+
lines.push(invocation("start", [wf.inputTypeName], "StartWorkflowOptions"));
|
|
180
|
+
// Typed status fetch (#1512), emitted for EVERY non-reserved workflow — not
|
|
181
|
+
// gated on `syncCallable`, since async-only workflows are exactly the ones
|
|
182
|
+
// that need a typed `status.output`. `output` is bound to `<Key>Output` from
|
|
183
|
+
// the workflow's `outputSchema` (schema-less → `unknown`, same as the sync
|
|
184
|
+
// path). `runKey` stays required (unlike start/runSync, which auto-generate
|
|
185
|
+
// it — you cannot fetch a run's status without knowing which run). Same
|
|
186
|
+
// spread-first / key-last ordering so an untyped caller cannot override the
|
|
187
|
+
// key and read the wrong workflow's status.
|
|
188
|
+
//
|
|
189
|
+
// Its `opts` parameter carries no generated names, so it always fits on one
|
|
190
|
+
// line — unlike start/runSync above.
|
|
191
|
+
lines.push(renderArrowCall({
|
|
192
|
+
head: `${indent(2)}getStatus: (opts: Omit<GetWorkflowStatusOptions, "workflowKey">) =>`,
|
|
193
|
+
callee: generic("client.workflows.getStatus", [atom(wf.outputTypeName)]),
|
|
194
|
+
leadingArgs: [],
|
|
195
|
+
objectMembers: ["...opts", { key: "workflowKey", value: keyLiteral }],
|
|
196
|
+
level: 3,
|
|
197
|
+
tail: ",",
|
|
198
|
+
}));
|
|
199
|
+
// Typed termination (#1543), emitted for EVERY non-reserved workflow — any
|
|
200
|
+
// run can be terminated. `output` is bound to `<Key>Output` (a terminated run
|
|
201
|
+
// can carry partial output), same schema-less → `unknown` rule as getStatus.
|
|
202
|
+
// `runKey` stays required. Same spread-first / key-last ordering so an untyped
|
|
203
|
+
// caller cannot override the key and terminate the wrong workflow's run. This
|
|
204
|
+
// member reverses #1512's start/status-only decision.
|
|
205
|
+
lines.push(renderArrowProperty({
|
|
206
|
+
level: 2,
|
|
207
|
+
key: "terminate",
|
|
208
|
+
params: [`opts: Omit<TerminateWorkflowOptions, "workflowKey">`],
|
|
209
|
+
signatureTail: " =>",
|
|
210
|
+
callee: generic("client.workflows.terminate", [atom(wf.outputTypeName)]),
|
|
211
|
+
leadingArgs: [],
|
|
212
|
+
objectMembers: ["...opts", { key: "workflowKey", value: keyLiteral }],
|
|
213
|
+
tail: ",",
|
|
214
|
+
}));
|
|
215
|
+
// Typed apply handler (#1543 Phase 2), emitted ONLY for an apply-mode
|
|
216
|
+
// workflow (`requiresClientApply !== false` — the same default the server
|
|
217
|
+
// uses to decide a completed run needs a client apply). `WorkflowDefineOptions<O>`
|
|
218
|
+
// and `WorkflowApplyHandler<O>` come from #1542; binding `<Key>Output` here
|
|
219
|
+
// makes the `onApply` callback's `output` the workflow's real output type
|
|
220
|
+
// instead of `any`. The key is passed as a positional argument, so there is
|
|
221
|
+
// no spread a caller could use to override it.
|
|
222
|
+
//
|
|
223
|
+
// No `getPendingApplies` member: #1542 shipped it as a concrete
|
|
224
|
+
// `PendingApply[]` (the server element carries no `output`, so there is no
|
|
225
|
+
// output generic to bind), and the call is scoped to a DOCUMENT rather than
|
|
226
|
+
// a workflow — a per-workflow member would bind nothing and would wrongly
|
|
227
|
+
// suggest the result only covers this workflow.
|
|
228
|
+
if (wf.requiresClientApply) {
|
|
229
|
+
lines.push(renderArrowProperty({
|
|
230
|
+
level: 2,
|
|
231
|
+
key: "define",
|
|
232
|
+
params: [`options: WorkflowDefineOptions<${wf.outputTypeName}>`],
|
|
233
|
+
signatureTail: " =>",
|
|
234
|
+
callee: generic("client.workflows.define", [atom(wf.outputTypeName)]),
|
|
235
|
+
leadingArgs: [keyLiteral, "options"],
|
|
236
|
+
tail: ",",
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
// Typed cron-trigger create/update (#1543), folded INTO the factory (not a
|
|
240
|
+
// separate export). The client's own `rootInput` generic (#1542) is bound to
|
|
241
|
+
// `<Key>Input`: `Partial<...>` for an object-shaped schema (an `inputMapping`
|
|
242
|
+
// may supply the rest), the full type otherwise. Binding the generic rather
|
|
243
|
+
// than restating the field keeps the caller-facing params in step with the
|
|
244
|
+
// client contract — notably `update` accepts `rootInput: null` to clear a
|
|
245
|
+
// stored root input, while `create` does not (the server rejects a null there
|
|
246
|
+
// with a 400). `workflowKey` is Omit-ted from the caller-facing params and
|
|
247
|
+
// pinned LAST so a caller can't redirect the trigger at another workflow.
|
|
248
|
+
// Nothing is spread after `workflowKey` — `rootInput` rides in via `...params`
|
|
249
|
+
// — preserving the key-last convention.
|
|
250
|
+
// `rootInput` is `Partial<<Key>Input>` for an object-shaped schema (an
|
|
251
|
+
// `inputMapping` may supply the rest) and the full `<Key>Input` otherwise.
|
|
252
|
+
// Built as a `TypeNode` so `printType` can break the nested type-argument
|
|
253
|
+
// lists Prettier opens up at long key lengths (e.g.
|
|
254
|
+
// `Omit<CreateCronTriggerParams<Partial<...>>, "workflowKey">`).
|
|
255
|
+
const rootInputNode = wf.inputIsObjectShaped
|
|
256
|
+
? generic("Partial", [atom(wf.inputTypeName)])
|
|
257
|
+
: atom(wf.inputTypeName);
|
|
258
|
+
const cronParam = (paramsGeneric) => ({
|
|
259
|
+
name: "params",
|
|
260
|
+
type: generic("Omit", [
|
|
261
|
+
generic(paramsGeneric, [rootInputNode]),
|
|
262
|
+
atom(`"workflowKey"`),
|
|
263
|
+
]),
|
|
264
|
+
});
|
|
265
|
+
lines.push([
|
|
266
|
+
` cronTriggers: {`,
|
|
267
|
+
renderArrowProperty({
|
|
268
|
+
level: 3,
|
|
269
|
+
key: "create",
|
|
270
|
+
params: [cronParam("CreateCronTriggerParams")],
|
|
271
|
+
signatureTail: " =>",
|
|
272
|
+
callee: generic("client.cronTriggers.create", [rootInputNode]),
|
|
273
|
+
leadingArgs: [],
|
|
274
|
+
objectMembers: ["...params", { key: "workflowKey", value: keyLiteral }],
|
|
275
|
+
tail: ",",
|
|
276
|
+
}),
|
|
277
|
+
renderArrowProperty({
|
|
278
|
+
level: 3,
|
|
279
|
+
key: "update",
|
|
280
|
+
params: ["triggerId: string", cronParam("UpdateCronTriggerParams")],
|
|
281
|
+
signatureTail: " =>",
|
|
282
|
+
callee: generic("client.cronTriggers.update", [rootInputNode]),
|
|
283
|
+
leadingArgs: ["triggerId"],
|
|
284
|
+
objectMembers: ["...params", { key: "workflowKey", value: keyLiteral }],
|
|
285
|
+
tail: ",",
|
|
286
|
+
}),
|
|
287
|
+
` },`,
|
|
288
|
+
].join("\n"));
|
|
289
|
+
lines.push(` };`, `}`);
|
|
290
|
+
return lines.join("\n");
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Render the full `<key>.generated.ts` content for a single workflow TOML input.
|
|
294
|
+
* Returns null for a reserved (`__internal.*`) workflow. Pure — exported so
|
|
295
|
+
* tests can assert on the string directly.
|
|
296
|
+
*/
|
|
297
|
+
export function renderWorkflowFile(input) {
|
|
298
|
+
const wf = parseWorkflow(input);
|
|
299
|
+
if (!wf)
|
|
300
|
+
return null;
|
|
301
|
+
const fingerprint = fingerprintToml(input.tomlContent);
|
|
302
|
+
// Only import the option types actually referenced, so the generated file
|
|
303
|
+
// compiles under a consumer's `noUnusedLocals`. `GetWorkflowStatusOptions`,
|
|
304
|
+
// `TerminateWorkflowOptions`, and the two cron-param types are always
|
|
305
|
+
// referenced now — every factory emits `getStatus`, `terminate` (#1512 /
|
|
306
|
+
// #1543), and `cronTriggers.{create,update}` (#1543).
|
|
307
|
+
const imports = [
|
|
308
|
+
"CreateCronTriggerParams",
|
|
309
|
+
"GetWorkflowStatusOptions",
|
|
310
|
+
"JsBaoClient",
|
|
311
|
+
"StartWorkflowOptions",
|
|
312
|
+
"TerminateWorkflowOptions",
|
|
313
|
+
"UpdateCronTriggerParams",
|
|
314
|
+
];
|
|
315
|
+
if (wf.syncCallable)
|
|
316
|
+
imports.push("RunSyncWorkflowOptions");
|
|
317
|
+
// Only an apply-mode workflow emits `define`, so its option type is imported
|
|
318
|
+
// only then — a non-apply-mode file would otherwise fail `noUnusedLocals`.
|
|
319
|
+
if (wf.requiresClientApply)
|
|
320
|
+
imports.push("WorkflowDefineOptions");
|
|
321
|
+
imports.sort();
|
|
322
|
+
const blocks = [];
|
|
323
|
+
blocks.push([
|
|
324
|
+
`// AUTO-GENERATED FROM workflows/${wf.key}.toml — DO NOT EDIT.`,
|
|
325
|
+
"// Run `primitive workflows codegen` to regenerate.",
|
|
326
|
+
`// fingerprint: ${fingerprint}`,
|
|
327
|
+
].join("\n"));
|
|
328
|
+
blocks.push(`import type {\n${imports
|
|
329
|
+
.map((i) => ` ${i},`)
|
|
330
|
+
.join("\n")}\n} from "${CLIENT_PACKAGE}";`);
|
|
331
|
+
blocks.push(wf.inputDecl);
|
|
332
|
+
blocks.push(wf.outputDecl);
|
|
333
|
+
blocks.push(renderFactory(wf));
|
|
334
|
+
return { key: wf.key, content: blocks.join("\n\n") + "\n" };
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Run workflow codegen end-to-end. One `<key>.generated.ts` per workflow;
|
|
338
|
+
* delegates the disk lifecycle to the shared writer/checker, exactly like
|
|
339
|
+
* `databases codegen`.
|
|
340
|
+
*/
|
|
341
|
+
export async function generateWorkflowTypes(options) {
|
|
342
|
+
const outAbs = path.resolve(options.outputDir);
|
|
343
|
+
const filesToWrite = new Map();
|
|
344
|
+
for (const input of options.inputs) {
|
|
345
|
+
const rendered = renderWorkflowFile(input);
|
|
346
|
+
if (!rendered)
|
|
347
|
+
continue; // reserved workflow — no file
|
|
348
|
+
const filePath = path.join(outAbs, `${rendered.key}${GENERATED_FILE_SUFFIX}`);
|
|
349
|
+
filesToWrite.set(filePath, rendered.content);
|
|
350
|
+
}
|
|
351
|
+
return await writeOrCheckGeneratedFiles({
|
|
352
|
+
outputDir: outAbs,
|
|
353
|
+
filesToWrite,
|
|
354
|
+
check: options.check,
|
|
355
|
+
// A single-workflow filter run owns only a subset of the generated files,
|
|
356
|
+
// so orphan cleanup / stale detection must be scoped to the filtered file.
|
|
357
|
+
fullOwnership: options.singleWorkflow !== true,
|
|
358
|
+
generatedSuffix: GENERATED_FILE_SUFFIX,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../src/lib/workflow-codegen/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,CAAC;IAE/B,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAqC;IAErC,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,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,QAAQ;YAAE,SAAS,CAAC,8BAA8B;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CACxB,MAAM,EACN,GAAG,QAAQ,CAAC,GAAG,GAAG,qBAAqB,EAAE,CAC1C,CAAC;QACF,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,MAAM,0BAA0B,CAAC;QACtC,SAAS,EAAE,MAAM;QACjB,YAAY;QACZ,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,0EAA0E;QAC1E,2EAA2E;QAC3E,aAAa,EAAE,OAAO,CAAC,cAAc,KAAK,IAAI;QAC9C,eAAe,EAAE,qBAAqB;KACvC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared workflow-invoker IR (issue #1547, Phase 3).
|
|
3
|
+
*
|
|
4
|
+
* The typed invoker factory is generated on BOTH the TypeScript side
|
|
5
|
+
* (`workflow-codegen/generator.ts`) and the Swift side
|
|
6
|
+
* (`swift-codegen/generator.ts`). The maintainer decision (item 5, binding)
|
|
7
|
+
* requires that invoker generation reuse ONE description of the workflow's
|
|
8
|
+
* operation metadata — the runtime key, whether `runSync` is emitted
|
|
9
|
+
* (`syncCallable`), whether `input` is a required argument, and whether the
|
|
10
|
+
* workflow is apply-mode (`requiresClientApply`) — rather than each language
|
|
11
|
+
* renderer re-deriving it from the TOML. This module is that
|
|
12
|
+
* single source: both renderers call `describeWorkflowInvoker` and read the
|
|
13
|
+
* SAME `WorkflowInvokerIR`, so the two clients can never disagree on which
|
|
14
|
+
* operations a workflow exposes or whether its input is required.
|
|
15
|
+
*
|
|
16
|
+
* What stays language-specific (and is therefore NOT in the IR): the emitted
|
|
17
|
+
* identifiers (the TS and Swift base names come from different naming helpers)
|
|
18
|
+
* and the rendered type declarations. The IR carries only the parsed schemas +
|
|
19
|
+
* the neutral operation flags; each renderer turns the schemas into its own
|
|
20
|
+
* syntax.
|
|
21
|
+
*/
|
|
22
|
+
import { INTERNAL_WORKFLOW_KEY_PREFIX } from "../platform-owned.js";
|
|
23
|
+
export { INTERNAL_WORKFLOW_KEY_PREFIX };
|
|
24
|
+
/** Raw inputs a renderer already has on hand for one workflow TOML. */
|
|
25
|
+
export interface WorkflowInvokerSource {
|
|
26
|
+
/** Source `.toml` filename stem (fallback key when `[workflow].key` is absent). */
|
|
27
|
+
fileStem: string;
|
|
28
|
+
/** Raw TOML content (already read from disk). */
|
|
29
|
+
tomlContent: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Language-neutral description of one workflow's invoker surface. Consumed by
|
|
33
|
+
* both the TS and Swift invoker renderers; neither reconstructs these decisions
|
|
34
|
+
* on its own.
|
|
35
|
+
*/
|
|
36
|
+
export interface WorkflowInvokerIR {
|
|
37
|
+
/**
|
|
38
|
+
* The ORIGINAL workflow key. The runtime call always passes this verbatim —
|
|
39
|
+
* only emitted identifiers are sanitized (per language).
|
|
40
|
+
*/
|
|
41
|
+
key: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the workflow is sync-callable. `runSync` is emitted ONLY when this
|
|
44
|
+
* is true (the server rejects run-sync for non-sync-callable workflows), on
|
|
45
|
+
* both clients.
|
|
46
|
+
*/
|
|
47
|
+
syncCallable: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether `input` is a REQUIRED argument. True iff the input schema rejects
|
|
50
|
+
* the empty object `{}` (the client's `input ?? {}` fallback would then fail
|
|
51
|
+
* validation). A schema-less workflow accepts anything → optional. Computed
|
|
52
|
+
* ONCE here via `schemaRejectsEmptyObject`, shared with both renderers.
|
|
53
|
+
*/
|
|
54
|
+
inputRequired: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the workflow is apply-mode — its completed run waits for a client
|
|
57
|
+
* to apply the output. Mirrors the server's default: apply-mode unless the
|
|
58
|
+
* TOML sets `requiresClientApply = false` (`src/workflows/app-workflow.ts`).
|
|
59
|
+
* Only an apply-mode workflow gets a `define` member on the generated
|
|
60
|
+
* invoker (issue #1543). Parsed here, alongside `syncCallable`, so no
|
|
61
|
+
* renderer reparses the TOML for it.
|
|
62
|
+
*/
|
|
63
|
+
requiresClientApply: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether the input schema is a plain object (`type: "object"`). Only an
|
|
66
|
+
* object-shaped input can be partialized, which is what each renderer's
|
|
67
|
+
* cron-trigger `rootInput` decision turns on: TS types it
|
|
68
|
+
* `Partial<<Key>Input>` (an `inputMapping` may supply the rest) and leaves
|
|
69
|
+
* Swift's — which has no `Partial<>` — an open `JSONValue`; anything else
|
|
70
|
+
* (schema-less / union / scalar / array) binds the full `<Key>Input` on both.
|
|
71
|
+
* Decided ONCE here (#2806) so the two renderers cannot disagree about which
|
|
72
|
+
* inputs are partializable.
|
|
73
|
+
*/
|
|
74
|
+
inputIsObjectShaped: boolean;
|
|
75
|
+
/** Parsed input schema, or `undefined` when absent. */
|
|
76
|
+
inputSchema: unknown;
|
|
77
|
+
/** Parsed output schema, or `undefined` when absent. */
|
|
78
|
+
outputSchema: unknown;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* True for a platform-owned (reserved) workflow key. Thin alias over the shared
|
|
82
|
+
* `isPlatformOwnedWorkflowKey` (#1660) kept for existing callers of this name.
|
|
83
|
+
*/
|
|
84
|
+
export declare function isReservedWorkflowKey(key: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Parse one workflow TOML into the shared invoker IR. Returns `null` for a
|
|
87
|
+
* reserved (`__internal.*`) workflow (no invoker is generated). Throws on
|
|
88
|
+
* malformed schema JSON (fail-and-exit) — the honest `undefined`/`unknown`
|
|
89
|
+
* fallback is for valid-but-untypeable schemas only.
|
|
90
|
+
*
|
|
91
|
+
* This is the ONE place that reads `syncCallable` / `requiresClientApply` and
|
|
92
|
+
* computes required-vs-optional `input`; both language generators call it.
|
|
93
|
+
*/
|
|
94
|
+
export declare function describeWorkflowInvoker(source: WorkflowInvokerSource): WorkflowInvokerIR | null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared workflow-invoker IR (issue #1547, Phase 3).
|
|
3
|
+
*
|
|
4
|
+
* The typed invoker factory is generated on BOTH the TypeScript side
|
|
5
|
+
* (`workflow-codegen/generator.ts`) and the Swift side
|
|
6
|
+
* (`swift-codegen/generator.ts`). The maintainer decision (item 5, binding)
|
|
7
|
+
* requires that invoker generation reuse ONE description of the workflow's
|
|
8
|
+
* operation metadata — the runtime key, whether `runSync` is emitted
|
|
9
|
+
* (`syncCallable`), whether `input` is a required argument, and whether the
|
|
10
|
+
* workflow is apply-mode (`requiresClientApply`) — rather than each language
|
|
11
|
+
* renderer re-deriving it from the TOML. This module is that
|
|
12
|
+
* single source: both renderers call `describeWorkflowInvoker` and read the
|
|
13
|
+
* SAME `WorkflowInvokerIR`, so the two clients can never disagree on which
|
|
14
|
+
* operations a workflow exposes or whether its input is required.
|
|
15
|
+
*
|
|
16
|
+
* What stays language-specific (and is therefore NOT in the IR): the emitted
|
|
17
|
+
* identifiers (the TS and Swift base names come from different naming helpers)
|
|
18
|
+
* and the rendered type declarations. The IR carries only the parsed schemas +
|
|
19
|
+
* the neutral operation flags; each renderer turns the schemas into its own
|
|
20
|
+
* syntax.
|
|
21
|
+
*/
|
|
22
|
+
import { parseConfigToml } from "../config-toml.js";
|
|
23
|
+
import { safeJsonParse } from "../workflow-payload.js";
|
|
24
|
+
import { schemaRejectsEmptyObject } from "./schemaToTs.js";
|
|
25
|
+
import { describeSchema } from "./generated-schema-descriptor.js";
|
|
26
|
+
import { INTERNAL_WORKFLOW_KEY_PREFIX, isPlatformOwnedWorkflowKey, } from "../platform-owned.js";
|
|
27
|
+
// Re-export so existing importers of these codegen symbols keep working; the
|
|
28
|
+
// single source of truth is now `../platform-owned.js` (#1660), shared with the
|
|
29
|
+
// `sync` pull/diff/push filters so codegen and sync can never drift.
|
|
30
|
+
export { INTERNAL_WORKFLOW_KEY_PREFIX };
|
|
31
|
+
/**
|
|
32
|
+
* True for a platform-owned (reserved) workflow key. Thin alias over the shared
|
|
33
|
+
* `isPlatformOwnedWorkflowKey` (#1660) kept for existing callers of this name.
|
|
34
|
+
*/
|
|
35
|
+
export function isReservedWorkflowKey(key) {
|
|
36
|
+
return isPlatformOwnedWorkflowKey(key);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parse one workflow TOML into the shared invoker IR. Returns `null` for a
|
|
40
|
+
* reserved (`__internal.*`) workflow (no invoker is generated). Throws on
|
|
41
|
+
* malformed schema JSON (fail-and-exit) — the honest `undefined`/`unknown`
|
|
42
|
+
* fallback is for valid-but-untypeable schemas only.
|
|
43
|
+
*
|
|
44
|
+
* This is the ONE place that reads `syncCallable` / `requiresClientApply` and
|
|
45
|
+
* computes required-vs-optional `input`; both language generators call it.
|
|
46
|
+
*/
|
|
47
|
+
export function describeWorkflowInvoker(source) {
|
|
48
|
+
const data = parseConfigToml(source.tomlContent);
|
|
49
|
+
const workflow = data?.workflow ?? {};
|
|
50
|
+
const key = typeof workflow.key === "string" && workflow.key.length > 0
|
|
51
|
+
? workflow.key
|
|
52
|
+
: source.fileStem;
|
|
53
|
+
if (isReservedWorkflowKey(key))
|
|
54
|
+
return null;
|
|
55
|
+
// safeJsonParse throws on invalid JSON in a schema string — let it bubble.
|
|
56
|
+
const inputSchema = safeJsonParse(workflow.inputSchema);
|
|
57
|
+
const outputSchema = safeJsonParse(workflow.outputSchema);
|
|
58
|
+
return {
|
|
59
|
+
key,
|
|
60
|
+
syncCallable: workflow.syncCallable === true,
|
|
61
|
+
// `input` is required iff the schema rejects the client's `{}` fallback.
|
|
62
|
+
// A schema-less workflow (`undefined`) accepts anything → optional.
|
|
63
|
+
inputRequired: inputSchema !== undefined && schemaRejectsEmptyObject(inputSchema),
|
|
64
|
+
// Apply-mode unless explicitly disabled — the same `!== false` default the
|
|
65
|
+
// server applies when it decides whether a completed run needs a client
|
|
66
|
+
// apply. An absent key means apply-mode.
|
|
67
|
+
requiresClientApply: workflow.requiresClientApply !== false,
|
|
68
|
+
// Object-shaped only when the schema declares exactly `type: "object"` —
|
|
69
|
+
// the one case a cron `rootInput` may legitimately be partial.
|
|
70
|
+
inputIsObjectShaped: inputSchema !== undefined &&
|
|
71
|
+
describeSchema(inputSchema).singularType === "object",
|
|
72
|
+
inputSchema,
|
|
73
|
+
outputSchema,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=invokerIR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invokerIR.js","sourceRoot":"","sources":["../../../../src/lib/workflow-codegen/invokerIR.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,GAC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ACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifier-naming helpers for `workflows codegen` (issue #1442).
|
|
3
|
+
*
|
|
4
|
+
* Workflow keys resolve case-insensitively server-side and may contain
|
|
5
|
+
* characters that aren't valid TS identifiers (`.`, `-`). Only the emitted
|
|
6
|
+
* identifiers are sanitized — the runtime call always passes the ORIGINAL key
|
|
7
|
+
* string.
|
|
8
|
+
*
|
|
9
|
+
* Type names: `pascalCase(key) + "Input" | "Output"` (reuses `pascalCase` from
|
|
10
|
+
* the database codegen so the two commands share one PascalCase rule).
|
|
11
|
+
* Factory property: a camelCase form of the key.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* `create-checkout-session` / `createCheckoutSession` → `CreateCheckoutSession`.
|
|
15
|
+
* A digit-leading key (`123-job` → `_123Job`) is prefixed with `_` so the
|
|
16
|
+
* emitted type name is a valid TS identifier.
|
|
17
|
+
*/
|
|
18
|
+
export declare function workflowTypeBaseName(key: string): string;
|
|
19
|
+
/** PascalCase base + `Input` (e.g. `CreateCheckoutSessionInput`). */
|
|
20
|
+
export declare function workflowInputTypeName(key: string): string;
|
|
21
|
+
/** PascalCase base + `Output` (e.g. `CreateCheckoutSessionOutput`). */
|
|
22
|
+
export declare function workflowOutputTypeName(key: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* camelCase factory function name for a workflow key: PascalCase, then lowercase
|
|
25
|
+
* the first character (`create-checkout-session` → `createCheckoutSession`,
|
|
26
|
+
* `refresh-sheet` → `refreshSheet`). Used as the top-level exported factory
|
|
27
|
+
* function name in the per-workflow generated file, so it must be a legal
|
|
28
|
+
* function identifier: a digit-leading key (`123-job` → `_123Job`) is
|
|
29
|
+
* underscore-prefixed, and a key that lands on a JS reserved word (`delete`,
|
|
30
|
+
* `new`, `import`) is underscore-suffixed (`delete_`). Only the emitted
|
|
31
|
+
* identifier changes; the runtime call still passes the ORIGINAL key string.
|
|
32
|
+
*/
|
|
33
|
+
export declare function workflowFactoryName(key: string): string;
|