@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,604 @@
|
|
|
1
|
+
import {buildUserContext, setUserContext} from '@shipfox/api-auth-context';
|
|
2
|
+
import {requireProjectAccess} from '@shipfox/api-projects';
|
|
3
|
+
import {ClientError} from '@shipfox/node-fastify';
|
|
4
|
+
import {eq} from 'drizzle-orm';
|
|
5
|
+
import type {FastifyInstance} from 'fastify';
|
|
6
|
+
import Fastify from 'fastify';
|
|
7
|
+
import {serializerCompiler, validatorCompiler} from 'fastify-type-provider-zod';
|
|
8
|
+
import {JobNotFoundError} from '#core/errors.js';
|
|
9
|
+
import {
|
|
10
|
+
nextStepForJob,
|
|
11
|
+
recordStepResult as recordJobExecutionStepResult,
|
|
12
|
+
} from '#core/job-execution.js';
|
|
13
|
+
import {db} from '#db/db.js';
|
|
14
|
+
import * as dbIndex from '#db/index.js';
|
|
15
|
+
import {jobExecutions as jobExecutionsTable} from '#db/schema/job-executions.js';
|
|
16
|
+
import {jobs as jobsTable} from '#db/schema/jobs.js';
|
|
17
|
+
import {steps as stepsTable} from '#db/schema/steps.js';
|
|
18
|
+
import {
|
|
19
|
+
createRerunWorkflowRun,
|
|
20
|
+
createWorkflowRun,
|
|
21
|
+
getJobExecutionsByJobId,
|
|
22
|
+
getJobsByWorkflowRunId,
|
|
23
|
+
getStepsByJobId,
|
|
24
|
+
updateWorkflowRunStatus,
|
|
25
|
+
} from '#db/workflow-runs.js';
|
|
26
|
+
import {workflowModel} from '#test/index.js';
|
|
27
|
+
import {getRunRoute} from './get-run.js';
|
|
28
|
+
|
|
29
|
+
const projectAccessState = vi.hoisted(() => ({workspaceId: ''}));
|
|
30
|
+
|
|
31
|
+
async function recordStepResult(
|
|
32
|
+
params: Omit<Parameters<typeof recordJobExecutionStepResult>[0], 'jobExecutionId'> & {
|
|
33
|
+
jobId: string;
|
|
34
|
+
},
|
|
35
|
+
) {
|
|
36
|
+
const steps = await getStepsByJobId(params.jobId);
|
|
37
|
+
const step = steps.find((candidate) => candidate.id === params.stepId);
|
|
38
|
+
if (!step) throw new JobNotFoundError(params.jobId);
|
|
39
|
+
const {jobId: _jobId, ...rest} = params;
|
|
40
|
+
return recordJobExecutionStepResult({...rest, jobExecutionId: step.jobExecutionId});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
vi.mock('@shipfox/api-projects', () => ({
|
|
44
|
+
requireProjectAccess: vi.fn(({projectId}) =>
|
|
45
|
+
Promise.resolve({
|
|
46
|
+
project: {id: projectId, workspaceId: projectAccessState.workspaceId},
|
|
47
|
+
workspaceId: projectAccessState.workspaceId,
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
const mockRequireProjectAccess = vi.mocked(requireProjectAccess);
|
|
53
|
+
|
|
54
|
+
describe('GET /api/workflows/runs/:id', () => {
|
|
55
|
+
let app: FastifyInstance;
|
|
56
|
+
let workspaceId: string;
|
|
57
|
+
|
|
58
|
+
beforeAll(async () => {
|
|
59
|
+
app = Fastify();
|
|
60
|
+
app.setValidatorCompiler(validatorCompiler);
|
|
61
|
+
app.setSerializerCompiler(serializerCompiler);
|
|
62
|
+
app.addHook('onRequest', (request, _reply, done) => {
|
|
63
|
+
setUserContext(
|
|
64
|
+
request,
|
|
65
|
+
buildUserContext({
|
|
66
|
+
userId: crypto.randomUUID(),
|
|
67
|
+
email: 'user@example.com',
|
|
68
|
+
memberships: [{workspaceId, role: 'admin'}],
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
done();
|
|
72
|
+
});
|
|
73
|
+
app.get('/api/workflows/runs/:id', getRunRoute);
|
|
74
|
+
await app.ready();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
beforeEach(() => {
|
|
78
|
+
workspaceId = crypto.randomUUID();
|
|
79
|
+
projectAccessState.workspaceId = workspaceId;
|
|
80
|
+
mockRequireProjectAccess.mockImplementation(({projectId}) =>
|
|
81
|
+
Promise.resolve({
|
|
82
|
+
project: {
|
|
83
|
+
id: projectId,
|
|
84
|
+
workspaceId,
|
|
85
|
+
sourceConnectionId: crypto.randomUUID(),
|
|
86
|
+
sourceExternalRepositoryId: `repo:${crypto.randomUUID()}`,
|
|
87
|
+
name: 'Project',
|
|
88
|
+
createdAt: new Date(),
|
|
89
|
+
updatedAt: new Date(),
|
|
90
|
+
},
|
|
91
|
+
workspaceId,
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('returns 200 with run, jobs, and steps', async () => {
|
|
97
|
+
const projectId = crypto.randomUUID();
|
|
98
|
+
const definitionId = crypto.randomUUID();
|
|
99
|
+
|
|
100
|
+
const run = await createWorkflowRun({
|
|
101
|
+
workspaceId,
|
|
102
|
+
projectId,
|
|
103
|
+
definitionId,
|
|
104
|
+
model: workflowModel({
|
|
105
|
+
name: 'Test',
|
|
106
|
+
jobs: {
|
|
107
|
+
build: {steps: [{name: 'Install', run: 'npm install'}, {run: 'npm build'}]},
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
triggerPayload: {
|
|
111
|
+
source: 'manual',
|
|
112
|
+
event: 'fire',
|
|
113
|
+
subscriptionId: crypto.randomUUID(),
|
|
114
|
+
userId: crypto.randomUUID(),
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const res = await app.inject({
|
|
119
|
+
method: 'GET',
|
|
120
|
+
url: `/api/workflows/runs/${run.id}`,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
expect(res.statusCode).toBe(200);
|
|
124
|
+
const body = res.json();
|
|
125
|
+
expect(body.id).toBe(run.id);
|
|
126
|
+
expect(body.source_snapshot).toBeNull();
|
|
127
|
+
expect(body.jobs).toHaveLength(1);
|
|
128
|
+
expect(body.jobs[0].key).toBe('build');
|
|
129
|
+
expect(body.jobs[0].name).toBeNull();
|
|
130
|
+
expect(body.jobs[0].job_executions).toHaveLength(1);
|
|
131
|
+
const steps = body.jobs[0].job_executions[0].steps;
|
|
132
|
+
// Synthetic setup step at position 0, then the two user steps.
|
|
133
|
+
expect(steps).toHaveLength(3);
|
|
134
|
+
expect(steps[0].name).toBe('Set up job');
|
|
135
|
+
expect(steps[1].name).toBe('Install');
|
|
136
|
+
expect(steps[2].name).toBe('npm build');
|
|
137
|
+
// Run timing fields flow through the read model (null on a fresh, unstamped run).
|
|
138
|
+
expect(body).toMatchObject({latest_attempt: 1, started_at: null, finished_at: null});
|
|
139
|
+
expect(body.jobs[0]).not.toHaveProperty('queued_at');
|
|
140
|
+
expect(body.jobs[0]).not.toHaveProperty('started_at');
|
|
141
|
+
expect(body.jobs[0]).not.toHaveProperty('finished_at');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('does not aggregate latest_attempt for a first attempt without lineage', async () => {
|
|
145
|
+
const latestAttemptSpy = vi.spyOn(dbIndex, 'getLatestAttempt');
|
|
146
|
+
const run = await createWorkflowRun({
|
|
147
|
+
workspaceId,
|
|
148
|
+
projectId: crypto.randomUUID(),
|
|
149
|
+
definitionId: crypto.randomUUID(),
|
|
150
|
+
model: workflowModel({name: 'First attempt'}),
|
|
151
|
+
triggerPayload: {
|
|
152
|
+
source: 'manual',
|
|
153
|
+
event: 'fire',
|
|
154
|
+
subscriptionId: crypto.randomUUID(),
|
|
155
|
+
userId: crypto.randomUUID(),
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const res = await app.inject({
|
|
160
|
+
method: 'GET',
|
|
161
|
+
url: `/api/workflows/runs/${run.id}`,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
expect(res.statusCode).toBe(200);
|
|
165
|
+
expect(res.json().latest_attempt).toBe(1);
|
|
166
|
+
expect(latestAttemptSpy).not.toHaveBeenCalled();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('returns latest_attempt for a run lineage', async () => {
|
|
170
|
+
const projectId = crypto.randomUUID();
|
|
171
|
+
const source = await createWorkflowRun({
|
|
172
|
+
workspaceId,
|
|
173
|
+
projectId,
|
|
174
|
+
definitionId: crypto.randomUUID(),
|
|
175
|
+
model: workflowModel({name: 'Lineage'}),
|
|
176
|
+
triggerPayload: {
|
|
177
|
+
source: 'manual',
|
|
178
|
+
event: 'fire',
|
|
179
|
+
subscriptionId: crypto.randomUUID(),
|
|
180
|
+
userId: crypto.randomUUID(),
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
await updateWorkflowRunStatus({workflowRunId: source.id, status: 'failed', expectedVersion: 1});
|
|
184
|
+
const rerun = await createRerunWorkflowRun({
|
|
185
|
+
workflowRunId: source.id,
|
|
186
|
+
mode: 'all',
|
|
187
|
+
actorUserId: crypto.randomUUID(),
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const res = await app.inject({
|
|
191
|
+
method: 'GET',
|
|
192
|
+
url: `/api/workflows/runs/${rerun.id}`,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
expect(res.statusCode).toBe(200);
|
|
196
|
+
expect(res.json().latest_attempt).toBe(2);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('returns run source snapshot when present', async () => {
|
|
200
|
+
const projectId = crypto.randomUUID();
|
|
201
|
+
const definitionId = crypto.randomUUID();
|
|
202
|
+
const sourceContent = `name: Source View
|
|
203
|
+
jobs:
|
|
204
|
+
build:
|
|
205
|
+
steps:
|
|
206
|
+
- run: echo source
|
|
207
|
+
`;
|
|
208
|
+
const run = await createWorkflowRun({
|
|
209
|
+
workspaceId,
|
|
210
|
+
projectId,
|
|
211
|
+
definitionId,
|
|
212
|
+
model: workflowModel({name: 'Source View'}),
|
|
213
|
+
sourceSnapshot: {content: sourceContent, format: 'yaml'},
|
|
214
|
+
triggerPayload: {
|
|
215
|
+
source: 'manual',
|
|
216
|
+
event: 'fire',
|
|
217
|
+
subscriptionId: crypto.randomUUID(),
|
|
218
|
+
userId: crypto.randomUUID(),
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
const res = await app.inject({
|
|
223
|
+
method: 'GET',
|
|
224
|
+
url: `/api/workflows/runs/${run.id}`,
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
expect(res.statusCode).toBe(200);
|
|
228
|
+
expect(res.json().source_snapshot).toEqual({content: sourceContent, format: 'yaml'});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test('returns source locations for authored steps and null for synthetic steps', async () => {
|
|
232
|
+
const projectId = crypto.randomUUID();
|
|
233
|
+
const definitionId = crypto.randomUUID();
|
|
234
|
+
|
|
235
|
+
const run = await createWorkflowRun({
|
|
236
|
+
workspaceId,
|
|
237
|
+
projectId,
|
|
238
|
+
definitionId,
|
|
239
|
+
model: workflowModel({
|
|
240
|
+
name: 'Source locations',
|
|
241
|
+
jobs: {
|
|
242
|
+
build: {
|
|
243
|
+
steps: [
|
|
244
|
+
{name: 'Install', run: 'npm install', sourceLocation: {startLine: 5, endLine: 6}},
|
|
245
|
+
{run: 'npm test', sourceLocation: {startLine: 7, endLine: 10}},
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
}),
|
|
250
|
+
triggerPayload: {
|
|
251
|
+
source: 'manual',
|
|
252
|
+
event: 'fire',
|
|
253
|
+
subscriptionId: crypto.randomUUID(),
|
|
254
|
+
userId: crypto.randomUUID(),
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const res = await app.inject({
|
|
259
|
+
method: 'GET',
|
|
260
|
+
url: `/api/workflows/runs/${run.id}`,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
expect(res.statusCode).toBe(200);
|
|
264
|
+
expect(
|
|
265
|
+
res
|
|
266
|
+
.json()
|
|
267
|
+
.jobs[0].job_executions[0].steps.map(
|
|
268
|
+
(step: {source_location: unknown}) => step.source_location,
|
|
269
|
+
),
|
|
270
|
+
).toEqual([null, {start_line: 5, end_line: 6}, {start_line: 7, end_line: 10}]);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test('exposes per-step error and skipped status after a failed per-step report', async () => {
|
|
274
|
+
const projectId = crypto.randomUUID();
|
|
275
|
+
const definitionId = crypto.randomUUID();
|
|
276
|
+
|
|
277
|
+
const run = await createWorkflowRun({
|
|
278
|
+
workspaceId,
|
|
279
|
+
projectId,
|
|
280
|
+
definitionId,
|
|
281
|
+
model: workflowModel({
|
|
282
|
+
name: 'Test',
|
|
283
|
+
jobs: {build: {steps: [{run: 'a'}, {run: 'b'}, {run: 'c'}]}},
|
|
284
|
+
}),
|
|
285
|
+
triggerPayload: {
|
|
286
|
+
source: 'manual',
|
|
287
|
+
event: 'fire',
|
|
288
|
+
subscriptionId: crypto.randomUUID(),
|
|
289
|
+
userId: crypto.randomUUID(),
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
const runJobs = await getJobsByWorkflowRunId(run.id);
|
|
294
|
+
const jobId = runJobs[0]?.id ?? '';
|
|
295
|
+
const steps = await getStepsByJobId(jobId);
|
|
296
|
+
|
|
297
|
+
// Drive the per-step path: step 1 succeeds, step 2 fails, step 3 is skipped
|
|
298
|
+
// by the default gate on the follow-up pull.
|
|
299
|
+
await nextStepForJob(jobId);
|
|
300
|
+
await recordStepResult({
|
|
301
|
+
jobId,
|
|
302
|
+
stepId: steps[0]?.id as string,
|
|
303
|
+
status: 'succeeded',
|
|
304
|
+
exitCode: 0,
|
|
305
|
+
});
|
|
306
|
+
await nextStepForJob(jobId);
|
|
307
|
+
await recordStepResult({
|
|
308
|
+
jobId,
|
|
309
|
+
stepId: steps[1]?.id as string,
|
|
310
|
+
status: 'failed',
|
|
311
|
+
error: {message: 'Command exited with code 1', exitCode: 1},
|
|
312
|
+
exitCode: 1,
|
|
313
|
+
});
|
|
314
|
+
await nextStepForJob(jobId);
|
|
315
|
+
|
|
316
|
+
const res = await app.inject({
|
|
317
|
+
method: 'GET',
|
|
318
|
+
url: `/api/workflows/runs/${run.id}`,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
expect(res.statusCode).toBe(200);
|
|
322
|
+
const body = res.json();
|
|
323
|
+
// steps[0] is the setup step (reported succeeded above); the failed user step
|
|
324
|
+
// follows. A failed step's error carries the server-derived category 'user'.
|
|
325
|
+
const responseSteps = body.jobs[0].job_executions[0].steps as Array<{
|
|
326
|
+
status: string;
|
|
327
|
+
error: {message: string; exit_code?: number | null; category?: string} | null;
|
|
328
|
+
}>;
|
|
329
|
+
expect(responseSteps[0]?.status).toBe('succeeded');
|
|
330
|
+
expect(responseSteps[0]?.error).toBeNull();
|
|
331
|
+
expect(responseSteps[1]?.status).toBe('failed');
|
|
332
|
+
expect(responseSteps[1]?.error).toEqual({
|
|
333
|
+
message: 'Command exited with code 1',
|
|
334
|
+
exit_code: 1,
|
|
335
|
+
category: 'user',
|
|
336
|
+
});
|
|
337
|
+
expect(responseSteps[2]?.status).toBe('skipped');
|
|
338
|
+
expect(responseSteps[2]?.error).toBeNull();
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
test('returns 404 for non-existent run', async () => {
|
|
342
|
+
const res = await app.inject({
|
|
343
|
+
method: 'GET',
|
|
344
|
+
url: `/api/workflows/runs/${crypto.randomUUID()}`,
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
expect(res.statusCode).toBe(404);
|
|
348
|
+
expect(res.json().code).toBe('not-found');
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
test('returns 404 for inaccessible run', async () => {
|
|
352
|
+
const detailSpy = vi.spyOn(dbIndex, 'getWorkflowRunDetail');
|
|
353
|
+
const run = await createWorkflowRun({
|
|
354
|
+
workspaceId,
|
|
355
|
+
projectId: crypto.randomUUID(),
|
|
356
|
+
definitionId: crypto.randomUUID(),
|
|
357
|
+
model: workflowModel({name: 'Test'}),
|
|
358
|
+
triggerPayload: {
|
|
359
|
+
source: 'manual',
|
|
360
|
+
event: 'fire',
|
|
361
|
+
subscriptionId: crypto.randomUUID(),
|
|
362
|
+
userId: crypto.randomUUID(),
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
mockRequireProjectAccess.mockRejectedValueOnce(
|
|
366
|
+
new ClientError('Not a member of this workspace', 'forbidden', {status: 403}),
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
const res = await app.inject({
|
|
370
|
+
method: 'GET',
|
|
371
|
+
url: `/api/workflows/runs/${run.id}`,
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
expect(res.statusCode).toBe(404);
|
|
375
|
+
expect(res.json().code).toBe('not-found');
|
|
376
|
+
expect(detailSpy).not.toHaveBeenCalled();
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
test('propagates unexpected errors from project access check', async () => {
|
|
380
|
+
const run = await createWorkflowRun({
|
|
381
|
+
workspaceId,
|
|
382
|
+
projectId: crypto.randomUUID(),
|
|
383
|
+
definitionId: crypto.randomUUID(),
|
|
384
|
+
model: workflowModel({name: 'Test'}),
|
|
385
|
+
triggerPayload: {
|
|
386
|
+
source: 'manual',
|
|
387
|
+
event: 'fire',
|
|
388
|
+
subscriptionId: crypto.randomUUID(),
|
|
389
|
+
userId: crypto.randomUUID(),
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
mockRequireProjectAccess.mockRejectedValueOnce(new Error('database connection lost'));
|
|
393
|
+
|
|
394
|
+
const res = await app.inject({
|
|
395
|
+
method: 'GET',
|
|
396
|
+
url: `/api/workflows/runs/${run.id}`,
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
expect(res.statusCode).toBe(500);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
test('exposes step current_attempt and attempt history', async () => {
|
|
403
|
+
const projectId = crypto.randomUUID();
|
|
404
|
+
const run = await createWorkflowRun({
|
|
405
|
+
workspaceId,
|
|
406
|
+
projectId,
|
|
407
|
+
definitionId: crypto.randomUUID(),
|
|
408
|
+
model: workflowModel({
|
|
409
|
+
name: 'Test',
|
|
410
|
+
jobs: {build: {steps: [{run: 'a'}, {run: 'b'}]}},
|
|
411
|
+
}),
|
|
412
|
+
triggerPayload: {
|
|
413
|
+
source: 'manual',
|
|
414
|
+
event: 'fire',
|
|
415
|
+
subscriptionId: crypto.randomUUID(),
|
|
416
|
+
userId: crypto.randomUUID(),
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
const jobId = (await getJobsByWorkflowRunId(run.id))[0]?.id as string;
|
|
420
|
+
const steps = await getStepsByJobId(jobId);
|
|
421
|
+
await nextStepForJob(jobId);
|
|
422
|
+
await recordStepResult({
|
|
423
|
+
jobId,
|
|
424
|
+
stepId: steps[0]?.id as string,
|
|
425
|
+
status: 'succeeded',
|
|
426
|
+
exitCode: 0,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
const res = await app.inject({method: 'GET', url: `/api/workflows/runs/${run.id}`});
|
|
430
|
+
|
|
431
|
+
expect(res.statusCode).toBe(200);
|
|
432
|
+
const [step0, step1] = res.json().jobs[0].job_executions[0].steps;
|
|
433
|
+
expect(step0.current_attempt).toBe(1);
|
|
434
|
+
expect(step0.attempts).toHaveLength(1);
|
|
435
|
+
expect(step0.attempts[0]).toMatchObject({
|
|
436
|
+
attempt: 1,
|
|
437
|
+
status: 'succeeded',
|
|
438
|
+
exit_code: 0,
|
|
439
|
+
gate_result: {kind: 'none'},
|
|
440
|
+
restart_feedback: null,
|
|
441
|
+
});
|
|
442
|
+
// A never-dispatched step has no attempt history yet.
|
|
443
|
+
expect(step1.current_attempt).toBe(1);
|
|
444
|
+
expect(step1.attempts).toEqual([]);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
test('exposes server-derived outputs and responses in run detail', async () => {
|
|
448
|
+
const projectId = crypto.randomUUID();
|
|
449
|
+
const run = await createWorkflowRun({
|
|
450
|
+
workspaceId,
|
|
451
|
+
projectId,
|
|
452
|
+
definitionId: crypto.randomUUID(),
|
|
453
|
+
model: workflowModel({
|
|
454
|
+
name: 'Test',
|
|
455
|
+
jobs: {build: {steps: [{run: 'build'}]}},
|
|
456
|
+
}),
|
|
457
|
+
triggerPayload: {
|
|
458
|
+
source: 'manual',
|
|
459
|
+
event: 'fire',
|
|
460
|
+
subscriptionId: crypto.randomUUID(),
|
|
461
|
+
userId: crypto.randomUUID(),
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
const job = (await getJobsByWorkflowRunId(run.id))[0];
|
|
465
|
+
if (!job) throw new Error('Expected workflow job');
|
|
466
|
+
const jobExecution = (await getJobExecutionsByJobId(job.id))[0];
|
|
467
|
+
if (!jobExecution) throw new Error('Expected job execution');
|
|
468
|
+
const steps = await getStepsByJobId(job.id);
|
|
469
|
+
const setupId = steps[0]?.id as string;
|
|
470
|
+
const buildId = steps[1]?.id as string;
|
|
471
|
+
await db()
|
|
472
|
+
.update(jobsTable)
|
|
473
|
+
.set({outputs: {image_sha: 'sha-123'}})
|
|
474
|
+
.where(eq(jobsTable.id, job.id));
|
|
475
|
+
await db()
|
|
476
|
+
.update(jobExecutionsTable)
|
|
477
|
+
.set({outputs: {image_sha: 'sha-123', token: '***'}})
|
|
478
|
+
.where(eq(jobExecutionsTable.id, jobExecution.id));
|
|
479
|
+
await nextStepForJob(job.id);
|
|
480
|
+
await recordStepResult({
|
|
481
|
+
jobId: job.id,
|
|
482
|
+
stepId: setupId,
|
|
483
|
+
status: 'succeeded',
|
|
484
|
+
exitCode: 0,
|
|
485
|
+
});
|
|
486
|
+
await nextStepForJob(job.id);
|
|
487
|
+
await recordStepResult({
|
|
488
|
+
jobId: job.id,
|
|
489
|
+
stepId: buildId,
|
|
490
|
+
status: 'succeeded',
|
|
491
|
+
exitCode: 0,
|
|
492
|
+
output: {image_sha: 'sha-123', token: '***'},
|
|
493
|
+
response: 'Build complete',
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
const res = await app.inject({method: 'GET', url: `/api/workflows/runs/${run.id}`});
|
|
497
|
+
|
|
498
|
+
expect(res.statusCode).toBe(200);
|
|
499
|
+
const responseJob = res.json().jobs[0];
|
|
500
|
+
const responseExecution = responseJob.job_executions[0];
|
|
501
|
+
const responseBuildStep = responseExecution.steps[1];
|
|
502
|
+
expect(responseJob.outputs).toEqual({image_sha: 'sha-123'});
|
|
503
|
+
expect(responseExecution.outputs).toEqual({image_sha: 'sha-123', token: '***'});
|
|
504
|
+
expect(responseBuildStep).toMatchObject({
|
|
505
|
+
exit_code: 0,
|
|
506
|
+
outputs: {image_sha: 'sha-123', token: '***'},
|
|
507
|
+
response: 'Build complete',
|
|
508
|
+
gate_result: {kind: 'none'},
|
|
509
|
+
});
|
|
510
|
+
expect(responseBuildStep.attempts[0]).toMatchObject({
|
|
511
|
+
output: {image_sha: 'sha-123', token: '***'},
|
|
512
|
+
outputs: {image_sha: 'sha-123', token: '***'},
|
|
513
|
+
response: 'Build complete',
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
test('exposes multiple ordered attempts for a restarted step', async () => {
|
|
518
|
+
const projectId = crypto.randomUUID();
|
|
519
|
+
const run = await createWorkflowRun({
|
|
520
|
+
workspaceId,
|
|
521
|
+
projectId,
|
|
522
|
+
definitionId: crypto.randomUUID(),
|
|
523
|
+
model: workflowModel({
|
|
524
|
+
name: 'Test',
|
|
525
|
+
jobs: {build: {steps: [{run: 'produce'}, {run: 'review'}]}},
|
|
526
|
+
}),
|
|
527
|
+
triggerPayload: {
|
|
528
|
+
source: 'manual',
|
|
529
|
+
event: 'fire',
|
|
530
|
+
subscriptionId: crypto.randomUUID(),
|
|
531
|
+
userId: crypto.randomUUID(),
|
|
532
|
+
},
|
|
533
|
+
});
|
|
534
|
+
const jobId = (await getJobsByWorkflowRunId(run.id))[0]?.id as string;
|
|
535
|
+
const steps = await getStepsByJobId(jobId);
|
|
536
|
+
// steps[0] is the synthetic setup step; the user steps follow at 1..2.
|
|
537
|
+
const setupId = steps[0]?.id as string;
|
|
538
|
+
const producerId = steps[1]?.id as string;
|
|
539
|
+
const reviewerId = steps[2]?.id as string;
|
|
540
|
+
// reviewer gate: succeed only on exit 0; otherwise restart from producer.
|
|
541
|
+
await db().update(stepsTable).set({key: 'producer'}).where(eq(stepsTable.id, producerId));
|
|
542
|
+
await db()
|
|
543
|
+
.update(stepsTable)
|
|
544
|
+
.set({
|
|
545
|
+
config: {
|
|
546
|
+
run: 'review',
|
|
547
|
+
gate: {
|
|
548
|
+
success: {language: 'cel', check: 'syntax', source: 'step.exit_code == 0'},
|
|
549
|
+
on_failure: {restart_from: 'producer'},
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
})
|
|
553
|
+
.where(eq(stepsTable.id, reviewerId));
|
|
554
|
+
const runStep = async (stepId: string, exitCode: number) => {
|
|
555
|
+
await nextStepForJob(jobId);
|
|
556
|
+
await recordStepResult({
|
|
557
|
+
jobId,
|
|
558
|
+
stepId,
|
|
559
|
+
status: exitCode === 0 ? 'succeeded' : 'failed',
|
|
560
|
+
...(exitCode === 0 ? {} : {error: {message: `exit ${exitCode}`}}),
|
|
561
|
+
exitCode,
|
|
562
|
+
});
|
|
563
|
+
};
|
|
564
|
+
await runStep(setupId, 0); // setup (position 0) succeeds first
|
|
565
|
+
await runStep(producerId, 0); // producer attempt 1 succeeds
|
|
566
|
+
await runStep(reviewerId, 1); // reviewer attempt 1 gate-fails → restart, both bumped to 2
|
|
567
|
+
await runStep(producerId, 0); // producer attempt 2 succeeds
|
|
568
|
+
await runStep(reviewerId, 0); // reviewer attempt 2 gate-passes → job done
|
|
569
|
+
|
|
570
|
+
const res = await app.inject({method: 'GET', url: `/api/workflows/runs/${run.id}`});
|
|
571
|
+
|
|
572
|
+
expect(res.statusCode).toBe(200);
|
|
573
|
+
const [, producer, reviewer] = res.json().jobs[0].job_executions[0].steps;
|
|
574
|
+
expect(producer.current_attempt).toBe(2);
|
|
575
|
+
expect(producer.attempts.map((a: {attempt: number}) => a.attempt)).toEqual([1, 2]);
|
|
576
|
+
expect(reviewer.current_attempt).toBe(2);
|
|
577
|
+
const reviewerAttempts = reviewer.attempts as Array<{
|
|
578
|
+
attempt: number;
|
|
579
|
+
status: string;
|
|
580
|
+
exit_code: number | null;
|
|
581
|
+
gate_result: unknown;
|
|
582
|
+
restart_feedback: string | null;
|
|
583
|
+
}>;
|
|
584
|
+
expect(reviewerAttempts.map((a) => a.attempt)).toEqual([1, 2]); // ordered by attempt
|
|
585
|
+
expect(reviewerAttempts[0]?.status).toBe('failed');
|
|
586
|
+
expect(reviewerAttempts[0]?.exit_code).toBe(1);
|
|
587
|
+
expect(reviewerAttempts[0]?.gate_result).toEqual({
|
|
588
|
+
kind: 'failed',
|
|
589
|
+
passed: false,
|
|
590
|
+
source: 'step.exit_code == 0',
|
|
591
|
+
exit_code: 1,
|
|
592
|
+
});
|
|
593
|
+
expect(reviewerAttempts[0]?.restart_feedback).toBe('gate condition not met');
|
|
594
|
+
expect(reviewerAttempts[1]?.status).toBe('succeeded');
|
|
595
|
+
expect(reviewerAttempts[1]?.exit_code).toBe(0);
|
|
596
|
+
expect(reviewerAttempts[1]?.gate_result).toEqual({
|
|
597
|
+
kind: 'passed',
|
|
598
|
+
passed: true,
|
|
599
|
+
source: 'step.exit_code == 0',
|
|
600
|
+
exit_code: 0,
|
|
601
|
+
});
|
|
602
|
+
expect(reviewerAttempts[1]?.restart_feedback).toBeNull();
|
|
603
|
+
});
|
|
604
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {workflowRunDetailResponseSchema} from '@shipfox/api-workflows-dto';
|
|
2
|
+
import {ClientError, defineRoute} from '@shipfox/node-fastify';
|
|
3
|
+
import {z} from 'zod';
|
|
4
|
+
import {getWorkflowRunDetail} from '#db/index.js';
|
|
5
|
+
import {
|
|
6
|
+
toJobDto,
|
|
7
|
+
toJobExecutionDto,
|
|
8
|
+
toRunAttemptDto,
|
|
9
|
+
toRunDto,
|
|
10
|
+
toStepAttemptDto,
|
|
11
|
+
toStepDto,
|
|
12
|
+
} from '#presentation/dto/index.js';
|
|
13
|
+
import {requireAccessibleRun} from './require-accessible-run.js';
|
|
14
|
+
|
|
15
|
+
export const getRunRoute = defineRoute({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
path: '/:id',
|
|
18
|
+
description: 'Get a workflow run by ID with jobs and steps',
|
|
19
|
+
schema: {
|
|
20
|
+
params: z.object({
|
|
21
|
+
id: z.string().uuid(),
|
|
22
|
+
}),
|
|
23
|
+
querystring: z.object({
|
|
24
|
+
attempt: z.coerce.number().int().positive().optional(),
|
|
25
|
+
}),
|
|
26
|
+
response: {
|
|
27
|
+
200: workflowRunDetailResponseSchema,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
handler: async (request) => {
|
|
31
|
+
const {id} = request.params;
|
|
32
|
+
await requireAccessibleRun({request, id});
|
|
33
|
+
|
|
34
|
+
const run = await getWorkflowRunDetail(id, request.query.attempt);
|
|
35
|
+
if (!run) {
|
|
36
|
+
throw new ClientError('Run not found', 'not-found', {status: 404});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const jobDtos = run.jobs.map((job) => ({
|
|
40
|
+
...toJobDto(job),
|
|
41
|
+
job_executions: job.jobExecutions.map((jobExecution) => ({
|
|
42
|
+
...toJobExecutionDto(jobExecution),
|
|
43
|
+
steps: jobExecution.steps.map((step) => {
|
|
44
|
+
const attempts = step.attempts.map(toStepAttemptDto);
|
|
45
|
+
const latestTerminalAttempt = attempts
|
|
46
|
+
.filter((attempt) => attempt.status !== 'running')
|
|
47
|
+
.at(-1);
|
|
48
|
+
return {
|
|
49
|
+
...toStepDto(step),
|
|
50
|
+
exit_code: latestTerminalAttempt?.exit_code ?? null,
|
|
51
|
+
outputs: latestTerminalAttempt?.outputs ?? null,
|
|
52
|
+
response: latestTerminalAttempt?.response ?? null,
|
|
53
|
+
gate_result: latestTerminalAttempt?.gate_result ?? null,
|
|
54
|
+
attempts,
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
})),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
...toRunDto(run, run.latestAttempt),
|
|
62
|
+
run_attempt: toRunAttemptDto(run.runAttempt),
|
|
63
|
+
jobs: jobDtos,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|