@shipfox/api-workflows 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 +311 -0
- package/LICENSE +21 -0
- package/dist/core/agent-tool-capability-warning.d.ts +7 -0
- package/dist/core/agent-tool-capability-warning.d.ts.map +1 -0
- package/dist/core/agent-tool-capability-warning.js +149 -0
- package/dist/core/agent-tool-capability-warning.js.map +1 -0
- package/dist/core/agent-tools.d.ts +51 -0
- package/dist/core/agent-tools.d.ts.map +1 -0
- package/dist/core/agent-tools.js +296 -0
- package/dist/core/agent-tools.js.map +1 -0
- package/dist/core/checkout.d.ts +29 -0
- package/dist/core/checkout.d.ts.map +1 -0
- package/dist/core/checkout.js +42 -0
- package/dist/core/checkout.js.map +1 -0
- package/dist/core/condition-trace.d.ts +13 -0
- package/dist/core/condition-trace.d.ts.map +1 -0
- package/dist/core/condition-trace.js +51 -0
- package/dist/core/condition-trace.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 +3 -0
- package/dist/core/entities/index.js.map +1 -0
- package/dist/core/entities/job-execution.d.ts +30 -0
- package/dist/core/entities/job-execution.d.ts.map +1 -0
- package/dist/core/entities/job-execution.js +3 -0
- package/dist/core/entities/job-execution.js.map +1 -0
- package/dist/core/entities/job-listener-event.d.ts +15 -0
- package/dist/core/entities/job-listener-event.d.ts.map +1 -0
- package/dist/core/entities/job-listener-event.js +3 -0
- package/dist/core/entities/job-listener-event.js.map +1 -0
- package/dist/core/entities/job.d.ts +54 -0
- package/dist/core/entities/job.d.ts.map +1 -0
- package/dist/core/entities/job.js +29 -0
- package/dist/core/entities/job.js.map +1 -0
- package/dist/core/entities/step.d.ts +86 -0
- package/dist/core/entities/step.d.ts.map +1 -0
- package/dist/core/entities/step.js +12 -0
- package/dist/core/entities/step.js.map +1 -0
- package/dist/core/entities/workflow-run-attempt.d.ts +20 -0
- package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -0
- package/dist/core/entities/workflow-run-attempt.js +3 -0
- package/dist/core/entities/workflow-run-attempt.js.map +1 -0
- package/dist/core/entities/workflow-run.d.ts +66 -0
- package/dist/core/entities/workflow-run.d.ts.map +1 -0
- package/dist/core/entities/workflow-run.js +10 -0
- package/dist/core/entities/workflow-run.js.map +1 -0
- package/dist/core/errors.d.ts +85 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +134 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +14 -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/job-execution-outcome.d.ts +29 -0
- package/dist/core/job-execution-outcome.d.ts.map +1 -0
- package/dist/core/job-execution-outcome.js +31 -0
- package/dist/core/job-execution-outcome.js.map +1 -0
- package/dist/core/job-execution.d.ts +37 -0
- package/dist/core/job-execution.d.ts.map +1 -0
- package/dist/core/job-execution.js +425 -0
- package/dist/core/job-execution.js.map +1 -0
- package/dist/core/job-transition/decide-job-activation.d.ts +29 -0
- package/dist/core/job-transition/decide-job-activation.d.ts.map +1 -0
- package/dist/core/job-transition/decide-job-activation.js +51 -0
- package/dist/core/job-transition/decide-job-activation.js.map +1 -0
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts +18 -0
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -0
- package/dist/core/job-transition/derive-job-execution-outputs.js +23 -0
- package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -0
- package/dist/core/job-transition/derive-job-success.d.ts +16 -0
- package/dist/core/job-transition/derive-job-success.d.ts.map +1 -0
- package/dist/core/job-transition/derive-job-success.js +47 -0
- package/dist/core/job-transition/derive-job-success.js.map +1 -0
- package/dist/core/job-transition/index.d.ts +5 -0
- package/dist/core/job-transition/index.d.ts.map +1 -0
- package/dist/core/job-transition/index.js +6 -0
- package/dist/core/job-transition/index.js.map +1 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.d.ts +4 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.d.ts.map +1 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.js +8 -0
- package/dist/core/job-transition/runtime-completion-status-for-job.js.map +1 -0
- package/dist/core/listener-execution-materialization.d.ts +30 -0
- package/dist/core/listener-execution-materialization.d.ts.map +1 -0
- package/dist/core/listener-execution-materialization.js +87 -0
- package/dist/core/listener-execution-materialization.js.map +1 -0
- package/dist/core/run-workflow.d.ts +11 -0
- package/dist/core/run-workflow.d.ts.map +1 -0
- package/dist/core/run-workflow.js +28 -0
- package/dist/core/run-workflow.js.map +1 -0
- package/dist/core/source-control.d.ts +5 -0
- package/dist/core/source-control.d.ts.map +1 -0
- package/dist/core/source-control.js +19 -0
- package/dist/core/source-control.js.map +1 -0
- package/dist/core/step-config/agent.d.ts +49 -0
- package/dist/core/step-config/agent.d.ts.map +1 -0
- package/dist/core/step-config/agent.js +337 -0
- package/dist/core/step-config/agent.js.map +1 -0
- package/dist/core/step-config/assemble-run-context.d.ts +94 -0
- package/dist/core/step-config/assemble-run-context.d.ts.map +1 -0
- package/dist/core/step-config/assemble-run-context.js +393 -0
- package/dist/core/step-config/assemble-run-context.js.map +1 -0
- package/dist/core/step-config/complete-step-dispatch-config.d.ts +13 -0
- package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -0
- package/dist/core/step-config/complete-step-dispatch-config.js +38 -0
- package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -0
- package/dist/core/step-config/fields.d.ts +38 -0
- package/dist/core/step-config/fields.d.ts.map +1 -0
- package/dist/core/step-config/fields.js +72 -0
- package/dist/core/step-config/fields.js.map +1 -0
- package/dist/core/step-config/index.d.ts +8 -0
- package/dist/core/step-config/index.d.ts.map +1 -0
- package/dist/core/step-config/index.js +7 -0
- package/dist/core/step-config/index.js.map +1 -0
- package/dist/core/step-config/materialize-job-execution-steps.d.ts +35 -0
- package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -0
- package/dist/core/step-config/materialize-job-execution-steps.js +92 -0
- package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -0
- package/dist/core/step-config/materialize-workflow-model.d.ts +42 -0
- package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -0
- package/dist/core/step-config/materialize-workflow-model.js +96 -0
- package/dist/core/step-config/materialize-workflow-model.js.map +1 -0
- package/dist/core/step-config/resolve-job-execution-name.d.ts +18 -0
- package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -0
- package/dist/core/step-config/resolve-job-execution-name.js +36 -0
- package/dist/core/step-config/resolve-job-execution-name.js.map +1 -0
- package/dist/core/step-config/resolve-step-config.d.ts +33 -0
- package/dist/core/step-config/resolve-step-config.d.ts.map +1 -0
- package/dist/core/step-config/resolve-step-config.js +164 -0
- package/dist/core/step-config/resolve-step-config.js.map +1 -0
- package/dist/core/step-config/run.d.ts +39 -0
- package/dist/core/step-config/run.d.ts.map +1 -0
- package/dist/core/step-config/run.js +360 -0
- package/dist/core/step-config/run.js.map +1 -0
- package/dist/core/step-config/workflow-evaluation-context.d.ts +6 -0
- package/dist/core/step-config/workflow-evaluation-context.d.ts.map +1 -0
- package/dist/core/step-config/workflow-evaluation-context.js +3 -0
- package/dist/core/step-config/workflow-evaluation-context.js.map +1 -0
- package/dist/core/step-transition/apply-step-transition.d.ts +26 -0
- package/dist/core/step-transition/apply-step-transition.d.ts.map +1 -0
- package/dist/core/step-transition/apply-step-transition.js +141 -0
- package/dist/core/step-transition/apply-step-transition.js.map +1 -0
- package/dist/core/step-transition/decide-step-transition.d.ts +71 -0
- package/dist/core/step-transition/decide-step-transition.d.ts.map +1 -0
- package/dist/core/step-transition/decide-step-transition.js +110 -0
- package/dist/core/step-transition/decide-step-transition.js.map +1 -0
- package/dist/core/step-transition/evaluate-gate.d.ts +28 -0
- package/dist/core/step-transition/evaluate-gate.d.ts.map +1 -0
- package/dist/core/step-transition/evaluate-gate.js +159 -0
- package/dist/core/step-transition/evaluate-gate.js.map +1 -0
- package/dist/core/step-transition/read-step-outputs.d.ts +3 -0
- package/dist/core/step-transition/read-step-outputs.d.ts.map +1 -0
- package/dist/core/step-transition/read-step-outputs.js +24 -0
- package/dist/core/step-transition/read-step-outputs.js.map +1 -0
- package/dist/core/workflow-run-creation.d.ts +43 -0
- package/dist/core/workflow-run-creation.d.ts.map +1 -0
- package/dist/core/workflow-run-creation.js +80 -0
- package/dist/core/workflow-run-creation.js.map +1 -0
- package/dist/core/workflow-scheduling/index.d.ts +5 -0
- package/dist/core/workflow-scheduling/index.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/index.js +4 -0
- package/dist/core/workflow-scheduling/index.js.map +1 -0
- package/dist/core/workflow-scheduling/run-progress.d.ts +20 -0
- package/dist/core/workflow-scheduling/run-progress.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/run-progress.js +40 -0
- package/dist/core/workflow-scheduling/run-progress.js.map +1 -0
- package/dist/core/workflow-scheduling/runtime-dag.d.ts +10 -0
- package/dist/core/workflow-scheduling/runtime-dag.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/runtime-dag.js +3 -0
- package/dist/core/workflow-scheduling/runtime-dag.js.map +1 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.d.ts +16 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.js +3 -0
- package/dist/core/workflow-scheduling/runtime-scheduling-command.js.map +1 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.d.ts +9 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.d.ts.map +1 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.js +72 -0
- package/dist/core/workflow-scheduling/schedule-runtime-dag.js.map +1 -0
- package/dist/db/db.d.ts +4959 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +37 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/index.d.ts +9 -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/job-listener-events.d.ts +18 -0
- package/dist/db/job-listener-events.d.ts.map +1 -0
- package/dist/db/job-listener-events.js +59 -0
- package/dist/db/job-listener-events.js.map +1 -0
- package/dist/db/job-listeners.d.ts +55 -0
- package/dist/db/job-listeners.d.ts.map +1 -0
- package/dist/db/job-listeners.js +358 -0
- package/dist/db/job-listeners.js.map +1 -0
- package/dist/db/outbox-writes.d.ts +12 -0
- package/dist/db/outbox-writes.d.ts.map +1 -0
- package/dist/db/outbox-writes.js +20 -0
- package/dist/db/outbox-writes.js.map +1 -0
- package/dist/db/runner-lease-table.d.ts +469 -0
- package/dist/db/runner-lease-table.d.ts.map +1 -0
- package/dist/db/runner-lease-table.js +42 -0
- package/dist/db/runner-lease-table.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/job-executions.d.ts +311 -0
- package/dist/db/schema/job-executions.d.ts.map +1 -0
- package/dist/db/schema/job-executions.js +76 -0
- package/dist/db/schema/job-executions.js.map +1 -0
- package/dist/db/schema/job-listener-events.d.ts +200 -0
- package/dist/db/schema/job-listener-events.d.ts.map +1 -0
- package/dist/db/schema/job-listener-events.js +50 -0
- package/dist/db/schema/job-listener-events.js.map +1 -0
- package/dist/db/schema/jobs.d.ts +542 -0
- package/dist/db/schema/jobs.d.ts.map +1 -0
- package/dist/db/schema/jobs.js +121 -0
- package/dist/db/schema/jobs.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/step-attempts.d.ts +330 -0
- package/dist/db/schema/step-attempts.d.ts.map +1 -0
- package/dist/db/schema/step-attempts.js +80 -0
- package/dist/db/schema/step-attempts.js.map +1 -0
- package/dist/db/schema/steps.d.ts +352 -0
- package/dist/db/schema/steps.d.ts.map +1 -0
- package/dist/db/schema/steps.js +80 -0
- package/dist/db/schema/steps.js.map +1 -0
- package/dist/db/schema/workflow-run-attempts.d.ts +239 -0
- package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -0
- package/dist/db/schema/workflow-run-attempts.js +53 -0
- package/dist/db/schema/workflow-run-attempts.js.map +1 -0
- package/dist/db/schema/workflow-runs.d.ts +360 -0
- package/dist/db/schema/workflow-runs.d.ts.map +1 -0
- package/dist/db/schema/workflow-runs.js +85 -0
- package/dist/db/schema/workflow-runs.js.map +1 -0
- package/dist/db/workflow-runs/job-executions.d.ts +49 -0
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -0
- package/dist/db/workflow-runs/job-executions.js +271 -0
- package/dist/db/workflow-runs/job-executions.js.map +1 -0
- package/dist/db/workflow-runs/jobs.d.ts +60 -0
- package/dist/db/workflow-runs/jobs.d.ts.map +1 -0
- package/dist/db/workflow-runs/jobs.js +288 -0
- package/dist/db/workflow-runs/jobs.js.map +1 -0
- package/dist/db/workflow-runs/outbox.d.ts +20 -0
- package/dist/db/workflow-runs/outbox.d.ts.map +1 -0
- package/dist/db/workflow-runs/outbox.js +68 -0
- package/dist/db/workflow-runs/outbox.js.map +1 -0
- package/dist/db/workflow-runs/queries.d.ts +71 -0
- package/dist/db/workflow-runs/queries.d.ts.map +1 -0
- package/dist/db/workflow-runs/queries.js +253 -0
- package/dist/db/workflow-runs/queries.js.map +1 -0
- package/dist/db/workflow-runs/run-create.d.ts +32 -0
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-create.js +288 -0
- package/dist/db/workflow-runs/run-create.js.map +1 -0
- package/dist/db/workflow-runs/run-graph.d.ts +27 -0
- package/dist/db/workflow-runs/run-graph.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-graph.js +63 -0
- package/dist/db/workflow-runs/run-graph.js.map +1 -0
- package/dist/db/workflow-runs/run-rerun.d.ts +8 -0
- package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-rerun.js +207 -0
- package/dist/db/workflow-runs/run-rerun.js.map +1 -0
- package/dist/db/workflow-runs/run-status.d.ts +24 -0
- package/dist/db/workflow-runs/run-status.d.ts.map +1 -0
- package/dist/db/workflow-runs/run-status.js +249 -0
- package/dist/db/workflow-runs/run-status.js.map +1 -0
- package/dist/db/workflow-runs/runs.d.ts +7 -0
- package/dist/db/workflow-runs/runs.d.ts.map +1 -0
- package/dist/db/workflow-runs/runs.js +5 -0
- package/dist/db/workflow-runs/runs.js.map +1 -0
- package/dist/db/workflow-runs/shared.d.ts +24 -0
- package/dist/db/workflow-runs/shared.d.ts.map +1 -0
- package/dist/db/workflow-runs/shared.js +50 -0
- package/dist/db/workflow-runs/shared.js.map +1 -0
- package/dist/db/workflow-runs/steps.d.ts +83 -0
- package/dist/db/workflow-runs/steps.d.ts.map +1 -0
- package/dist/db/workflow-runs/steps.js +246 -0
- package/dist/db/workflow-runs/steps.js.map +1 -0
- package/dist/db/workflow-runs.d.ts +12 -0
- package/dist/db/workflow-runs.d.ts.map +1 -0
- package/dist/db/workflow-runs.js +8 -0
- package/dist/db/workflow-runs.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +3 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +20 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +127 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/metrics/service.d.ts +2 -0
- package/dist/metrics/service.d.ts.map +1 -0
- package/dist/metrics/service.js +30 -0
- package/dist/metrics/service.js.map +1 -0
- package/dist/presentation/dto/checkout-token.d.ts +6 -0
- package/dist/presentation/dto/checkout-token.d.ts.map +1 -0
- package/dist/presentation/dto/checkout-token.js +74 -0
- package/dist/presentation/dto/checkout-token.js.map +1 -0
- package/dist/presentation/dto/index.d.ts +4 -0
- package/dist/presentation/dto/index.d.ts.map +1 -0
- package/dist/presentation/dto/index.js +5 -0
- package/dist/presentation/dto/index.js.map +1 -0
- package/dist/presentation/dto/job.d.ts +6 -0
- package/dist/presentation/dto/job.d.ts.map +1 -0
- package/dist/presentation/dto/job.js +59 -0
- package/dist/presentation/dto/job.js.map +1 -0
- package/dist/presentation/dto/step.d.ts +6 -0
- package/dist/presentation/dto/step.d.ts.map +1 -0
- package/dist/presentation/dto/step.js +162 -0
- package/dist/presentation/dto/step.js.map +1 -0
- package/dist/presentation/dto/workflow-run.d.ts +6 -0
- package/dist/presentation/dto/workflow-run.d.ts.map +1 -0
- package/dist/presentation/dto/workflow-run.js +35 -0
- package/dist/presentation/dto/workflow-run.js.map +1 -0
- package/dist/presentation/index.d.ts +3 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +4 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts +2 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.js +71 -0
- package/dist/presentation/routes/agent-runtime-config.js.map +1 -0
- package/dist/presentation/routes/cancel-run.d.ts +2 -0
- package/dist/presentation/routes/cancel-run.d.ts.map +1 -0
- package/dist/presentation/routes/cancel-run.js +46 -0
- package/dist/presentation/routes/cancel-run.js.map +1 -0
- package/dist/presentation/routes/checkout-token.d.ts +2 -0
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -0
- package/dist/presentation/routes/checkout-token.js +64 -0
- package/dist/presentation/routes/checkout-token.js.map +1 -0
- package/dist/presentation/routes/get-run-aggregates.d.ts +2 -0
- package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -0
- package/dist/presentation/routes/get-run-aggregates.js +60 -0
- package/dist/presentation/routes/get-run-aggregates.js.map +1 -0
- package/dist/presentation/routes/get-run.d.ts +2 -0
- package/dist/presentation/routes/get-run.d.ts.map +1 -0
- package/dist/presentation/routes/get-run.js +60 -0
- package/dist/presentation/routes/get-run.js.map +1 -0
- package/dist/presentation/routes/get-step-secrets.d.ts +2 -0
- package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -0
- package/dist/presentation/routes/get-step-secrets.js +115 -0
- package/dist/presentation/routes/get-step-secrets.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +4 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +41 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/leased-step.d.ts +14 -0
- package/dist/presentation/routes/leased-step.d.ts.map +1 -0
- package/dist/presentation/routes/leased-step.js +50 -0
- package/dist/presentation/routes/leased-step.js.map +1 -0
- package/dist/presentation/routes/list-run-attempts.d.ts +2 -0
- package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -0
- package/dist/presentation/routes/list-run-attempts.js +35 -0
- package/dist/presentation/routes/list-run-attempts.js.map +1 -0
- package/dist/presentation/routes/list-runs.d.ts +2 -0
- package/dist/presentation/routes/list-runs.d.ts.map +1 -0
- package/dist/presentation/routes/list-runs.js +70 -0
- package/dist/presentation/routes/list-runs.js.map +1 -0
- package/dist/presentation/routes/next-step.d.ts +2 -0
- package/dist/presentation/routes/next-step.d.ts.map +1 -0
- package/dist/presentation/routes/next-step.js +65 -0
- package/dist/presentation/routes/next-step.js.map +1 -0
- package/dist/presentation/routes/report-step.d.ts +2 -0
- package/dist/presentation/routes/report-step.d.ts.map +1 -0
- package/dist/presentation/routes/report-step.js +73 -0
- package/dist/presentation/routes/report-step.js.map +1 -0
- package/dist/presentation/routes/require-accessible-run.d.ts +7 -0
- package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -0
- package/dist/presentation/routes/require-accessible-run.js +25 -0
- package/dist/presentation/routes/require-accessible-run.js.map +1 -0
- package/dist/presentation/routes/rerun-run.d.ts +2 -0
- package/dist/presentation/routes/rerun-run.d.ts.map +1 -0
- package/dist/presentation/routes/rerun-run.js +56 -0
- package/dist/presentation/routes/rerun-run.js.map +1 -0
- package/dist/presentation/subscribers/index.d.ts +8 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -0
- package/dist/presentation/subscribers/index.js +9 -0
- package/dist/presentation/subscribers/index.js.map +1 -0
- package/dist/presentation/subscribers/on-job-event-delivered.d.ts +3 -0
- package/dist/presentation/subscribers/on-job-event-delivered.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-job-event-delivered.js +24 -0
- package/dist/presentation/subscribers/on-job-event-delivered.js.map +1 -0
- package/dist/presentation/subscribers/on-job-steps-settled.d.ts +3 -0
- package/dist/presentation/subscribers/on-job-steps-settled.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-job-steps-settled.js +36 -0
- package/dist/presentation/subscribers/on-job-steps-settled.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.js +20 -0
- package/dist/presentation/subscribers/on-runner-job-claimed.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.js +35 -0
- package/dist/presentation/subscribers/on-runner-job-lease-expired.js.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-queued.d.ts +3 -0
- package/dist/presentation/subscribers/on-runner-job-queued.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-runner-job-queued.js +20 -0
- package/dist/presentation/subscribers/on-runner-job-queued.js.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.d.ts +3 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.js +35 -0
- package/dist/presentation/subscribers/on-workflow-run-attempt-created.js.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.d.ts +3 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.js +25 -0
- package/dist/presentation/subscribers/on-workflow-run-cancelled.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +23 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +26 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/orchestration-activities.d.ts +130 -0
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -0
- package/dist/temporal/activities/orchestration-activities.js +188 -0
- package/dist/temporal/activities/orchestration-activities.js.map +1 -0
- package/dist/temporal/constants.d.ts +7 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +8 -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/workflow-not-found.d.ts +2 -0
- package/dist/temporal/workflow-not-found.d.ts.map +1 -0
- package/dist/temporal/workflow-not-found.js +10 -0
- package/dist/temporal/workflow-not-found.js.map +1 -0
- package/dist/temporal/workflows/deadline.d.ts +3 -0
- package/dist/temporal/workflows/deadline.d.ts.map +1 -0
- package/dist/temporal/workflows/deadline.js +8 -0
- package/dist/temporal/workflows/deadline.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +4 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +5 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/job-execution-orchestration.d.ts +27 -0
- package/dist/temporal/workflows/job-execution-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/job-execution-orchestration.js +265 -0
- package/dist/temporal/workflows/job-execution-orchestration.js.map +1 -0
- package/dist/temporal/workflows/job-listener-orchestration.d.ts +40 -0
- package/dist/temporal/workflows/job-listener-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/job-listener-orchestration.js +332 -0
- package/dist/temporal/workflows/job-listener-orchestration.js.map +1 -0
- package/dist/temporal/workflows/run-orchestration.d.ts +8 -0
- package/dist/temporal/workflows/run-orchestration.d.ts.map +1 -0
- package/dist/temporal/workflows/run-orchestration.js +243 -0
- package/dist/temporal/workflows/run-orchestration.js.map +1 -0
- package/dist/temporal/workflows/test-env.d.ts +114 -0
- package/dist/temporal/workflows/test-env.d.ts.map +1 -0
- package/dist/temporal/workflows/test-env.js +323 -0
- package/dist/temporal/workflows/test-env.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +211 -0
- package/drizzle/0001_agent_tool_materialization.sql +1 -0
- package/drizzle/meta/0000_snapshot.json +1613 -0
- package/drizzle/meta/_journal.json +20 -0
- package/drizzle.config.ts +7 -0
- package/package.json +91 -0
- package/src/core/README.md +79 -0
- package/src/core/agent-tool-capability-warning.test.ts +280 -0
- package/src/core/agent-tool-capability-warning.ts +200 -0
- package/src/core/agent-tools.ts +422 -0
- package/src/core/checkout.test.ts +112 -0
- package/src/core/checkout.ts +63 -0
- package/src/core/condition-trace.ts +64 -0
- package/src/core/entities/index.ts +9 -0
- package/src/core/entities/job-execution.ts +32 -0
- package/src/core/entities/job-listener-event.ts +15 -0
- package/src/core/entities/job.ts +91 -0
- package/src/core/entities/step.ts +126 -0
- package/src/core/entities/workflow-run-attempt.ts +21 -0
- package/src/core/entities/workflow-run.ts +94 -0
- package/src/core/errors.test.ts +45 -0
- package/src/core/errors.ts +209 -0
- package/src/core/index.ts +54 -0
- package/src/core/job-execution-outcome.ts +64 -0
- package/src/core/job-execution.test.ts +1560 -0
- package/src/core/job-execution.ts +581 -0
- package/src/core/job-transition/decide-job-activation.test.ts +196 -0
- package/src/core/job-transition/decide-job-activation.ts +79 -0
- package/src/core/job-transition/derive-job-execution-outputs.ts +41 -0
- package/src/core/job-transition/derive-job-success.test.ts +133 -0
- package/src/core/job-transition/derive-job-success.ts +67 -0
- package/src/core/job-transition/index.ts +11 -0
- package/src/core/job-transition/runtime-completion-status-for-job.ts +14 -0
- package/src/core/listener-execution-materialization.test.ts +49 -0
- package/src/core/listener-execution-materialization.ts +162 -0
- package/src/core/run-workflow.test.ts +229 -0
- package/src/core/run-workflow.ts +41 -0
- package/src/core/source-control.test.ts +17 -0
- package/src/core/source-control.ts +22 -0
- package/src/core/step-config/agent.ts +459 -0
- package/src/core/step-config/assemble-run-context.test.ts +1021 -0
- package/src/core/step-config/assemble-run-context.ts +535 -0
- package/src/core/step-config/complete-step-dispatch-config.test.ts +354 -0
- package/src/core/step-config/complete-step-dispatch-config.ts +40 -0
- package/src/core/step-config/fields.ts +111 -0
- package/src/core/step-config/index.ts +41 -0
- package/src/core/step-config/materialize-job-execution-steps.test.ts +494 -0
- package/src/core/step-config/materialize-job-execution-steps.ts +136 -0
- package/src/core/step-config/materialize-workflow-model.test.ts +1214 -0
- package/src/core/step-config/materialize-workflow-model.ts +140 -0
- package/src/core/step-config/resolve-job-execution-name.test.ts +94 -0
- package/src/core/step-config/resolve-job-execution-name.ts +51 -0
- package/src/core/step-config/resolve-step-config.ts +199 -0
- package/src/core/step-config/run.ts +467 -0
- package/src/core/step-config/workflow-evaluation-context.ts +6 -0
- package/src/core/step-transition/apply-step-transition.ts +163 -0
- package/src/core/step-transition/decide-step-transition.test.ts +307 -0
- package/src/core/step-transition/decide-step-transition.ts +200 -0
- package/src/core/step-transition/evaluate-gate.test.ts +317 -0
- package/src/core/step-transition/evaluate-gate.ts +168 -0
- package/src/core/step-transition/read-step-outputs.ts +27 -0
- package/src/core/workflow-run-creation.test.ts +155 -0
- package/src/core/workflow-run-creation.ts +131 -0
- package/src/core/workflow-scheduling/index.ts +15 -0
- package/src/core/workflow-scheduling/run-progress.test.ts +46 -0
- package/src/core/workflow-scheduling/run-progress.ts +68 -0
- package/src/core/workflow-scheduling/runtime-dag.ts +10 -0
- package/src/core/workflow-scheduling/runtime-scheduling-command.ts +20 -0
- package/src/core/workflow-scheduling/schedule-runtime-dag.test.ts +197 -0
- package/src/core/workflow-scheduling/schedule-runtime-dag.ts +115 -0
- package/src/db/db.ts +40 -0
- package/src/db/index.ts +86 -0
- package/src/db/job-listener-events.test.ts +113 -0
- package/src/db/job-listener-events.ts +73 -0
- package/src/db/job-listeners.test.ts +865 -0
- package/src/db/job-listeners.ts +564 -0
- package/src/db/outbox-writes.ts +40 -0
- package/src/db/rerun-listener.test.ts +64 -0
- package/src/db/run-timeout.test.ts +102 -0
- package/src/db/runner-lease-table.ts +39 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/job-executions.ts +85 -0
- package/src/db/schema/job-listener-events.ts +58 -0
- package/src/db/schema/jobs.ts +136 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/step-attempts.ts +99 -0
- package/src/db/schema/steps.ts +99 -0
- package/src/db/schema/workflow-run-attempts.ts +59 -0
- package/src/db/schema/workflow-runs.ts +112 -0
- package/src/db/workflow-runs/job-executions.test.ts +99 -0
- package/src/db/workflow-runs/job-executions.ts +421 -0
- package/src/db/workflow-runs/job-status.test.ts +532 -0
- package/src/db/workflow-runs/jobs.test.ts +194 -0
- package/src/db/workflow-runs/jobs.ts +418 -0
- package/src/db/workflow-runs/outbox.ts +109 -0
- package/src/db/workflow-runs/queries.test.ts +256 -0
- package/src/db/workflow-runs/queries.ts +437 -0
- package/src/db/workflow-runs/run-create.test.ts +1281 -0
- package/src/db/workflow-runs/run-create.ts +373 -0
- package/src/db/workflow-runs/run-graph.ts +95 -0
- package/src/db/workflow-runs/run-rerun.test.ts +625 -0
- package/src/db/workflow-runs/run-rerun.ts +266 -0
- package/src/db/workflow-runs/run-status.test.ts +425 -0
- package/src/db/workflow-runs/run-status.ts +391 -0
- package/src/db/workflow-runs/runs.ts +17 -0
- package/src/db/workflow-runs/shared.ts +84 -0
- package/src/db/workflow-runs/steps.test.ts +191 -0
- package/src/db/workflow-runs/steps.ts +476 -0
- package/src/db/workflow-runs.ts +111 -0
- package/src/index.ts +99 -0
- package/src/metrics/index.ts +1 -0
- package/src/metrics/instance.ts +160 -0
- package/src/metrics/service.ts +30 -0
- package/src/presentation/dto/checkout-token.test.ts +107 -0
- package/src/presentation/dto/checkout-token.ts +85 -0
- package/src/presentation/dto/index.ts +3 -0
- package/src/presentation/dto/job.test.ts +108 -0
- package/src/presentation/dto/job.ts +64 -0
- package/src/presentation/dto/step.test.ts +307 -0
- package/src/presentation/dto/step.ts +145 -0
- package/src/presentation/dto/workflow-run.ts +38 -0
- package/src/presentation/index.ts +10 -0
- package/src/presentation/routes/agent-runtime-config.test.ts +478 -0
- package/src/presentation/routes/agent-runtime-config.ts +81 -0
- package/src/presentation/routes/cancel-run.test.ts +156 -0
- package/src/presentation/routes/cancel-run.ts +37 -0
- package/src/presentation/routes/checkout-token.test.ts +366 -0
- package/src/presentation/routes/checkout-token.ts +61 -0
- package/src/presentation/routes/get-run-aggregates.test.ts +114 -0
- package/src/presentation/routes/get-run-aggregates.ts +69 -0
- package/src/presentation/routes/get-run.test.ts +604 -0
- package/src/presentation/routes/get-run.ts +66 -0
- package/src/presentation/routes/get-step-secrets.test.ts +260 -0
- package/src/presentation/routes/get-step-secrets.ts +117 -0
- package/src/presentation/routes/index.test.ts +71 -0
- package/src/presentation/routes/index.ts +42 -0
- package/src/presentation/routes/leased-step.ts +54 -0
- package/src/presentation/routes/list-run-attempts.test.ts +163 -0
- package/src/presentation/routes/list-run-attempts.ts +27 -0
- package/src/presentation/routes/list-runs.test.ts +244 -0
- package/src/presentation/routes/list-runs.ts +83 -0
- package/src/presentation/routes/next-step.test.ts +366 -0
- package/src/presentation/routes/next-step.ts +62 -0
- package/src/presentation/routes/report-step.test.ts +374 -0
- package/src/presentation/routes/report-step.ts +61 -0
- package/src/presentation/routes/require-accessible-run.ts +27 -0
- package/src/presentation/routes/rerun-run.test.ts +202 -0
- package/src/presentation/routes/rerun-run.ts +48 -0
- package/src/presentation/subscribers/index.ts +7 -0
- package/src/presentation/subscribers/on-job-event-delivered.test.ts +71 -0
- package/src/presentation/subscribers/on-job-event-delivered.ts +30 -0
- package/src/presentation/subscribers/on-job-steps-settled.test.ts +75 -0
- package/src/presentation/subscribers/on-job-steps-settled.ts +42 -0
- package/src/presentation/subscribers/on-runner-job-claimed.test.ts +57 -0
- package/src/presentation/subscribers/on-runner-job-claimed.ts +23 -0
- package/src/presentation/subscribers/on-runner-job-lease-expired.test.ts +73 -0
- package/src/presentation/subscribers/on-runner-job-lease-expired.ts +36 -0
- package/src/presentation/subscribers/on-runner-job-queued.test.ts +57 -0
- package/src/presentation/subscribers/on-runner-job-queued.ts +23 -0
- package/src/presentation/subscribers/on-workflow-run-attempt-created.test.ts +69 -0
- package/src/presentation/subscribers/on-workflow-run-attempt-created.ts +40 -0
- package/src/presentation/subscribers/on-workflow-run-cancelled.test.ts +59 -0
- package/src/presentation/subscribers/on-workflow-run-cancelled.ts +29 -0
- package/src/temporal/activities/index.ts +45 -0
- package/src/temporal/activities/orchestration-activities.test.ts +115 -0
- package/src/temporal/activities/orchestration-activities.ts +305 -0
- package/src/temporal/constants.ts +6 -0
- package/src/temporal/index.ts +6 -0
- package/src/temporal/workflow-not-found.ts +9 -0
- package/src/temporal/workflows/deadline.ts +7 -0
- package/src/temporal/workflows/index.ts +11 -0
- package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +165 -0
- package/src/temporal/workflows/job-execution-orchestration.test.ts +311 -0
- package/src/temporal/workflows/job-execution-orchestration.ts +314 -0
- package/src/temporal/workflows/job-listener-orchestration-continuation.test.ts +93 -0
- package/src/temporal/workflows/job-listener-orchestration.test.ts +406 -0
- package/src/temporal/workflows/job-listener-orchestration.ts +490 -0
- package/src/temporal/workflows/run-orchestration.test.ts +409 -0
- package/src/temporal/workflows/run-orchestration.ts +283 -0
- package/src/temporal/workflows/test-env.ts +409 -0
- package/test/env.ts +11 -0
- package/test/factories/job.ts +83 -0
- package/test/factories/project.ts +16 -0
- package/test/factories/workflow-model.test.ts +26 -0
- package/test/factories/workflow-model.ts +268 -0
- package/test/factories/workflow-run.ts +58 -0
- package/test/fixtures/active-lease-token.ts +85 -0
- package/test/fixtures/job-with-steps.ts +42 -0
- package/test/fixtures/lease-token.ts +44 -0
- package/test/fixtures/strip-setup-step.ts +23 -0
- package/test/globalSetup.ts +54 -0
- package/test/helpers/workflow-runs.ts +210 -0
- package/test/index.ts +3 -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 +12 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import {DEFAULT_JOB_CHECKOUT, type WorkflowModel} from '@shipfox/api-definitions';
|
|
2
|
+
import {
|
|
3
|
+
createWorkflowExpression,
|
|
4
|
+
parseWorkflowTemplate,
|
|
5
|
+
planInterpolationField,
|
|
6
|
+
type ResolvedFieldSegment,
|
|
7
|
+
type WorkflowInterpolationField,
|
|
8
|
+
} from '@shipfox/expression';
|
|
9
|
+
|
|
10
|
+
type ModelStep = WorkflowModel['jobs'][number]['steps'][number];
|
|
11
|
+
type AgentThinking = Extract<ModelStep, {kind: 'agent'}>['thinking'];
|
|
12
|
+
type Harness = Extract<ModelStep, {kind: 'agent'}>['harness'];
|
|
13
|
+
type WorkflowEnvTemplates = NonNullable<NonNullable<WorkflowModel['templates']>['env']>;
|
|
14
|
+
|
|
15
|
+
interface TestWorkflowStepBase {
|
|
16
|
+
readonly key?: string | undefined;
|
|
17
|
+
readonly name?: string | undefined;
|
|
18
|
+
readonly sourceLocation?: WorkflowModel['jobs'][number]['steps'][number]['sourceLocation'];
|
|
19
|
+
readonly if?: ModelStep['if'] | undefined;
|
|
20
|
+
readonly gate?: WorkflowModel['jobs'][number]['steps'][number]['gate'] | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface TestRunStep extends TestWorkflowStepBase {
|
|
24
|
+
readonly run: string;
|
|
25
|
+
readonly env?: WorkflowModel['env'] | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface TestAgentStep extends TestWorkflowStepBase {
|
|
29
|
+
readonly harness?: Harness | undefined;
|
|
30
|
+
readonly model?: string | undefined;
|
|
31
|
+
readonly provider?: string | undefined;
|
|
32
|
+
readonly prompt: string;
|
|
33
|
+
readonly thinking?: AgentThinking | undefined;
|
|
34
|
+
readonly tools?: readonly string[] | undefined;
|
|
35
|
+
readonly integrations?: Extract<ModelStep, {kind: 'agent'}>['integrations'] | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type TestWorkflowStep = TestRunStep | TestAgentStep;
|
|
39
|
+
|
|
40
|
+
const DEFAULT_RUNNER_LABELS = ['ubuntu-latest'] as const;
|
|
41
|
+
|
|
42
|
+
interface TestWorkflowJob {
|
|
43
|
+
readonly needs?: string | readonly string[] | undefined;
|
|
44
|
+
readonly name?: string | undefined;
|
|
45
|
+
readonly runner?: string | readonly string[] | undefined;
|
|
46
|
+
readonly runnerTemplates?: readonly string[] | undefined;
|
|
47
|
+
readonly checkout?: WorkflowModel['jobs'][number]['checkout'] | undefined;
|
|
48
|
+
readonly if?: string | undefined;
|
|
49
|
+
readonly success?: string | undefined;
|
|
50
|
+
readonly outputs?: Readonly<Record<string, string>> | undefined;
|
|
51
|
+
readonly env?: WorkflowModel['env'] | undefined;
|
|
52
|
+
readonly steps: readonly TestWorkflowStep[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface TestWorkflowModelInput {
|
|
56
|
+
readonly name?: string | undefined;
|
|
57
|
+
readonly runner?: string | readonly string[] | undefined;
|
|
58
|
+
readonly env?: WorkflowModel['env'] | undefined;
|
|
59
|
+
readonly jobs?: Readonly<Record<string, TestWorkflowJob>> | undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function workflowModel(input: TestWorkflowModelInput = {}): WorkflowModel {
|
|
63
|
+
const jobs = input.jobs ?? {
|
|
64
|
+
build: {
|
|
65
|
+
steps: [{run: 'echo hello'}],
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
const modelJobs = Object.entries(jobs).map(([key, job]) => {
|
|
69
|
+
const jobId = stableId(key);
|
|
70
|
+
return {
|
|
71
|
+
id: jobId,
|
|
72
|
+
key,
|
|
73
|
+
mode: 'one_shot' as const,
|
|
74
|
+
runner: normalizeStringArray(job.runner ?? input.runner ?? DEFAULT_RUNNER_LABELS),
|
|
75
|
+
...(job.runnerTemplates === undefined
|
|
76
|
+
? {}
|
|
77
|
+
: {
|
|
78
|
+
runnerTemplates: job.runnerTemplates.map((template) =>
|
|
79
|
+
requiredFieldTemplate('job.runner', template),
|
|
80
|
+
),
|
|
81
|
+
}),
|
|
82
|
+
checkout: job.checkout ?? DEFAULT_JOB_CHECKOUT,
|
|
83
|
+
...(job.if === undefined ? {} : {if: workflowExpression(job.if)}),
|
|
84
|
+
...(job.success === undefined ? {} : {success: job.success}),
|
|
85
|
+
...(job.outputs === undefined ? {} : {outputs: outputTemplates(job.outputs)}),
|
|
86
|
+
...(job.name === undefined
|
|
87
|
+
? {}
|
|
88
|
+
: {
|
|
89
|
+
name: fieldTemplate('job.name', job.name) ?? [
|
|
90
|
+
{kind: 'literal' as const, value: job.name},
|
|
91
|
+
],
|
|
92
|
+
}),
|
|
93
|
+
...optionalScopedEnv(job.env),
|
|
94
|
+
dependencies: normalizeStringArray(job.needs).map(stableId),
|
|
95
|
+
steps: job.steps.map((step, stepIndex) => normalizeStep(step, jobId, stepIndex)),
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
kind: 'workflow',
|
|
101
|
+
name: input.name ?? 'Test Workflow',
|
|
102
|
+
...optionalScopedEnv(input.env),
|
|
103
|
+
triggers: [],
|
|
104
|
+
jobs: modelJobs,
|
|
105
|
+
dependencies: modelJobs.flatMap((job) =>
|
|
106
|
+
job.dependencies.map((dependency) => ({from: dependency, to: job.id})),
|
|
107
|
+
),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function workflowExpression(source: string) {
|
|
112
|
+
return createWorkflowExpression({
|
|
113
|
+
source,
|
|
114
|
+
check: {mode: 'syntax'},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function outputTemplates(outputs: Readonly<Record<string, string>>) {
|
|
119
|
+
return Object.fromEntries(
|
|
120
|
+
Object.entries(outputs).map(([key, source]) => [
|
|
121
|
+
key,
|
|
122
|
+
fieldTemplate('job.outputs', source) ?? [{kind: 'literal' as const, value: source}],
|
|
123
|
+
]),
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function normalizeStep(step: TestWorkflowStep, jobId: string, stepIndex: number): ModelStep {
|
|
128
|
+
const base = stepBase(step, jobId, stepIndex);
|
|
129
|
+
return 'run' in step
|
|
130
|
+
? {
|
|
131
|
+
...base,
|
|
132
|
+
kind: 'run',
|
|
133
|
+
command: {kind: 'shell', value: step.run},
|
|
134
|
+
...optionalRunTemplates(step),
|
|
135
|
+
...optionalStepEnv(step.env),
|
|
136
|
+
}
|
|
137
|
+
: {
|
|
138
|
+
...base,
|
|
139
|
+
kind: 'agent',
|
|
140
|
+
...(step.harness === undefined ? {} : {harness: step.harness}),
|
|
141
|
+
...(step.model === undefined ? {} : {model: step.model}),
|
|
142
|
+
...(step.provider === undefined ? {} : {provider: step.provider}),
|
|
143
|
+
...(step.thinking === undefined ? {} : {thinking: step.thinking}),
|
|
144
|
+
...(step.tools === undefined ? {} : {tools: step.tools}),
|
|
145
|
+
...(step.integrations === undefined ? {} : {integrations: step.integrations}),
|
|
146
|
+
prompt: step.prompt,
|
|
147
|
+
...optionalAgentTemplates(step),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function stepBase(step: TestWorkflowStep, jobId: string, stepIndex: number) {
|
|
152
|
+
return {
|
|
153
|
+
id:
|
|
154
|
+
step.key === undefined ? `${jobId}-step-${stepIndex + 1}` : `${jobId}-${stableId(step.key)}`,
|
|
155
|
+
...(step.key === undefined ? {} : {key: step.key}),
|
|
156
|
+
...(step.name === undefined ? {} : {name: step.name}),
|
|
157
|
+
...(step.sourceLocation === undefined ? {} : {sourceLocation: step.sourceLocation}),
|
|
158
|
+
...(step.if === undefined ? {} : {if: step.if}),
|
|
159
|
+
...(step.gate === undefined ? {} : {gate: step.gate}),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function normalizeStringArray(value: string | readonly string[] | undefined): readonly string[] {
|
|
164
|
+
if (value === undefined) return [];
|
|
165
|
+
return typeof value === 'string' ? [value] : value;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function optionalScopedEnv(
|
|
169
|
+
env: WorkflowModel['env'] | undefined,
|
|
170
|
+
):
|
|
171
|
+
| {env: NonNullable<WorkflowModel['env']>; templates: {env: WorkflowEnvTemplates}}
|
|
172
|
+
| {env: NonNullable<WorkflowModel['env']>}
|
|
173
|
+
| Record<string, never> {
|
|
174
|
+
if (env === undefined || Object.keys(env).length === 0) return {};
|
|
175
|
+
const templates = envTemplates(env);
|
|
176
|
+
return templates === undefined ? {env} : {env, templates: {env: templates}};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function optionalStepEnv(
|
|
180
|
+
env: WorkflowModel['env'] | undefined,
|
|
181
|
+
): {env: NonNullable<WorkflowModel['env']>} | Record<string, never> {
|
|
182
|
+
if (env === undefined || Object.keys(env).length === 0) return {};
|
|
183
|
+
return {env};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function optionalRunTemplates(step: TestRunStep) {
|
|
187
|
+
const command = fieldTemplate('run', step.run);
|
|
188
|
+
const name = step.name === undefined ? undefined : fieldTemplate('step.name', step.name);
|
|
189
|
+
const env = envTemplates(step.env);
|
|
190
|
+
if (command === undefined && name === undefined && env === undefined) return {};
|
|
191
|
+
return {
|
|
192
|
+
templates: {
|
|
193
|
+
...(command === undefined ? {} : {command}),
|
|
194
|
+
...(name === undefined ? {} : {name}),
|
|
195
|
+
...(env === undefined ? {} : {env}),
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function optionalAgentTemplates(step: TestAgentStep) {
|
|
201
|
+
const prompt = fieldTemplate('agent.prompt', step.prompt);
|
|
202
|
+
const model = step.model === undefined ? undefined : fieldTemplate('agent.model', step.model);
|
|
203
|
+
const provider =
|
|
204
|
+
step.provider === undefined ? undefined : fieldTemplate('agent.provider', step.provider);
|
|
205
|
+
const name = step.name === undefined ? undefined : fieldTemplate('step.name', step.name);
|
|
206
|
+
if (prompt === undefined && model === undefined && provider === undefined && name === undefined) {
|
|
207
|
+
return {};
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
templates: {
|
|
211
|
+
...(prompt === undefined ? {} : {prompt}),
|
|
212
|
+
...(model === undefined ? {} : {model}),
|
|
213
|
+
...(provider === undefined ? {} : {provider}),
|
|
214
|
+
...(name === undefined ? {} : {name}),
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function envTemplates(env: WorkflowModel['env'] | undefined): WorkflowEnvTemplates | undefined {
|
|
220
|
+
if (env === undefined) return undefined;
|
|
221
|
+
|
|
222
|
+
const templates = Object.fromEntries(
|
|
223
|
+
Object.entries(env).flatMap(([key, value]) => {
|
|
224
|
+
const template = fieldTemplate('env.value', value);
|
|
225
|
+
return template === undefined ? [] : [[key, template]];
|
|
226
|
+
}),
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
return Object.keys(templates).length === 0 ? undefined : templates;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function fieldTemplate(
|
|
233
|
+
field: WorkflowInterpolationField,
|
|
234
|
+
source: string,
|
|
235
|
+
): readonly ResolvedFieldSegment[] | undefined {
|
|
236
|
+
const segments = parseWorkflowTemplate(source);
|
|
237
|
+
if (!segments.some((segment) => segment.kind === 'expr')) return undefined;
|
|
238
|
+
const plan = planInterpolationField({field, segments});
|
|
239
|
+
if (!plan.ok) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
`Invalid test workflow template for ${field}: ${plan.violations
|
|
242
|
+
.map((violation) => violation.source)
|
|
243
|
+
.join(', ')}`,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
return plan.plan.field.segments;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function requiredFieldTemplate(
|
|
250
|
+
field: WorkflowInterpolationField,
|
|
251
|
+
source: string,
|
|
252
|
+
): readonly ResolvedFieldSegment[] {
|
|
253
|
+
const template = fieldTemplate(field, source);
|
|
254
|
+
if (template === undefined) {
|
|
255
|
+
throw new Error(`Expected test workflow template for ${field}: ${source}`);
|
|
256
|
+
}
|
|
257
|
+
return template;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function stableId(sourceName: string): string {
|
|
261
|
+
const id = sourceName
|
|
262
|
+
.trim()
|
|
263
|
+
.toLowerCase()
|
|
264
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
265
|
+
.replace(/^-+|-+$/g, '');
|
|
266
|
+
|
|
267
|
+
return id.length === 0 ? 'unnamed' : id;
|
|
268
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type {WorkflowModel} from '@shipfox/api-definitions';
|
|
2
|
+
import {Factory} from 'fishery';
|
|
3
|
+
import type {WorkflowRun} from '#core/entities/workflow-run.js';
|
|
4
|
+
import {createWorkflowRun} from '#db/workflow-runs.js';
|
|
5
|
+
import {workflowModel} from './workflow-model.js';
|
|
6
|
+
|
|
7
|
+
interface WorkflowRunTransientParams {
|
|
8
|
+
model?: WorkflowModel | undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const workflowRunFactory = Factory.define<WorkflowRun, WorkflowRunTransientParams>(
|
|
12
|
+
({transientParams, onCreate}) => {
|
|
13
|
+
const workspaceId = crypto.randomUUID();
|
|
14
|
+
const projectId = crypto.randomUUID();
|
|
15
|
+
const definitionId = crypto.randomUUID();
|
|
16
|
+
|
|
17
|
+
onCreate((run) => {
|
|
18
|
+
return createWorkflowRun({
|
|
19
|
+
workspaceId: run.workspaceId,
|
|
20
|
+
projectId: run.projectId,
|
|
21
|
+
definitionId: run.definitionId,
|
|
22
|
+
name: run.name,
|
|
23
|
+
model: transientParams.model ?? workflowModel({name: run.name}),
|
|
24
|
+
triggerPayload: run.triggerPayload,
|
|
25
|
+
inputs: run.inputs ?? undefined,
|
|
26
|
+
sourceSnapshot: run.sourceSnapshot,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
id: crypto.randomUUID(),
|
|
32
|
+
workspaceId,
|
|
33
|
+
projectId,
|
|
34
|
+
definitionId,
|
|
35
|
+
name: 'Test Workflow',
|
|
36
|
+
status: 'pending',
|
|
37
|
+
currentAttempt: 1,
|
|
38
|
+
triggerProvider: null,
|
|
39
|
+
triggerSource: 'manual',
|
|
40
|
+
triggerEvent: 'fire',
|
|
41
|
+
triggerPayload: {
|
|
42
|
+
source: 'manual',
|
|
43
|
+
event: 'fire',
|
|
44
|
+
subscriptionId: crypto.randomUUID(),
|
|
45
|
+
userId: crypto.randomUUID(),
|
|
46
|
+
},
|
|
47
|
+
inputs: null,
|
|
48
|
+
sourceSnapshot: null,
|
|
49
|
+
triggerIdempotencyKey: null,
|
|
50
|
+
timeoutMs: 30 * 24 * 60 * 60 * 1000,
|
|
51
|
+
version: 1,
|
|
52
|
+
createdAt: new Date(),
|
|
53
|
+
updatedAt: new Date(),
|
|
54
|
+
startedAt: null,
|
|
55
|
+
finishedAt: null,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {db} from '#db/db.js';
|
|
2
|
+
import {runnerSessions, runningJobExecutions} from '#db/runner-lease-table.js';
|
|
3
|
+
import {
|
|
4
|
+
getFirstJobExecutionByJobId,
|
|
5
|
+
getJobById,
|
|
6
|
+
getWorkflowRunByAttemptId,
|
|
7
|
+
} from '#db/workflow-runs.js';
|
|
8
|
+
import {mintLeaseToken} from './lease-token.js';
|
|
9
|
+
|
|
10
|
+
export interface MintActiveLeaseTokenParams {
|
|
11
|
+
jobId: string;
|
|
12
|
+
token?: {
|
|
13
|
+
workflowRunId?: string;
|
|
14
|
+
workflowRunAttemptId?: string;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
workspaceId?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function mintActiveLeaseToken(params: MintActiveLeaseTokenParams): Promise<string> {
|
|
21
|
+
const jobExecution = await getFirstJobExecutionByJobId(params.jobId);
|
|
22
|
+
if (!jobExecution) throw new Error('Expected job execution to exist');
|
|
23
|
+
const job = await getJobById(params.jobId);
|
|
24
|
+
if (!job) throw new Error('Expected job to exist');
|
|
25
|
+
const run = await getWorkflowRunByAttemptId(job.workflowRunAttemptId);
|
|
26
|
+
if (!run) throw new Error('Expected workflow run to exist');
|
|
27
|
+
const runnerSessionId = crypto.randomUUID();
|
|
28
|
+
|
|
29
|
+
await insertRunningJobLease({
|
|
30
|
+
workspaceId: run.workspaceId,
|
|
31
|
+
workflowRunId: run.id,
|
|
32
|
+
workflowRunAttemptId: job.workflowRunAttemptId,
|
|
33
|
+
jobId: params.jobId,
|
|
34
|
+
jobExecutionId: jobExecution.id,
|
|
35
|
+
projectId: run.projectId,
|
|
36
|
+
runnerSessionId,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return await mintLeaseToken({
|
|
40
|
+
jobId: params.jobId,
|
|
41
|
+
jobExecutionId: jobExecution.id,
|
|
42
|
+
workflowRunId: params.token?.workflowRunId ?? run.id,
|
|
43
|
+
workflowRunAttemptId: params.token?.workflowRunAttemptId ?? job.workflowRunAttemptId,
|
|
44
|
+
projectId: params.token?.projectId ?? run.projectId,
|
|
45
|
+
workspaceId: params.token?.workspaceId ?? run.workspaceId,
|
|
46
|
+
runnerSessionId,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface InsertRunningJobLeaseParams {
|
|
51
|
+
workspaceId: string;
|
|
52
|
+
workflowRunId: string;
|
|
53
|
+
workflowRunAttemptId: string;
|
|
54
|
+
jobId: string;
|
|
55
|
+
jobExecutionId: string;
|
|
56
|
+
projectId: string;
|
|
57
|
+
runnerSessionId: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function insertRunningJobLease(params: InsertRunningJobLeaseParams): Promise<void> {
|
|
61
|
+
await db()
|
|
62
|
+
.insert(runnerSessions)
|
|
63
|
+
.values({
|
|
64
|
+
id: params.runnerSessionId,
|
|
65
|
+
workspaceId: params.workspaceId,
|
|
66
|
+
scope: 'workspace',
|
|
67
|
+
registrationTokenId: crypto.randomUUID(),
|
|
68
|
+
registrationTokenKind: 'manual',
|
|
69
|
+
labels: ['linux'],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await db()
|
|
73
|
+
.insert(runningJobExecutions)
|
|
74
|
+
.values({
|
|
75
|
+
workspaceId: params.workspaceId,
|
|
76
|
+
workflowRunId: params.workflowRunId,
|
|
77
|
+
workflowRunAttemptId: params.workflowRunAttemptId,
|
|
78
|
+
jobId: params.jobId,
|
|
79
|
+
jobExecutionId: params.jobExecutionId,
|
|
80
|
+
projectId: params.projectId,
|
|
81
|
+
runnerSessionId: params.runnerSessionId,
|
|
82
|
+
requiredLabels: ['linux'],
|
|
83
|
+
runnerLabels: ['linux'],
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type {Step} from '#core/entities/step.js';
|
|
2
|
+
import {createWorkflowRun, getJobsByWorkflowRunId, getStepsByJobId} from '#db/workflow-runs.js';
|
|
3
|
+
import {stripSetupStep} from '#test/fixtures/strip-setup-step.js';
|
|
4
|
+
import {workflowModel} from '#test/index.js';
|
|
5
|
+
|
|
6
|
+
// Jobs and steps have no standalone factory — they only exist as children
|
|
7
|
+
// materialized from a WorkflowModel by createWorkflowRun, which also prepends a
|
|
8
|
+
// synthetic "Set up job" step to every job. This fixture exercises step-execution
|
|
9
|
+
// mechanics in isolation, so it strips that step (see stripSetupStep) to keep the
|
|
10
|
+
// arrangement focused. The setup step's own behavior is covered by materialize /
|
|
11
|
+
// createWorkflowRun / runner tests.
|
|
12
|
+
export async function arrangeJobWithSteps(
|
|
13
|
+
stepCount: number,
|
|
14
|
+
): Promise<{jobId: string; steps: Step[]}> {
|
|
15
|
+
const model = workflowModel({
|
|
16
|
+
name: 'Test Workflow',
|
|
17
|
+
jobs: {
|
|
18
|
+
build: {steps: Array.from({length: stepCount}, (_, i) => ({run: `echo step-${i}`}))},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const run = await createWorkflowRun({
|
|
23
|
+
workspaceId: crypto.randomUUID(),
|
|
24
|
+
projectId: crypto.randomUUID(),
|
|
25
|
+
definitionId: crypto.randomUUID(),
|
|
26
|
+
model,
|
|
27
|
+
triggerPayload: {
|
|
28
|
+
source: 'manual',
|
|
29
|
+
event: 'fire',
|
|
30
|
+
subscriptionId: crypto.randomUUID(),
|
|
31
|
+
userId: crypto.randomUUID(),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const jobs = await getJobsByWorkflowRunId(run.id);
|
|
36
|
+
const jobId = jobs[0]?.id as string;
|
|
37
|
+
|
|
38
|
+
await stripSetupStep(jobId);
|
|
39
|
+
|
|
40
|
+
const steps = await getStepsByJobId(jobId);
|
|
41
|
+
return {jobId, steps};
|
|
42
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {JOB_LEASE_TOKEN_AUDIENCE} from '@shipfox/api-auth-dto';
|
|
2
|
+
import {signHs256} from '@shipfox/node-jwt';
|
|
3
|
+
import {getFirstJobExecutionByJobId} from '#db/workflow-runs.js';
|
|
4
|
+
|
|
5
|
+
// Matches test/env.ts; the lease-token auth method reads this same value from config.
|
|
6
|
+
const SECRET = process.env.AUTH_JOB_LEASE_TOKEN_SECRET ?? 'test-lease-secret';
|
|
7
|
+
|
|
8
|
+
export interface MintLeaseTokenParams {
|
|
9
|
+
jobId: string;
|
|
10
|
+
jobExecutionId?: string;
|
|
11
|
+
// Override informational claims to pair a job with chosen surrounding context.
|
|
12
|
+
workflowRunId?: string;
|
|
13
|
+
workflowRunAttemptId?: string;
|
|
14
|
+
projectId?: string;
|
|
15
|
+
workspaceId?: string;
|
|
16
|
+
runnerSessionId?: string;
|
|
17
|
+
secret?: string;
|
|
18
|
+
expiresIn?: string;
|
|
19
|
+
audience?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function mintLeaseToken(params: MintLeaseTokenParams): Promise<string> {
|
|
23
|
+
let jobExecutionId = params.jobExecutionId;
|
|
24
|
+
if (jobExecutionId === undefined) {
|
|
25
|
+
const jobExecution = await getFirstJobExecutionByJobId(params.jobId);
|
|
26
|
+
if (!jobExecution) throw new Error('Expected job execution to exist');
|
|
27
|
+
jobExecutionId = jobExecution.id;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return signHs256({
|
|
31
|
+
payload: {
|
|
32
|
+
jobId: params.jobId,
|
|
33
|
+
jobExecutionId,
|
|
34
|
+
workflowRunId: params.workflowRunId ?? crypto.randomUUID(),
|
|
35
|
+
workflowRunAttemptId: params.workflowRunAttemptId ?? crypto.randomUUID(),
|
|
36
|
+
projectId: params.projectId ?? crypto.randomUUID(),
|
|
37
|
+
workspaceId: params.workspaceId ?? crypto.randomUUID(),
|
|
38
|
+
runnerSessionId: params.runnerSessionId ?? crypto.randomUUID(),
|
|
39
|
+
},
|
|
40
|
+
secret: params.secret ?? SECRET,
|
|
41
|
+
expiresIn: params.expiresIn ?? '90m',
|
|
42
|
+
audience: params.audience ?? JOB_LEASE_TOKEN_AUDIENCE,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {and, eq, inArray, sql} from 'drizzle-orm';
|
|
2
|
+
import {db} from '#db/db.js';
|
|
3
|
+
import {steps as stepsTable} from '#db/schema/steps.js';
|
|
4
|
+
import {getStepsByJobId} from '#db/workflow-runs.js';
|
|
5
|
+
|
|
6
|
+
// createWorkflowRun prepends a synthetic "Set up job" step to every job. Tests that
|
|
7
|
+
// exercise step-execution mechanics in isolation strip it and renumber the user
|
|
8
|
+
// steps back to 0-based, so their arrangement matches the steps they declared.
|
|
9
|
+
export async function stripSetupStep(jobId: string): Promise<void> {
|
|
10
|
+
const jobSteps = await getStepsByJobId(jobId);
|
|
11
|
+
const stepIds = jobSteps.map((step) => step.id);
|
|
12
|
+
if (stepIds.length === 0) return;
|
|
13
|
+
|
|
14
|
+
await db().transaction(async (tx) => {
|
|
15
|
+
await tx
|
|
16
|
+
.delete(stepsTable)
|
|
17
|
+
.where(and(inArray(stepsTable.id, stepIds), eq(stepsTable.type, 'setup')));
|
|
18
|
+
await tx
|
|
19
|
+
.update(stepsTable)
|
|
20
|
+
.set({position: sql`${stepsTable.position} - 1`})
|
|
21
|
+
.where(inArray(stepsTable.id, stepIds));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import './env.js';
|
|
2
|
+
import {annotationsModule} from '@shipfox/annotations';
|
|
3
|
+
import {agentModule} from '@shipfox/api-agent';
|
|
4
|
+
import {runnersModule} from '@shipfox/api-runners';
|
|
5
|
+
import {secretsModule} from '@shipfox/api-secrets';
|
|
6
|
+
import {runMigrations} from '@shipfox/node-drizzle';
|
|
7
|
+
import {closePostgresClient, createPostgresClient} from '@shipfox/node-postgres';
|
|
8
|
+
import {sql} from 'drizzle-orm';
|
|
9
|
+
import {closeDb, db, migrationsPath} from '#db/index.js';
|
|
10
|
+
|
|
11
|
+
export async function setup() {
|
|
12
|
+
createPostgresClient();
|
|
13
|
+
|
|
14
|
+
if (!agentModule.database || Array.isArray(agentModule.database)) {
|
|
15
|
+
throw new Error('Agent module database is not configured');
|
|
16
|
+
}
|
|
17
|
+
await runMigrations(
|
|
18
|
+
agentModule.database.db(),
|
|
19
|
+
agentModule.database.migrationsPath,
|
|
20
|
+
'__drizzle_migrations_agent',
|
|
21
|
+
);
|
|
22
|
+
if (!runnersModule.database || Array.isArray(runnersModule.database)) {
|
|
23
|
+
throw new Error('Runners module database is not configured');
|
|
24
|
+
}
|
|
25
|
+
await runMigrations(
|
|
26
|
+
runnersModule.database.db(),
|
|
27
|
+
runnersModule.database.migrationsPath,
|
|
28
|
+
'__drizzle_migrations_runners',
|
|
29
|
+
);
|
|
30
|
+
if (!secretsModule.database || Array.isArray(secretsModule.database)) {
|
|
31
|
+
throw new Error('Secrets module database is not configured');
|
|
32
|
+
}
|
|
33
|
+
await runMigrations(
|
|
34
|
+
secretsModule.database.db(),
|
|
35
|
+
secretsModule.database.migrationsPath,
|
|
36
|
+
'__drizzle_migrations_secrets',
|
|
37
|
+
);
|
|
38
|
+
if (!annotationsModule.database || Array.isArray(annotationsModule.database)) {
|
|
39
|
+
throw new Error('Annotations module database is not configured');
|
|
40
|
+
}
|
|
41
|
+
await runMigrations(
|
|
42
|
+
annotationsModule.database.db(),
|
|
43
|
+
annotationsModule.database.migrationsPath,
|
|
44
|
+
'__drizzle_migrations_annotations',
|
|
45
|
+
);
|
|
46
|
+
await runMigrations(db(), migrationsPath, '__drizzle_migrations_workflows');
|
|
47
|
+
await db().execute(sql`TRUNCATE workflows_workflow_runs CASCADE`);
|
|
48
|
+
await db().execute(sql`TRUNCATE workflows_job_listener_events CASCADE`);
|
|
49
|
+
await db().execute(sql`TRUNCATE workflows_outbox CASCADE`);
|
|
50
|
+
await db().execute(sql`TRUNCATE annotations_annotations CASCADE`);
|
|
51
|
+
|
|
52
|
+
closeDb();
|
|
53
|
+
await closePostgresClient();
|
|
54
|
+
}
|