@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,288 @@
|
|
|
1
|
+
import { WORKFLOWS_JOB_TERMINATED } from '@shipfox/api-workflows-dto';
|
|
2
|
+
import { and, asc, desc, eq, inArray, notInArray, sql } from 'drizzle-orm';
|
|
3
|
+
import { isJobTerminal } from '#core/entities/job.js';
|
|
4
|
+
import { JobNotFoundError } from '#core/errors.js';
|
|
5
|
+
import { decideJobActivation, deriveJobSuccess, runtimeCompletionStatusForJob } from '#core/job-transition/index.js';
|
|
6
|
+
import { recordWorkflowJobStatusChanged } from '#metrics/instance.js';
|
|
7
|
+
import { db } from '../db.js';
|
|
8
|
+
import { writeWorkflowsOutboxEvent } from '../outbox-writes.js';
|
|
9
|
+
import { jobExecutions, toJobExecution } from '../schema/job-executions.js';
|
|
10
|
+
import { jobs, toJob } from '../schema/jobs.js';
|
|
11
|
+
import { workflowRunAttempts } from '../schema/workflow-run-attempts.js';
|
|
12
|
+
import { toWorkflowRun, workflowRuns } from '../schema/workflow-runs.js';
|
|
13
|
+
import { getWorkflowRunById } from './queries.js';
|
|
14
|
+
import { getWorkflowContextForJob, optimisticLockRetry, TERMINAL_JOB_STATUSES } from './shared.js';
|
|
15
|
+
export async function getJobsByWorkflowRunAttemptId(workflowRunAttemptId) {
|
|
16
|
+
const rows = await db().select().from(jobs).where(eq(jobs.workflowRunAttemptId, workflowRunAttemptId)).orderBy(asc(jobs.position));
|
|
17
|
+
return rows.map(toJob);
|
|
18
|
+
}
|
|
19
|
+
export async function getJobsByWorkflowRunId(workflowRunId) {
|
|
20
|
+
const run = await getWorkflowRunById(workflowRunId);
|
|
21
|
+
if (!run) return [];
|
|
22
|
+
const [attempt] = await db().select().from(workflowRunAttempts).where(and(eq(workflowRunAttempts.workflowRunId, run.id), eq(workflowRunAttempts.attempt, run.currentAttempt))).limit(1);
|
|
23
|
+
return attempt ? getJobsByWorkflowRunAttemptId(attempt.id) : [];
|
|
24
|
+
}
|
|
25
|
+
export async function getJobById(id) {
|
|
26
|
+
const rows = await db().select().from(jobs).where(eq(jobs.id, id)).limit(1);
|
|
27
|
+
const row = rows[0];
|
|
28
|
+
if (!row) return undefined;
|
|
29
|
+
return toJob(row);
|
|
30
|
+
}
|
|
31
|
+
export async function getJobScope(jobId) {
|
|
32
|
+
const rows = await db().select({
|
|
33
|
+
workspaceId: workflowRuns.workspaceId,
|
|
34
|
+
projectId: workflowRuns.projectId
|
|
35
|
+
}).from(jobs).innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id)).innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id)).where(eq(jobs.id, jobId)).limit(1);
|
|
36
|
+
return rows[0];
|
|
37
|
+
}
|
|
38
|
+
export async function getDirectDependencyJobContexts(jobId, tx) {
|
|
39
|
+
const targetRows = await (tx ?? db()).select().from(jobs).where(eq(jobs.id, jobId)).limit(1);
|
|
40
|
+
const target = targetRows[0];
|
|
41
|
+
if (!target || target.dependencies.length === 0) return [];
|
|
42
|
+
const rows = await (tx ?? db()).select({
|
|
43
|
+
job: jobs,
|
|
44
|
+
execution: jobExecutions
|
|
45
|
+
}).from(jobs).leftJoin(jobExecutions, eq(jobExecutions.jobId, jobs.id)).where(and(eq(jobs.workflowRunAttemptId, target.workflowRunAttemptId), inArray(jobs.key, target.dependencies))).orderBy(asc(jobs.position), asc(jobs.id), asc(jobExecutions.sequence), asc(jobExecutions.id));
|
|
46
|
+
const contextsByJobId = new Map();
|
|
47
|
+
for (const row of rows){
|
|
48
|
+
let context = contextsByJobId.get(row.job.id);
|
|
49
|
+
if (!context) {
|
|
50
|
+
context = {
|
|
51
|
+
job: toJob(row.job),
|
|
52
|
+
executions: []
|
|
53
|
+
};
|
|
54
|
+
contextsByJobId.set(row.job.id, context);
|
|
55
|
+
}
|
|
56
|
+
if (row.execution) context.executions.push(toJobExecution(row.execution));
|
|
57
|
+
}
|
|
58
|
+
return [
|
|
59
|
+
...contextsByJobId.values()
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
export async function evaluateJobActivations(params) {
|
|
63
|
+
if (params.jobs.length === 0) return [];
|
|
64
|
+
const result = await db().transaction(async (tx)=>{
|
|
65
|
+
const expectedVersions = new Map(params.jobs.map((job)=>[
|
|
66
|
+
job.jobId,
|
|
67
|
+
job.expectedVersion
|
|
68
|
+
]));
|
|
69
|
+
const jobIds = params.jobs.map((job)=>job.jobId);
|
|
70
|
+
const targets = await tx.select({
|
|
71
|
+
job: jobs,
|
|
72
|
+
attempt: workflowRunAttempts,
|
|
73
|
+
run: workflowRuns
|
|
74
|
+
}).from(jobs).innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id)).innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id)).where(and(eq(jobs.workflowRunAttemptId, params.runAttemptId), inArray(jobs.id, jobIds))).for('update');
|
|
75
|
+
if (targets.length !== jobIds.length) {
|
|
76
|
+
const found = new Set(targets.map((target)=>target.job.id));
|
|
77
|
+
const missing = jobIds.filter((jobId)=>!found.has(jobId));
|
|
78
|
+
throw new Error(`Cannot evaluate missing activation jobs: ${missing.join(', ')}`);
|
|
79
|
+
}
|
|
80
|
+
const contextsByJobKey = await directDependencyContextsByJobKey(tx, params.runAttemptId, targets.map((target)=>toJob(target.job)));
|
|
81
|
+
const targetsByJobId = new Map(targets.map((target)=>[
|
|
82
|
+
target.job.id,
|
|
83
|
+
target
|
|
84
|
+
]));
|
|
85
|
+
const decisions = [];
|
|
86
|
+
for (const input of params.jobs){
|
|
87
|
+
const target = targetsByJobId.get(input.jobId);
|
|
88
|
+
if (!target) throw new Error(`Cannot evaluate missing activation job: ${input.jobId}`);
|
|
89
|
+
const job = toJob(target.job);
|
|
90
|
+
const modelJob = target.attempt.model?.jobs.find((item)=>item.key === target.job.key);
|
|
91
|
+
const decision = decideJobActivation({
|
|
92
|
+
run: toWorkflowRun(target.run),
|
|
93
|
+
job,
|
|
94
|
+
condition: modelJob?.if,
|
|
95
|
+
dependencies: job.dependencies.flatMap((key)=>{
|
|
96
|
+
const dependency = contextsByJobKey.get(key);
|
|
97
|
+
return dependency === undefined ? [] : [
|
|
98
|
+
dependency
|
|
99
|
+
];
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
if (decision.kind === 'terminal-job' || decision.kind === 'start-job') {
|
|
103
|
+
decisions.push(decision);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const expectedVersion = expectedVersions.get(job.id);
|
|
107
|
+
if (expectedVersion === undefined) {
|
|
108
|
+
throw new Error(`Missing expected version for activation job ${job.id}`);
|
|
109
|
+
}
|
|
110
|
+
const updated = await updateJobStatusAtVersion(tx, {
|
|
111
|
+
jobId: job.id,
|
|
112
|
+
status: decision.status,
|
|
113
|
+
expectedVersion,
|
|
114
|
+
statusReason: decision.statusReason,
|
|
115
|
+
evaluationTrace: decision.evaluationTrace
|
|
116
|
+
});
|
|
117
|
+
if (updated) {
|
|
118
|
+
decisions.push({
|
|
119
|
+
kind: 'terminal-job',
|
|
120
|
+
jobId: job.id,
|
|
121
|
+
status: 'skipped',
|
|
122
|
+
jobVersion: updated.job.version,
|
|
123
|
+
changed: updated.changed
|
|
124
|
+
});
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const [existing] = await tx.select().from(jobs).where(eq(jobs.id, job.id)).limit(1);
|
|
128
|
+
if (existing && isJobTerminal(existing.status)) {
|
|
129
|
+
decisions.push({
|
|
130
|
+
kind: 'terminal-job',
|
|
131
|
+
jobId: job.id,
|
|
132
|
+
status: runtimeCompletionStatusForJob(existing.status),
|
|
133
|
+
jobVersion: existing.version
|
|
134
|
+
});
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
throw new Error(`Optimistic lock failure evaluating activation for job ${job.id}`);
|
|
138
|
+
}
|
|
139
|
+
return decisions;
|
|
140
|
+
});
|
|
141
|
+
for (const decision of result){
|
|
142
|
+
if (decision.kind === 'terminal-job' && decision.changed) {
|
|
143
|
+
recordWorkflowJobStatusChanged(decision.status);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return result.map(({ changed: _changed, ...decision })=>decision);
|
|
147
|
+
}
|
|
148
|
+
async function directDependencyContextsByJobKey(tx, runAttemptId, targetJobs) {
|
|
149
|
+
const dependencyKeys = new Set(targetJobs.flatMap((job)=>job.dependencies));
|
|
150
|
+
if (dependencyKeys.size === 0) return new Map();
|
|
151
|
+
const rows = await tx.select({
|
|
152
|
+
job: jobs,
|
|
153
|
+
execution: jobExecutions
|
|
154
|
+
}).from(jobs).leftJoin(jobExecutions, eq(jobExecutions.jobId, jobs.id)).where(and(eq(jobs.workflowRunAttemptId, runAttemptId), inArray(jobs.key, [
|
|
155
|
+
...dependencyKeys
|
|
156
|
+
]))).orderBy(asc(jobs.position), asc(jobs.id), asc(jobExecutions.sequence), asc(jobExecutions.id));
|
|
157
|
+
const contextsByJobKey = new Map();
|
|
158
|
+
for (const row of rows){
|
|
159
|
+
let context = contextsByJobKey.get(row.job.key);
|
|
160
|
+
if (!context) {
|
|
161
|
+
context = {
|
|
162
|
+
job: toJob(row.job),
|
|
163
|
+
executions: []
|
|
164
|
+
};
|
|
165
|
+
contextsByJobKey.set(row.job.key, context);
|
|
166
|
+
}
|
|
167
|
+
if (row.execution) context.executions.push(toJobExecution(row.execution));
|
|
168
|
+
}
|
|
169
|
+
return contextsByJobKey;
|
|
170
|
+
}
|
|
171
|
+
// Returns null on version mismatch so callers can choose throw vs treat-as-success.
|
|
172
|
+
export async function updateJobStatusAtVersion(tx, params) {
|
|
173
|
+
const outputs = isJobTerminal(params.status) ? await reduceJobOutputs(tx, {
|
|
174
|
+
jobId: params.jobId,
|
|
175
|
+
status: params.status
|
|
176
|
+
}) : undefined;
|
|
177
|
+
const rows = await tx.update(jobs).set({
|
|
178
|
+
status: params.status,
|
|
179
|
+
statusReason: params.statusReason ?? null,
|
|
180
|
+
...outputs === undefined ? {} : {
|
|
181
|
+
outputs
|
|
182
|
+
},
|
|
183
|
+
...params.evaluationTrace === undefined ? {} : {
|
|
184
|
+
evaluationTrace: params.evaluationTrace
|
|
185
|
+
},
|
|
186
|
+
version: sql`${jobs.version} + 1`,
|
|
187
|
+
updatedAt: new Date()
|
|
188
|
+
}).where(and(eq(jobs.id, params.jobId), eq(jobs.version, params.expectedVersion), notInArray(jobs.status, TERMINAL_JOB_STATUSES))).returning();
|
|
189
|
+
const row = rows[0];
|
|
190
|
+
if (!row) return null;
|
|
191
|
+
const job = toJob(row);
|
|
192
|
+
// Every terminal job-status write funnels through this one guarded UPDATE, where the
|
|
193
|
+
// version match lets a single caller win. Emitting here, in the same transaction,
|
|
194
|
+
// makes the terminal fact fire exactly once across all paths.
|
|
195
|
+
if (isJobTerminal(job.status)) {
|
|
196
|
+
const identity = await getWorkflowContextForJob(job.id, tx);
|
|
197
|
+
await writeWorkflowsOutboxEvent(tx, {
|
|
198
|
+
type: WORKFLOWS_JOB_TERMINATED,
|
|
199
|
+
payload: {
|
|
200
|
+
jobId: job.id,
|
|
201
|
+
workflowRunId: identity.workflowRunId,
|
|
202
|
+
workflowRunAttemptId: identity.workflowRunAttemptId,
|
|
203
|
+
status: job.status,
|
|
204
|
+
statusReason: job.statusReason
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
job,
|
|
210
|
+
changed: true
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
async function reduceJobOutputs(tx, params) {
|
|
214
|
+
if (params.status !== 'succeeded') return null;
|
|
215
|
+
const [row] = await tx.select({
|
|
216
|
+
outputs: jobExecutions.outputs
|
|
217
|
+
}).from(jobExecutions).where(and(eq(jobExecutions.jobId, params.jobId), eq(jobExecutions.status, 'succeeded'))).orderBy(desc(jobExecutions.sequence), desc(jobExecutions.id)).limit(1);
|
|
218
|
+
return row?.outputs ? {
|
|
219
|
+
...row.outputs
|
|
220
|
+
} : null;
|
|
221
|
+
}
|
|
222
|
+
export async function updateJobStatus(params) {
|
|
223
|
+
const statusReason = params.statusReason ?? null;
|
|
224
|
+
const result = await db().transaction(async (tx)=>{
|
|
225
|
+
return await optimisticLockRetry({
|
|
226
|
+
updateFn: ()=>updateJobStatusAtVersion(tx, {
|
|
227
|
+
jobId: params.jobId,
|
|
228
|
+
status: params.status,
|
|
229
|
+
expectedVersion: params.expectedVersion,
|
|
230
|
+
statusReason,
|
|
231
|
+
evaluationTrace: params.evaluationTrace
|
|
232
|
+
}),
|
|
233
|
+
fetchFn: async ()=>{
|
|
234
|
+
const row = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];
|
|
235
|
+
return row ? toJob(row) : undefined;
|
|
236
|
+
},
|
|
237
|
+
matchFn: (job)=>job.status === params.status && job.statusReason === statusReason || isJobTerminal(job.status) ? {
|
|
238
|
+
job,
|
|
239
|
+
changed: false
|
|
240
|
+
} : null,
|
|
241
|
+
failureMessage: `Optimistic lock failure: job ${params.jobId} version ${params.expectedVersion}`
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
if (result.changed) recordWorkflowJobStatusChanged(result.job.status);
|
|
245
|
+
return result.job;
|
|
246
|
+
}
|
|
247
|
+
export const evaluateJobSuccess = deriveJobSuccess;
|
|
248
|
+
export async function resolveJobStatusFromJobExecutions(params) {
|
|
249
|
+
const result = await db().transaction(async (tx)=>{
|
|
250
|
+
const jobRow = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];
|
|
251
|
+
if (!jobRow) throw new JobNotFoundError(params.jobId);
|
|
252
|
+
const jobExecutionRows = await tx.select().from(jobExecutions).where(eq(jobExecutions.jobId, params.jobId)).orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));
|
|
253
|
+
if (jobExecutionRows.length === 0) {
|
|
254
|
+
throw new Error(`Cannot resolve job ${params.jobId}: no job executions found`);
|
|
255
|
+
}
|
|
256
|
+
const { status, statusReason, trace } = evaluateJobSuccess({
|
|
257
|
+
success: jobRow.success,
|
|
258
|
+
executions: jobExecutionRows.map(toJobExecution),
|
|
259
|
+
jobs: await getDirectDependencyJobContexts(params.jobId, tx)
|
|
260
|
+
});
|
|
261
|
+
return optimisticLockRetry({
|
|
262
|
+
updateFn: ()=>updateJobStatusAtVersion(tx, {
|
|
263
|
+
jobId: params.jobId,
|
|
264
|
+
status,
|
|
265
|
+
expectedVersion: jobRow.version,
|
|
266
|
+
statusReason,
|
|
267
|
+
evaluationTrace: trace
|
|
268
|
+
}),
|
|
269
|
+
fetchFn: async ()=>{
|
|
270
|
+
const row = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];
|
|
271
|
+
if (!row) throw new JobNotFoundError(params.jobId);
|
|
272
|
+
return toJob(row);
|
|
273
|
+
},
|
|
274
|
+
matchFn: (job)=>({
|
|
275
|
+
job,
|
|
276
|
+
changed: false
|
|
277
|
+
}),
|
|
278
|
+
failureMessage: `Optimistic lock failure: job ${params.jobId} version ${jobRow.version}`
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
if (result.changed) recordWorkflowJobStatusChanged(result.job.status);
|
|
282
|
+
return {
|
|
283
|
+
status: result.job.status === 'succeeded' ? 'succeeded' : 'failed',
|
|
284
|
+
jobVersion: result.job.version
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/workflow-runs/jobs.ts"],"sourcesContent":["import {WORKFLOWS_JOB_TERMINATED} from '@shipfox/api-workflows-dto';\nimport {and, asc, desc, eq, inArray, notInArray, sql} from 'drizzle-orm';\nimport {isJobTerminal, type Job, type JobStatus, type JobStatusReason} from '#core/entities/job.js';\nimport type {JobExecution} from '#core/entities/job-execution.js';\nimport type {PersistedEvaluationTraceEntry} from '#core/entities/step.js';\nimport {JobNotFoundError} from '#core/errors.js';\nimport {\n type DeriveJobSuccessResult,\n decideJobActivation,\n deriveJobSuccess,\n runtimeCompletionStatusForJob,\n} from '#core/job-transition/index.js';\nimport type {JobContextInput} from '#core/step-config/assemble-run-context.js';\nimport type {RuntimeCompletionStatus} from '#core/workflow-scheduling/runtime-dag.js';\nimport {recordWorkflowJobStatusChanged} from '#metrics/instance.js';\nimport {db, type Tx} from '../db.js';\nimport {writeWorkflowsOutboxEvent} from '../outbox-writes.js';\nimport {jobExecutions, toJobExecution} from '../schema/job-executions.js';\nimport {jobs, toJob} from '../schema/jobs.js';\nimport {workflowRunAttempts} from '../schema/workflow-run-attempts.js';\nimport {toWorkflowRun, workflowRuns} from '../schema/workflow-runs.js';\nimport {getWorkflowRunById} from './queries.js';\nimport {getWorkflowContextForJob, optimisticLockRetry, TERMINAL_JOB_STATUSES} from './shared.js';\n\nexport async function getJobsByWorkflowRunAttemptId(workflowRunAttemptId: string): Promise<Job[]> {\n const rows = await db()\n .select()\n .from(jobs)\n .where(eq(jobs.workflowRunAttemptId, workflowRunAttemptId))\n .orderBy(asc(jobs.position));\n return rows.map(toJob);\n}\n\nexport async function getJobsByWorkflowRunId(workflowRunId: string): Promise<Job[]> {\n const run = await getWorkflowRunById(workflowRunId);\n if (!run) return [];\n const [attempt] = await db()\n .select()\n .from(workflowRunAttempts)\n .where(\n and(\n eq(workflowRunAttempts.workflowRunId, run.id),\n eq(workflowRunAttempts.attempt, run.currentAttempt),\n ),\n )\n .limit(1);\n return attempt ? getJobsByWorkflowRunAttemptId(attempt.id) : [];\n}\n\nexport async function getJobById(id: string): Promise<Job | undefined> {\n const rows = await db().select().from(jobs).where(eq(jobs.id, id)).limit(1);\n const row = rows[0];\n if (!row) return undefined;\n return toJob(row);\n}\n\nexport interface JobScope {\n workspaceId: string;\n projectId: string;\n}\n\nexport async function getJobScope(jobId: string): Promise<JobScope | undefined> {\n const rows = await db()\n .select({workspaceId: workflowRuns.workspaceId, projectId: workflowRuns.projectId})\n .from(jobs)\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(eq(jobs.id, jobId))\n .limit(1);\n return rows[0];\n}\n\nexport async function getDirectDependencyJobContexts(\n jobId: string,\n tx?: Tx,\n): Promise<JobContextInput[]> {\n const targetRows = await (tx ?? db()).select().from(jobs).where(eq(jobs.id, jobId)).limit(1);\n const target = targetRows[0];\n if (!target || target.dependencies.length === 0) return [];\n\n const rows = await (tx ?? db())\n .select({job: jobs, execution: jobExecutions})\n .from(jobs)\n .leftJoin(jobExecutions, eq(jobExecutions.jobId, jobs.id))\n .where(\n and(\n eq(jobs.workflowRunAttemptId, target.workflowRunAttemptId),\n inArray(jobs.key, target.dependencies),\n ),\n )\n .orderBy(asc(jobs.position), asc(jobs.id), asc(jobExecutions.sequence), asc(jobExecutions.id));\n\n const contextsByJobId = new Map<string, JobContextInput & {executions: JobExecution[]}>();\n for (const row of rows) {\n let context = contextsByJobId.get(row.job.id);\n if (!context) {\n context = {job: toJob(row.job), executions: []};\n contextsByJobId.set(row.job.id, context);\n }\n if (row.execution) context.executions.push(toJobExecution(row.execution));\n }\n\n return [...contextsByJobId.values()];\n}\n\nexport interface EvaluateJobActivationsParams {\n runAttemptId: string;\n jobs: readonly {\n jobId: string;\n expectedVersion: number;\n }[];\n}\n\nexport type JobActivationDecision =\n | {\n kind: 'start-job';\n jobId: string;\n }\n | {\n kind: 'terminal-job';\n jobId: string;\n status: RuntimeCompletionStatus;\n jobVersion: number;\n };\n\ntype InternalJobActivationDecision = JobActivationDecision & {changed?: boolean};\n\nexport async function evaluateJobActivations(\n params: EvaluateJobActivationsParams,\n): Promise<JobActivationDecision[]> {\n if (params.jobs.length === 0) return [];\n\n const result = await db().transaction(async (tx) => {\n const expectedVersions = new Map(\n params.jobs.map((job) => [job.jobId, job.expectedVersion] as const),\n );\n const jobIds = params.jobs.map((job) => job.jobId);\n const targets = await tx\n .select({job: jobs, attempt: workflowRunAttempts, run: workflowRuns})\n .from(jobs)\n .innerJoin(workflowRunAttempts, eq(jobs.workflowRunAttemptId, workflowRunAttempts.id))\n .innerJoin(workflowRuns, eq(workflowRunAttempts.workflowRunId, workflowRuns.id))\n .where(and(eq(jobs.workflowRunAttemptId, params.runAttemptId), inArray(jobs.id, jobIds)))\n .for('update');\n\n if (targets.length !== jobIds.length) {\n const found = new Set(targets.map((target) => target.job.id));\n const missing = jobIds.filter((jobId) => !found.has(jobId));\n throw new Error(`Cannot evaluate missing activation jobs: ${missing.join(', ')}`);\n }\n\n const contextsByJobKey = await directDependencyContextsByJobKey(\n tx,\n params.runAttemptId,\n targets.map((target) => toJob(target.job)),\n );\n const targetsByJobId = new Map(targets.map((target) => [target.job.id, target]));\n const decisions: InternalJobActivationDecision[] = [];\n\n for (const input of params.jobs) {\n const target = targetsByJobId.get(input.jobId);\n if (!target) throw new Error(`Cannot evaluate missing activation job: ${input.jobId}`);\n const job = toJob(target.job);\n const modelJob = target.attempt.model?.jobs.find((item) => item.key === target.job.key);\n const decision = decideJobActivation({\n run: toWorkflowRun(target.run),\n job,\n condition: modelJob?.if,\n dependencies: job.dependencies.flatMap((key) => {\n const dependency = contextsByJobKey.get(key);\n return dependency === undefined ? [] : [dependency];\n }),\n });\n\n if (decision.kind === 'terminal-job' || decision.kind === 'start-job') {\n decisions.push(decision);\n continue;\n }\n\n const expectedVersion = expectedVersions.get(job.id);\n if (expectedVersion === undefined) {\n throw new Error(`Missing expected version for activation job ${job.id}`);\n }\n const updated = await updateJobStatusAtVersion(tx, {\n jobId: job.id,\n status: decision.status,\n expectedVersion,\n statusReason: decision.statusReason,\n evaluationTrace: decision.evaluationTrace,\n });\n if (updated) {\n decisions.push({\n kind: 'terminal-job',\n jobId: job.id,\n status: 'skipped',\n jobVersion: updated.job.version,\n changed: updated.changed,\n });\n continue;\n }\n\n const [existing] = await tx.select().from(jobs).where(eq(jobs.id, job.id)).limit(1);\n if (existing && isJobTerminal(existing.status)) {\n decisions.push({\n kind: 'terminal-job',\n jobId: job.id,\n status: runtimeCompletionStatusForJob(existing.status),\n jobVersion: existing.version,\n });\n continue;\n }\n throw new Error(`Optimistic lock failure evaluating activation for job ${job.id}`);\n }\n\n return decisions;\n });\n\n for (const decision of result) {\n if (decision.kind === 'terminal-job' && decision.changed) {\n recordWorkflowJobStatusChanged(decision.status);\n }\n }\n\n return result.map(({changed: _changed, ...decision}) => decision);\n}\n\nasync function directDependencyContextsByJobKey(\n tx: Tx,\n runAttemptId: string,\n targetJobs: readonly Job[],\n): Promise<ReadonlyMap<string, JobContextInput>> {\n const dependencyKeys = new Set(targetJobs.flatMap((job) => job.dependencies));\n if (dependencyKeys.size === 0) return new Map();\n\n const rows = await tx\n .select({job: jobs, execution: jobExecutions})\n .from(jobs)\n .leftJoin(jobExecutions, eq(jobExecutions.jobId, jobs.id))\n .where(and(eq(jobs.workflowRunAttemptId, runAttemptId), inArray(jobs.key, [...dependencyKeys])))\n .orderBy(asc(jobs.position), asc(jobs.id), asc(jobExecutions.sequence), asc(jobExecutions.id));\n\n const contextsByJobKey = new Map<string, JobContextInput & {executions: JobExecution[]}>();\n for (const row of rows) {\n let context = contextsByJobKey.get(row.job.key);\n if (!context) {\n context = {job: toJob(row.job), executions: []};\n contextsByJobKey.set(row.job.key, context);\n }\n if (row.execution) context.executions.push(toJobExecution(row.execution));\n }\n\n return contextsByJobKey;\n}\n\nexport interface UpdateJobStatusAtVersionParams {\n jobId: string;\n status: JobStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null | undefined;\n}\n\n// Returns null on version mismatch so callers can choose throw vs treat-as-success.\nexport async function updateJobStatusAtVersion(\n tx: Tx,\n params: UpdateJobStatusAtVersionParams,\n): Promise<{job: Job; changed: boolean} | null> {\n const outputs = isJobTerminal(params.status)\n ? await reduceJobOutputs(tx, {jobId: params.jobId, status: params.status})\n : undefined;\n const rows = await tx\n .update(jobs)\n .set({\n status: params.status,\n statusReason: params.statusReason ?? null,\n ...(outputs === undefined ? {} : {outputs}),\n ...(params.evaluationTrace === undefined ? {} : {evaluationTrace: params.evaluationTrace}),\n version: sql`${jobs.version} + 1`,\n updatedAt: new Date(),\n })\n .where(\n and(\n eq(jobs.id, params.jobId),\n eq(jobs.version, params.expectedVersion),\n notInArray(jobs.status, TERMINAL_JOB_STATUSES),\n ),\n )\n .returning();\n\n const row = rows[0];\n if (!row) return null;\n const job = toJob(row);\n\n // Every terminal job-status write funnels through this one guarded UPDATE, where the\n // version match lets a single caller win. Emitting here, in the same transaction,\n // makes the terminal fact fire exactly once across all paths.\n if (isJobTerminal(job.status)) {\n const identity = await getWorkflowContextForJob(job.id, tx);\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_JOB_TERMINATED,\n payload: {\n jobId: job.id,\n workflowRunId: identity.workflowRunId,\n workflowRunAttemptId: identity.workflowRunAttemptId,\n status: job.status,\n statusReason: job.statusReason,\n },\n });\n }\n\n return {job, changed: true};\n}\n\nasync function reduceJobOutputs(\n tx: Tx,\n params: {jobId: string; status: JobStatus},\n): Promise<Record<string, unknown> | null> {\n if (params.status !== 'succeeded') return null;\n\n const [row] = await tx\n .select({outputs: jobExecutions.outputs})\n .from(jobExecutions)\n .where(and(eq(jobExecutions.jobId, params.jobId), eq(jobExecutions.status, 'succeeded')))\n .orderBy(desc(jobExecutions.sequence), desc(jobExecutions.id))\n .limit(1);\n\n return row?.outputs ? {...row.outputs} : null;\n}\n\nexport interface UpdateJobStatusParams {\n jobId: string;\n status: JobStatus;\n expectedVersion: number;\n statusReason?: JobStatusReason | null | undefined;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null | undefined;\n}\n\nexport async function updateJobStatus(params: UpdateJobStatusParams): Promise<Job> {\n const statusReason = params.statusReason ?? null;\n const result = await db().transaction(async (tx) => {\n return await optimisticLockRetry({\n updateFn: () =>\n updateJobStatusAtVersion(tx, {\n jobId: params.jobId,\n status: params.status,\n expectedVersion: params.expectedVersion,\n statusReason,\n evaluationTrace: params.evaluationTrace,\n }),\n fetchFn: async () => {\n const row = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n return row ? toJob(row) : undefined;\n },\n matchFn: (job) =>\n (job.status === params.status && job.statusReason === statusReason) ||\n isJobTerminal(job.status)\n ? {job, changed: false}\n : null,\n failureMessage: `Optimistic lock failure: job ${params.jobId} version ${params.expectedVersion}`,\n });\n });\n\n if (result.changed) recordWorkflowJobStatusChanged(result.job.status);\n\n return result.job;\n}\n\nexport type EvaluateJobSuccessResult = DeriveJobSuccessResult;\nexport const evaluateJobSuccess = deriveJobSuccess;\n\nexport async function resolveJobStatusFromJobExecutions(params: {\n jobId: string;\n}): Promise<{status: RuntimeCompletionStatus; jobVersion: number}> {\n const result = await db().transaction(async (tx) => {\n const jobRow = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n if (!jobRow) throw new JobNotFoundError(params.jobId);\n\n const jobExecutionRows = await tx\n .select()\n .from(jobExecutions)\n .where(eq(jobExecutions.jobId, params.jobId))\n .orderBy(asc(jobExecutions.sequence), asc(jobExecutions.id));\n\n if (jobExecutionRows.length === 0) {\n throw new Error(`Cannot resolve job ${params.jobId}: no job executions found`);\n }\n\n const {status, statusReason, trace} = evaluateJobSuccess({\n success: jobRow.success,\n executions: jobExecutionRows.map(toJobExecution),\n jobs: await getDirectDependencyJobContexts(params.jobId, tx),\n });\n\n return optimisticLockRetry({\n updateFn: () =>\n updateJobStatusAtVersion(tx, {\n jobId: params.jobId,\n status,\n expectedVersion: jobRow.version,\n statusReason,\n evaluationTrace: trace,\n }),\n fetchFn: async () => {\n const row = (await tx.select().from(jobs).where(eq(jobs.id, params.jobId)).limit(1))[0];\n if (!row) throw new JobNotFoundError(params.jobId);\n return toJob(row);\n },\n matchFn: (job) => ({job, changed: false}),\n failureMessage: `Optimistic lock failure: job ${params.jobId} version ${jobRow.version}`,\n });\n });\n\n if (result.changed) recordWorkflowJobStatusChanged(result.job.status);\n return {\n status: result.job.status === 'succeeded' ? 'succeeded' : 'failed',\n jobVersion: result.job.version,\n };\n}\n"],"names":["WORKFLOWS_JOB_TERMINATED","and","asc","desc","eq","inArray","notInArray","sql","isJobTerminal","JobNotFoundError","decideJobActivation","deriveJobSuccess","runtimeCompletionStatusForJob","recordWorkflowJobStatusChanged","db","writeWorkflowsOutboxEvent","jobExecutions","toJobExecution","jobs","toJob","workflowRunAttempts","toWorkflowRun","workflowRuns","getWorkflowRunById","getWorkflowContextForJob","optimisticLockRetry","TERMINAL_JOB_STATUSES","getJobsByWorkflowRunAttemptId","workflowRunAttemptId","rows","select","from","where","orderBy","position","map","getJobsByWorkflowRunId","workflowRunId","run","attempt","id","currentAttempt","limit","getJobById","row","undefined","getJobScope","jobId","workspaceId","projectId","innerJoin","getDirectDependencyJobContexts","tx","targetRows","target","dependencies","length","job","execution","leftJoin","key","sequence","contextsByJobId","Map","context","get","executions","set","push","values","evaluateJobActivations","params","result","transaction","expectedVersions","expectedVersion","jobIds","targets","runAttemptId","for","found","Set","missing","filter","has","Error","join","contextsByJobKey","directDependencyContextsByJobKey","targetsByJobId","decisions","input","modelJob","model","find","item","decision","condition","if","flatMap","dependency","kind","updated","updateJobStatusAtVersion","status","statusReason","evaluationTrace","jobVersion","version","changed","existing","_changed","targetJobs","dependencyKeys","size","outputs","reduceJobOutputs","update","updatedAt","Date","returning","identity","type","payload","updateJobStatus","updateFn","fetchFn","matchFn","failureMessage","evaluateJobSuccess","resolveJobStatusFromJobExecutions","jobRow","jobExecutionRows","trace","success"],"mappings":"AAAA,SAAQA,wBAAwB,QAAO,6BAA6B;AACpE,SAAQC,GAAG,EAAEC,GAAG,EAAEC,IAAI,EAAEC,EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAEC,GAAG,QAAO,cAAc;AACzE,SAAQC,aAAa,QAAuD,wBAAwB;AAGpG,SAAQC,gBAAgB,QAAO,kBAAkB;AACjD,SAEEC,mBAAmB,EACnBC,gBAAgB,EAChBC,6BAA6B,QACxB,gCAAgC;AAGvC,SAAQC,8BAA8B,QAAO,uBAAuB;AACpE,SAAQC,EAAE,QAAgB,WAAW;AACrC,SAAQC,yBAAyB,QAAO,sBAAsB;AAC9D,SAAQC,aAAa,EAAEC,cAAc,QAAO,8BAA8B;AAC1E,SAAQC,IAAI,EAAEC,KAAK,QAAO,oBAAoB;AAC9C,SAAQC,mBAAmB,QAAO,qCAAqC;AACvE,SAAQC,aAAa,EAAEC,YAAY,QAAO,6BAA6B;AACvE,SAAQC,kBAAkB,QAAO,eAAe;AAChD,SAAQC,wBAAwB,EAAEC,mBAAmB,EAAEC,qBAAqB,QAAO,cAAc;AAEjG,OAAO,eAAeC,8BAA8BC,oBAA4B;IAC9E,MAAMC,OAAO,MAAMf,KAChBgB,MAAM,GACNC,IAAI,CAACb,MACLc,KAAK,CAAC5B,GAAGc,KAAKU,oBAAoB,EAAEA,uBACpCK,OAAO,CAAC/B,IAAIgB,KAAKgB,QAAQ;IAC5B,OAAOL,KA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AAEzD,OAAOxB,KAAK,CAAC,SAAS,EAAEoF,OAAOvB,OAAO,EAAE;QAC1F;IACF;IAEA,IAAIpC,OAAOqC,OAAO,EAAEhG,+BAA+B2D,OAAOf,GAAG,CAAC+C,MAAM;IACpE,OAAO;QACLA,QAAQhC,OAAOf,GAAG,CAAC+C,MAAM,KAAK,cAAc,cAAc;QAC1DG,YAAYnC,OAAOf,GAAG,CAACmD,OAAO;IAChC;AACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type LogOutcomeDto } from '@shipfox/api-workflows-dto';
|
|
2
|
+
import type { Tx } from '../db.js';
|
|
3
|
+
export declare function writeJobStepsSettledOutbox(tx: Tx, params: {
|
|
4
|
+
jobId: string;
|
|
5
|
+
jobExecutionId: string;
|
|
6
|
+
status: 'succeeded' | 'failed';
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
export declare function writeStepAttemptTerminatedOutbox(tx: Tx, params: {
|
|
9
|
+
stepId: string;
|
|
10
|
+
attempt: number;
|
|
11
|
+
logOutcome: LogOutcomeDto;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
export declare function writeStepRestartEnqueuedOutbox(tx: Tx, params: {
|
|
14
|
+
jobId: string;
|
|
15
|
+
failedStepId: string;
|
|
16
|
+
failedStepAttempt: number;
|
|
17
|
+
restartFromStepId: string;
|
|
18
|
+
feedback: string;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=outbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox.d.ts","sourceRoot":"","sources":["../../../src/db/workflow-runs/outbox.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,UAAU,CAAC;AAUjC,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,EAAE,EACN,MAAM,EAAE;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAA;CAAC,GAC9E,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAsB,gCAAgC,CACpD,EAAE,EAAE,EAAE,EACN,MAAM,EAAE;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,aAAa,CAAA;CAAC,GACnE,OAAO,CAAC,IAAI,CAAC,CAgBf;AA8BD,wBAAsB,8BAA8B,CAClD,EAAE,EAAE,EAAE,EACN,MAAM,EAAE;IACN,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB,GACA,OAAO,CAAC,IAAI,CAAC,CAef"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { WORKFLOWS_JOB_STEPS_SETTLED, WORKFLOWS_STEP_ATTEMPT_TERMINATED, WORKFLOWS_STEP_RESTART_ENQUEUED } from '@shipfox/api-workflows-dto';
|
|
2
|
+
import { eq } from 'drizzle-orm';
|
|
3
|
+
import { writeWorkflowsOutboxEvent } from '../outbox-writes.js';
|
|
4
|
+
import { jobExecutions } from '../schema/job-executions.js';
|
|
5
|
+
import { steps } from '../schema/steps.js';
|
|
6
|
+
import { getWorkflowContextForJob } from './shared.js';
|
|
7
|
+
// Enqueue the steps-settled signal in the same transaction as the final per-step
|
|
8
|
+
// result, so per-step execution observes it exactly once (the outbox is at-least-once;
|
|
9
|
+
// the job workflow dedupes the signal). Drives the Temporal JOB_FINISHED_SIGNAL; the
|
|
10
|
+
// job's terminal fact is emitted separately by updateJobStatusAtVersion.
|
|
11
|
+
export async function writeJobStepsSettledOutbox(tx, params) {
|
|
12
|
+
const identity = await getWorkflowContextForJob(params.jobId, tx);
|
|
13
|
+
await writeWorkflowsOutboxEvent(tx, {
|
|
14
|
+
type: WORKFLOWS_JOB_STEPS_SETTLED,
|
|
15
|
+
payload: {
|
|
16
|
+
jobId: params.jobId,
|
|
17
|
+
jobExecutionId: params.jobExecutionId,
|
|
18
|
+
workflowRunId: identity.workflowRunId,
|
|
19
|
+
workflowRunAttemptId: identity.workflowRunAttemptId,
|
|
20
|
+
status: params.status
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export async function writeStepAttemptTerminatedOutbox(tx, params) {
|
|
25
|
+
const identity = await getStepAttemptTerminatedOutboxIdentity(tx, params.stepId);
|
|
26
|
+
await writeWorkflowsOutboxEvent(tx, {
|
|
27
|
+
type: WORKFLOWS_STEP_ATTEMPT_TERMINATED,
|
|
28
|
+
payload: {
|
|
29
|
+
jobId: identity.jobId,
|
|
30
|
+
workflowRunId: identity.workflowRunId,
|
|
31
|
+
workflowRunAttemptId: identity.workflowRunAttemptId,
|
|
32
|
+
workspaceId: identity.workspaceId,
|
|
33
|
+
projectId: identity.projectId,
|
|
34
|
+
stepId: params.stepId,
|
|
35
|
+
attempt: params.attempt,
|
|
36
|
+
logOutcome: params.logOutcome
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async function getStepAttemptTerminatedOutboxIdentity(tx, stepId) {
|
|
41
|
+
const rows = await tx.select({
|
|
42
|
+
jobId: jobExecutions.jobId
|
|
43
|
+
}).from(steps).innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id)).where(eq(steps.id, stepId)).limit(1);
|
|
44
|
+
const step = rows[0];
|
|
45
|
+
if (!step) {
|
|
46
|
+
throw new Error(`Cannot enqueue step-attempt-terminated event: step ${stepId} not found`);
|
|
47
|
+
}
|
|
48
|
+
return getWorkflowContextForJob(step.jobId, tx);
|
|
49
|
+
}
|
|
50
|
+
// Enqueue the durable audit record of a restart, in the same transaction as the
|
|
51
|
+
// rewind. Looks up the workflow run id like writeJobStepsSettledOutbox.
|
|
52
|
+
export async function writeStepRestartEnqueuedOutbox(tx, params) {
|
|
53
|
+
const identity = await getWorkflowContextForJob(params.jobId, tx);
|
|
54
|
+
await writeWorkflowsOutboxEvent(tx, {
|
|
55
|
+
type: WORKFLOWS_STEP_RESTART_ENQUEUED,
|
|
56
|
+
payload: {
|
|
57
|
+
jobId: params.jobId,
|
|
58
|
+
workflowRunId: identity.workflowRunId,
|
|
59
|
+
workflowRunAttemptId: identity.workflowRunAttemptId,
|
|
60
|
+
failedStepId: params.failedStepId,
|
|
61
|
+
failedStepAttempt: params.failedStepAttempt,
|
|
62
|
+
restartFromStepId: params.restartFromStepId,
|
|
63
|
+
feedback: params.feedback
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=outbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/db/workflow-runs/outbox.ts"],"sourcesContent":["import {\n type LogOutcomeDto,\n WORKFLOWS_JOB_STEPS_SETTLED,\n WORKFLOWS_STEP_ATTEMPT_TERMINATED,\n WORKFLOWS_STEP_RESTART_ENQUEUED,\n} from '@shipfox/api-workflows-dto';\nimport {eq} from 'drizzle-orm';\nimport type {Tx} from '../db.js';\nimport {writeWorkflowsOutboxEvent} from '../outbox-writes.js';\nimport {jobExecutions} from '../schema/job-executions.js';\nimport {steps} from '../schema/steps.js';\nimport {getWorkflowContextForJob} from './shared.js';\n\n// Enqueue the steps-settled signal in the same transaction as the final per-step\n// result, so per-step execution observes it exactly once (the outbox is at-least-once;\n// the job workflow dedupes the signal). Drives the Temporal JOB_FINISHED_SIGNAL; the\n// job's terminal fact is emitted separately by updateJobStatusAtVersion.\nexport async function writeJobStepsSettledOutbox(\n tx: Tx,\n params: {jobId: string; jobExecutionId: string; status: 'succeeded' | 'failed'},\n): Promise<void> {\n const identity = await getWorkflowContextForJob(params.jobId, tx);\n\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_JOB_STEPS_SETTLED,\n payload: {\n jobId: params.jobId,\n jobExecutionId: params.jobExecutionId,\n workflowRunId: identity.workflowRunId,\n workflowRunAttemptId: identity.workflowRunAttemptId,\n status: params.status,\n },\n });\n}\n\nexport async function writeStepAttemptTerminatedOutbox(\n tx: Tx,\n params: {stepId: string; attempt: number; logOutcome: LogOutcomeDto},\n): Promise<void> {\n const identity = await getStepAttemptTerminatedOutboxIdentity(tx, params.stepId);\n\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_STEP_ATTEMPT_TERMINATED,\n payload: {\n jobId: identity.jobId,\n workflowRunId: identity.workflowRunId,\n workflowRunAttemptId: identity.workflowRunAttemptId,\n workspaceId: identity.workspaceId,\n projectId: identity.projectId,\n stepId: params.stepId,\n attempt: params.attempt,\n logOutcome: params.logOutcome,\n },\n });\n}\n\nasync function getStepAttemptTerminatedOutboxIdentity(\n tx: Tx,\n stepId: string,\n): Promise<{\n jobId: string;\n workflowRunId: string;\n workflowRunAttemptId: string;\n workspaceId: string;\n projectId: string;\n}> {\n const rows = await tx\n .select({\n jobId: jobExecutions.jobId,\n })\n .from(steps)\n .innerJoin(jobExecutions, eq(steps.jobExecutionId, jobExecutions.id))\n .where(eq(steps.id, stepId))\n .limit(1);\n const step = rows[0];\n if (!step) {\n throw new Error(`Cannot enqueue step-attempt-terminated event: step ${stepId} not found`);\n }\n\n return getWorkflowContextForJob(step.jobId, tx);\n}\n\n// Enqueue the durable audit record of a restart, in the same transaction as the\n// rewind. Looks up the workflow run id like writeJobStepsSettledOutbox.\nexport async function writeStepRestartEnqueuedOutbox(\n tx: Tx,\n params: {\n jobId: string;\n failedStepId: string;\n failedStepAttempt: number;\n restartFromStepId: string;\n feedback: string;\n },\n): Promise<void> {\n const identity = await getWorkflowContextForJob(params.jobId, tx);\n\n await writeWorkflowsOutboxEvent(tx, {\n type: WORKFLOWS_STEP_RESTART_ENQUEUED,\n payload: {\n jobId: params.jobId,\n workflowRunId: identity.workflowRunId,\n workflowRunAttemptId: identity.workflowRunAttemptId,\n failedStepId: params.failedStepId,\n failedStepAttempt: params.failedStepAttempt,\n restartFromStepId: params.restartFromStepId,\n feedback: params.feedback,\n },\n });\n}\n"],"names":["WORKFLOWS_JOB_STEPS_SETTLED","WORKFLOWS_STEP_ATTEMPT_TERMINATED","WORKFLOWS_STEP_RESTART_ENQUEUED","eq","writeWorkflowsOutboxEvent","jobExecutions","steps","getWorkflowContextForJob","writeJobStepsSettledOutbox","tx","params","identity","jobId","type","payload","jobExecutionId","workflowRunId","workflowRunAttemptId","status","writeStepAttemptTerminatedOutbox","getStepAttemptTerminatedOutboxIdentity","stepId","workspaceId","projectId","attempt","logOutcome","rows","select","from","innerJoin","id","where","limit","step","Error","writeStepRestartEnqueuedOutbox","failedStepId","failedStepAttempt","restartFromStepId","feedback"],"mappings":"AAAA,SAEEA,2BAA2B,EAC3BC,iCAAiC,EACjCC,+BAA+B,QAC1B,6BAA6B;AACpC,SAAQC,EAAE,QAAO,cAAc;AAE/B,SAAQC,yBAAyB,QAAO,sBAAsB;AAC9D,SAAQC,aAAa,QAAO,8BAA8B;AAC1D,SAAQC,KAAK,QAAO,qBAAqB;AACzC,SAAQC,wBAAwB,QAAO,cAAc;AAErD,iFAAiF;AACjF,uFAAuF;AACvF,qFAAqF;AACrF,yEAAyE;AACzE,OAAO,eAAeC,2BACpBC,EAAM,EACNC,MAA+E;IAE/E,MAAMC,WAAW,MAAMJ,yBAAyBG,OAAOE,KAAK,EAAEH;IAE9D,MAAML,0BAA0BK,IAAI;QAClCI,MAAMb;QACNc,SAAS;YACPF,OAAOF,OAAOE,KAAK;YACnBG,gBAAgBL,OAAOK,cAAc;YACrCC,eAAeL,SAASK,aAAa;YACrCC,sBAAsBN,SAASM,oBAAoB;YACnDC,QAAQR,OAAOQ,MAAM;QACvB;IACF;AACF;AAEA,OAAO,eAAeC,iCACpBV,EAAM,EACNC,MAAoE;IAEpE,MAAMC,WAAW,MAAMS,uCAAuCX,IAA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
|
1
|
+
import { type TimestampIdCursor } from '@shipfox/node-drizzle';
|
|
2
|
+
import { type SQL } from 'drizzle-orm';
|
|
3
|
+
import type { JobExecutionDetail, WorkflowRun, WorkflowRunDetail, WorkflowRunStatus } from '#core/entities/workflow-run.js';
|
|
4
|
+
export type WorkflowRunCursor = TimestampIdCursor;
|
|
5
|
+
export interface WorkflowRunFilters {
|
|
6
|
+
status?: WorkflowRunStatus | undefined;
|
|
7
|
+
definitionId?: string | undefined;
|
|
8
|
+
triggerSource?: string | undefined;
|
|
9
|
+
createdFrom?: Date | undefined;
|
|
10
|
+
createdTo?: Date | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface ListWorkflowRunsParams {
|
|
13
|
+
projectId: string;
|
|
14
|
+
limit: number;
|
|
15
|
+
cursor?: WorkflowRunCursor | undefined;
|
|
16
|
+
filters?: WorkflowRunFilters | undefined;
|
|
17
|
+
includeTotal?: boolean | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface ListWorkflowRunsResult {
|
|
20
|
+
runs: WorkflowRun[];
|
|
21
|
+
nextCursor: WorkflowRunCursor | null;
|
|
22
|
+
filteredTotalCount: number | null;
|
|
23
|
+
}
|
|
24
|
+
export interface WorkflowRunAggregates {
|
|
25
|
+
status: Array<{
|
|
26
|
+
value: WorkflowRunStatus;
|
|
27
|
+
count: number;
|
|
28
|
+
}>;
|
|
29
|
+
triggerSource: Array<{
|
|
30
|
+
value: string;
|
|
31
|
+
count: number;
|
|
32
|
+
}>;
|
|
33
|
+
workflow: Array<{
|
|
34
|
+
value: string;
|
|
35
|
+
count: number;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface WorkflowJobExecutionDepth {
|
|
39
|
+
runningRuns: number;
|
|
40
|
+
runningJobExecutions: number;
|
|
41
|
+
}
|
|
42
|
+
export interface WorkflowJobExecutionDepthParams {
|
|
43
|
+
workspaceId?: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function getWorkflowRunById(id: string): Promise<WorkflowRun | undefined>;
|
|
46
|
+
export declare function getWorkflowRunByAttemptId(workflowRunAttemptId: string): Promise<WorkflowRun | undefined>;
|
|
47
|
+
export declare function getWorkflowRunAttemptById(workflowRunAttemptId: string): Promise<import("../../core/entities/workflow-run-attempt.js").WorkflowRunAttempt | undefined>;
|
|
48
|
+
export declare function listRunAttempts(params: {
|
|
49
|
+
workflowRunId: string;
|
|
50
|
+
projectId: string;
|
|
51
|
+
}): Promise<import("../../core/entities/workflow-run-attempt.js").WorkflowRunAttempt[]>;
|
|
52
|
+
export declare function getLatestAttempt(params: {
|
|
53
|
+
workflowRunId: string;
|
|
54
|
+
projectId: string;
|
|
55
|
+
}): Promise<number>;
|
|
56
|
+
export declare function buildWorkflowRunListConditions(params: {
|
|
57
|
+
projectId: string;
|
|
58
|
+
filters?: WorkflowRunFilters | undefined;
|
|
59
|
+
cursor?: WorkflowRunCursor | undefined;
|
|
60
|
+
omit?: 'status' | 'definitionId' | 'triggerSource' | undefined;
|
|
61
|
+
}): SQL[];
|
|
62
|
+
export declare function listWorkflowRuns(params: ListWorkflowRunsParams): Promise<ListWorkflowRunsResult>;
|
|
63
|
+
export declare function listWorkflowRunsByProject(projectId: string): Promise<WorkflowRun[]>;
|
|
64
|
+
export declare function getWorkflowRunAggregates(params: {
|
|
65
|
+
projectId: string;
|
|
66
|
+
filters?: WorkflowRunFilters | undefined;
|
|
67
|
+
}): Promise<WorkflowRunAggregates>;
|
|
68
|
+
export declare function getWorkflowJobExecutionDepth(params?: WorkflowJobExecutionDepthParams): Promise<WorkflowJobExecutionDepth>;
|
|
69
|
+
export declare function getWorkflowRunDetail(workflowRunId: string, attempt?: number | undefined): Promise<WorkflowRunDetail | undefined>;
|
|
70
|
+
export declare function getJobExecutionDetail(jobExecutionId: string): Promise<JobExecutionDetail | undefined>;
|
|
71
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["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