@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,102 @@
|
|
|
1
|
+
import {WORKFLOWS_WORKFLOW_RUN_TERMINATED} from '@shipfox/api-workflows-dto';
|
|
2
|
+
import {eq} from 'drizzle-orm';
|
|
3
|
+
import type {JobExecutionStatus} from '#core/entities/job-execution.js';
|
|
4
|
+
import {db} from '#db/db.js';
|
|
5
|
+
import {jobExecutions} from '#db/schema/job-executions.js';
|
|
6
|
+
import {jobs} from '#db/schema/jobs.js';
|
|
7
|
+
import {workflowsOutbox} from '#db/schema/outbox.js';
|
|
8
|
+
import {failWorkflowRunAsTimedOut} from '#db/workflow-runs.js';
|
|
9
|
+
import {jobFactory} from '#test/index.js';
|
|
10
|
+
|
|
11
|
+
async function insertExecution(jobId: string, sequence: number, status: JobExecutionStatus) {
|
|
12
|
+
const [row] = await db()
|
|
13
|
+
.insert(jobExecutions)
|
|
14
|
+
.values({jobId, sequence, name: `firing #${sequence}`, status, triggerEvents: []})
|
|
15
|
+
.returning();
|
|
16
|
+
if (!row) throw new Error('insertExecution: no row returned');
|
|
17
|
+
return row;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function readJob(jobId: string) {
|
|
21
|
+
return db()
|
|
22
|
+
.select()
|
|
23
|
+
.from(jobs)
|
|
24
|
+
.where(eq(jobs.id, jobId))
|
|
25
|
+
.limit(1)
|
|
26
|
+
.then((rows) => rows[0]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('failWorkflowRunAsTimedOut', () => {
|
|
30
|
+
it('drives a running listener job, its execution, and the run to timed out', async () => {
|
|
31
|
+
const job = await jobFactory.create({}, {transient: {status: 'running'}});
|
|
32
|
+
await db()
|
|
33
|
+
.update(jobs)
|
|
34
|
+
.set({mode: 'listening', listenerStatus: 'listening'})
|
|
35
|
+
.where(eq(jobs.id, job.id));
|
|
36
|
+
await db().delete(jobExecutions).where(eq(jobExecutions.jobId, job.id));
|
|
37
|
+
const execution = await insertExecution(job.id, 1, 'running');
|
|
38
|
+
|
|
39
|
+
const run = await failWorkflowRunAsTimedOut({runAttemptId: job.workflowRunAttemptId});
|
|
40
|
+
|
|
41
|
+
const storedJob = await readJob(job.id);
|
|
42
|
+
const [storedExecution] = await db()
|
|
43
|
+
.select()
|
|
44
|
+
.from(jobExecutions)
|
|
45
|
+
.where(eq(jobExecutions.id, execution.id));
|
|
46
|
+
expect(run.status).toBe('failed');
|
|
47
|
+
expect(storedJob?.status).toBe('failed');
|
|
48
|
+
expect(storedJob?.statusReason).toBe('timed_out');
|
|
49
|
+
expect(storedJob?.listenerStatus).toBe('resolved');
|
|
50
|
+
expect(storedJob?.resolutionReason).toBe('cancelled');
|
|
51
|
+
expect(storedExecution?.status).toBe('failed');
|
|
52
|
+
expect(storedExecution?.statusReason).toBe('timed_out');
|
|
53
|
+
expect(storedExecution?.timedOutAt).not.toBeNull();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('emits a run-terminated outbox event with the failed status', async () => {
|
|
57
|
+
const job = await jobFactory.create({}, {transient: {status: 'running'}});
|
|
58
|
+
|
|
59
|
+
const run = await failWorkflowRunAsTimedOut({runAttemptId: job.workflowRunAttemptId});
|
|
60
|
+
|
|
61
|
+
const terminated = await db()
|
|
62
|
+
.select()
|
|
63
|
+
.from(workflowsOutbox)
|
|
64
|
+
.where(eq(workflowsOutbox.eventType, WORKFLOWS_WORKFLOW_RUN_TERMINATED));
|
|
65
|
+
const forRun = terminated.filter(
|
|
66
|
+
(row) => (row.payload as Record<string, unknown>).workflowRunId === run.id,
|
|
67
|
+
);
|
|
68
|
+
expect(forRun).toHaveLength(1);
|
|
69
|
+
expect(forRun[0]?.payload).toMatchObject({workflowRunId: run.id, status: 'failed'});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('leaves an already-resolved listener job untouched', async () => {
|
|
73
|
+
const job = await jobFactory.create({}, {transient: {status: 'succeeded'}});
|
|
74
|
+
await db()
|
|
75
|
+
.update(jobs)
|
|
76
|
+
.set({mode: 'listening', listenerStatus: 'resolved', resolutionReason: 'until'})
|
|
77
|
+
.where(eq(jobs.id, job.id));
|
|
78
|
+
|
|
79
|
+
await failWorkflowRunAsTimedOut({runAttemptId: job.workflowRunAttemptId});
|
|
80
|
+
|
|
81
|
+
const storedJob = await readJob(job.id);
|
|
82
|
+
expect(storedJob?.status).toBe('succeeded');
|
|
83
|
+
expect(storedJob?.resolutionReason).toBe('until');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('is idempotent once the run is terminal', async () => {
|
|
87
|
+
const job = await jobFactory.create({}, {transient: {status: 'running'}});
|
|
88
|
+
|
|
89
|
+
await failWorkflowRunAsTimedOut({runAttemptId: job.workflowRunAttemptId});
|
|
90
|
+
const second = await failWorkflowRunAsTimedOut({runAttemptId: job.workflowRunAttemptId});
|
|
91
|
+
|
|
92
|
+
const terminated = await db()
|
|
93
|
+
.select()
|
|
94
|
+
.from(workflowsOutbox)
|
|
95
|
+
.where(eq(workflowsOutbox.eventType, WORKFLOWS_WORKFLOW_RUN_TERMINATED));
|
|
96
|
+
const forRun = terminated.filter(
|
|
97
|
+
(row) => (row.payload as Record<string, unknown>).workflowRunId === second.id,
|
|
98
|
+
);
|
|
99
|
+
expect(second.status).toBe('failed');
|
|
100
|
+
expect(forRun).toHaveLength(1);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';
|
|
2
|
+
import {integer, pgEnum, pgTableCreator, text, timestamp, uuid} from 'drizzle-orm/pg-core';
|
|
3
|
+
|
|
4
|
+
const pgTable = pgTableCreator((name) => `runners_${name}`);
|
|
5
|
+
|
|
6
|
+
export const runnerSessionScopeEnum = pgEnum('runners_runner_session_scope', ['workspace']);
|
|
7
|
+
export const runnerSessionRegistrationTokenKindEnum = pgEnum(
|
|
8
|
+
'runners_runner_session_registration_token_kind',
|
|
9
|
+
['manual', 'ephemeral'],
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const runnerSessions = pgTable('runner_sessions', {
|
|
13
|
+
id: uuidv7PrimaryKey(),
|
|
14
|
+
workspaceId: uuid('workspace_id').notNull(),
|
|
15
|
+
scope: runnerSessionScopeEnum('scope').notNull().default('workspace'),
|
|
16
|
+
registrationTokenId: uuid('registration_token_id').notNull(),
|
|
17
|
+
registrationTokenKind:
|
|
18
|
+
runnerSessionRegistrationTokenKindEnum('registration_token_kind').notNull(),
|
|
19
|
+
provisionerId: uuid('provisioner_id'),
|
|
20
|
+
provisionedRunnerId: text('provisioned_runner_id'),
|
|
21
|
+
labels: text('labels').array().notNull(),
|
|
22
|
+
maxClaims: integer('max_claims'),
|
|
23
|
+
claimsUsed: integer('claims_used').notNull().default(0),
|
|
24
|
+
createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),
|
|
25
|
+
updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const runningJobExecutions = pgTable('running_jobs', {
|
|
29
|
+
id: uuidv7PrimaryKey(),
|
|
30
|
+
workspaceId: uuid('workspace_id').notNull(),
|
|
31
|
+
workflowRunId: uuid('workflow_run_id').notNull(),
|
|
32
|
+
workflowRunAttemptId: uuid('workflow_run_attempt_id').notNull(),
|
|
33
|
+
jobId: uuid('job_id').notNull(),
|
|
34
|
+
jobExecutionId: uuid('job_execution_id').notNull(),
|
|
35
|
+
projectId: uuid('project_id').notNull(),
|
|
36
|
+
runnerSessionId: uuid('runner_session_id').notNull(),
|
|
37
|
+
requiredLabels: text('required_labels').array().notNull(),
|
|
38
|
+
runnerLabels: text('runner_labels').array().notNull(),
|
|
39
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';
|
|
2
|
+
import {sql} from 'drizzle-orm';
|
|
3
|
+
import {
|
|
4
|
+
index,
|
|
5
|
+
integer,
|
|
6
|
+
jsonb,
|
|
7
|
+
pgEnum,
|
|
8
|
+
text,
|
|
9
|
+
timestamp,
|
|
10
|
+
uniqueIndex,
|
|
11
|
+
uuid,
|
|
12
|
+
} from 'drizzle-orm/pg-core';
|
|
13
|
+
import {toJobStatusReason} from '#core/entities/job.js';
|
|
14
|
+
import type {JobExecution, WorkflowExecutionEvent} from '#core/entities/job-execution.js';
|
|
15
|
+
import type {PersistedEvaluationTraceEntry} from '#core/entities/step.js';
|
|
16
|
+
import {pgTable} from './common.js';
|
|
17
|
+
import {jobStatusReasonEnum, jobs} from './jobs.js';
|
|
18
|
+
|
|
19
|
+
export const jobExecutionStatusEnum = pgEnum('workflows_job_execution_status', [
|
|
20
|
+
'pending',
|
|
21
|
+
'running',
|
|
22
|
+
'succeeded',
|
|
23
|
+
'failed',
|
|
24
|
+
'cancelled',
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
export const jobExecutions = pgTable(
|
|
28
|
+
'job_executions',
|
|
29
|
+
{
|
|
30
|
+
id: uuidv7PrimaryKey(),
|
|
31
|
+
jobId: uuid('job_id')
|
|
32
|
+
.notNull()
|
|
33
|
+
.references(() => jobs.id, {onDelete: 'cascade'}),
|
|
34
|
+
sequence: integer('sequence').notNull(),
|
|
35
|
+
name: text('name').notNull(),
|
|
36
|
+
runner: jsonb('runner').$type<string[]>(),
|
|
37
|
+
status: jobExecutionStatusEnum('status').notNull().default('pending'),
|
|
38
|
+
statusReason: jobStatusReasonEnum('status_reason'),
|
|
39
|
+
triggerEvents: jsonb('trigger_events').notNull().default([]).$type<WorkflowExecutionEvent[]>(),
|
|
40
|
+
outputs: jsonb('outputs').$type<Record<string, unknown> | null>(),
|
|
41
|
+
evaluationTrace: jsonb('evaluation_trace').$type<readonly PersistedEvaluationTraceEntry[]>(),
|
|
42
|
+
version: integer('version').notNull().default(1),
|
|
43
|
+
createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),
|
|
44
|
+
updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),
|
|
45
|
+
queuedAt: timestamp('queued_at', {withTimezone: true}),
|
|
46
|
+
startedAt: timestamp('started_at', {withTimezone: true}),
|
|
47
|
+
finishedAt: timestamp('finished_at', {withTimezone: true}),
|
|
48
|
+
timedOutAt: timestamp('timed_out_at', {withTimezone: true}),
|
|
49
|
+
},
|
|
50
|
+
(table) => [
|
|
51
|
+
index('workflows_job_executions_job_id_idx').on(table.jobId),
|
|
52
|
+
// Partial index backing the running-executions depth gauge, which counts on
|
|
53
|
+
// every Prometheus scrape. Indexes only active rows so the count stays cheap
|
|
54
|
+
// as the historical table grows.
|
|
55
|
+
index('workflows_job_executions_running_idx')
|
|
56
|
+
.on(table.status)
|
|
57
|
+
.where(sql`${table.status} = 'running'`),
|
|
58
|
+
uniqueIndex('workflows_job_executions_job_sequence_uq').on(table.jobId, table.sequence),
|
|
59
|
+
],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export type JobExecutionDb = typeof jobExecutions.$inferSelect;
|
|
63
|
+
export type JobExecutionCreateDb = typeof jobExecutions.$inferInsert;
|
|
64
|
+
|
|
65
|
+
export function toJobExecution(row: JobExecutionDb): JobExecution {
|
|
66
|
+
return {
|
|
67
|
+
id: row.id,
|
|
68
|
+
jobId: row.jobId,
|
|
69
|
+
sequence: row.sequence,
|
|
70
|
+
name: row.name,
|
|
71
|
+
runner: row.runner as string[] | null,
|
|
72
|
+
status: row.status,
|
|
73
|
+
statusReason: toJobStatusReason(row.statusReason),
|
|
74
|
+
triggerEvents: row.triggerEvents,
|
|
75
|
+
outputs: row.outputs,
|
|
76
|
+
evaluationTrace: row.evaluationTrace ?? null,
|
|
77
|
+
version: row.version,
|
|
78
|
+
createdAt: row.createdAt,
|
|
79
|
+
updatedAt: row.updatedAt,
|
|
80
|
+
queuedAt: row.queuedAt,
|
|
81
|
+
startedAt: row.startedAt,
|
|
82
|
+
finishedAt: row.finishedAt,
|
|
83
|
+
timedOutAt: row.timedOutAt,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';
|
|
2
|
+
import {index, jsonb, pgEnum, text, timestamp, uniqueIndex, uuid} from 'drizzle-orm/pg-core';
|
|
3
|
+
import type {JobListenerEvent} from '#core/entities/job-listener-event.js';
|
|
4
|
+
import {pgTable} from './common.js';
|
|
5
|
+
import {jobExecutions} from './job-executions.js';
|
|
6
|
+
import {jobs} from './jobs.js';
|
|
7
|
+
|
|
8
|
+
export const jobListenerEventDispositionEnum = pgEnum('workflows_job_listener_event_disposition', [
|
|
9
|
+
'fire',
|
|
10
|
+
'resolve',
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export const jobListenerEvents = pgTable(
|
|
14
|
+
'job_listener_events',
|
|
15
|
+
{
|
|
16
|
+
id: uuidv7PrimaryKey(),
|
|
17
|
+
jobId: uuid('job_id')
|
|
18
|
+
.notNull()
|
|
19
|
+
.references(() => jobs.id, {onDelete: 'cascade'}),
|
|
20
|
+
disposition: jobListenerEventDispositionEnum('disposition').notNull(),
|
|
21
|
+
eventRef: text('event_ref').notNull(),
|
|
22
|
+
deliveryId: text('delivery_id').notNull(),
|
|
23
|
+
source: text('source').notNull(),
|
|
24
|
+
event: text('event').notNull(),
|
|
25
|
+
payload: jsonb('payload').notNull(),
|
|
26
|
+
receivedAt: timestamp('received_at', {withTimezone: true}).notNull(),
|
|
27
|
+
consumedByExecutionId: uuid('consumed_by_execution_id').references(() => jobExecutions.id, {
|
|
28
|
+
onDelete: 'set null',
|
|
29
|
+
}),
|
|
30
|
+
createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),
|
|
31
|
+
},
|
|
32
|
+
(table) => [
|
|
33
|
+
uniqueIndex('workflows_job_listener_events_job_event_ref_unique').on(
|
|
34
|
+
table.jobId,
|
|
35
|
+
table.eventRef,
|
|
36
|
+
),
|
|
37
|
+
index('workflows_job_listener_events_job_received_idx').on(table.jobId, table.receivedAt),
|
|
38
|
+
],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export type JobListenerEventDb = typeof jobListenerEvents.$inferSelect;
|
|
42
|
+
export type JobListenerEventCreateDb = typeof jobListenerEvents.$inferInsert;
|
|
43
|
+
|
|
44
|
+
export function toJobListenerEvent(row: JobListenerEventDb): JobListenerEvent {
|
|
45
|
+
return {
|
|
46
|
+
id: row.id,
|
|
47
|
+
jobId: row.jobId,
|
|
48
|
+
disposition: row.disposition,
|
|
49
|
+
eventRef: row.eventRef,
|
|
50
|
+
deliveryId: row.deliveryId,
|
|
51
|
+
source: row.source,
|
|
52
|
+
event: row.event,
|
|
53
|
+
payload: row.payload,
|
|
54
|
+
receivedAt: row.receivedAt,
|
|
55
|
+
consumedByExecutionId: row.consumedByExecutionId,
|
|
56
|
+
createdAt: row.createdAt,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';
|
|
2
|
+
import {sql} from 'drizzle-orm';
|
|
3
|
+
import {
|
|
4
|
+
bigint,
|
|
5
|
+
boolean,
|
|
6
|
+
index,
|
|
7
|
+
integer,
|
|
8
|
+
jsonb,
|
|
9
|
+
pgEnum,
|
|
10
|
+
text,
|
|
11
|
+
timestamp,
|
|
12
|
+
uuid,
|
|
13
|
+
} from 'drizzle-orm/pg-core';
|
|
14
|
+
import {
|
|
15
|
+
JOB_STATUS_REASONS,
|
|
16
|
+
type Job,
|
|
17
|
+
type JobListeningTrigger,
|
|
18
|
+
toJobStatusReason,
|
|
19
|
+
} from '#core/entities/job.js';
|
|
20
|
+
import type {PersistedEvaluationTraceEntry} from '#core/entities/step.js';
|
|
21
|
+
import {pgTable} from './common.js';
|
|
22
|
+
import {workflowRunAttempts} from './workflow-run-attempts.js';
|
|
23
|
+
|
|
24
|
+
export const jobStatusEnum = pgEnum('workflows_job_status', [
|
|
25
|
+
'pending',
|
|
26
|
+
'running',
|
|
27
|
+
'succeeded',
|
|
28
|
+
'failed',
|
|
29
|
+
'cancelled',
|
|
30
|
+
'skipped',
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
export const jobStatusReasonEnum = pgEnum('workflows_job_status_reason', JOB_STATUS_REASONS);
|
|
34
|
+
|
|
35
|
+
export const jobModeEnum = pgEnum('workflows_job_mode', ['one_shot', 'listening']);
|
|
36
|
+
|
|
37
|
+
export const jobCheckoutContentsEnum = pgEnum('workflows_checkout_contents', ['read', 'write']);
|
|
38
|
+
|
|
39
|
+
export const jobOnResolveEnum = pgEnum('workflows_job_on_resolve', ['finish', 'cancel']);
|
|
40
|
+
|
|
41
|
+
export const listenerStatusEnum = pgEnum('workflows_listener_status', [
|
|
42
|
+
'inactive',
|
|
43
|
+
'listening',
|
|
44
|
+
'resolved',
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
export const resolutionReasonEnum = pgEnum('workflows_resolution_reason', [
|
|
48
|
+
'until',
|
|
49
|
+
'timeout',
|
|
50
|
+
'max_executions',
|
|
51
|
+
'cancelled',
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
export const jobs = pgTable(
|
|
55
|
+
'jobs',
|
|
56
|
+
{
|
|
57
|
+
id: uuidv7PrimaryKey(),
|
|
58
|
+
workflowRunAttemptId: uuid('workflow_run_attempt_id')
|
|
59
|
+
.notNull()
|
|
60
|
+
.references(() => workflowRunAttempts.id, {onDelete: 'cascade'}),
|
|
61
|
+
key: text('key').notNull(),
|
|
62
|
+
mode: jobModeEnum('mode').notNull().default('one_shot'),
|
|
63
|
+
name: text('name'),
|
|
64
|
+
status: jobStatusEnum('status').notNull().default('pending'),
|
|
65
|
+
statusReason: jobStatusReasonEnum('status_reason'),
|
|
66
|
+
carriedOver: boolean('carried_over').notNull().default(false),
|
|
67
|
+
checkoutPersistCredentials: boolean('checkout_persist_credentials').notNull(),
|
|
68
|
+
checkoutPermissionsContents: jobCheckoutContentsEnum('checkout_permissions_contents').notNull(),
|
|
69
|
+
success: text('success'),
|
|
70
|
+
evaluationTrace: jsonb('evaluation_trace').$type<readonly PersistedEvaluationTraceEntry[]>(),
|
|
71
|
+
executionTimeoutMs: integer('execution_timeout_ms'),
|
|
72
|
+
listeningTimeoutMs: bigint('listening_timeout_ms', {mode: 'number'}),
|
|
73
|
+
maxExecutions: integer('max_executions'),
|
|
74
|
+
onResolve: jobOnResolveEnum('on_resolve'),
|
|
75
|
+
batchDebounceMs: integer('batch_debounce_ms'),
|
|
76
|
+
batchMaxSize: integer('batch_max_size'),
|
|
77
|
+
batchMaxWaitMs: integer('batch_max_wait_ms'),
|
|
78
|
+
listenerStatus: listenerStatusEnum('listener_status').notNull().default('inactive'),
|
|
79
|
+
resolutionReason: resolutionReasonEnum('resolution_reason'),
|
|
80
|
+
listeningOn: jsonb('listening_on').$type<JobListeningTrigger[]>(),
|
|
81
|
+
listeningUntil: jsonb('listening_until').$type<JobListeningTrigger[]>(),
|
|
82
|
+
outputs: jsonb('outputs').$type<Record<string, unknown> | null>(),
|
|
83
|
+
dependencies: jsonb('dependencies').notNull().$type<string[]>(),
|
|
84
|
+
runner: jsonb('runner').$type<string[]>(),
|
|
85
|
+
position: integer('position').notNull(),
|
|
86
|
+
version: integer('version').notNull().default(1),
|
|
87
|
+
createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),
|
|
88
|
+
updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),
|
|
89
|
+
},
|
|
90
|
+
(table) => [
|
|
91
|
+
index('workflows_jobs_workflow_run_attempt_id_idx').on(table.workflowRunAttemptId),
|
|
92
|
+
index('workflows_jobs_active_listeners_idx')
|
|
93
|
+
.on(table.listenerStatus)
|
|
94
|
+
.where(sql`${table.listenerStatus} = 'listening'`),
|
|
95
|
+
],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export type JobDb = typeof jobs.$inferSelect;
|
|
99
|
+
export type JobCreateDb = typeof jobs.$inferInsert;
|
|
100
|
+
|
|
101
|
+
export function toJob(row: JobDb): Job {
|
|
102
|
+
return {
|
|
103
|
+
id: row.id,
|
|
104
|
+
workflowRunAttemptId: row.workflowRunAttemptId,
|
|
105
|
+
key: row.key,
|
|
106
|
+
name: row.name,
|
|
107
|
+
mode: row.mode,
|
|
108
|
+
status: row.status,
|
|
109
|
+
statusReason: toJobStatusReason(row.statusReason),
|
|
110
|
+
carriedOver: row.carriedOver,
|
|
111
|
+
checkout: {
|
|
112
|
+
permissions: {contents: row.checkoutPermissionsContents},
|
|
113
|
+
persistCredentials: row.checkoutPersistCredentials,
|
|
114
|
+
},
|
|
115
|
+
success: row.success,
|
|
116
|
+
evaluationTrace: row.evaluationTrace ?? null,
|
|
117
|
+
executionTimeoutMs: row.executionTimeoutMs,
|
|
118
|
+
listeningTimeoutMs: row.listeningTimeoutMs,
|
|
119
|
+
maxExecutions: row.maxExecutions,
|
|
120
|
+
onResolve: row.onResolve,
|
|
121
|
+
batchDebounceMs: row.batchDebounceMs,
|
|
122
|
+
batchMaxSize: row.batchMaxSize,
|
|
123
|
+
batchMaxWaitMs: row.batchMaxWaitMs,
|
|
124
|
+
listenerStatus: row.listenerStatus,
|
|
125
|
+
resolutionReason: row.resolutionReason,
|
|
126
|
+
listeningOn: row.listeningOn,
|
|
127
|
+
listeningUntil: row.listeningUntil,
|
|
128
|
+
outputs: row.outputs,
|
|
129
|
+
dependencies: row.dependencies as string[],
|
|
130
|
+
runner: row.runner as string[] | null,
|
|
131
|
+
position: row.position,
|
|
132
|
+
version: row.version,
|
|
133
|
+
createdAt: row.createdAt,
|
|
134
|
+
updatedAt: row.updatedAt,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';
|
|
2
|
+
import {sql} from 'drizzle-orm';
|
|
3
|
+
import {
|
|
4
|
+
check,
|
|
5
|
+
foreignKey,
|
|
6
|
+
integer,
|
|
7
|
+
jsonb,
|
|
8
|
+
text,
|
|
9
|
+
timestamp,
|
|
10
|
+
unique,
|
|
11
|
+
uuid,
|
|
12
|
+
} from 'drizzle-orm/pg-core';
|
|
13
|
+
import type {
|
|
14
|
+
PersistedEvaluationTraceEntry,
|
|
15
|
+
StepAttempt,
|
|
16
|
+
StepAttemptLogOutcome,
|
|
17
|
+
StepAttemptStatus,
|
|
18
|
+
} from '#core/entities/step.js';
|
|
19
|
+
import {pgTable} from './common.js';
|
|
20
|
+
import {stepStatusEnum, steps} from './steps.js';
|
|
21
|
+
|
|
22
|
+
// Append-only execution history. One row per dispatched attempt of a step,
|
|
23
|
+
// inserted `running` at dispatch and finalized terminal at report. `steps` holds
|
|
24
|
+
// the fast current projection; this table is the audit trail and — via the
|
|
25
|
+
// unique (step_id, attempt) constraint — the idempotency anchor.
|
|
26
|
+
export const stepAttempts = pgTable(
|
|
27
|
+
'step_attempts',
|
|
28
|
+
{
|
|
29
|
+
id: uuidv7PrimaryKey(),
|
|
30
|
+
stepId: uuid('step_id')
|
|
31
|
+
.notNull()
|
|
32
|
+
.references(() => steps.id, {onDelete: 'cascade'}),
|
|
33
|
+
jobExecutionId: uuid('job_execution_id').notNull(),
|
|
34
|
+
attempt: integer('attempt').notNull(),
|
|
35
|
+
executionOrder: integer('execution_order').notNull(),
|
|
36
|
+
// Reuses the step status enum, but a row is created only once dispatched, so
|
|
37
|
+
// it is never 'pending'.
|
|
38
|
+
status: stepStatusEnum('status').notNull(),
|
|
39
|
+
config: jsonb('config').$type<Record<string, unknown>>(),
|
|
40
|
+
evaluationTrace: jsonb('evaluation_trace').$type<readonly PersistedEvaluationTraceEntry[]>(),
|
|
41
|
+
output: jsonb('output').$type<Record<string, unknown>>(),
|
|
42
|
+
response: text('response'),
|
|
43
|
+
error: jsonb('error').$type<Record<string, unknown>>(),
|
|
44
|
+
exitCode: integer('exit_code'),
|
|
45
|
+
logOutcome: text('log_outcome').$type<StepAttemptLogOutcome>(),
|
|
46
|
+
gateResult: jsonb('gate_result').$type<Record<string, unknown>>(),
|
|
47
|
+
restartFeedback: text('restart_feedback'),
|
|
48
|
+
startedAt: timestamp('started_at', {withTimezone: true}).notNull().defaultNow(),
|
|
49
|
+
finishedAt: timestamp('finished_at', {withTimezone: true}),
|
|
50
|
+
createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),
|
|
51
|
+
},
|
|
52
|
+
(table) => [
|
|
53
|
+
unique('workflows_step_attempts_step_id_attempt_uq').on(table.stepId, table.attempt),
|
|
54
|
+
unique('workflows_step_attempts_job_execution_id_execution_order_uq').on(
|
|
55
|
+
table.jobExecutionId,
|
|
56
|
+
table.executionOrder,
|
|
57
|
+
),
|
|
58
|
+
foreignKey({
|
|
59
|
+
name: 'workflows_step_attempts_step_id_job_execution_id_workflows_steps_fk',
|
|
60
|
+
columns: [table.stepId, table.jobExecutionId],
|
|
61
|
+
foreignColumns: [steps.id, steps.jobExecutionId],
|
|
62
|
+
}).onDelete('cascade'),
|
|
63
|
+
check('workflows_step_attempts_attempt_positive_ck', sql`${table.attempt} > 0`),
|
|
64
|
+
check('workflows_step_attempts_execution_order_positive_ck', sql`${table.executionOrder} > 0`),
|
|
65
|
+
check(
|
|
66
|
+
'workflows_step_attempts_status_dispatched_ck',
|
|
67
|
+
sql`${table.status} NOT IN ('pending', 'skipped')`,
|
|
68
|
+
),
|
|
69
|
+
check(
|
|
70
|
+
'workflows_step_attempts_log_outcome_ck',
|
|
71
|
+
sql`${table.logOutcome} IS NULL OR ${table.logOutcome} IN ('drained', 'abandoned')`,
|
|
72
|
+
),
|
|
73
|
+
],
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export type StepAttemptDb = typeof stepAttempts.$inferSelect;
|
|
77
|
+
export type StepAttemptCreateDb = typeof stepAttempts.$inferInsert;
|
|
78
|
+
|
|
79
|
+
export function toStepAttempt(row: StepAttemptDb): StepAttempt {
|
|
80
|
+
return {
|
|
81
|
+
id: row.id,
|
|
82
|
+
stepId: row.stepId,
|
|
83
|
+
attempt: row.attempt,
|
|
84
|
+
executionOrder: row.executionOrder,
|
|
85
|
+
status: row.status as StepAttemptStatus,
|
|
86
|
+
config: (row.config as Record<string, unknown>) ?? null,
|
|
87
|
+
evaluationTrace: row.evaluationTrace ?? null,
|
|
88
|
+
output: (row.output as Record<string, unknown>) ?? null,
|
|
89
|
+
response: row.response ?? null,
|
|
90
|
+
error: (row.error as Record<string, unknown>) ?? null,
|
|
91
|
+
exitCode: row.exitCode ?? null,
|
|
92
|
+
logOutcome: row.logOutcome ?? null,
|
|
93
|
+
gateResult: (row.gateResult as Record<string, unknown>) ?? null,
|
|
94
|
+
restartFeedback: row.restartFeedback ?? null,
|
|
95
|
+
startedAt: row.startedAt,
|
|
96
|
+
finishedAt: row.finishedAt ?? null,
|
|
97
|
+
createdAt: row.createdAt,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type {WorkflowExpression} from '@shipfox/expression';
|
|
2
|
+
import {uuidv7PrimaryKey} from '@shipfox/node-drizzle';
|
|
3
|
+
import {sql} from 'drizzle-orm';
|
|
4
|
+
import {
|
|
5
|
+
check,
|
|
6
|
+
foreignKey,
|
|
7
|
+
index,
|
|
8
|
+
integer,
|
|
9
|
+
jsonb,
|
|
10
|
+
pgEnum,
|
|
11
|
+
text,
|
|
12
|
+
timestamp,
|
|
13
|
+
uniqueIndex,
|
|
14
|
+
uuid,
|
|
15
|
+
} from 'drizzle-orm/pg-core';
|
|
16
|
+
import {
|
|
17
|
+
type PersistedEvaluationTraceEntry,
|
|
18
|
+
STEP_STATUS_REASONS,
|
|
19
|
+
type Step,
|
|
20
|
+
type StepConfigDispatchPlan,
|
|
21
|
+
toStepStatusReason,
|
|
22
|
+
} from '#core/entities/step.js';
|
|
23
|
+
import {pgTable} from './common.js';
|
|
24
|
+
import {jobExecutions} from './job-executions.js';
|
|
25
|
+
|
|
26
|
+
export const stepStatusEnum = pgEnum('workflows_step_status', [
|
|
27
|
+
'pending',
|
|
28
|
+
'running',
|
|
29
|
+
'succeeded',
|
|
30
|
+
'failed',
|
|
31
|
+
'cancelled',
|
|
32
|
+
'skipped',
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
export const stepStatusReasonEnum = pgEnum('workflows_step_status_reason', STEP_STATUS_REASONS);
|
|
36
|
+
|
|
37
|
+
export const steps = pgTable(
|
|
38
|
+
'steps',
|
|
39
|
+
{
|
|
40
|
+
id: uuidv7PrimaryKey(),
|
|
41
|
+
jobExecutionId: uuid('job_execution_id').notNull(),
|
|
42
|
+
key: text('key'),
|
|
43
|
+
name: text('name').notNull(),
|
|
44
|
+
sourceLocation: jsonb('source_location').$type<Step['sourceLocation']>(),
|
|
45
|
+
status: stepStatusEnum('status').notNull().default('pending'),
|
|
46
|
+
statusReason: stepStatusReasonEnum('status_reason'),
|
|
47
|
+
evaluationTrace: jsonb('evaluation_trace').$type<readonly PersistedEvaluationTraceEntry[]>(),
|
|
48
|
+
type: text('type').notNull(),
|
|
49
|
+
config: jsonb('config').notNull().$type<Record<string, unknown>>(),
|
|
50
|
+
condition: jsonb('condition').$type<WorkflowExpression>(),
|
|
51
|
+
configPlan: jsonb('config_plan').$type<StepConfigDispatchPlan>(),
|
|
52
|
+
authoredConfig: jsonb('authored_config').$type<Record<string, unknown>>(),
|
|
53
|
+
error: jsonb('error').$type<Record<string, unknown>>(),
|
|
54
|
+
position: integer('position').notNull(),
|
|
55
|
+
version: integer('version').notNull().default(1),
|
|
56
|
+
// Execution-attempt identity, distinct from the optimistic `version` counter.
|
|
57
|
+
// Starts at 1 and is bumped only on durable rewind.
|
|
58
|
+
currentAttempt: integer('current_attempt').notNull().default(1),
|
|
59
|
+
createdAt: timestamp('created_at', {withTimezone: true}).notNull().defaultNow(),
|
|
60
|
+
updatedAt: timestamp('updated_at', {withTimezone: true}).notNull().defaultNow(),
|
|
61
|
+
},
|
|
62
|
+
(table) => [
|
|
63
|
+
index('workflows_steps_job_execution_id_idx').on(table.jobExecutionId),
|
|
64
|
+
uniqueIndex('workflows_steps_id_job_execution_id_uq').on(table.id, table.jobExecutionId),
|
|
65
|
+
check('workflows_steps_current_attempt_positive_ck', sql`${table.currentAttempt} > 0`),
|
|
66
|
+
foreignKey({
|
|
67
|
+
name: 'workflows_steps_job_execution_id_workflows_job_executions_id_fk',
|
|
68
|
+
columns: [table.jobExecutionId],
|
|
69
|
+
foreignColumns: [jobExecutions.id],
|
|
70
|
+
}).onDelete('cascade'),
|
|
71
|
+
],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
export type StepDb = typeof steps.$inferSelect;
|
|
75
|
+
export type StepCreateDb = typeof steps.$inferInsert;
|
|
76
|
+
|
|
77
|
+
export function toStep(row: StepDb): Step {
|
|
78
|
+
return {
|
|
79
|
+
id: row.id,
|
|
80
|
+
jobExecutionId: row.jobExecutionId,
|
|
81
|
+
key: row.key,
|
|
82
|
+
name: row.name,
|
|
83
|
+
sourceLocation: row.sourceLocation ?? null,
|
|
84
|
+
status: row.status,
|
|
85
|
+
statusReason: toStepStatusReason(row.statusReason),
|
|
86
|
+
evaluationTrace: row.evaluationTrace ?? null,
|
|
87
|
+
type: row.type,
|
|
88
|
+
config: row.config as Record<string, unknown>,
|
|
89
|
+
condition: (row.condition as WorkflowExpression) ?? null,
|
|
90
|
+
configPlan: row.configPlan ?? null,
|
|
91
|
+
authoredConfig: (row.authoredConfig as Record<string, unknown>) ?? null,
|
|
92
|
+
error: (row.error as Record<string, unknown>) ?? null,
|
|
93
|
+
position: row.position,
|
|
94
|
+
version: row.version,
|
|
95
|
+
currentAttempt: row.currentAttempt,
|
|
96
|
+
createdAt: row.createdAt,
|
|
97
|
+
updatedAt: row.updatedAt,
|
|
98
|
+
};
|
|
99
|
+
}
|