primitive-admin 1.1.0-alpha.6 → 1.1.0-alpha.60
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 +389 -71
- package/assets/skill/skills/primitive-platform/SKILL.md +670 -0
- package/dist/bin/primitive.d.ts +2 -0
- package/dist/bin/primitive.js +287 -17
- 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 +554 -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 +27 -80
- 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 +526 -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 +35 -0
- package/dist/src/commands/config.js +437 -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 +204 -0
- package/dist/src/commands/cron-triggers.js.map +1 -0
- package/dist/src/commands/database-types.d.ts +2 -0
- package/dist/src/commands/database-types.js +171 -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 +2153 -96
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.d.ts +2 -0
- package/dist/src/commands/documents.js +1230 -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 +12 -0
- package/dist/src/commands/env.js +260 -0
- package/dist/src/commands/env.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 +17 -0
- package/dist/src/commands/init.js +964 -202
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.d.ts +2 -0
- package/dist/src/commands/integrations.js +484 -205
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/llm.d.ts +2 -0
- package/dist/src/commands/llm.js +13 -8
- 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.d.ts +2 -0
- package/dist/src/commands/metadata.js +406 -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 +135 -355
- 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 +271 -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 +739 -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/settings.d.ts +18 -0
- package/dist/src/commands/settings.js +54 -0
- package/dist/src/commands/settings.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 +125 -0
- package/dist/src/commands/sync-app-settings.js +380 -0
- package/dist/src/commands/sync-app-settings.js.map +1 -0
- package/dist/src/commands/sync.d.ts +958 -0
- package/dist/src/commands/sync.js +8954 -812
- 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 +440 -22
- 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 +442 -0
- package/dist/src/commands/webhooks.js.map +1 -0
- package/dist/src/commands/workflows.d.ts +94 -0
- package/dist/src/commands/workflows.js +1581 -448
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +1814 -0
- package/dist/src/lib/api-client.js +1655 -103
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +130 -0
- package/dist/src/lib/app-settings-descriptor.js +262 -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 +97 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js +184 -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 +108 -0
- package/dist/src/lib/config-object-descriptor.js +607 -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 +105 -0
- package/dist/src/lib/config-payload.js.map +1 -0
- package/dist/src/lib/config-surface.d.ts +93 -0
- package/dist/src/lib/config-surface.js +178 -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.d.ts +62 -0
- package/dist/src/lib/env-resolver.js +121 -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 +266 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +578 -0
- package/dist/src/lib/generated-config-surfaces.js +3630 -0
- package/dist/src/lib/generated-config-surfaces.js.map +1 -0
- package/dist/src/lib/generated-template-lint.d.ts +206 -0
- package/dist/src/lib/generated-template-lint.js +589 -0
- package/dist/src/lib/generated-template-lint.js.map +1 -0
- package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
- package/dist/src/lib/generated-workflow-model-fields.js +53 -0
- package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
- package/dist/src/lib/google-client-secret-status.d.ts +35 -0
- package/dist/src/lib/google-client-secret-status.js +56 -0
- package/dist/src/lib/google-client-secret-status.js.map +1 -0
- package/dist/src/lib/init-config.d.ts +81 -0
- package/dist/src/lib/init-config.js +149 -0
- package/dist/src/lib/init-config.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/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 +51 -0
- package/dist/src/lib/platform-owned.js +64 -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 +219 -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 +71 -0
- package/dist/src/lib/resolve-init-server.js +94 -0
- package/dist/src/lib/resolve-init-server.js.map +1 -0
- package/dist/src/lib/resolve-platform.d.ts +45 -0
- package/dist/src/lib/resolve-platform.js +43 -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/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 +100 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js +682 -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 +85 -0
- package/dist/src/lib/swift-codegen/generator.js +266 -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 +90 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js +152 -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-paths.d.ts +72 -0
- package/dist/src/lib/sync-paths.js +130 -0
- package/dist/src/lib/sync-paths.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +445 -0
- package/dist/src/lib/sync-resource-types.js +812 -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 +121 -0
- package/dist/src/lib/template.js +447 -67
- package/dist/src/lib/template.js.map +1 -1
- 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 +51 -0
- package/dist/src/lib/workflow-apply.js +89 -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 +83 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js +71 -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-field-descriptor.d.ts +91 -0
- package/dist/src/lib/workflow-field-descriptor.js +153 -0
- package/dist/src/lib/workflow-field-descriptor.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 +71 -0
- package/dist/src/lib/workflow-include-preserve.js +153 -0
- package/dist/src/lib/workflow-include-preserve.js.map +1 -0
- package/dist/src/lib/workflow-payload.d.ts +86 -0
- package/dist/src/lib/workflow-payload.js +168 -0
- package/dist/src/lib/workflow-payload.js.map +1 -0
- package/dist/src/lib/workflow-toml-validator.d.ts +199 -0
- package/dist/src/lib/workflow-toml-validator.js +754 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -0
- package/dist/src/types/index.d.ts +533 -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 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../../../../src/lib/workflow-codegen/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;;;;;;GAOG;AACH,SAAS,0BAA0B,CAAC,IAAY;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;QACjC,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,0BAA0B,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,OAAO,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC;AAC7C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,GAAG,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU;IAClE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO;IACvE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK;IACvE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK;IACnE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ;IAClE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ;IACtE,OAAO;CACR,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IACvC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-Schema → TypeScript converter for `workflows codegen` (issue #1442).
|
|
3
|
+
*
|
|
4
|
+
* Workflow `inputSchema`/`outputSchema` are real JSON Schema. This converter
|
|
5
|
+
* types only the subset the server's validator descends into — and it reads
|
|
6
|
+
* that interpretation from the SAME descriptor the server validator consumes,
|
|
7
|
+
* vendored into the CLI as `generated-schema-descriptor.ts` (a byte copy of
|
|
8
|
+
* `src/workflows/schema-descriptor.ts`, kept fresh by
|
|
9
|
+
* `cli/scripts/gen-workflow-schema-descriptor.mjs` + its drift guard). So the
|
|
10
|
+
* generated type and the runtime validation can never disagree on:
|
|
11
|
+
*
|
|
12
|
+
* - `type` single scalar (`string`/`number`/`integer`/`boolean`/`null`) →
|
|
13
|
+
* the mapped TS scalar.
|
|
14
|
+
* - `type` array-union — only when every member is a scalar/`null` → a TS
|
|
15
|
+
* union. A union that contains `object` or `array` renders `unknown`,
|
|
16
|
+
* because the server only walks `properties`/`items` for the bare string
|
|
17
|
+
* `"object"`/`"array"` — a union is never descended, so a precise-looking
|
|
18
|
+
* type would over-promise.
|
|
19
|
+
* - `enum` → a scalar-literal union, intersected with the declared `type`
|
|
20
|
+
* first (the server gates on `type` before checking `enum`).
|
|
21
|
+
* - `type: "object"` with `properties` → a nested object type; `required[]`
|
|
22
|
+
* drives `name:` vs `name?:`. An OPEN object (no `additionalProperties:
|
|
23
|
+
* false`) also emits `[key: string]: unknown` so extra keys the runtime
|
|
24
|
+
* validator accepts don't hit TS excess-property errors; a CLOSED object
|
|
25
|
+
* (`additionalProperties: false`) omits the index signature.
|
|
26
|
+
* - `type: "array"` with `items` → `T[]`.
|
|
27
|
+
* - `oneOf` whose members are ALL `type: "object"` → a discriminated
|
|
28
|
+
* (tagged) union: the `|`-union of member object types, keyed by an
|
|
29
|
+
* auto-detected single-literal-`enum` discriminator (#1511). A defective
|
|
30
|
+
* all-object tagged union (no/ambiguous discriminator, <2 members) or an
|
|
31
|
+
* all-object `anyOf` (unsupported in v1) is a STRICT codegen error, not a
|
|
32
|
+
* silent `unknown` (Fork 3, resolved by the maintainer).
|
|
33
|
+
*
|
|
34
|
+
* Everything else the server ignores (`$ref`, `allOf`, `format`,
|
|
35
|
+
* `patternProperties`, numeric constraints, tuple `items`, and a `oneOf`/`anyOf`
|
|
36
|
+
* whose members are NOT all objects) renders `unknown`.
|
|
37
|
+
*
|
|
38
|
+
* Errors are NOT swallowed here — a malformed schema fails upstream at parse
|
|
39
|
+
* time, and a defective tagged union throws — this walker otherwise returns
|
|
40
|
+
* `unknown` for anything it does not recognize.
|
|
41
|
+
*
|
|
42
|
+
* FORMATTING CONTRACT (#1565): the types emitted here must be a fixed point of
|
|
43
|
+
* Prettier's DEFAULT config, since `workflows codegen --check` byte-compares
|
|
44
|
+
* the emission against disk. Long unions therefore render through
|
|
45
|
+
* `codegen-shared/prettierStable.ts` (which reproduces Prettier's width
|
|
46
|
+
* decision) instead of being joined with `" | "`. There is no Prettier
|
|
47
|
+
* dependency and no automated round-trip test, so verify any change to these
|
|
48
|
+
* shapes by hand — see that module's header.
|
|
49
|
+
*/
|
|
50
|
+
import { type TypeNode } from "../codegen-shared/prettierStable.js";
|
|
51
|
+
/**
|
|
52
|
+
* Convert a parsed JSON Schema node to a TypeScript type expression. Object
|
|
53
|
+
* types render multi-line (2-space indent per level); everything else renders
|
|
54
|
+
* on a single line unless it is too wide for Prettier's default print width
|
|
55
|
+
* (#1565). `indent` is the current indentation depth.
|
|
56
|
+
*/
|
|
57
|
+
export declare function schemaToTsType(schema: any, indent?: number): string;
|
|
58
|
+
/**
|
|
59
|
+
* `schemaToTsType` as a wrappable node — the emitters print it at the position
|
|
60
|
+
* it actually occupies so long unions/objects wrap exactly as Prettier would
|
|
61
|
+
* (#1565). See `codegen-shared/prettierStable.ts`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function schemaToTypeNode(schema: any): TypeNode;
|
|
64
|
+
/**
|
|
65
|
+
* True when the schema REJECTS an empty object `{}` — i.e. the client's
|
|
66
|
+
* `rootInput: options.input ?? {}` fallback would fail validation, so `input`
|
|
67
|
+
* must be a compile-time-required option (issue #1442, P4). Derived from the
|
|
68
|
+
* shared descriptor so it matches the server validator exactly:
|
|
69
|
+
*
|
|
70
|
+
* - a valid top-level discriminated-union (`oneOf`): the runtime always
|
|
71
|
+
* requires the discriminator present, so `{}` matches no case;
|
|
72
|
+
* - a declared top-level `type` that `{}` does not satisfy (anything but
|
|
73
|
+
* `object`, e.g. `string`/`array`, or a union with no `object` arm);
|
|
74
|
+
* - a top-level `enum` (a fresh `{}` is never an enum member);
|
|
75
|
+
* - `type: "object"` with a non-empty `required[]` (a missing required key).
|
|
76
|
+
*
|
|
77
|
+
* An all-optional object schema, or a schema with no top-level constraints,
|
|
78
|
+
* accepts `{}` → `input` is optional.
|
|
79
|
+
*/
|
|
80
|
+
export declare function schemaRejectsEmptyObject(schema: any): boolean;
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-Schema → TypeScript converter for `workflows codegen` (issue #1442).
|
|
3
|
+
*
|
|
4
|
+
* Workflow `inputSchema`/`outputSchema` are real JSON Schema. This converter
|
|
5
|
+
* types only the subset the server's validator descends into — and it reads
|
|
6
|
+
* that interpretation from the SAME descriptor the server validator consumes,
|
|
7
|
+
* vendored into the CLI as `generated-schema-descriptor.ts` (a byte copy of
|
|
8
|
+
* `src/workflows/schema-descriptor.ts`, kept fresh by
|
|
9
|
+
* `cli/scripts/gen-workflow-schema-descriptor.mjs` + its drift guard). So the
|
|
10
|
+
* generated type and the runtime validation can never disagree on:
|
|
11
|
+
*
|
|
12
|
+
* - `type` single scalar (`string`/`number`/`integer`/`boolean`/`null`) →
|
|
13
|
+
* the mapped TS scalar.
|
|
14
|
+
* - `type` array-union — only when every member is a scalar/`null` → a TS
|
|
15
|
+
* union. A union that contains `object` or `array` renders `unknown`,
|
|
16
|
+
* because the server only walks `properties`/`items` for the bare string
|
|
17
|
+
* `"object"`/`"array"` — a union is never descended, so a precise-looking
|
|
18
|
+
* type would over-promise.
|
|
19
|
+
* - `enum` → a scalar-literal union, intersected with the declared `type`
|
|
20
|
+
* first (the server gates on `type` before checking `enum`).
|
|
21
|
+
* - `type: "object"` with `properties` → a nested object type; `required[]`
|
|
22
|
+
* drives `name:` vs `name?:`. An OPEN object (no `additionalProperties:
|
|
23
|
+
* false`) also emits `[key: string]: unknown` so extra keys the runtime
|
|
24
|
+
* validator accepts don't hit TS excess-property errors; a CLOSED object
|
|
25
|
+
* (`additionalProperties: false`) omits the index signature.
|
|
26
|
+
* - `type: "array"` with `items` → `T[]`.
|
|
27
|
+
* - `oneOf` whose members are ALL `type: "object"` → a discriminated
|
|
28
|
+
* (tagged) union: the `|`-union of member object types, keyed by an
|
|
29
|
+
* auto-detected single-literal-`enum` discriminator (#1511). A defective
|
|
30
|
+
* all-object tagged union (no/ambiguous discriminator, <2 members) or an
|
|
31
|
+
* all-object `anyOf` (unsupported in v1) is a STRICT codegen error, not a
|
|
32
|
+
* silent `unknown` (Fork 3, resolved by the maintainer).
|
|
33
|
+
*
|
|
34
|
+
* Everything else the server ignores (`$ref`, `allOf`, `format`,
|
|
35
|
+
* `patternProperties`, numeric constraints, tuple `items`, and a `oneOf`/`anyOf`
|
|
36
|
+
* whose members are NOT all objects) renders `unknown`.
|
|
37
|
+
*
|
|
38
|
+
* Errors are NOT swallowed here — a malformed schema fails upstream at parse
|
|
39
|
+
* time, and a defective tagged union throws — this walker otherwise returns
|
|
40
|
+
* `unknown` for anything it does not recognize.
|
|
41
|
+
*
|
|
42
|
+
* FORMATTING CONTRACT (#1565): the types emitted here must be a fixed point of
|
|
43
|
+
* Prettier's DEFAULT config, since `workflows codegen --check` byte-compares
|
|
44
|
+
* the emission against disk. Long unions therefore render through
|
|
45
|
+
* `codegen-shared/prettierStable.ts` (which reproduces Prettier's width
|
|
46
|
+
* decision) instead of being joined with `" | "`. There is no Prettier
|
|
47
|
+
* dependency and no automated round-trip test, so verify any change to these
|
|
48
|
+
* shapes by hand — see that module's header.
|
|
49
|
+
*/
|
|
50
|
+
import { describeSchema, isType, } from "./generated-schema-descriptor.js";
|
|
51
|
+
import { arrayOf, atom, block, indent as pad2, printType, recordOf, renderMember, tsStringLiteral, union, } from "../codegen-shared/prettierStable.js";
|
|
52
|
+
/** Scalar JSON-schema types this converter maps to a concrete TS scalar. */
|
|
53
|
+
const SCALAR_TS = {
|
|
54
|
+
string: "string",
|
|
55
|
+
number: "number",
|
|
56
|
+
integer: "number",
|
|
57
|
+
boolean: "boolean",
|
|
58
|
+
null: "null",
|
|
59
|
+
};
|
|
60
|
+
/** A shared empty-object reference for the `{}`-rejection probe below. */
|
|
61
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
62
|
+
/**
|
|
63
|
+
* Render a scalar-literal union from an `enum` array. A string member is
|
|
64
|
+
* emitted via `tsStringLiteral` (Prettier's quote choice, #1565); a number,
|
|
65
|
+
* boolean, or `null` via `JSON.stringify`, which is already a Prettier fixed
|
|
66
|
+
* point for those. An object/array member has no TS literal form, so the whole
|
|
67
|
+
* enum falls back to `unknown` (returns `null` here).
|
|
68
|
+
*/
|
|
69
|
+
function tsUnionFromScalarEnum(values) {
|
|
70
|
+
if (!Array.isArray(values) || values.length === 0)
|
|
71
|
+
return null;
|
|
72
|
+
const literals = [];
|
|
73
|
+
const seen = new Set();
|
|
74
|
+
for (const v of values) {
|
|
75
|
+
if (v !== null && (typeof v === "object" || Array.isArray(v))) {
|
|
76
|
+
// Objects/arrays are not representable as TS literals.
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const literal = typeof v === "string" ? tsStringLiteral(v) : JSON.stringify(v);
|
|
80
|
+
if (literal === undefined)
|
|
81
|
+
return null; // e.g. `undefined` in the enum
|
|
82
|
+
if (!seen.has(literal)) {
|
|
83
|
+
seen.add(literal);
|
|
84
|
+
literals.push(literal);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return literals.length > 0 ? union(literals.map(atom)) : null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Convert a parsed JSON Schema node to a TypeScript type expression. Object
|
|
91
|
+
* types render multi-line (2-space indent per level); everything else renders
|
|
92
|
+
* on a single line unless it is too wide for Prettier's default print width
|
|
93
|
+
* (#1565). `indent` is the current indentation depth.
|
|
94
|
+
*/
|
|
95
|
+
export function schemaToTsType(schema, indent = 0) {
|
|
96
|
+
return printType(schemaToTypeNode(schema), indent * 2, indent);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* `schemaToTsType` as a wrappable node — the emitters print it at the position
|
|
100
|
+
* it actually occupies so long unions/objects wrap exactly as Prettier would
|
|
101
|
+
* (#1565). See `codegen-shared/prettierStable.ts`.
|
|
102
|
+
*/
|
|
103
|
+
export function schemaToTypeNode(schema) {
|
|
104
|
+
const d = describeSchema(schema);
|
|
105
|
+
// `enum` is the most specific constraint — the server checks it AFTER the
|
|
106
|
+
// type gate, so when both are present only the enum members that satisfy the
|
|
107
|
+
// declared type(s) are reachable. Emit just those (intersect with `type`
|
|
108
|
+
// via the shared `isType`). If the type filter leaves nothing representable,
|
|
109
|
+
// fall through to plain `type` rendering rather than over-promising.
|
|
110
|
+
if (d.enumValues) {
|
|
111
|
+
const allowedTypes = d.types;
|
|
112
|
+
const candidates = allowedTypes.length > 0
|
|
113
|
+
? d.enumValues.filter((v) => allowedTypes.some((t) => isType(v, t)))
|
|
114
|
+
: d.enumValues;
|
|
115
|
+
if (candidates.length === 0) {
|
|
116
|
+
// No enum member satisfies the declared type gate (or the enum is empty),
|
|
117
|
+
// so the runtime rejects EVERY value: the type gate lets some values
|
|
118
|
+
// through, then `enum.includes(value)` fails them all. The reachable set
|
|
119
|
+
// is empty → an uninhabitable `never`. Widening to the declared type here
|
|
120
|
+
// (e.g. `{type:"string", enum:[1]}` → `string`) would let typed callers
|
|
121
|
+
// pass values the server always rejects.
|
|
122
|
+
return atom("never");
|
|
123
|
+
}
|
|
124
|
+
const enumUnion = tsUnionFromScalarEnum(candidates);
|
|
125
|
+
if (enumUnion !== null)
|
|
126
|
+
return enumUnion;
|
|
127
|
+
// Candidates survive the type gate but aren't representable as TS literals
|
|
128
|
+
// (object/array enum members). With no declared type there is nothing to
|
|
129
|
+
// fall back on → `unknown`; otherwise fall through to plain `type`.
|
|
130
|
+
if (allowedTypes.length === 0)
|
|
131
|
+
return atom("unknown");
|
|
132
|
+
}
|
|
133
|
+
// Array-union type (e.g. `["string", "null"]`). Only scalar/null members get
|
|
134
|
+
// a precise union — the server never descends `properties`/`items` for a
|
|
135
|
+
// union, so an object/array member forces `unknown`.
|
|
136
|
+
if (d.isUnion) {
|
|
137
|
+
const parts = [];
|
|
138
|
+
const seen = new Set();
|
|
139
|
+
for (const t of d.types) {
|
|
140
|
+
const mapped = SCALAR_TS[t];
|
|
141
|
+
// object/array/unknown member
|
|
142
|
+
if (mapped === undefined)
|
|
143
|
+
return atom("unknown");
|
|
144
|
+
if (!seen.has(mapped)) {
|
|
145
|
+
seen.add(mapped);
|
|
146
|
+
parts.push(mapped);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return parts.length > 0 ? union(parts.map(atom)) : atom("unknown");
|
|
150
|
+
}
|
|
151
|
+
// Discriminated-union (`oneOf`) rendering (#1511). A qualifying tagged union
|
|
152
|
+
// has no top-level `type`, so this runs ahead of the `singularType === null`
|
|
153
|
+
// fallback. Render each member via the existing object rendering and join
|
|
154
|
+
// with `|` — the natural TS discriminated union TS narrows on. A defective
|
|
155
|
+
// all-object tagged union (`kind: "invalid"`) is a strict codegen error
|
|
156
|
+
// (Fork 3, resolved by the maintainer), not a silent `unknown`.
|
|
157
|
+
if (d.oneOf) {
|
|
158
|
+
if (d.oneOf.kind === "invalid") {
|
|
159
|
+
throw new Error(`workflows codegen: ${d.oneOf.reason}`);
|
|
160
|
+
}
|
|
161
|
+
const { discriminant } = d.oneOf;
|
|
162
|
+
const members = d.oneOf.members.map((m) => {
|
|
163
|
+
const md = describeSchema(m.schema);
|
|
164
|
+
// Every member is `type: "object"` with `properties`, so `md.object` is
|
|
165
|
+
// non-null — reuse the shared object rendering rather than reimplement it.
|
|
166
|
+
if (!md.object)
|
|
167
|
+
return schemaToTypeNode(m.schema);
|
|
168
|
+
// The runtime validator always requires the discriminator present before
|
|
169
|
+
// it can select a branch — regardless of whether the member lists it in
|
|
170
|
+
// its own `required`. Force it required so the generated union can't
|
|
171
|
+
// compile a value that omits the tag (which the runtime rejects as
|
|
172
|
+
// "matches no case") (#1511).
|
|
173
|
+
const required = md.object.required.includes(discriminant)
|
|
174
|
+
? md.object.required
|
|
175
|
+
: [...md.object.required, discriminant];
|
|
176
|
+
return objectNode({ ...md.object, required });
|
|
177
|
+
});
|
|
178
|
+
return union(members);
|
|
179
|
+
}
|
|
180
|
+
if (d.singularType === null) {
|
|
181
|
+
// No usable single type and no enum — the server enforces nothing.
|
|
182
|
+
return atom("unknown");
|
|
183
|
+
}
|
|
184
|
+
// Object: the server walks `properties`/`required` ONLY when the type is
|
|
185
|
+
// exactly `"object"`. `d.object` is non-null only in that case with declared
|
|
186
|
+
// properties; a typed object with no properties is open → Record.
|
|
187
|
+
if (d.singularType === "object") {
|
|
188
|
+
if (d.object)
|
|
189
|
+
return objectNode(d.object);
|
|
190
|
+
return recordOf("unknown");
|
|
191
|
+
}
|
|
192
|
+
// Array: the server walks `items` ONLY when the type is exactly `"array"`.
|
|
193
|
+
if (d.singularType === "array") {
|
|
194
|
+
const items = d.array ? d.array.items : undefined;
|
|
195
|
+
// Missing or tuple `items` (an array of schemas) is ignored → unknown[].
|
|
196
|
+
if (!items || typeof items !== "object" || Array.isArray(items)) {
|
|
197
|
+
return atom("unknown[]");
|
|
198
|
+
}
|
|
199
|
+
return arrayOf(schemaToTypeNode(items));
|
|
200
|
+
}
|
|
201
|
+
// Single scalar type.
|
|
202
|
+
const scalar = SCALAR_TS[d.singularType];
|
|
203
|
+
return scalar ? atom(scalar) : atom("unknown");
|
|
204
|
+
}
|
|
205
|
+
/** An object type as a node — always multi-line, so Prettier never collapses it. */
|
|
206
|
+
function objectNode(objectDesc) {
|
|
207
|
+
return block((level) => renderObjectType(objectDesc, level));
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Render an object descriptor (`describeSchema(...).object`) as a TS object
|
|
211
|
+
* type. `required[]` drives optionality. An OPEN object (not
|
|
212
|
+
* `additionalProperties: false`) emits `[key: string]: unknown` so extra keys
|
|
213
|
+
* the runtime accepts don't trip TS excess-property checks; a CLOSED object
|
|
214
|
+
* omits it.
|
|
215
|
+
*/
|
|
216
|
+
function renderObjectType(objectDesc, indent) {
|
|
217
|
+
const { properties, required, additionalPropertiesClosed } = objectDesc;
|
|
218
|
+
const propNames = Object.keys(properties);
|
|
219
|
+
const requiredSet = new Set(Array.isArray(required)
|
|
220
|
+
? required.filter((k) => typeof k === "string")
|
|
221
|
+
: []);
|
|
222
|
+
const pad = pad2(indent + 1);
|
|
223
|
+
const closePad = pad2(indent);
|
|
224
|
+
const propNameSet = new Set(propNames);
|
|
225
|
+
const lines = [];
|
|
226
|
+
for (const name of propNames) {
|
|
227
|
+
lines.push(renderMember(indent + 1, quotePropIfNeeded(name), !requiredSet.has(name), schemaToTypeNode(properties[name])));
|
|
228
|
+
}
|
|
229
|
+
// A key listed in `required` but absent from `properties` has no declared
|
|
230
|
+
// child schema, yet the validator still rejects an object missing it. Emit it
|
|
231
|
+
// as a required `unknown` member so the generated type demands the key too —
|
|
232
|
+
// otherwise `{properties:{}, required:["id"]}` would accept `{}`, which the
|
|
233
|
+
// runtime rejects.
|
|
234
|
+
for (const name of requiredSet) {
|
|
235
|
+
if (!propNameSet.has(name)) {
|
|
236
|
+
lines.push(`${pad}${quotePropIfNeeded(name)}: unknown;`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// Open objects accept extra keys at runtime; model that with an index
|
|
240
|
+
// signature so a call site passing an unlisted key still compiles.
|
|
241
|
+
if (!additionalPropertiesClosed) {
|
|
242
|
+
lines.push(`${pad}[key: string]: unknown;`);
|
|
243
|
+
}
|
|
244
|
+
// A closed object with no members at all renders `{}` — Prettier collapses an
|
|
245
|
+
// empty `{\n}` to `{}`, so emit it that way to stay byte-stable (#1565).
|
|
246
|
+
if (lines.length === 0)
|
|
247
|
+
return "{}";
|
|
248
|
+
return ["{", ...lines, `${closePad}}`].join("\n");
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Quote an object-property name when it is not a plain identifier (so keys with
|
|
252
|
+
* hyphens, dots, or other characters render as valid TS). A quoted key uses
|
|
253
|
+
* Prettier's quote choice so it stays a fixed point (#1565).
|
|
254
|
+
*/
|
|
255
|
+
function quotePropIfNeeded(name) {
|
|
256
|
+
if (/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name))
|
|
257
|
+
return name;
|
|
258
|
+
return tsStringLiteral(name);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* True when the schema REJECTS an empty object `{}` — i.e. the client's
|
|
262
|
+
* `rootInput: options.input ?? {}` fallback would fail validation, so `input`
|
|
263
|
+
* must be a compile-time-required option (issue #1442, P4). Derived from the
|
|
264
|
+
* shared descriptor so it matches the server validator exactly:
|
|
265
|
+
*
|
|
266
|
+
* - a valid top-level discriminated-union (`oneOf`): the runtime always
|
|
267
|
+
* requires the discriminator present, so `{}` matches no case;
|
|
268
|
+
* - a declared top-level `type` that `{}` does not satisfy (anything but
|
|
269
|
+
* `object`, e.g. `string`/`array`, or a union with no `object` arm);
|
|
270
|
+
* - a top-level `enum` (a fresh `{}` is never an enum member);
|
|
271
|
+
* - `type: "object"` with a non-empty `required[]` (a missing required key).
|
|
272
|
+
*
|
|
273
|
+
* An all-optional object schema, or a schema with no top-level constraints,
|
|
274
|
+
* accepts `{}` → `input` is optional.
|
|
275
|
+
*/
|
|
276
|
+
export function schemaRejectsEmptyObject(schema) {
|
|
277
|
+
const d = describeSchema(schema);
|
|
278
|
+
// 0. A valid discriminated-union (`oneOf`) always requires the discriminator
|
|
279
|
+
// present before the runtime can select a branch, so a fresh `{}` (the
|
|
280
|
+
// client's `input ?? {}` fallback) matches no case and is rejected. The
|
|
281
|
+
// generated `input` must therefore be required, not optional (#1511).
|
|
282
|
+
if (d.oneOf && d.oneOf.kind === "valid") {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
// 1. Type gate: `{}` must satisfy at least one declared type.
|
|
286
|
+
if (d.types.length && !d.types.some((t) => isType(EMPTY_OBJECT, t))) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
// 2. Enum gate: a JSON enum never contains a value reference-equal to `{}`,
|
|
290
|
+
// so any enum rejects it (mirrors `enum.includes(value)` at runtime).
|
|
291
|
+
if (d.enumValues && !d.enumValues.includes(EMPTY_OBJECT)) {
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
// 3. Object required: any required key is absent from `{}`.
|
|
295
|
+
if (d.object) {
|
|
296
|
+
for (const key of d.object.required) {
|
|
297
|
+
if (!(key in EMPTY_OBJECT))
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=schemaToTs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaToTs.js","sourceRoot":"","sources":["../../../../src/lib/workflow-codegen/schemaToTs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EACL,cAAc,EACd,MAAM,GAEP,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,IAAI,EACJ,KAAK,EACL,MAAM,IAAI,IAAI,EAEd,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,KAAK,GAEN,MAAM,qCAAqC,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,SAAS,GAA2B;IACxC,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,0EAA0E;AAC1E,MAAM,YAAY,GAA0B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE9D;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,MAAa;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC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AAC;IACD,4EAA4E;IAC5E,yEAAyE;IACzE,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,4DAA4D;IAC5D,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QACb,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpC,IAAI,CAAC,CAAC,GAAG,IAAI,YAAY,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a workflow's named config sidecars, and honor `activeConfigName`
|
|
3
|
+
* (issue #2645, spec §Contracts/Named configs).
|
|
4
|
+
*
|
|
5
|
+
* ── What this is for ─────────────────────────────────────────────────────
|
|
6
|
+
* Named configs used to be reachable only through `workflows configs
|
|
7
|
+
* create/update/duplicate/activate`. Those verbs are removed, so `sync push`
|
|
8
|
+
* has to apply the bodies now — otherwise the capability would have been
|
|
9
|
+
* deleted rather than moved to TOML, which the spec's criterion 2 forbids.
|
|
10
|
+
*
|
|
11
|
+
* ── Division of labour with `applyWorkflowBody` ──────────────────────────
|
|
12
|
+
* The ACTIVE config's body stays where it already is: the `steps` at the top of
|
|
13
|
+
* `workflows/<key>.toml`, written through `applyWorkflowBody`'s
|
|
14
|
+
* ordering-sensitive sequence (metadata PATCH → steps → deferred `syncCallable`
|
|
15
|
+
* PATCH, #807). That path is deliberately untouched — a second single-object
|
|
16
|
+
* apply is what broke that ordering before. This module handles the OTHER named
|
|
17
|
+
* configs, each from its own sidecar, and then the activation.
|
|
18
|
+
*
|
|
19
|
+
* So each config body is declared exactly once: the live one at the top of the
|
|
20
|
+
* workflow file, every other one in `workflows/<key>.configs/<name>.toml`.
|
|
21
|
+
* After a pull that follows an `activeConfigName` change, the two swap roles.
|
|
22
|
+
*
|
|
23
|
+
* ── Ordering ─────────────────────────────────────────────────────────────
|
|
24
|
+
* Bodies first, activation last. Activating a config before writing its steps
|
|
25
|
+
* would put an empty or stale body into service for the width of one call.
|
|
26
|
+
*/
|
|
27
|
+
import type { ApiClient } from "./api-client.js";
|
|
28
|
+
import type { WorkflowConfigSidecar } from "./workflow-config-sidecar.js";
|
|
29
|
+
export interface ApplyWorkflowConfigsOptions {
|
|
30
|
+
/** The workflow's configs as the server currently has them. */
|
|
31
|
+
serverConfigs: any[];
|
|
32
|
+
/** `[workflow].activeConfigName` from the TOML, when the author set one. */
|
|
33
|
+
activeConfigName?: string;
|
|
34
|
+
/** The config that is live right now, so a no-op activation is skipped. */
|
|
35
|
+
currentActiveConfigId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Let `activeConfigName` NAME the config that just received the workflow
|
|
38
|
+
* file's body, instead of requiring it to already exist.
|
|
39
|
+
*
|
|
40
|
+
* Create only. A workflow the server has just made carries one config it
|
|
41
|
+
* named itself ("default"), holding the body from `workflows/<key>.toml` —
|
|
42
|
+
* and pull never writes a sidecar for the active config, so on a fresh app
|
|
43
|
+
* there is nothing else `activeConfigName` could be referring to.
|
|
44
|
+
*
|
|
45
|
+
* Deliberately NOT set on update: there, an `activeConfigName` matching no
|
|
46
|
+
* config and no sidecar is far more likely a typo than a rename, and
|
|
47
|
+
* renaming the live config out from under that typo would be a silent
|
|
48
|
+
* mutation. Update keeps failing with the message that names the file to
|
|
49
|
+
* author.
|
|
50
|
+
*/
|
|
51
|
+
adoptActiveConfigName?: boolean;
|
|
52
|
+
log?: (message: string) => void;
|
|
53
|
+
}
|
|
54
|
+
export interface ApplyWorkflowConfigsResult {
|
|
55
|
+
/** Config name → id, which the rest of push needs to resolve test cases. */
|
|
56
|
+
configIds: Map<string, string>;
|
|
57
|
+
/** Whether this call moved the live config. */
|
|
58
|
+
activated: boolean;
|
|
59
|
+
/** The config that is live once this call returns, when known. */
|
|
60
|
+
activeConfigId?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create or update each sidecar's config, then activate the named one.
|
|
64
|
+
*
|
|
65
|
+
* Reports whether it activated anything: activation writes the workflow
|
|
66
|
+
* DEFINITION (`activeConfigId`, and with it a fresh `modifiedAt`), so the
|
|
67
|
+
* caller's sync state is stale afterwards unless it re-reads — which is how a
|
|
68
|
+
* push that only switched the active config left the next one to conflict.
|
|
69
|
+
*/
|
|
70
|
+
export declare function applyWorkflowConfigSidecars(client: ApiClient, appId: string, workflowId: string, sidecars: readonly WorkflowConfigSidecar[], options: ApplyWorkflowConfigsOptions): Promise<ApplyWorkflowConfigsResult>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a workflow's named config sidecars, and honor `activeConfigName`
|
|
3
|
+
* (issue #2645, spec §Contracts/Named configs).
|
|
4
|
+
*
|
|
5
|
+
* ── What this is for ─────────────────────────────────────────────────────
|
|
6
|
+
* Named configs used to be reachable only through `workflows configs
|
|
7
|
+
* create/update/duplicate/activate`. Those verbs are removed, so `sync push`
|
|
8
|
+
* has to apply the bodies now — otherwise the capability would have been
|
|
9
|
+
* deleted rather than moved to TOML, which the spec's criterion 2 forbids.
|
|
10
|
+
*
|
|
11
|
+
* ── Division of labour with `applyWorkflowBody` ──────────────────────────
|
|
12
|
+
* The ACTIVE config's body stays where it already is: the `steps` at the top of
|
|
13
|
+
* `workflows/<key>.toml`, written through `applyWorkflowBody`'s
|
|
14
|
+
* ordering-sensitive sequence (metadata PATCH → steps → deferred `syncCallable`
|
|
15
|
+
* PATCH, #807). That path is deliberately untouched — a second single-object
|
|
16
|
+
* apply is what broke that ordering before. This module handles the OTHER named
|
|
17
|
+
* configs, each from its own sidecar, and then the activation.
|
|
18
|
+
*
|
|
19
|
+
* So each config body is declared exactly once: the live one at the top of the
|
|
20
|
+
* workflow file, every other one in `workflows/<key>.configs/<name>.toml`.
|
|
21
|
+
* After a pull that follows an `activeConfigName` change, the two swap roles.
|
|
22
|
+
*
|
|
23
|
+
* ── Ordering ─────────────────────────────────────────────────────────────
|
|
24
|
+
* Bodies first, activation last. Activating a config before writing its steps
|
|
25
|
+
* would put an empty or stale body into service for the width of one call.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Create or update each sidecar's config, then activate the named one.
|
|
29
|
+
*
|
|
30
|
+
* Reports whether it activated anything: activation writes the workflow
|
|
31
|
+
* DEFINITION (`activeConfigId`, and with it a fresh `modifiedAt`), so the
|
|
32
|
+
* caller's sync state is stale afterwards unless it re-reads — which is how a
|
|
33
|
+
* push that only switched the active config left the next one to conflict.
|
|
34
|
+
*/
|
|
35
|
+
export async function applyWorkflowConfigSidecars(client, appId, workflowId, sidecars, options) {
|
|
36
|
+
const { serverConfigs, activeConfigName, currentActiveConfigId, adoptActiveConfigName, } = options;
|
|
37
|
+
const log = options.log ?? (() => { });
|
|
38
|
+
const nameToId = new Map();
|
|
39
|
+
for (const config of serverConfigs ?? []) {
|
|
40
|
+
if (config?.configName && config?.configId) {
|
|
41
|
+
nameToId.set(config.configName, config.configId);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// The workflow file's own `[[steps]]` IS the active config's body — pull
|
|
45
|
+
// deliberately does not repeat it as a sidecar
|
|
46
|
+
// (`workflowConfigSidecarsToWrite`). So when `activeConfigName` names no
|
|
47
|
+
// config the server knows, the config that just received that body is the
|
|
48
|
+
// one the file is naming, and it takes the authored name.
|
|
49
|
+
//
|
|
50
|
+
// Without this, a pulled tree could not be pushed back: the server names a
|
|
51
|
+
// new workflow's first config "default" (`admin-api.ts`), so any workflow
|
|
52
|
+
// whose active config is called something else pulled to a tree whose
|
|
53
|
+
// `activeConfigName` matched no sidecar and no server config — push then
|
|
54
|
+
// refused a file pull had just written. This runs BEFORE the sidecar loop so
|
|
55
|
+
// a `default.toml` sidecar creates its own config rather than overwriting
|
|
56
|
+
// the active body on its way past.
|
|
57
|
+
if (adoptActiveConfigName &&
|
|
58
|
+
activeConfigName &&
|
|
59
|
+
!nameToId.has(activeConfigName) &&
|
|
60
|
+
currentActiveConfigId) {
|
|
61
|
+
await client.updateWorkflowConfig(appId, workflowId, currentActiveConfigId, { configName: activeConfigName });
|
|
62
|
+
// The name it had is now free, and the map must say so. Leaving the old
|
|
63
|
+
// entry pointing at this id makes the sidecar of that name look like an
|
|
64
|
+
// existing config: the loop below UPDATES the just-renamed one instead of
|
|
65
|
+
// creating its own, both sidecars collapse onto a single config, and
|
|
66
|
+
// whichever is applied last silently wins. A fresh cross-app push of a
|
|
67
|
+
// two-config workflow landed exactly one config because of this.
|
|
68
|
+
for (const [name, id] of nameToId) {
|
|
69
|
+
if (id === currentActiveConfigId)
|
|
70
|
+
nameToId.delete(name);
|
|
71
|
+
}
|
|
72
|
+
nameToId.set(activeConfigName, currentActiveConfigId);
|
|
73
|
+
log(` Named the active config "${activeConfigName}"`);
|
|
74
|
+
}
|
|
75
|
+
for (const sidecar of sidecars) {
|
|
76
|
+
const existingId = nameToId.get(sidecar.name);
|
|
77
|
+
if (existingId) {
|
|
78
|
+
// In place: the config keeps its id, so anything pointing at it (a test
|
|
79
|
+
// case, a running trigger) keeps working across the edit.
|
|
80
|
+
//
|
|
81
|
+
// `description` and `status` travel with the steps: they are in the file,
|
|
82
|
+
// so the file owns them (#1567's convention — an omitted `description`
|
|
83
|
+
// sends `null` and clears, since that is what the round-trip means). An
|
|
84
|
+
// update that sent steps alone silently ignored half of what the author
|
|
85
|
+
// wrote, which is the same invisibility the flag removal was about.
|
|
86
|
+
await client.updateWorkflowConfig(appId, workflowId, existingId, {
|
|
87
|
+
steps: sidecar.steps,
|
|
88
|
+
expressions: sidecar.expressions,
|
|
89
|
+
description: sidecar.description ?? null,
|
|
90
|
+
// A defaulted enum, so there is no "clear": an absent key leaves the
|
|
91
|
+
// server's value alone rather than inventing one.
|
|
92
|
+
status: sidecar.status,
|
|
93
|
+
});
|
|
94
|
+
log(` Updated config "${sidecar.name}"`);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const created = await client.createWorkflowConfig(appId, workflowId, {
|
|
98
|
+
configName: sidecar.name,
|
|
99
|
+
description: sidecar.description,
|
|
100
|
+
steps: sidecar.steps,
|
|
101
|
+
expressions: sidecar.expressions,
|
|
102
|
+
});
|
|
103
|
+
if (created?.configId)
|
|
104
|
+
nameToId.set(sidecar.name, created.configId);
|
|
105
|
+
log(` Created config "${sidecar.name}"`);
|
|
106
|
+
// Create always mints an ACTIVE config (admin-api.ts, createWorkflowConfig
|
|
107
|
+
// hard-codes it), so a sidecar that says otherwise needs the follow-up
|
|
108
|
+
// write or its `status` would be silently dropped on a fresh app.
|
|
109
|
+
if (created?.configId && sidecar.status && sidecar.status !== "active") {
|
|
110
|
+
await client.updateWorkflowConfig(appId, workflowId, created.configId, {
|
|
111
|
+
status: sidecar.status,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
let activated = false;
|
|
117
|
+
let activeConfigId = currentActiveConfigId;
|
|
118
|
+
if (activeConfigName) {
|
|
119
|
+
const targetId = nameToId.get(activeConfigName);
|
|
120
|
+
if (!targetId) {
|
|
121
|
+
// Leaving the old config live would mean the committed file says one
|
|
122
|
+
// config is running and another is — the exact drift this issue removes.
|
|
123
|
+
// A typo has to stop the push, not be absorbed by it.
|
|
124
|
+
throw new Error(`activeConfigName "${activeConfigName}" names no configuration. ` +
|
|
125
|
+
`Author it at workflows/<key>.configs/${activeConfigName}.toml, or ` +
|
|
126
|
+
`correct the name in workflows/<key>.toml.`);
|
|
127
|
+
}
|
|
128
|
+
if (targetId !== currentActiveConfigId) {
|
|
129
|
+
await client.activateWorkflowConfig(appId, workflowId, targetId);
|
|
130
|
+
log(` Activated config "${activeConfigName}"`);
|
|
131
|
+
activated = true;
|
|
132
|
+
}
|
|
133
|
+
activeConfigId = targetId;
|
|
134
|
+
}
|
|
135
|
+
return { configIds: nameToId, activated, activeConfigId };
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=workflow-config-apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-config-apply.js","sourceRoot":"","sources":["../../../src/lib/workflow-config-apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAwCH;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAiB,EACjB,KAAa,EACb,UAAkB,EAClB,QAA0C,EAC1C,OAAoC;IAEpC,MAAM,EACJ,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,GACtB,GAAG,OAAO,CAAC;IACZ,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAEtC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,aAAa,IAAI,EAAE,EAAE,CAAC;QACzC,IAAI,MAAM,EAAE,UAAU,IAAI,MAAM,EAAE,QAAQ,EAAE,CAAC;YAC3C,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,yEAAyE;IACzE,+CAA+C;IAC/C,yEAAyE;IACzE,0EAA0E;IAC1E,0DAA0D;IAC1D,EAAE;IACF,2EAA2E;IAC3E,0EAA0E;IAC1E,sEAAsE;IACtE,yEAAyE;IACzE,6EAA6E;IAC7E,0EAA0E;IAC1E,mCAAmC;IACnC,IACE,qBAAqB;QACrB,gBAAgB;QAChB,CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC;QAC/B,qBAAqB,EACrB,CAAC;QACD,MAAM,MAAM,CAAC,oBAAoB,CAC/B,KAAK,EACL,UAAU,EACV,qBAAqB,EACrB,EAAE,UAAU,EAAE,gBAAgB,EA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