@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,50 @@
|
|
|
1
|
+
import { requireLeasedJobContext } from '@shipfox/api-auth-context';
|
|
2
|
+
import { isJobLeaseActive } from '@shipfox/api-runners';
|
|
3
|
+
import { ClientError } from '@shipfox/node-fastify';
|
|
4
|
+
import { getJobScope, getStepByIdForJobExecution } from '#db/index.js';
|
|
5
|
+
export async function loadRunningLeasedStep(params) {
|
|
6
|
+
const leasedJob = requireLeasedJobContext(params.request);
|
|
7
|
+
const leaseIsActive = await isJobLeaseActive({
|
|
8
|
+
jobId: leasedJob.jobId,
|
|
9
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
10
|
+
runnerSessionId: leasedJob.runnerSessionId
|
|
11
|
+
});
|
|
12
|
+
if (!leaseIsActive) {
|
|
13
|
+
throw new ClientError('Job lease is no longer active', 'lease-not-active', {
|
|
14
|
+
status: 404
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const step = await getStepByIdForJobExecution({
|
|
18
|
+
stepId: params.stepId,
|
|
19
|
+
jobExecutionId: leasedJob.jobExecutionId
|
|
20
|
+
});
|
|
21
|
+
if (!step) {
|
|
22
|
+
throw new ClientError('Step not found for leased job', 'step-not-found', {
|
|
23
|
+
status: 404
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const scope = await getJobScope(leasedJob.jobId);
|
|
27
|
+
if (!scope) {
|
|
28
|
+
throw new ClientError('Leased job not found', 'job-not-found', {
|
|
29
|
+
status: 404
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (step.currentAttempt !== params.attempt) {
|
|
33
|
+
throw new ClientError('Step attempt does not match current attempt', 'step-attempt-mismatch', {
|
|
34
|
+
status: 409
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (step.status !== 'running') {
|
|
38
|
+
throw new ClientError('Step is not running', 'step-not-running', {
|
|
39
|
+
status: 409
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
leasedJob,
|
|
44
|
+
step,
|
|
45
|
+
workspaceId: scope.workspaceId,
|
|
46
|
+
projectId: scope.projectId
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=leased-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/leased-step.ts"],"sourcesContent":["import {type LeasedJobContext, requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport {isJobLeaseActive} from '@shipfox/api-runners';\nimport {ClientError} from '@shipfox/node-fastify';\nimport type {Step} from '#core/entities/step.js';\nimport {getJobScope, getStepByIdForJobExecution} from '#db/index.js';\n\nexport interface LoadedRunningLeasedStep {\n leasedJob: LeasedJobContext;\n step: Step;\n workspaceId: string;\n projectId: string;\n}\n\nexport async function loadRunningLeasedStep(params: {\n request: object;\n stepId: string;\n attempt: number;\n}): Promise<LoadedRunningLeasedStep> {\n const leasedJob = requireLeasedJobContext(params.request);\n\n const leaseIsActive = await isJobLeaseActive({\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n runnerSessionId: leasedJob.runnerSessionId,\n });\n if (!leaseIsActive) {\n throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});\n }\n\n const step = await getStepByIdForJobExecution({\n stepId: params.stepId,\n jobExecutionId: leasedJob.jobExecutionId,\n });\n if (!step) {\n throw new ClientError('Step not found for leased job', 'step-not-found', {status: 404});\n }\n\n const scope = await getJobScope(leasedJob.jobId);\n if (!scope) {\n throw new ClientError('Leased job not found', 'job-not-found', {status: 404});\n }\n\n if (step.currentAttempt !== params.attempt) {\n throw new ClientError('Step attempt does not match current attempt', 'step-attempt-mismatch', {\n status: 409,\n });\n }\n\n if (step.status !== 'running') {\n throw new ClientError('Step is not running', 'step-not-running', {status: 409});\n }\n\n return {leasedJob, step, workspaceId: scope.workspaceId, projectId: scope.projectId};\n}\n"],"names":["requireLeasedJobContext","isJobLeaseActive","ClientError","getJobScope","getStepByIdForJobExecution","loadRunningLeasedStep","params","leasedJob","request","leaseIsActive","jobId","jobExecutionId","runnerSessionId","status","step","stepId","scope","currentAttempt","attempt","workspaceId","projectId"],"mappings":"AAAA,SAA+BA,uBAAuB,QAAO,4BAA4B;AACzF,SAAQC,gBAAgB,QAAO,uBAAuB;AACtD,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,WAAW,EAAEC,0BAA0B,QAAO,eAAe;AASrE,OAAO,eAAeC,sBAAsBC,MAI3C;IACC,MAAMC,YAAYP,wBAAwBM,OAAOE,OAAO;IAExD,MAAMC,gBAAgB,MAAMR,iBAAiB;QAC3CS,OAAOH,UAAUG,KAAK;QACtBC,gBAAgBJ,UAAUI,cAAc;QACxCC,iBAAiBL,UAAUK,eAAe;IAC5C;IACA,IAAI,CAACH,eAAe;QAClB,MAAM,IAAIP,YAAY,iCAAiC,oBAAoB;YAACW,QAAQ;QAAG;IACzF;IAEA,MAAMC,OAAO,MAAMV,2BAA2B;QAC5CW,QAAQT,OAAOS,MAAM;QACrBJ,gBAAgBJ,UAAUI,cAAc;IAC1C;IACA,IAAI,CAACG,MAAM;QACT,MAAM,IAAIZ,YAAY,iCAAiC,kBAAkB;YAACW,QAAQ;QAAG;IACvF;IAEA,MAAMG,QAAQ,MAAMb,YAAYI,UAAUG,KAAK;IAC/C,IAAI,CAACM,OAAO;QACV,MAAM,IAAId,YAAY,wBAAwB,iBAAiB;YAACW,QAAQ;QAAG;IAC7E;IAEA,IAAIC,KAAKG,cAAc,KAAKX,OAAOY,OAAO,EAAE;QAC1C,MAAM,IAAIhB,YAAY,+CAA+C,yBAAyB;YAC5FW,QAAQ;QACV;IACF;IAEA,IAAIC,KAAKD,MAAM,KAAK,WAAW;QAC7B,MAAM,IAAIX,YAAY,uBAAuB,oBAAoB;YAACW,QAAQ;QAAG;IAC/E;IAEA,OAAO;QAACN;QAAWO;QAAMK,aAAaH,MAAMG,WAAW;QAAEC,WAAWJ,MAAMI,SAAS;IAAA;AACrF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-run-attempts.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-run-attempts.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,oBAAoB,iDAmB/B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { workflowRunAttemptsResponseSchema } from '@shipfox/api-workflows-dto';
|
|
2
|
+
import { defineRoute } from '@shipfox/node-fastify';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { listRunAttempts } from '#db/index.js';
|
|
5
|
+
import { toRunAttemptDto } from '#presentation/dto/index.js';
|
|
6
|
+
import { requireAccessibleRun } from './require-accessible-run.js';
|
|
7
|
+
export const listRunAttemptsRoute = defineRoute({
|
|
8
|
+
method: 'GET',
|
|
9
|
+
path: '/:id/attempts',
|
|
10
|
+
description: 'List attempts in a workflow run lineage',
|
|
11
|
+
schema: {
|
|
12
|
+
params: z.object({
|
|
13
|
+
id: z.string().uuid()
|
|
14
|
+
}),
|
|
15
|
+
response: {
|
|
16
|
+
200: workflowRunAttemptsResponseSchema
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
handler: async (request)=>{
|
|
20
|
+
const { id } = request.params;
|
|
21
|
+
const run = await requireAccessibleRun({
|
|
22
|
+
request,
|
|
23
|
+
id
|
|
24
|
+
});
|
|
25
|
+
const attempts = await listRunAttempts({
|
|
26
|
+
workflowRunId: run.id,
|
|
27
|
+
projectId: run.projectId
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
attempts: attempts.map(toRunAttemptDto)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=list-run-attempts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-run-attempts.ts"],"sourcesContent":["import {workflowRunAttemptsResponseSchema} from '@shipfox/api-workflows-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {listRunAttempts} from '#db/index.js';\nimport {toRunAttemptDto} from '#presentation/dto/index.js';\nimport {requireAccessibleRun} from './require-accessible-run.js';\n\nexport const listRunAttemptsRoute = defineRoute({\n method: 'GET',\n path: '/:id/attempts',\n description: 'List attempts in a workflow run lineage',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n response: {\n 200: workflowRunAttemptsResponseSchema,\n },\n },\n handler: async (request) => {\n const {id} = request.params;\n const run = await requireAccessibleRun({request, id});\n const attempts = await listRunAttempts({workflowRunId: run.id, projectId: run.projectId});\n\n return {attempts: attempts.map(toRunAttemptDto)};\n },\n});\n"],"names":["workflowRunAttemptsResponseSchema","defineRoute","z","listRunAttempts","toRunAttemptDto","requireAccessibleRun","listRunAttemptsRoute","method","path","description","schema","params","object","id","string","uuid","response","handler","request","run","attempts","workflowRunId","projectId","map"],"mappings":"AAAA,SAAQA,iCAAiC,QAAO,6BAA6B;AAC7E,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,eAAe,QAAO,eAAe;AAC7C,SAAQC,eAAe,QAAO,6BAA6B;AAC3D,SAAQC,oBAAoB,QAAO,8BAA8B;AAEjE,OAAO,MAAMC,uBAAuBL,YAAY;IAC9CM,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQT,EAAEU,MAAM,CAAC;YACfC,IAAIX,EAAEY,MAAM,GAAGC,IAAI;QACrB;QACAC,UAAU;YACR,KAAKhB;QACP;IACF;IACAiB,SAAS,OAAOC;QACd,MAAM,EAACL,EAAE,EAAC,GAAGK,QAAQP,MAAM;QAC3B,MAAMQ,MAAM,MAAMd,qBAAqB;YAACa;YAASL;QAAE;QACnD,MAAMO,WAAW,MAAMjB,gBAAgB;YAACkB,eAAeF,IAAIN,EAAE;YAAES,WAAWH,IAAIG,SAAS;QAAA;QAEvF,OAAO;YAACF,UAAUA,SAASG,GAAG,CAACnB;QAAgB;IACjD;AACF,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-runs.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-runs.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa,iDAuExB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ProjectNotFoundError, requireProjectAccess } from '@shipfox/api-projects';
|
|
2
|
+
import { workflowRunListQuerySchema, workflowRunListResponseSchema } from '@shipfox/api-workflows-dto';
|
|
3
|
+
import { decodeTimestampIdCursor, encodeTimestampIdCursor } from '@shipfox/node-drizzle';
|
|
4
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
|
+
import { logger } from '@shipfox/node-opentelemetry';
|
|
6
|
+
import { listWorkflowRuns } from '#db/index.js';
|
|
7
|
+
import { toRunDto } from '#presentation/dto/index.js';
|
|
8
|
+
export const listRunsRoute = defineRoute({
|
|
9
|
+
method: 'GET',
|
|
10
|
+
path: '/',
|
|
11
|
+
description: 'List workflow runs for a project',
|
|
12
|
+
schema: {
|
|
13
|
+
querystring: workflowRunListQuerySchema,
|
|
14
|
+
response: {
|
|
15
|
+
200: workflowRunListResponseSchema
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
errorHandler: (error)=>{
|
|
19
|
+
if (error instanceof ProjectNotFoundError) {
|
|
20
|
+
throw new ClientError(error.message, 'project-not-found', {
|
|
21
|
+
status: 404
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
},
|
|
26
|
+
handler: async (request)=>{
|
|
27
|
+
const startedAt = performance.now();
|
|
28
|
+
const { project_id: projectId, limit, cursor, status, definition_id: definitionId, trigger_source: triggerSource, created_from: createdFrom, created_to: createdTo } = request.query;
|
|
29
|
+
const decodedCursor = decodeTimestampIdCursor(cursor);
|
|
30
|
+
if (cursor && !decodedCursor) {
|
|
31
|
+
throw new ClientError('Invalid cursor', 'invalid-cursor', {
|
|
32
|
+
status: 400
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const { project } = await requireProjectAccess({
|
|
36
|
+
request,
|
|
37
|
+
projectId
|
|
38
|
+
});
|
|
39
|
+
const filters = {
|
|
40
|
+
status,
|
|
41
|
+
definitionId,
|
|
42
|
+
triggerSource,
|
|
43
|
+
createdFrom: createdFrom ? new Date(createdFrom) : undefined,
|
|
44
|
+
createdTo: createdTo ? new Date(createdTo) : undefined
|
|
45
|
+
};
|
|
46
|
+
const result = await listWorkflowRuns({
|
|
47
|
+
projectId: project.id,
|
|
48
|
+
limit,
|
|
49
|
+
cursor: decodedCursor,
|
|
50
|
+
filters,
|
|
51
|
+
includeTotal: !decodedCursor
|
|
52
|
+
});
|
|
53
|
+
logger().info({
|
|
54
|
+
projectId: project.id,
|
|
55
|
+
filterKeys: Object.entries(filters).filter(([, value])=>value !== undefined).map(([key])=>key),
|
|
56
|
+
limit,
|
|
57
|
+
cursorPresent: Boolean(cursor),
|
|
58
|
+
resultCount: result.runs.length,
|
|
59
|
+
nextCursorPresent: Boolean(result.nextCursor),
|
|
60
|
+
durationMs: Math.round(performance.now() - startedAt)
|
|
61
|
+
}, 'Listed workflow runs');
|
|
62
|
+
return {
|
|
63
|
+
runs: result.runs.map((run)=>toRunDto(run)),
|
|
64
|
+
next_cursor: result.nextCursor ? encodeTimestampIdCursor(result.nextCursor) : null,
|
|
65
|
+
filtered_total_count: result.filteredTotalCount
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=list-runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-runs.ts"],"sourcesContent":["import {ProjectNotFoundError, requireProjectAccess} from '@shipfox/api-projects';\nimport {\n workflowRunListQuerySchema,\n workflowRunListResponseSchema,\n} from '@shipfox/api-workflows-dto';\nimport {decodeTimestampIdCursor, encodeTimestampIdCursor} from '@shipfox/node-drizzle';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {listWorkflowRuns} from '#db/index.js';\nimport {toRunDto} from '#presentation/dto/index.js';\n\nexport const listRunsRoute = defineRoute({\n method: 'GET',\n path: '/',\n description: 'List workflow runs for a project',\n schema: {\n querystring: workflowRunListQuerySchema,\n response: {\n 200: workflowRunListResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof ProjectNotFoundError) {\n throw new ClientError(error.message, 'project-not-found', {status: 404});\n }\n throw error;\n },\n handler: async (request) => {\n const startedAt = performance.now();\n const {\n project_id: projectId,\n limit,\n cursor,\n status,\n definition_id: definitionId,\n trigger_source: triggerSource,\n created_from: createdFrom,\n created_to: createdTo,\n } = request.query;\n const decodedCursor = decodeTimestampIdCursor(cursor);\n if (cursor && !decodedCursor) {\n throw new ClientError('Invalid cursor', 'invalid-cursor', {status: 400});\n }\n\n const {project} = await requireProjectAccess({request, projectId});\n\n const filters = {\n status,\n definitionId,\n triggerSource,\n createdFrom: createdFrom ? new Date(createdFrom) : undefined,\n createdTo: createdTo ? new Date(createdTo) : undefined,\n };\n const result = await listWorkflowRuns({\n projectId: project.id,\n limit,\n cursor: decodedCursor,\n filters,\n includeTotal: !decodedCursor,\n });\n\n logger().info(\n {\n projectId: project.id,\n filterKeys: Object.entries(filters)\n .filter(([, value]) => value !== undefined)\n .map(([key]) => key),\n limit,\n cursorPresent: Boolean(cursor),\n resultCount: result.runs.length,\n nextCursorPresent: Boolean(result.nextCursor),\n durationMs: Math.round(performance.now() - startedAt),\n },\n 'Listed workflow runs',\n );\n\n return {\n runs: result.runs.map((run) => toRunDto(run)),\n next_cursor: result.nextCursor ? encodeTimestampIdCursor(result.nextCursor) : null,\n filtered_total_count: result.filteredTotalCount,\n };\n },\n});\n"],"names":["ProjectNotFoundError","requireProjectAccess","workflowRunListQuerySchema","workflowRunListResponseSchema","decodeTimestampIdCursor","encodeTimestampIdCursor","ClientError","defineRoute","logger","listWorkflowRuns","toRunDto","listRunsRoute","method","path","description","schema","querystring","response","errorHandler","error","message","status","handler","request","startedAt","performance","now","project_id","projectId","limit","cursor","definition_id","definitionId","trigger_source","triggerSource","created_from","createdFrom","created_to","createdTo","query","decodedCursor","project","filters","Date","undefined","result","id","includeTotal","info","filterKeys","Object","entries","filter","value","map","key","cursorPresent","Boolean","resultCount","runs","length","nextCursorPresent","nextCursor","durationMs","Math","round","run","next_cursor","filtered_total_count","filteredTotalCount"],"mappings":"AAAA,SAAQA,oBAAoB,EAAEC,oBAAoB,QAAO,wBAAwB;AACjF,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,6BAA6B;AACpC,SAAQC,uBAAuB,EAAEC,uBAAuB,QAAO,wBAAwB;AACvF,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,gBAAgB,QAAO,eAAe;AAC9C,SAAQC,QAAQ,QAAO,6BAA6B;AAEpD,OAAO,MAAMC,gBAAgBJ,YAAY;IACvCK,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,aAAad;QACbe,UAAU;YACR,KAAKd;QACP;IACF;IACAe,cAAc,CAACC;QACb,IAAIA,iBAAiBnB,sBAAsB;YACzC,MAAM,IAAIM,YAAYa,MAAMC,OAAO,EAAE,qBAAqB;gBAACC,QAAQ;YAAG;QACxE;QACA,MAAMF;IACR;IACAG,SAAS,OAAOC;QACd,MAAMC,YAAYC,YAAYC,GAAG;QACjC,MAAM,EACJC,YAAYC,SAAS,EACrBC,KAAK,EACLC,MAAM,EACNT,MAAM,EACNU,eAAeC,YAAY,EAC3BC,gBAAgBC,aAAa,EAC7BC,cAAcC,WAAW,EACzBC,YAAYC,SAAS,EACtB,GAAGf,QAAQgB,KAAK;QACjB,MAAMC,gBAAgBpC,wBAAwB0B;QAC9C,IAAIA,UAAU,CAACU,eAAe;YAC5B,MAAM,IAAIlC,YAAY,kBAAkB,kBAAkB;gBAACe,QAAQ;YAAG;QACxE;QAEA,MAAM,EAACoB,OAAO,EAAC,GAAG,MAAMxC,qBAAqB;YAACsB;YAASK;QAAS;QAEhE,MAAMc,UAAU;YACdrB;YACAW;YACAE;YACAE,aAAaA,cAAc,IAAIO,KAAKP,eAAeQ;YACnDN,WAAWA,YAAY,IAAIK,KAAKL,aAAaM;QAC/C;QACA,MAAMC,SAAS,MAAMpC,iBAAiB;YACpCmB,WAAWa,QAAQK,EAAE;YACrBjB;YACAC,QAAQU;YACRE;YACAK,cAAc,CAACP;QACjB;QAEAhC,SAASwC,IAAI,CACX;YACEpB,WAAWa,QAAQK,EAAE;YACrBG,YAAYC,OAAOC,OAAO,CAACT,SACxBU,MAAM,CAAC,CAAC,GAAGC,MAAM,GAAKA,UAAUT,WAChCU,GAAG,CAAC,CAAC,CAACC,IAAI,GAAKA;YAClB1B;YACA2B,eAAeC,QAAQ3B;YACvB4B,aAAab,OAAOc,IAAI,CAACC,MAAM;YAC/BC,mBAAmBJ,QAAQZ,OAAOiB,UAAU;YAC5CC,YAAYC,KAAKC,KAAK,CAACxC,YAAYC,GAAG,KAAKF;QAC7C,GACA;QAGF,OAAO;YACLmC,MAAMd,OAAOc,IAAI,CAACL,GAAG,CAAC,CAACY,MAAQxD,SAASwD;YACxCC,aAAatB,OAAOiB,UAAU,GAAGzD,wBAAwBwC,OAAOiB,UAAU,IAAI;YAC9EM,sBAAsBvB,OAAOwB,kBAAkB;QACjD;IACF;AACF,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/next-step.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,aAAa,iDAoDxB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { issueJobLeaseToken, jobLeaseParamsFrom } from '@shipfox/api-auth';
|
|
2
|
+
import { requireLeasedJobContext } from '@shipfox/api-auth-context';
|
|
3
|
+
import { nextStepResponseSchema } from '@shipfox/api-workflows-dto';
|
|
4
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
|
+
import { warnAgentToolCapabilityMismatchOnDispatch } from '#core/agent-tool-capability-warning.js';
|
|
6
|
+
import { JobLeaseNotActiveError, JobNotFoundError } from '#core/errors.js';
|
|
7
|
+
import { nextStepForLeasedJobExecution } from '#core/job-execution.js';
|
|
8
|
+
import { toStepDto } from '#presentation/dto/step.js';
|
|
9
|
+
export const nextStepRoute = defineRoute({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/steps/next',
|
|
12
|
+
description: 'Returns the next step for the runner to run on its job. The job is identified by the access token, so no job ID is needed. Calling this again before reporting the current step returns that same step, so retries are safe. When no runnable steps remain, the response reports that there are no more steps to run, along with the job status; the runner then stops. Finalization is driven server-side from recorded step results and dispatch-time skips, not by the runner calling a job-completion endpoint.',
|
|
13
|
+
schema: {
|
|
14
|
+
response: {
|
|
15
|
+
200: nextStepResponseSchema
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
errorHandler: (error)=>{
|
|
19
|
+
if (error instanceof JobNotFoundError) {
|
|
20
|
+
throw new ClientError(error.message, 'job-not-found', {
|
|
21
|
+
status: 404
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (error instanceof JobLeaseNotActiveError) {
|
|
25
|
+
throw new ClientError('Job lease is no longer active', 'lease-not-active', {
|
|
26
|
+
status: 404
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
},
|
|
31
|
+
handler: async (request)=>{
|
|
32
|
+
const leasedJob = requireLeasedJobContext(request);
|
|
33
|
+
const next = await nextStepForLeasedJobExecution({
|
|
34
|
+
jobId: leasedJob.jobId,
|
|
35
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
36
|
+
runnerSessionId: leasedJob.runnerSessionId
|
|
37
|
+
});
|
|
38
|
+
if (next.kind === 'step') {
|
|
39
|
+
const leaseToken = await issueJobLeaseToken(jobLeaseParamsFrom(leasedJob, {
|
|
40
|
+
currentStepId: next.step.id,
|
|
41
|
+
currentStepAttempt: next.step.currentAttempt
|
|
42
|
+
}));
|
|
43
|
+
if (next.dispatched) {
|
|
44
|
+
await warnAgentToolCapabilityMismatchOnDispatch({
|
|
45
|
+
leaseIdentity: leasedJob,
|
|
46
|
+
step: next.step
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// The runner echoes this back on report so a stale report from a superseded
|
|
50
|
+
// attempt is ignored.
|
|
51
|
+
return {
|
|
52
|
+
kind: 'step',
|
|
53
|
+
step: toStepDto(next.step),
|
|
54
|
+
attempt: next.step.currentAttempt,
|
|
55
|
+
lease_token: leaseToken
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
kind: 'done',
|
|
60
|
+
status: next.status
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=next-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/next-step.ts"],"sourcesContent":["import {issueJobLeaseToken, jobLeaseParamsFrom} from '@shipfox/api-auth';\nimport {requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport {nextStepResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {warnAgentToolCapabilityMismatchOnDispatch} from '#core/agent-tool-capability-warning.js';\nimport {JobLeaseNotActiveError, JobNotFoundError} from '#core/errors.js';\nimport {nextStepForLeasedJobExecution} from '#core/job-execution.js';\nimport {toStepDto} from '#presentation/dto/step.js';\n\nexport const nextStepRoute = defineRoute({\n method: 'POST',\n path: '/steps/next',\n description:\n 'Returns the next step for the runner to run on its job. The job is identified by the access token, so no job ID is needed. Calling this again before reporting the current step returns that same step, so retries are safe. When no runnable steps remain, the response reports that there are no more steps to run, along with the job status; the runner then stops. Finalization is driven server-side from recorded step results and dispatch-time skips, not by the runner calling a job-completion endpoint.',\n schema: {\n response: {\n 200: nextStepResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof JobNotFoundError) {\n throw new ClientError(error.message, 'job-not-found', {status: 404});\n }\n if (error instanceof JobLeaseNotActiveError) {\n throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});\n }\n throw error;\n },\n handler: async (request) => {\n const leasedJob = requireLeasedJobContext(request);\n\n const next = await nextStepForLeasedJobExecution({\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n runnerSessionId: leasedJob.runnerSessionId,\n });\n\n if (next.kind === 'step') {\n const leaseToken = await issueJobLeaseToken(\n jobLeaseParamsFrom(leasedJob, {\n currentStepId: next.step.id,\n currentStepAttempt: next.step.currentAttempt,\n }),\n );\n if (next.dispatched) {\n await warnAgentToolCapabilityMismatchOnDispatch({\n leaseIdentity: leasedJob,\n step: next.step,\n });\n }\n // The runner echoes this back on report so a stale report from a superseded\n // attempt is ignored.\n return {\n kind: 'step' as const,\n step: toStepDto(next.step),\n attempt: next.step.currentAttempt,\n lease_token: leaseToken,\n };\n }\n return {kind: 'done' as const, status: next.status};\n },\n});\n"],"names":["issueJobLeaseToken","jobLeaseParamsFrom","requireLeasedJobContext","nextStepResponseSchema","ClientError","defineRoute","warnAgentToolCapabilityMismatchOnDispatch","JobLeaseNotActiveError","JobNotFoundError","nextStepForLeasedJobExecution","toStepDto","nextStepRoute","method","path","description","schema","response","errorHandler","error","message","status","handler","request","leasedJob","next","jobId","jobExecutionId","runnerSessionId","kind","leaseToken","currentStepId","step","id","currentStepAttempt","currentAttempt","dispatched","leaseIdentity","attempt","lease_token"],"mappings":"AAAA,SAAQA,kBAAkB,EAAEC,kBAAkB,QAAO,oBAAoB;AACzE,SAAQC,uBAAuB,QAAO,4BAA4B;AAClE,SAAQC,sBAAsB,QAAO,6BAA6B;AAClE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,yCAAyC,QAAO,yCAAyC;AACjG,SAAQC,sBAAsB,EAAEC,gBAAgB,QAAO,kBAAkB;AACzE,SAAQC,6BAA6B,QAAO,yBAAyB;AACrE,SAAQC,SAAS,QAAO,4BAA4B;AAEpD,OAAO,MAAMC,gBAAgBN,YAAY;IACvCO,QAAQ;IACRC,MAAM;IACNC,aACE;IACFC,QAAQ;QACNC,UAAU;YACR,KAAKb;QACP;IACF;IACAc,cAAc,CAACC;QACb,IAAIA,iBAAiBV,kBAAkB;YACrC,MAAM,IAAIJ,YAAYc,MAAMC,OAAO,EAAE,iBAAiB;gBAACC,QAAQ;YAAG;QACpE;QACA,IAAIF,iBAAiBX,wBAAwB;YAC3C,MAAM,IAAIH,YAAY,iCAAiC,oBAAoB;gBAACgB,QAAQ;YAAG;QACzF;QACA,MAAMF;IACR;IACAG,SAAS,OAAOC;QACd,MAAMC,YAAYrB,wBAAwBoB;QAE1C,MAAME,OAAO,MAAMf,8BAA8B;YAC/CgB,OAAOF,UAAUE,KAAK;YACtBC,gBAAgBH,UAAUG,cAAc;YACxCC,iBAAiBJ,UAAUI,eAAe;QAC5C;QAEA,IAAIH,KAAKI,IAAI,KAAK,QAAQ;YACxB,MAAMC,aAAa,MAAM7B,mBACvBC,mBAAmBsB,WAAW;gBAC5BO,eAAeN,KAAKO,IAAI,CAACC,EAAE;gBAC3BC,oBAAoBT,KAAKO,IAAI,CAACG,cAAc;YAC9C;YAEF,IAAIV,KAAKW,UAAU,EAAE;gBACnB,MAAM7B,0CAA0C;oBAC9C8B,eAAeb;oBACfQ,MAAMP,KAAKO,IAAI;gBACjB;YACF;YACA,4EAA4E;YAC5E,sBAAsB;YACtB,OAAO;gBACLH,MAAM;gBACNG,MAAMrB,UAAUc,KAAKO,IAAI;gBACzBM,SAASb,KAAKO,IAAI,CAACG,cAAc;gBACjCI,aAAaT;YACf;QACF;QACA,OAAO;YAACD,MAAM;YAAiBR,QAAQI,KAAKJ,MAAM;QAAA;IACpD;AACF,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/report-step.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,eAAe,iDAmD1B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { requireLeasedJobContext } from '@shipfox/api-auth-context';
|
|
2
|
+
import { isJobLeaseActive } from '@shipfox/api-runners';
|
|
3
|
+
import { reportStepBodySchema, reportStepResponseSchema } from '@shipfox/api-workflows-dto';
|
|
4
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { StepAttemptAheadError, StepNotFoundError, StepNotRunningError } from '#core/errors.js';
|
|
7
|
+
import { recordStepResult } from '#core/job-execution.js';
|
|
8
|
+
import { fromStepErrorDto } from '#presentation/dto/step.js';
|
|
9
|
+
export const reportStepRoute = defineRoute({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/steps/:stepId/report',
|
|
12
|
+
description: 'Reports whether a step succeeded or failed. The job is identified by the access token. Reporting the same step more than once is safe: once a step has finished, later reports for it are ignored. The runner does not call a separate job-completion endpoint — finalization is driven server-side from the recorded step results, and the `cancel` flag tells the runner to stop once the job has finished without full success.',
|
|
13
|
+
schema: {
|
|
14
|
+
params: z.object({
|
|
15
|
+
stepId: z.string().uuid()
|
|
16
|
+
}),
|
|
17
|
+
body: reportStepBodySchema,
|
|
18
|
+
response: {
|
|
19
|
+
200: reportStepResponseSchema
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
errorHandler: (error)=>{
|
|
23
|
+
if (error instanceof StepNotFoundError) {
|
|
24
|
+
throw new ClientError(error.message, 'step-not-found', {
|
|
25
|
+
status: 404
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (error instanceof StepNotRunningError) {
|
|
29
|
+
throw new ClientError(error.message, 'step-not-running', {
|
|
30
|
+
status: 409
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (error instanceof StepAttemptAheadError) {
|
|
34
|
+
throw new ClientError(error.message, 'step-attempt-ahead', {
|
|
35
|
+
status: 409
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
},
|
|
40
|
+
handler: async (request)=>{
|
|
41
|
+
const { stepId } = request.params;
|
|
42
|
+
const leasedJob = requireLeasedJobContext(request);
|
|
43
|
+
const leaseIsActive = await isJobLeaseActive({
|
|
44
|
+
jobId: leasedJob.jobId,
|
|
45
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
46
|
+
runnerSessionId: leasedJob.runnerSessionId
|
|
47
|
+
});
|
|
48
|
+
if (!leaseIsActive) {
|
|
49
|
+
throw new ClientError('Job lease is no longer active', 'lease-not-active', {
|
|
50
|
+
status: 404
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const outcome = await recordStepResult({
|
|
54
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
55
|
+
stepId,
|
|
56
|
+
status: request.body.status,
|
|
57
|
+
error: fromStepErrorDto(request.body.error),
|
|
58
|
+
output: request.body.output ?? null,
|
|
59
|
+
response: request.body.response ?? null,
|
|
60
|
+
exitCode: request.body.exit_code ?? request.body.error?.exit_code ?? null,
|
|
61
|
+
logOutcome: request.body.log_outcome,
|
|
62
|
+
...request.body.attempt !== undefined ? {
|
|
63
|
+
attempt: request.body.attempt
|
|
64
|
+
} : {}
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
ok: true,
|
|
68
|
+
cancel: outcome.jobFinished && outcome.status === 'failed'
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=report-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/report-step.ts"],"sourcesContent":["import {requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport {isJobLeaseActive} from '@shipfox/api-runners';\nimport {reportStepBodySchema, reportStepResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {StepAttemptAheadError, StepNotFoundError, StepNotRunningError} from '#core/errors.js';\nimport {recordStepResult} from '#core/job-execution.js';\nimport {fromStepErrorDto} from '#presentation/dto/step.js';\n\nexport const reportStepRoute = defineRoute({\n method: 'POST',\n path: '/steps/:stepId/report',\n description:\n 'Reports whether a step succeeded or failed. The job is identified by the access token. Reporting the same step more than once is safe: once a step has finished, later reports for it are ignored. The runner does not call a separate job-completion endpoint — finalization is driven server-side from the recorded step results, and the `cancel` flag tells the runner to stop once the job has finished without full success.',\n schema: {\n params: z.object({stepId: z.string().uuid()}),\n body: reportStepBodySchema,\n response: {\n 200: reportStepResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof StepNotFoundError) {\n throw new ClientError(error.message, 'step-not-found', {status: 404});\n }\n if (error instanceof StepNotRunningError) {\n throw new ClientError(error.message, 'step-not-running', {status: 409});\n }\n if (error instanceof StepAttemptAheadError) {\n throw new ClientError(error.message, 'step-attempt-ahead', {status: 409});\n }\n throw error;\n },\n handler: async (request) => {\n const {stepId} = request.params;\n const leasedJob = requireLeasedJobContext(request);\n\n const leaseIsActive = await isJobLeaseActive({\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n runnerSessionId: leasedJob.runnerSessionId,\n });\n if (!leaseIsActive) {\n throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});\n }\n\n const outcome = await recordStepResult({\n jobExecutionId: leasedJob.jobExecutionId,\n stepId,\n status: request.body.status,\n error: fromStepErrorDto(request.body.error),\n output: request.body.output ?? null,\n response: request.body.response ?? null,\n exitCode: request.body.exit_code ?? request.body.error?.exit_code ?? null,\n logOutcome: request.body.log_outcome,\n ...(request.body.attempt !== undefined ? {attempt: request.body.attempt} : {}),\n });\n\n return {ok: true, cancel: outcome.jobFinished && outcome.status === 'failed'};\n },\n});\n"],"names":["requireLeasedJobContext","isJobLeaseActive","reportStepBodySchema","reportStepResponseSchema","ClientError","defineRoute","z","StepAttemptAheadError","StepNotFoundError","StepNotRunningError","recordStepResult","fromStepErrorDto","reportStepRoute","method","path","description","schema","params","object","stepId","string","uuid","body","response","errorHandler","error","message","status","handler","request","leasedJob","leaseIsActive","jobId","jobExecutionId","runnerSessionId","outcome","output","exitCode","exit_code","logOutcome","log_outcome","attempt","undefined","ok","cancel","jobFinished"],"mappings":"AAAA,SAAQA,uBAAuB,QAAO,4BAA4B;AAClE,SAAQC,gBAAgB,QAAO,uBAAuB;AACtD,SAAQC,oBAAoB,EAAEC,wBAAwB,QAAO,6BAA6B;AAC1F,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,qBAAqB,EAAEC,iBAAiB,EAAEC,mBAAmB,QAAO,kBAAkB;AAC9F,SAAQC,gBAAgB,QAAO,yBAAyB;AACxD,SAAQC,gBAAgB,QAAO,4BAA4B;AAE3D,OAAO,MAAMC,kBAAkBP,YAAY;IACzCQ,QAAQ;IACRC,MAAM;IACNC,aACE;IACFC,QAAQ;QACNC,QAAQX,EAAEY,MAAM,CAAC;YAACC,QAAQb,EAAEc,MAAM,GAAGC,IAAI;QAAE;QAC3CC,MAAMpB;QACNqB,UAAU;YACR,KAAKpB;QACP;IACF;IACAqB,cAAc,CAACC;QACb,IAAIA,iBAAiBjB,mBAAmB;YACtC,MAAM,IAAIJ,YAAYqB,MAAMC,OAAO,EAAE,kBAAkB;gBAACC,QAAQ;YAAG;QACrE;QACA,IAAIF,iBAAiBhB,qBAAqB;YACxC,MAAM,IAAIL,YAAYqB,MAAMC,OAAO,EAAE,oBAAoB;gBAACC,QAAQ;YAAG;QACvE;QACA,IAAIF,iBAAiBlB,uBAAuB;YAC1C,MAAM,IAAIH,YAAYqB,MAAMC,OAAO,EAAE,sBAAsB;gBAACC,QAAQ;YAAG;QACzE;QACA,MAAMF;IACR;IACAG,SAAS,OAAOC;QACd,MAAM,EAACV,MAAM,EAAC,GAAGU,QAAQZ,MAAM;QAC/B,MAAMa,YAAY9B,wBAAwB6B;QAE1C,MAAME,gBAAgB,MAAM9B,iBAAiB;YAC3C+B,OAAOF,UAAUE,KAAK;YACtBC,gBAAgBH,UAAUG,cAAc;YACxCC,iBAAiBJ,UAAUI,eAAe;QAC5C;QACA,IAAI,CAACH,eAAe;YAClB,MAAM,IAAI3B,YAAY,iCAAiC,oBAAoB;gBAACuB,QAAQ;YAAG;QACzF;QAEA,MAAMQ,UAAU,MAAMzB,iBAAiB;YACrCuB,gBAAgBH,UAAUG,cAAc;YACxCd;YACAQ,QAAQE,QAAQP,IAAI,CAACK,MAAM;YAC3BF,OAAOd,iBAAiBkB,QAAQP,IAAI,CAACG,KAAK;YAC1CW,QAAQP,QAAQP,IAAI,CAACc,MAAM,IAAI;YAC/Bb,UAAUM,QAAQP,IAAI,CAACC,QAAQ,IAAI;YACnCc,UAAUR,QAAQP,IAAI,CAACgB,SAAS,IAAIT,QAAQP,IAAI,CAACG,KAAK,EAAEa,aAAa;YACrEC,YAAYV,QAAQP,IAAI,CAACkB,WAAW;YACpC,GAAIX,QAAQP,IAAI,CAACmB,OAAO,KAAKC,YAAY;gBAACD,SAASZ,QAAQP,IAAI,CAACmB,OAAO;YAAA,IAAI,CAAC,CAAC;QAC/E;QAEA,OAAO;YAACE,IAAI;YAAMC,QAAQT,QAAQU,WAAW,IAAIV,QAAQR,MAAM,KAAK;QAAQ;IAC9E;AACF,GAAG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FastifyRequest } from 'fastify';
|
|
2
|
+
import type { WorkflowRun } from '#core/entities/workflow-run.js';
|
|
3
|
+
export declare function requireAccessibleRun({ request, id, }: {
|
|
4
|
+
request: FastifyRequest;
|
|
5
|
+
id: string;
|
|
6
|
+
}): Promise<WorkflowRun>;
|
|
7
|
+
//# sourceMappingURL=require-accessible-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-accessible-run.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/require-accessible-run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAGhE,wBAAsB,oBAAoB,CAAC,EACzC,OAAO,EACP,EAAE,GACH,EAAE;IACD,OAAO,EAAE,cAAc,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,WAAW,CAAC,CAcvB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { requireProjectAccess } from '@shipfox/api-projects';
|
|
2
|
+
import { ClientError } from '@shipfox/node-fastify';
|
|
3
|
+
import { getWorkflowRunById } from '#db/index.js';
|
|
4
|
+
export async function requireAccessibleRun({ request, id }) {
|
|
5
|
+
const run = await getWorkflowRunById(id);
|
|
6
|
+
if (!run) {
|
|
7
|
+
throw new ClientError('Run not found', 'not-found', {
|
|
8
|
+
status: 404
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
await requireProjectAccess({
|
|
12
|
+
request,
|
|
13
|
+
projectId: run.projectId
|
|
14
|
+
}).catch((err)=>{
|
|
15
|
+
if (err instanceof ClientError && (err.status === 403 || err.status === 404)) {
|
|
16
|
+
throw new ClientError('Run not found', 'not-found', {
|
|
17
|
+
status: 404
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
throw err;
|
|
21
|
+
});
|
|
22
|
+
return run;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=require-accessible-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/require-accessible-run.ts"],"sourcesContent":["import {requireProjectAccess} from '@shipfox/api-projects';\nimport {ClientError} from '@shipfox/node-fastify';\nimport type {FastifyRequest} from 'fastify';\nimport type {WorkflowRun} from '#core/entities/workflow-run.js';\nimport {getWorkflowRunById} from '#db/index.js';\n\nexport async function requireAccessibleRun({\n request,\n id,\n}: {\n request: FastifyRequest;\n id: string;\n}): Promise<WorkflowRun> {\n const run = await getWorkflowRunById(id);\n if (!run) {\n throw new ClientError('Run not found', 'not-found', {status: 404});\n }\n\n await requireProjectAccess({request, projectId: run.projectId}).catch((err: unknown) => {\n if (err instanceof ClientError && (err.status === 403 || err.status === 404)) {\n throw new ClientError('Run not found', 'not-found', {status: 404});\n }\n throw err;\n });\n\n return run;\n}\n"],"names":["requireProjectAccess","ClientError","getWorkflowRunById","requireAccessibleRun","request","id","run","status","projectId","catch","err"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,wBAAwB;AAC3D,SAAQC,WAAW,QAAO,wBAAwB;AAGlD,SAAQC,kBAAkB,QAAO,eAAe;AAEhD,OAAO,eAAeC,qBAAqB,EACzCC,OAAO,EACPC,EAAE,EAIH;IACC,MAAMC,MAAM,MAAMJ,mBAAmBG;IACrC,IAAI,CAACC,KAAK;QACR,MAAM,IAAIL,YAAY,iBAAiB,aAAa;YAACM,QAAQ;QAAG;IAClE;IAEA,MAAMP,qBAAqB;QAACI;QAASI,WAAWF,IAAIE,SAAS;IAAA,GAAGC,KAAK,CAAC,CAACC;QACrE,IAAIA,eAAeT,eAAgBS,CAAAA,IAAIH,MAAM,KAAK,OAAOG,IAAIH,MAAM,KAAK,GAAE,GAAI;YAC5E,MAAM,IAAIN,YAAY,iBAAiB,aAAa;gBAACM,QAAQ;YAAG;QAClE;QACA,MAAMG;IACR;IAEA,OAAOJ;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rerun-run.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/rerun-run.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,aAAa,iDAsCxB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { requireUserContext } from '@shipfox/api-auth-context';
|
|
2
|
+
import { rerunWorkflowRunBodySchema, workflowRunResponseSchema } from '@shipfox/api-workflows-dto';
|
|
3
|
+
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { NoFailedJobsError, RunNotTerminalError, SourceRunNotFoundError } from '#core/errors.js';
|
|
6
|
+
import { createRerunWorkflowRun } from '#db/index.js';
|
|
7
|
+
import { toRunDto } from '#presentation/dto/index.js';
|
|
8
|
+
import { requireAccessibleRun } from './require-accessible-run.js';
|
|
9
|
+
export const rerunRunRoute = defineRoute({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/:id/rerun',
|
|
12
|
+
description: 'Re-run a terminal workflow run',
|
|
13
|
+
schema: {
|
|
14
|
+
params: z.object({
|
|
15
|
+
id: z.string().uuid()
|
|
16
|
+
}),
|
|
17
|
+
body: rerunWorkflowRunBodySchema,
|
|
18
|
+
response: {
|
|
19
|
+
200: workflowRunResponseSchema
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
errorHandler: (error)=>{
|
|
23
|
+
if (error instanceof SourceRunNotFoundError) {
|
|
24
|
+
throw new ClientError('Run not found', 'not-found', {
|
|
25
|
+
status: 404
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (error instanceof RunNotTerminalError) {
|
|
29
|
+
throw new ClientError('Run is not terminal', 'run-not-terminal', {
|
|
30
|
+
status: 409
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (error instanceof NoFailedJobsError) {
|
|
34
|
+
throw new ClientError('Run has no failed jobs', 'no-failed-jobs', {
|
|
35
|
+
status: 409
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
},
|
|
40
|
+
handler: async (request)=>{
|
|
41
|
+
const { id } = request.params;
|
|
42
|
+
const sourceRun = await requireAccessibleRun({
|
|
43
|
+
request,
|
|
44
|
+
id
|
|
45
|
+
});
|
|
46
|
+
const actor = requireUserContext(request);
|
|
47
|
+
const run = await createRerunWorkflowRun({
|
|
48
|
+
workflowRunId: sourceRun.id,
|
|
49
|
+
mode: request.body.mode,
|
|
50
|
+
actorUserId: actor.userId
|
|
51
|
+
});
|
|
52
|
+
return toRunDto(run, run.currentAttempt);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=rerun-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/rerun-run.ts"],"sourcesContent":["import {requireUserContext} from '@shipfox/api-auth-context';\nimport {rerunWorkflowRunBodySchema, workflowRunResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {NoFailedJobsError, RunNotTerminalError, SourceRunNotFoundError} from '#core/errors.js';\nimport {createRerunWorkflowRun} from '#db/index.js';\nimport {toRunDto} from '#presentation/dto/index.js';\nimport {requireAccessibleRun} from './require-accessible-run.js';\n\nexport const rerunRunRoute = defineRoute({\n method: 'POST',\n path: '/:id/rerun',\n description: 'Re-run a terminal workflow run',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n body: rerunWorkflowRunBodySchema,\n response: {\n 200: workflowRunResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (error instanceof SourceRunNotFoundError) {\n throw new ClientError('Run not found', 'not-found', {status: 404});\n }\n if (error instanceof RunNotTerminalError) {\n throw new ClientError('Run is not terminal', 'run-not-terminal', {status: 409});\n }\n if (error instanceof NoFailedJobsError) {\n throw new ClientError('Run has no failed jobs', 'no-failed-jobs', {status: 409});\n }\n throw error;\n },\n handler: async (request) => {\n const {id} = request.params;\n const sourceRun = await requireAccessibleRun({request, id});\n\n const actor = requireUserContext(request);\n const run = await createRerunWorkflowRun({\n workflowRunId: sourceRun.id,\n mode: request.body.mode,\n actorUserId: actor.userId,\n });\n\n return toRunDto(run, run.currentAttempt);\n },\n});\n"],"names":["requireUserContext","rerunWorkflowRunBodySchema","workflowRunResponseSchema","ClientError","defineRoute","z","NoFailedJobsError","RunNotTerminalError","SourceRunNotFoundError","createRerunWorkflowRun","toRunDto","requireAccessibleRun","rerunRunRoute","method","path","description","schema","params","object","id","string","uuid","body","response","errorHandler","error","status","handler","request","sourceRun","actor","run","workflowRunId","mode","actorUserId","userId","currentAttempt"],"mappings":"AAAA,SAAQA,kBAAkB,QAAO,4BAA4B;AAC7D,SAAQC,0BAA0B,EAAEC,yBAAyB,QAAO,6BAA6B;AACjG,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,iBAAiB,EAAEC,mBAAmB,EAAEC,sBAAsB,QAAO,kBAAkB;AAC/F,SAAQC,sBAAsB,QAAO,eAAe;AACpD,SAAQC,QAAQ,QAAO,6BAA6B;AACpD,SAAQC,oBAAoB,QAAO,8BAA8B;AAEjE,OAAO,MAAMC,gBAAgBR,YAAY;IACvCS,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQZ,EAAEa,MAAM,CAAC;YACfC,IAAId,EAAEe,MAAM,GAAGC,IAAI;QACrB;QACAC,MAAMrB;QACNsB,UAAU;YACR,KAAKrB;QACP;IACF;IACAsB,cAAc,CAACC;QACb,IAAIA,iBAAiBjB,wBAAwB;YAC3C,MAAM,IAAIL,YAAY,iBAAiB,aAAa;gBAACuB,QAAQ;YAAG;QAClE;QACA,IAAID,iBAAiBlB,qBAAqB;YACxC,MAAM,IAAIJ,YAAY,uBAAuB,oBAAoB;gBAACuB,QAAQ;YAAG;QAC/E;QACA,IAAID,iBAAiBnB,mBAAmB;YACtC,MAAM,IAAIH,YAAY,0BAA0B,kBAAkB;gBAACuB,QAAQ;YAAG;QAChF;QACA,MAAMD;IACR;IACAE,SAAS,OAAOC;QACd,MAAM,EAACT,EAAE,EAAC,GAAGS,QAAQX,MAAM;QAC3B,MAAMY,YAAY,MAAMlB,qBAAqB;YAACiB;YAAST;QAAE;QAEzD,MAAMW,QAAQ9B,mBAAmB4B;QACjC,MAAMG,MAAM,MAAMtB,uBAAuB;YACvCuB,eAAeH,UAAUV,EAAE;YAC3Bc,MAAML,QAAQN,IAAI,CAACW,IAAI;YACvBC,aAAaJ,MAAMK,MAAM;QAC3B;QAEA,OAAOzB,SAASqB,KAAKA,IAAIK,cAAc;IACzC;AACF,GAAG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { onJobEventDelivered } from './on-job-event-delivered.js';
|
|
2
|
+
export { onJobStepsSettled } from './on-job-steps-settled.js';
|
|
3
|
+
export { onRunnerJobClaimed } from './on-runner-job-claimed.js';
|
|
4
|
+
export { onRunnerJobLeaseExpired } from './on-runner-job-lease-expired.js';
|
|
5
|
+
export { onRunnerJobQueued } from './on-runner-job-queued.js';
|
|
6
|
+
export { onWorkflowRunAttemptCreated } from './on-workflow-run-attempt-created.js';
|
|
7
|
+
export { onWorkflowRunCancelled } from './on-workflow-run-cancelled.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAC,uBAAuB,EAAC,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAC,2BAA2B,EAAC,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { onJobEventDelivered } from './on-job-event-delivered.js';
|
|
2
|
+
export { onJobStepsSettled } from './on-job-steps-settled.js';
|
|
3
|
+
export { onRunnerJobClaimed } from './on-runner-job-claimed.js';
|
|
4
|
+
export { onRunnerJobLeaseExpired } from './on-runner-job-lease-expired.js';
|
|
5
|
+
export { onRunnerJobQueued } from './on-runner-job-queued.js';
|
|
6
|
+
export { onWorkflowRunAttemptCreated } from './on-workflow-run-attempt-created.js';
|
|
7
|
+
export { onWorkflowRunCancelled } from './on-workflow-run-cancelled.js';
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/subscribers/index.ts"],"sourcesContent":["export {onJobEventDelivered} from './on-job-event-delivered.js';\nexport {onJobStepsSettled} from './on-job-steps-settled.js';\nexport {onRunnerJobClaimed} from './on-runner-job-claimed.js';\nexport {onRunnerJobLeaseExpired} from './on-runner-job-lease-expired.js';\nexport {onRunnerJobQueued} from './on-runner-job-queued.js';\nexport {onWorkflowRunAttemptCreated} from './on-workflow-run-attempt-created.js';\nexport {onWorkflowRunCancelled} from './on-workflow-run-cancelled.js';\n"],"names":["onJobEventDelivered","onJobStepsSettled","onRunnerJobClaimed","onRunnerJobLeaseExpired","onRunnerJobQueued","onWorkflowRunAttemptCreated","onWorkflowRunCancelled"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,8BAA8B;AAChE,SAAQC,iBAAiB,QAAO,4BAA4B;AAC5D,SAAQC,kBAAkB,QAAO,6BAA6B;AAC9D,SAAQC,uBAAuB,QAAO,mCAAmC;AACzE,SAAQC,iBAAiB,QAAO,4BAA4B;AAC5D,SAAQC,2BAA2B,QAAO,uCAAuC;AACjF,SAAQC,sBAAsB,QAAO,iCAAiC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-job-event-delivered.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/on-job-event-delivered.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kCAAkC,EAAC,MAAM,4BAA4B,CAAC;AAMnF,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { logger } from '@shipfox/node-opentelemetry';
|
|
2
|
+
import { temporalClient } from '@shipfox/node-temporal';
|
|
3
|
+
import { LISTENER_EVENTS_AVAILABLE_SIGNAL, LISTENER_RESOLVE_SIGNAL } from '#temporal/constants.js';
|
|
4
|
+
import { isWorkflowNotFound } from '#temporal/workflow-not-found.js';
|
|
5
|
+
export async function onJobEventDelivered(payload) {
|
|
6
|
+
const signal = payload.disposition === 'resolve' ? LISTENER_RESOLVE_SIGNAL : LISTENER_EVENTS_AVAILABLE_SIGNAL;
|
|
7
|
+
const handle = temporalClient().workflow.getHandle(`job-listener:${payload.jobId}`);
|
|
8
|
+
try {
|
|
9
|
+
await handle.signal(signal);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
if (isWorkflowNotFound(err)) {
|
|
12
|
+
logger().debug({
|
|
13
|
+
jobId: payload.jobId,
|
|
14
|
+
disposition: payload.disposition,
|
|
15
|
+
eventRef: payload.eventRef,
|
|
16
|
+
eventName: payload.eventName
|
|
17
|
+
}, 'Listener workflow already terminated; delivered event discarded');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
throw err;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=on-job-event-delivered.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/subscribers/on-job-event-delivered.ts"],"sourcesContent":["import type {WorkflowsJobEventDeliveredEventDto} from '@shipfox/api-workflows-dto';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {temporalClient} from '@shipfox/node-temporal';\nimport {LISTENER_EVENTS_AVAILABLE_SIGNAL, LISTENER_RESOLVE_SIGNAL} from '#temporal/constants.js';\nimport {isWorkflowNotFound} from '#temporal/workflow-not-found.js';\n\nexport async function onJobEventDelivered(\n payload: WorkflowsJobEventDeliveredEventDto,\n): Promise<void> {\n const signal =\n payload.disposition === 'resolve' ? LISTENER_RESOLVE_SIGNAL : LISTENER_EVENTS_AVAILABLE_SIGNAL;\n const handle = temporalClient().workflow.getHandle(`job-listener:${payload.jobId}`);\n try {\n await handle.signal(signal);\n } catch (err) {\n if (isWorkflowNotFound(err)) {\n logger().debug(\n {\n jobId: payload.jobId,\n disposition: payload.disposition,\n eventRef: payload.eventRef,\n eventName: payload.eventName,\n },\n 'Listener workflow already terminated; delivered event discarded',\n );\n return;\n }\n throw err;\n }\n}\n"],"names":["logger","temporalClient","LISTENER_EVENTS_AVAILABLE_SIGNAL","LISTENER_RESOLVE_SIGNAL","isWorkflowNotFound","onJobEventDelivered","payload","signal","disposition","handle","workflow","getHandle","jobId","err","debug","eventRef","eventName"],"mappings":"AACA,SAAQA,MAAM,QAAO,8BAA8B;AACnD,SAAQC,cAAc,QAAO,yBAAyB;AACtD,SAAQC,gCAAgC,EAAEC,uBAAuB,QAAO,yBAAyB;AACjG,SAAQC,kBAAkB,QAAO,kCAAkC;AAEnE,OAAO,eAAeC,oBACpBC,OAA2C;IAE3C,MAAMC,SACJD,QAAQE,WAAW,KAAK,YAAYL,0BAA0BD;IAChE,MAAMO,SAASR,iBAAiBS,QAAQ,CAACC,SAAS,CAAC,CAAC,aAAa,EAAEL,QAAQM,KAAK,EAAE;IAClF,IAAI;QACF,MAAMH,OAAOF,MAAM,CAACA;IACtB,EAAE,OAAOM,KAAK;QACZ,IAAIT,mBAAmBS,MAAM;YAC3Bb,SAASc,KAAK,CACZ;gBACEF,OAAON,QAAQM,KAAK;gBACpBJ,aAAaF,QAAQE,WAAW;gBAChCO,UAAUT,QAAQS,QAAQ;gBAC1BC,WAAWV,QAAQU,SAAS;YAC9B,GACA;YAEF;QACF;QACA,MAAMH;IACR;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-job-steps-settled.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/on-job-steps-settled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gCAAgC,EAAC,MAAM,4BAA4B,CAAC;AAUjF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BhG"}
|