@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,273 @@
|
|
|
1
|
+
import { analyzeContextRootKeyAccess, availabilitySites, createWorkflowExpression, extractExactContextRoots, getWorkflowContextDefinition, getWorkflowContextTypeEnvironment, InvalidWorkflowExpressionError, predicateSourceIsBooleanShaped, resolveContextRootAvailability, resolveContextRootHost, routeExpression, validateServerEvaluable, workflowContextNames } from '@shipfox/expression';
|
|
2
|
+
import { validateDirectJobReferences } from './validate-job-references.js';
|
|
3
|
+
import { issue } from './validation-issue.js';
|
|
4
|
+
import { workflowFieldLabel } from './workflow-field-label.js';
|
|
5
|
+
export function validatePredicateExpression(params) {
|
|
6
|
+
const syntaxExpression = createSyntaxExpression(params);
|
|
7
|
+
if (syntaxExpression === undefined) return undefined;
|
|
8
|
+
const contextRoots = extractExactContextRoots(syntaxExpression.source);
|
|
9
|
+
const knownRoots = contextRoots.filter((root)=>resolveContextRootHost(root) !== undefined);
|
|
10
|
+
const unknownRoots = contextRoots.filter((root)=>resolveContextRootHost(root) === undefined);
|
|
11
|
+
if (unknownRoots.length > 0) {
|
|
12
|
+
params.issues.push(invalidPredicateIssue({
|
|
13
|
+
...params,
|
|
14
|
+
contextRoots
|
|
15
|
+
}));
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const serverEvaluability = validateServerEvaluable(syntaxExpression);
|
|
19
|
+
if (!serverEvaluability.ok) {
|
|
20
|
+
params.issues.push(...serverEvaluability.violations.map((violation)=>runnerContextInServerPredicateIssue({
|
|
21
|
+
...params,
|
|
22
|
+
contextRoots,
|
|
23
|
+
runnerRoots: violation.runnerRoots
|
|
24
|
+
})));
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const varsRoots = knownRoots.filter((root)=>root === 'vars');
|
|
28
|
+
if (varsRoots.length > 0) {
|
|
29
|
+
params.issues.push(varsContextInServerPredicateIssue({
|
|
30
|
+
...params,
|
|
31
|
+
contextRoots
|
|
32
|
+
}));
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const unavailableRoots = knownRoots.filter((root)=>!isRootAvailableAt(root, params.site));
|
|
36
|
+
if (unavailableRoots.length > 0) {
|
|
37
|
+
params.issues.push(unavailablePredicateContextIssue({
|
|
38
|
+
...params,
|
|
39
|
+
contextRoots,
|
|
40
|
+
unavailableRoots
|
|
41
|
+
}));
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const route = routeExpression(syntaxExpression);
|
|
45
|
+
if (route.fillTarget !== 'runner-fill' && !isSiteAtOrAfter(params.site, route.fillTarget)) {
|
|
46
|
+
const unavailableRoots = unavailableRouteReferences(syntaxExpression);
|
|
47
|
+
params.issues.push(unavailableRoots.length > 0 ? unavailablePredicateContextIssue({
|
|
48
|
+
...params,
|
|
49
|
+
contextRoots,
|
|
50
|
+
unavailableRoots
|
|
51
|
+
}) : routeUnavailablePredicateContextIssue({
|
|
52
|
+
...params,
|
|
53
|
+
contextRoots,
|
|
54
|
+
fillTarget: route.fillTarget
|
|
55
|
+
}));
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const invalidJobReferenceIssue = params.allowedJobReferences === undefined ? undefined : validateDirectJobReferences({
|
|
59
|
+
source: params.source,
|
|
60
|
+
expression: syntaxExpression,
|
|
61
|
+
field: params.field,
|
|
62
|
+
path: params.path,
|
|
63
|
+
allowedJobReferences: params.allowedJobReferences
|
|
64
|
+
});
|
|
65
|
+
if (invalidJobReferenceIssue !== undefined) {
|
|
66
|
+
params.issues.push(invalidJobReferenceIssue);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
if (params.typeOverlay === undefined && knownRoots.some((root)=>hasSyntaxOnlyCheckMode(root))) {
|
|
70
|
+
if (isWorkflowFilterPredicateField(params.field) && !predicateSourceIsBooleanShaped(syntaxExpression.source)) {
|
|
71
|
+
params.issues.push(invalidPredicateIssue({
|
|
72
|
+
...params,
|
|
73
|
+
contextRoots,
|
|
74
|
+
reason: 'Predicate source must be boolean-shaped.'
|
|
75
|
+
}));
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
return syntaxExpression;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
return createWorkflowExpression({
|
|
82
|
+
source: params.source,
|
|
83
|
+
check: {
|
|
84
|
+
mode: 'typed',
|
|
85
|
+
// `undefined` preserves the legacy syntax-only path above. `{}` means
|
|
86
|
+
// callers intentionally requested typed checking with the standard roots.
|
|
87
|
+
typeEnvironment: mergeTypeEnvironments(knownRoots, params.typeOverlay),
|
|
88
|
+
expectedResultType: 'bool'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
} catch (error) {
|
|
92
|
+
params.issues.push(invalidPredicateIssue({
|
|
93
|
+
...params,
|
|
94
|
+
contextRoots,
|
|
95
|
+
reason: error instanceof InvalidWorkflowExpressionError ? error.reason : 'Expression source did not parse or type-check.'
|
|
96
|
+
}));
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function createSyntaxExpression(params) {
|
|
101
|
+
try {
|
|
102
|
+
return createWorkflowExpression({
|
|
103
|
+
source: params.source,
|
|
104
|
+
check: {
|
|
105
|
+
mode: 'syntax'
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
} catch (error) {
|
|
109
|
+
params.issues.push(invalidPredicateIssue({
|
|
110
|
+
...params,
|
|
111
|
+
contextRoots: [],
|
|
112
|
+
reason: error instanceof InvalidWorkflowExpressionError ? error.reason : 'Expression source did not parse or type-check.'
|
|
113
|
+
}));
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function invalidPredicateIssue(params) {
|
|
118
|
+
return issue({
|
|
119
|
+
code: params.invalidCode,
|
|
120
|
+
message: params.invalidMessage,
|
|
121
|
+
path: params.path,
|
|
122
|
+
details: {
|
|
123
|
+
field: params.field,
|
|
124
|
+
source: params.source,
|
|
125
|
+
contextRoots: params.contextRoots,
|
|
126
|
+
reason: params.reason ?? 'Expression source did not parse or type-check.'
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const availabilitySiteLabels = {
|
|
131
|
+
ingest: 'ingest',
|
|
132
|
+
'run-creation': 'run creation',
|
|
133
|
+
'execution-creation': 'execution creation',
|
|
134
|
+
'job-activation': 'job activation',
|
|
135
|
+
'step-dispatch': 'step dispatch',
|
|
136
|
+
'step-report': 'step reporting',
|
|
137
|
+
'execution-resolution': 'execution resolution',
|
|
138
|
+
'job-resolution': 'job resolution'
|
|
139
|
+
};
|
|
140
|
+
function runnerContextInServerPredicateIssue(params) {
|
|
141
|
+
return issue({
|
|
142
|
+
code: 'runner-context-in-server-predicate',
|
|
143
|
+
message: `${fieldLabel(params.field)} cannot reference runner context ${formatList(params.runnerRoots)} because it is evaluated on the server at ${describeAvailabilitySite(params.site)}.`,
|
|
144
|
+
path: params.path,
|
|
145
|
+
details: {
|
|
146
|
+
field: params.field,
|
|
147
|
+
source: params.source,
|
|
148
|
+
contextRoots: params.contextRoots,
|
|
149
|
+
runnerRoots: params.runnerRoots,
|
|
150
|
+
site: params.site
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function varsContextInServerPredicateIssue(params) {
|
|
155
|
+
return issue({
|
|
156
|
+
code: 'vars-context-in-server-predicate',
|
|
157
|
+
message: `${fieldLabel(params.field)} cannot reference vars because predicate evaluation does not include workflow variables.`,
|
|
158
|
+
path: params.path,
|
|
159
|
+
details: {
|
|
160
|
+
field: params.field,
|
|
161
|
+
source: params.source,
|
|
162
|
+
contextRoots: params.contextRoots,
|
|
163
|
+
rejectedRoots: [
|
|
164
|
+
'vars'
|
|
165
|
+
],
|
|
166
|
+
site: params.site
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function unavailablePredicateContextIssue(params) {
|
|
171
|
+
return issue({
|
|
172
|
+
code: 'context-unavailable-at-predicate-site',
|
|
173
|
+
message: `${fieldLabel(params.field)} references ${contextNoun(params.unavailableRoots)} ${formatList(params.unavailableRoots)} that ${availabilityVerb(params.unavailableRoots)} not available at ${describeAvailabilitySite(params.site)}. ${params.unavailableRoots.map(unavailableRootAvailabilityMessage).join(' ')}`,
|
|
174
|
+
path: params.path,
|
|
175
|
+
details: {
|
|
176
|
+
field: params.field,
|
|
177
|
+
source: params.source,
|
|
178
|
+
contextRoots: params.contextRoots,
|
|
179
|
+
unavailableRoots: params.unavailableRoots,
|
|
180
|
+
site: params.site
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function routeUnavailablePredicateContextIssue(params) {
|
|
185
|
+
return issue({
|
|
186
|
+
code: 'context-unavailable-at-predicate-site',
|
|
187
|
+
message: `${fieldLabel(params.field)} requires context filled at ${describeAvailabilitySite(params.fillTarget)}, but it is evaluated at ${describeAvailabilitySite(params.site)}.`,
|
|
188
|
+
path: params.path,
|
|
189
|
+
details: {
|
|
190
|
+
field: params.field,
|
|
191
|
+
source: params.source,
|
|
192
|
+
contextRoots: params.contextRoots,
|
|
193
|
+
fillTarget: params.fillTarget,
|
|
194
|
+
site: params.site
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function isRootAvailableAt(root, site) {
|
|
199
|
+
const availability = resolveContextRootAvailability(root);
|
|
200
|
+
if (availability === undefined) return false;
|
|
201
|
+
return availabilitySites.indexOf(availability) <= availabilitySites.indexOf(site);
|
|
202
|
+
}
|
|
203
|
+
function unavailableRootAvailabilityMessage(root) {
|
|
204
|
+
if (root === 'execution.failed') {
|
|
205
|
+
return '"execution.failed" becomes available at step dispatch.';
|
|
206
|
+
}
|
|
207
|
+
const availability = resolveContextRootAvailability(root);
|
|
208
|
+
if (availability === undefined) return `"${root}" is not available at any server site.`;
|
|
209
|
+
return `"${root}" becomes available at ${describeAvailabilitySite(availability)}.`;
|
|
210
|
+
}
|
|
211
|
+
function unavailableRouteReferences(expression) {
|
|
212
|
+
const access = analyzeContextRootKeyAccess(expression, [
|
|
213
|
+
'execution'
|
|
214
|
+
]);
|
|
215
|
+
return access.references.some((reference)=>reference.key === 'failed') ? [
|
|
216
|
+
'execution.failed'
|
|
217
|
+
] : [];
|
|
218
|
+
}
|
|
219
|
+
function hasSyntaxOnlyCheckMode(root) {
|
|
220
|
+
if (!isWorkflowContextName(root)) return resolveContextRootHost(root) === 'server';
|
|
221
|
+
return isWorkflowContextName(root) && getWorkflowContextDefinition(root).checkMode === 'syntax';
|
|
222
|
+
}
|
|
223
|
+
function mergeTypeEnvironments(roots, typeOverlay) {
|
|
224
|
+
const typeEnvironment = {};
|
|
225
|
+
for (const root of roots){
|
|
226
|
+
const overlayType = typeOverlay?.[root];
|
|
227
|
+
if (overlayType !== undefined) {
|
|
228
|
+
typeEnvironment[root] = overlayType;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (!isWorkflowContextName(root)) {
|
|
232
|
+
if (typeOverlay !== undefined) typeEnvironment[root] = {
|
|
233
|
+
kind: 'map'
|
|
234
|
+
};
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const contextTypeEnvironment = getWorkflowContextTypeEnvironment(root);
|
|
238
|
+
if (contextTypeEnvironment === undefined) {
|
|
239
|
+
if (typeOverlay !== undefined) typeEnvironment[root] = {
|
|
240
|
+
kind: 'map'
|
|
241
|
+
};
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
Object.assign(typeEnvironment, contextTypeEnvironment);
|
|
245
|
+
}
|
|
246
|
+
return typeEnvironment;
|
|
247
|
+
}
|
|
248
|
+
function isWorkflowContextName(root) {
|
|
249
|
+
return workflowContextNames.includes(root);
|
|
250
|
+
}
|
|
251
|
+
function isWorkflowFilterPredicateField(field) {
|
|
252
|
+
return field === 'trigger.filter' || field === 'listener.on' || field === 'listener.until';
|
|
253
|
+
}
|
|
254
|
+
function fieldLabel(field) {
|
|
255
|
+
return workflowFieldLabel(field);
|
|
256
|
+
}
|
|
257
|
+
function contextNoun(roots) {
|
|
258
|
+
return roots.length === 1 ? 'context' : 'contexts';
|
|
259
|
+
}
|
|
260
|
+
function availabilityVerb(roots) {
|
|
261
|
+
return roots.length === 1 ? 'is' : 'are';
|
|
262
|
+
}
|
|
263
|
+
function describeAvailabilitySite(site) {
|
|
264
|
+
return availabilitySiteLabels[site];
|
|
265
|
+
}
|
|
266
|
+
function isSiteAtOrAfter(site, fillTarget) {
|
|
267
|
+
return availabilitySites.indexOf(site) >= availabilitySites.indexOf(fillTarget);
|
|
268
|
+
}
|
|
269
|
+
function formatList(values) {
|
|
270
|
+
return values.map((value)=>`"${value}"`).join(', ');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
//# sourceMappingURL=validate-predicate-expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/validate-predicate-expression.ts"],"sourcesContent":["import {\n type AvailabilitySite,\n analyzeContextRootKeyAccess,\n availabilitySites,\n createWorkflowExpression,\n type ExpressionTypeEnvironment,\n extractExactContextRoots,\n getWorkflowContextDefinition,\n getWorkflowContextTypeEnvironment,\n InvalidWorkflowExpressionError,\n predicateSourceIsBooleanShaped,\n resolveContextRootAvailability,\n resolveContextRootHost,\n routeExpression,\n validateServerEvaluable,\n type WorkflowContextName,\n type WorkflowExpression,\n type WorkflowPredicateField,\n workflowContextNames,\n} from '@shipfox/expression';\nimport type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\nimport {validateDirectJobReferences} from './validate-job-references.js';\nimport {issue} from './validation-issue.js';\nimport {workflowFieldLabel} from './workflow-field-label.js';\n\nexport function validatePredicateExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowExpression | undefined {\n const syntaxExpression = createSyntaxExpression(params);\n if (syntaxExpression === undefined) return undefined;\n\n const contextRoots = extractExactContextRoots(syntaxExpression.source);\n const knownRoots = contextRoots.filter((root) => resolveContextRootHost(root) !== undefined);\n const unknownRoots = contextRoots.filter((root) => resolveContextRootHost(root) === undefined);\n\n if (unknownRoots.length > 0) {\n params.issues.push(invalidPredicateIssue({...params, contextRoots}));\n return undefined;\n }\n\n const serverEvaluability = validateServerEvaluable(syntaxExpression);\n if (!serverEvaluability.ok) {\n params.issues.push(\n ...serverEvaluability.violations.map((violation) =>\n runnerContextInServerPredicateIssue({\n ...params,\n contextRoots,\n runnerRoots: violation.runnerRoots,\n }),\n ),\n );\n return undefined;\n }\n\n const varsRoots = knownRoots.filter((root) => root === 'vars');\n if (varsRoots.length > 0) {\n params.issues.push(varsContextInServerPredicateIssue({...params, contextRoots}));\n return undefined;\n }\n\n const unavailableRoots = knownRoots.filter((root) => !isRootAvailableAt(root, params.site));\n if (unavailableRoots.length > 0) {\n params.issues.push(\n unavailablePredicateContextIssue({...params, contextRoots, unavailableRoots}),\n );\n return undefined;\n }\n\n const route = routeExpression(syntaxExpression);\n if (route.fillTarget !== 'runner-fill' && !isSiteAtOrAfter(params.site, route.fillTarget)) {\n const unavailableRoots = unavailableRouteReferences(syntaxExpression);\n params.issues.push(\n unavailableRoots.length > 0\n ? unavailablePredicateContextIssue({\n ...params,\n contextRoots,\n unavailableRoots,\n })\n : routeUnavailablePredicateContextIssue({\n ...params,\n contextRoots,\n fillTarget: route.fillTarget,\n }),\n );\n return undefined;\n }\n\n const invalidJobReferenceIssue =\n params.allowedJobReferences === undefined\n ? undefined\n : validateDirectJobReferences({\n source: params.source,\n expression: syntaxExpression,\n field: params.field,\n path: params.path,\n allowedJobReferences: params.allowedJobReferences,\n });\n if (invalidJobReferenceIssue !== undefined) {\n params.issues.push(invalidJobReferenceIssue);\n return undefined;\n }\n\n if (params.typeOverlay === undefined && knownRoots.some((root) => hasSyntaxOnlyCheckMode(root))) {\n if (\n isWorkflowFilterPredicateField(params.field) &&\n !predicateSourceIsBooleanShaped(syntaxExpression.source)\n ) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason: 'Predicate source must be boolean-shaped.',\n }),\n );\n return undefined;\n }\n\n return syntaxExpression;\n }\n\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {\n mode: 'typed',\n // `undefined` preserves the legacy syntax-only path above. `{}` means\n // callers intentionally requested typed checking with the standard roots.\n typeEnvironment: mergeTypeEnvironments(knownRoots, params.typeOverlay),\n expectedResultType: 'bool',\n },\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction createSyntaxExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n}): WorkflowExpression | undefined {\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {mode: 'syntax'},\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots: [],\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction invalidPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n contextRoots: readonly string[];\n reason?: string;\n}): WorkflowModelValidationIssue {\n return issue({\n code: params.invalidCode,\n message: params.invalidMessage,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n reason: params.reason ?? 'Expression source did not parse or type-check.',\n },\n });\n}\n\nconst availabilitySiteLabels = {\n ingest: 'ingest',\n 'run-creation': 'run creation',\n 'execution-creation': 'execution creation',\n 'job-activation': 'job activation',\n 'step-dispatch': 'step dispatch',\n 'step-report': 'step reporting',\n 'execution-resolution': 'execution resolution',\n 'job-resolution': 'job resolution',\n} as const satisfies Record<AvailabilitySite, string>;\n\nfunction runnerContextInServerPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n runnerRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'runner-context-in-server-predicate',\n message: `${fieldLabel(params.field)} cannot reference runner context ${formatList(\n params.runnerRoots,\n )} because it is evaluated on the server at ${describeAvailabilitySite(params.site)}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n runnerRoots: params.runnerRoots,\n site: params.site,\n },\n });\n}\n\nfunction varsContextInServerPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'vars-context-in-server-predicate',\n message: `${fieldLabel(params.field)} cannot reference vars because predicate evaluation does not include workflow variables.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n rejectedRoots: ['vars'],\n site: params.site,\n },\n });\n}\n\nfunction unavailablePredicateContextIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n unavailableRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-predicate-site',\n message: `${fieldLabel(params.field)} references ${contextNoun(\n params.unavailableRoots,\n )} ${formatList(params.unavailableRoots)} that ${availabilityVerb(\n params.unavailableRoots,\n )} not available at ${describeAvailabilitySite(params.site)}. ${params.unavailableRoots\n .map(unavailableRootAvailabilityMessage)\n .join(' ')}`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n unavailableRoots: params.unavailableRoots,\n site: params.site,\n },\n });\n}\n\nfunction routeUnavailablePredicateContextIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n fillTarget: AvailabilitySite;\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-predicate-site',\n message: `${fieldLabel(params.field)} requires context filled at ${describeAvailabilitySite(\n params.fillTarget,\n )}, but it is evaluated at ${describeAvailabilitySite(params.site)}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n fillTarget: params.fillTarget,\n site: params.site,\n },\n });\n}\n\nfunction isRootAvailableAt(root: string, site: AvailabilitySite): boolean {\n const availability = resolveContextRootAvailability(root);\n if (availability === undefined) return false;\n\n return availabilitySites.indexOf(availability) <= availabilitySites.indexOf(site);\n}\n\nfunction unavailableRootAvailabilityMessage(root: string): string {\n if (root === 'execution.failed') {\n return '\"execution.failed\" becomes available at step dispatch.';\n }\n\n const availability = resolveContextRootAvailability(root);\n if (availability === undefined) return `\"${root}\" is not available at any server site.`;\n return `\"${root}\" becomes available at ${describeAvailabilitySite(availability)}.`;\n}\n\nfunction unavailableRouteReferences(expression: WorkflowExpression): readonly string[] {\n const access = analyzeContextRootKeyAccess(expression, ['execution']);\n return access.references.some((reference) => reference.key === 'failed')\n ? ['execution.failed']\n : [];\n}\n\nfunction hasSyntaxOnlyCheckMode(root: string): boolean {\n if (!isWorkflowContextName(root)) return resolveContextRootHost(root) === 'server';\n return isWorkflowContextName(root) && getWorkflowContextDefinition(root).checkMode === 'syntax';\n}\n\nfunction mergeTypeEnvironments(\n roots: readonly string[],\n typeOverlay?: ExpressionTypeEnvironment,\n): ExpressionTypeEnvironment {\n const typeEnvironment: Record<string, ExpressionTypeEnvironment[string]> = {};\n\n for (const root of roots) {\n const overlayType = typeOverlay?.[root];\n if (overlayType !== undefined) {\n typeEnvironment[root] = overlayType;\n continue;\n }\n\n if (!isWorkflowContextName(root)) {\n if (typeOverlay !== undefined) typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n const contextTypeEnvironment = getWorkflowContextTypeEnvironment(root);\n if (contextTypeEnvironment === undefined) {\n if (typeOverlay !== undefined) typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n Object.assign(typeEnvironment, contextTypeEnvironment);\n }\n\n return typeEnvironment;\n}\n\nfunction isWorkflowContextName(root: string): root is WorkflowContextName {\n return (workflowContextNames as readonly string[]).includes(root);\n}\n\nfunction isWorkflowFilterPredicateField(field: WorkflowPredicateField): boolean {\n return field === 'trigger.filter' || field === 'listener.on' || field === 'listener.until';\n}\n\nfunction fieldLabel(field: WorkflowPredicateField): string {\n return workflowFieldLabel(field);\n}\n\nfunction contextNoun(roots: readonly string[]): 'context' | 'contexts' {\n return roots.length === 1 ? 'context' : 'contexts';\n}\n\nfunction availabilityVerb(roots: readonly string[]): 'is' | 'are' {\n return roots.length === 1 ? 'is' : 'are';\n}\n\nfunction describeAvailabilitySite(site: AvailabilitySite): string {\n return availabilitySiteLabels[site];\n}\n\nfunction isSiteAtOrAfter(site: AvailabilitySite, fillTarget: AvailabilitySite): boolean {\n return availabilitySites.indexOf(site) >= availabilitySites.indexOf(fillTarget);\n}\n\nfunction formatList(values: readonly string[]): string {\n return values.map((value) => `\"${value}\"`).join(', ');\n}\n"],"names":["analyzeContextRootKeyAccess","availabilitySites","createWorkflowExpression","extractExactContextRoots","getWorkflowContextDefinition","getWorkflowContextTypeEnvironment","InvalidWorkflowExpressionError","predicateSourceIsBooleanShaped","resolveContextRootAvailability","resolveContextRootHost","routeExpression","validateServerEvaluable","workflowContextNames","validateDirectJobReferences","issue","workflowFieldLabel","validatePredicateExpression","params","syntaxExpression","createSyntaxExpression","undefined","contextRoots","source","knownRoots","filter","root","unknownRoots","length","issues","push","invalidPredicateIssue","serverEvaluability","ok","violations","map","violation","runnerContextInServerPredicateIssue","runnerRoots","varsRoots","varsContextInServerPredicateIssue","unavailableRoots","isRootAvailableAt","site","unavailablePredicateContextIssue","route","fillTarget","isSiteAtOrAfter","unavailableRouteReferences","routeUnavailablePredicateContextIssue","invalidJobReferenceIssue","allowedJobReferences","expression","field","path","typeOverlay","some","hasSyntaxOnlyCheckMode","isWorkflowFilterPredicateField","reason","check","mode","typeEnvironment","mergeTypeEnvironments","expectedResultType","error","code","invalidCode","message","invalidMessage","details","availabilitySiteLabels","ingest","fieldLabel","formatList","describeAvailabilitySite","rejectedRoots","contextNoun","availabilityVerb","unavailableRootAvailabilityMessage","join","availability","indexOf","access","references","reference","key","isWorkflowContextName","checkMode","roots","overlayType","kind","contextTypeEnvironment","Object","assign","includes","values","value"],"mappings":"AAAA,SAEEA,2BAA2B,EAC3BC,iBAAiB,EACjBC,wBAAwB,EAExBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,iCAAiC,EACjCC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,sBAAsB,EACtBC,eAAe,EACfC,uBAAuB,EAIvBC,oBAAoB,QACf,sBAAsB;AAM7B,SAAQC,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,KAAK,QAAO,wBAAwB;AAC5C,SAAQC,kBAAkB,QAAO,4BAA4B;AAE7D,OAAO,SAASC,4BAA4BC,MAU3C;IACC,MAAMC,mBAAmBC,uBAAuBF;IAChD,IAAIC,qBAAqBE,WAAW,OAAOA;IAE3C,MAAMC,eAAelB,yBAAyBe,iBAAiBI,MAAM;IACrE,MAAMC,aAAaF,aAAaG,MAAM,CAAC,CAACC,OAAShB,uBAAuBgB,UAAUL;IAClF,MAAMM,eAAeL,aAAaG,MAAM,CAAC,CAACC,OAAShB,uBAAuBgB,UAAUL;IAEpF,IAAIM,aAAaC,MAAM,GAAG,GAAG;QAC3BV,OAAOW,MAAM,CAACC,IAAI,CAACC,sBAAsB;YAAC,GAAGb,MAAM;YAAEI;QAAY;QACjE,OAAOD;IACT;IAEA,MAAMW,qBAAqBpB,wBAAwBO;IACnD,IAAI,CAACa,mBAAmBC,EAAE,EAAE;QAC1Bf,OAAOW,MAAM,CAACC,IAAI,IACbE,mBAAmBE,UAAU,CAACC,GAAG,CAAC,CAACC,YACpCC,oCAAoC;gBAClC,GAAGnB,MAAM;gBACTI;gBACAgB,aAAaF,UAAUE,WAAW;YACpC;QAGJ,OAAOjB;IACT;IAEA,MAAMkB,YAAYf,WAAWC,MAAM,CAAC,CAACC,OAASA,SAAS;IACvD,IAAIa,UAAUX,MAAM,GAAG,GAAG;QACxBV,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J,IAAsB,EAAEG,UAA4B;IAC3E,OAAO5C,kBAAkBgF,OAAO,CAACvC,SAASzC,kBAAkBgF,OAAO,CAACpC;AACtE;AAEA,SAAS4B,WAAWsB,MAAyB;IAC3C,OAAOA,OAAO7D,GAAG,CAAC,CAAC8D,QAAU,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,EAAEjB,IAAI,CAAC;AAClD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkflowModelValidationIssue, WorkflowModelValidationIssueCode, WorkflowModelValidationIssuePathSegment } from './invalid-workflow-model-error.js';
|
|
2
|
+
export declare function issue(params: {
|
|
3
|
+
code: WorkflowModelValidationIssueCode;
|
|
4
|
+
message: string;
|
|
5
|
+
path: readonly WorkflowModelValidationIssuePathSegment[];
|
|
6
|
+
details?: Readonly<Record<string, unknown>>;
|
|
7
|
+
}): WorkflowModelValidationIssue;
|
|
8
|
+
//# sourceMappingURL=validation-issue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-issue.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/validation-issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACxC,MAAM,mCAAmC,CAAC;AAE3C,wBAAgB,KAAK,CAAC,MAAM,EAAE;IAC5B,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,uCAAuC,EAAE,CAAC;IACzD,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC7C,GAAG,4BAA4B,CAe/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function issue(params) {
|
|
2
|
+
if (params.details === undefined) {
|
|
3
|
+
return {
|
|
4
|
+
code: params.code,
|
|
5
|
+
message: params.message,
|
|
6
|
+
path: params.path
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
code: params.code,
|
|
11
|
+
message: params.message,
|
|
12
|
+
path: params.path,
|
|
13
|
+
details: params.details
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=validation-issue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/validation-issue.ts"],"sourcesContent":["import type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\n\nexport function issue(params: {\n code: WorkflowModelValidationIssueCode;\n message: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n details?: Readonly<Record<string, unknown>>;\n}): WorkflowModelValidationIssue {\n if (params.details === undefined) {\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n };\n }\n\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n details: params.details,\n };\n}\n"],"names":["issue","params","details","undefined","code","message","path"],"mappings":"AAMA,OAAO,SAASA,MAAMC,MAKrB;IACC,IAAIA,OAAOC,OAAO,KAAKC,WAAW;QAChC,OAAO;YACLC,MAAMH,OAAOG,IAAI;YACjBC,SAASJ,OAAOI,OAAO;YACvBC,MAAML,OAAOK,IAAI;QACnB;IACF;IAEA,OAAO;QACLF,MAAMH,OAAOG,IAAI;QACjBC,SAASJ,OAAOI,OAAO;QACvBC,MAAML,OAAOK,IAAI;QACjBJ,SAASD,OAAOC,OAAO;IACzB;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-field-label.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/workflow-field-label.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,0BAA0B,EAAE,sBAAsB,EAAC,MAAM,qBAAqB,CAAC;AAE5F,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,0BAA0B,GAAG,sBAAsB,GACzD,MAAM,CAyCR"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function workflowFieldLabel(field) {
|
|
2
|
+
switch(field){
|
|
3
|
+
case 'run':
|
|
4
|
+
return 'Run command interpolation';
|
|
5
|
+
case 'env.value':
|
|
6
|
+
return 'Env value interpolation';
|
|
7
|
+
case 'agent.prompt':
|
|
8
|
+
return 'Agent prompt interpolation';
|
|
9
|
+
case 'agent.model':
|
|
10
|
+
return 'Agent model interpolation';
|
|
11
|
+
case 'agent.provider':
|
|
12
|
+
return 'Agent provider interpolation';
|
|
13
|
+
case 'agent.thinking':
|
|
14
|
+
return 'Agent thinking';
|
|
15
|
+
case 'job.runner':
|
|
16
|
+
return 'Job runner interpolation';
|
|
17
|
+
case 'job.outputs':
|
|
18
|
+
return 'Job outputs mapping';
|
|
19
|
+
case 'job.name':
|
|
20
|
+
return 'Job name interpolation';
|
|
21
|
+
case 'step.name':
|
|
22
|
+
return 'Step name interpolation';
|
|
23
|
+
case 'step.success':
|
|
24
|
+
return 'Step gate success';
|
|
25
|
+
case 'step.feedback':
|
|
26
|
+
return 'Step feedback';
|
|
27
|
+
case 'job.success':
|
|
28
|
+
return 'Job success';
|
|
29
|
+
case 'trigger.filter':
|
|
30
|
+
return 'Trigger filter';
|
|
31
|
+
case 'listener.on':
|
|
32
|
+
return 'Listener on filter';
|
|
33
|
+
case 'listener.until':
|
|
34
|
+
return 'Listener until filter';
|
|
35
|
+
case 'job.if':
|
|
36
|
+
return 'Job if';
|
|
37
|
+
case 'step.if':
|
|
38
|
+
return 'Step if';
|
|
39
|
+
default:
|
|
40
|
+
return assertNever(field);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function assertNever(value) {
|
|
44
|
+
throw new Error(`Unhandled workflow field: ${value}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=workflow-field-label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/workflow-field-label.ts"],"sourcesContent":["import type {WorkflowInterpolationField, WorkflowPredicateField} from '@shipfox/expression';\n\nexport function workflowFieldLabel(\n field: WorkflowInterpolationField | WorkflowPredicateField,\n): string {\n switch (field) {\n case 'run':\n return 'Run command interpolation';\n case 'env.value':\n return 'Env value interpolation';\n case 'agent.prompt':\n return 'Agent prompt interpolation';\n case 'agent.model':\n return 'Agent model interpolation';\n case 'agent.provider':\n return 'Agent provider interpolation';\n case 'agent.thinking':\n return 'Agent thinking';\n case 'job.runner':\n return 'Job runner interpolation';\n case 'job.outputs':\n return 'Job outputs mapping';\n case 'job.name':\n return 'Job name interpolation';\n case 'step.name':\n return 'Step name interpolation';\n case 'step.success':\n return 'Step gate success';\n case 'step.feedback':\n return 'Step feedback';\n case 'job.success':\n return 'Job success';\n case 'trigger.filter':\n return 'Trigger filter';\n case 'listener.on':\n return 'Listener on filter';\n case 'listener.until':\n return 'Listener until filter';\n case 'job.if':\n return 'Job if';\n case 'step.if':\n return 'Step if';\n default:\n return assertNever(field);\n }\n}\n\nfunction assertNever(value: never): never {\n throw new Error(`Unhandled workflow field: ${value}`);\n}\n"],"names":["workflowFieldLabel","field","assertNever","value","Error"],"mappings":"AAEA,OAAO,SAASA,mBACdC,KAA0D;IAE1D,OAAQA;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAOC,YAAYD;IACvB;AACF;AAEA,SAASC,YAAYC,KAAY;IAC/B,MAAM,IAAIC,MAAM,CAAC,0BAA0B,EAAED,OAAO;AACtD"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { InvalidWorkflowYamlError, type InvalidWorkflowYamlReason, invalidWorkflowYamlErrorCode, type WorkflowYamlLocation, } from './invalid-workflow-yaml-error.js';
|
|
2
|
+
export { type ParsedWorkflowYaml, parseWorkflowYaml, parseWorkflowYamlWithLocations, } from './parse-workflow-yaml.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-yaml/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,4BAA4B,EAC5B,KAAK,oBAAoB,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-yaml/index.ts"],"sourcesContent":["export {\n InvalidWorkflowYamlError,\n type InvalidWorkflowYamlReason,\n invalidWorkflowYamlErrorCode,\n type WorkflowYamlLocation,\n} from './invalid-workflow-yaml-error.js';\nexport {\n type ParsedWorkflowYaml,\n parseWorkflowYaml,\n parseWorkflowYamlWithLocations,\n} from './parse-workflow-yaml.js';\n"],"names":["InvalidWorkflowYamlError","invalidWorkflowYamlErrorCode","parseWorkflowYaml","parseWorkflowYamlWithLocations"],"mappings":"AAAA,SACEA,wBAAwB,EAExBC,4BAA4B,QAEvB,mCAAmC;AAC1C,SAEEC,iBAAiB,EACjBC,8BAA8B,QACzB,2BAA2B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const invalidWorkflowYamlErrorCode = "invalid-workflow-yaml";
|
|
2
|
+
export type InvalidWorkflowYamlReason = 'syntax' | 'non-object-root';
|
|
3
|
+
export interface WorkflowYamlLocation {
|
|
4
|
+
readonly line: number;
|
|
5
|
+
readonly column: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class InvalidWorkflowYamlError extends Error {
|
|
8
|
+
readonly reason: InvalidWorkflowYamlReason;
|
|
9
|
+
readonly code = "invalid-workflow-yaml";
|
|
10
|
+
readonly location: WorkflowYamlLocation | undefined;
|
|
11
|
+
constructor(reason: InvalidWorkflowYamlReason, message: string, options?: {
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
location?: WorkflowYamlLocation | undefined;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=invalid-workflow-yaml-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-workflow-yaml-error.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-yaml/invalid-workflow-yaml-error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,0BAA0B,CAAC;AAEpE,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAErE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAK/C,QAAQ,CAAC,MAAM,EAAE,yBAAyB;IAJ5C,QAAQ,CAAC,IAAI,2BAAgC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,GAAG,SAAS,CAAC;gBAGzC,MAAM,EAAE,yBAAyB,EAC1C,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAA;KAAM;CAM/E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const invalidWorkflowYamlErrorCode = 'invalid-workflow-yaml';
|
|
2
|
+
export class InvalidWorkflowYamlError extends Error {
|
|
3
|
+
constructor(reason, message, options = {}){
|
|
4
|
+
super(message, {
|
|
5
|
+
cause: options.cause
|
|
6
|
+
}), this.reason = reason, this.code = invalidWorkflowYamlErrorCode;
|
|
7
|
+
this.name = 'InvalidWorkflowYamlError';
|
|
8
|
+
this.location = options.location;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=invalid-workflow-yaml-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-yaml/invalid-workflow-yaml-error.ts"],"sourcesContent":["export const invalidWorkflowYamlErrorCode = 'invalid-workflow-yaml';\n\nexport type InvalidWorkflowYamlReason = 'syntax' | 'non-object-root';\n\nexport interface WorkflowYamlLocation {\n readonly line: number;\n readonly column: number;\n}\n\nexport class InvalidWorkflowYamlError extends Error {\n readonly code = invalidWorkflowYamlErrorCode;\n readonly location: WorkflowYamlLocation | undefined;\n\n constructor(\n readonly reason: InvalidWorkflowYamlReason,\n message: string,\n options: {cause?: unknown; location?: WorkflowYamlLocation | undefined} = {},\n ) {\n super(message, {cause: options.cause});\n this.name = 'InvalidWorkflowYamlError';\n this.location = options.location;\n }\n}\n"],"names":["invalidWorkflowYamlErrorCode","InvalidWorkflowYamlError","Error","reason","message","options","cause","code","name","location"],"mappings":"AAAA,OAAO,MAAMA,+BAA+B,wBAAwB;AASpE,OAAO,MAAMC,iCAAiCC;IAI5C,YACE,AAASC,MAAiC,EAC1CC,OAAe,EACfC,UAA0E,CAAC,CAAC,CAC5E;QACA,KAAK,CAACD,SAAS;YAACE,OAAOD,QAAQC,KAAK;QAAA,SAJ3BH,SAAAA,aAJFI,OAAOP;QASd,IAAI,CAACQ,IAAI,GAAG;QACZ,IAAI,CAACC,QAAQ,GAAGJ,QAAQI,QAAQ;IAClC;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type WorkflowDocument } from '@shipfox/workflow-document';
|
|
2
|
+
import type { WorkflowStepSourceLocationMap } from '../entities/workflow-model.js';
|
|
3
|
+
export interface ParsedWorkflowYaml {
|
|
4
|
+
document: WorkflowDocument;
|
|
5
|
+
stepSourceLocations: WorkflowStepSourceLocationMap;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseWorkflowYaml(source: string): WorkflowDocument;
|
|
8
|
+
export declare function parseWorkflowYamlWithLocations(source: string): ParsedWorkflowYaml;
|
|
9
|
+
//# sourceMappingURL=parse-workflow-yaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-workflow-yaml.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-yaml/parse-workflow-yaml.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAExF,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAOjF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,mBAAmB,EAAE,6BAA6B,CAAC;CACpD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAElE;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAOjF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { parseWorkflowDocument } from '@shipfox/workflow-document';
|
|
2
|
+
import yaml from 'js-yaml';
|
|
3
|
+
import { InvalidWorkflowYamlError } from './invalid-workflow-yaml-error.js';
|
|
4
|
+
import { extractWorkflowStepSourceLocations } from './source-locations.js';
|
|
5
|
+
export function parseWorkflowYaml(source) {
|
|
6
|
+
return parseWorkflowDocument(loadWorkflowYaml(source));
|
|
7
|
+
}
|
|
8
|
+
export function parseWorkflowYamlWithLocations(source) {
|
|
9
|
+
const parsed = loadWorkflowYaml(source);
|
|
10
|
+
return {
|
|
11
|
+
document: parseWorkflowDocument(parsed),
|
|
12
|
+
stepSourceLocations: extractWorkflowStepSourceLocations(source)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function loadWorkflowYaml(source) {
|
|
16
|
+
let parsed;
|
|
17
|
+
try {
|
|
18
|
+
parsed = yaml.load(source);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new InvalidWorkflowYamlError('syntax', `Invalid workflow YAML syntax: ${yamlErrorMessage(error)}`, {
|
|
21
|
+
cause: error,
|
|
22
|
+
location: yamlErrorLocation(error)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (!isRecord(parsed)) {
|
|
26
|
+
throw new InvalidWorkflowYamlError('non-object-root', 'Workflow YAML must parse to an object.');
|
|
27
|
+
}
|
|
28
|
+
return parsed;
|
|
29
|
+
}
|
|
30
|
+
function isRecord(value) {
|
|
31
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
32
|
+
}
|
|
33
|
+
function yamlErrorMessage(error) {
|
|
34
|
+
if (error !== null && typeof error === 'object' && typeof error.reason === 'string') {
|
|
35
|
+
return error.reason;
|
|
36
|
+
}
|
|
37
|
+
return error instanceof Error ? error.message : String(error);
|
|
38
|
+
}
|
|
39
|
+
function yamlErrorLocation(error) {
|
|
40
|
+
if (error === null || typeof error !== 'object') return undefined;
|
|
41
|
+
const mark = error.mark;
|
|
42
|
+
if (mark === null || typeof mark !== 'object') return undefined;
|
|
43
|
+
const line = mark.line;
|
|
44
|
+
const column = mark.column;
|
|
45
|
+
if (typeof line !== 'number' || typeof column !== 'number') return undefined;
|
|
46
|
+
return {
|
|
47
|
+
line: line + 1,
|
|
48
|
+
column: column + 1
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=parse-workflow-yaml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-yaml/parse-workflow-yaml.ts"],"sourcesContent":["import {parseWorkflowDocument, type WorkflowDocument} from '@shipfox/workflow-document';\nimport yaml from 'js-yaml';\nimport type {WorkflowStepSourceLocationMap} from '../entities/workflow-model.js';\nimport {\n InvalidWorkflowYamlError,\n type WorkflowYamlLocation,\n} from './invalid-workflow-yaml-error.js';\nimport {extractWorkflowStepSourceLocations} from './source-locations.js';\n\nexport interface ParsedWorkflowYaml {\n document: WorkflowDocument;\n stepSourceLocations: WorkflowStepSourceLocationMap;\n}\n\nexport function parseWorkflowYaml(source: string): WorkflowDocument {\n return parseWorkflowDocument(loadWorkflowYaml(source));\n}\n\nexport function parseWorkflowYamlWithLocations(source: string): ParsedWorkflowYaml {\n const parsed = loadWorkflowYaml(source);\n\n return {\n document: parseWorkflowDocument(parsed),\n stepSourceLocations: extractWorkflowStepSourceLocations(source),\n };\n}\n\nfunction loadWorkflowYaml(source: string): Record<string, unknown> {\n let parsed: unknown;\n try {\n parsed = yaml.load(source);\n } catch (error) {\n throw new InvalidWorkflowYamlError(\n 'syntax',\n `Invalid workflow YAML syntax: ${yamlErrorMessage(error)}`,\n {cause: error, location: yamlErrorLocation(error)},\n );\n }\n\n if (!isRecord(parsed)) {\n throw new InvalidWorkflowYamlError('non-object-root', 'Workflow YAML must parse to an object.');\n }\n\n return parsed;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction yamlErrorMessage(error: unknown): string {\n if (\n error !== null &&\n typeof error === 'object' &&\n typeof (error as {reason?: unknown}).reason === 'string'\n ) {\n return (error as {reason: string}).reason;\n }\n\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction yamlErrorLocation(error: unknown): WorkflowYamlLocation | undefined {\n if (error === null || typeof error !== 'object') return undefined;\n\n const mark = (error as {mark?: unknown}).mark;\n if (mark === null || typeof mark !== 'object') return undefined;\n\n const line = (mark as {line?: unknown}).line;\n const column = (mark as {column?: unknown}).column;\n if (typeof line !== 'number' || typeof column !== 'number') return undefined;\n\n return {line: line + 1, column: column + 1};\n}\n"],"names":["parseWorkflowDocument","yaml","InvalidWorkflowYamlError","extractWorkflowStepSourceLocations","parseWorkflowYaml","source","loadWorkflowYaml","parseWorkflowYamlWithLocations","parsed","document","stepSourceLocations","load","error","yamlErrorMessage","cause","location","yamlErrorLocation","isRecord","value","Array","isArray","reason","Error","message","String","undefined","mark","line","column"],"mappings":"AAAA,SAAQA,qBAAqB,QAA8B,6BAA6B;AACxF,OAAOC,UAAU,UAAU;AAE3B,SACEC,wBAAwB,QAEnB,mCAAmC;AAC1C,SAAQC,kCAAkC,QAAO,wBAAwB;AAOzE,OAAO,SAASC,kBAAkBC,MAAc;IAC9C,OAAOL,sBAAsBM,iBAAiBD;AAChD;AAEA,OAAO,SAASE,+BAA+BF,MAAc;IAC3D,MAAMG,SAASF,iBAAiBD;IAEhC,OAAO;QACLI,UAAUT,sBAAsBQ;QAChCE,qBAAqBP,mCAAmCE;IAC1D;AACF;AAEA,SAASC,iBAAiBD,MAAc;IACtC,IAAIG;IACJ,IAAI;QACFA,SAASP,KAAKU,IAAI,CAACN;IACrB,EAAE,OAAOO,OAAO;QACd,MAAM,IAAIV,yBACR,UACA,CAAC,8BAA8B,EAAEW,iBAAiBD,QAAQ,EAC1D;YAACE,OAAOF;YAAOG,UAAUC,kBAAkBJ;QAAM;IAErD;IAEA,IAAI,CAACK,SAAST,SAAS;QACrB,MAAM,IAAIN,yBAAyB,mBAAmB;IACxD;IAEA,OAAOM;AACT;AAEA,SAASS,SAASC,KAAc;IAC9B,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,CAACC,MAAMC,OAAO,CAACF;AACvE;AAEA,SAASL,iBAAiBD,KAAc;IACtC,IACEA,UAAU,QACV,OAAOA,UAAU,YACjB,OAAO,AAACA,MAA6BS,MAAM,KAAK,UAChD;QACA,OAAO,AAACT,MAA2BS,MAAM;IAC3C;IAEA,OAAOT,iBAAiBU,QAAQV,MAAMW,OAAO,GAAGC,OAAOZ;AACzD;AAEA,SAASI,kBAAkBJ,KAAc;IACvC,IAAIA,UAAU,QAAQ,OAAOA,UAAU,UAAU,OAAOa;IAExD,MAAMC,OAAO,AAACd,MAA2Bc,IAAI;IAC7C,IAAIA,SAAS,QAAQ,OAAOA,SAAS,UAAU,OAAOD;IAEtD,MAAME,OAAO,AAACD,KAA0BC,IAAI;IAC5C,MAAMC,SAAS,AAACF,KAA4BE,MAAM;IAClD,IAAI,OAAOD,SAAS,YAAY,OAAOC,WAAW,UAAU,OAAOH;IAEnE,OAAO;QAACE,MAAMA,OAAO;QAAGC,QAAQA,SAAS;IAAC;AAC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-locations.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-yaml/source-locations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,MAAM,GAAG,6BAA6B,CA2BhG"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isMap, isNode, isScalar, isSeq, LineCounter, parseDocument } from 'yaml';
|
|
2
|
+
export function extractWorkflowStepSourceLocations(source) {
|
|
3
|
+
const lineCounter = new LineCounter();
|
|
4
|
+
const document = parseDocument(source, {
|
|
5
|
+
lineCounter
|
|
6
|
+
});
|
|
7
|
+
if (document.errors.length > 0 || !isMap(document.contents)) return new Map();
|
|
8
|
+
const jobs = getMapValue(document.contents, 'jobs');
|
|
9
|
+
if (!isMap(jobs)) return new Map();
|
|
10
|
+
const locations = new Map();
|
|
11
|
+
for (const jobPair of jobs.items){
|
|
12
|
+
const jobName = scalarString(jobPair.key);
|
|
13
|
+
if (jobName === undefined || !isMap(jobPair.value)) continue;
|
|
14
|
+
const steps = getMapValue(jobPair.value, 'steps');
|
|
15
|
+
if (!isSeq(steps)) continue;
|
|
16
|
+
const stepLocations = new Map();
|
|
17
|
+
for (const [index, step] of steps.items.entries()){
|
|
18
|
+
const location = sourceLocationFor(step, lineCounter);
|
|
19
|
+
if (location) stepLocations.set(index, location);
|
|
20
|
+
}
|
|
21
|
+
if (stepLocations.size > 0) locations.set(jobName, stepLocations);
|
|
22
|
+
}
|
|
23
|
+
return locations;
|
|
24
|
+
}
|
|
25
|
+
function getMapValue(map, key) {
|
|
26
|
+
for (const item of map.items){
|
|
27
|
+
if (scalarString(item.key) === key) return item.value;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
function scalarString(node) {
|
|
32
|
+
return isScalar(node) && typeof node.value === 'string' ? node.value : undefined;
|
|
33
|
+
}
|
|
34
|
+
function sourceLocationFor(node, lineCounter) {
|
|
35
|
+
if (!isNode(node)) return undefined;
|
|
36
|
+
const range = node?.range;
|
|
37
|
+
if (!range) return undefined;
|
|
38
|
+
const start = lineCounter.linePos(range[0]);
|
|
39
|
+
const end = lineCounter.linePos(range[1]);
|
|
40
|
+
if (!start || !end) return undefined;
|
|
41
|
+
const endLine = end.col === 1 && end.line > start.line ? end.line - 1 : end.line;
|
|
42
|
+
return {
|
|
43
|
+
startLine: start.line,
|
|
44
|
+
endLine: Math.max(start.line, endLine)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=source-locations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-yaml/source-locations.ts"],"sourcesContent":["import {isMap, isNode, isScalar, isSeq, LineCounter, parseDocument, type YAMLMap} from 'yaml';\nimport type {\n WorkflowSourceLocation,\n WorkflowStepSourceLocationMap,\n} from '../entities/workflow-model.js';\n\nexport function extractWorkflowStepSourceLocations(source: string): WorkflowStepSourceLocationMap {\n const lineCounter = new LineCounter();\n const document = parseDocument(source, {lineCounter});\n if (document.errors.length > 0 || !isMap(document.contents)) return new Map();\n\n const jobs = getMapValue(document.contents, 'jobs');\n if (!isMap(jobs)) return new Map();\n\n const locations = new Map<string, Map<number, WorkflowSourceLocation>>();\n\n for (const jobPair of jobs.items) {\n const jobName = scalarString(jobPair.key);\n if (jobName === undefined || !isMap(jobPair.value)) continue;\n\n const steps = getMapValue(jobPair.value, 'steps');\n if (!isSeq(steps)) continue;\n\n const stepLocations = new Map<number, WorkflowSourceLocation>();\n for (const [index, step] of steps.items.entries()) {\n const location = sourceLocationFor(step, lineCounter);\n if (location) stepLocations.set(index, location);\n }\n\n if (stepLocations.size > 0) locations.set(jobName, stepLocations);\n }\n\n return locations;\n}\n\nfunction getMapValue(map: YAMLMap, key: string): unknown {\n for (const item of map.items) {\n if (scalarString(item.key) === key) return item.value;\n }\n\n return undefined;\n}\n\nfunction scalarString(node: unknown): string | undefined {\n return isScalar(node) && typeof node.value === 'string' ? node.value : undefined;\n}\n\nfunction sourceLocationFor(\n node: unknown,\n lineCounter: LineCounter,\n): WorkflowSourceLocation | undefined {\n if (!isNode(node)) return undefined;\n const range = node?.range;\n if (!range) return undefined;\n\n const start = lineCounter.linePos(range[0]);\n const end = lineCounter.linePos(range[1]);\n if (!start || !end) return undefined;\n\n const endLine = end.col === 1 && end.line > start.line ? end.line - 1 : end.line;\n return {startLine: start.line, endLine: Math.max(start.line, endLine)};\n}\n"],"names":["isMap","isNode","isScalar","isSeq","LineCounter","parseDocument","extractWorkflowStepSourceLocations","source","lineCounter","document","errors","length","contents","Map","jobs","getMapValue","locations","jobPair","items","jobName","scalarString","key","undefined","value","steps","stepLocations","index","step","entries","location","sourceLocationFor","set","size","map","item","node","range","start","linePos","end","endLine","col","line","startLine","Math","max"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,WAAW,EAAEC,aAAa,QAAqB,OAAO;AAM9F,OAAO,SAASC,mCAAmCC,MAAc;IAC/D,MAAMC,cAAc,IAAIJ;IACxB,MAAMK,WAAWJ,cAAcE,QAAQ;QAACC;IAAW;IACnD,IAAIC,SAASC,MAAM,CAACC,MAAM,GAAG,KAAK,CAACX,MAAMS,SAASG,QAAQ,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