@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,476 @@
|
|
|
1
|
+
import type {LogOutcomeDto} from '@shipfox/api-workflows-dto';
|
|
2
|
+
import {and, asc, count, eq, gte, inArray, sql} from 'drizzle-orm';
|
|
3
|
+
import type {
|
|
4
|
+
PersistedEvaluationTraceEntry,
|
|
5
|
+
Step,
|
|
6
|
+
StepAttempt,
|
|
7
|
+
StepAttemptStatus,
|
|
8
|
+
StepStatus,
|
|
9
|
+
StepStatusReason,
|
|
10
|
+
} from '#core/entities/step.js';
|
|
11
|
+
import {deriveCompletion, isTerminal} from '#core/step-transition/decide-step-transition.js';
|
|
12
|
+
import {db, type Tx} from '../db.js';
|
|
13
|
+
import {jobExecutions} from '../schema/job-executions.js';
|
|
14
|
+
import {stepAttempts, toStepAttempt} from '../schema/step-attempts.js';
|
|
15
|
+
import {steps, toStep} from '../schema/steps.js';
|
|
16
|
+
import {writeJobStepsSettledOutbox, writeStepAttemptTerminatedOutbox} from './outbox.js';
|
|
17
|
+
import {NON_TERMINAL_STEP_STATUS_FILTER} from './shared.js';
|
|
18
|
+
|
|
19
|
+
export async function getStepByIdForJobExecution(params: {
|
|
20
|
+
stepId: string;
|
|
21
|
+
jobExecutionId: string;
|
|
22
|
+
}): Promise<Step | undefined> {
|
|
23
|
+
const rows = await db()
|
|
24
|
+
.select()
|
|
25
|
+
.from(steps)
|
|
26
|
+
.where(and(eq(steps.id, params.stepId), eq(steps.jobExecutionId, params.jobExecutionId)))
|
|
27
|
+
.limit(1);
|
|
28
|
+
|
|
29
|
+
const row = rows[0];
|
|
30
|
+
if (!row) return undefined;
|
|
31
|
+
return toStep(row);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function getStepById(stepId: string): Promise<Step | undefined> {
|
|
35
|
+
const rows = await db().select().from(steps).where(eq(steps.id, stepId)).limit(1);
|
|
36
|
+
|
|
37
|
+
const row = rows[0];
|
|
38
|
+
if (!row) return undefined;
|
|
39
|
+
return toStep(row);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function getStepsByJobId(jobId: string): Promise<Step[]> {
|
|
43
|
+
const rows = await db()
|
|
44
|
+
.select({step: steps})
|
|
45
|
+
.from(steps)
|
|
46
|
+
.innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))
|
|
47
|
+
.where(eq(jobExecutions.jobId, jobId))
|
|
48
|
+
.orderBy(asc(steps.position));
|
|
49
|
+
return rows.map((row) => toStep(row.step));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function getStepsByJobExecutionId(jobExecutionId: string): Promise<Step[]> {
|
|
53
|
+
const rows = await db()
|
|
54
|
+
.select()
|
|
55
|
+
.from(steps)
|
|
56
|
+
.where(eq(steps.jobExecutionId, jobExecutionId))
|
|
57
|
+
.orderBy(asc(steps.position));
|
|
58
|
+
return rows.map(toStep);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface BulkUpdateStepStatusesParams {
|
|
62
|
+
jobExecutionId: string;
|
|
63
|
+
status: Extract<StepStatus, 'failed' | 'cancelled'>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function bulkUpdateStepStatuses(
|
|
67
|
+
params: BulkUpdateStepStatusesParams,
|
|
68
|
+
tx?: Tx,
|
|
69
|
+
): Promise<void> {
|
|
70
|
+
if (!tx) {
|
|
71
|
+
await db().transaction((transaction) => bulkUpdateStepStatuses(params, transaction));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
await tx
|
|
76
|
+
.update(steps)
|
|
77
|
+
.set({
|
|
78
|
+
status: params.status,
|
|
79
|
+
statusReason: null,
|
|
80
|
+
updatedAt: new Date(),
|
|
81
|
+
})
|
|
82
|
+
.where(and(eq(steps.jobExecutionId, params.jobExecutionId), NON_TERMINAL_STEP_STATUS_FILTER));
|
|
83
|
+
|
|
84
|
+
// Finalize open attempt rows so a timed-out/cancelled sweep does not leave
|
|
85
|
+
// phantom in-flight work for gate and restart logic.
|
|
86
|
+
const finalizedAttempts = await tx
|
|
87
|
+
.update(stepAttempts)
|
|
88
|
+
.set({status: params.status, logOutcome: 'abandoned', finishedAt: new Date()})
|
|
89
|
+
.from(steps)
|
|
90
|
+
.where(
|
|
91
|
+
and(
|
|
92
|
+
eq(stepAttempts.stepId, steps.id),
|
|
93
|
+
eq(steps.jobExecutionId, params.jobExecutionId),
|
|
94
|
+
eq(stepAttempts.status, 'running'),
|
|
95
|
+
),
|
|
96
|
+
)
|
|
97
|
+
.returning({
|
|
98
|
+
stepId: stepAttempts.stepId,
|
|
99
|
+
attempt: stepAttempts.attempt,
|
|
100
|
+
logOutcome: stepAttempts.logOutcome,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (finalizedAttempts.length > 0) {
|
|
104
|
+
for (const attempt of finalizedAttempts) {
|
|
105
|
+
await writeStepAttemptTerminatedOutbox(tx, {
|
|
106
|
+
stepId: attempt.stepId,
|
|
107
|
+
attempt: attempt.attempt,
|
|
108
|
+
logOutcome: attempt.logOutcome ?? 'abandoned',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Per-step progression primitives. They take a mandatory `tx` because they only
|
|
115
|
+
// run inside the job-execution service's transaction, and every write guards on
|
|
116
|
+
// the never-downgrade predicate so a late or duplicate write cannot overwrite an
|
|
117
|
+
// already-terminal row.
|
|
118
|
+
|
|
119
|
+
export async function getStepsByJobExecutionIdForUpdate(
|
|
120
|
+
jobExecutionId: string,
|
|
121
|
+
tx: Tx,
|
|
122
|
+
): Promise<Step[]> {
|
|
123
|
+
const rows = await tx
|
|
124
|
+
.select()
|
|
125
|
+
.from(steps)
|
|
126
|
+
.where(eq(steps.jobExecutionId, jobExecutionId))
|
|
127
|
+
.orderBy(asc(steps.position))
|
|
128
|
+
.for('update');
|
|
129
|
+
return rows.map(toStep);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export async function getStepAttemptsByJobExecutionId(
|
|
133
|
+
jobExecutionId: string,
|
|
134
|
+
tx: Tx,
|
|
135
|
+
): Promise<StepAttempt[]> {
|
|
136
|
+
const rows = await tx
|
|
137
|
+
.select()
|
|
138
|
+
.from(stepAttempts)
|
|
139
|
+
.where(eq(stepAttempts.jobExecutionId, jobExecutionId))
|
|
140
|
+
.orderBy(asc(stepAttempts.executionOrder), asc(stepAttempts.id));
|
|
141
|
+
return rows.map(toStepAttempt);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface MarkStepRunningParams {
|
|
145
|
+
jobExecutionId: string;
|
|
146
|
+
stepId: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export async function markStepRunning(params: MarkStepRunningParams, tx: Tx): Promise<Step | null> {
|
|
150
|
+
const rows = await tx
|
|
151
|
+
.update(steps)
|
|
152
|
+
.set({
|
|
153
|
+
status: 'running',
|
|
154
|
+
statusReason: null,
|
|
155
|
+
evaluationTrace: null,
|
|
156
|
+
updatedAt: new Date(),
|
|
157
|
+
})
|
|
158
|
+
.where(
|
|
159
|
+
and(
|
|
160
|
+
eq(steps.id, params.stepId),
|
|
161
|
+
eq(steps.jobExecutionId, params.jobExecutionId),
|
|
162
|
+
NON_TERMINAL_STEP_STATUS_FILTER,
|
|
163
|
+
),
|
|
164
|
+
)
|
|
165
|
+
.returning();
|
|
166
|
+
const row = rows[0];
|
|
167
|
+
if (!row) return null;
|
|
168
|
+
const step = toStep(row);
|
|
169
|
+
// Open the attempt this dispatch runs. onConflictDoNothing makes a racing
|
|
170
|
+
// re-dispatch a no-op against the unique (step_id, attempt) anchor; normal
|
|
171
|
+
// re-delivery returns the already-running step without calling this.
|
|
172
|
+
await insertRunningStepAttempt(
|
|
173
|
+
{
|
|
174
|
+
jobExecutionId: step.jobExecutionId,
|
|
175
|
+
stepId: step.id,
|
|
176
|
+
attempt: step.currentAttempt,
|
|
177
|
+
config: step.config,
|
|
178
|
+
},
|
|
179
|
+
tx,
|
|
180
|
+
);
|
|
181
|
+
return step;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface DispatchStepWithCompletedConfigParams {
|
|
185
|
+
jobExecutionId: string;
|
|
186
|
+
stepId: string;
|
|
187
|
+
config: Record<string, unknown>;
|
|
188
|
+
evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export async function dispatchStepWithCompletedConfig(
|
|
192
|
+
params: DispatchStepWithCompletedConfigParams,
|
|
193
|
+
tx: Tx,
|
|
194
|
+
): Promise<Step | null> {
|
|
195
|
+
const rows = await tx
|
|
196
|
+
.update(steps)
|
|
197
|
+
.set({
|
|
198
|
+
status: 'running',
|
|
199
|
+
statusReason: null,
|
|
200
|
+
evaluationTrace: null,
|
|
201
|
+
config: params.config,
|
|
202
|
+
updatedAt: new Date(),
|
|
203
|
+
})
|
|
204
|
+
.where(
|
|
205
|
+
and(
|
|
206
|
+
eq(steps.id, params.stepId),
|
|
207
|
+
eq(steps.jobExecutionId, params.jobExecutionId),
|
|
208
|
+
NON_TERMINAL_STEP_STATUS_FILTER,
|
|
209
|
+
),
|
|
210
|
+
)
|
|
211
|
+
.returning();
|
|
212
|
+
const row = rows[0];
|
|
213
|
+
if (!row) return null;
|
|
214
|
+
const step = toStep(row);
|
|
215
|
+
await insertRunningStepAttempt(
|
|
216
|
+
{
|
|
217
|
+
jobExecutionId: step.jobExecutionId,
|
|
218
|
+
stepId: step.id,
|
|
219
|
+
attempt: step.currentAttempt,
|
|
220
|
+
config: params.config,
|
|
221
|
+
evaluationTrace: params.evaluationTrace,
|
|
222
|
+
},
|
|
223
|
+
tx,
|
|
224
|
+
);
|
|
225
|
+
return step;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface MarkStepSkippedParams {
|
|
229
|
+
jobExecutionId: string;
|
|
230
|
+
stepId: string;
|
|
231
|
+
statusReason: StepStatusReason;
|
|
232
|
+
evaluationTrace: readonly PersistedEvaluationTraceEntry[];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export async function markStepSkipped(params: MarkStepSkippedParams, tx: Tx): Promise<Step | null> {
|
|
236
|
+
const rows = await tx
|
|
237
|
+
.update(steps)
|
|
238
|
+
.set({
|
|
239
|
+
status: 'skipped',
|
|
240
|
+
statusReason: params.statusReason,
|
|
241
|
+
evaluationTrace: params.evaluationTrace,
|
|
242
|
+
error: null,
|
|
243
|
+
updatedAt: new Date(),
|
|
244
|
+
})
|
|
245
|
+
.where(
|
|
246
|
+
and(
|
|
247
|
+
eq(steps.id, params.stepId),
|
|
248
|
+
eq(steps.jobExecutionId, params.jobExecutionId),
|
|
249
|
+
eq(steps.status, 'pending'),
|
|
250
|
+
),
|
|
251
|
+
)
|
|
252
|
+
.returning();
|
|
253
|
+
const row = rows[0];
|
|
254
|
+
return row ? toStep(row) : null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export async function settleJobFailed(
|
|
258
|
+
tx: Tx,
|
|
259
|
+
params: {
|
|
260
|
+
jobId: string;
|
|
261
|
+
jobExecutionId: string;
|
|
262
|
+
failedStepId: string;
|
|
263
|
+
error: Record<string, unknown>;
|
|
264
|
+
},
|
|
265
|
+
): Promise<'succeeded' | 'failed' | null> {
|
|
266
|
+
await applyStepResult(
|
|
267
|
+
{
|
|
268
|
+
jobExecutionId: params.jobExecutionId,
|
|
269
|
+
stepId: params.failedStepId,
|
|
270
|
+
status: 'failed',
|
|
271
|
+
error: params.error,
|
|
272
|
+
},
|
|
273
|
+
tx,
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
const after = await getStepsByJobExecutionIdForUpdate(params.jobExecutionId, tx);
|
|
277
|
+
if (!after.every((step) => isTerminal(step.status))) return null;
|
|
278
|
+
|
|
279
|
+
const status = deriveCompletion(after);
|
|
280
|
+
await writeJobStepsSettledOutbox(tx, {
|
|
281
|
+
jobId: params.jobId,
|
|
282
|
+
jobExecutionId: params.jobExecutionId,
|
|
283
|
+
status,
|
|
284
|
+
});
|
|
285
|
+
return status;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface InsertRunningStepAttemptParams {
|
|
289
|
+
jobExecutionId: string;
|
|
290
|
+
stepId: string;
|
|
291
|
+
attempt: number;
|
|
292
|
+
config?: Record<string, unknown> | null;
|
|
293
|
+
evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export async function insertRunningStepAttempt(
|
|
297
|
+
params: InsertRunningStepAttemptParams,
|
|
298
|
+
tx: Tx,
|
|
299
|
+
): Promise<void> {
|
|
300
|
+
const [{nextExecutionOrder} = {nextExecutionOrder: 1}] = await tx
|
|
301
|
+
.select({
|
|
302
|
+
nextExecutionOrder: sql<number>`coalesce(max(${stepAttempts.executionOrder}), 0) + 1`,
|
|
303
|
+
})
|
|
304
|
+
.from(stepAttempts)
|
|
305
|
+
.where(eq(stepAttempts.jobExecutionId, params.jobExecutionId));
|
|
306
|
+
|
|
307
|
+
await tx
|
|
308
|
+
.insert(stepAttempts)
|
|
309
|
+
.values({
|
|
310
|
+
jobExecutionId: params.jobExecutionId,
|
|
311
|
+
stepId: params.stepId,
|
|
312
|
+
attempt: params.attempt,
|
|
313
|
+
executionOrder: nextExecutionOrder,
|
|
314
|
+
status: 'running',
|
|
315
|
+
config: params.config ?? null,
|
|
316
|
+
evaluationTrace: params.evaluationTrace ?? null,
|
|
317
|
+
})
|
|
318
|
+
.onConflictDoNothing({target: [stepAttempts.stepId, stepAttempts.attempt]});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface FinishStepAttemptParams {
|
|
322
|
+
stepId: string;
|
|
323
|
+
attempt: number;
|
|
324
|
+
status: Exclude<StepAttemptStatus, 'running'>;
|
|
325
|
+
error?: Record<string, unknown> | null;
|
|
326
|
+
output?: Record<string, unknown> | null;
|
|
327
|
+
response?: string | null;
|
|
328
|
+
exitCode?: number | null;
|
|
329
|
+
logOutcome: LogOutcomeDto;
|
|
330
|
+
gateResult?: Record<string, unknown> | null;
|
|
331
|
+
restartFeedback?: string | null;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Finalize the running attempt to a terminal state. The `status='running'` guard
|
|
335
|
+
// makes this idempotent: a duplicate report finds the attempt already terminal
|
|
336
|
+
// and updates nothing (never-downgrade for the audit row).
|
|
337
|
+
export async function finishStepAttempt(params: FinishStepAttemptParams, tx: Tx): Promise<void> {
|
|
338
|
+
const rows = await tx
|
|
339
|
+
.update(stepAttempts)
|
|
340
|
+
.set({
|
|
341
|
+
status: params.status,
|
|
342
|
+
output: params.output ?? null,
|
|
343
|
+
response: params.response ?? null,
|
|
344
|
+
error: params.error ?? null,
|
|
345
|
+
exitCode: params.exitCode ?? null,
|
|
346
|
+
logOutcome: params.logOutcome,
|
|
347
|
+
gateResult: params.gateResult ?? null,
|
|
348
|
+
restartFeedback: params.restartFeedback ?? null,
|
|
349
|
+
finishedAt: new Date(),
|
|
350
|
+
})
|
|
351
|
+
.where(
|
|
352
|
+
and(
|
|
353
|
+
eq(stepAttempts.stepId, params.stepId),
|
|
354
|
+
eq(stepAttempts.attempt, params.attempt),
|
|
355
|
+
eq(stepAttempts.status, 'running'),
|
|
356
|
+
),
|
|
357
|
+
)
|
|
358
|
+
.returning({
|
|
359
|
+
stepId: stepAttempts.stepId,
|
|
360
|
+
attempt: stepAttempts.attempt,
|
|
361
|
+
logOutcome: stepAttempts.logOutcome,
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
const row = rows[0];
|
|
365
|
+
if (!row) return;
|
|
366
|
+
|
|
367
|
+
await writeStepAttemptTerminatedOutbox(tx, {
|
|
368
|
+
stepId: row.stepId,
|
|
369
|
+
attempt: row.attempt,
|
|
370
|
+
logOutcome: row.logOutcome ?? params.logOutcome,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface RewindStepsToPendingParams {
|
|
375
|
+
jobExecutionId: string;
|
|
376
|
+
fromPosition: number;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Restart-only: rewind every step at or after `fromPosition` back to pending,
|
|
380
|
+
// clearing its result and bumping both `version` and `current_attempt` so the next
|
|
381
|
+
// dispatch opens a fresh attempt. This DELIBERATELY bypasses the never-downgrade
|
|
382
|
+
// guard used everywhere else — it is the one place that resurrects terminal steps
|
|
383
|
+
// — so it must only be called from the durable-restart path, never the ordinary
|
|
384
|
+
// report path. It must run in the same transaction as the failed-attempt write.
|
|
385
|
+
export async function rewindStepsToPending(
|
|
386
|
+
params: RewindStepsToPendingParams,
|
|
387
|
+
tx: Tx,
|
|
388
|
+
): Promise<void> {
|
|
389
|
+
await tx
|
|
390
|
+
.update(steps)
|
|
391
|
+
.set({
|
|
392
|
+
status: 'pending',
|
|
393
|
+
statusReason: null,
|
|
394
|
+
error: null,
|
|
395
|
+
version: sql`${steps.version} + 1`,
|
|
396
|
+
currentAttempt: sql`${steps.currentAttempt} + 1`,
|
|
397
|
+
updatedAt: new Date(),
|
|
398
|
+
})
|
|
399
|
+
.where(
|
|
400
|
+
and(
|
|
401
|
+
eq(steps.jobExecutionId, params.jobExecutionId),
|
|
402
|
+
gte(steps.position, params.fromPosition),
|
|
403
|
+
),
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Count a single step's own attempts. Used to bound the restart cap on the
|
|
408
|
+
// gating step's actual executions — `steps.current_attempt` can't be used for
|
|
409
|
+
// the cap because a rewind also bumps it for downstream steps swept into the
|
|
410
|
+
// rewind range (which would inflate a later gate's cap in a multi-gate job).
|
|
411
|
+
export async function countStepAttempts(stepId: string, tx: Tx): Promise<number> {
|
|
412
|
+
const rows = await tx
|
|
413
|
+
.select({total: count()})
|
|
414
|
+
.from(stepAttempts)
|
|
415
|
+
.where(eq(stepAttempts.stepId, stepId));
|
|
416
|
+
return Number(rows[0]?.total ?? 0);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export async function getStepAttempts(jobId: string): Promise<StepAttempt[]> {
|
|
420
|
+
const rows = await db()
|
|
421
|
+
.select({stepAttempt: stepAttempts})
|
|
422
|
+
.from(stepAttempts)
|
|
423
|
+
.innerJoin(steps, eq(stepAttempts.stepId, steps.id))
|
|
424
|
+
.innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))
|
|
425
|
+
.where(eq(jobExecutions.jobId, jobId))
|
|
426
|
+
.orderBy(asc(stepAttempts.executionOrder));
|
|
427
|
+
return rows.map((row) => toStepAttempt(row.stepAttempt));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export async function getStepAttemptsByJobIds(jobIds: string[]): Promise<StepAttempt[]> {
|
|
431
|
+
if (jobIds.length === 0) return [];
|
|
432
|
+
const rows = await db()
|
|
433
|
+
.select({stepAttempt: stepAttempts, jobId: jobExecutions.jobId})
|
|
434
|
+
.from(stepAttempts)
|
|
435
|
+
.innerJoin(steps, eq(stepAttempts.stepId, steps.id))
|
|
436
|
+
.innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))
|
|
437
|
+
.where(inArray(jobExecutions.jobId, jobIds))
|
|
438
|
+
.orderBy(asc(jobExecutions.jobId), asc(stepAttempts.executionOrder));
|
|
439
|
+
return rows.map((row) => toStepAttempt(row.stepAttempt));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export interface ApplyStepResultParams {
|
|
443
|
+
jobExecutionId: string;
|
|
444
|
+
stepId: string;
|
|
445
|
+
status: 'succeeded' | 'failed';
|
|
446
|
+
error: Record<string, unknown> | null;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export async function applyStepResult(params: ApplyStepResultParams, tx: Tx): Promise<void> {
|
|
450
|
+
await tx
|
|
451
|
+
.update(steps)
|
|
452
|
+
.set({
|
|
453
|
+
status: params.status,
|
|
454
|
+
statusReason: null,
|
|
455
|
+
error: params.error ?? null,
|
|
456
|
+
updatedAt: new Date(),
|
|
457
|
+
})
|
|
458
|
+
.where(
|
|
459
|
+
and(
|
|
460
|
+
eq(steps.id, params.stepId),
|
|
461
|
+
eq(steps.jobExecutionId, params.jobExecutionId),
|
|
462
|
+
NON_TERMINAL_STEP_STATUS_FILTER,
|
|
463
|
+
),
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export interface CancelRemainingStepsParams {
|
|
468
|
+
jobExecutionId: string;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export async function cancelRemainingSteps(
|
|
472
|
+
params: CancelRemainingStepsParams,
|
|
473
|
+
tx: Tx,
|
|
474
|
+
): Promise<void> {
|
|
475
|
+
await bulkUpdateStepStatuses({jobExecutionId: params.jobExecutionId, status: 'cancelled'}, tx);
|
|
476
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
UpdateJobExecutionStatusAtVersionParams,
|
|
3
|
+
UpdateJobExecutionStatusParams,
|
|
4
|
+
} from './workflow-runs/job-executions.js';
|
|
5
|
+
export {
|
|
6
|
+
failJobExecutionAsTimedOut,
|
|
7
|
+
getFirstJobExecutionByJobId,
|
|
8
|
+
getJobExecutionById,
|
|
9
|
+
getJobExecutionsByJobId,
|
|
10
|
+
getJobExecutionsByWorkflowRunAttemptId,
|
|
11
|
+
getLatestJobExecutionByJobId,
|
|
12
|
+
lockActiveJobExecutionLeaseForUpdate,
|
|
13
|
+
recordJobExecutionQueuedAt,
|
|
14
|
+
recordJobExecutionStartedAt,
|
|
15
|
+
resolveJobExecutionAfterLeaseExpiry,
|
|
16
|
+
updateJobExecutionStatus,
|
|
17
|
+
} from './workflow-runs/job-executions.js';
|
|
18
|
+
export type {
|
|
19
|
+
EvaluateJobActivationsParams,
|
|
20
|
+
EvaluateJobSuccessResult,
|
|
21
|
+
JobActivationDecision,
|
|
22
|
+
JobScope,
|
|
23
|
+
UpdateJobStatusAtVersionParams,
|
|
24
|
+
UpdateJobStatusParams,
|
|
25
|
+
} from './workflow-runs/jobs.js';
|
|
26
|
+
export {
|
|
27
|
+
evaluateJobActivations,
|
|
28
|
+
evaluateJobSuccess,
|
|
29
|
+
getDirectDependencyJobContexts,
|
|
30
|
+
getJobById,
|
|
31
|
+
getJobScope,
|
|
32
|
+
getJobsByWorkflowRunAttemptId,
|
|
33
|
+
getJobsByWorkflowRunId,
|
|
34
|
+
resolveJobStatusFromJobExecutions,
|
|
35
|
+
updateJobStatus,
|
|
36
|
+
updateJobStatusAtVersion,
|
|
37
|
+
} from './workflow-runs/jobs.js';
|
|
38
|
+
export {
|
|
39
|
+
writeJobStepsSettledOutbox,
|
|
40
|
+
writeStepAttemptTerminatedOutbox,
|
|
41
|
+
writeStepRestartEnqueuedOutbox,
|
|
42
|
+
} from './workflow-runs/outbox.js';
|
|
43
|
+
export type {
|
|
44
|
+
ListWorkflowRunsParams,
|
|
45
|
+
ListWorkflowRunsResult,
|
|
46
|
+
WorkflowJobExecutionDepth,
|
|
47
|
+
WorkflowJobExecutionDepthParams,
|
|
48
|
+
WorkflowRunAggregates,
|
|
49
|
+
WorkflowRunCursor,
|
|
50
|
+
WorkflowRunFilters,
|
|
51
|
+
} from './workflow-runs/queries.js';
|
|
52
|
+
export {
|
|
53
|
+
buildWorkflowRunListConditions,
|
|
54
|
+
getJobExecutionDetail,
|
|
55
|
+
getLatestAttempt,
|
|
56
|
+
getWorkflowJobExecutionDepth,
|
|
57
|
+
getWorkflowRunAggregates,
|
|
58
|
+
getWorkflowRunAttemptById,
|
|
59
|
+
getWorkflowRunByAttemptId,
|
|
60
|
+
getWorkflowRunById,
|
|
61
|
+
getWorkflowRunDetail,
|
|
62
|
+
listRunAttempts,
|
|
63
|
+
listWorkflowRuns,
|
|
64
|
+
listWorkflowRunsByProject,
|
|
65
|
+
} from './workflow-runs/queries.js';
|
|
66
|
+
export type {
|
|
67
|
+
CancelWorkflowRunParams,
|
|
68
|
+
CreateRerunWorkflowRunParams,
|
|
69
|
+
CreateWorkflowRunParams,
|
|
70
|
+
FailWorkflowRunAsTimedOutParams,
|
|
71
|
+
UpdateWorkflowRunStatusParams,
|
|
72
|
+
} from './workflow-runs/runs.js';
|
|
73
|
+
export {
|
|
74
|
+
cancelWorkflowRun,
|
|
75
|
+
createRerunWorkflowRun,
|
|
76
|
+
createWorkflowRun,
|
|
77
|
+
failWorkflowRunAsTimedOut,
|
|
78
|
+
updateWorkflowRunStatus,
|
|
79
|
+
} from './workflow-runs/runs.js';
|
|
80
|
+
export type {
|
|
81
|
+
ApplyStepResultParams,
|
|
82
|
+
BulkUpdateStepStatusesParams,
|
|
83
|
+
CancelRemainingStepsParams,
|
|
84
|
+
DispatchStepWithCompletedConfigParams,
|
|
85
|
+
FinishStepAttemptParams,
|
|
86
|
+
InsertRunningStepAttemptParams,
|
|
87
|
+
MarkStepRunningParams,
|
|
88
|
+
MarkStepSkippedParams,
|
|
89
|
+
RewindStepsToPendingParams,
|
|
90
|
+
} from './workflow-runs/steps.js';
|
|
91
|
+
export {
|
|
92
|
+
applyStepResult,
|
|
93
|
+
bulkUpdateStepStatuses,
|
|
94
|
+
cancelRemainingSteps,
|
|
95
|
+
countStepAttempts,
|
|
96
|
+
dispatchStepWithCompletedConfig,
|
|
97
|
+
finishStepAttempt,
|
|
98
|
+
getStepAttempts,
|
|
99
|
+
getStepAttemptsByJobExecutionId,
|
|
100
|
+
getStepAttemptsByJobIds,
|
|
101
|
+
getStepById,
|
|
102
|
+
getStepByIdForJobExecution,
|
|
103
|
+
getStepsByJobExecutionId,
|
|
104
|
+
getStepsByJobExecutionIdForUpdate,
|
|
105
|
+
getStepsByJobId,
|
|
106
|
+
insertRunningStepAttempt,
|
|
107
|
+
markStepRunning,
|
|
108
|
+
markStepSkipped,
|
|
109
|
+
rewindStepsToPending,
|
|
110
|
+
settleJobFailed,
|
|
111
|
+
} from './workflow-runs/steps.js';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {dirname, resolve} from 'node:path';
|
|
2
|
+
import {fileURLToPath} from 'node:url';
|
|
3
|
+
import {
|
|
4
|
+
RUNNER_JOB_CLAIMED,
|
|
5
|
+
RUNNER_JOB_LEASE_EXPIRED,
|
|
6
|
+
RUNNER_JOB_QUEUED,
|
|
7
|
+
type RunnersEventMap,
|
|
8
|
+
} from '@shipfox/api-runners-dto';
|
|
9
|
+
import {
|
|
10
|
+
WORKFLOWS_JOB_EVENT_DELIVERED,
|
|
11
|
+
WORKFLOWS_JOB_STEPS_SETTLED,
|
|
12
|
+
WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED,
|
|
13
|
+
WORKFLOWS_WORKFLOW_RUN_CANCELLED,
|
|
14
|
+
type WorkflowsEventMapDto,
|
|
15
|
+
workflowsEventSchemas,
|
|
16
|
+
} from '@shipfox/api-workflows-dto';
|
|
17
|
+
import {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';
|
|
18
|
+
import {db, migrationsPath, workflowsOutbox} from '#db/index.js';
|
|
19
|
+
import {registerWorkflowsServiceMetrics} from '#metrics/index.js';
|
|
20
|
+
import {
|
|
21
|
+
onJobEventDelivered,
|
|
22
|
+
onJobStepsSettled,
|
|
23
|
+
onRunnerJobClaimed,
|
|
24
|
+
onRunnerJobLeaseExpired,
|
|
25
|
+
onRunnerJobQueued,
|
|
26
|
+
onWorkflowRunAttemptCreated,
|
|
27
|
+
onWorkflowRunCancelled,
|
|
28
|
+
routes,
|
|
29
|
+
} from '#presentation/index.js';
|
|
30
|
+
import {createOrchestrationActivities, WORKFLOWS_TASK_QUEUE} from '#temporal/index.js';
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
clearAgentToolMaterializationServices,
|
|
34
|
+
setAgentToolMaterializationServices,
|
|
35
|
+
} from '#core/agent-tools.js';
|
|
36
|
+
export type {
|
|
37
|
+
Job,
|
|
38
|
+
JobListenerEvent,
|
|
39
|
+
JobListenerEventDisposition,
|
|
40
|
+
RunWorkflowParams,
|
|
41
|
+
Step,
|
|
42
|
+
TriggerPayload,
|
|
43
|
+
WorkflowRun,
|
|
44
|
+
WorkflowSourceSnapshot,
|
|
45
|
+
} from '#core/index.js';
|
|
46
|
+
export {
|
|
47
|
+
DefinitionNotFoundError,
|
|
48
|
+
InterpolationUnresolvableError,
|
|
49
|
+
isPermanentRunWorkflowError,
|
|
50
|
+
ProjectMismatchError,
|
|
51
|
+
runWorkflow,
|
|
52
|
+
WorkflowRunNotCancellableError,
|
|
53
|
+
} from '#core/index.js';
|
|
54
|
+
export {setSourceControl} from '#core/source-control.js';
|
|
55
|
+
export {
|
|
56
|
+
closeDb,
|
|
57
|
+
type DeliverEventToListenerParams,
|
|
58
|
+
type DeliverEventToListenerResult,
|
|
59
|
+
db,
|
|
60
|
+
deliverEventToListener,
|
|
61
|
+
getStepById,
|
|
62
|
+
getStepByIdForJobExecution,
|
|
63
|
+
migrationsPath,
|
|
64
|
+
workflowsOutbox,
|
|
65
|
+
} from '#db/index.js';
|
|
66
|
+
export {routes} from '#presentation/index.js';
|
|
67
|
+
export {loadRunningLeasedStep} from '#presentation/routes/leased-step.js';
|
|
68
|
+
|
|
69
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
70
|
+
const workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');
|
|
71
|
+
|
|
72
|
+
const subscriber = subscriberFactory<WorkflowsEventMapDto & RunnersEventMap>();
|
|
73
|
+
|
|
74
|
+
export const workflowsModule: ShipfoxModule = {
|
|
75
|
+
name: 'workflows',
|
|
76
|
+
database: {db, migrationsPath},
|
|
77
|
+
routes,
|
|
78
|
+
metrics: registerWorkflowsServiceMetrics,
|
|
79
|
+
publishers: [
|
|
80
|
+
{name: 'workflows', table: workflowsOutbox, db, eventSchemas: workflowsEventSchemas},
|
|
81
|
+
],
|
|
82
|
+
subscribers: [
|
|
83
|
+
subscriber(WORKFLOWS_WORKFLOW_RUN_ATTEMPT_CREATED, onWorkflowRunAttemptCreated),
|
|
84
|
+
subscriber(WORKFLOWS_WORKFLOW_RUN_CANCELLED, onWorkflowRunCancelled),
|
|
85
|
+
subscriber(WORKFLOWS_JOB_EVENT_DELIVERED, onJobEventDelivered),
|
|
86
|
+
subscriber(WORKFLOWS_JOB_STEPS_SETTLED, onJobStepsSettled),
|
|
87
|
+
subscriber(RUNNER_JOB_LEASE_EXPIRED, onRunnerJobLeaseExpired),
|
|
88
|
+
subscriber(RUNNER_JOB_QUEUED, onRunnerJobQueued),
|
|
89
|
+
subscriber(RUNNER_JOB_CLAIMED, onRunnerJobClaimed),
|
|
90
|
+
],
|
|
91
|
+
workers: [
|
|
92
|
+
{
|
|
93
|
+
taskQueue: WORKFLOWS_TASK_QUEUE,
|
|
94
|
+
workflowsPath,
|
|
95
|
+
activities: createOrchestrationActivities,
|
|
96
|
+
workflows: [],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {registerWorkflowsServiceMetrics} from './service.js';
|