@shipfox/api-definitions 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +215 -0
- package/LICENSE +21 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +35 -0
- package/dist/config.js.map +1 -0
- package/dist/core/entities/index.d.ts +5 -0
- package/dist/core/entities/index.d.ts.map +1 -0
- package/dist/core/entities/index.js +6 -0
- package/dist/core/entities/index.js.map +1 -0
- package/dist/core/entities/integration-context.d.ts +11 -0
- package/dist/core/entities/integration-context.d.ts.map +1 -0
- package/dist/core/entities/integration-context.js +3 -0
- package/dist/core/entities/integration-context.js.map +1 -0
- package/dist/core/entities/sync-state.d.ts +19 -0
- package/dist/core/entities/sync-state.d.ts.map +1 -0
- package/dist/core/entities/sync-state.js +20 -0
- package/dist/core/entities/sync-state.js.map +1 -0
- package/dist/core/entities/workflow-definition.d.ts +35 -0
- package/dist/core/entities/workflow-definition.d.ts.map +1 -0
- package/dist/core/entities/workflow-definition.js +3 -0
- package/dist/core/entities/workflow-definition.js.map +1 -0
- package/dist/core/entities/workflow-model.d.ts +138 -0
- package/dist/core/entities/workflow-model.d.ts.map +1 -0
- package/dist/core/entities/workflow-model.js +3 -0
- package/dist/core/entities/workflow-model.js.map +1 -0
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +14 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/has-agent-step-integrations.d.ts +3 -0
- package/dist/core/has-agent-step-integrations.d.ts.map +1 -0
- package/dist/core/has-agent-step-integrations.js +5 -0
- package/dist/core/has-agent-step-integrations.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/parse-definition.d.ts +9 -0
- package/dist/core/parse-definition.d.ts.map +1 -0
- package/dist/core/parse-definition.js +17 -0
- package/dist/core/parse-definition.js.map +1 -0
- package/dist/core/sync-definitions.d.ts +44 -0
- package/dist/core/sync-definitions.d.ts.map +1 -0
- package/dist/core/sync-definitions.js +140 -0
- package/dist/core/sync-definitions.js.map +1 -0
- package/dist/core/validate-definition.d.ts +20 -0
- package/dist/core/validate-definition.d.ts.map +1 -0
- package/dist/core/validate-definition.js +61 -0
- package/dist/core/validate-definition.js.map +1 -0
- package/dist/core/workflow-model/constants.d.ts +2 -0
- package/dist/core/workflow-model/constants.d.ts.map +1 -0
- package/dist/core/workflow-model/constants.js +3 -0
- package/dist/core/workflow-model/constants.js.map +1 -0
- package/dist/core/workflow-model/cron-trigger.d.ts +16 -0
- package/dist/core/workflow-model/cron-trigger.d.ts.map +1 -0
- package/dist/core/workflow-model/cron-trigger.js +85 -0
- package/dist/core/workflow-model/cron-trigger.js.map +1 -0
- package/dist/core/workflow-model/index.d.ts +4 -0
- package/dist/core/workflow-model/index.d.ts.map +1 -0
- package/dist/core/workflow-model/index.js +5 -0
- package/dist/core/workflow-model/index.js.map +1 -0
- package/dist/core/workflow-model/invalid-workflow-model-error.d.ts +15 -0
- package/dist/core/workflow-model/invalid-workflow-model-error.d.ts.map +1 -0
- package/dist/core/workflow-model/invalid-workflow-model-error.js +9 -0
- package/dist/core/workflow-model/invalid-workflow-model-error.js.map +1 -0
- package/dist/core/workflow-model/map-job-ids.d.ts +4 -0
- package/dist/core/workflow-model/map-job-ids.d.ts.map +1 -0
- package/dist/core/workflow-model/map-job-ids.js +33 -0
- package/dist/core/workflow-model/map-job-ids.js.map +1 -0
- package/dist/core/workflow-model/normalize-agent-integrations.d.ts +12 -0
- package/dist/core/workflow-model/normalize-agent-integrations.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-agent-integrations.js +157 -0
- package/dist/core/workflow-model/normalize-agent-integrations.js.map +1 -0
- package/dist/core/workflow-model/normalize-dependencies.d.ts +6 -0
- package/dist/core/workflow-model/normalize-dependencies.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-dependencies.js +119 -0
- package/dist/core/workflow-model/normalize-dependencies.js.map +1 -0
- package/dist/core/workflow-model/normalize-env.d.ts +17 -0
- package/dist/core/workflow-model/normalize-env.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-env.js +40 -0
- package/dist/core/workflow-model/normalize-env.js.map +1 -0
- package/dist/core/workflow-model/normalize-if-condition.d.ts +14 -0
- package/dist/core/workflow-model/normalize-if-condition.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-if-condition.js +75 -0
- package/dist/core/workflow-model/normalize-if-condition.js.map +1 -0
- package/dist/core/workflow-model/normalize-job-checkout.d.ts +5 -0
- package/dist/core/workflow-model/normalize-job-checkout.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-job-checkout.js +16 -0
- package/dist/core/workflow-model/normalize-job-checkout.js.map +1 -0
- package/dist/core/workflow-model/normalize-job-listening.d.ts +10 -0
- package/dist/core/workflow-model/normalize-job-listening.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-job-listening.js +125 -0
- package/dist/core/workflow-model/normalize-job-listening.js.map +1 -0
- package/dist/core/workflow-model/normalize-job-success.d.ts +11 -0
- package/dist/core/workflow-model/normalize-job-success.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-job-success.js +23 -0
- package/dist/core/workflow-model/normalize-job-success.js.map +1 -0
- package/dist/core/workflow-model/normalize-jobs.d.ts +12 -0
- package/dist/core/workflow-model/normalize-jobs.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-jobs.js +935 -0
- package/dist/core/workflow-model/normalize-jobs.js.map +1 -0
- package/dist/core/workflow-model/normalize-needs.d.ts +2 -0
- package/dist/core/workflow-model/normalize-needs.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-needs.js +16 -0
- package/dist/core/workflow-model/normalize-needs.js.map +1 -0
- package/dist/core/workflow-model/normalize-step-gate.d.ts +15 -0
- package/dist/core/workflow-model/normalize-step-gate.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-step-gate.js +89 -0
- package/dist/core/workflow-model/normalize-step-gate.js.map +1 -0
- package/dist/core/workflow-model/normalize-step-outputs.d.ts +10 -0
- package/dist/core/workflow-model/normalize-step-outputs.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-step-outputs.js +32 -0
- package/dist/core/workflow-model/normalize-step-outputs.js.map +1 -0
- package/dist/core/workflow-model/normalize-triggers.d.ts +11 -0
- package/dist/core/workflow-model/normalize-triggers.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-triggers.js +128 -0
- package/dist/core/workflow-model/normalize-triggers.js.map +1 -0
- package/dist/core/workflow-model/normalize-workflow-document.d.ts +11 -0
- package/dist/core/workflow-model/normalize-workflow-document.d.ts.map +1 -0
- package/dist/core/workflow-model/normalize-workflow-document.js +43 -0
- package/dist/core/workflow-model/normalize-workflow-document.js.map +1 -0
- package/dist/core/workflow-model/parse-duration-ms.d.ts +11 -0
- package/dist/core/workflow-model/parse-duration-ms.d.ts.map +1 -0
- package/dist/core/workflow-model/parse-duration-ms.js +47 -0
- package/dist/core/workflow-model/parse-duration-ms.js.map +1 -0
- package/dist/core/workflow-model/parse-interpolation-field.d.ts +14 -0
- package/dist/core/workflow-model/parse-interpolation-field.d.ts.map +1 -0
- package/dist/core/workflow-model/parse-interpolation-field.js +377 -0
- package/dist/core/workflow-model/parse-interpolation-field.js.map +1 -0
- package/dist/core/workflow-model/stable-id.d.ts +2 -0
- package/dist/core/workflow-model/stable-id.d.ts.map +1 -0
- package/dist/core/workflow-model/stable-id.js +8 -0
- package/dist/core/workflow-model/stable-id.js.map +1 -0
- package/dist/core/workflow-model/validate-job-references.d.ts +10 -0
- package/dist/core/workflow-model/validate-job-references.d.ts.map +1 -0
- package/dist/core/workflow-model/validate-job-references.js +42 -0
- package/dist/core/workflow-model/validate-job-references.js.map +1 -0
- package/dist/core/workflow-model/validate-predicate-expression.d.ts +14 -0
- package/dist/core/workflow-model/validate-predicate-expression.d.ts.map +1 -0
- package/dist/core/workflow-model/validate-predicate-expression.js +273 -0
- package/dist/core/workflow-model/validate-predicate-expression.js.map +1 -0
- package/dist/core/workflow-model/validation-issue.d.ts +8 -0
- package/dist/core/workflow-model/validation-issue.d.ts.map +1 -0
- package/dist/core/workflow-model/validation-issue.js +17 -0
- package/dist/core/workflow-model/validation-issue.js.map +1 -0
- package/dist/core/workflow-model/workflow-field-label.d.ts +3 -0
- package/dist/core/workflow-model/workflow-field-label.d.ts.map +1 -0
- package/dist/core/workflow-model/workflow-field-label.js +47 -0
- package/dist/core/workflow-model/workflow-field-label.js.map +1 -0
- package/dist/core/workflow-yaml/index.d.ts +3 -0
- package/dist/core/workflow-yaml/index.d.ts.map +1 -0
- package/dist/core/workflow-yaml/index.js +4 -0
- package/dist/core/workflow-yaml/index.js.map +1 -0
- package/dist/core/workflow-yaml/invalid-workflow-yaml-error.d.ts +16 -0
- package/dist/core/workflow-yaml/invalid-workflow-yaml-error.d.ts.map +1 -0
- package/dist/core/workflow-yaml/invalid-workflow-yaml-error.js +12 -0
- package/dist/core/workflow-yaml/invalid-workflow-yaml-error.js.map +1 -0
- package/dist/core/workflow-yaml/parse-workflow-yaml.d.ts +9 -0
- package/dist/core/workflow-yaml/parse-workflow-yaml.d.ts.map +1 -0
- package/dist/core/workflow-yaml/parse-workflow-yaml.js +52 -0
- package/dist/core/workflow-yaml/parse-workflow-yaml.js.map +1 -0
- package/dist/core/workflow-yaml/source-locations.d.ts +3 -0
- package/dist/core/workflow-yaml/source-locations.d.ts.map +1 -0
- package/dist/core/workflow-yaml/source-locations.js +48 -0
- package/dist/core/workflow-yaml/source-locations.js.map +1 -0
- package/dist/db/db.d.ts +1277 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +22 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/definition-triggers.d.ts +4 -0
- package/dist/db/definition-triggers.d.ts.map +1 -0
- package/dist/db/definition-triggers.js +17 -0
- package/dist/db/definition-triggers.js.map +1 -0
- package/dist/db/definitions.d.ts +63 -0
- package/dist/db/definitions.d.ts.map +1 -0
- package/dist/db/definitions.js +208 -0
- package/dist/db/definitions.js.map +1 -0
- package/dist/db/index.d.ts +8 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +10 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/definitions.d.ts +237 -0
- package/dist/db/schema/definitions.d.ts.map +1 -0
- package/dist/db/schema/definitions.js +63 -0
- package/dist/db/schema/definitions.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/sync-states.d.ts +218 -0
- package/dist/db/schema/sync-states.d.ts.map +1 -0
- package/dist/db/schema/sync-states.js +68 -0
- package/dist/db/schema/sync-states.js.map +1 -0
- package/dist/db/sync-states.d.ts +21 -0
- package/dist/db/sync-states.d.ts.map +1 -0
- package/dist/db/sync-states.js +47 -0
- package/dist/db/sync-states.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/presentation/dto/definition.d.ts +6 -0
- package/dist/presentation/dto/definition.d.ts.map +1 -0
- package/dist/presentation/dto/definition.js +35 -0
- package/dist/presentation/dto/definition.js.map +1 -0
- package/dist/presentation/dto/index.d.ts +2 -0
- package/dist/presentation/dto/index.d.ts.map +1 -0
- package/dist/presentation/dto/index.js +3 -0
- package/dist/presentation/dto/index.js.map +1 -0
- package/dist/presentation/index.d.ts +2 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +3 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/presentation/routes/create-definition.d.ts +9 -0
- package/dist/presentation/routes/create-definition.d.ts.map +1 -0
- package/dist/presentation/routes/create-definition.js +76 -0
- package/dist/presentation/routes/create-definition.js.map +1 -0
- package/dist/presentation/routes/get-definition.d.ts +2 -0
- package/dist/presentation/routes/get-definition.d.ts.map +1 -0
- package/dist/presentation/routes/get-definition.js +43 -0
- package/dist/presentation/routes/get-definition.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +7 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +22 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/list-definitions.d.ts +2 -0
- package/dist/presentation/routes/list-definitions.d.ts.map +1 -0
- package/dist/presentation/routes/list-definitions.js +56 -0
- package/dist/presentation/routes/list-definitions.js.map +1 -0
- package/dist/presentation/routes/validate-definition.d.ts +2 -0
- package/dist/presentation/routes/validate-definition.d.ts.map +1 -0
- package/dist/presentation/routes/validate-definition.js +43 -0
- package/dist/presentation/routes/validate-definition.js.map +1 -0
- package/dist/presentation/subscribers/index.d.ts +3 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -0
- package/dist/presentation/subscribers/index.js +4 -0
- package/dist/presentation/subscribers/index.js.map +1 -0
- package/dist/presentation/subscribers/on-project-source-bound.d.ts +3 -0
- package/dist/presentation/subscribers/on-project-source-bound.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-project-source-bound.js +11 -0
- package/dist/presentation/subscribers/on-project-source-bound.js.map +1 -0
- package/dist/presentation/subscribers/on-project-source-commit-observed.d.ts +3 -0
- package/dist/presentation/subscribers/on-project-source-commit-observed.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-project-source-commit-observed.js +13 -0
- package/dist/presentation/subscribers/on-project-source-commit-observed.js.map +1 -0
- package/dist/presentation/subscribers/start-definition-sync.d.ts +10 -0
- package/dist/presentation/subscribers/start-definition-sync.d.ts.map +1 -0
- package/dist/presentation/subscribers/start-definition-sync.js +26 -0
- package/dist/presentation/subscribers/start-definition-sync.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +3 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +3 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/sync-activities.d.ts +47 -0
- package/dist/temporal/activities/sync-activities.d.ts.map +1 -0
- package/dist/temporal/activities/sync-activities.js +128 -0
- package/dist/temporal/activities/sync-activities.js.map +1 -0
- package/dist/temporal/constants.d.ts +3 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +4 -0
- package/dist/temporal/constants.js.map +1 -0
- package/dist/temporal/index.d.ts +3 -0
- package/dist/temporal/index.d.ts.map +1 -0
- package/dist/temporal/index.js +4 -0
- package/dist/temporal/index.js.map +1 -0
- package/dist/temporal/workflows/definition-sync.d.ts +20 -0
- package/dist/temporal/workflows/definition-sync.d.ts.map +1 -0
- package/dist/temporal/workflows/definition-sync.js +95 -0
- package/dist/temporal/workflows/definition-sync.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +2 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +3 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +64 -0
- package/drizzle/0001_definition_list_pagination.sql +1 -0
- package/drizzle/meta/0000_snapshot.json +527 -0
- package/drizzle/meta/_journal.json +20 -0
- package/drizzle.config.ts +11 -0
- package/package.json +89 -0
- package/src/config.test.ts +23 -0
- package/src/config.ts +50 -0
- package/src/core/entities/index.ts +4 -0
- package/src/core/entities/integration-context.ts +21 -0
- package/src/core/entities/sync-state.ts +40 -0
- package/src/core/entities/workflow-definition.ts +38 -0
- package/src/core/entities/workflow-model.ts +162 -0
- package/src/core/errors.ts +21 -0
- package/src/core/has-agent-step-integrations.ts +7 -0
- package/src/core/index.ts +23 -0
- package/src/core/parse-definition.test.ts +200 -0
- package/src/core/parse-definition.ts +28 -0
- package/src/core/sync-definitions.test.ts +390 -0
- package/src/core/sync-definitions.ts +216 -0
- package/src/core/validate-definition.test.ts +152 -0
- package/src/core/validate-definition.ts +72 -0
- package/src/core/workflow-model/README.md +129 -0
- package/src/core/workflow-model/constants.ts +1 -0
- package/src/core/workflow-model/cron-trigger.test.ts +29 -0
- package/src/core/workflow-model/cron-trigger.ts +83 -0
- package/src/core/workflow-model/index.ts +9 -0
- package/src/core/workflow-model/invalid-workflow-model-error.ts +71 -0
- package/src/core/workflow-model/map-job-ids.ts +33 -0
- package/src/core/workflow-model/normalize-agent-integrations.ts +208 -0
- package/src/core/workflow-model/normalize-dependencies.ts +139 -0
- package/src/core/workflow-model/normalize-env.ts +48 -0
- package/src/core/workflow-model/normalize-if-condition.ts +126 -0
- package/src/core/workflow-model/normalize-job-checkout.ts +19 -0
- package/src/core/workflow-model/normalize-job-listening.ts +121 -0
- package/src/core/workflow-model/normalize-job-success.ts +28 -0
- package/src/core/workflow-model/normalize-jobs.ts +1010 -0
- package/src/core/workflow-model/normalize-needs.ts +12 -0
- package/src/core/workflow-model/normalize-step-gate.ts +90 -0
- package/src/core/workflow-model/normalize-step-outputs.ts +36 -0
- package/src/core/workflow-model/normalize-triggers.ts +130 -0
- package/src/core/workflow-model/normalize-workflow-document.test.ts +4463 -0
- package/src/core/workflow-model/normalize-workflow-document.ts +63 -0
- package/src/core/workflow-model/parse-duration-ms.ts +58 -0
- package/src/core/workflow-model/parse-interpolation-field.ts +566 -0
- package/src/core/workflow-model/stable-id.ts +12 -0
- package/src/core/workflow-model/validate-job-references.ts +54 -0
- package/src/core/workflow-model/validate-predicate-expression.test.ts +161 -0
- package/src/core/workflow-model/validate-predicate-expression.ts +406 -0
- package/src/core/workflow-model/validation-issue.ts +27 -0
- package/src/core/workflow-model/workflow-field-label.ts +50 -0
- package/src/core/workflow-yaml/README.md +77 -0
- package/src/core/workflow-yaml/index.ts +11 -0
- package/src/core/workflow-yaml/invalid-workflow-yaml-error.ts +23 -0
- package/src/core/workflow-yaml/parse-workflow-yaml.test.ts +71 -0
- package/src/core/workflow-yaml/parse-workflow-yaml.ts +74 -0
- package/src/core/workflow-yaml/source-locations.ts +62 -0
- package/src/db/db.ts +18 -0
- package/src/db/definition-triggers.test.ts +95 -0
- package/src/db/definition-triggers.ts +17 -0
- package/src/db/definitions.test.ts +1309 -0
- package/src/db/definitions.ts +357 -0
- package/src/db/index.ts +31 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/definitions.test.ts +36 -0
- package/src/db/schema/definitions.ts +76 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/sync-states.ts +79 -0
- package/src/db/sync-states.test.ts +90 -0
- package/src/db/sync-states.ts +86 -0
- package/src/index.ts +104 -0
- package/src/presentation/dto/definition.test.ts +59 -0
- package/src/presentation/dto/definition.ts +41 -0
- package/src/presentation/dto/index.ts +1 -0
- package/src/presentation/index.ts +1 -0
- package/src/presentation/routes/create-definition.test.ts +356 -0
- package/src/presentation/routes/create-definition.ts +101 -0
- package/src/presentation/routes/get-definition.test.ts +79 -0
- package/src/presentation/routes/get-definition.ts +37 -0
- package/src/presentation/routes/index.test.ts +41 -0
- package/src/presentation/routes/index.ts +28 -0
- package/src/presentation/routes/list-definitions.test.ts +195 -0
- package/src/presentation/routes/list-definitions.ts +49 -0
- package/src/presentation/routes/validate-definition.test.ts +63 -0
- package/src/presentation/routes/validate-definition.ts +46 -0
- package/src/presentation/subscribers/index.ts +2 -0
- package/src/presentation/subscribers/on-project-source-bound.test.ts +65 -0
- package/src/presentation/subscribers/on-project-source-bound.ts +11 -0
- package/src/presentation/subscribers/on-project-source-commit-observed.test.ts +56 -0
- package/src/presentation/subscribers/on-project-source-commit-observed.ts +15 -0
- package/src/presentation/subscribers/start-definition-sync.ts +38 -0
- package/src/temporal/activities/index.ts +10 -0
- package/src/temporal/activities/sync-activities.test.ts +337 -0
- package/src/temporal/activities/sync-activities.ts +206 -0
- package/src/temporal/constants.ts +2 -0
- package/src/temporal/index.ts +2 -0
- package/src/temporal/workflows/definition-sync.test.ts +59 -0
- package/src/temporal/workflows/definition-sync.ts +116 -0
- package/src/temporal/workflows/index.ts +1 -0
- package/test/env.ts +7 -0
- package/test/factories/definition.ts +66 -0
- package/test/fixtures/invalid-cycle.yml +13 -0
- package/test/fixtures/invalid-missing-name.yml +4 -0
- package/test/fixtures/invalid-yaml-syntax.yml +6 -0
- package/test/fixtures/valid-dag.yml +25 -0
- package/test/fixtures/valid-listening-job.yml +21 -0
- package/test/fixtures/valid-simple.yml +18 -0
- package/test/fixtures/workflow-yaml/invalid/invalid-yaml-syntax.yaml +6 -0
- package/test/fixtures/workflow-yaml/invalid/missing-step-run.yaml +5 -0
- package/test/fixtures/workflow-yaml/valid/simple-build.document.json +26 -0
- package/test/fixtures/workflow-yaml/valid/simple-build.yaml +14 -0
- package/test/globalSetup.ts +25 -0
- package/test/index.ts +1 -0
- package/test/setup.ts +17 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/normalize-jobs.ts"],"sourcesContent":["import {\n agentThinkingByHarness,\n getHarnessDescriptor,\n getModelProviderEntry,\n type HarnessToolDeploymentConfig,\n listEnabledHarnessTools,\n} from '@shipfox/api-agent-dto';\nimport {\n type AvailabilitySite,\n buildTypedRootsEnvironment,\n type ExpressionType,\n type ExpressionTypeEnvironment,\n type WorkflowJobTypeOverlay,\n type WorkflowStepTypeOverlay,\n} from '@shipfox/expression';\nimport {\n canonicalizeLabels,\n findInvalidLabels,\n MAX_RUNNER_LABEL_LENGTH,\n MAX_RUNNER_LABELS,\n RUNNER_LABEL_PATTERN,\n} from '@shipfox/runner-labels';\nimport type {\n WorkflowDocument,\n WorkflowDocumentJob,\n WorkflowDocumentStep,\n} from '@shipfox/workflow-document';\nimport type {IntegrationValidationContext} from '../entities/integration-context.js';\nimport type {\n WorkflowEnvTemplates,\n WorkflowFieldTemplate,\n WorkflowModelAgentStep,\n WorkflowModelJob,\n WorkflowModelRunStep,\n WorkflowModelStep,\n WorkflowOutputTemplates,\n WorkflowStepSourceLocationMap,\n} from '../entities/workflow-model.js';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {normalizeAgentIntegrations} from './normalize-agent-integrations.js';\nimport {normalizeEnv} from './normalize-env.js';\nimport {normalizeIfCondition} from './normalize-if-condition.js';\nimport {normalizeJobCheckout} from './normalize-job-checkout.js';\nimport {normalizeJobListening} from './normalize-job-listening.js';\nimport {normalizeJobSuccess} from './normalize-job-success.js';\nimport {normalizeNeeds} from './normalize-needs.js';\nimport {normalizeStepGate} from './normalize-step-gate.js';\nimport {normalizeStepOutputs} from './normalize-step-outputs.js';\nimport {parseDurationMs} from './parse-duration-ms.js';\nimport {parseInterpolationField} from './parse-interpolation-field.js';\nimport {stableId} from './stable-id.js';\nimport {issue} from './validation-issue.js';\n\nexport interface NormalizeContext {\n readonly defaultRunnerLabels: readonly string[];\n readonly harnessToolDeploymentConfig: HarnessToolDeploymentConfig;\n readonly integrationValidationContext?: IntegrationValidationContext | undefined;\n}\n\nexport function normalizeJobs(\n document: WorkflowDocument,\n jobIdBySourceName: ReadonlyMap<string, string>,\n issues: WorkflowModelValidationIssue[],\n stepSourceLocations: WorkflowStepSourceLocationMap | undefined,\n context: NormalizeContext,\n): readonly WorkflowModelJob[] {\n const entries = Object.entries(document.jobs);\n const pending = new Set(entries.map(([sourceName]) => sourceName));\n const modelsBySourceName = new Map<string, WorkflowModelJob>();\n const jobOutputTypesBySourceName = new Map<string, Readonly<Record<string, ExpressionType>>>();\n const issuesBySourceName = new Map<string, WorkflowModelValidationIssue[]>();\n\n while (pending.size > 0) {\n let progressed = false;\n\n for (const [sourceName, job] of entries) {\n if (!pending.has(sourceName)) continue;\n\n const dependencySourceNames = normalizeNeeds(job.needs).filter((dependency) =>\n jobIdBySourceName.has(dependency),\n );\n if (dependencySourceNames.some((dependency) => pending.has(dependency))) continue;\n\n const model = normalizeJob({\n document,\n sourceName,\n job,\n jobIdBySourceName,\n issues: issuesForSourceName(issuesBySourceName, sourceName),\n stepSourceLocations,\n context,\n jobOutputTypesBySourceName,\n });\n if (model !== undefined) modelsBySourceName.set(sourceName, model);\n pending.delete(sourceName);\n progressed = true;\n }\n\n if (progressed) continue;\n\n for (const sourceName of pending) {\n const job = document.jobs[sourceName];\n if (job === undefined) continue;\n const model = normalizeJob({\n document,\n sourceName,\n job,\n jobIdBySourceName,\n issues: issuesForSourceName(issuesBySourceName, sourceName),\n stepSourceLocations,\n context,\n jobOutputTypesBySourceName,\n });\n if (model !== undefined) modelsBySourceName.set(sourceName, model);\n }\n break;\n }\n\n for (const [sourceName] of entries) {\n issues.push(...(issuesBySourceName.get(sourceName) ?? []));\n }\n\n return entries.flatMap(([sourceName]) => {\n const model = modelsBySourceName.get(sourceName);\n return model === undefined ? [] : [model];\n });\n}\n\nfunction issuesForSourceName(\n issuesBySourceName: Map<string, WorkflowModelValidationIssue[]>,\n sourceName: string,\n): WorkflowModelValidationIssue[] {\n const existing = issuesBySourceName.get(sourceName);\n if (existing !== undefined) return existing;\n\n const issues: WorkflowModelValidationIssue[] = [];\n issuesBySourceName.set(sourceName, issues);\n return issues;\n}\n\nfunction normalizeJob(params: {\n document: WorkflowDocument;\n sourceName: string;\n job: WorkflowDocumentJob;\n jobIdBySourceName: ReadonlyMap<string, string>;\n issues: WorkflowModelValidationIssue[];\n stepSourceLocations: WorkflowStepSourceLocationMap | undefined;\n context: NormalizeContext;\n jobOutputTypesBySourceName: Map<string, Readonly<Record<string, ExpressionType>>>;\n}): WorkflowModelJob | undefined {\n const id = params.jobIdBySourceName.get(params.sourceName);\n if (id === undefined) return undefined;\n\n const dependencies = normalizeJobDependencies({\n sourceName: params.sourceName,\n job: params.job,\n jobIdBySourceName: params.jobIdBySourceName,\n });\n const allowedJobReferences = directNeedSourceNames({\n sourceName: params.sourceName,\n job: params.job,\n jobIdBySourceName: params.jobIdBySourceName,\n });\n const upstreamJobs = upstreamJobTypeOverlays({\n allowedJobReferences,\n jobOutputTypesBySourceName: params.jobOutputTypesBySourceName,\n });\n const directNeedJobs = directNeedJobTypeOverlays({\n allowedJobReferences,\n jobOutputTypesBySourceName: params.jobOutputTypesBySourceName,\n });\n const upstreamJobsTypeOverlay =\n upstreamJobs.length === 0 ? undefined : buildTypedRootsEnvironment({jobs: upstreamJobs});\n const jobConditionTypeOverlay = buildTypedRootsEnvironment({\n jobs: directNeedJobs,\n needs: directNeedJobs,\n });\n // Step config can reference peer step outputs, which are completed at dispatch.\n const stepFillSite: AvailabilitySite = 'step-dispatch';\n const stepTypeOverlay = params.job.steps.some((step) => step.outputs !== undefined)\n ? {}\n : undefined;\n const steps = normalizeJobSteps({\n sourceName: params.sourceName,\n jobId: id,\n job: params.job,\n issues: params.issues,\n stepSourceLocations: params.stepSourceLocations,\n fillSite: stepFillSite,\n allowedJobReferences,\n typeOverlay: stepTypeOverlay,\n upstreamJobs,\n directNeedJobs,\n context: params.context,\n });\n const runner = normalizeRunner({\n document: params.document,\n job: params.job,\n sourceName: params.sourceName,\n issues: params.issues,\n defaultRunnerLabels: params.context.defaultRunnerLabels,\n });\n const checkout = normalizeJobCheckout(params.job.checkout);\n const jobEnv = normalizeEnv({\n env: params.job.env,\n path: ['jobs', params.sourceName, 'env'],\n issues: params.issues,\n allowedJobReferences,\n typeOverlay: upstreamJobsTypeOverlay,\n });\n const success = normalizeJobSuccess({\n source: params.job.success,\n sourceName: params.sourceName,\n issues: params.issues,\n allowedJobReferences,\n typeOverlay: upstreamJobsTypeOverlay,\n });\n const condition = normalizeIfCondition({\n field: 'job.if',\n source: params.job.if,\n site: 'job-activation',\n path: ['jobs', params.sourceName, 'if'],\n invalidCode: 'invalid-job-if',\n invalidMessage: 'Job if must be a valid wrapped CEL boolean expression.',\n issues: params.issues,\n allowedJobReferences,\n typeOverlay: jobConditionTypeOverlay,\n });\n const outputs = normalizeJobOutputs({\n sourceName: params.sourceName,\n outputs: params.job.outputs,\n issues: params.issues,\n allowedJobReferences,\n steps: params.job.steps,\n upstreamJobs,\n });\n if (outputs?.types !== undefined) {\n params.jobOutputTypesBySourceName.set(params.sourceName, outputs.types);\n }\n const executionTimeoutMs = parseDurationMs({\n source: params.job.execution_timeout,\n path: ['jobs', params.sourceName, 'execution_timeout'],\n issues: params.issues,\n });\n const listening = normalizeJobListening({\n job: params.job,\n sourceName: params.sourceName,\n issues: params.issues,\n allowedJobReferences,\n });\n const name =\n params.job.name === undefined\n ? undefined\n : (parseInterpolationField({\n field: 'job.name',\n source: params.job.name,\n path: ['jobs', params.sourceName, 'name'],\n issues: params.issues,\n allowedJobReferences,\n typeOverlay: upstreamJobsTypeOverlay,\n }) ?? [{kind: 'literal' as const, value: params.job.name}]);\n\n return {\n id,\n key: params.sourceName,\n mode: listening === undefined ? 'one_shot' : 'listening',\n runner: runner.labels,\n ...(runner.templates.length === 0 ? {} : {runnerTemplates: runner.templates}),\n checkout,\n ...(condition === undefined ? {} : {if: condition}),\n ...(success === undefined ? {} : {success}),\n ...(outputs === undefined ? {} : {outputs: outputs.templates}),\n ...(outputs?.types === undefined ? {} : {outputTypes: outputs.types}),\n ...(executionTimeoutMs === undefined ? {} : {executionTimeoutMs}),\n ...(listening === undefined ? {} : {listening}),\n ...(name === undefined ? {} : {name}),\n ...jobEnv,\n dependencies,\n steps,\n };\n}\n\nfunction normalizeJobDependencies(params: {\n sourceName: string;\n job: WorkflowDocumentJob;\n jobIdBySourceName: ReadonlyMap<string, string>;\n}): readonly string[] {\n return normalizeNeeds(params.job.needs).flatMap((dependencySourceName) => {\n const dependencyId = params.jobIdBySourceName.get(dependencySourceName);\n if (dependencyId === undefined || dependencySourceName === params.sourceName) return [];\n return [dependencyId];\n });\n}\n\nfunction directNeedSourceNames(params: {\n sourceName: string;\n job: WorkflowDocumentJob;\n jobIdBySourceName: ReadonlyMap<string, string>;\n}): ReadonlySet<string> {\n return new Set(\n normalizeNeeds(params.job.needs).filter(\n (dependencySourceName) =>\n dependencySourceName !== params.sourceName &&\n params.jobIdBySourceName.has(dependencySourceName),\n ),\n );\n}\n\nfunction previousStepOverlays(\n steps: readonly WorkflowDocumentStep[],\n index: number,\n): readonly WorkflowStepTypeOverlay[] {\n return steps.slice(0, index).flatMap((step) => {\n if (step.key === undefined) return [];\n return [{key: step.key, ...(step.outputs === undefined ? {} : {outputs: step.outputs})}];\n });\n}\n\nfunction allStepOverlays(\n steps: readonly WorkflowDocumentStep[],\n): readonly WorkflowStepTypeOverlay[] {\n return previousStepOverlays(steps, steps.length);\n}\n\nfunction upstreamJobTypeOverlays(params: {\n allowedJobReferences: ReadonlySet<string>;\n jobOutputTypesBySourceName: ReadonlyMap<string, Readonly<Record<string, ExpressionType>>>;\n}): readonly WorkflowJobTypeOverlay[] {\n const overlays = [...params.allowedJobReferences].map((sourceName) => {\n const outputs = params.jobOutputTypesBySourceName.get(sourceName);\n return {key: sourceName, ...(outputs === undefined ? {} : {outputs})};\n });\n return overlays.some((overlay) => overlay.outputs !== undefined) ? overlays : [];\n}\n\nfunction directNeedJobTypeOverlays(params: {\n allowedJobReferences: ReadonlySet<string>;\n jobOutputTypesBySourceName: ReadonlyMap<string, Readonly<Record<string, ExpressionType>>>;\n}): readonly WorkflowJobTypeOverlay[] {\n return [...params.allowedJobReferences].map((sourceName) => {\n const outputs = params.jobOutputTypesBySourceName.get(sourceName);\n return {key: sourceName, ...(outputs === undefined ? {} : {outputs})};\n });\n}\n\nfunction normalizeJobOutputs(params: {\n sourceName: string;\n outputs: WorkflowDocumentJob['outputs'];\n issues: WorkflowModelValidationIssue[];\n allowedJobReferences: ReadonlySet<string>;\n steps: readonly WorkflowDocumentStep[];\n upstreamJobs: readonly WorkflowJobTypeOverlay[];\n}):\n | {templates: WorkflowOutputTemplates; types: Readonly<Record<string, ExpressionType>>}\n | undefined {\n if (params.outputs === undefined) return undefined;\n\n const templates: Record<string, WorkflowFieldTemplate> = Object.create(null) as Record<\n string,\n WorkflowFieldTemplate\n >;\n const types: Record<string, ExpressionType> = Object.create(null) as Record<\n string,\n ExpressionType\n >;\n const hasStepOutputDeclarations = params.steps.some((step) => step.outputs !== undefined);\n const typeOverlay =\n hasStepOutputDeclarations || params.upstreamJobs.length > 0\n ? buildTypedRootsEnvironment({\n ...(hasStepOutputDeclarations ? {steps: allStepOverlays(params.steps)} : {}),\n ...(params.upstreamJobs.length === 0 ? {} : {jobs: params.upstreamJobs}),\n })\n : undefined;\n\n for (const [key, source] of Object.entries(params.outputs)) {\n const template = parseInterpolationField({\n field: 'job.outputs',\n source,\n path: ['jobs', params.sourceName, 'outputs', key],\n issues: params.issues,\n fillSite: 'execution-resolution',\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay,\n }) ?? [{kind: 'literal' as const, value: source}];\n templates[key] = template;\n types[key] = inferJobOutputType({\n sourceName: params.sourceName,\n key,\n source,\n template,\n issues: params.issues,\n });\n }\n\n return {templates, types};\n}\n\nfunction inferJobOutputType(params: {\n sourceName: string;\n key: string;\n source: string;\n template: WorkflowFieldTemplate;\n issues: WorkflowModelValidationIssue[];\n}): ExpressionType {\n if (params.template.length !== 1) return 'string';\n\n const [segment] = params.template;\n if (segment?.kind !== 'deferred') return 'string';\n\n const resultType = segment.expression.resultType;\n if (resultType === undefined) return 'string';\n if (isScalarExpressionType(resultType)) return resultType;\n\n params.issues.push(\n issue({\n code: 'invalid-job-output',\n message: `Job output \"${params.key}\" must resolve to a scalar value.`,\n path: ['jobs', params.sourceName, 'outputs', params.key],\n details: {\n output: params.key,\n source: params.source,\n },\n }),\n );\n return 'string';\n}\n\nfunction isScalarExpressionType(type: ExpressionType): boolean {\n return (\n type === 'string' ||\n type === 'int' ||\n type === 'double' ||\n type === 'bool' ||\n type === 'null' ||\n type === 'timestamp'\n );\n}\n\nfunction normalizeJobSteps(params: {\n sourceName: string;\n jobId: string;\n job: WorkflowDocumentJob;\n issues: WorkflowModelValidationIssue[];\n stepSourceLocations: WorkflowStepSourceLocationMap | undefined;\n fillSite: AvailabilitySite;\n allowedJobReferences: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n upstreamJobs: readonly WorkflowJobTypeOverlay[];\n directNeedJobs: readonly WorkflowJobTypeOverlay[];\n context: NormalizeContext;\n}): readonly WorkflowModelStep[] {\n const usedStepIds = new Map<string, number>();\n\n return params.job.steps.map((step, index) =>\n normalizeStep({\n step,\n index,\n sourceName: params.sourceName,\n jobId: params.jobId,\n allSteps: params.job.steps,\n usedStepIds,\n issues: params.issues,\n stepSourceLocations: params.stepSourceLocations,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: params.typeOverlay,\n upstreamJobs: params.upstreamJobs,\n directNeedJobs: params.directNeedJobs,\n context: params.context,\n }),\n );\n}\n\nfunction normalizeStep(params: {\n step: WorkflowDocumentStep;\n index: number;\n sourceName: string;\n jobId: string;\n allSteps: readonly WorkflowDocumentStep[];\n usedStepIds: Map<string, number>;\n issues: WorkflowModelValidationIssue[];\n stepSourceLocations: WorkflowStepSourceLocationMap | undefined;\n fillSite: AvailabilitySite;\n allowedJobReferences: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n upstreamJobs: readonly WorkflowJobTypeOverlay[];\n directNeedJobs: readonly WorkflowJobTypeOverlay[];\n context: NormalizeContext;\n}): WorkflowModelStep {\n const stepKey = params.step.key;\n const stepId =\n stepKey === undefined\n ? `${params.jobId}-step-${params.index + 1}`\n : `${params.jobId}-${stableId(stepKey)}`;\n const existingIndex = params.usedStepIds.get(stepId);\n\n if (existingIndex !== undefined) {\n params.issues.push(\n issue({\n code: 'duplicate-step-id',\n message: `Steps ${existingIndex} and ${params.index} in job \"${params.sourceName}\" resolve to the same stable id \"${stepId}\".`,\n path: ['jobs', params.sourceName, 'steps', params.index],\n details: {id: stepId, indexes: [existingIndex, params.index]},\n }),\n );\n } else {\n params.usedStepIds.set(stepId, params.index);\n }\n\n const outputs = normalizeStepOutputs({\n step: params.step,\n sourceName: params.sourceName,\n stepIndex: params.index,\n issues: params.issues,\n });\n const currentStepOverlay =\n stepKey === undefined\n ? undefined\n : ({\n key: stepKey,\n ...(outputs === undefined ? {} : {outputs}),\n } satisfies WorkflowStepTypeOverlay);\n const shouldBuildTypeOverlay = params.typeOverlay !== undefined || params.upstreamJobs.length > 0;\n const typeOverlay = !shouldBuildTypeOverlay\n ? undefined\n : buildTypedRootsEnvironment({\n steps: previousStepOverlays(params.allSteps, params.index),\n ...(currentStepOverlay === undefined ? {} : {currentStep: currentStepOverlay}),\n ...(params.upstreamJobs.length === 0 ? {} : {jobs: params.upstreamJobs}),\n });\n const conditionTypeOverlay = buildTypedRootsEnvironment({\n steps: previousStepOverlays(params.allSteps, params.index),\n ...(currentStepOverlay === undefined ? {} : {currentStep: currentStepOverlay}),\n jobs: params.directNeedJobs,\n needs: params.directNeedJobs,\n });\n\n const condition = normalizeIfCondition({\n field: 'step.if',\n source: params.step.if,\n site: 'step-dispatch',\n path: ['jobs', params.sourceName, 'steps', params.index, 'if'],\n invalidCode: 'invalid-step-if',\n invalidMessage: 'Step if must be a valid wrapped CEL boolean expression.',\n issues: params.issues,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: conditionTypeOverlay,\n });\n const gate = normalizeStepGate({\n step: params.step,\n sourceName: params.sourceName,\n stepIndex: params.index,\n stepId,\n previousStepKeys: new Set(\n params.allSteps\n .slice(0, params.index)\n .flatMap((candidate) => (candidate.key ? [candidate.key] : [])),\n ),\n issues: params.issues,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay,\n });\n const sourceLocation = params.stepSourceLocations?.get(params.sourceName)?.get(params.index);\n const name =\n params.step.name === undefined\n ? undefined\n : parseInterpolationField({\n field: 'step.name',\n source: params.step.name,\n path: ['jobs', params.sourceName, 'steps', params.index, 'name'],\n issues: params.issues,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay,\n });\n const stepBase = {\n id: stepId,\n ...(stepKey === undefined ? {} : {key: stepKey}),\n ...(params.step.name === undefined ? {} : {name: params.step.name}),\n ...(outputs === undefined ? {} : {outputs}),\n ...(sourceLocation === undefined ? {} : {sourceLocation}),\n ...(condition === undefined ? {} : {if: condition}),\n ...(gate === undefined ? {} : {gate}),\n };\n\n if (params.step.run !== undefined) {\n return normalizeRunStep({\n step: params.step,\n stepBase,\n sourceName: params.sourceName,\n stepIndex: params.index,\n name,\n issues: params.issues,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay,\n });\n }\n\n if (params.step.prompt !== undefined) {\n return normalizeAgentStep({\n step: params.step,\n stepBase,\n sourceName: params.sourceName,\n stepIndex: params.index,\n name,\n issues: params.issues,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay,\n context: params.context,\n });\n }\n\n // workflowDocumentStepSchema requires either `run` or an agent `prompt`; this\n // keeps the model-step union honest if callers bypass the document parser.\n throw new Error(`Workflow step \"${stepId}\" is neither a run nor an agent step`);\n}\n\nfunction normalizeRunStep(params: {\n step: WorkflowDocumentStep;\n stepBase: WorkflowModelStepBaseFields;\n sourceName: string;\n stepIndex: number;\n name: WorkflowFieldTemplate | undefined;\n issues: WorkflowModelValidationIssue[];\n fillSite: AvailabilitySite;\n allowedJobReferences: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowModelRunStep {\n if (params.step.run === undefined) {\n throw new Error('Run step normalization requires a run command');\n }\n\n const commandTemplate = parseInterpolationField({\n field: 'run',\n source: params.step.run,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'run'],\n issues: params.issues,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: params.typeOverlay,\n });\n const stepEnv = normalizeEnv({\n env: params.step.env,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'env'],\n issues: params.issues,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: params.typeOverlay,\n });\n const templates = optionalRunStepTemplates({\n command: commandTemplate,\n name: params.name,\n env: stepEnv.templates?.env,\n });\n\n return {\n ...params.stepBase,\n kind: 'run',\n command: {kind: 'shell', value: params.step.run},\n ...(stepEnv.env === undefined ? {} : {env: stepEnv.env}),\n ...(templates === undefined ? {} : {templates}),\n };\n}\n\nfunction normalizeAgentStep(params: {\n step: WorkflowDocumentStep;\n stepBase: WorkflowModelStepBaseFields;\n sourceName: string;\n stepIndex: number;\n name: WorkflowFieldTemplate | undefined;\n issues: WorkflowModelValidationIssue[];\n fillSite: AvailabilitySite;\n allowedJobReferences: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n context: NormalizeContext;\n}): WorkflowModelAgentStep {\n if (params.step.prompt === undefined) {\n throw new Error('Agent step normalization requires a prompt');\n }\n\n const promptTemplate = parseInterpolationField({\n field: 'agent.prompt',\n source: params.step.prompt,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'prompt'],\n issues: params.issues,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: params.typeOverlay,\n });\n const modelTemplate =\n params.step.model === undefined\n ? undefined\n : parseInterpolationField({\n field: 'agent.model',\n source: params.step.model,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'model'],\n issues: params.issues,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: params.typeOverlay,\n });\n const providerTemplate =\n params.step.provider === undefined\n ? undefined\n : parseInterpolationField({\n field: 'agent.provider',\n source: params.step.provider,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'provider'],\n issues: params.issues,\n fillSite: params.fillSite,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: params.typeOverlay,\n });\n validateAgentStep({\n step: params.step,\n sourceName: params.sourceName,\n stepIndex: params.stepIndex,\n issues: params.issues,\n validateLiteralProvider: providerTemplate === undefined,\n harnessToolDeploymentConfig: params.context.harnessToolDeploymentConfig,\n });\n const integrations = normalizeAgentIntegrations({\n integrations: params.step.integrations,\n sourceName: params.sourceName,\n stepIndex: params.stepIndex,\n issues: params.issues,\n integrationValidationContext: params.context.integrationValidationContext,\n });\n const templates = optionalAgentStepTemplates({\n prompt: promptTemplate,\n model: modelTemplate,\n provider: providerTemplate,\n name: params.name,\n });\n\n return {\n ...params.stepBase,\n kind: 'agent',\n ...(params.step.harness === undefined ? {} : {harness: params.step.harness}),\n ...(params.step.model === undefined ? {} : {model: params.step.model}),\n ...(params.step.provider === undefined ? {} : {provider: params.step.provider}),\n prompt: params.step.prompt,\n ...(params.step.thinking === undefined ? {} : {thinking: params.step.thinking}),\n ...(params.step.tools === undefined ? {} : {tools: params.step.tools}),\n ...(integrations === undefined ? {} : {integrations}),\n ...(templates === undefined ? {} : {templates}),\n };\n}\n\nfunction validateAgentStep(params: {\n step: WorkflowDocumentStep;\n sourceName: string;\n stepIndex: number;\n issues: WorkflowModelValidationIssue[];\n validateLiteralProvider: boolean;\n harnessToolDeploymentConfig: HarnessToolDeploymentConfig;\n}): void {\n validateHarnessThinking(params);\n validateHarnessTools(params);\n if (!params.validateLiteralProvider) return;\n\n const providerId = params.step.provider;\n if (providerId === undefined) return;\n\n const provider = getModelProviderEntry(providerId);\n const harness = params.step.harness;\n if (provider === undefined && harness === 'pi') return;\n\n if (provider === undefined || provider.support_status !== 'supported') {\n params.issues.push(\n issue({\n code: 'invalid-provider',\n message: `Provider \"${providerId}\" is not supported.`,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'provider'],\n details: {provider: providerId},\n }),\n );\n return;\n }\n\n if (harness === undefined) return;\n\n const descriptor = getHarnessDescriptor(harness);\n if (descriptor.supportedProviderIds.includes(providerId)) return;\n\n params.issues.push(\n issue({\n code: 'harness-provider-incompatible',\n message: `Harness \"${harness}\" does not support provider: ${providerId}. Supported providers: ${descriptor.supportedProviderIds.join(', ')}.`,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'provider'],\n details: {harness, provider: providerId, supportedProviders: descriptor.supportedProviderIds},\n }),\n );\n}\n\nfunction validateHarnessTools(params: {\n step: WorkflowDocumentStep;\n sourceName: string;\n stepIndex: number;\n issues: WorkflowModelValidationIssue[];\n harnessToolDeploymentConfig: HarnessToolDeploymentConfig;\n}): void {\n const {harness, tools} = params.step;\n if (tools === undefined) return;\n\n if (harness === undefined) {\n params.issues.push(\n issue({\n code: 'missing-harness-for-tools',\n message:\n 'Agent step tools require an explicit harness because tool names are harness-specific.',\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'tools'],\n details: {tools},\n }),\n );\n return;\n }\n\n const supportedTools = listEnabledHarnessTools(harness, params.harnessToolDeploymentConfig).map(\n (tool) => tool.name,\n );\n const supportedToolSet = new Set(supportedTools);\n\n tools.forEach((tool, toolIndex) => {\n if (supportedToolSet.has(tool)) return;\n\n params.issues.push(\n issue({\n code: 'harness-tool-incompatible',\n message: `Harness \"${harness}\" does not support tool: ${tool}. Supported tools: ${supportedTools.join(', ')}.`,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'tools', toolIndex],\n details: {harness, tool, supportedTools},\n }),\n );\n });\n}\n\nfunction validateHarnessThinking(params: {\n step: WorkflowDocumentStep;\n sourceName: string;\n stepIndex: number;\n issues: WorkflowModelValidationIssue[];\n}): void {\n const {harness, thinking} = params.step;\n if (harness === undefined || thinking === undefined) return;\n\n const thinkingSchema = agentThinkingByHarness[harness];\n if (thinkingSchema.safeParse(thinking).success) return;\n\n const supportedLevels = thinkingSchema.options;\n params.issues.push(\n issue({\n code: 'harness-thinking-incompatible',\n message: `Harness \"${harness}\" does not support thinking: ${thinking}. Supported levels: ${supportedLevels.join(', ')}.`,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'thinking'],\n details: {harness, thinking, supportedLevels},\n }),\n );\n}\nfunction normalizeRunner(params: {\n document: WorkflowDocument;\n job: WorkflowDocumentJob;\n sourceName: string;\n issues: WorkflowModelValidationIssue[];\n defaultRunnerLabels: readonly string[];\n}): {labels: readonly string[]; templates: readonly WorkflowFieldTemplate[]} {\n const rawRunner = params.job.runner ?? params.document.runner;\n if (rawRunner === undefined) {\n const runnerLabels = params.defaultRunnerLabels;\n validateRunnerLabels({...params, runnerLabels, allowEmpty: false});\n return {labels: runnerLabels, templates: []};\n }\n\n const runnerValues = typeof rawRunner === 'string' ? [rawRunner] : rawRunner;\n const literalLabels: string[] = [];\n const templates: WorkflowFieldTemplate[] = [];\n let templateValueCount = 0;\n for (const [index, value] of runnerValues.entries()) {\n const template = parseInterpolationField({\n field: 'job.runner',\n source: value,\n path: ['jobs', params.sourceName, 'runner', index],\n issues: params.issues,\n fillSite: 'execution-creation',\n });\n const hasTemplateSyntax = hasInterpolationSyntax(value);\n if (hasTemplateSyntax) templateValueCount += 1;\n if (template === undefined && !hasTemplateSyntax) {\n literalLabels.push(value);\n } else if (template !== undefined) {\n templates.push(template);\n }\n }\n\n const runnerLabels = canonicalizeLabels(literalLabels);\n validateRunnerLabels({\n ...params,\n runnerLabels,\n runnerLabelCount: runnerLabels.length + templates.length,\n allowEmpty: templateValueCount > 0,\n });\n\n return {labels: runnerLabels, templates};\n}\n\nfunction hasInterpolationSyntax(value: string): boolean {\n return value.includes('${{');\n}\n\nfunction validateRunnerLabels(params: {\n sourceName: string;\n issues: WorkflowModelValidationIssue[];\n runnerLabels: readonly string[];\n runnerLabelCount?: number;\n allowEmpty: boolean;\n}): void {\n const runnerLabels = params.runnerLabels;\n const runnerLabelCount = params.runnerLabelCount ?? runnerLabels.length;\n const invalid = findInvalidLabels(runnerLabels);\n\n if (invalid.length > 0) {\n params.issues.push(\n issue({\n code: 'invalid-runner-label',\n message: `Job \"${params.sourceName}\" has invalid runner label(s): ${invalid.join(', ')}. Labels must match ${RUNNER_LABEL_PATTERN} and be at most ${MAX_RUNNER_LABEL_LENGTH} chars.`,\n path: ['jobs', params.sourceName, 'runner'],\n details: {labels: invalid},\n }),\n );\n }\n\n if (runnerLabels.length === 0 && !params.allowEmpty) {\n params.issues.push(\n issue({\n code: 'missing-runner-label',\n message: `Job \"${params.sourceName}\" must declare at least one runner label. Set \"runner\" on the job or the workflow, or configure DEFINITION_DEFAULT_RUNNER_LABEL.`,\n path: ['jobs', params.sourceName, 'runner'],\n }),\n );\n }\n\n if (runnerLabelCount > MAX_RUNNER_LABELS) {\n params.issues.push(\n issue({\n code: 'too-many-runner-labels',\n message: `Job \"${params.sourceName}\" declares ${runnerLabelCount} runner labels; the maximum is ${MAX_RUNNER_LABELS}.`,\n path: ['jobs', params.sourceName, 'runner'],\n }),\n );\n }\n}\n\ntype WorkflowModelStepBaseFields = Pick<\n WorkflowModelStep,\n 'id' | 'key' | 'name' | 'outputs' | 'sourceLocation' | 'gate'\n>;\n\nfunction optionalRunStepTemplates(params: {\n command: WorkflowFieldTemplate | undefined;\n name: WorkflowFieldTemplate | undefined;\n env: WorkflowEnvTemplates | undefined;\n}):\n | {\n command?: WorkflowFieldTemplate;\n name?: WorkflowFieldTemplate;\n env?: WorkflowEnvTemplates;\n }\n | undefined {\n if (params.command === undefined && params.name === undefined && params.env === undefined) {\n return undefined;\n }\n\n return {\n ...(params.command === undefined ? {} : {command: params.command}),\n ...(params.name === undefined ? {} : {name: params.name}),\n ...(params.env === undefined ? {} : {env: params.env}),\n };\n}\n\nfunction optionalAgentStepTemplates(params: {\n prompt: WorkflowFieldTemplate | undefined;\n model: WorkflowFieldTemplate | undefined;\n provider: WorkflowFieldTemplate | undefined;\n name: WorkflowFieldTemplate | undefined;\n}):\n | {\n prompt?: WorkflowFieldTemplate;\n model?: WorkflowFieldTemplate;\n provider?: WorkflowFieldTemplate;\n name?: WorkflowFieldTemplate;\n }\n | undefined {\n if (\n params.prompt === undefined &&\n params.model === undefined &&\n params.provider === undefined &&\n params.name === undefined\n ) {\n return undefined;\n }\n\n return {\n ...(params.prompt === undefined ? {} : {prompt: params.prompt}),\n ...(params.model === undefined ? {} : {model: params.model}),\n ...(params.provider === undefined ? {} : {provider: params.provider}),\n ...(params.name === undefined ? {} : {name: params.name}),\n };\n}\n"],"names":["agentThinkingByHarness","getHarnessDescriptor","getModelProviderEntry","listEnabledHarnessTools","buildTypedRootsEnvironment","canonicalizeLabels","findInvalidLabels","MAX_RUNNER_LABEL_LENGTH","MAX_RUNNER_LABELS","RUNNER_LABEL_PATTERN","normalizeAgentIntegrations","normalizeEnv","normalizeIfCondition","normalizeJobCheckout","normalizeJobListening","normalizeJobSuccess","normalizeNeeds","normalizeStepGate","normalizeStepOutputs","parseDurationMs","parseInterpolationField","stableId","issue","normalizeJobs","document","jobIdBySourceName","issues","stepSourceLocations","context","entries","Object","jobs","pending","Set","map","sourceName","modelsBySourceName","Map","jobOutputTypesBySourceName","issuesBySourceName","size","progressed","job","has","dependencySourceNames","needs","filter","dependency","some","model","normalizeJob","issuesForSourceName","undefined","set","delete","push","get","flatMap","existing","params","id","dependencies","normalizeJobDependencies","allowedJobReferences","directNeedSourceNames","upstreamJobs","upstreamJobTypeOverlays","directNeedJobs","directNeedJobTypeOverlays","upstreamJobsTypeOverlay","length","jobConditionTypeOverlay","stepFillSite","stepTypeOverlay","steps","step","outputs","normalizeJobSteps","jobId","fillSite","typeOverlay","runner","normalizeRunner","defaultRunnerLabels","checkout","jobEnv","env","path","success","source","condition","field","if","site","invalidCode","invalidMessage","normalizeJobOutputs","types","executionTimeoutMs","execution_timeout","listening","name","kind","value","key","mode","labels","templates","runnerTemplates","outputTypes","dependencySourceName","dependencyId","previousStepOverlays","index","slice","allStepOverlays","overlays","overlay","create","hasStepOutputDeclarations","template","inferJobOutputType","segment","resultType","expression","isScalarExpressionType","code","message","details","output","type","usedStepIds","normalizeStep","allSteps","stepKey","stepId","existingIndex","indexes","stepIndex","currentStepOverlay","shouldBuildTypeOverlay","currentStep","conditionTypeOverlay","gate","previousStepKeys","candidate","sourceLocation","stepBase","run","normalizeRunStep","prompt","normalizeAgentStep","Error","commandTemplate","stepEnv","optionalRunStepTemplates","command","promptTemplate","modelTemplate","providerTemplate","provider","validateAgentStep","validateLiteralProvider","harnessToolDeploymentConfig","integrations","integrationValidationContext","optionalAgentStepTemplates","harness","thinking","tools","validateHarnessThinking","validateHarnessTools","providerId","support_status","descriptor","supportedProviderIds","includes","join","supportedProviders","supportedTools","tool","supportedToolSet","forEach","toolIndex","thinkingSchema","safeParse","supportedLevels","options","rawRunner","runnerLabels","validateRunnerLabels","allowEmpty","runnerValues","literalLabels","templateValueCount","hasTemplateSyntax","hasInterpolationSyntax","runnerLabelCount","invalid"],"mappings":"AAAA,SACEA,sBAAsB,EACtBC,oBAAoB,EACpBC,qBAAqB,EAErBC,uBAAuB,QAClB,yBAAyB;AAChC,SAEEC,0BAA0B,QAKrB,sBAAsB;AAC7B,SACEC,kBAAkB,EAClBC,iBAAiB,EACjBC,uBAAuB,EACvBC,iBAAiB,EACjBC,oBAAoB,QACf,yBAAyB;AAkBhC,SAAQC,0BAA0B,QAAO,oCAAoC;AAC7E,SAAQC,YAAY,QAAO,qBAAqB;AAChD,SAAQC,oBAAoB,QAAO,8BAA8B;AACjE,SAAQC,oBAAoB,QAAO,8BAA8B;AACjE,SAAQC,qBAAqB,QAAO,+BAA+B;AACnE,SAAQC,mBAAmB,QAAO,6BAA6B;AAC/D,SAAQC,cAAc,QAAO,uBAAuB;AACpD,SAAQC,iBAAiB,QAAO,2BAA2B;AAC3D,SAAQC,oBAAoB,QAAO,8BAA8B;AACjE,SAAQC,eAAe,QAAO,yBAAyB;AACvD,SAAQC,uBAAuB,QAAO,iCAAiC;AACvE,SAAQC,QAAQ,QAAO,iBAAiB;AACxC,SAAQC,KAAK,QAAO,wBAAwB;AAQ5C,OAAO,SAASC,cACdC,QAA0B,EAC1BC,iBAA8C,EAC9CC,MAAsC,EACtCC,mBAA8D,EAC9DC,OA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OA;IACT;IAEA,OAAO;QACL,GAAIO,OAAOiG,OAAO,KAAKxG,YAAY,CAAC,IAAI;YAACwG,SAASjG,OAAOiG,OAAO;QAAA,CAAC;QACjE,GAAIjG,OAAO0C,IAAI,KAAKjD,YAAY,CAAC,IAAI;YAACiD,MAAM1C,OAAO0C,IAAI;QAAA,CAAC;QACxD,GAAI1C,OAAO2B,GAAG,KAAKlC,YAAY,CAAC,IAAI;YAACkC,KAAK3B,OAAO2B,GAAG;QAAA,CAAC;IACvD;AACF;AAEA,SAASgF,2BAA2B3G,MAKnC;IAQC,IACEA,OAAO2F,MAAM,KAAKlG,aAClBO,OAAOV,KAAK,KAAKG,aACjBO,OAAOqG,QAAQ,KAAK5G,aACpBO,OAAO0C,IAAI,KAAKjD,WAChB;QACA,OAAOA;IACT;IAEA,OAAO;QACL,GAAIO,OAAO2F,MAAM,KAAKlG,YAAY,CAAC,IAAI;YAACkG,QAAQ3F,OAAO2F,MAAM;QAAA,CAAC;QAC9D,GAAI3F,OAAOV,KAAK,KAAKG,YAAY,CAAC,IAAI;YAACH,OAAOU,OAAOV,KAAK;QAAA,CAAC;QAC3D,GAAIU,OAAOqG,QAAQ,KAAK5G,YAAY,CAAC,IAAI;YAAC4G,UAAUrG,OAAOqG,QAAQ;QAAA,CAAC;QACpE,GAAIrG,OAAO0C,IAAI,KAAKjD,YAAY,CAAC,IAAI;YAACiD,MAAM1C,OAAO0C,IAAI;QAAA,CAAC;IAC1D;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-needs.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-needs.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,CAE/F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function normalizeNeeds(value) {
|
|
2
|
+
return uniqueStrings(normalizeStringArray(value));
|
|
3
|
+
}
|
|
4
|
+
function normalizeStringArray(value) {
|
|
5
|
+
if (value === undefined) return [];
|
|
6
|
+
return typeof value === 'string' ? [
|
|
7
|
+
value
|
|
8
|
+
] : value;
|
|
9
|
+
}
|
|
10
|
+
function uniqueStrings(values) {
|
|
11
|
+
return [
|
|
12
|
+
...new Set(values)
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=normalize-needs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/normalize-needs.ts"],"sourcesContent":["export function normalizeNeeds(value: string | readonly string[] | undefined): readonly string[] {\n return uniqueStrings(normalizeStringArray(value));\n}\n\nfunction normalizeStringArray(value: string | readonly string[] | undefined): readonly string[] {\n if (value === undefined) return [];\n return typeof value === 'string' ? [value] : value;\n}\n\nfunction uniqueStrings(values: readonly string[]): readonly string[] {\n return [...new Set(values)];\n}\n"],"names":["normalizeNeeds","value","uniqueStrings","normalizeStringArray","undefined","values","Set"],"mappings":"AAAA,OAAO,SAASA,eAAeC,KAA6C;IAC1E,OAAOC,cAAcC,qBAAqBF;AAC5C;AAEA,SAASE,qBAAqBF,KAA6C;IACzE,IAAIA,UAAUG,WAAW,OAAO,EAAE;IAClC,OAAO,OAAOH,UAAU,WAAW;QAACA;KAAM,GAAGA;AAC/C;AAEA,SAASC,cAAcG,MAAyB;IAC9C,OAAO;WAAI,IAAIC,IAAID;KAAQ;AAC7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExpressionTypeEnvironment } from '@shipfox/expression';
|
|
2
|
+
import type { WorkflowDocumentStep } from '@shipfox/workflow-document';
|
|
3
|
+
import type { WorkflowModelStepGate } from '../entities/workflow-model.js';
|
|
4
|
+
import type { WorkflowModelValidationIssue } from './invalid-workflow-model-error.js';
|
|
5
|
+
export declare function normalizeStepGate(params: {
|
|
6
|
+
step: WorkflowDocumentStep;
|
|
7
|
+
sourceName: string;
|
|
8
|
+
stepIndex: number;
|
|
9
|
+
stepId: string;
|
|
10
|
+
previousStepKeys: ReadonlySet<string>;
|
|
11
|
+
issues: WorkflowModelValidationIssue[];
|
|
12
|
+
allowedJobReferences: ReadonlySet<string>;
|
|
13
|
+
typeOverlay?: ExpressionTypeEnvironment | undefined;
|
|
14
|
+
}): WorkflowModelStepGate | undefined;
|
|
15
|
+
//# sourceMappingURL=normalize-step-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-step-gate.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-step-gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,yBAAyB,EAAqB,MAAM,qBAAqB,CAAC;AACvF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAKpF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,EAAE,4BAA4B,EAAE,CAAC;IACvC,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C,WAAW,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;CACrD,GAAG,qBAAqB,GAAG,SAAS,CAiDpC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { parseInterpolationField } from './parse-interpolation-field.js';
|
|
2
|
+
import { validatePredicateExpression } from './validate-predicate-expression.js';
|
|
3
|
+
import { issue } from './validation-issue.js';
|
|
4
|
+
export function normalizeStepGate(params) {
|
|
5
|
+
const gate = params.step.gate;
|
|
6
|
+
if (gate === undefined) return undefined;
|
|
7
|
+
const success = normalizeGateSuccess({
|
|
8
|
+
source: gate.success,
|
|
9
|
+
sourceName: params.sourceName,
|
|
10
|
+
stepIndex: params.stepIndex,
|
|
11
|
+
issues: params.issues,
|
|
12
|
+
allowedJobReferences: params.allowedJobReferences,
|
|
13
|
+
typeOverlay: params.typeOverlay
|
|
14
|
+
});
|
|
15
|
+
const feedbackTemplate = gate.on_failure?.feedback === undefined ? undefined : parseInterpolationField({
|
|
16
|
+
field: 'step.feedback',
|
|
17
|
+
source: gate.on_failure.feedback,
|
|
18
|
+
path: [
|
|
19
|
+
'jobs',
|
|
20
|
+
params.sourceName,
|
|
21
|
+
'steps',
|
|
22
|
+
params.stepIndex,
|
|
23
|
+
'gate',
|
|
24
|
+
'on_failure'
|
|
25
|
+
],
|
|
26
|
+
issues: params.issues,
|
|
27
|
+
fillSite: 'step-report',
|
|
28
|
+
typeOverlay: params.typeOverlay
|
|
29
|
+
});
|
|
30
|
+
const onFailure = gate.on_failure === undefined ? undefined : {
|
|
31
|
+
restartFrom: gate.on_failure.restart_from,
|
|
32
|
+
...gate.on_failure.feedback === undefined ? {} : {
|
|
33
|
+
feedback: gate.on_failure.feedback
|
|
34
|
+
},
|
|
35
|
+
...feedbackTemplate === undefined ? {} : {
|
|
36
|
+
feedbackTemplate
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
if (gate.on_failure !== undefined && !params.previousStepKeys.has(gate.on_failure.restart_from)) {
|
|
40
|
+
params.issues.push(issue({
|
|
41
|
+
code: 'invalid-step-gate-restart-from',
|
|
42
|
+
message: `Step "${params.stepId}" must restart from an earlier keyed step; found "${gate.on_failure.restart_from}".`,
|
|
43
|
+
path: [
|
|
44
|
+
'jobs',
|
|
45
|
+
params.sourceName,
|
|
46
|
+
'steps',
|
|
47
|
+
params.stepIndex,
|
|
48
|
+
'gate',
|
|
49
|
+
'on_failure'
|
|
50
|
+
],
|
|
51
|
+
details: {
|
|
52
|
+
stepId: params.stepId,
|
|
53
|
+
restartFrom: gate.on_failure.restart_from
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
if (success === undefined && onFailure === undefined) return undefined;
|
|
58
|
+
return {
|
|
59
|
+
...success === undefined ? {} : {
|
|
60
|
+
success
|
|
61
|
+
},
|
|
62
|
+
...onFailure === undefined ? {} : {
|
|
63
|
+
onFailure
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function normalizeGateSuccess(params) {
|
|
68
|
+
if (params.source === undefined) return undefined;
|
|
69
|
+
return validatePredicateExpression({
|
|
70
|
+
field: 'step.success',
|
|
71
|
+
source: params.source,
|
|
72
|
+
site: 'step-report',
|
|
73
|
+
path: [
|
|
74
|
+
'jobs',
|
|
75
|
+
params.sourceName,
|
|
76
|
+
'steps',
|
|
77
|
+
params.stepIndex,
|
|
78
|
+
'gate',
|
|
79
|
+
'success'
|
|
80
|
+
],
|
|
81
|
+
invalidCode: 'invalid-step-gate-success',
|
|
82
|
+
invalidMessage: 'Step gate success must be a valid CEL boolean expression.',
|
|
83
|
+
issues: params.issues,
|
|
84
|
+
allowedJobReferences: params.allowedJobReferences,
|
|
85
|
+
typeOverlay: params.typeOverlay
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=normalize-step-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/normalize-step-gate.ts"],"sourcesContent":["import type {ExpressionTypeEnvironment, WorkflowExpression} from '@shipfox/expression';\nimport type {WorkflowDocumentStep} from '@shipfox/workflow-document';\nimport type {WorkflowModelStepGate} from '../entities/workflow-model.js';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {parseInterpolationField} from './parse-interpolation-field.js';\nimport {validatePredicateExpression} from './validate-predicate-expression.js';\nimport {issue} from './validation-issue.js';\n\nexport function normalizeStepGate(params: {\n step: WorkflowDocumentStep;\n sourceName: string;\n stepIndex: number;\n stepId: string;\n previousStepKeys: ReadonlySet<string>;\n issues: WorkflowModelValidationIssue[];\n allowedJobReferences: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowModelStepGate | undefined {\n const gate = params.step.gate;\n if (gate === undefined) return undefined;\n\n const success = normalizeGateSuccess({\n source: gate.success,\n sourceName: params.sourceName,\n stepIndex: params.stepIndex,\n issues: params.issues,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: params.typeOverlay,\n });\n const feedbackTemplate =\n gate.on_failure?.feedback === undefined\n ? undefined\n : parseInterpolationField({\n field: 'step.feedback',\n source: gate.on_failure.feedback,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'gate', 'on_failure'],\n issues: params.issues,\n fillSite: 'step-report',\n typeOverlay: params.typeOverlay,\n });\n const onFailure =\n gate.on_failure === undefined\n ? undefined\n : {\n restartFrom: gate.on_failure.restart_from,\n ...(gate.on_failure.feedback === undefined ? {} : {feedback: gate.on_failure.feedback}),\n ...(feedbackTemplate === undefined ? {} : {feedbackTemplate}),\n };\n\n if (gate.on_failure !== undefined && !params.previousStepKeys.has(gate.on_failure.restart_from)) {\n params.issues.push(\n issue({\n code: 'invalid-step-gate-restart-from',\n message: `Step \"${params.stepId}\" must restart from an earlier keyed step; found \"${gate.on_failure.restart_from}\".`,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'gate', 'on_failure'],\n details: {stepId: params.stepId, restartFrom: gate.on_failure.restart_from},\n }),\n );\n }\n\n if (success === undefined && onFailure === undefined) return undefined;\n\n return {\n ...(success === undefined ? {} : {success}),\n ...(onFailure === undefined ? {} : {onFailure}),\n };\n}\n\nfunction normalizeGateSuccess(params: {\n source: string | undefined;\n sourceName: string;\n stepIndex: number;\n issues: WorkflowModelValidationIssue[];\n allowedJobReferences: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowExpression | undefined {\n if (params.source === undefined) return undefined;\n\n return validatePredicateExpression({\n field: 'step.success',\n source: params.source,\n site: 'step-report',\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'gate', 'success'],\n invalidCode: 'invalid-step-gate-success',\n invalidMessage: 'Step gate success must be a valid CEL boolean expression.',\n issues: params.issues,\n allowedJobReferences: params.allowedJobReferences,\n typeOverlay: params.typeOverlay,\n });\n}\n"],"names":["parseInterpolationField","validatePredicateExpression","issue","normalizeStepGate","params","gate","step","undefined","success","normalizeGateSuccess","source","sourceName","stepIndex","issues","allowedJobReferences","typeOverlay","feedbackTemplate","on_failure","feedback","field","path","fillSite","onFailure","restartFrom","restart_from","previousStepKeys","has","push","code","message","stepId","details","site","invalidCode","invalidMessage"],"mappings":"AAIA,SAAQA,uBAAuB,QAAO,iCAAiC;AACvE,SAAQC,2BAA2B,QAAO,qCAAqC;AAC/E,SAAQC,KAAK,QAAO,wBAAwB;AAE5C,OAAO,SAASC,kBAAkBC,MASjC;IACC,MAAMC,OAAOD,OAAOE,IAAI,CAACD,IAAI;IAC7B,IAAIA,SAASE,WAAW,OAAOA;IAE/B,MAAMC,UAAUC,qBAAqB;QACnCC,QAAQL,KAAKG,OAAO;QACpBG,YAAYP,OAAOO,UAAU;QAC7BC,WAAWR,OAAOQ,SAAS;QAC3BC,QAAQT,OAAOS,MAAM;QACrBC,sBAAsBV,OAAOU,oBAAoB;QACjDC,aAAaX,OAAOW,WAAW;IACjC;IACA,MAAMC,mBACJX,KAAKY,UAAU,EAAEC,aAAaX,YAC1BA,YACAP,wBAAwB;QACtBmB,OAAO;QACPT,QAAQL,KAAKY,UAAU,CAACC,QAAQ;QAChCE,MAAM;YAAC;YAAQhB,OAAOO,UAAU;YAAE;YAASP,OAAOQ,SAAS;YAAE;YAAQ;SAAa;QAClFC,QAAQT,OAAOS,MAAM;QACrBQ,UAAU;QACVN,aAAaX,OAAOW,WAAW;IACjC;IACN,MAAMO,YACJjB,KAAKY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BAAsBV,OAAOU,oBAAoB;QACjDC,aAAaX,OAAOW,WAAW;IACjC;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type OutputDeclarations } from '@shipfox/expression';
|
|
2
|
+
import type { WorkflowDocumentStep } from '@shipfox/workflow-document';
|
|
3
|
+
import type { WorkflowModelValidationIssue } from './invalid-workflow-model-error.js';
|
|
4
|
+
export declare function normalizeStepOutputs(params: {
|
|
5
|
+
step: WorkflowDocumentStep;
|
|
6
|
+
sourceName: string;
|
|
7
|
+
stepIndex: number;
|
|
8
|
+
issues: WorkflowModelValidationIssue[];
|
|
9
|
+
}): OutputDeclarations | undefined;
|
|
10
|
+
//# sourceMappingURL=normalize-step-outputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-step-outputs.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-step-outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,kBAAkB,EAAqB,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAGpF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,IAAI,EAAE,oBAAoB,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,4BAA4B,EAAE,CAAC;CACxC,GAAG,kBAAkB,GAAG,SAAS,CAyBjC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { validateJsonSchema } from '@shipfox/expression';
|
|
2
|
+
import { issue } from './validation-issue.js';
|
|
3
|
+
export function normalizeStepOutputs(params) {
|
|
4
|
+
const outputs = params.step.outputs;
|
|
5
|
+
if (outputs === undefined) return undefined;
|
|
6
|
+
for (const [key, declaration] of Object.entries(outputs)){
|
|
7
|
+
const schema = 'schema' in declaration ? declaration.schema : undefined;
|
|
8
|
+
if (declaration.type !== 'json' || schema === undefined) continue;
|
|
9
|
+
const validation = validateJsonSchema(schema);
|
|
10
|
+
if (validation.ok) continue;
|
|
11
|
+
params.issues.push(issue({
|
|
12
|
+
code: 'invalid-output-schema',
|
|
13
|
+
message: `Step output "${key}" must declare a valid JSON Schema.`,
|
|
14
|
+
path: [
|
|
15
|
+
'jobs',
|
|
16
|
+
params.sourceName,
|
|
17
|
+
'steps',
|
|
18
|
+
params.stepIndex,
|
|
19
|
+
'outputs',
|
|
20
|
+
key,
|
|
21
|
+
'schema'
|
|
22
|
+
],
|
|
23
|
+
details: {
|
|
24
|
+
output: key,
|
|
25
|
+
reason: validation.reason
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
return outputs;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=normalize-step-outputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/normalize-step-outputs.ts"],"sourcesContent":["import {type OutputDeclarations, validateJsonSchema} from '@shipfox/expression';\nimport type {WorkflowDocumentStep} from '@shipfox/workflow-document';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {issue} from './validation-issue.js';\n\nexport function normalizeStepOutputs(params: {\n step: WorkflowDocumentStep;\n sourceName: string;\n stepIndex: number;\n issues: WorkflowModelValidationIssue[];\n}): OutputDeclarations | undefined {\n const outputs = params.step.outputs;\n if (outputs === undefined) return undefined;\n\n for (const [key, declaration] of Object.entries(outputs)) {\n const schema = 'schema' in declaration ? declaration.schema : undefined;\n if (declaration.type !== 'json' || schema === undefined) continue;\n\n const validation = validateJsonSchema(schema);\n if (validation.ok) continue;\n\n params.issues.push(\n issue({\n code: 'invalid-output-schema',\n message: `Step output \"${key}\" must declare a valid JSON Schema.`,\n path: ['jobs', params.sourceName, 'steps', params.stepIndex, 'outputs', key, 'schema'],\n details: {\n output: key,\n reason: validation.reason,\n },\n }),\n );\n }\n\n return outputs;\n}\n"],"names":["validateJsonSchema","issue","normalizeStepOutputs","params","outputs","step","undefined","key","declaration","Object","entries","schema","type","validation","ok","issues","push","code","message","path","sourceName","stepIndex","details","output","reason"],"mappings":"AAAA,SAAiCA,kBAAkB,QAAO,sBAAsB;AAGhF,SAAQC,KAAK,QAAO,wBAAwB;AAE5C,OAAO,SAASC,qBAAqBC,MAKpC;IACC,MAAMC,UAAUD,OAAOE,IAAI,CAACD,OAAO;IACnC,IAAIA,YAAYE,WAAW,OAAOA;IAElC,KAAK,MAAM,CAACC,KAAKC,YAAY,IAAIC,OAAOC,OAAO,CAACN,SAAU;QACxD,MAAMO,SAAS,YAAYH,cAAcA,YAAYG,MAAM,GAAGL;QAC9D,IAAIE,YAAYI,IAAI,KAAK,UAAUD,WAAWL,WAAW;QAEzD,MAAMO,aAAab,mBAAmBW;QACtC,IAAIE,WAAWC,EAAE,EAAE;QAEnBX,OAAOY,MAAM,CAACC,IAAI,CAChBf,MAAM;YACJgB,MAAM;YACNC,SAAS,CAAC,aAAa,EAAEX,IAAI,mCAAmC,CAAC;YACjEY,MAAM;gBAAC;gBAAQhB,OAAOiB,UAAU;gBAAE;gBAASjB,OAAOkB,SAAS;gBAAE;gBAAWd;gBAAK;aAAS;YACtFe,SAAS;gBACPC,QAAQhB;gBACRiB,QAAQX,WAAWW,MAAM;YAC3B;QACF;IAEJ;IAEA,OAAOpB;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type WorkflowDocument } from '@shipfox/workflow-document';
|
|
2
|
+
import type { WorkflowModelListeningTrigger, WorkflowModelTrigger } from '../entities/workflow-model.js';
|
|
3
|
+
import type { WorkflowModelValidationIssue } from './invalid-workflow-model-error.js';
|
|
4
|
+
export declare function normalizeTriggers(document: WorkflowDocument, issues: WorkflowModelValidationIssue[]): readonly WorkflowModelTrigger[];
|
|
5
|
+
export declare function normalizeTriggerEntry(trigger: {
|
|
6
|
+
readonly source: string;
|
|
7
|
+
readonly event: string;
|
|
8
|
+
readonly with?: Readonly<Record<string, unknown>> | undefined;
|
|
9
|
+
readonly filter?: string | undefined;
|
|
10
|
+
}): WorkflowModelListeningTrigger;
|
|
11
|
+
//# sourceMappingURL=normalize-triggers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-triggers.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAC7F,OAAO,KAAK,EACV,6BAA6B,EAC7B,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AASpF,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,4BAA4B,EAAE,GACrC,SAAS,oBAAoB,EAAE,CAiEjC;AAkCD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,GAAG,6BAA6B,CAOhC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { triggerSourceConfigSchemas } from '@shipfox/workflow-document';
|
|
2
|
+
import { cronTriggerDefaultTimezone, validateCronTrigger } from './cron-trigger.js';
|
|
3
|
+
import { stableId } from './stable-id.js';
|
|
4
|
+
import { validatePredicateExpression } from './validate-predicate-expression.js';
|
|
5
|
+
import { issue } from './validation-issue.js';
|
|
6
|
+
const manualTriggerSource = 'manual';
|
|
7
|
+
const cronTriggerSource = 'cron';
|
|
8
|
+
export function normalizeTriggers(document, issues) {
|
|
9
|
+
const triggers = document.triggers ?? {};
|
|
10
|
+
const manualTriggerKeys = Object.entries(triggers).filter(([, trigger])=>trigger.source === manualTriggerSource).map(([sourceKey])=>sourceKey);
|
|
11
|
+
const usedTriggerIds = new Map();
|
|
12
|
+
if (manualTriggerKeys.length > 1) {
|
|
13
|
+
issues.push(issue({
|
|
14
|
+
code: 'multiple-manual-triggers',
|
|
15
|
+
message: `A workflow may declare at most one manual trigger; found ${manualTriggerKeys.length}: ${manualTriggerKeys.join(', ')}.`,
|
|
16
|
+
path: [
|
|
17
|
+
'triggers'
|
|
18
|
+
],
|
|
19
|
+
details: {
|
|
20
|
+
manualTriggerKeys
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
return Object.entries(triggers).flatMap(([sourceKey, trigger])=>{
|
|
25
|
+
const id = stableId(sourceKey);
|
|
26
|
+
const existingSourceKey = usedTriggerIds.get(id);
|
|
27
|
+
if (existingSourceKey !== undefined) {
|
|
28
|
+
issues.push(issue({
|
|
29
|
+
code: 'duplicate-trigger-id',
|
|
30
|
+
message: `Trigger keys "${existingSourceKey}" and "${sourceKey}" resolve to the same stable id "${id}".`,
|
|
31
|
+
path: [
|
|
32
|
+
'triggers',
|
|
33
|
+
sourceKey
|
|
34
|
+
],
|
|
35
|
+
details: {
|
|
36
|
+
id,
|
|
37
|
+
sourceKeys: [
|
|
38
|
+
existingSourceKey,
|
|
39
|
+
sourceKey
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
usedTriggerIds.set(id, sourceKey);
|
|
46
|
+
validateTriggerFilter({
|
|
47
|
+
sourceKey,
|
|
48
|
+
trigger,
|
|
49
|
+
issues
|
|
50
|
+
});
|
|
51
|
+
const normalizedTrigger = normalizeTriggerEntry(trigger);
|
|
52
|
+
if (trigger.source !== cronTriggerSource) {
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
id,
|
|
56
|
+
key: sourceKey,
|
|
57
|
+
...normalizedTrigger,
|
|
58
|
+
...trigger.config === undefined ? {} : {
|
|
59
|
+
config: trigger.config
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
const cronConfig = triggerSourceConfigSchemas.cron.parse(trigger.config ?? {});
|
|
65
|
+
const normalizedCronConfig = {
|
|
66
|
+
...cronConfig,
|
|
67
|
+
timezone: cronConfig.timezone ?? cronTriggerDefaultTimezone
|
|
68
|
+
};
|
|
69
|
+
validateCronTrigger({
|
|
70
|
+
trigger,
|
|
71
|
+
config: cronConfig,
|
|
72
|
+
sourceKey,
|
|
73
|
+
issues
|
|
74
|
+
});
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
id,
|
|
78
|
+
key: sourceKey,
|
|
79
|
+
...normalizedTrigger,
|
|
80
|
+
config: normalizedCronConfig
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function validateTriggerFilter(params) {
|
|
86
|
+
const { sourceKey, trigger, issues } = params;
|
|
87
|
+
if (trigger.filter === undefined) return;
|
|
88
|
+
const path = [
|
|
89
|
+
'triggers',
|
|
90
|
+
sourceKey,
|
|
91
|
+
'filter'
|
|
92
|
+
];
|
|
93
|
+
if (trigger.source === manualTriggerSource || trigger.source === cronTriggerSource) {
|
|
94
|
+
issues.push(issue({
|
|
95
|
+
code: 'invalid-trigger-filter',
|
|
96
|
+
message: `A ${trigger.source} trigger cannot define a filter because it does not receive an event payload.`,
|
|
97
|
+
path,
|
|
98
|
+
details: {
|
|
99
|
+
source: trigger.filter,
|
|
100
|
+
triggerSource: trigger.source
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
validatePredicateExpression({
|
|
106
|
+
field: 'trigger.filter',
|
|
107
|
+
source: trigger.filter,
|
|
108
|
+
site: 'ingest',
|
|
109
|
+
path,
|
|
110
|
+
invalidCode: 'invalid-trigger-filter',
|
|
111
|
+
invalidMessage: 'Trigger filter must be a valid boolean predicate.',
|
|
112
|
+
issues
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export function normalizeTriggerEntry(trigger) {
|
|
116
|
+
return {
|
|
117
|
+
source: trigger.source,
|
|
118
|
+
event: trigger.event,
|
|
119
|
+
...trigger.with === undefined ? {} : {
|
|
120
|
+
inputs: trigger.with
|
|
121
|
+
},
|
|
122
|
+
...trigger.filter === undefined ? {} : {
|
|
123
|
+
filter: trigger.filter
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=normalize-triggers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/normalize-triggers.ts"],"sourcesContent":["import {triggerSourceConfigSchemas, type WorkflowDocument} from '@shipfox/workflow-document';\nimport type {\n WorkflowModelListeningTrigger,\n WorkflowModelTrigger,\n} from '../entities/workflow-model.js';\nimport {cronTriggerDefaultTimezone, validateCronTrigger} from './cron-trigger.js';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {stableId} from './stable-id.js';\nimport {validatePredicateExpression} from './validate-predicate-expression.js';\nimport {issue} from './validation-issue.js';\n\nconst manualTriggerSource = 'manual';\nconst cronTriggerSource = 'cron';\ntype WorkflowDocumentTrigger = NonNullable<WorkflowDocument['triggers']>[string];\n\nexport function normalizeTriggers(\n document: WorkflowDocument,\n issues: WorkflowModelValidationIssue[],\n): readonly WorkflowModelTrigger[] {\n const triggers = document.triggers ?? {};\n const manualTriggerKeys = Object.entries(triggers)\n .filter(([, trigger]) => trigger.source === manualTriggerSource)\n .map(([sourceKey]) => sourceKey);\n const usedTriggerIds = new Map<string, string>();\n\n if (manualTriggerKeys.length > 1) {\n issues.push(\n issue({\n code: 'multiple-manual-triggers',\n message: `A workflow may declare at most one manual trigger; found ${manualTriggerKeys.length}: ${manualTriggerKeys.join(', ')}.`,\n path: ['triggers'],\n details: {manualTriggerKeys},\n }),\n );\n }\n\n return Object.entries(triggers).flatMap(([sourceKey, trigger]) => {\n const id = stableId(sourceKey);\n const existingSourceKey = usedTriggerIds.get(id);\n if (existingSourceKey !== undefined) {\n issues.push(\n issue({\n code: 'duplicate-trigger-id',\n message: `Trigger keys \"${existingSourceKey}\" and \"${sourceKey}\" resolve to the same stable id \"${id}\".`,\n path: ['triggers', sourceKey],\n details: {id, sourceKeys: [existingSourceKey, sourceKey]},\n }),\n );\n return [];\n }\n usedTriggerIds.set(id, sourceKey);\n\n validateTriggerFilter({sourceKey, trigger, issues});\n\n const normalizedTrigger = normalizeTriggerEntry(trigger);\n if (trigger.source !== cronTriggerSource) {\n return [\n {\n id,\n key: sourceKey,\n ...normalizedTrigger,\n ...(trigger.config === undefined ? {} : {config: trigger.config}),\n },\n ];\n }\n\n const cronConfig = triggerSourceConfigSchemas.cron.parse(trigger.config ?? {});\n const normalizedCronConfig = {\n ...cronConfig,\n timezone: cronConfig.timezone ?? cronTriggerDefaultTimezone,\n };\n\n validateCronTrigger({trigger, config: cronConfig, sourceKey, issues});\n\n return [\n {\n id,\n key: sourceKey,\n ...normalizedTrigger,\n config: normalizedCronConfig,\n },\n ];\n });\n}\n\nfunction validateTriggerFilter(params: {\n sourceKey: string;\n trigger: WorkflowDocumentTrigger;\n issues: WorkflowModelValidationIssue[];\n}): void {\n const {sourceKey, trigger, issues} = params;\n if (trigger.filter === undefined) return;\n\n const path = ['triggers', sourceKey, 'filter'] as const;\n if (trigger.source === manualTriggerSource || trigger.source === cronTriggerSource) {\n issues.push(\n issue({\n code: 'invalid-trigger-filter',\n message: `A ${trigger.source} trigger cannot define a filter because it does not receive an event payload.`,\n path,\n details: {source: trigger.filter, triggerSource: trigger.source},\n }),\n );\n return;\n }\n\n validatePredicateExpression({\n field: 'trigger.filter',\n source: trigger.filter,\n site: 'ingest',\n path,\n invalidCode: 'invalid-trigger-filter',\n invalidMessage: 'Trigger filter must be a valid boolean predicate.',\n issues,\n });\n}\n\nexport function normalizeTriggerEntry(trigger: {\n readonly source: string;\n readonly event: string;\n readonly with?: Readonly<Record<string, unknown>> | undefined;\n readonly filter?: string | undefined;\n}): WorkflowModelListeningTrigger {\n return {\n source: trigger.source,\n event: trigger.event,\n ...(trigger.with === undefined ? {} : {inputs: trigger.with}),\n ...(trigger.filter === undefined ? {} : {filter: trigger.filter}),\n };\n}\n"],"names":["triggerSourceConfigSchemas","cronTriggerDefaultTimezone","validateCronTrigger","stableId","validatePredicateExpression","issue","manualTriggerSource","cronTriggerSource","normalizeTriggers","document","issues","triggers","manualTriggerKeys","Object","entries","filter","trigger","source","map","sourceKey","usedTriggerIds","Map","length","push","code","message","join","path","details","flatMap","id","existingSourceKey","get","undefined","sourceKeys","set","validateTriggerFilter","normalizedTrigger","normalizeTriggerEntry","key","config","cronConfig","cron","parse","normalizedCronConfig","timezone","params","triggerSource","field","site","invalidCode","invalidMessage","event","with","inputs"],"mappings":"AAAA,SAAQA,0BAA0B,QAA8B,6BAA6B;AAK7F,SAAQC,0BAA0B,EAAEC,mBAAmB,QAAO,oBAAoB;AAElF,SAAQC,QAAQ,QAAO,iBAAiB;AACxC,SAAQC,2BAA2B,QAAO,qCAAqC;AAC/E,SAAQC,KAAK,QAAO,wBAAwB;AAE5C,MAAMC,sBAAsB;AAC5B,MAAMC,oBAAoB;AAG1B,OAAO,SAASC,kBACdC,QAA0B,EAC1BC,MAAsC;IAEtC,MAAMC,WAAWF,SAASE,QAAQ,IAAI,CAAC;IACvC,MAAMC,oBAAoBC,OAAOC,OAAO,CAACH,UACtCI,MAAM,CAAC,CAAC,GAAGC,QAAQ,GAAKA,QAAQC,MAAM,KAAKX,qBAC3CY,GAAG,CAAC,CAAC,CAACC,UAAU,GAAKA;IACxB,MAAMC,iBAAiB,IAAIC;IAE3B,IAA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oBAAoB;YAACc;YAASwB,QAAQC;YAAYtB;YAAWT;QAAM;QAEnE,OAAO;YACL;gBACEoB;gBACAS,KAAKpB;gBACL,GAAGkB,iBAAiB;gBACpBG,QAAQI;YACV;SACD;IACH;AACF;AAEA,SAASR,sBAAsBU,MAI9B;IACC,MAAM,EAAC3B,SAAS,EAAEH,OAAO,EAAEN,MAAM,EAAC,GAAGoC;IACrC,IAAI9B,QAAQD,MAAM,KAAKkB,WAAW;IAElC,MAAMN,OAAO;QAAC;QAAYR;QAAW;KAAS;IAC9C,IAAIH,QAAQC,MAAM,KAAKX,uBAAuBU,QAAQC,MAAM,KAAKV,mBAAmB;QAClFG,OAAOa,IAAI,CACTlB,MAAM;YACJmB,MAAM;YACNC,SAAS,CAAC,EAAE,EAAET,QAAQC,MAAM,CAAC,6EAA6E,CAAC;YAC3GU;YACAC,SAAS;gBAACX,QAAQD,QAAQD,MAAM;gBAAEgC,eAAe/B,QAAQC,MAAM;YAAA;QACjE;QAEF;IACF;IAEAb,4BAA4B;QAC1B4C,OAAO;QACP/B,QAAQD,QAAQD,MAAM;QACtBkC,MAAM;QACNtB;QACAuB,aAAa;QACbC,gBAAgB;QAChBzC;IACF;AACF;AAEA,OAAO,SAAS4B,sBAAsBtB,OAKrC;IACC,OAAO;QACLC,QAAQD,QAAQC,MAAM;QACtBmC,OAAOpC,QAAQoC,KAAK;QACpB,GAAIpC,QAAQqC,IAAI,KAAKpB,YAAY,CAAC,IAAI;YAACqB,QAAQtC,QAAQqC,IAAI;QAAA,CAAC;QAC5D,GAAIrC,QAAQD,MAAM,KAAKkB,YAAY,CAAC,IAAI;YAAClB,QAAQC,QAAQD,MAAM;QAAA,CAAC;IAClE;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type HarnessToolDeploymentConfig } from '@shipfox/api-agent-dto';
|
|
2
|
+
import type { WorkflowDocument } from '@shipfox/workflow-document';
|
|
3
|
+
import type { IntegrationValidationContext } from '../entities/integration-context.js';
|
|
4
|
+
import type { WorkflowModel, WorkflowStepSourceLocationMap } from '../entities/workflow-model.js';
|
|
5
|
+
export declare function normalizeWorkflowDocument(document: WorkflowDocument, options?: {
|
|
6
|
+
defaultRunnerLabels?: readonly string[] | undefined;
|
|
7
|
+
harnessToolDeploymentConfig?: HarnessToolDeploymentConfig | undefined;
|
|
8
|
+
integrationValidationContext?: IntegrationValidationContext | undefined;
|
|
9
|
+
stepSourceLocations?: WorkflowStepSourceLocationMap | undefined;
|
|
10
|
+
}): WorkflowModel;
|
|
11
|
+
//# sourceMappingURL=normalize-workflow-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-workflow-document.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-workflow-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAC,aAAa,EAAE,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAWhG,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACpD,2BAA2B,CAAC,EAAE,2BAA2B,GAAG,SAAS,CAAC;IACtE,4BAA4B,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;IACxE,mBAAmB,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;CAC5D,GACL,aAAa,CAoCf"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DEFAULT_HARNESS_TOOL_DEPLOYMENT_CONFIG } from '@shipfox/api-agent-dto';
|
|
2
|
+
import { canonicalizeLabels } from '@shipfox/runner-labels';
|
|
3
|
+
import { InvalidWorkflowModelError } from './invalid-workflow-model-error.js';
|
|
4
|
+
import { mapJobIds } from './map-job-ids.js';
|
|
5
|
+
import { normalizeDependencies, validateCycles } from './normalize-dependencies.js';
|
|
6
|
+
import { normalizeEnv } from './normalize-env.js';
|
|
7
|
+
import { normalizeJobs } from './normalize-jobs.js';
|
|
8
|
+
import { normalizeTriggers } from './normalize-triggers.js';
|
|
9
|
+
export function normalizeWorkflowDocument(document, options = {}) {
|
|
10
|
+
const issues = [];
|
|
11
|
+
const defaultRunnerLabels = canonicalizeLabels(options.defaultRunnerLabels);
|
|
12
|
+
const harnessToolDeploymentConfig = options.harnessToolDeploymentConfig ?? DEFAULT_HARNESS_TOOL_DEPLOYMENT_CONFIG;
|
|
13
|
+
const context = {
|
|
14
|
+
defaultRunnerLabels,
|
|
15
|
+
harnessToolDeploymentConfig,
|
|
16
|
+
integrationValidationContext: options.integrationValidationContext
|
|
17
|
+
};
|
|
18
|
+
const jobIdBySourceName = mapJobIds(document, issues);
|
|
19
|
+
const triggers = normalizeTriggers(document, issues);
|
|
20
|
+
const jobs = normalizeJobs(document, jobIdBySourceName, issues, options.stepSourceLocations, context);
|
|
21
|
+
const dependencies = normalizeDependencies(document.jobs, jobIdBySourceName, issues);
|
|
22
|
+
const workflowEnv = normalizeEnv({
|
|
23
|
+
env: document.env,
|
|
24
|
+
path: [
|
|
25
|
+
'env'
|
|
26
|
+
],
|
|
27
|
+
issues
|
|
28
|
+
});
|
|
29
|
+
validateCycles(document.jobs, jobIdBySourceName, issues);
|
|
30
|
+
if (issues.length > 0) {
|
|
31
|
+
throw new InvalidWorkflowModelError(issues);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
kind: 'workflow',
|
|
35
|
+
name: document.name,
|
|
36
|
+
...workflowEnv,
|
|
37
|
+
triggers,
|
|
38
|
+
jobs,
|
|
39
|
+
dependencies
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=normalize-workflow-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/normalize-workflow-document.ts"],"sourcesContent":["import {\n DEFAULT_HARNESS_TOOL_DEPLOYMENT_CONFIG,\n type HarnessToolDeploymentConfig,\n} from '@shipfox/api-agent-dto';\nimport {canonicalizeLabels} from '@shipfox/runner-labels';\nimport type {WorkflowDocument} from '@shipfox/workflow-document';\nimport type {IntegrationValidationContext} from '../entities/integration-context.js';\nimport type {WorkflowModel, WorkflowStepSourceLocationMap} from '../entities/workflow-model.js';\nimport {\n InvalidWorkflowModelError,\n type WorkflowModelValidationIssue,\n} from './invalid-workflow-model-error.js';\nimport {mapJobIds} from './map-job-ids.js';\nimport {normalizeDependencies, validateCycles} from './normalize-dependencies.js';\nimport {normalizeEnv} from './normalize-env.js';\nimport {normalizeJobs} from './normalize-jobs.js';\nimport {normalizeTriggers} from './normalize-triggers.js';\n\nexport function normalizeWorkflowDocument(\n document: WorkflowDocument,\n options: {\n defaultRunnerLabels?: readonly string[] | undefined;\n harnessToolDeploymentConfig?: HarnessToolDeploymentConfig | undefined;\n integrationValidationContext?: IntegrationValidationContext | undefined;\n stepSourceLocations?: WorkflowStepSourceLocationMap | undefined;\n } = {},\n): WorkflowModel {\n const issues: WorkflowModelValidationIssue[] = [];\n const defaultRunnerLabels = canonicalizeLabels(options.defaultRunnerLabels);\n const harnessToolDeploymentConfig =\n options.harnessToolDeploymentConfig ?? DEFAULT_HARNESS_TOOL_DEPLOYMENT_CONFIG;\n const context = {\n defaultRunnerLabels,\n harnessToolDeploymentConfig,\n integrationValidationContext: options.integrationValidationContext,\n };\n const jobIdBySourceName = mapJobIds(document, issues);\n const triggers = normalizeTriggers(document, issues);\n const jobs = normalizeJobs(\n document,\n jobIdBySourceName,\n issues,\n options.stepSourceLocations,\n context,\n );\n const dependencies = normalizeDependencies(document.jobs, jobIdBySourceName, issues);\n const workflowEnv = normalizeEnv({env: document.env, path: ['env'], issues});\n\n validateCycles(document.jobs, jobIdBySourceName, issues);\n\n if (issues.length > 0) {\n throw new InvalidWorkflowModelError(issues);\n }\n\n return {\n kind: 'workflow',\n name: document.name,\n ...workflowEnv,\n triggers,\n jobs,\n dependencies,\n };\n}\n"],"names":["DEFAULT_HARNESS_TOOL_DEPLOYMENT_CONFIG","canonicalizeLabels","InvalidWorkflowModelError","mapJobIds","normalizeDependencies","validateCycles","normalizeEnv","normalizeJobs","normalizeTriggers","normalizeWorkflowDocument","document","options","issues","defaultRunnerLabels","harnessToolDeploymentConfig","context","integrationValidationContext","jobIdBySourceName","triggers","jobs","stepSourceLocations","dependencies","workflowEnv","env","path","length","kind","name"],"mappings":"AAAA,SACEA,sCAAsC,QAEjC,yBAAyB;AAChC,SAAQC,kBAAkB,QAAO,yBAAyB;AAI1D,SACEC,yBAAyB,QAEpB,oCAAoC;AAC3C,SAAQC,SAAS,QAAO,mBAAmB;AAC3C,SAAQC,qBAAqB,EAAEC,cAAc,QAAO,8BAA8B;AAClF,SAAQC,YAAY,QAAO,qBAAqB;AAChD,SAAQC,aAAa,QAAO,sBAAsB;AAClD,SAAQC,iBAAiB,QAAO,0BAA0B;AAE1D,OAAO,SAASC,0BACdC,QAA0B,EAC1BC,UAKI,CAAC,CAAC;IAEN,MAAMC,SAAyC,EAAE;IACjD,MAAMC,sBAAsBZ,mBAAmBU,QAAQE,mBAAmB;IAC1E,MAAMC,8BACJH,QAAQG,2BAA2B,IAAId;IACzC,MAAMe,UAAU;QACdF;QACAC;QACAE,8BAA8BL,QAAQK,4BAA4B;IACpE;IACA,MAAMC,oBAAoBd,UAAUO,UAAUE;IAC9C,MAAMM,WAAWV,kBAAkBE,UAAUE;IAC7C,MAAMO,OAAOZ,cACXG,UACAO,mBACAL,QACAD,QAAQS,mBAAmB,EAC3BL;IAEF,MAAMM,eAAejB,sBAAsBM,SAASS,IAAI,EAAEF,mBAAmBL;IAC7E,MAAMU,cAAchB,aAAa;QAACiB,KAAKb,SAASa,GAAG;QAAEC,MAAM;YAAC;SAAM;QAAEZ;IAAM;IAE1EP,eAAeK,SAASS,IAAI,EAAEF,mBAAmBL;IAEjD,IAAIA,OAAOa,MAAM,GAAG,GAAG;QACrB,MAAM,IAAIvB,0BAA0BU;IACtC;IAEA,OAAO;QACLc,MAAM;QACNC,MAAMjB,SAASiB,IAAI;QACnB,GAAGL,WAAW;QACdJ;QACAC;QACAE;IACF;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WorkflowModelValidationIssue } from './invalid-workflow-model-error.js';
|
|
2
|
+
export declare function parseDurationMs(params: {
|
|
3
|
+
source: string | undefined;
|
|
4
|
+
path: Array<string | number>;
|
|
5
|
+
issues: WorkflowModelValidationIssue[];
|
|
6
|
+
minMs?: number | undefined;
|
|
7
|
+
maxMs?: number | undefined;
|
|
8
|
+
outOfRangeCode?: 'invalid-duration' | 'listening-timeout-exceeds-run-timeout' | undefined;
|
|
9
|
+
outOfRangeMessage?: string | undefined;
|
|
10
|
+
}): number | undefined;
|
|
11
|
+
//# sourceMappingURL=parse-duration-ms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-duration-ms.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/parse-duration-ms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAepF,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,4BAA4B,EAAE,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,cAAc,CAAC,EAAE,kBAAkB,GAAG,uCAAuC,GAAG,SAAS,CAAC;IAC1F,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC,GAAG,MAAM,GAAG,SAAS,CAkCrB"}
|