@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,65 @@
|
|
|
1
|
+
import type {ProjectSourceBoundEvent} from '@shipfox/api-projects-dto';
|
|
2
|
+
import {onProjectSourceBound} from './on-project-source-bound.js';
|
|
3
|
+
|
|
4
|
+
const startMock = vi.fn();
|
|
5
|
+
|
|
6
|
+
vi.mock('@shipfox/node-temporal', () => ({
|
|
7
|
+
temporalClient: () => ({
|
|
8
|
+
workflow: {
|
|
9
|
+
start: startMock,
|
|
10
|
+
},
|
|
11
|
+
}),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
function buildPayload(): ProjectSourceBoundEvent {
|
|
15
|
+
return {
|
|
16
|
+
actorId: crypto.randomUUID(),
|
|
17
|
+
workspaceId: crypto.randomUUID(),
|
|
18
|
+
projectId: crypto.randomUUID(),
|
|
19
|
+
sourceConnectionId: crypto.randomUUID(),
|
|
20
|
+
provider: 'gitea',
|
|
21
|
+
externalRepositoryId: 'gitea:gitea-owner/platform',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('onProjectSourceBound', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
startMock.mockReset();
|
|
28
|
+
startMock.mockResolvedValue({});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('starts a definition sync workflow keyed on project + bind', async () => {
|
|
32
|
+
const payload = buildPayload();
|
|
33
|
+
|
|
34
|
+
const result = onProjectSourceBound(payload);
|
|
35
|
+
await result;
|
|
36
|
+
|
|
37
|
+
expect(startMock).toHaveBeenCalledTimes(1);
|
|
38
|
+
expect(startMock).toHaveBeenCalledWith('definitionSyncWorkflow', {
|
|
39
|
+
taskQueue: 'definitions-sync',
|
|
40
|
+
workflowId: `definition-sync:${payload.projectId}:bind`,
|
|
41
|
+
workflowIdConflictPolicy: 'USE_EXISTING',
|
|
42
|
+
workflowIdReusePolicy: 'ALLOW_DUPLICATE',
|
|
43
|
+
args: [
|
|
44
|
+
{
|
|
45
|
+
projectId: payload.projectId,
|
|
46
|
+
workspaceId: payload.workspaceId,
|
|
47
|
+
sourceConnectionId: payload.sourceConnectionId,
|
|
48
|
+
sourceExternalRepositoryId: payload.externalRepositoryId,
|
|
49
|
+
sourceRef: undefined,
|
|
50
|
+
sourceCommitSha: undefined,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('rethrows when the temporal client fails to start', async () => {
|
|
57
|
+
const failure = new Error('temporal unavailable');
|
|
58
|
+
startMock.mockRejectedValueOnce(failure);
|
|
59
|
+
const payload = buildPayload();
|
|
60
|
+
|
|
61
|
+
const result = onProjectSourceBound(payload);
|
|
62
|
+
|
|
63
|
+
await expect(result).rejects.toBe(failure);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type {ProjectSourceBoundEvent} from '@shipfox/api-projects-dto';
|
|
2
|
+
import {startDefinitionSync} from './start-definition-sync.js';
|
|
3
|
+
|
|
4
|
+
export async function onProjectSourceBound(payload: ProjectSourceBoundEvent): Promise<void> {
|
|
5
|
+
await startDefinitionSync({
|
|
6
|
+
projectId: payload.projectId,
|
|
7
|
+
workspaceId: payload.workspaceId,
|
|
8
|
+
sourceConnectionId: payload.sourceConnectionId,
|
|
9
|
+
externalRepositoryId: payload.externalRepositoryId,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type {ProjectSourceCommitObservedEvent} from '@shipfox/api-projects-dto';
|
|
2
|
+
import {onProjectSourceCommitObserved} from './on-project-source-commit-observed.js';
|
|
3
|
+
|
|
4
|
+
const startMock = vi.fn();
|
|
5
|
+
|
|
6
|
+
vi.mock('@shipfox/node-temporal', () => ({
|
|
7
|
+
temporalClient: () => ({
|
|
8
|
+
workflow: {
|
|
9
|
+
start: startMock,
|
|
10
|
+
},
|
|
11
|
+
}),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
function buildPayload(): ProjectSourceCommitObservedEvent {
|
|
15
|
+
return {
|
|
16
|
+
workspaceId: crypto.randomUUID(),
|
|
17
|
+
projectId: crypto.randomUUID(),
|
|
18
|
+
sourceConnectionId: crypto.randomUUID(),
|
|
19
|
+
provider: 'github',
|
|
20
|
+
externalRepositoryId: 'github:42',
|
|
21
|
+
ref: 'main',
|
|
22
|
+
headCommitSha: 'abc123',
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('onProjectSourceCommitObserved', () => {
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
startMock.mockReset();
|
|
29
|
+
startMock.mockResolvedValue({});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('starts a definition sync workflow keyed on project + source commit sha', async () => {
|
|
33
|
+
const payload = buildPayload();
|
|
34
|
+
|
|
35
|
+
const result = onProjectSourceCommitObserved(payload);
|
|
36
|
+
await result;
|
|
37
|
+
|
|
38
|
+
expect(startMock).toHaveBeenCalledTimes(1);
|
|
39
|
+
expect(startMock).toHaveBeenCalledWith('definitionSyncWorkflow', {
|
|
40
|
+
taskQueue: 'definitions-sync',
|
|
41
|
+
workflowId: `definition-sync:${payload.projectId}:${payload.headCommitSha}`,
|
|
42
|
+
workflowIdConflictPolicy: 'USE_EXISTING',
|
|
43
|
+
workflowIdReusePolicy: 'ALLOW_DUPLICATE',
|
|
44
|
+
args: [
|
|
45
|
+
{
|
|
46
|
+
projectId: payload.projectId,
|
|
47
|
+
workspaceId: payload.workspaceId,
|
|
48
|
+
sourceConnectionId: payload.sourceConnectionId,
|
|
49
|
+
sourceExternalRepositoryId: payload.externalRepositoryId,
|
|
50
|
+
sourceRef: payload.ref,
|
|
51
|
+
sourceCommitSha: payload.headCommitSha,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type {ProjectSourceCommitObservedEvent} from '@shipfox/api-projects-dto';
|
|
2
|
+
import {startDefinitionSync} from './start-definition-sync.js';
|
|
3
|
+
|
|
4
|
+
export async function onProjectSourceCommitObserved(
|
|
5
|
+
payload: ProjectSourceCommitObservedEvent,
|
|
6
|
+
): Promise<void> {
|
|
7
|
+
await startDefinitionSync({
|
|
8
|
+
projectId: payload.projectId,
|
|
9
|
+
workspaceId: payload.workspaceId,
|
|
10
|
+
sourceConnectionId: payload.sourceConnectionId,
|
|
11
|
+
externalRepositoryId: payload.externalRepositoryId,
|
|
12
|
+
sourceRef: payload.ref,
|
|
13
|
+
sourceCommitSha: payload.headCommitSha,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {temporalClient} from '@shipfox/node-temporal';
|
|
2
|
+
import {DEFINITION_SYNC_WORKFLOW, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';
|
|
3
|
+
|
|
4
|
+
export interface StartDefinitionSyncParams {
|
|
5
|
+
projectId: string;
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
sourceConnectionId: string;
|
|
8
|
+
externalRepositoryId: string;
|
|
9
|
+
sourceRef?: string | undefined;
|
|
10
|
+
sourceCommitSha?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function startDefinitionSync(params: StartDefinitionSyncParams): Promise<void> {
|
|
14
|
+
const workflowId = buildWorkflowId(params);
|
|
15
|
+
|
|
16
|
+
await temporalClient().workflow.start(DEFINITION_SYNC_WORKFLOW, {
|
|
17
|
+
taskQueue: DEFINITIONS_TASK_QUEUE,
|
|
18
|
+
workflowId,
|
|
19
|
+
workflowIdConflictPolicy: 'USE_EXISTING',
|
|
20
|
+
workflowIdReusePolicy: 'ALLOW_DUPLICATE',
|
|
21
|
+
args: [
|
|
22
|
+
{
|
|
23
|
+
projectId: params.projectId,
|
|
24
|
+
workspaceId: params.workspaceId,
|
|
25
|
+
sourceConnectionId: params.sourceConnectionId,
|
|
26
|
+
sourceExternalRepositoryId: params.externalRepositoryId,
|
|
27
|
+
sourceRef: params.sourceRef,
|
|
28
|
+
sourceCommitSha: params.sourceCommitSha,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildWorkflowId(params: StartDefinitionSyncParams): string {
|
|
35
|
+
return params.sourceCommitSha
|
|
36
|
+
? `definition-sync:${params.projectId}:${params.sourceCommitSha}`
|
|
37
|
+
: `definition-sync:${params.projectId}:bind`;
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
DiscoverWorkflowsActivityResult,
|
|
3
|
+
FetchAndApplyActivityInput,
|
|
4
|
+
FetchAndApplyActivityResult,
|
|
5
|
+
MarkSyncFailedActivityInput,
|
|
6
|
+
PrepareSyncResult,
|
|
7
|
+
SyncRefScopedInput,
|
|
8
|
+
SyncWorkflowInput,
|
|
9
|
+
} from './sync-activities.js';
|
|
10
|
+
export {createDefinitionSyncActivities} from './sync-activities.js';
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IntegrationProviderError,
|
|
3
|
+
type IntegrationSourceControlService,
|
|
4
|
+
} from '@shipfox/api-integration-core';
|
|
5
|
+
import {ApplicationFailure} from '@temporalio/common';
|
|
6
|
+
import {sql} from 'drizzle-orm';
|
|
7
|
+
import {db, definitionSyncStates} from '#db/index.js';
|
|
8
|
+
import {workflowDefinitions} from '#db/schema/definitions.js';
|
|
9
|
+
import {createDefinitionSyncActivities} from './sync-activities.js';
|
|
10
|
+
|
|
11
|
+
vi.mock('@temporalio/activity', () => ({
|
|
12
|
+
Context: {
|
|
13
|
+
current: () => ({heartbeat: vi.fn()}),
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
const validYaml = `
|
|
18
|
+
name: CI
|
|
19
|
+
runner: ubuntu-latest
|
|
20
|
+
jobs:
|
|
21
|
+
build:
|
|
22
|
+
steps:
|
|
23
|
+
- run: pnpm test
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
function sourceControl(
|
|
27
|
+
overrides: Partial<IntegrationSourceControlService> = {},
|
|
28
|
+
): IntegrationSourceControlService {
|
|
29
|
+
return {
|
|
30
|
+
getConnection: vi.fn(),
|
|
31
|
+
listRepositories: vi.fn(),
|
|
32
|
+
resolveRepository: vi.fn(() =>
|
|
33
|
+
Promise.resolve({
|
|
34
|
+
connection: {
|
|
35
|
+
id: 'connection-1',
|
|
36
|
+
workspaceId: 'workspace-1',
|
|
37
|
+
provider: 'gitea',
|
|
38
|
+
externalAccountId: 'gitea-owner',
|
|
39
|
+
slug: 'gitea_owner',
|
|
40
|
+
displayName: 'Gitea',
|
|
41
|
+
lifecycleStatus: 'active' as const,
|
|
42
|
+
createdAt: new Date(),
|
|
43
|
+
updatedAt: new Date(),
|
|
44
|
+
},
|
|
45
|
+
repository: {
|
|
46
|
+
externalRepositoryId: 'gitea:gitea-owner/platform',
|
|
47
|
+
owner: 'gitea-owner',
|
|
48
|
+
name: 'platform',
|
|
49
|
+
fullName: 'gitea-owner/platform',
|
|
50
|
+
defaultBranch: 'main',
|
|
51
|
+
visibility: 'private' as const,
|
|
52
|
+
cloneUrl: 'https://gitea.local/gitea-owner/platform.git',
|
|
53
|
+
htmlUrl: 'https://gitea.local/gitea-owner/platform',
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
|
+
listFiles: vi.fn(() =>
|
|
58
|
+
Promise.resolve({
|
|
59
|
+
files: [{path: '.shipfox/workflows/ci.yml', type: 'file' as const, size: validYaml.length}],
|
|
60
|
+
nextCursor: null,
|
|
61
|
+
}),
|
|
62
|
+
),
|
|
63
|
+
fetchFile: vi.fn(() =>
|
|
64
|
+
Promise.resolve({path: '.shipfox/workflows/ci.yml', ref: 'main', content: validYaml}),
|
|
65
|
+
),
|
|
66
|
+
createCheckoutSpec: vi.fn(),
|
|
67
|
+
...overrides,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
describe('definition sync activities', () => {
|
|
72
|
+
let projectId: string;
|
|
73
|
+
let sourceConnectionId: string;
|
|
74
|
+
|
|
75
|
+
beforeEach(() => {
|
|
76
|
+
projectId = crypto.randomUUID();
|
|
77
|
+
sourceConnectionId = crypto.randomUUID();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('prepareDefinitionSync', () => {
|
|
81
|
+
it('marks the sync state as syncing and returns the resolved ref', async () => {
|
|
82
|
+
const activities = createDefinitionSyncActivities(sourceControl());
|
|
83
|
+
|
|
84
|
+
const result = await activities.prepareDefinitionSync({
|
|
85
|
+
projectId,
|
|
86
|
+
workspaceId: crypto.randomUUID(),
|
|
87
|
+
sourceConnectionId,
|
|
88
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(result).toEqual({sourceRef: 'main', sourceCommitSha: undefined});
|
|
92
|
+
const rows = await db()
|
|
93
|
+
.select()
|
|
94
|
+
.from(definitionSyncStates)
|
|
95
|
+
.where(sql`${definitionSyncStates.projectId} = ${projectId}`);
|
|
96
|
+
expect(rows).toHaveLength(1);
|
|
97
|
+
expect(rows[0]?.status).toBe('syncing');
|
|
98
|
+
expect(rows[0]?.ref).toBe('main');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('keeps source ref and source commit sha separate for commit-triggered sync', async () => {
|
|
102
|
+
const source = sourceControl();
|
|
103
|
+
const activities = createDefinitionSyncActivities(source);
|
|
104
|
+
|
|
105
|
+
const result = await activities.prepareDefinitionSync({
|
|
106
|
+
projectId,
|
|
107
|
+
workspaceId: crypto.randomUUID(),
|
|
108
|
+
sourceConnectionId,
|
|
109
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
110
|
+
sourceRef: 'main',
|
|
111
|
+
sourceCommitSha: 'abc123',
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(result).toEqual({sourceRef: 'main', sourceCommitSha: 'abc123'});
|
|
115
|
+
expect(source.resolveRepository).not.toHaveBeenCalled();
|
|
116
|
+
const rows = await db()
|
|
117
|
+
.select()
|
|
118
|
+
.from(definitionSyncStates)
|
|
119
|
+
.where(sql`${definitionSyncStates.projectId} = ${projectId}`);
|
|
120
|
+
expect(rows[0]?.ref).toBe('main');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('translates retryable resolveRepository failures into retryable ApplicationFailures', async () => {
|
|
124
|
+
const activities = createDefinitionSyncActivities(
|
|
125
|
+
sourceControl({
|
|
126
|
+
resolveRepository: vi.fn(() => {
|
|
127
|
+
return Promise.reject(new Error('temporary outage'));
|
|
128
|
+
}),
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const result = activities.prepareDefinitionSync({
|
|
133
|
+
projectId,
|
|
134
|
+
workspaceId: crypto.randomUUID(),
|
|
135
|
+
sourceConnectionId,
|
|
136
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
await expect(result).rejects.toBeInstanceOf(ApplicationFailure);
|
|
140
|
+
await expect(result).rejects.toMatchObject({
|
|
141
|
+
nonRetryable: false,
|
|
142
|
+
type: 'unknown',
|
|
143
|
+
message: 'temporary outage',
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('preserves retryable provider error codes for workflow-level failure persistence', async () => {
|
|
148
|
+
const activities = createDefinitionSyncActivities(
|
|
149
|
+
sourceControl({
|
|
150
|
+
resolveRepository: vi.fn(() => {
|
|
151
|
+
return Promise.reject(
|
|
152
|
+
new IntegrationProviderError('timeout', 'GitHub request timed out'),
|
|
153
|
+
);
|
|
154
|
+
}),
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const result = activities.prepareDefinitionSync({
|
|
159
|
+
projectId,
|
|
160
|
+
workspaceId: crypto.randomUUID(),
|
|
161
|
+
sourceConnectionId,
|
|
162
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
await expect(result).rejects.toMatchObject({
|
|
166
|
+
nonRetryable: false,
|
|
167
|
+
type: 'provider-timeout',
|
|
168
|
+
message: 'GitHub request timed out',
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
describe('fetchAndApplyDefinitionWorkflows', () => {
|
|
174
|
+
it('upserts workflow definitions and soft-deletes orphans', async () => {
|
|
175
|
+
const activities = createDefinitionSyncActivities(sourceControl());
|
|
176
|
+
|
|
177
|
+
const result = await activities.fetchAndApplyDefinitionWorkflows({
|
|
178
|
+
projectId,
|
|
179
|
+
workspaceId: crypto.randomUUID(),
|
|
180
|
+
sourceConnectionId,
|
|
181
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
182
|
+
sourceRef: 'main',
|
|
183
|
+
paths: ['.shipfox/workflows/ci.yml'],
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
expect(result.appliedCount).toBe(1);
|
|
187
|
+
expect(result.deletedCount).toBe(0);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('translates DefinitionSyncPermanentError into a non-retryable ApplicationFailure', async () => {
|
|
191
|
+
const activities = createDefinitionSyncActivities(
|
|
192
|
+
sourceControl({
|
|
193
|
+
fetchFile: vi.fn(() =>
|
|
194
|
+
Promise.resolve({
|
|
195
|
+
path: '.shipfox/workflows/bad.yml',
|
|
196
|
+
ref: 'main',
|
|
197
|
+
content: 'name: Bad\n broken:\nindent',
|
|
198
|
+
}),
|
|
199
|
+
),
|
|
200
|
+
}),
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const result = activities.fetchAndApplyDefinitionWorkflows({
|
|
204
|
+
projectId,
|
|
205
|
+
workspaceId: crypto.randomUUID(),
|
|
206
|
+
sourceConnectionId,
|
|
207
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
208
|
+
sourceRef: 'main',
|
|
209
|
+
sourceCommitSha: 'abc123',
|
|
210
|
+
paths: ['.shipfox/workflows/ci.yml'],
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
await expect(result).rejects.toBeInstanceOf(ApplicationFailure);
|
|
214
|
+
await expect(result).rejects.toMatchObject({nonRetryable: true, type: 'invalid-definition'});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('fetches from source commit sha while persisting under source ref', async () => {
|
|
218
|
+
const source = sourceControl();
|
|
219
|
+
const activities = createDefinitionSyncActivities(source);
|
|
220
|
+
|
|
221
|
+
const result = await activities.fetchAndApplyDefinitionWorkflows({
|
|
222
|
+
projectId,
|
|
223
|
+
workspaceId: crypto.randomUUID(),
|
|
224
|
+
sourceConnectionId,
|
|
225
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
226
|
+
sourceRef: 'main',
|
|
227
|
+
sourceCommitSha: 'abc123',
|
|
228
|
+
paths: ['.shipfox/workflows/ci.yml'],
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const rows = await db()
|
|
232
|
+
.select()
|
|
233
|
+
.from(workflowDefinitions)
|
|
234
|
+
.where(sql`${workflowDefinitions.projectId} = ${projectId}`);
|
|
235
|
+
expect(result.appliedCount).toBe(1);
|
|
236
|
+
expect(source.fetchFile).toHaveBeenCalledWith(
|
|
237
|
+
expect.objectContaining({ref: 'abc123', path: '.shipfox/workflows/ci.yml'}),
|
|
238
|
+
);
|
|
239
|
+
expect(rows[0]?.ref).toBe('main');
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
describe('markDefinitionSyncFailed', () => {
|
|
244
|
+
it('persists last_error_code and last_error_message verbatim', async () => {
|
|
245
|
+
const activities = createDefinitionSyncActivities(sourceControl());
|
|
246
|
+
await activities.prepareDefinitionSync({
|
|
247
|
+
projectId,
|
|
248
|
+
workspaceId: crypto.randomUUID(),
|
|
249
|
+
sourceConnectionId,
|
|
250
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
const result = activities.markDefinitionSyncFailed({
|
|
254
|
+
projectId,
|
|
255
|
+
workspaceId: crypto.randomUUID(),
|
|
256
|
+
sourceConnectionId,
|
|
257
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
258
|
+
sourceRef: 'main',
|
|
259
|
+
code: 'invalid-definition',
|
|
260
|
+
message: 'Invalid workflow at .shipfox/workflows/bad.yml',
|
|
261
|
+
});
|
|
262
|
+
await result;
|
|
263
|
+
|
|
264
|
+
const rows = await db()
|
|
265
|
+
.select()
|
|
266
|
+
.from(definitionSyncStates)
|
|
267
|
+
.where(sql`${definitionSyncStates.projectId} = ${projectId}`);
|
|
268
|
+
expect(rows[0]?.status).toBe('failed');
|
|
269
|
+
expect(rows[0]?.lastErrorCode).toBe('invalid-definition');
|
|
270
|
+
expect(rows[0]?.lastErrorMessage).toBe('Invalid workflow at .shipfox/workflows/bad.yml');
|
|
271
|
+
expect(rows[0]?.finishedAt).not.toBeNull();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('persists failures with the unresolved sentinel ref when no ref was produced', async () => {
|
|
275
|
+
const activities = createDefinitionSyncActivities(sourceControl());
|
|
276
|
+
|
|
277
|
+
const result = activities.markDefinitionSyncFailed({
|
|
278
|
+
projectId,
|
|
279
|
+
workspaceId: crypto.randomUUID(),
|
|
280
|
+
sourceConnectionId,
|
|
281
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
282
|
+
sourceRef: null,
|
|
283
|
+
code: 'connection-unavailable',
|
|
284
|
+
message: 'connection disabled before resolving repository',
|
|
285
|
+
});
|
|
286
|
+
await result;
|
|
287
|
+
|
|
288
|
+
const rows = await db()
|
|
289
|
+
.select()
|
|
290
|
+
.from(definitionSyncStates)
|
|
291
|
+
.where(sql`${definitionSyncStates.projectId} = ${projectId}`);
|
|
292
|
+
expect(rows).toHaveLength(1);
|
|
293
|
+
expect(rows[0]?.ref).toBe('__unresolved__');
|
|
294
|
+
expect(rows[0]?.status).toBe('failed');
|
|
295
|
+
expect(rows[0]?.lastErrorCode).toBe('connection-unavailable');
|
|
296
|
+
expect(rows[0]?.lastErrorMessage).toBe('connection disabled before resolving repository');
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
describe('markDefinitionSyncSucceeded', () => {
|
|
301
|
+
it('clears stale error fields when transitioning to succeeded', async () => {
|
|
302
|
+
const activities = createDefinitionSyncActivities(sourceControl());
|
|
303
|
+
await activities.prepareDefinitionSync({
|
|
304
|
+
projectId,
|
|
305
|
+
workspaceId: crypto.randomUUID(),
|
|
306
|
+
sourceConnectionId,
|
|
307
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
308
|
+
});
|
|
309
|
+
await activities.markDefinitionSyncFailed({
|
|
310
|
+
projectId,
|
|
311
|
+
workspaceId: crypto.randomUUID(),
|
|
312
|
+
sourceConnectionId,
|
|
313
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
314
|
+
sourceRef: 'main',
|
|
315
|
+
code: 'invalid-definition',
|
|
316
|
+
message: 'something',
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const result = activities.markDefinitionSyncSucceeded({
|
|
320
|
+
projectId,
|
|
321
|
+
workspaceId: crypto.randomUUID(),
|
|
322
|
+
sourceConnectionId,
|
|
323
|
+
sourceExternalRepositoryId: 'gitea:gitea-owner/platform',
|
|
324
|
+
sourceRef: 'main',
|
|
325
|
+
});
|
|
326
|
+
await result;
|
|
327
|
+
|
|
328
|
+
const rows = await db()
|
|
329
|
+
.select()
|
|
330
|
+
.from(definitionSyncStates)
|
|
331
|
+
.where(sql`${definitionSyncStates.projectId} = ${projectId}`);
|
|
332
|
+
expect(rows[0]?.status).toBe('succeeded');
|
|
333
|
+
expect(rows[0]?.lastErrorCode).toBeNull();
|
|
334
|
+
expect(rows[0]?.lastErrorMessage).toBeNull();
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
});
|