@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,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,0BAA0B,CAAC;AAEtE,qBAAa,oBAAqB,SAAQ,KAAK;IAGpC,OAAO,CAAC,EAAE,OAAO;gBADxB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED,qBAAa,4BAA6B,SAAQ,KAAK;aAEnC,IAAI,EAAE,uBAAuB;gBAA7B,IAAI,EAAE,uBAAuB,EAC7C,OAAO,EAAE,MAAM;CAKlB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class DefinitionParseError extends Error {
|
|
2
|
+
constructor(message, details){
|
|
3
|
+
super(message), this.details = details;
|
|
4
|
+
this.name = 'DefinitionParseError';
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export class DefinitionSyncPermanentError extends Error {
|
|
8
|
+
constructor(code, message){
|
|
9
|
+
super(message), this.code = code;
|
|
10
|
+
this.name = 'DefinitionSyncPermanentError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/errors.ts"],"sourcesContent":["import type {DefinitionSyncErrorCode} from './entities/sync-state.js';\n\nexport class DefinitionParseError extends Error {\n constructor(\n message: string,\n public details?: unknown,\n ) {\n super(message);\n this.name = 'DefinitionParseError';\n }\n}\n\nexport class DefinitionSyncPermanentError extends Error {\n constructor(\n public readonly code: DefinitionSyncErrorCode,\n message: string,\n ) {\n super(message);\n this.name = 'DefinitionSyncPermanentError';\n }\n}\n"],"names":["DefinitionParseError","Error","message","details","name","DefinitionSyncPermanentError","code"],"mappings":"AAEA,OAAO,MAAMA,6BAA6BC;IACxC,YACEC,OAAe,EACf,AAAOC,OAAiB,CACxB;QACA,KAAK,CAACD,eAFCC,UAAAA;QAGP,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,qCAAqCJ;IAChD,YACE,AAAgBK,IAA6B,EAC7CJ,OAAe,CACf;QACA,KAAK,CAACA,eAHUI,OAAAA;QAIhB,IAAI,CAACF,IAAI,GAAG;IACd;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-agent-step-integrations.d.ts","sourceRoot":"","sources":["../../src/core/has-agent-step-integrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAEjE,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAI5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/has-agent-step-integrations.ts"],"sourcesContent":["import type {WorkflowDocument} from '@shipfox/workflow-document';\n\nexport function hasAgentStepIntegrations(document: WorkflowDocument): boolean {\n return Object.values(document.jobs).some((job) =>\n job.steps.some((step) => step.integrations !== undefined),\n );\n}\n"],"names":["hasAgentStepIntegrations","document","Object","values","jobs","some","job","steps","step","integrations","undefined"],"mappings":"AAEA,OAAO,SAASA,yBAAyBC,QAA0B;IACjE,OAAOC,OAAOC,MAAM,CAACF,SAASG,IAAI,EAAEC,IAAI,CAAC,CAACC,MACxCA,IAAIC,KAAK,CAACF,IAAI,CAAC,CAACG,OAASA,KAAKC,YAAY,KAAKC;AAEnD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type * from './entities/index.js';
|
|
2
|
+
export { DefinitionParseError, DefinitionSyncPermanentError } from './errors.js';
|
|
3
|
+
export { parseDefinition } from './parse-definition.js';
|
|
4
|
+
export { classifySyncFailure, type DiscoverWorkflowFilesParams, discoverWorkflowFiles, type FetchAndParseWorkflowsParams, FILE_FETCH_CONCURRENCY, fetchAndParseWorkflows, MAX_WORKFLOW_FILES, type ParsedWorkflow, type ResolvedSyncSource, resolveSyncSource, type SyncFailureClassification, type SyncSourceContext, UNRESOLVED_SYNC_REF, WORKFLOW_PREFIX, } from './sync-definitions.js';
|
|
5
|
+
export { DEFAULT_RUN_TIMEOUT_MS } from './workflow-model/constants.js';
|
|
6
|
+
export { normalizeWorkflowDocument } from './workflow-model/index.js';
|
|
7
|
+
export { DEFAULT_JOB_CHECKOUT } from './workflow-model/normalize-job-checkout.js';
|
|
8
|
+
export { DEFAULT_JOB_SUCCESS } from './workflow-model/normalize-job-success.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,qBAAqB,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAAE,4BAA4B,EAAC,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,mBAAmB,EACnB,KAAK,2BAA2B,EAChC,qBAAqB,EACrB,KAAK,4BAA4B,EACjC,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,sBAAsB,EAAC,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAC,mBAAmB,EAAC,MAAM,2CAA2C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { DefinitionParseError, DefinitionSyncPermanentError } from './errors.js';
|
|
2
|
+
export { parseDefinition } from './parse-definition.js';
|
|
3
|
+
export { classifySyncFailure, discoverWorkflowFiles, FILE_FETCH_CONCURRENCY, fetchAndParseWorkflows, MAX_WORKFLOW_FILES, resolveSyncSource, UNRESOLVED_SYNC_REF, WORKFLOW_PREFIX } from './sync-definitions.js';
|
|
4
|
+
export { DEFAULT_RUN_TIMEOUT_MS } from './workflow-model/constants.js';
|
|
5
|
+
export { normalizeWorkflowDocument } from './workflow-model/index.js';
|
|
6
|
+
export { DEFAULT_JOB_CHECKOUT } from './workflow-model/normalize-job-checkout.js';
|
|
7
|
+
export { DEFAULT_JOB_SUCCESS } from './workflow-model/normalize-job-success.js';
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["export type * from './entities/index.js';\nexport {DefinitionParseError, DefinitionSyncPermanentError} from './errors.js';\nexport {parseDefinition} from './parse-definition.js';\nexport {\n classifySyncFailure,\n type DiscoverWorkflowFilesParams,\n discoverWorkflowFiles,\n type FetchAndParseWorkflowsParams,\n FILE_FETCH_CONCURRENCY,\n fetchAndParseWorkflows,\n MAX_WORKFLOW_FILES,\n type ParsedWorkflow,\n type ResolvedSyncSource,\n resolveSyncSource,\n type SyncFailureClassification,\n type SyncSourceContext,\n UNRESOLVED_SYNC_REF,\n WORKFLOW_PREFIX,\n} from './sync-definitions.js';\nexport {DEFAULT_RUN_TIMEOUT_MS} from './workflow-model/constants.js';\nexport {normalizeWorkflowDocument} from './workflow-model/index.js';\nexport {DEFAULT_JOB_CHECKOUT} from './workflow-model/normalize-job-checkout.js';\nexport {DEFAULT_JOB_SUCCESS} from './workflow-model/normalize-job-success.js';\n"],"names":["DefinitionParseError","DefinitionSyncPermanentError","parseDefinition","classifySyncFailure","discoverWorkflowFiles","FILE_FETCH_CONCURRENCY","fetchAndParseWorkflows","MAX_WORKFLOW_FILES","resolveSyncSource","UNRESOLVED_SYNC_REF","WORKFLOW_PREFIX","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS"],"mappings":"AACA,SAAQA,oBAAoB,EAAEC,4BAA4B,QAAO,cAAc;AAC/E,SAAQC,eAAe,QAAO,wBAAwB;AACtD,SACEC,mBAAmB,EAEnBC,qBAAqB,EAErBC,sBAAsB,EACtBC,sBAAsB,EACtBC,kBAAkB,EAGlBC,iBAAiB,EAGjBC,mBAAmB,EACnBC,eAAe,QACV,wBAAwB;AAC/B,SAAQC,sBAAsB,QAAO,gCAAgC;AACrE,SAAQC,yBAAyB,QAAO,4BAA4B;AACpE,SAAQC,oBAAoB,QAAO,6CAA6C;AAChF,SAAQC,mBAAmB,QAAO,4CAA4C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HarnessToolDeploymentConfig } from '@shipfox/api-agent-dto';
|
|
2
|
+
import type { IntegrationValidationContext } from './entities/integration-context.js';
|
|
3
|
+
import type { WorkflowDefinitionPayload } from './entities/workflow-definition.js';
|
|
4
|
+
export declare function parseDefinition(yamlString: string, options?: {
|
|
5
|
+
defaultRunnerLabels?: readonly string[];
|
|
6
|
+
harnessToolDeploymentConfig?: HarnessToolDeploymentConfig;
|
|
7
|
+
integrationValidationContext?: IntegrationValidationContext;
|
|
8
|
+
}): WorkflowDefinitionPayload;
|
|
9
|
+
//# sourceMappingURL=parse-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-definition.d.ts","sourceRoot":"","sources":["../../src/core/parse-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC;AAIjF,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IACR,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAC1D,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;CAC7D,GACA,yBAAyB,CAc3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DefinitionParseError } from './errors.js';
|
|
2
|
+
import { validateDefinition } from './validate-definition.js';
|
|
3
|
+
export function parseDefinition(yamlString, options) {
|
|
4
|
+
const result = validateDefinition(yamlString, options);
|
|
5
|
+
if (!result.valid) {
|
|
6
|
+
throw new DefinitionParseError(result.errors[0]?.message ?? 'Invalid definition', result.errors);
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
...result.definition,
|
|
10
|
+
sourceSnapshot: {
|
|
11
|
+
content: yamlString,
|
|
12
|
+
format: 'yaml'
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=parse-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/parse-definition.ts"],"sourcesContent":["import type {HarnessToolDeploymentConfig} from '@shipfox/api-agent-dto';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {DefinitionParseError} from './errors.js';\nimport {validateDefinition} from './validate-definition.js';\n\nexport function parseDefinition(\n yamlString: string,\n options?: {\n defaultRunnerLabels?: readonly string[];\n harnessToolDeploymentConfig?: HarnessToolDeploymentConfig;\n integrationValidationContext?: IntegrationValidationContext;\n },\n): WorkflowDefinitionPayload {\n const result = validateDefinition(yamlString, options);\n\n if (!result.valid) {\n throw new DefinitionParseError(\n result.errors[0]?.message ?? 'Invalid definition',\n result.errors,\n );\n }\n\n return {\n ...result.definition,\n sourceSnapshot: {content: yamlString, format: 'yaml'},\n };\n}\n"],"names":["DefinitionParseError","validateDefinition","parseDefinition","yamlString","options","result","valid","errors","message","definition","sourceSnapshot","content","format"],"mappings":"AAGA,SAAQA,oBAAoB,QAAO,cAAc;AACjD,SAAQC,kBAAkB,QAAO,2BAA2B;AAE5D,OAAO,SAASC,gBACdC,UAAkB,EAClBC,OAIC;IAED,MAAMC,SAASJ,mBAAmBE,YAAYC;IAE9C,IAAI,CAACC,OAAOC,KAAK,EAAE;QACjB,MAAM,IAAIN,qBACRK,OAAOE,MAAM,CAAC,EAAE,EAAEC,WAAW,sBAC7BH,OAAOE,MAAM;IAEjB;IAEA,OAAO;QACL,GAAGF,OAAOI,UAAU;QACpBC,gBAAgB;YAACC,SAASR;YAAYS,QAAQ;QAAM;IACtD;AACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type IntegrationSourceControlService } from '@shipfox/api-integration-core';
|
|
2
|
+
import type { IntegrationValidationContext } from './entities/integration-context.js';
|
|
3
|
+
import type { DefinitionSyncErrorCode } from './entities/sync-state.js';
|
|
4
|
+
import type { WorkflowDefinitionPayload } from './entities/workflow-definition.js';
|
|
5
|
+
export declare const WORKFLOW_PREFIX = ".shipfox/workflows/";
|
|
6
|
+
export declare const MAX_WORKFLOW_FILES = 100;
|
|
7
|
+
export declare const FILE_FETCH_CONCURRENCY = 4;
|
|
8
|
+
export declare const UNRESOLVED_SYNC_REF = "__unresolved__";
|
|
9
|
+
export interface SyncSourceContext {
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
sourceConnectionId: string;
|
|
12
|
+
sourceExternalRepositoryId: string;
|
|
13
|
+
sourceControl: IntegrationSourceControlService;
|
|
14
|
+
}
|
|
15
|
+
export interface ResolvedSyncSource {
|
|
16
|
+
ref: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function resolveSyncSource(params: SyncSourceContext): Promise<ResolvedSyncSource>;
|
|
19
|
+
export interface DiscoverWorkflowFilesParams extends SyncSourceContext {
|
|
20
|
+
ref: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function discoverWorkflowFiles(params: DiscoverWorkflowFilesParams): Promise<{
|
|
23
|
+
paths: string[];
|
|
24
|
+
}>;
|
|
25
|
+
export interface ParsedWorkflow {
|
|
26
|
+
path: string;
|
|
27
|
+
name: string;
|
|
28
|
+
definition: WorkflowDefinitionPayload;
|
|
29
|
+
contentHash: string;
|
|
30
|
+
}
|
|
31
|
+
export interface FetchAndParseWorkflowsParams extends SyncSourceContext {
|
|
32
|
+
ref: string;
|
|
33
|
+
paths: string[];
|
|
34
|
+
onProgress?: ((path: string) => void) | undefined;
|
|
35
|
+
loadIntegrationValidationContext?: (() => Promise<IntegrationValidationContext>) | undefined;
|
|
36
|
+
}
|
|
37
|
+
export declare function fetchAndParseWorkflows(params: FetchAndParseWorkflowsParams): Promise<ParsedWorkflow[]>;
|
|
38
|
+
export interface SyncFailureClassification {
|
|
39
|
+
code: DefinitionSyncErrorCode;
|
|
40
|
+
message: string;
|
|
41
|
+
retryable: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare function classifySyncFailure(error: unknown): SyncFailureClassification;
|
|
44
|
+
//# sourceMappingURL=sync-definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-definitions.d.ts","sourceRoot":"","sources":["../../src/core/sync-definitions.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,+BAA+B,EAErC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC;AAKjF,eAAO,MAAM,eAAe,wBAAwB,CAAC;AACrD,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,aAAa,EAAE,+BAA+B,CAAC;CAChD;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAO9F;AAED,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CA2B5B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,yBAAyB,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAClD,gCAAgC,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,4BAA4B,CAAC,CAAC,GAAG,SAAS,CAAC;CAC9F;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,cAAc,EAAE,CAAC,CA6C3B;AA2BD,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,yBAAyB,CAuB7E"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { IntegrationConnectionInactiveError, IntegrationConnectionNotFoundError, IntegrationConnectionWorkspaceMismatchError, IntegrationProviderError, MAX_REPOSITORY_FILE_BYTES } from '@shipfox/api-integration-core';
|
|
3
|
+
import { boundedMap } from '@shipfox/node-module';
|
|
4
|
+
import { DefinitionParseError, DefinitionSyncPermanentError } from './errors.js';
|
|
5
|
+
import { hasAgentStepIntegrations } from './has-agent-step-integrations.js';
|
|
6
|
+
import { parseDefinition } from './parse-definition.js';
|
|
7
|
+
export const WORKFLOW_PREFIX = '.shipfox/workflows/';
|
|
8
|
+
export const MAX_WORKFLOW_FILES = 100;
|
|
9
|
+
export const FILE_FETCH_CONCURRENCY = 4;
|
|
10
|
+
export const UNRESOLVED_SYNC_REF = '__unresolved__';
|
|
11
|
+
export async function resolveSyncSource(params) {
|
|
12
|
+
const source = await params.sourceControl.resolveRepository({
|
|
13
|
+
workspaceId: params.workspaceId,
|
|
14
|
+
connectionId: params.sourceConnectionId,
|
|
15
|
+
externalRepositoryId: params.sourceExternalRepositoryId
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
ref: source.repository.defaultBranch
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export async function discoverWorkflowFiles(params) {
|
|
22
|
+
const page = await params.sourceControl.listFiles({
|
|
23
|
+
workspaceId: params.workspaceId,
|
|
24
|
+
connectionId: params.sourceConnectionId,
|
|
25
|
+
externalRepositoryId: params.sourceExternalRepositoryId,
|
|
26
|
+
ref: params.ref,
|
|
27
|
+
prefix: WORKFLOW_PREFIX,
|
|
28
|
+
limit: MAX_WORKFLOW_FILES
|
|
29
|
+
});
|
|
30
|
+
if (page.nextCursor) {
|
|
31
|
+
throw new DefinitionSyncPermanentError('too-many-files', `More than ${MAX_WORKFLOW_FILES} workflow files were found`);
|
|
32
|
+
}
|
|
33
|
+
const paths = page.files.filter((file)=>file.path.endsWith('.yml') || file.path.endsWith('.yaml')).map((file)=>file.path);
|
|
34
|
+
if (paths.length === 0) {
|
|
35
|
+
throw new DefinitionSyncPermanentError('no-workflow-files', `No workflow files were found under ${WORKFLOW_PREFIX}`);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
paths
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export async function fetchAndParseWorkflows(params) {
|
|
42
|
+
const parsed = await boundedMap(params.paths, FILE_FETCH_CONCURRENCY, async (path)=>{
|
|
43
|
+
params.onProgress?.(path);
|
|
44
|
+
const snapshot = await params.sourceControl.fetchFile({
|
|
45
|
+
workspaceId: params.workspaceId,
|
|
46
|
+
connectionId: params.sourceConnectionId,
|
|
47
|
+
externalRepositoryId: params.sourceExternalRepositoryId,
|
|
48
|
+
ref: params.ref,
|
|
49
|
+
path
|
|
50
|
+
});
|
|
51
|
+
if (Buffer.byteLength(snapshot.content, 'utf8') > MAX_REPOSITORY_FILE_BYTES) {
|
|
52
|
+
throw new DefinitionSyncPermanentError('content-too-large', `Workflow file is larger than ${MAX_REPOSITORY_FILE_BYTES} bytes: ${snapshot.path}`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...parseWorkflowSnapshot({
|
|
56
|
+
path: snapshot.path,
|
|
57
|
+
content: snapshot.content
|
|
58
|
+
}),
|
|
59
|
+
rawContent: snapshot.content
|
|
60
|
+
};
|
|
61
|
+
}, {
|
|
62
|
+
stopOnError: true
|
|
63
|
+
});
|
|
64
|
+
if (!params.loadIntegrationValidationContext || !parsed.some((entry)=>hasAgentStepIntegrations(entry.definition.document))) {
|
|
65
|
+
return parsed.map(({ rawContent: _rawContent, ...entry })=>entry);
|
|
66
|
+
}
|
|
67
|
+
const integrationValidationContext = await params.loadIntegrationValidationContext();
|
|
68
|
+
return parsed.map((entry)=>parseWorkflowSnapshot({
|
|
69
|
+
path: entry.path,
|
|
70
|
+
content: entry.rawContent,
|
|
71
|
+
integrationValidationContext
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
function parseWorkflowSnapshot(params) {
|
|
75
|
+
try {
|
|
76
|
+
const definition = params.integrationValidationContext === undefined ? parseDefinition(params.content) : parseDefinition(params.content, {
|
|
77
|
+
integrationValidationContext: params.integrationValidationContext
|
|
78
|
+
});
|
|
79
|
+
const contentHash = sha256Hex(params.content);
|
|
80
|
+
return {
|
|
81
|
+
path: params.path,
|
|
82
|
+
name: definition.document.name,
|
|
83
|
+
definition,
|
|
84
|
+
contentHash
|
|
85
|
+
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error instanceof DefinitionParseError) {
|
|
88
|
+
throw new DefinitionSyncPermanentError('invalid-definition', `Invalid workflow definition at ${params.path}: ${error.message}`);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function classifySyncFailure(error) {
|
|
94
|
+
if (error instanceof DefinitionSyncPermanentError) {
|
|
95
|
+
return {
|
|
96
|
+
code: error.code,
|
|
97
|
+
message: error.message,
|
|
98
|
+
retryable: false
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (error instanceof IntegrationConnectionNotFoundError || error instanceof IntegrationConnectionInactiveError || error instanceof IntegrationConnectionWorkspaceMismatchError) {
|
|
102
|
+
return {
|
|
103
|
+
code: 'connection-unavailable',
|
|
104
|
+
message: error.message,
|
|
105
|
+
retryable: false
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (error instanceof IntegrationProviderError) {
|
|
109
|
+
return {
|
|
110
|
+
code: providerErrorCode(error.reason),
|
|
111
|
+
message: error.message,
|
|
112
|
+
retryable: isProviderReasonRetryable(error.reason)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
code: 'unknown',
|
|
117
|
+
message: error instanceof Error ? error.message : String(error),
|
|
118
|
+
retryable: true
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function isProviderReasonRetryable(reason) {
|
|
122
|
+
return reason === 'rate-limited' || reason === 'timeout' || reason === 'provider-unavailable';
|
|
123
|
+
}
|
|
124
|
+
function providerErrorCode(reason) {
|
|
125
|
+
if (reason === 'repository-not-found') return 'provider-repository-not-found';
|
|
126
|
+
if (reason === 'file-not-found') return 'provider-file-not-found';
|
|
127
|
+
if (reason === 'access-denied') return 'provider-access-denied';
|
|
128
|
+
if (reason === 'rate-limited') return 'provider-rate-limited';
|
|
129
|
+
if (reason === 'timeout') return 'provider-timeout';
|
|
130
|
+
if (reason === 'provider-unavailable') return 'provider-unavailable';
|
|
131
|
+
if (reason === 'malformed-provider-response') return 'provider-malformed-response';
|
|
132
|
+
if (reason === 'content-too-large') return 'content-too-large';
|
|
133
|
+
if (reason === 'too-many-files') return 'too-many-files';
|
|
134
|
+
return 'unknown';
|
|
135
|
+
}
|
|
136
|
+
function sha256Hex(content) {
|
|
137
|
+
return createHash('sha256').update(content, 'utf8').digest('hex');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=sync-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/sync-definitions.ts"],"sourcesContent":["import {createHash} from 'node:crypto';\nimport {\n IntegrationConnectionInactiveError,\n IntegrationConnectionNotFoundError,\n IntegrationConnectionWorkspaceMismatchError,\n IntegrationProviderError,\n type IntegrationSourceControlService,\n MAX_REPOSITORY_FILE_BYTES,\n} from '@shipfox/api-integration-core';\nimport {boundedMap} from '@shipfox/node-module';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {DefinitionSyncErrorCode} from './entities/sync-state.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {DefinitionParseError, DefinitionSyncPermanentError} from './errors.js';\nimport {hasAgentStepIntegrations} from './has-agent-step-integrations.js';\nimport {parseDefinition} from './parse-definition.js';\n\nexport const WORKFLOW_PREFIX = '.shipfox/workflows/';\nexport const MAX_WORKFLOW_FILES = 100;\nexport const FILE_FETCH_CONCURRENCY = 4;\nexport const UNRESOLVED_SYNC_REF = '__unresolved__';\n\nexport interface SyncSourceContext {\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceControl: IntegrationSourceControlService;\n}\n\nexport interface ResolvedSyncSource {\n ref: string;\n}\n\nexport async function resolveSyncSource(params: SyncSourceContext): Promise<ResolvedSyncSource> {\n const source = await params.sourceControl.resolveRepository({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n });\n return {ref: source.repository.defaultBranch};\n}\n\nexport interface DiscoverWorkflowFilesParams extends SyncSourceContext {\n ref: string;\n}\n\nexport async function discoverWorkflowFiles(\n params: DiscoverWorkflowFilesParams,\n): Promise<{paths: string[]}> {\n const page = await params.sourceControl.listFiles({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n prefix: WORKFLOW_PREFIX,\n limit: MAX_WORKFLOW_FILES,\n });\n if (page.nextCursor) {\n throw new DefinitionSyncPermanentError(\n 'too-many-files',\n `More than ${MAX_WORKFLOW_FILES} workflow files were found`,\n );\n }\n\n const paths = page.files\n .filter((file) => file.path.endsWith('.yml') || file.path.endsWith('.yaml'))\n .map((file) => file.path);\n if (paths.length === 0) {\n throw new DefinitionSyncPermanentError(\n 'no-workflow-files',\n `No workflow files were found under ${WORKFLOW_PREFIX}`,\n );\n }\n\n return {paths};\n}\n\nexport interface ParsedWorkflow {\n path: string;\n name: string;\n definition: WorkflowDefinitionPayload;\n contentHash: string;\n}\n\nexport interface FetchAndParseWorkflowsParams extends SyncSourceContext {\n ref: string;\n paths: string[];\n onProgress?: ((path: string) => void) | undefined;\n loadIntegrationValidationContext?: (() => Promise<IntegrationValidationContext>) | undefined;\n}\n\nexport async function fetchAndParseWorkflows(\n params: FetchAndParseWorkflowsParams,\n): Promise<ParsedWorkflow[]> {\n const parsed = await boundedMap(\n params.paths,\n FILE_FETCH_CONCURRENCY,\n async (path) => {\n params.onProgress?.(path);\n\n const snapshot = await params.sourceControl.fetchFile({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n path,\n });\n\n if (Buffer.byteLength(snapshot.content, 'utf8') > MAX_REPOSITORY_FILE_BYTES) {\n throw new DefinitionSyncPermanentError(\n 'content-too-large',\n `Workflow file is larger than ${MAX_REPOSITORY_FILE_BYTES} bytes: ${snapshot.path}`,\n );\n }\n\n return {\n ...parseWorkflowSnapshot({path: snapshot.path, content: snapshot.content}),\n rawContent: snapshot.content,\n };\n },\n {stopOnError: true},\n );\n\n if (\n !params.loadIntegrationValidationContext ||\n !parsed.some((entry) => hasAgentStepIntegrations(entry.definition.document))\n ) {\n return parsed.map(({rawContent: _rawContent, ...entry}) => entry);\n }\n\n const integrationValidationContext = await params.loadIntegrationValidationContext();\n return parsed.map((entry) =>\n parseWorkflowSnapshot({\n path: entry.path,\n content: entry.rawContent,\n integrationValidationContext,\n }),\n );\n}\n\nfunction parseWorkflowSnapshot(params: {\n path: string;\n content: string;\n integrationValidationContext?: IntegrationValidationContext | undefined;\n}): ParsedWorkflow {\n try {\n const definition =\n params.integrationValidationContext === undefined\n ? parseDefinition(params.content)\n : parseDefinition(params.content, {\n integrationValidationContext: params.integrationValidationContext,\n });\n const contentHash = sha256Hex(params.content);\n return {path: params.path, name: definition.document.name, definition, contentHash};\n } catch (error) {\n if (error instanceof DefinitionParseError) {\n throw new DefinitionSyncPermanentError(\n 'invalid-definition',\n `Invalid workflow definition at ${params.path}: ${error.message}`,\n );\n }\n throw error;\n }\n}\n\nexport interface SyncFailureClassification {\n code: DefinitionSyncErrorCode;\n message: string;\n retryable: boolean;\n}\n\nexport function classifySyncFailure(error: unknown): SyncFailureClassification {\n if (error instanceof DefinitionSyncPermanentError) {\n return {code: error.code, message: error.message, retryable: false};\n }\n if (\n error instanceof IntegrationConnectionNotFoundError ||\n error instanceof IntegrationConnectionInactiveError ||\n error instanceof IntegrationConnectionWorkspaceMismatchError\n ) {\n return {code: 'connection-unavailable', message: error.message, retryable: false};\n }\n if (error instanceof IntegrationProviderError) {\n return {\n code: providerErrorCode(error.reason),\n message: error.message,\n retryable: isProviderReasonRetryable(error.reason),\n };\n }\n return {\n code: 'unknown',\n message: error instanceof Error ? error.message : String(error),\n retryable: true,\n };\n}\n\nfunction isProviderReasonRetryable(reason: string): boolean {\n return reason === 'rate-limited' || reason === 'timeout' || reason === 'provider-unavailable';\n}\n\nfunction providerErrorCode(reason: string): DefinitionSyncErrorCode {\n if (reason === 'repository-not-found') return 'provider-repository-not-found';\n if (reason === 'file-not-found') return 'provider-file-not-found';\n if (reason === 'access-denied') return 'provider-access-denied';\n if (reason === 'rate-limited') return 'provider-rate-limited';\n if (reason === 'timeout') return 'provider-timeout';\n if (reason === 'provider-unavailable') return 'provider-unavailable';\n if (reason === 'malformed-provider-response') return 'provider-malformed-response';\n if (reason === 'content-too-large') return 'content-too-large';\n if (reason === 'too-many-files') return 'too-many-files';\n return 'unknown';\n}\n\nfunction sha256Hex(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n}\n"],"names":["createHash","IntegrationConnectionInactiveError","IntegrationConnectionNotFoundError","IntegrationConnectionWorkspaceMismatchError","IntegrationProviderError","MAX_REPOSITORY_FILE_BYTES","boundedMap","DefinitionParseError","DefinitionSyncPermanentError","hasAgentStepIntegrations","parseDefinition","WORKFLOW_PREFIX","MAX_WORKFLOW_FILES","FILE_FETCH_CONCURRENCY","UNRESOLVED_SYNC_REF","resolveSyncSource","params","source","sourceControl","resolveRepository","workspaceId","connectionId","sourceConnectionId","externalRepositoryId","sourceExternalRepositoryId","ref","repository","defaultBranch","discoverWorkflowFiles","page","listFiles","prefix","limit","nextCursor","paths","files","filter","file","path","endsWith","map","length","fetchAndParseWorkflows","parsed","onProgress","snapshot","fetchFile","Buffer","byteLength","content","parseWorkflowSnapshot","rawContent","stopOnError","loadIntegrationValidationContext","some","entry","definition","document","_rawContent","integrationValidationContext","undefined","contentHash","sha256Hex","name","error","message","classifySyncFailure","code","retryable","providerErrorCode","reason","isProviderReasonRetryable","Error","String","update","digest"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAc;AACvC,SACEC,kCAAkC,EAClCC,kCAAkC,EAClCC,2CAA2C,EAC3CC,wBAAwB,EAExBC,yBAAyB,QACpB,gCAAgC;AACvC,SAAQC,UAAU,QAAO,uBAAuB;AAIhD,SAAQC,oBAAoB,EAAEC,4BAA4B,QAAO,cAAc;AAC/E,SAAQC,wBAAwB,QAAO,mCAAmC;AAC1E,SAAQC,eAAe,QAAO,wBAAwB;AAEtD,OAAO,MAAMC,kBAAkB,sBAAsB;AACrD,OAAO,MAAMC,qBAAqB,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,SAAS,QAAQ0B,MAAM,CAAC;AAC7D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HarnessToolDeploymentConfig } from '@shipfox/api-agent-dto';
|
|
2
|
+
import type { IntegrationValidationContext } from './entities/integration-context.js';
|
|
3
|
+
import type { WorkflowDefinitionPayload } from './entities/workflow-definition.js';
|
|
4
|
+
export type ValidationError = {
|
|
5
|
+
message: string;
|
|
6
|
+
path?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export type ValidationResult = {
|
|
9
|
+
valid: true;
|
|
10
|
+
definition: WorkflowDefinitionPayload;
|
|
11
|
+
} | {
|
|
12
|
+
valid: false;
|
|
13
|
+
errors: ValidationError[];
|
|
14
|
+
};
|
|
15
|
+
export declare function validateDefinition(yamlContent: string, options?: {
|
|
16
|
+
defaultRunnerLabels?: readonly string[];
|
|
17
|
+
harnessToolDeploymentConfig?: HarnessToolDeploymentConfig;
|
|
18
|
+
integrationValidationContext?: IntegrationValidationContext;
|
|
19
|
+
}): ValidationResult;
|
|
20
|
+
//# sourceMappingURL=validate-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-definition.d.ts","sourceRoot":"","sources":["../../src/core/validate-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,wBAAwB,CAAC;AAGxE,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC;AAIjF,MAAM,MAAM,eAAe,GAAG;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,CAAC;AAE3E,MAAM,MAAM,gBAAgB,GACxB;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,yBAAyB,CAAA;CAAC,GACpD;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAC,CAAC;AAE9C,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAC1D,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;CACxD,GACL,gBAAgB,CAclB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { InvalidWorkflowDocumentError } from '@shipfox/workflow-document';
|
|
2
|
+
import { definitionDefaultRunnerLabels, definitionHarnessToolDeploymentConfig } from '../config.js';
|
|
3
|
+
import { InvalidWorkflowModelError, normalizeWorkflowDocument } from './workflow-model/index.js';
|
|
4
|
+
import { InvalidWorkflowYamlError, parseWorkflowYamlWithLocations } from './workflow-yaml/index.js';
|
|
5
|
+
export function validateDefinition(yamlContent, options = {}) {
|
|
6
|
+
try {
|
|
7
|
+
const { document, stepSourceLocations } = parseWorkflowYamlWithLocations(yamlContent);
|
|
8
|
+
const model = normalizeWorkflowDocument(document, {
|
|
9
|
+
defaultRunnerLabels: options.defaultRunnerLabels ?? definitionDefaultRunnerLabels,
|
|
10
|
+
harnessToolDeploymentConfig: options.harnessToolDeploymentConfig ?? definitionHarnessToolDeploymentConfig,
|
|
11
|
+
integrationValidationContext: options.integrationValidationContext,
|
|
12
|
+
stepSourceLocations
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
valid: true,
|
|
16
|
+
definition: {
|
|
17
|
+
document,
|
|
18
|
+
model
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return {
|
|
23
|
+
valid: false,
|
|
24
|
+
errors: validationErrorsFor(error)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function validationErrorsFor(error) {
|
|
29
|
+
if (error instanceof InvalidWorkflowYamlError) {
|
|
30
|
+
return [
|
|
31
|
+
validationError({
|
|
32
|
+
message: error.message,
|
|
33
|
+
path: error.location === undefined ? undefined : `${error.location.line}:${error.location.column}`
|
|
34
|
+
})
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
if (error instanceof InvalidWorkflowDocumentError) {
|
|
38
|
+
return error.validationError.issues.map((issue)=>validationError({
|
|
39
|
+
message: issue.message,
|
|
40
|
+
path: issue.path.join('.') || undefined
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
if (error instanceof InvalidWorkflowModelError) {
|
|
44
|
+
return error.issues.map((issue)=>validationError({
|
|
45
|
+
message: issue.message,
|
|
46
|
+
path: issue.path.join('.')
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
function validationError(params) {
|
|
52
|
+
if (params.path === undefined) return {
|
|
53
|
+
message: params.message
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
message: params.message,
|
|
57
|
+
path: params.path
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=validate-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/validate-definition.ts"],"sourcesContent":["import type {HarnessToolDeploymentConfig} from '@shipfox/api-agent-dto';\nimport {InvalidWorkflowDocumentError} from '@shipfox/workflow-document';\nimport {definitionDefaultRunnerLabels, definitionHarnessToolDeploymentConfig} from '../config.js';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {InvalidWorkflowModelError, normalizeWorkflowDocument} from './workflow-model/index.js';\nimport {InvalidWorkflowYamlError, parseWorkflowYamlWithLocations} from './workflow-yaml/index.js';\n\nexport type ValidationError = {message: string; path?: string | undefined};\n\nexport type ValidationResult =\n | {valid: true; definition: WorkflowDefinitionPayload}\n | {valid: false; errors: ValidationError[]};\n\nexport function validateDefinition(\n yamlContent: string,\n options: {\n defaultRunnerLabels?: readonly string[];\n harnessToolDeploymentConfig?: HarnessToolDeploymentConfig;\n integrationValidationContext?: IntegrationValidationContext;\n } = {},\n): ValidationResult {\n try {\n const {document, stepSourceLocations} = parseWorkflowYamlWithLocations(yamlContent);\n const model = normalizeWorkflowDocument(document, {\n defaultRunnerLabels: options.defaultRunnerLabels ?? definitionDefaultRunnerLabels,\n harnessToolDeploymentConfig:\n options.harnessToolDeploymentConfig ?? definitionHarnessToolDeploymentConfig,\n integrationValidationContext: options.integrationValidationContext,\n stepSourceLocations,\n });\n return {valid: true, definition: {document, model}};\n } catch (error) {\n return {valid: false, errors: validationErrorsFor(error)};\n }\n}\n\nfunction validationErrorsFor(error: unknown): ValidationError[] {\n if (error instanceof InvalidWorkflowYamlError) {\n return [\n validationError({\n message: error.message,\n path:\n error.location === undefined\n ? undefined\n : `${error.location.line}:${error.location.column}`,\n }),\n ];\n }\n\n if (error instanceof InvalidWorkflowDocumentError) {\n return error.validationError.issues.map((issue) =>\n validationError({\n message: issue.message,\n path: issue.path.join('.') || undefined,\n }),\n );\n }\n\n if (error instanceof InvalidWorkflowModelError) {\n return error.issues.map((issue) =>\n validationError({message: issue.message, path: issue.path.join('.')}),\n );\n }\n\n throw error;\n}\n\nfunction validationError(params: {message: string; path?: string | undefined}): ValidationError {\n if (params.path === undefined) return {message: params.message};\n return {message: params.message, path: params.path};\n}\n"],"names":["InvalidWorkflowDocumentError","definitionDefaultRunnerLabels","definitionHarnessToolDeploymentConfig","InvalidWorkflowModelError","normalizeWorkflowDocument","InvalidWorkflowYamlError","parseWorkflowYamlWithLocations","validateDefinition","yamlContent","options","document","stepSourceLocations","model","defaultRunnerLabels","harnessToolDeploymentConfig","integrationValidationContext","valid","definition","error","errors","validationErrorsFor","validationError","message","path","location","undefined","line","column","issues","map","issue","join","params"],"mappings":"AACA,SAAQA,4BAA4B,QAAO,6BAA6B;AACxE,SAAQC,6BAA6B,EAAEC,qCAAqC,QAAO,eAAe;AAGlG,SAAQC,yB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BW,MAAoD;IAC3E,IAAIA,OAAOT,IAAI,KAAKE,WAAW,OAAO;QAACH,SAASU,OAAOV,OAAO;IAAA;IAC9D,OAAO;QAACA,SAASU,OAAOV,OAAO;QAAEC,MAAMS,OAAOT,IAAI;IAAA;AACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,QAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/constants.ts"],"sourcesContent":["export const DEFAULT_RUN_TIMEOUT_MS = 30 * 24 * 60 * 60 * 1000;\n"],"names":["DEFAULT_RUN_TIMEOUT_MS"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,KAAK,KAAK,KAAK,KAAK,KAAK"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WorkflowModelValidationIssue } from './invalid-workflow-model-error.js';
|
|
2
|
+
export declare const cronTriggerDefaultTimezone = "UTC";
|
|
3
|
+
export declare function validateCronTrigger(params: {
|
|
4
|
+
readonly sourceKey: string;
|
|
5
|
+
readonly trigger: {
|
|
6
|
+
readonly event: string;
|
|
7
|
+
};
|
|
8
|
+
readonly config: {
|
|
9
|
+
readonly schedule?: string | undefined;
|
|
10
|
+
readonly timezone?: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
readonly issues: WorkflowModelValidationIssue[];
|
|
13
|
+
}): void;
|
|
14
|
+
export declare function isValidCronExpression(expression: string): boolean;
|
|
15
|
+
export declare function isValidTimezone(timezone: string): boolean;
|
|
16
|
+
//# sourceMappingURL=cron-trigger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-trigger.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/cron-trigger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAGpF,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAGhD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACxC,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,4BAA4B,EAAE,CAAC;CACjD,GAAG,IAAI,CA2CP;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAWjE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOzD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CronExpressionParser } from 'cron-parser';
|
|
2
|
+
import { issue } from './validation-issue.js';
|
|
3
|
+
export const cronTriggerDefaultTimezone = 'UTC';
|
|
4
|
+
const cronFieldSeparatorRegex = /\s+/;
|
|
5
|
+
export function validateCronTrigger(params) {
|
|
6
|
+
const { sourceKey, trigger, config, issues } = params;
|
|
7
|
+
if (trigger.event !== 'tick') {
|
|
8
|
+
issues.push(issue({
|
|
9
|
+
code: 'invalid-cron-event',
|
|
10
|
+
message: `A cron trigger must use event "tick"; found "${trigger.event}".`,
|
|
11
|
+
path: [
|
|
12
|
+
'triggers',
|
|
13
|
+
sourceKey,
|
|
14
|
+
'event'
|
|
15
|
+
],
|
|
16
|
+
details: {
|
|
17
|
+
event: trigger.event
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
if (config.schedule === undefined) {
|
|
22
|
+
issues.push(issue({
|
|
23
|
+
code: 'missing-cron-schedule',
|
|
24
|
+
message: 'A cron trigger requires a schedule.',
|
|
25
|
+
path: [
|
|
26
|
+
'triggers',
|
|
27
|
+
sourceKey,
|
|
28
|
+
'config',
|
|
29
|
+
'schedule'
|
|
30
|
+
]
|
|
31
|
+
}));
|
|
32
|
+
} else if (!isValidCronExpression(config.schedule)) {
|
|
33
|
+
issues.push(issue({
|
|
34
|
+
code: 'invalid-cron-schedule',
|
|
35
|
+
message: 'Cron trigger schedule must be a valid 5-field cron expression.',
|
|
36
|
+
path: [
|
|
37
|
+
'triggers',
|
|
38
|
+
sourceKey,
|
|
39
|
+
'config',
|
|
40
|
+
'schedule'
|
|
41
|
+
],
|
|
42
|
+
details: {
|
|
43
|
+
schedule: config.schedule
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
if (config.timezone !== undefined && !isValidTimezone(config.timezone)) {
|
|
48
|
+
issues.push(issue({
|
|
49
|
+
code: 'invalid-cron-timezone',
|
|
50
|
+
message: 'Cron trigger timezone must be a valid IANA time zone.',
|
|
51
|
+
path: [
|
|
52
|
+
'triggers',
|
|
53
|
+
sourceKey,
|
|
54
|
+
'config',
|
|
55
|
+
'timezone'
|
|
56
|
+
],
|
|
57
|
+
details: {
|
|
58
|
+
timezone: config.timezone
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function isValidCronExpression(expression) {
|
|
64
|
+
const trimmedExpression = expression.trim();
|
|
65
|
+
if (trimmedExpression.length === 0) return false;
|
|
66
|
+
if (trimmedExpression.split(cronFieldSeparatorRegex).length !== 5) return false;
|
|
67
|
+
try {
|
|
68
|
+
CronExpressionParser.parse(trimmedExpression);
|
|
69
|
+
return true;
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function isValidTimezone(timezone) {
|
|
75
|
+
try {
|
|
76
|
+
new Intl.DateTimeFormat('en-US', {
|
|
77
|
+
timeZone: timezone
|
|
78
|
+
});
|
|
79
|
+
return true;
|
|
80
|
+
} catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=cron-trigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/cron-trigger.ts"],"sourcesContent":["import {CronExpressionParser} from 'cron-parser';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {issue} from './validation-issue.js';\n\nexport const cronTriggerDefaultTimezone = 'UTC';\nconst cronFieldSeparatorRegex = /\\s+/;\n\nexport function validateCronTrigger(params: {\n readonly sourceKey: string;\n readonly trigger: {\n readonly event: string;\n };\n readonly config: {\n readonly schedule?: string | undefined;\n readonly timezone?: string | undefined;\n };\n readonly issues: WorkflowModelValidationIssue[];\n}): void {\n const {sourceKey, trigger, config, issues} = params;\n\n if (trigger.event !== 'tick') {\n issues.push(\n issue({\n code: 'invalid-cron-event',\n message: `A cron trigger must use event \"tick\"; found \"${trigger.event}\".`,\n path: ['triggers', sourceKey, 'event'],\n details: {event: trigger.event},\n }),\n );\n }\n\n if (config.schedule === undefined) {\n issues.push(\n issue({\n code: 'missing-cron-schedule',\n message: 'A cron trigger requires a schedule.',\n path: ['triggers', sourceKey, 'config', 'schedule'],\n }),\n );\n } else if (!isValidCronExpression(config.schedule)) {\n issues.push(\n issue({\n code: 'invalid-cron-schedule',\n message: 'Cron trigger schedule must be a valid 5-field cron expression.',\n path: ['triggers', sourceKey, 'config', 'schedule'],\n details: {schedule: config.schedule},\n }),\n );\n }\n\n if (config.timezone !== undefined && !isValidTimezone(config.timezone)) {\n issues.push(\n issue({\n code: 'invalid-cron-timezone',\n message: 'Cron trigger timezone must be a valid IANA time zone.',\n path: ['triggers', sourceKey, 'config', 'timezone'],\n details: {timezone: config.timezone},\n }),\n );\n }\n}\n\nexport function isValidCronExpression(expression: string): boolean {\n const trimmedExpression = expression.trim();\n if (trimmedExpression.length === 0) return false;\n if (trimmedExpression.split(cronFieldSeparatorRegex).length !== 5) return false;\n\n try {\n CronExpressionParser.parse(trimmedExpression);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function isValidTimezone(timezone: string): boolean {\n try {\n new Intl.DateTimeFormat('en-US', {timeZone: timezone});\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["CronExpressionParser","issue","cronTriggerDefaultTimezone","cronFieldSeparatorRegex","validateCronTrigger","params","sourceKey","trigger","config","issues","event","push","code","message","path","details","schedule","undefined","isValidCronExpression","timezone","isValidTimezone","expression","trimmedExpression","trim","length","split","parse","Intl","DateTimeFormat","timeZone"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,cAAc;AAEjD,SAAQC,KAAK,QAAO,wBAAwB;AAE5C,OAAO,MAAMC,6BAA6B,MAAM;AAChD,MAAMC,0BAA0B;AAEhC,OAAO,SAASC,oBAAoBC,MAUnC;IACC,MAAM,EAACC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAC,GAAGJ;IAE7C,IAAIE,QAAQG,KAAK,KAAK,QAAQ;QAC5BD,OAAOE,IAAI,CACTV,MAAM;YACJW,MAAM;YACNC,SAAS,CAAC,6CAA6C,EAAEN,QAAQG,KAAK,CAAC,EAAE,CAAC;YAC1EI,MAAM;gBAAC;gBAAYR;gBAAW;aAAQ;YACtCS,SAAS;gBAACL,OAAOH,QAAQG,KAAK;YAAA;QAChC;IAEJ;IAEA,IAAIF,OAAOQ,QAAQ,KAAKC,WAAW;QACjCR,OAAOE,IAAI,CACTV,MAAM;YACJW,MAAM;YACNC,SAAS;YACTC,MAAM;gBAAC;gBAAYR;gBAAW;gBAAU;aAAW;QACrD;IAEJ,OAAO,IAAI,CAACY,sBAAsBV,OAAOQ,QAAQ,GAAG;QAClDP,OAAOE,IAAI,CACTV,MAAM;YACJW,MAAM;YACNC,SAAS;YACTC,MAAM;gBAAC;gBAAYR;gBAAW;gBAAU;aAAW;YACnDS,SAAS;gBAACC,UAAUR,OAAOQ,QAAQ;YAAA;QACrC;IAEJ;IAEA,IAAIR,OAAOW,QAAQ,KAAKF,aAAa,CAACG,gBAAgBZ,OAAOW,QAAQ,GAAG;QACtEV,OAAOE,IAAI,CACTV,MAAM;YACJW,MAAM;YACNC,SAAS;YACTC,MAAM;gBAAC;gBAAYR;gBAAW;gBAAU;aAAW;YACnDS,SAAS;gBAACI,UAAUX,OAAOW,QAAQ;YAAA;QACrC;IAEJ;AACF;AAEA,OAAO,SAASD,sBAAsBG,UAAkB;IACtD,MAAMC,oBAAoBD,WAAWE,IAAI;IACzC,IAAID,kBAAkBE,MAAM,KAAK,GAAG,OAAO;IAC3C,IAAIF,kBAAkBG,KAAK,CAACtB,yBAAyBqB,MAAM,KAAK,GAAG,OAAO;IAE1E,IAAI;QACFxB,qBAAqB0B,KAAK,CAACJ;QAC3B,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,OAAO,SAASF,gBAAgBD,QAAgB;IAC9C,IAAI;QACF,IAAIQ,KAAKC,cAAc,CAAC,SAAS;YAACC,UAAUV;QAAQ;QACpD,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { DEFAULT_RUN_TIMEOUT_MS } from './constants.js';
|
|
2
|
+
export { InvalidWorkflowModelError, invalidWorkflowModelErrorCode, type WorkflowModelValidationIssue, type WorkflowModelValidationIssueCode, type WorkflowModelValidationIssuePathSegment, } from './invalid-workflow-model-error.js';
|
|
3
|
+
export { normalizeWorkflowDocument } from './normalize-workflow-document.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,gBAAgB,CAAC;AACtD,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,KAAK,4BAA4B,EACjC,KAAK,gCAAgC,EACrC,KAAK,uCAAuC,GAC7C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,yBAAyB,EAAC,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DEFAULT_RUN_TIMEOUT_MS } from './constants.js';
|
|
2
|
+
export { InvalidWorkflowModelError, invalidWorkflowModelErrorCode } from './invalid-workflow-model-error.js';
|
|
3
|
+
export { normalizeWorkflowDocument } from './normalize-workflow-document.js';
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/workflow-model/index.ts"],"sourcesContent":["export {DEFAULT_RUN_TIMEOUT_MS} from './constants.js';\nexport {\n InvalidWorkflowModelError,\n invalidWorkflowModelErrorCode,\n type WorkflowModelValidationIssue,\n type WorkflowModelValidationIssueCode,\n type WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\nexport {normalizeWorkflowDocument} from './normalize-workflow-document.js';\n"],"names":["DEFAULT_RUN_TIMEOUT_MS","InvalidWorkflowModelError","invalidWorkflowModelErrorCode","normalizeWorkflowDocument"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,iBAAiB;AACtD,SACEC,yBAAyB,EACzBC,6BAA6B,QAIxB,oCAAoC;AAC3C,SAAQC,yBAAyB,QAAO,mCAAmC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const invalidWorkflowModelErrorCode = "invalid-workflow-model";
|
|
2
|
+
export type WorkflowModelValidationIssueCode = 'context-unavailable-at-fill-site' | 'context-unavailable-at-predicate-site' | 'computed-context-key' | 'duplicate-job-id' | 'duplicate-step-id' | 'duplicate-trigger-id' | 'harness-provider-incompatible' | 'harness-thinking-incompatible' | 'harness-tool-incompatible' | 'integration-connection-not-capable' | 'integration-connection-not-found' | 'integration-write-not-allowed' | 'invalid-cron-event' | 'invalid-cron-schedule' | 'invalid-cron-timezone' | 'invalid-provider' | 'invalid-trigger-filter' | 'invalid-interpolation-expression' | 'invalid-interpolation-template' | 'invalid-duration' | 'invalid-listener-filter' | 'invalid-job-if' | 'invalid-job-output' | 'invalid-job-success' | 'invalid-output-schema' | 'invalid-runner-label' | 'invalid-step-gate-restart-from' | 'invalid-step-gate-success' | 'invalid-step-if' | 'job-dependency-cycle' | 'listening-job-missing-resolution-source' | 'listening-timeout-exceeds-run-timeout' | 'missing-harness-for-tools' | 'missing-connection-for-integration' | 'missing-job-needs-edge' | 'missing-cron-schedule' | 'missing-runner-label' | 'multiple-manual-triggers' | 'runner-context-not-bare' | 'runner-context-in-field' | 'runner-context-in-server-predicate' | 'self-job-dependency' | 'too-many-runner-labels' | 'unknown-secret-store' | 'unknown-interpolation-context' | 'unknown-integration-method' | 'unknown-integration-tool' | 'unknown-job-dependency' | 'untrusted-context-in-field' | 'vars-context-in-server-predicate';
|
|
3
|
+
export type WorkflowModelValidationIssuePathSegment = string | number;
|
|
4
|
+
export interface WorkflowModelValidationIssue {
|
|
5
|
+
readonly code: WorkflowModelValidationIssueCode;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly path: readonly WorkflowModelValidationIssuePathSegment[];
|
|
8
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
9
|
+
}
|
|
10
|
+
export declare class InvalidWorkflowModelError extends Error {
|
|
11
|
+
readonly issues: readonly WorkflowModelValidationIssue[];
|
|
12
|
+
readonly code = "invalid-workflow-model";
|
|
13
|
+
constructor(issues: readonly WorkflowModelValidationIssue[]);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=invalid-workflow-model-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalid-workflow-model-error.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/invalid-workflow-model-error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,2BA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