@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,188 @@
|
|
|
1
|
+
import { cancelRunnerJobs, enqueueJobExecution, releaseJobExecution } from '@shipfox/api-runners';
|
|
2
|
+
import { ApplicationFailure } from '@temporalio/common';
|
|
3
|
+
import { defaultJobConditionTrace } from '#core/condition-trace.js';
|
|
4
|
+
import { JobNotFoundError } from '#core/errors.js';
|
|
5
|
+
import { activateJobListener, bulkUpdateStepStatuses, drainListenerEventsIntoExecution, evaluateJobActivations, failJobExecutionAsTimedOut, failWorkflowRunAsTimedOut, getJobExecutionsByWorkflowRunAttemptId, getJobsByWorkflowRunAttemptId, getWorkflowRunAttemptById, getWorkflowRunByAttemptId, peekListenerBuffer, resolveJobExecutionAfterLeaseExpiry, resolveJobListener, resolveJobStatusFromJobExecutions, settleListenerJobExecution, updateJobExecutionStatus, updateJobStatus, updateWorkflowRunStatus } from '#db/index.js';
|
|
6
|
+
import { recordWorkflowListenerExecution } from '#metrics/instance.js';
|
|
7
|
+
export async function loadRunAttemptDag(runAttemptId) {
|
|
8
|
+
const run = await getWorkflowRunByAttemptId(runAttemptId);
|
|
9
|
+
if (!run) throw new Error(`Run not found for attempt: ${runAttemptId}`);
|
|
10
|
+
const attempt = await getWorkflowRunAttemptById(runAttemptId);
|
|
11
|
+
if (!attempt) throw new Error(`Run attempt not found: ${runAttemptId}`);
|
|
12
|
+
const jobs = await getJobsByWorkflowRunAttemptId(runAttemptId);
|
|
13
|
+
const jobExecutions = await getJobExecutionsByWorkflowRunAttemptId(runAttemptId);
|
|
14
|
+
const firstJobExecutions = new Map();
|
|
15
|
+
for (const jobExecution of jobExecutions){
|
|
16
|
+
if (!firstJobExecutions.has(jobExecution.jobId)) {
|
|
17
|
+
firstJobExecutions.set(jobExecution.jobId, jobExecution);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
workflowRunId: run.id,
|
|
22
|
+
runAttemptId,
|
|
23
|
+
workspaceId: run.workspaceId,
|
|
24
|
+
projectId: run.projectId,
|
|
25
|
+
runVersion: attempt.version,
|
|
26
|
+
runTimeoutMs: run.timeoutMs,
|
|
27
|
+
jobs: jobs.flatMap((job)=>{
|
|
28
|
+
const jobExecution = firstJobExecutions.get(job.id);
|
|
29
|
+
const modelJob = attempt.model?.jobs.find((item)=>item.key === job.key);
|
|
30
|
+
if (!jobExecution && job.mode !== 'listening') return [];
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
id: job.id,
|
|
34
|
+
key: job.key,
|
|
35
|
+
mode: job.mode,
|
|
36
|
+
status: job.status,
|
|
37
|
+
...jobExecution === undefined ? {} : {
|
|
38
|
+
jobExecutionId: jobExecution.id,
|
|
39
|
+
executionVersion: jobExecution.version
|
|
40
|
+
},
|
|
41
|
+
executionTimeoutMs: job.executionTimeoutMs,
|
|
42
|
+
listeningTimeoutMs: job.listeningTimeoutMs,
|
|
43
|
+
maxExecutions: job.maxExecutions,
|
|
44
|
+
onResolve: job.onResolve,
|
|
45
|
+
batchDebounceMs: job.batchDebounceMs,
|
|
46
|
+
batchMaxSize: job.batchMaxSize,
|
|
47
|
+
batchMaxWaitMs: job.batchMaxWaitMs,
|
|
48
|
+
dependencies: job.dependencies,
|
|
49
|
+
hasActivationCondition: modelJob?.if !== undefined,
|
|
50
|
+
runner: jobExecution?.runner ?? job.runner ?? [],
|
|
51
|
+
version: job.version
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export async function evaluateJobActivationsActivity(params) {
|
|
58
|
+
return await evaluateJobActivations(params);
|
|
59
|
+
}
|
|
60
|
+
export async function setRunAttemptStatus(params) {
|
|
61
|
+
const updated = await updateWorkflowRunStatus({
|
|
62
|
+
workflowRunAttemptId: params.runAttemptId,
|
|
63
|
+
status: params.status,
|
|
64
|
+
expectedVersion: params.version
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
newVersion: updated.version,
|
|
68
|
+
status: updated.status
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export async function setJobStatus(params) {
|
|
72
|
+
const updated = await updateJobStatus({
|
|
73
|
+
jobId: params.jobId,
|
|
74
|
+
status: params.status,
|
|
75
|
+
expectedVersion: params.version,
|
|
76
|
+
statusReason: params.statusReason,
|
|
77
|
+
evaluationTrace: jobStatusEvaluationTrace(params)
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
newVersion: updated.version,
|
|
81
|
+
status: updated.status
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function jobStatusEvaluationTrace(params) {
|
|
85
|
+
if (params.evaluationTrace !== undefined) return params.evaluationTrace;
|
|
86
|
+
return params.status === 'skipped' && params.statusReason === 'default_gate_rejected' ? defaultJobConditionTrace() : undefined;
|
|
87
|
+
}
|
|
88
|
+
export async function setJobExecutionStatus(params) {
|
|
89
|
+
const updated = await updateJobExecutionStatus({
|
|
90
|
+
jobExecutionId: params.jobExecutionId,
|
|
91
|
+
status: params.status,
|
|
92
|
+
expectedVersion: params.version,
|
|
93
|
+
statusReason: params.statusReason
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
newVersion: updated.version,
|
|
97
|
+
status: updated.status
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export async function bulkSetStepStatuses(params) {
|
|
101
|
+
await bulkUpdateStepStatuses(params);
|
|
102
|
+
}
|
|
103
|
+
export async function resolveLeaseExpiredJobExecutionActivity(params) {
|
|
104
|
+
try {
|
|
105
|
+
return await resolveJobExecutionAfterLeaseExpiry(params);
|
|
106
|
+
} catch (err) {
|
|
107
|
+
if (err instanceof JobNotFoundError) {
|
|
108
|
+
throw ApplicationFailure.nonRetryable(err.message, err.name);
|
|
109
|
+
}
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Best-effort lease cleanup on job finalization. Idempotent: deleting an
|
|
114
|
+
// already-released (or already-reaped) lease is a no-op. The workflow wraps the
|
|
115
|
+
// call so a persistent failure never blocks the DAG result.
|
|
116
|
+
export async function releaseLeaseActivity(params) {
|
|
117
|
+
await releaseJobExecution({
|
|
118
|
+
jobExecutionId: params.jobExecutionId
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export async function enqueueJobExecutionForRunner(params) {
|
|
122
|
+
try {
|
|
123
|
+
await enqueueJobExecution({
|
|
124
|
+
workspaceId: params.workspaceId,
|
|
125
|
+
workflowRunId: params.workflowRunId,
|
|
126
|
+
workflowRunAttemptId: params.runAttemptId,
|
|
127
|
+
jobId: params.jobId,
|
|
128
|
+
jobExecutionId: params.jobExecutionId,
|
|
129
|
+
projectId: params.projectId,
|
|
130
|
+
requiredLabels: params.requiredLabels
|
|
131
|
+
});
|
|
132
|
+
} catch (err) {
|
|
133
|
+
if (err instanceof Error && err.name === 'EmptyRequiredLabelsError') {
|
|
134
|
+
throw ApplicationFailure.nonRetryable(err.message, err.name);
|
|
135
|
+
}
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export async function cancelRunnerJobsActivity(params) {
|
|
140
|
+
await cancelRunnerJobs({
|
|
141
|
+
jobIds: params.jobIds
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
export async function failJobExecutionAsTimedOutActivity(params) {
|
|
145
|
+
const jobExecution = await failJobExecutionAsTimedOut({
|
|
146
|
+
jobExecutionId: params.jobExecutionId,
|
|
147
|
+
workflowRunAttemptId: params.runAttemptId,
|
|
148
|
+
expectedVersion: params.expectedVersion
|
|
149
|
+
});
|
|
150
|
+
return {
|
|
151
|
+
newVersion: jobExecution.version
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export async function failRunAsTimedOutActivity(params) {
|
|
155
|
+
await failWorkflowRunAsTimedOut({
|
|
156
|
+
runAttemptId: params.runAttemptId
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
export async function resolveJobStatusFromJobExecutionsActivity(params) {
|
|
160
|
+
return await resolveJobStatusFromJobExecutions(params);
|
|
161
|
+
}
|
|
162
|
+
export async function activateJobListenerActivity(params) {
|
|
163
|
+
return await activateJobListener(params);
|
|
164
|
+
}
|
|
165
|
+
export async function drainListenerEventsActivity(params) {
|
|
166
|
+
return await drainListenerEventsIntoExecution(params);
|
|
167
|
+
}
|
|
168
|
+
export async function peekListenerBufferActivity(params) {
|
|
169
|
+
return await peekListenerBuffer(params);
|
|
170
|
+
}
|
|
171
|
+
export async function resolveJobListenerActivity(params) {
|
|
172
|
+
return await resolveJobListener(params);
|
|
173
|
+
}
|
|
174
|
+
export async function settleListenerJobExecutionActivity(params) {
|
|
175
|
+
await settleListenerJobExecution(params);
|
|
176
|
+
}
|
|
177
|
+
// The listener workflow owns every firing's terminal outcome, but a workflow
|
|
178
|
+
// sandbox cannot emit metrics. This activity is the single recording point so
|
|
179
|
+
// each firing is counted exactly once, including successes that settle through
|
|
180
|
+
// the child's own resolution path rather than a listener DB write. The body is
|
|
181
|
+
// synchronous; it returns a resolved promise because Temporal invokes activities
|
|
182
|
+
// asynchronously.
|
|
183
|
+
export function recordListenerFiringOutcomeActivity(params) {
|
|
184
|
+
recordWorkflowListenerExecution(params.outcome);
|
|
185
|
+
return Promise.resolve();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=orchestration-activities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/activities/orchestration-activities.ts"],"sourcesContent":["import {cancelRunnerJobs, enqueueJobExecution, releaseJobExecution} from '@shipfox/api-runners';\nimport {ApplicationFailure} from '@temporalio/common';\nimport {defaultJobConditionTrace} from '#core/condition-trace.js';\nimport type {JobStatus, JobStatusReason, ResolutionReason} from '#core/entities/job.js';\nimport type {PersistedEvaluationTraceEntry, StepStatus} from '#core/entities/step.js';\nimport type {WorkflowRunStatus} from '#core/entities/workflow-run.js';\nimport {JobNotFoundError} from '#core/errors.js';\nimport type {\n RuntimeCompletionStatus,\n RuntimeDagNode,\n} from '#core/workflow-scheduling/runtime-dag.js';\nimport {\n activateJobListener,\n bulkUpdateStepStatuses,\n drainListenerEventsIntoExecution,\n type EvaluateJobActivationsParams,\n evaluateJobActivations,\n failJobExecutionAsTimedOut,\n failWorkflowRunAsTimedOut,\n getJobExecutionsByWorkflowRunAttemptId,\n getJobsByWorkflowRunAttemptId,\n getWorkflowRunAttemptById,\n getWorkflowRunByAttemptId,\n type JobActivationDecision,\n peekListenerBuffer,\n resolveJobExecutionAfterLeaseExpiry,\n resolveJobListener,\n resolveJobStatusFromJobExecutions,\n settleListenerJobExecution,\n updateJobExecutionStatus,\n updateJobStatus,\n updateWorkflowRunStatus,\n} from '#db/index.js';\nimport {recordWorkflowListenerExecution} from '#metrics/instance.js';\n\nexport interface DagJob extends RuntimeDagNode {\n id: string;\n key: string;\n mode: 'one_shot' | 'listening';\n status: JobStatus;\n jobExecutionId?: string | undefined;\n executionVersion?: number;\n executionTimeoutMs?: number | null | undefined;\n listeningTimeoutMs?: number | null | undefined;\n maxExecutions?: number | null | undefined;\n onResolve?: 'finish' | 'cancel' | null | undefined;\n batchDebounceMs?: number | null | undefined;\n batchMaxSize?: number | null | undefined;\n batchMaxWaitMs?: number | null | undefined;\n dependencies: string[];\n runner: string[];\n version: number;\n}\n\nexport interface RunDag {\n workflowRunId: string;\n runAttemptId: string;\n workspaceId: string;\n projectId: string;\n runVersion: number;\n runTimeoutMs: number;\n jobs: DagJob[];\n}\n\nexport async function loadRunAttemptDag(runAttemptId: string): Promise<RunDag> {\n const run = await getWorkflowRunByAttemptId(runAttemptId);\n if (!run) throw new Error(`Run not found for attempt: ${runAttemptId}`);\n const attempt = await getWorkflowRunAttemptById(runAttemptId);\n if (!attempt) throw new Error(`Run attempt not found: ${runAttemptId}`);\n\n const jobs = await getJobsByWorkflowRunAttemptId(runAttemptId);\n const jobExecutions = await getJobExecutionsByWorkflowRunAttemptId(runAttemptId);\n const firstJobExecutions = new Map<string, (typeof jobExecutions)[number]>();\n for (const jobExecution of jobExecutions) {\n if (!firstJobExecutions.has(jobExecution.jobId)) {\n firstJobExecutions.set(jobExecution.jobId, jobExecution);\n }\n }\n\n return {\n workflowRunId: run.id,\n runAttemptId,\n workspaceId: run.workspaceId,\n projectId: run.projectId,\n runVersion: attempt.version,\n runTimeoutMs: run.timeoutMs,\n jobs: jobs.flatMap((job) => {\n const jobExecution = firstJobExecutions.get(job.id);\n const modelJob = attempt.model?.jobs.find((item) => item.key === job.key);\n if (!jobExecution && job.mode !== 'listening') return [];\n return [\n {\n id: job.id,\n key: job.key,\n mode: job.mode,\n status: job.status,\n ...(jobExecution === undefined\n ? {}\n : {jobExecutionId: jobExecution.id, executionVersion: jobExecution.version}),\n executionTimeoutMs: job.executionTimeoutMs,\n listeningTimeoutMs: job.listeningTimeoutMs,\n maxExecutions: job.maxExecutions,\n onResolve: job.onResolve,\n batchDebounceMs: job.batchDebounceMs,\n batchMaxSize: job.batchMaxSize,\n batchMaxWaitMs: job.batchMaxWaitMs,\n dependencies: job.dependencies,\n hasActivationCondition: modelJob?.if !== undefined,\n runner: jobExecution?.runner ?? job.runner ?? [],\n version: job.version,\n },\n ];\n }),\n };\n}\n\nexport async function evaluateJobActivationsActivity(\n params: EvaluateJobActivationsParams,\n): Promise<JobActivationDecision[]> {\n return await evaluateJobActivations(params);\n}\n\nexport async function setRunAttemptStatus(params: {\n runAttemptId: string;\n status: WorkflowRunStatus;\n version: number;\n}): Promise<{newVersion: number; status: WorkflowRunStatus}> {\n const updated = await updateWorkflowRunStatus({\n workflowRunAttemptId: params.runAttemptId,\n status: params.status,\n expectedVersion: params.version,\n });\n return {newVersion: updated.version, status: updated.status};\n}\n\nexport async function setJobStatus(params: {\n jobId: string;\n status: JobStatus;\n version: number;\n statusReason?: JobStatusReason | null | undefined;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null | undefined;\n}): Promise<{newVersion: number; status: JobStatus}> {\n const updated = await updateJobStatus({\n jobId: params.jobId,\n status: params.status,\n expectedVersion: params.version,\n statusReason: params.statusReason,\n evaluationTrace: jobStatusEvaluationTrace(params),\n });\n return {newVersion: updated.version, status: updated.status};\n}\n\nfunction jobStatusEvaluationTrace(params: {\n status: JobStatus;\n statusReason?: JobStatusReason | null | undefined;\n evaluationTrace?: readonly PersistedEvaluationTraceEntry[] | null | undefined;\n}): readonly PersistedEvaluationTraceEntry[] | null | undefined {\n if (params.evaluationTrace !== undefined) return params.evaluationTrace;\n return params.status === 'skipped' && params.statusReason === 'default_gate_rejected'\n ? defaultJobConditionTrace()\n : undefined;\n}\n\nexport async function setJobExecutionStatus(params: {\n jobExecutionId: string;\n status: Exclude<JobStatus, 'skipped'>;\n version: number;\n statusReason?: JobStatusReason | null | undefined;\n}): Promise<{newVersion: number; status: Exclude<JobStatus, 'skipped'>}> {\n const updated = await updateJobExecutionStatus({\n jobExecutionId: params.jobExecutionId,\n status: params.status,\n expectedVersion: params.version,\n statusReason: params.statusReason,\n });\n return {newVersion: updated.version, status: updated.status};\n}\n\nexport async function bulkSetStepStatuses(params: {\n jobExecutionId: string;\n status: Extract<StepStatus, 'failed' | 'cancelled'>;\n}): Promise<void> {\n await bulkUpdateStepStatuses(params);\n}\n\nexport async function resolveLeaseExpiredJobExecutionActivity(params: {\n jobExecutionId: string;\n expectedVersion: number;\n}): Promise<{status: RuntimeCompletionStatus; executionVersion: number}> {\n try {\n return await resolveJobExecutionAfterLeaseExpiry(params);\n } catch (err) {\n if (err instanceof JobNotFoundError) {\n throw ApplicationFailure.nonRetryable(err.message, err.name);\n }\n throw err;\n }\n}\n\n// Best-effort lease cleanup on job finalization. Idempotent: deleting an\n// already-released (or already-reaped) lease is a no-op. The workflow wraps the\n// call so a persistent failure never blocks the DAG result.\nexport async function releaseLeaseActivity(params: {jobExecutionId: string}): Promise<void> {\n await releaseJobExecution({jobExecutionId: params.jobExecutionId});\n}\n\nexport async function enqueueJobExecutionForRunner(params: {\n workspaceId: string;\n workflowRunId: string;\n jobId: string;\n jobExecutionId: string;\n runAttemptId: string;\n projectId: string;\n requiredLabels: string[];\n}): Promise<void> {\n try {\n await enqueueJobExecution({\n workspaceId: params.workspaceId,\n workflowRunId: params.workflowRunId,\n workflowRunAttemptId: params.runAttemptId,\n jobId: params.jobId,\n jobExecutionId: params.jobExecutionId,\n projectId: params.projectId,\n requiredLabels: params.requiredLabels,\n });\n } catch (err) {\n if (err instanceof Error && err.name === 'EmptyRequiredLabelsError') {\n throw ApplicationFailure.nonRetryable(err.message, err.name);\n }\n throw err;\n }\n}\n\nexport async function cancelRunnerJobsActivity(params: {jobIds: string[]}): Promise<void> {\n await cancelRunnerJobs({jobIds: params.jobIds});\n}\n\nexport async function failJobExecutionAsTimedOutActivity(params: {\n jobExecutionId: string;\n runAttemptId: string;\n expectedVersion: number;\n}): Promise<{newVersion: number}> {\n const jobExecution = await failJobExecutionAsTimedOut({\n jobExecutionId: params.jobExecutionId,\n workflowRunAttemptId: params.runAttemptId,\n expectedVersion: params.expectedVersion,\n });\n return {newVersion: jobExecution.version};\n}\n\nexport async function failRunAsTimedOutActivity(params: {runAttemptId: string}): Promise<void> {\n await failWorkflowRunAsTimedOut({runAttemptId: params.runAttemptId});\n}\n\nexport async function resolveJobStatusFromJobExecutionsActivity(params: {\n jobId: string;\n}): Promise<{status: RuntimeCompletionStatus; jobVersion: number}> {\n return await resolveJobStatusFromJobExecutions(params);\n}\n\nexport async function activateJobListenerActivity(params: {\n jobId: string;\n expectedVersion: number;\n}) {\n return await activateJobListener(params);\n}\n\nexport async function drainListenerEventsActivity(params: {\n jobId: string;\n expectedSequence: number;\n maxSize?: number | undefined;\n}) {\n return await drainListenerEventsIntoExecution(params);\n}\n\nexport async function peekListenerBufferActivity(params: {jobId: string}) {\n return await peekListenerBuffer(params);\n}\n\nexport async function resolveJobListenerActivity(params: {\n jobId: string;\n reason: ResolutionReason;\n}) {\n return await resolveJobListener(params);\n}\n\nexport async function settleListenerJobExecutionActivity(params: {\n jobExecutionId: string;\n status: 'failed' | 'cancelled';\n}) {\n await settleListenerJobExecution(params);\n}\n\n// The listener workflow owns every firing's terminal outcome, but a workflow\n// sandbox cannot emit metrics. This activity is the single recording point so\n// each firing is counted exactly once, including successes that settle through\n// the child's own resolution path rather than a listener DB write. The body is\n// synchronous; it returns a resolved promise because Temporal invokes activities\n// asynchronously.\nexport function recordListenerFiringOutcomeActivity(params: {\n outcome: 'succeeded' | 'failed' | 'cancelled';\n}): Promise<void> {\n recordWorkflowListenerExecution(params.outcome);\n return Promise.resolve();\n}\n"],"names":["cancelRunnerJobs","enqueueJobExecution","releaseJobExecution","ApplicationFailure","defaultJobConditionTrace","JobNotFoundError","activateJobListener","bulkUpdateStepStatuses","drainListenerEventsIntoExecution","evaluateJobActivations","failJobExecutionAsTimedOut","failWorkflowRunAsTimedOut","getJobExecutionsByWorkflowRunAttemptId","getJobsByWorkflowRunAttemptId","getWorkflowRunAttemptById","getWorkflowRunByAttemptId","peekListenerBuffer","resolveJobExecutionAfterLeaseExpiry","resolveJobListener","resolveJobStatusFromJobExecutions","settleListenerJobExecution","updateJobExecutionStatus","updateJobStatus","updateWorkflowRunStatus","recordWorkflowListenerExecution","loadRunAttemptDag","runAttemptId","run","Error","attempt","jobs","jobExecutions","firstJobExecutions","Map","jobExecution","has","jobId","set","workflowRunId","id","workspaceId","projectId","runVersion","version","runTimeoutMs","timeoutMs","flatMap","job","get","modelJob","model","find","item","key","mode","status","undefined","jobExecutionId","executionVersion","executionTimeoutMs","listeningTimeoutMs","maxExecutions","onResolve","batchDebounceMs","batchMaxSize","batchMaxWaitMs","dependencies","hasActivationCondition","if","runner","evaluateJobActivationsActivity","params","setRunAttemptStatus","updated","workflowRunAttemptId","expectedVersion","newVersion","setJobStatus","statusReason","evaluationTrace","jobStatusEvaluationTrace","setJobExecutionStatus","bulkSetStepStatuses","resolveLeaseExpiredJobExecutionActivity","err","nonRetryable","message","name","releaseLeaseActivity","enqueueJobExecutionForRunner","requiredLabels","cancelRunnerJobsActivity","jobIds","failJobExecutionAsTimedOutActivity","failRunAsTimedOutActivity","resolveJobStatusFromJobExecutionsActivity","activateJobListenerActivity","drainListenerEventsActivity","peekListenerBufferActivity","resolveJobListenerActivity","settleListenerJobExecutionActivity","recordListenerFiringOutcomeActivity","outcome","Promise","resolve"],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const WORKFLOWS_TASK_QUEUE = "workflows-orchestrator";
|
|
2
|
+
export declare const RUN_CANCEL_SIGNAL = "run-cancel";
|
|
3
|
+
export declare const JOB_FINISHED_SIGNAL = "job-finished";
|
|
4
|
+
export declare const JOB_LEASE_EXPIRED_SIGNAL = "job-lease-expired";
|
|
5
|
+
export declare const LISTENER_EVENTS_AVAILABLE_SIGNAL = "events-available";
|
|
6
|
+
export declare const LISTENER_RESOLVE_SIGNAL = "resolve";
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/temporal/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAC7D,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAC9C,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,gCAAgC,qBAAqB,CAAC;AACnE,eAAO,MAAM,uBAAuB,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const WORKFLOWS_TASK_QUEUE = 'workflows-orchestrator';
|
|
2
|
+
export const RUN_CANCEL_SIGNAL = 'run-cancel';
|
|
3
|
+
export const JOB_FINISHED_SIGNAL = 'job-finished';
|
|
4
|
+
export const JOB_LEASE_EXPIRED_SIGNAL = 'job-lease-expired';
|
|
5
|
+
export const LISTENER_EVENTS_AVAILABLE_SIGNAL = 'events-available';
|
|
6
|
+
export const LISTENER_RESOLVE_SIGNAL = 'resolve';
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/constants.ts"],"sourcesContent":["export const WORKFLOWS_TASK_QUEUE = 'workflows-orchestrator';\nexport const RUN_CANCEL_SIGNAL = 'run-cancel';\nexport const JOB_FINISHED_SIGNAL = 'job-finished';\nexport const JOB_LEASE_EXPIRED_SIGNAL = 'job-lease-expired';\nexport const LISTENER_EVENTS_AVAILABLE_SIGNAL = 'events-available';\nexport const LISTENER_RESOLVE_SIGNAL = 'resolve';\n"],"names":["WORKFLOWS_TASK_QUEUE","RUN_CANCEL_SIGNAL","JOB_FINISHED_SIGNAL","JOB_LEASE_EXPIRED_SIGNAL","LISTENER_EVENTS_AVAILABLE_SIGNAL","LISTENER_RESOLVE_SIGNAL"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,yBAAyB;AAC7D,OAAO,MAAMC,oBAAoB,aAAa;AAC9C,OAAO,MAAMC,sBAAsB,eAAe;AAClD,OAAO,MAAMC,2BAA2B,oBAAoB;AAC5D,OAAO,MAAMC,mCAAmC,mBAAmB;AACnE,OAAO,MAAMC,0BAA0B,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/temporal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,uBAAuB,CAAC;AACpE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/index.ts"],"sourcesContent":["export {createOrchestrationActivities} from './activities/index.js';\nexport {\n JOB_FINISHED_SIGNAL,\n JOB_LEASE_EXPIRED_SIGNAL,\n WORKFLOWS_TASK_QUEUE,\n} from './constants.js';\n"],"names":["createOrchestrationActivities","JOB_FINISHED_SIGNAL","JOB_LEASE_EXPIRED_SIGNAL","WORKFLOWS_TASK_QUEUE"],"mappings":"AAAA,SAAQA,6BAA6B,QAAO,wBAAwB;AACpE,SACEC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,QACf,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-not-found.d.ts","sourceRoot":"","sources":["../../src/temporal/workflow-not-found.ts"],"names":[],"mappings":"AAMA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAExD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// A signal to a workflow that has already terminated (it finished or hit the
|
|
2
|
+
// timeout backstop first) throws WorkflowNotFoundError. Match on the error name
|
|
3
|
+
// rather than `instanceof` so the check holds regardless of which @temporalio
|
|
4
|
+
// package instance constructed the error.
|
|
5
|
+
const WORKFLOW_NOT_FOUND = 'WorkflowNotFoundError';
|
|
6
|
+
export function isWorkflowNotFound(err) {
|
|
7
|
+
return err instanceof Error && err.name === WORKFLOW_NOT_FOUND;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=workflow-not-found.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/workflow-not-found.ts"],"sourcesContent":["// A signal to a workflow that has already terminated (it finished or hit the\n// timeout backstop first) throws WorkflowNotFoundError. Match on the error name\n// rather than `instanceof` so the check holds regardless of which @temporalio\n// package instance constructed the error.\nconst WORKFLOW_NOT_FOUND = 'WorkflowNotFoundError';\n\nexport function isWorkflowNotFound(err: unknown): boolean {\n return err instanceof Error && err.name === WORKFLOW_NOT_FOUND;\n}\n"],"names":["WORKFLOW_NOT_FOUND","isWorkflowNotFound","err","Error","name"],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,8EAA8E;AAC9E,0CAA0C;AAC1C,MAAMA,qBAAqB;AAE3B,OAAO,SAASC,mBAAmBC,GAAY;IAC7C,OAAOA,eAAeC,SAASD,IAAIE,IAAI,KAAKJ;AAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/deadline.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAErE;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE5E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function deadlineReached(deadline) {
|
|
2
|
+
return deadline !== undefined && Date.now() >= deadline;
|
|
3
|
+
}
|
|
4
|
+
export function remainingMs(deadline) {
|
|
5
|
+
return deadline === undefined ? undefined : Math.max(0, deadline - Date.now());
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=deadline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/deadline.ts"],"sourcesContent":["export function deadlineReached(deadline: number | undefined): boolean {\n return deadline !== undefined && Date.now() >= deadline;\n}\n\nexport function remainingMs(deadline: number | undefined): number | undefined {\n return deadline === undefined ? undefined : Math.max(0, deadline - Date.now());\n}\n"],"names":["deadlineReached","deadline","undefined","Date","now","remainingMs","Math","max"],"mappings":"AAAA,OAAO,SAASA,gBAAgBC,QAA4B;IAC1D,OAAOA,aAAaC,aAAaC,KAAKC,GAAG,MAAMH;AACjD;AAEA,OAAO,SAASI,YAAYJ,QAA4B;IACtD,OAAOA,aAAaC,YAAYA,YAAYI,KAAKC,GAAG,CAAC,GAAGN,WAAWE,KAAKC,GAAG;AAC7E"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { jobExecutionOrchestration, jobFinishedSignal, jobLeaseExpiredSignal, } from './job-execution-orchestration.js';
|
|
2
|
+
export { jobListenerOrchestration, listenerEventsAvailableSignal, listenerResolveSignal, } from './job-listener-orchestration.js';
|
|
3
|
+
export { runOrchestration } from './run-orchestration.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { jobExecutionOrchestration, jobFinishedSignal, jobLeaseExpiredSignal } from './job-execution-orchestration.js';
|
|
2
|
+
export { jobListenerOrchestration, listenerEventsAvailableSignal, listenerResolveSignal } from './job-listener-orchestration.js';
|
|
3
|
+
export { runOrchestration } from './run-orchestration.js';
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/index.ts"],"sourcesContent":["export {\n jobExecutionOrchestration,\n jobFinishedSignal,\n jobLeaseExpiredSignal,\n} from './job-execution-orchestration.js';\nexport {\n jobListenerOrchestration,\n listenerEventsAvailableSignal,\n listenerResolveSignal,\n} from './job-listener-orchestration.js';\nexport {runOrchestration} from './run-orchestration.js';\n"],"names":["jobExecutionOrchestration","jobFinishedSignal","jobLeaseExpiredSignal","jobListenerOrchestration","listenerEventsAvailableSignal","listenerResolveSignal","runOrchestration"],"mappings":"AAAA,SACEA,yBAAyB,EACzBC,iBAAiB,EACjBC,qBAAqB,QAChB,mCAAmC;AAC1C,SACEC,wBAAwB,EACxBC,6BAA6B,EAC7BC,qBAAqB,QAChB,kCAAkC;AACzC,SAAQC,gBAAgB,QAAO,yBAAyB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RuntimeCompletionStatus } from '#core/workflow-scheduling/runtime-dag.js';
|
|
2
|
+
export declare const jobFinishedSignal: import("@temporalio/common").SignalDefinition<[{
|
|
3
|
+
status: RuntimeCompletionStatus;
|
|
4
|
+
jobExecutionId?: string | undefined;
|
|
5
|
+
}], string>;
|
|
6
|
+
export declare const jobLeaseExpiredSignal: import("@temporalio/common").SignalDefinition<[{
|
|
7
|
+
jobExecutionId?: string | undefined;
|
|
8
|
+
}], string>;
|
|
9
|
+
export interface JobExecutionOrchestrationInput {
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
workflowRunId: string;
|
|
12
|
+
runAttemptId: string;
|
|
13
|
+
jobId: string;
|
|
14
|
+
jobExecutionId: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
jobVersion: number;
|
|
17
|
+
executionVersion: number;
|
|
18
|
+
executionTimeoutMs?: number | null | undefined;
|
|
19
|
+
resolveJobStatus?: boolean | undefined;
|
|
20
|
+
requiredLabels: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface JobExecutionOrchestrationResult {
|
|
23
|
+
status: RuntimeCompletionStatus;
|
|
24
|
+
jobVersion: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function jobExecutionOrchestration(input: JobExecutionOrchestrationInput): Promise<JobExecutionOrchestrationResult>;
|
|
27
|
+
//# sourceMappingURL=job-execution-orchestration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-execution-orchestration.d.ts","sourceRoot":"","sources":["../../../src/temporal/workflows/job-execution-orchestration.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,0CAA0C,CAAC;AAoDtF,eAAO,MAAM,iBAAiB;YACL,uBAAuB;qBAAmB,MAAM,GAAG,SAAS;WAElF,CAAC;AACJ,eAAO,MAAM,qBAAqB;qBACA,MAAM,GAAG,SAAS;WAA6B,CAAC;AAElF,MAAM,WAAW,8BAA8B;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/C,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,uBAAuB,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB;AAyMD,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,+BAA+B,CAAC,CA0B1C"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { ApplicationFailure } from '@temporalio/common';
|
|
2
|
+
import { condition, defineSignal, log, proxyActivities, setHandler } from '@temporalio/workflow';
|
|
3
|
+
import { hasNoRequiredRunnerLabels, jobExecutionStartOutcome, resolveJobExecutionOutcomeSignal } from '#core/job-execution-outcome.js';
|
|
4
|
+
import { JOB_FINISHED_SIGNAL, JOB_LEASE_EXPIRED_SIGNAL } from '../constants.js';
|
|
5
|
+
/**
|
|
6
|
+
* Two signals, one precedence ladder, then best-effort lease release:
|
|
7
|
+
*
|
|
8
|
+
* job-finished (recordStepResult exhausted the steps) ─┐
|
|
9
|
+
* job-lease-expired (runner heartbeat went stale) ─────┤
|
|
10
|
+
* ▼
|
|
11
|
+
* condition(finished ∥ leaseExpired, executionTimeout)
|
|
12
|
+
* ├─ finished → setJobExecutionStatus(status) + resolve job status ─┐
|
|
13
|
+
* ├─ leaseExpired → resolveLeaseExpiredJobExecutionActivity ─┤→ releaseLease
|
|
14
|
+
* └─ neither (6h) → failJobExecutionAsTimedOutActivity + sweep steps (NO release; the
|
|
15
|
+
* TIMED_OUT event drives cooperative cancel, the detector reaps)
|
|
16
|
+
*
|
|
17
|
+
* Both signals can be delivered before condition() resumes (independent outboxes,
|
|
18
|
+
* no ordering), so finished is evaluated FIRST: a genuinely-finished job is never
|
|
19
|
+
* flipped to failed by a late lease-expiry. releaseLease is best-effort — a runners
|
|
20
|
+
* DB outage must never block the child workflow from returning the job outcome to
|
|
21
|
+
* run-orchestration; a leftover lease row is reaped by the stuck detector.
|
|
22
|
+
*/ const { setJobStatus, setJobExecutionStatus, enqueueJobExecutionForRunner, bulkSetStepStatuses, failJobExecutionAsTimedOutActivity, resolveLeaseExpiredJobExecutionActivity } = proxyActivities({
|
|
23
|
+
startToCloseTimeout: '30s'
|
|
24
|
+
});
|
|
25
|
+
const { resolveJobStatusFromJobExecutionsActivity } = proxyActivities({
|
|
26
|
+
startToCloseTimeout: '30s',
|
|
27
|
+
retry: {
|
|
28
|
+
maximumAttempts: 5
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
// Lease cleanup gets a bounded retry policy of its own: after a few attempts the
|
|
32
|
+
// workflow stops waiting on it (see releaseLeaseBestEffort) rather than blocking
|
|
33
|
+
// the DAG on runners-side availability.
|
|
34
|
+
const { releaseLeaseActivity } = proxyActivities({
|
|
35
|
+
startToCloseTimeout: '30s',
|
|
36
|
+
retry: {
|
|
37
|
+
maximumAttempts: 5
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const DEFAULT_EXECUTION_MAX_DURATION_MS = 6 * 60 * 60 * 1000;
|
|
41
|
+
export const jobFinishedSignal = defineSignal(JOB_FINISHED_SIGNAL);
|
|
42
|
+
export const jobLeaseExpiredSignal = defineSignal(JOB_LEASE_EXPIRED_SIGNAL);
|
|
43
|
+
async function releaseLeaseBestEffort(jobExecutionId) {
|
|
44
|
+
try {
|
|
45
|
+
await releaseLeaseActivity({
|
|
46
|
+
jobExecutionId
|
|
47
|
+
});
|
|
48
|
+
} catch (err) {
|
|
49
|
+
log.warn('lease release failed; stuck detector will reap the row', {
|
|
50
|
+
jobExecutionId,
|
|
51
|
+
error: String(err)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function resolveJobStatusOrFailClosed(input) {
|
|
56
|
+
try {
|
|
57
|
+
return await resolveJobStatusFromJobExecutionsActivity({
|
|
58
|
+
jobId: input.jobId
|
|
59
|
+
});
|
|
60
|
+
} catch (err) {
|
|
61
|
+
log.error('job status resolution failed; failing job closed', {
|
|
62
|
+
jobId: input.jobId,
|
|
63
|
+
jobExecutionId: input.jobExecutionId,
|
|
64
|
+
error: String(err)
|
|
65
|
+
});
|
|
66
|
+
const { newVersion } = await setJobStatus({
|
|
67
|
+
jobId: input.jobId,
|
|
68
|
+
status: 'failed',
|
|
69
|
+
version: input.jobVersion,
|
|
70
|
+
statusReason: 'step_failed'
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
status: 'failed',
|
|
74
|
+
jobVersion: newVersion
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function markJobExecutionRunningAndEnqueue(input) {
|
|
79
|
+
if (hasNoRequiredRunnerLabels(input.requiredLabels)) {
|
|
80
|
+
throw ApplicationFailure.nonRetryable(`Job ${input.jobId} has no required runner labels`, 'EmptyRequiredLabelsError');
|
|
81
|
+
}
|
|
82
|
+
const { newVersion: runningVersion, status } = await setJobExecutionStatus({
|
|
83
|
+
jobExecutionId: input.jobExecutionId,
|
|
84
|
+
status: 'running',
|
|
85
|
+
version: input.executionVersion
|
|
86
|
+
});
|
|
87
|
+
const start = jobExecutionStartOutcome({
|
|
88
|
+
newVersion: runningVersion,
|
|
89
|
+
status
|
|
90
|
+
});
|
|
91
|
+
if (start.kind === 'terminal') return start;
|
|
92
|
+
await enqueueJobExecutionForRunner({
|
|
93
|
+
workspaceId: input.workspaceId,
|
|
94
|
+
workflowRunId: input.workflowRunId,
|
|
95
|
+
runAttemptId: input.runAttemptId,
|
|
96
|
+
jobId: input.jobId,
|
|
97
|
+
jobExecutionId: input.jobExecutionId,
|
|
98
|
+
projectId: input.projectId,
|
|
99
|
+
requiredLabels: input.requiredLabels
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
kind: 'running',
|
|
103
|
+
runningVersion
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// Both signals can arrive before condition() resumes (independent outboxes, no
|
|
107
|
+
// ordering), so callers must evaluate `finished` before `leaseExpired`.
|
|
108
|
+
async function awaitJobOutcome(jobExecutionId, timeoutMs) {
|
|
109
|
+
let finished;
|
|
110
|
+
let leaseExpired = false;
|
|
111
|
+
setHandler(jobFinishedSignal, (payload)=>{
|
|
112
|
+
if (payload.jobExecutionId !== undefined && payload.jobExecutionId !== jobExecutionId) return;
|
|
113
|
+
finished ??= payload;
|
|
114
|
+
});
|
|
115
|
+
setHandler(jobLeaseExpiredSignal, (payload = {})=>{
|
|
116
|
+
if (payload.jobExecutionId !== undefined && payload.jobExecutionId !== jobExecutionId) return;
|
|
117
|
+
leaseExpired = true;
|
|
118
|
+
});
|
|
119
|
+
await condition(()=>finished !== undefined || leaseExpired, timeoutMs);
|
|
120
|
+
return {
|
|
121
|
+
finished,
|
|
122
|
+
leaseExpired
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async function resolveFinishedJobExecution({ input, runningVersion, status }) {
|
|
126
|
+
await setJobExecutionStatus({
|
|
127
|
+
jobExecutionId: input.jobExecutionId,
|
|
128
|
+
status: jobExecutionStatusForRuntimeStatus(status),
|
|
129
|
+
version: runningVersion,
|
|
130
|
+
statusReason: status === 'failed' ? 'step_failed' : null
|
|
131
|
+
});
|
|
132
|
+
if (input.resolveJobStatus === false) {
|
|
133
|
+
log.info('job execution terminated', {
|
|
134
|
+
jobId: input.jobId,
|
|
135
|
+
jobExecutionId: input.jobExecutionId,
|
|
136
|
+
terminationReason: 'finished',
|
|
137
|
+
status
|
|
138
|
+
});
|
|
139
|
+
await releaseLeaseBestEffort(input.jobExecutionId);
|
|
140
|
+
return {
|
|
141
|
+
status,
|
|
142
|
+
jobVersion: input.jobVersion
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const resolved = await resolveJobStatusOrFailClosed(input);
|
|
146
|
+
log.info('job execution terminated', {
|
|
147
|
+
jobId: input.jobId,
|
|
148
|
+
jobExecutionId: input.jobExecutionId,
|
|
149
|
+
terminationReason: 'finished',
|
|
150
|
+
status: resolved.status
|
|
151
|
+
});
|
|
152
|
+
await releaseLeaseBestEffort(input.jobExecutionId);
|
|
153
|
+
return resolved;
|
|
154
|
+
}
|
|
155
|
+
function jobExecutionStatusForRuntimeStatus(status) {
|
|
156
|
+
if (status === 'succeeded' || status === 'failed' || status === 'cancelled') return status;
|
|
157
|
+
throw ApplicationFailure.nonRetryable(`Job execution cannot be marked ${status}`, 'InvalidJobExecutionStatusError');
|
|
158
|
+
}
|
|
159
|
+
async function resolveLeaseExpiredJobExecution({ input, runningVersion }) {
|
|
160
|
+
const leaseExpired = await resolveLeaseExpiredJobExecutionActivity({
|
|
161
|
+
jobExecutionId: input.jobExecutionId,
|
|
162
|
+
expectedVersion: runningVersion
|
|
163
|
+
});
|
|
164
|
+
if (input.resolveJobStatus === false) {
|
|
165
|
+
log.info('job execution terminated', {
|
|
166
|
+
jobId: input.jobId,
|
|
167
|
+
jobExecutionId: input.jobExecutionId,
|
|
168
|
+
terminationReason: 'lease_expired',
|
|
169
|
+
status: leaseExpired.status
|
|
170
|
+
});
|
|
171
|
+
await releaseLeaseBestEffort(input.jobExecutionId);
|
|
172
|
+
return {
|
|
173
|
+
status: leaseExpired.status,
|
|
174
|
+
jobVersion: input.jobVersion
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const { status, jobVersion } = await resolveJobStatusOrFailClosed(input);
|
|
178
|
+
log.info('job execution terminated', {
|
|
179
|
+
jobId: input.jobId,
|
|
180
|
+
jobExecutionId: input.jobExecutionId,
|
|
181
|
+
terminationReason: 'lease_expired',
|
|
182
|
+
status
|
|
183
|
+
});
|
|
184
|
+
await releaseLeaseBestEffort(input.jobExecutionId);
|
|
185
|
+
return {
|
|
186
|
+
status,
|
|
187
|
+
jobVersion
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// Timeout backstop. The activity atomically fails the execution, marks
|
|
191
|
+
// `timed_out_at`, and enqueues WORKFLOWS_JOB_EXECUTION_TIMED_OUT; the runners subscriber
|
|
192
|
+
// then asks the runner to cancel. The lease is intentionally NOT released here.
|
|
193
|
+
async function resolveTimedOutJobExecution({ input, runningVersion }) {
|
|
194
|
+
await failJobExecutionAsTimedOutActivity({
|
|
195
|
+
jobExecutionId: input.jobExecutionId,
|
|
196
|
+
runAttemptId: input.runAttemptId,
|
|
197
|
+
expectedVersion: runningVersion
|
|
198
|
+
});
|
|
199
|
+
await bulkSetStepStatuses({
|
|
200
|
+
jobExecutionId: input.jobExecutionId,
|
|
201
|
+
status: 'failed'
|
|
202
|
+
});
|
|
203
|
+
if (input.resolveJobStatus === false) {
|
|
204
|
+
log.info('job execution terminated', {
|
|
205
|
+
jobId: input.jobId,
|
|
206
|
+
jobExecutionId: input.jobExecutionId,
|
|
207
|
+
terminationReason: 'max_duration',
|
|
208
|
+
status: 'failed'
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
status: 'failed',
|
|
212
|
+
jobVersion: input.jobVersion
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const { jobVersion } = await resolveJobStatusOrFailClosed(input);
|
|
216
|
+
log.info('job execution terminated', {
|
|
217
|
+
jobId: input.jobId,
|
|
218
|
+
jobExecutionId: input.jobExecutionId,
|
|
219
|
+
terminationReason: 'max_duration',
|
|
220
|
+
status: 'failed'
|
|
221
|
+
});
|
|
222
|
+
return {
|
|
223
|
+
status: 'failed',
|
|
224
|
+
jobVersion
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
export async function jobExecutionOrchestration(input) {
|
|
228
|
+
const running = await markJobExecutionRunningAndEnqueue(input);
|
|
229
|
+
if (running.kind === 'terminal') {
|
|
230
|
+
if (input.resolveJobStatus === false) {
|
|
231
|
+
return {
|
|
232
|
+
status: running.result.status,
|
|
233
|
+
jobVersion: input.jobVersion
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return running.result;
|
|
237
|
+
}
|
|
238
|
+
const { runningVersion } = running;
|
|
239
|
+
const timeoutMs = input.executionTimeoutMs ?? DEFAULT_EXECUTION_MAX_DURATION_MS;
|
|
240
|
+
const signals = await awaitJobOutcome(input.jobExecutionId, timeoutMs);
|
|
241
|
+
// Precedence ladder: a genuinely-finished job is never flipped to failed by a
|
|
242
|
+
// late lease-expiry, so `finished` wins over `leaseExpired`.
|
|
243
|
+
const resolution = resolveJobExecutionOutcomeSignal(signals);
|
|
244
|
+
if (resolution === 'finished') {
|
|
245
|
+
const { finished } = signals;
|
|
246
|
+
if (finished === undefined) throw new Error('Missing finished signal for finished resolution');
|
|
247
|
+
return resolveFinishedJobExecution({
|
|
248
|
+
input,
|
|
249
|
+
runningVersion,
|
|
250
|
+
status: finished.status
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
if (resolution === 'lease-expired') {
|
|
254
|
+
return resolveLeaseExpiredJobExecution({
|
|
255
|
+
input,
|
|
256
|
+
runningVersion
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return resolveTimedOutJobExecution({
|
|
260
|
+
input,
|
|
261
|
+
runningVersion
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
//# sourceMappingURL=job-execution-orchestration.js.map
|