@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,206 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentToolSelectionCatalogs,
|
|
3
|
+
IntegrationSourceControlService,
|
|
4
|
+
LoadWorkspaceConnectionSnapshot,
|
|
5
|
+
} from '@shipfox/api-integration-core';
|
|
6
|
+
import {Context} from '@temporalio/activity';
|
|
7
|
+
import {ApplicationFailure} from '@temporalio/common';
|
|
8
|
+
import type {DefinitionSyncErrorCode} from '#core/entities/sync-state.js';
|
|
9
|
+
import {
|
|
10
|
+
classifySyncFailure,
|
|
11
|
+
discoverWorkflowFiles,
|
|
12
|
+
fetchAndParseWorkflows,
|
|
13
|
+
resolveSyncSource,
|
|
14
|
+
UNRESOLVED_SYNC_REF,
|
|
15
|
+
} from '#core/index.js';
|
|
16
|
+
import {applyVcsDefinitionsBatch, markDefinitionSyncState} from '#db/index.js';
|
|
17
|
+
|
|
18
|
+
export interface SyncWorkflowInput {
|
|
19
|
+
projectId: string;
|
|
20
|
+
workspaceId: string;
|
|
21
|
+
sourceConnectionId: string;
|
|
22
|
+
sourceExternalRepositoryId: string;
|
|
23
|
+
sourceRef?: string | undefined;
|
|
24
|
+
sourceCommitSha?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SyncRefScopedInput extends SyncWorkflowInput {
|
|
28
|
+
sourceRef: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface FetchAndApplyActivityInput extends SyncRefScopedInput {
|
|
32
|
+
paths: string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface MarkSyncFailedActivityInput extends Omit<SyncWorkflowInput, 'sourceRef'> {
|
|
36
|
+
sourceRef: string | null;
|
|
37
|
+
code: DefinitionSyncErrorCode;
|
|
38
|
+
message: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface PrepareSyncResult {
|
|
42
|
+
sourceRef: string;
|
|
43
|
+
sourceCommitSha?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface DiscoverWorkflowsActivityResult {
|
|
47
|
+
paths: string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface FetchAndApplyActivityResult {
|
|
51
|
+
appliedCount: number;
|
|
52
|
+
deletedCount: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface DefinitionSyncIntegrationValidationOptions {
|
|
56
|
+
agentToolSelectionCatalogs: AgentToolSelectionCatalogs;
|
|
57
|
+
loadWorkspaceConnectionSnapshot: LoadWorkspaceConnectionSnapshot;
|
|
58
|
+
getIntegrationConnectionById: (id: string) => Promise<{slug: string} | undefined>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function createDefinitionSyncActivities(
|
|
62
|
+
sourceControl: IntegrationSourceControlService,
|
|
63
|
+
integrationValidation?: DefinitionSyncIntegrationValidationOptions | undefined,
|
|
64
|
+
) {
|
|
65
|
+
return {
|
|
66
|
+
prepareDefinitionSync: createPrepareDefinitionSyncActivity(sourceControl),
|
|
67
|
+
discoverDefinitionWorkflows: createDiscoverDefinitionWorkflowsActivity(sourceControl),
|
|
68
|
+
fetchAndApplyDefinitionWorkflows: createFetchAndApplyActivity(
|
|
69
|
+
sourceControl,
|
|
70
|
+
integrationValidation,
|
|
71
|
+
),
|
|
72
|
+
markDefinitionSyncSucceeded: createMarkSyncSucceededActivity(),
|
|
73
|
+
markDefinitionSyncFailed: createMarkSyncFailedActivity(),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function createPrepareDefinitionSyncActivity(sourceControl: IntegrationSourceControlService) {
|
|
78
|
+
return async function prepareDefinitionSync(
|
|
79
|
+
input: SyncWorkflowInput,
|
|
80
|
+
): Promise<PrepareSyncResult> {
|
|
81
|
+
return await runWithPermanentTranslation(async () => {
|
|
82
|
+
const sourceRef = input.sourceRef ?? (await resolveSyncSource({...input, sourceControl})).ref;
|
|
83
|
+
|
|
84
|
+
await markDefinitionSyncState({
|
|
85
|
+
projectId: input.projectId,
|
|
86
|
+
sourceConnectionId: input.sourceConnectionId,
|
|
87
|
+
sourceExternalRepositoryId: input.sourceExternalRepositoryId,
|
|
88
|
+
ref: sourceRef,
|
|
89
|
+
status: 'syncing',
|
|
90
|
+
lastErrorCode: null,
|
|
91
|
+
lastErrorMessage: null,
|
|
92
|
+
startedAt: new Date(),
|
|
93
|
+
finishedAt: null,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return {sourceRef, sourceCommitSha: input.sourceCommitSha};
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function createDiscoverDefinitionWorkflowsActivity(sourceControl: IntegrationSourceControlService) {
|
|
102
|
+
return async function discoverDefinitionWorkflows(
|
|
103
|
+
input: SyncRefScopedInput,
|
|
104
|
+
): Promise<DiscoverWorkflowsActivityResult> {
|
|
105
|
+
return await runWithPermanentTranslation(async () => {
|
|
106
|
+
return await discoverWorkflowFiles({
|
|
107
|
+
...input,
|
|
108
|
+
ref: input.sourceCommitSha ?? input.sourceRef,
|
|
109
|
+
sourceControl,
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function createFetchAndApplyActivity(
|
|
116
|
+
sourceControl: IntegrationSourceControlService,
|
|
117
|
+
integrationValidation?: DefinitionSyncIntegrationValidationOptions | undefined,
|
|
118
|
+
) {
|
|
119
|
+
return async function fetchAndApplyDefinitionWorkflows(
|
|
120
|
+
input: FetchAndApplyActivityInput,
|
|
121
|
+
): Promise<FetchAndApplyActivityResult> {
|
|
122
|
+
return await runWithPermanentTranslation(async () => {
|
|
123
|
+
const definitions = await fetchAndParseWorkflows({
|
|
124
|
+
...input,
|
|
125
|
+
ref: input.sourceCommitSha ?? input.sourceRef,
|
|
126
|
+
sourceControl,
|
|
127
|
+
onProgress: (path) => Context.current().heartbeat({path}),
|
|
128
|
+
loadIntegrationValidationContext:
|
|
129
|
+
integrationValidation === undefined
|
|
130
|
+
? undefined
|
|
131
|
+
: async () => {
|
|
132
|
+
const sourceConnection = await integrationValidation.getIntegrationConnectionById(
|
|
133
|
+
input.sourceConnectionId,
|
|
134
|
+
);
|
|
135
|
+
return {
|
|
136
|
+
agentToolSelectionCatalogs: integrationValidation.agentToolSelectionCatalogs,
|
|
137
|
+
workspaceConnectionSnapshot:
|
|
138
|
+
await integrationValidation.loadWorkspaceConnectionSnapshot(input.workspaceId),
|
|
139
|
+
defaultConnectionSlug: sourceConnection?.slug,
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return await applyVcsDefinitionsBatch({
|
|
145
|
+
projectId: input.projectId,
|
|
146
|
+
workspaceId: input.workspaceId,
|
|
147
|
+
ref: input.sourceRef,
|
|
148
|
+
upserts: definitions.map((entry) => ({
|
|
149
|
+
configPath: entry.path,
|
|
150
|
+
name: entry.name,
|
|
151
|
+
document: entry.definition.document,
|
|
152
|
+
model: entry.definition.model,
|
|
153
|
+
sourceSnapshot: entry.definition.sourceSnapshot,
|
|
154
|
+
contentHash: entry.contentHash,
|
|
155
|
+
})),
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function createMarkSyncSucceededActivity() {
|
|
162
|
+
return async function markDefinitionSyncSucceeded(input: SyncRefScopedInput): Promise<void> {
|
|
163
|
+
await markDefinitionSyncState({
|
|
164
|
+
projectId: input.projectId,
|
|
165
|
+
sourceConnectionId: input.sourceConnectionId,
|
|
166
|
+
sourceExternalRepositoryId: input.sourceExternalRepositoryId,
|
|
167
|
+
ref: input.sourceRef,
|
|
168
|
+
status: 'succeeded',
|
|
169
|
+
lastErrorCode: null,
|
|
170
|
+
lastErrorMessage: null,
|
|
171
|
+
finishedAt: new Date(),
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function createMarkSyncFailedActivity() {
|
|
177
|
+
return async function markDefinitionSyncFailed(
|
|
178
|
+
input: MarkSyncFailedActivityInput,
|
|
179
|
+
): Promise<void> {
|
|
180
|
+
await markDefinitionSyncState({
|
|
181
|
+
projectId: input.projectId,
|
|
182
|
+
sourceConnectionId: input.sourceConnectionId,
|
|
183
|
+
sourceExternalRepositoryId: input.sourceExternalRepositoryId,
|
|
184
|
+
ref: input.sourceRef ?? UNRESOLVED_SYNC_REF,
|
|
185
|
+
status: 'failed',
|
|
186
|
+
lastErrorCode: input.code,
|
|
187
|
+
lastErrorMessage: input.message,
|
|
188
|
+
finishedAt: new Date(),
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async function runWithPermanentTranslation<T>(operation: () => Promise<T>): Promise<T> {
|
|
194
|
+
try {
|
|
195
|
+
return await operation();
|
|
196
|
+
} catch (error) {
|
|
197
|
+
if (error instanceof ApplicationFailure) {
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
const failure = classifySyncFailure(error);
|
|
201
|
+
if (!failure.retryable) {
|
|
202
|
+
throw ApplicationFailure.nonRetryable(failure.message, failure.code);
|
|
203
|
+
}
|
|
204
|
+
throw ApplicationFailure.retryable(failure.message, failure.code);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {ActivityFailure, ApplicationFailure, RetryState} from '@temporalio/common';
|
|
2
|
+
import {classifyWorkflowError} from './definition-sync.js';
|
|
3
|
+
|
|
4
|
+
describe('definitionSyncWorkflow error classification', () => {
|
|
5
|
+
it('unwraps activity application failures before persisting sync failure metadata', () => {
|
|
6
|
+
const cause = ApplicationFailure.nonRetryable(
|
|
7
|
+
'Invalid workflow definition at .shipfox/workflows/bad.yml',
|
|
8
|
+
'invalid-definition',
|
|
9
|
+
);
|
|
10
|
+
const error = new ActivityFailure(
|
|
11
|
+
'Activity failed',
|
|
12
|
+
'fetchAndApplyDefinitionWorkflows',
|
|
13
|
+
'activity-id',
|
|
14
|
+
RetryState.NON_RETRYABLE_FAILURE,
|
|
15
|
+
'worker',
|
|
16
|
+
cause,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const result = classifyWorkflowError(error);
|
|
20
|
+
|
|
21
|
+
expect(result).toEqual({
|
|
22
|
+
code: 'invalid-definition',
|
|
23
|
+
message: 'Invalid workflow definition at .shipfox/workflows/bad.yml',
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('classifies a bare ApplicationFailure using its type', () => {
|
|
28
|
+
const error = ApplicationFailure.retryable('GitHub request timed out', 'provider-timeout');
|
|
29
|
+
|
|
30
|
+
const result = classifyWorkflowError(error);
|
|
31
|
+
|
|
32
|
+
expect(result).toEqual({
|
|
33
|
+
code: 'provider-timeout',
|
|
34
|
+
message: 'GitHub request timed out',
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('falls back to unknown when ApplicationFailure.type is not a known sync error code', () => {
|
|
39
|
+
const error = ApplicationFailure.nonRetryable('boom', 'something-unexpected');
|
|
40
|
+
|
|
41
|
+
const result = classifyWorkflowError(error);
|
|
42
|
+
|
|
43
|
+
expect(result).toEqual({
|
|
44
|
+
code: 'unknown',
|
|
45
|
+
message: 'boom',
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('classifies non-temporal errors as unknown and preserves the message', () => {
|
|
50
|
+
const error = new Error('connection reset');
|
|
51
|
+
|
|
52
|
+
const result = classifyWorkflowError(error);
|
|
53
|
+
|
|
54
|
+
expect(result).toEqual({
|
|
55
|
+
code: 'unknown',
|
|
56
|
+
message: 'connection reset',
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {ActivityFailure, ApplicationFailure, proxyActivities} from '@temporalio/workflow';
|
|
2
|
+
import {
|
|
3
|
+
type DefinitionSyncErrorCode,
|
|
4
|
+
isDefinitionSyncErrorCode,
|
|
5
|
+
} from '#core/entities/sync-state.js';
|
|
6
|
+
import type {createDefinitionSyncActivities} from '../activities/index.js';
|
|
7
|
+
|
|
8
|
+
export interface DefinitionSyncWorkflowInput {
|
|
9
|
+
projectId: string;
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
sourceConnectionId: string;
|
|
12
|
+
sourceExternalRepositoryId: string;
|
|
13
|
+
sourceRef?: string | undefined;
|
|
14
|
+
sourceCommitSha?: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface DefinitionSyncWorkflowResult {
|
|
18
|
+
sourceRef: string;
|
|
19
|
+
appliedCount: number;
|
|
20
|
+
deletedCount: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const PROVIDER_RETRY = {
|
|
24
|
+
initialInterval: '5 seconds',
|
|
25
|
+
backoffCoefficient: 2,
|
|
26
|
+
maximumInterval: '1 minute',
|
|
27
|
+
maximumAttempts: 5,
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
const DB_RETRY = {
|
|
31
|
+
initialInterval: '1 second',
|
|
32
|
+
backoffCoefficient: 2,
|
|
33
|
+
maximumInterval: '15 seconds',
|
|
34
|
+
maximumAttempts: 5,
|
|
35
|
+
} as const;
|
|
36
|
+
|
|
37
|
+
const {prepareDefinitionSync, discoverDefinitionWorkflows, fetchAndApplyDefinitionWorkflows} =
|
|
38
|
+
proxyActivities<ReturnType<typeof createDefinitionSyncActivities>>({
|
|
39
|
+
startToCloseTimeout: '5 minutes',
|
|
40
|
+
heartbeatTimeout: '30 seconds',
|
|
41
|
+
retry: PROVIDER_RETRY,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const {markDefinitionSyncSucceeded, markDefinitionSyncFailed} = proxyActivities<
|
|
45
|
+
ReturnType<typeof createDefinitionSyncActivities>
|
|
46
|
+
>({
|
|
47
|
+
startToCloseTimeout: '30 seconds',
|
|
48
|
+
retry: DB_RETRY,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export async function definitionSyncWorkflow(
|
|
52
|
+
input: DefinitionSyncWorkflowInput,
|
|
53
|
+
): Promise<DefinitionSyncWorkflowResult> {
|
|
54
|
+
let sourceRef: string | null = null;
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
const prepared = await prepareDefinitionSync(input);
|
|
58
|
+
sourceRef = prepared.sourceRef;
|
|
59
|
+
|
|
60
|
+
const source = {
|
|
61
|
+
...input,
|
|
62
|
+
sourceRef: prepared.sourceRef,
|
|
63
|
+
sourceCommitSha: prepared.sourceCommitSha,
|
|
64
|
+
};
|
|
65
|
+
const {paths} = await discoverDefinitionWorkflows(source);
|
|
66
|
+
const applied = await fetchAndApplyDefinitionWorkflows({...source, paths});
|
|
67
|
+
|
|
68
|
+
await markDefinitionSyncSucceeded(source);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
sourceRef,
|
|
72
|
+
appliedCount: applied.appliedCount,
|
|
73
|
+
deletedCount: applied.deletedCount,
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
const {code, message} = classifyWorkflowError(error);
|
|
77
|
+
try {
|
|
78
|
+
await markDefinitionSyncFailed({...input, sourceRef, code, message});
|
|
79
|
+
} catch (markFailedError) {
|
|
80
|
+
const failureOptions = {
|
|
81
|
+
message: `Definition sync failed with ${code}: ${message}; additionally failed to persist failure state: ${formatWorkflowError(markFailedError)}`,
|
|
82
|
+
type: 'definition-sync-failure-persistence-failed',
|
|
83
|
+
nonRetryable: true,
|
|
84
|
+
details: [
|
|
85
|
+
{
|
|
86
|
+
syncFailureCode: code,
|
|
87
|
+
syncFailureMessage: message,
|
|
88
|
+
failurePersistenceMessage: formatWorkflowError(markFailedError),
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
throw ApplicationFailure.create(
|
|
93
|
+
error instanceof Error ? {...failureOptions, cause: error} : failureOptions,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function classifyWorkflowError(error: unknown): {
|
|
101
|
+
code: DefinitionSyncErrorCode;
|
|
102
|
+
message: string;
|
|
103
|
+
} {
|
|
104
|
+
if (error instanceof ActivityFailure && error.cause instanceof ApplicationFailure) {
|
|
105
|
+
return classifyWorkflowError(error.cause);
|
|
106
|
+
}
|
|
107
|
+
if (error instanceof ApplicationFailure) {
|
|
108
|
+
const code = isDefinitionSyncErrorCode(error.type) ? error.type : 'unknown';
|
|
109
|
+
return {code, message: error.message ?? code};
|
|
110
|
+
}
|
|
111
|
+
return {code: 'unknown', message: error instanceof Error ? error.message : String(error)};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function formatWorkflowError(error: unknown): string {
|
|
115
|
+
return error instanceof Error ? error.message : String(error);
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {definitionSyncWorkflow} from './definition-sync.js';
|
package/test/env.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
process.env.POSTGRES_HOST ??= 'localhost';
|
|
2
|
+
process.env.POSTGRES_PORT ??= '5432';
|
|
3
|
+
process.env.POSTGRES_USERNAME ??= 'shipfox';
|
|
4
|
+
process.env.POSTGRES_PASSWORD ??= 'password';
|
|
5
|
+
process.env.POSTGRES_DATABASE = 'api_test';
|
|
6
|
+
process.env.POSTGRES_MAX_CONNECTIONS ??= '5';
|
|
7
|
+
process.env.TZ = 'UTC';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {Factory} from 'fishery';
|
|
2
|
+
import type {
|
|
3
|
+
WorkflowDefinition,
|
|
4
|
+
WorkflowDefinitionPayload,
|
|
5
|
+
} from '#core/entities/workflow-definition.js';
|
|
6
|
+
import {normalizeWorkflowDocument} from '#core/workflow-model/index.js';
|
|
7
|
+
import {upsertDefinition} from '#db/definitions.js';
|
|
8
|
+
|
|
9
|
+
function defaultDefinition(): WorkflowDefinitionPayload {
|
|
10
|
+
const document = {
|
|
11
|
+
name: 'Test Workflow',
|
|
12
|
+
runner: 'ubuntu-latest',
|
|
13
|
+
jobs: {
|
|
14
|
+
build: {
|
|
15
|
+
steps: [{run: 'echo hello'}],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
return {document, model: normalizeWorkflowDocument(document)};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface DefinitionTransients {
|
|
23
|
+
workspaceId: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const definitionFactory = Factory.define<WorkflowDefinition, DefinitionTransients>(
|
|
27
|
+
({sequence, onCreate, transientParams}) => {
|
|
28
|
+
const projectId = crypto.randomUUID();
|
|
29
|
+
|
|
30
|
+
onCreate((definition) => {
|
|
31
|
+
return upsertDefinition({
|
|
32
|
+
projectId: definition.projectId,
|
|
33
|
+
workspaceId: transientParams.workspaceId ?? crypto.randomUUID(),
|
|
34
|
+
configPath: definition.configPath,
|
|
35
|
+
source: definition.source,
|
|
36
|
+
name: definition.name,
|
|
37
|
+
document: definition.document,
|
|
38
|
+
model: definition.model,
|
|
39
|
+
sourceSnapshot: definition.sourceSnapshot,
|
|
40
|
+
contentHash: definition.contentHash ?? undefined,
|
|
41
|
+
sha: definition.sha ?? undefined,
|
|
42
|
+
ref: definition.ref ?? undefined,
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const definition = defaultDefinition();
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
id: crypto.randomUUID(),
|
|
50
|
+
projectId,
|
|
51
|
+
configPath: `.shipfox/workflows/test-${sequence}.yml`,
|
|
52
|
+
source: 'manual',
|
|
53
|
+
sha: null,
|
|
54
|
+
ref: null,
|
|
55
|
+
name: `Test Workflow ${sequence}`,
|
|
56
|
+
definition: definition.document,
|
|
57
|
+
...definition,
|
|
58
|
+
sourceSnapshot: definition.sourceSnapshot ?? null,
|
|
59
|
+
contentHash: null,
|
|
60
|
+
fetchedAt: new Date(),
|
|
61
|
+
createdAt: new Date(),
|
|
62
|
+
updatedAt: new Date(),
|
|
63
|
+
deletedAt: null,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Multi-job pipeline
|
|
2
|
+
runner: ubuntu-latest
|
|
3
|
+
|
|
4
|
+
jobs:
|
|
5
|
+
build:
|
|
6
|
+
steps:
|
|
7
|
+
- run: npm install
|
|
8
|
+
- run: npm run build
|
|
9
|
+
|
|
10
|
+
test-unit:
|
|
11
|
+
needs: build
|
|
12
|
+
steps:
|
|
13
|
+
- run: npm run test:unit
|
|
14
|
+
|
|
15
|
+
test-integration:
|
|
16
|
+
needs: build
|
|
17
|
+
steps:
|
|
18
|
+
- run: npm run test:integration
|
|
19
|
+
|
|
20
|
+
deploy:
|
|
21
|
+
needs:
|
|
22
|
+
- test-unit
|
|
23
|
+
- test-integration
|
|
24
|
+
steps:
|
|
25
|
+
- run: ./deploy.sh staging
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Listening workflow
|
|
2
|
+
runner: ubuntu-latest
|
|
3
|
+
jobs:
|
|
4
|
+
review:
|
|
5
|
+
name: Review batch ${{ execution.index }}
|
|
6
|
+
listening:
|
|
7
|
+
on:
|
|
8
|
+
- source: github
|
|
9
|
+
event: pull_request_review
|
|
10
|
+
until:
|
|
11
|
+
- source: github
|
|
12
|
+
event: pull_request
|
|
13
|
+
timeout: 30d
|
|
14
|
+
max_executions: 3
|
|
15
|
+
batch:
|
|
16
|
+
debounce: 5s
|
|
17
|
+
max_size: 10
|
|
18
|
+
max_wait: 1h
|
|
19
|
+
on_resolve: cancel
|
|
20
|
+
steps:
|
|
21
|
+
- prompt: Review ${{ execution.events[0].data.body }}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Simple build
|
|
2
|
+
runner: ubuntu-latest
|
|
3
|
+
|
|
4
|
+
triggers:
|
|
5
|
+
on_demand:
|
|
6
|
+
source: manual
|
|
7
|
+
event: fire
|
|
8
|
+
on_push:
|
|
9
|
+
source: github_acme
|
|
10
|
+
event: push
|
|
11
|
+
filter: event.ref == "refs/heads/main"
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
steps:
|
|
16
|
+
- run: npm install
|
|
17
|
+
- run: npm run build
|
|
18
|
+
name: build_output
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "simple build",
|
|
3
|
+
"triggers": {
|
|
4
|
+
"main_push": {
|
|
5
|
+
"source": "github_acme",
|
|
6
|
+
"event": "push",
|
|
7
|
+
"filter": "event.ref == \"refs/heads/main\""
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"jobs": {
|
|
11
|
+
"build": {
|
|
12
|
+
"steps": [
|
|
13
|
+
{
|
|
14
|
+
"run": "npm install"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "build",
|
|
18
|
+
"run": "npm run build",
|
|
19
|
+
"gate": {
|
|
20
|
+
"success": "step.exit_code == 0"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import './env.js';
|
|
2
|
+
import {runMigrations} from '@shipfox/node-drizzle';
|
|
3
|
+
import {closePostgresClient, createPostgresClient} from '@shipfox/node-postgres';
|
|
4
|
+
import {sql} from 'drizzle-orm';
|
|
5
|
+
import {closeDb, db, migrationsPath} from '#db/index.js';
|
|
6
|
+
|
|
7
|
+
export async function setup() {
|
|
8
|
+
createPostgresClient();
|
|
9
|
+
|
|
10
|
+
await db().execute(sql`DROP TABLE IF EXISTS definitions_workflow_definitions CASCADE`);
|
|
11
|
+
await db().execute(sql`DROP TABLE IF EXISTS definitions_sync_states CASCADE`);
|
|
12
|
+
await db().execute(sql`DROP TABLE IF EXISTS definitions_outbox CASCADE`);
|
|
13
|
+
await db().execute(sql`DROP TYPE IF EXISTS definitions_sync_status CASCADE`);
|
|
14
|
+
await db().execute(sql`DROP TYPE IF EXISTS definitions_sync_error_code CASCADE`);
|
|
15
|
+
await db().execute(sql`DROP TYPE IF EXISTS definitions_source CASCADE`);
|
|
16
|
+
await db().execute(sql`DROP TABLE IF EXISTS __drizzle_migrations_definitions CASCADE`);
|
|
17
|
+
await db().execute(sql`DROP TABLE IF EXISTS drizzle.__drizzle_migrations_definitions CASCADE`);
|
|
18
|
+
await runMigrations(db(), migrationsPath, '__drizzle_migrations_definitions');
|
|
19
|
+
await db().execute(sql`TRUNCATE TABLE definitions_workflow_definitions CASCADE`);
|
|
20
|
+
await db().execute(sql`TRUNCATE TABLE definitions_sync_states CASCADE`);
|
|
21
|
+
await db().execute(sql`TRUNCATE TABLE definitions_outbox CASCADE`);
|
|
22
|
+
|
|
23
|
+
closeDb();
|
|
24
|
+
await closePostgresClient();
|
|
25
|
+
}
|
package/test/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {definitionFactory} from './factories/definition.js';
|
package/test/setup.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import './env.js';
|
|
2
|
+
import {closePostgresClient, createPostgresClient} from '@shipfox/node-postgres';
|
|
3
|
+
import {afterAll, afterEach, beforeAll, vi} from '@shipfox/vitest/vi';
|
|
4
|
+
import {closeDb} from '#db/index.js';
|
|
5
|
+
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
createPostgresClient();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
vi.restoreAllMocks();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterAll(async () => {
|
|
15
|
+
closeDb();
|
|
16
|
+
await closePostgresClient();
|
|
17
|
+
});
|