@shipfox/api-workflows 5.0.0 → 7.0.1
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 +4 -4
- package/CHANGELOG.md +89 -0
- package/dist/core/agent-defaults.d.ts +17 -0
- package/dist/core/agent-defaults.d.ts.map +1 -0
- package/dist/core/agent-defaults.js +21 -0
- package/dist/core/agent-defaults.js.map +1 -0
- package/dist/core/agent-tool-capability-warning.d.ts +4 -0
- package/dist/core/agent-tool-capability-warning.d.ts.map +1 -1
- package/dist/core/agent-tool-capability-warning.js +15 -17
- package/dist/core/agent-tool-capability-warning.js.map +1 -1
- package/dist/core/agent-tools.d.ts +11 -9
- package/dist/core/agent-tools.d.ts.map +1 -1
- package/dist/core/agent-tools.js +23 -18
- package/dist/core/agent-tools.js.map +1 -1
- package/dist/core/checkout.d.ts +21 -7
- package/dist/core/checkout.d.ts.map +1 -1
- package/dist/core/checkout.js +23 -11
- package/dist/core/checkout.js.map +1 -1
- package/dist/core/entities/workflow-run-attempt.d.ts +1 -1
- package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
- package/dist/core/entities/workflow-run-attempt.js.map +1 -1
- package/dist/core/job-execution.d.ts +3 -1
- package/dist/core/job-execution.d.ts.map +1 -1
- package/dist/core/job-execution.js +14 -12
- package/dist/core/job-execution.js.map +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -1
- package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -1
- package/dist/core/job-transition/derive-job-success.js +1 -1
- package/dist/core/job-transition/derive-job-success.js.map +1 -1
- package/dist/core/listener-execution-materialization.d.ts +3 -3
- package/dist/core/listener-execution-materialization.d.ts.map +1 -1
- package/dist/core/listener-execution-materialization.js +3 -4
- package/dist/core/listener-execution-materialization.js.map +1 -1
- package/dist/core/run-workflow.d.ts +12 -1
- package/dist/core/run-workflow.d.ts.map +1 -1
- package/dist/core/run-workflow.js +13 -8
- package/dist/core/run-workflow.js.map +1 -1
- package/dist/core/step-config/agent.d.ts +8 -8
- package/dist/core/step-config/agent.d.ts.map +1 -1
- package/dist/core/step-config/agent.js +12 -10
- package/dist/core/step-config/agent.js.map +1 -1
- package/dist/core/step-config/complete-step-dispatch-config.d.ts +4 -4
- package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -1
- package/dist/core/step-config/complete-step-dispatch-config.js +2 -2
- package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.d.ts +3 -3
- package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.js +5 -6
- package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
- package/dist/core/step-config/materialize-workflow-model.d.ts +3 -3
- package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
- package/dist/core/step-config/materialize-workflow-model.js +4 -4
- package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
- package/dist/core/step-config/resolve-job-execution-name.d.ts +1 -1
- package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -1
- package/dist/core/step-config/resolve-job-execution-name.js.map +1 -1
- package/dist/core/step-config/resolve-step-config.d.ts +4 -4
- package/dist/core/step-config/resolve-step-config.d.ts.map +1 -1
- package/dist/core/step-config/resolve-step-config.js +6 -6
- package/dist/core/step-config/resolve-step-config.js.map +1 -1
- package/dist/core/step-config/run.d.ts +1 -1
- package/dist/core/step-config/run.d.ts.map +1 -1
- package/dist/core/step-config/run.js.map +1 -1
- package/dist/core/workflow-run-creation.d.ts +3 -3
- package/dist/core/workflow-run-creation.d.ts.map +1 -1
- package/dist/core/workflow-run-creation.js +3 -4
- package/dist/core/workflow-run-creation.js.map +1 -1
- package/dist/db/db.d.ts +16 -4
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/job-listeners.d.ts +7 -1
- package/dist/db/job-listeners.d.ts.map +1 -1
- package/dist/db/job-listeners.js +10 -5
- package/dist/db/job-listeners.js.map +1 -1
- package/dist/db/runner-lease-table.d.ts +5 -5
- package/dist/db/runner-lease-table.d.ts.map +1 -1
- package/dist/db/runner-lease-table.js +3 -2
- package/dist/db/runner-lease-table.js.map +1 -1
- package/dist/db/schema/workflow-run-attempts.d.ts +9 -3
- package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -1
- package/dist/db/schema/workflow-run-attempts.js +2 -1
- package/dist/db/schema/workflow-run-attempts.js.map +1 -1
- package/dist/db/schema/workflow-runs.js +1 -1
- package/dist/db/schema/workflow-runs.js.map +1 -1
- package/dist/db/workflow-runs/job-executions.d.ts +5 -0
- package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
- package/dist/db/workflow-runs/job-executions.js +14 -7
- package/dist/db/workflow-runs/job-executions.js.map +1 -1
- package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
- package/dist/db/workflow-runs/jobs.js +3 -1
- package/dist/db/workflow-runs/jobs.js.map +1 -1
- package/dist/db/workflow-runs/run-create.d.ts +9 -2
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-create.js +12 -9
- package/dist/db/workflow-runs/run-create.js.map +1 -1
- package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-rerun.js +3 -1
- package/dist/db/workflow-runs/run-rerun.js.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -37
- package/dist/index.js.map +1 -1
- package/dist/presentation/dto/checkout-token.d.ts +14 -1
- package/dist/presentation/dto/checkout-token.d.ts.map +1 -1
- package/dist/presentation/dto/checkout-token.js.map +1 -1
- package/dist/presentation/index.d.ts +1 -1
- package/dist/presentation/index.d.ts.map +1 -1
- package/dist/presentation/index.js +1 -1
- package/dist/presentation/index.js.map +1 -1
- package/dist/presentation/inter-module.d.ts +18 -0
- package/dist/presentation/inter-module.d.ts.map +1 -0
- package/dist/presentation/inter-module.js +113 -0
- package/dist/presentation/inter-module.js.map +1 -0
- package/dist/presentation/routes/agent-runtime-config.d.ts +6 -1
- package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -1
- package/dist/presentation/routes/agent-runtime-config.js +59 -57
- package/dist/presentation/routes/agent-runtime-config.js.map +1 -1
- package/dist/presentation/routes/cancel-run.d.ts +2 -1
- package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
- package/dist/presentation/routes/cancel-run.js +37 -34
- package/dist/presentation/routes/cancel-run.js.map +1 -1
- package/dist/presentation/routes/checkout-token.d.ts +8 -1
- package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
- package/dist/presentation/routes/checkout-token.js +65 -47
- package/dist/presentation/routes/checkout-token.js.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts +2 -1
- package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
- package/dist/presentation/routes/get-run-aggregates.js +44 -53
- package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
- package/dist/presentation/routes/get-run.d.ts +2 -1
- package/dist/presentation/routes/get-run.d.ts.map +1 -1
- package/dist/presentation/routes/get-run.js +53 -50
- package/dist/presentation/routes/get-run.js.map +1 -1
- package/dist/presentation/routes/get-step-secrets.d.ts +3 -1
- package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -1
- package/dist/presentation/routes/get-step-secrets.js +72 -68
- package/dist/presentation/routes/get-step-secrets.js.map +1 -1
- package/dist/presentation/routes/index.d.ts +19 -2
- package/dist/presentation/routes/index.d.ts.map +1 -1
- package/dist/presentation/routes/index.js +38 -30
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/leased-step.d.ts +2 -0
- package/dist/presentation/routes/leased-step.d.ts.map +1 -1
- package/dist/presentation/routes/leased-step.js +1 -2
- package/dist/presentation/routes/leased-step.js.map +1 -1
- package/dist/presentation/routes/list-run-attempts.d.ts +2 -1
- package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
- package/dist/presentation/routes/list-run-attempts.js +29 -26
- package/dist/presentation/routes/list-run-attempts.js.map +1 -1
- package/dist/presentation/routes/list-runs.d.ts +2 -1
- package/dist/presentation/routes/list-runs.d.ts.map +1 -1
- package/dist/presentation/routes/list-runs.js +51 -60
- package/dist/presentation/routes/list-runs.js.map +1 -1
- package/dist/presentation/routes/next-step.d.ts +10 -1
- package/dist/presentation/routes/next-step.d.ts.map +1 -1
- package/dist/presentation/routes/next-step.js +64 -50
- package/dist/presentation/routes/next-step.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +10 -0
- package/dist/presentation/routes/project-access.d.ts.map +1 -0
- package/dist/presentation/routes/project-access.js +17 -0
- package/dist/presentation/routes/project-access.js.map +1 -0
- package/dist/presentation/routes/report-step.d.ts +2 -1
- package/dist/presentation/routes/report-step.d.ts.map +1 -1
- package/dist/presentation/routes/report-step.js +62 -61
- package/dist/presentation/routes/report-step.js.map +1 -1
- package/dist/presentation/routes/require-accessible-run.d.ts +3 -1
- package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
- package/dist/presentation/routes/require-accessible-run.js +3 -6
- package/dist/presentation/routes/require-accessible-run.js.map +1 -1
- package/dist/presentation/routes/rerun-run.d.ts +2 -1
- package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
- package/dist/presentation/routes/rerun-run.js +46 -43
- package/dist/presentation/routes/rerun-run.js.map +1 -1
- package/dist/temporal/activities/index.d.ts +44 -9
- package/dist/temporal/activities/index.d.ts.map +1 -1
- package/dist/temporal/activities/index.js +13 -9
- package/dist/temporal/activities/index.js.map +1 -1
- package/dist/temporal/activities/orchestration-activities.d.ts +20 -11
- package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
- package/dist/temporal/activities/orchestration-activities.js +48 -33
- package/dist/temporal/activities/orchestration-activities.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +28 -21
- package/src/core/agent-defaults.test.ts +28 -0
- package/src/core/agent-defaults.ts +36 -0
- package/src/core/agent-tool-capability-warning.test.ts +36 -11
- package/src/core/agent-tool-capability-warning.ts +27 -25
- package/src/core/agent-tools.ts +33 -36
- package/src/core/checkout.test.ts +38 -25
- package/src/core/checkout.ts +41 -14
- package/src/core/entities/workflow-run-attempt.ts +1 -1
- package/src/core/job-execution.ts +19 -9
- package/src/core/job-transition/derive-job-execution-outputs.ts +1 -1
- package/src/core/job-transition/derive-job-success.ts +1 -1
- package/src/core/listener-execution-materialization.test.ts +4 -2
- package/src/core/listener-execution-materialization.ts +6 -9
- package/src/core/run-workflow.test.ts +43 -38
- package/src/core/run-workflow.ts +26 -9
- package/src/core/step-config/agent.ts +24 -26
- package/src/core/step-config/complete-step-dispatch-config.test.ts +22 -23
- package/src/core/step-config/complete-step-dispatch-config.ts +6 -6
- package/src/core/step-config/materialize-job-execution-steps.test.ts +34 -23
- package/src/core/step-config/materialize-job-execution-steps.ts +38 -39
- package/src/core/step-config/materialize-workflow-model.test.ts +94 -82
- package/src/core/step-config/materialize-workflow-model.ts +31 -29
- package/src/core/step-config/resolve-job-execution-name.ts +1 -1
- package/src/core/step-config/resolve-step-config.ts +11 -9
- package/src/core/step-config/run.ts +1 -1
- package/src/core/workflow-run-creation.test.ts +14 -10
- package/src/core/workflow-run-creation.ts +6 -9
- package/src/db/job-listeners.ts +20 -5
- package/src/db/runner-lease-table.ts +2 -2
- package/src/db/schema/workflow-run-attempts.ts +7 -3
- package/src/db/schema/workflow-runs.ts +1 -1
- package/src/db/workflow-runs/job-executions.ts +15 -1
- package/src/db/workflow-runs/jobs.ts +4 -1
- package/src/db/workflow-runs/run-create.test.ts +7 -1
- package/src/db/workflow-runs/run-create.ts +25 -15
- package/src/db/workflow-runs/run-rerun.test.ts +1 -1
- package/src/db/workflow-runs/run-rerun.ts +6 -3
- package/src/index.ts +75 -33
- package/src/presentation/dto/checkout-token.ts +7 -1
- package/src/presentation/index.ts +1 -1
- package/src/presentation/inter-module.test.ts +149 -0
- package/src/presentation/inter-module.ts +132 -0
- package/src/presentation/routes/agent-runtime-config.test.ts +53 -10
- package/src/presentation/routes/agent-runtime-config.ts +89 -64
- package/src/presentation/routes/cancel-run.test.ts +10 -20
- package/src/presentation/routes/cancel-run.ts +30 -27
- package/src/presentation/routes/checkout-token.test.ts +52 -33
- package/src/presentation/routes/checkout-token.ts +109 -49
- package/src/presentation/routes/get-run-aggregates.test.ts +13 -7
- package/src/presentation/routes/get-run-aggregates.ts +54 -57
- package/src/presentation/routes/get-run.test.ts +10 -18
- package/src/presentation/routes/get-run.ts +51 -48
- package/src/presentation/routes/get-step-secrets.test.ts +29 -7
- package/src/presentation/routes/get-step-secrets.ts +72 -61
- package/src/presentation/routes/index.test.ts +16 -1
- package/src/presentation/routes/index.ts +54 -29
- package/src/presentation/routes/leased-step.ts +3 -2
- package/src/presentation/routes/list-run-attempts.test.ts +9 -19
- package/src/presentation/routes/list-run-attempts.ts +21 -18
- package/src/presentation/routes/list-runs.test.ts +13 -7
- package/src/presentation/routes/list-runs.ts +64 -67
- package/src/presentation/routes/next-step.test.ts +30 -11
- package/src/presentation/routes/next-step.ts +68 -48
- package/src/presentation/routes/project-access.ts +16 -0
- package/src/presentation/routes/report-step.test.ts +18 -2
- package/src/presentation/routes/report-step.ts +51 -49
- package/src/presentation/routes/require-accessible-run.ts +5 -2
- package/src/presentation/routes/rerun-run.test.ts +9 -19
- package/src/presentation/routes/rerun-run.ts +39 -36
- package/src/temporal/activities/index.ts +32 -12
- package/src/temporal/activities/orchestration-activities.test.ts +10 -8
- package/src/temporal/activities/orchestration-activities.ts +74 -50
- package/src/temporal/workflows/job-execution-orchestration.test.ts +47 -2
- package/test/env.ts +1 -3
- package/test/factories/project.ts +10 -5
- package/test/factories/workflow-model.test.ts +5 -1
- package/test/factories/workflow-model.ts +1 -1
- package/test/factories/workflow-run.ts +1 -1
- package/test/fixtures/agent-inter-module.ts +27 -0
- package/test/fixtures/annotations-inter-module.ts +5 -0
- package/test/fixtures/auth-inter-module.ts +22 -0
- package/test/fixtures/lease-token.ts +2 -1
- package/test/fixtures/projects-inter-module.ts +8 -0
- package/test/fixtures/runners-inter-module.ts +52 -0
- package/test/fixtures/secrets-inter-module.ts +61 -0
- package/test/globalSetup.ts +11 -11
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/core/source-control.d.ts +0 -5
- package/dist/core/source-control.d.ts.map +0 -1
- package/dist/core/source-control.js +0 -19
- package/dist/core/source-control.js.map +0 -1
- package/src/core/source-control.test.ts +0 -17
- package/src/core/source-control.ts +0 -22
- package/src/temporal/workflows/job-execution-orchestration-timeout.test.ts +0 -165
|
@@ -4,32 +4,35 @@ import { z } from 'zod';
|
|
|
4
4
|
import { listRunAttempts } from '#db/index.js';
|
|
5
5
|
import { toRunAttemptDto } from '#presentation/dto/index.js';
|
|
6
6
|
import { requireAccessibleRun } from './require-accessible-run.js';
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
export function listRunAttemptsRoute(projects) {
|
|
8
|
+
return defineRoute({
|
|
9
|
+
method: 'GET',
|
|
10
|
+
path: '/:id/attempts',
|
|
11
|
+
description: 'List attempts in a workflow run lineage',
|
|
12
|
+
schema: {
|
|
13
|
+
params: z.object({
|
|
14
|
+
id: z.string().uuid()
|
|
15
|
+
}),
|
|
16
|
+
response: {
|
|
17
|
+
200: workflowRunAttemptsResponseSchema
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
handler: async (request)=>{
|
|
21
|
+
const { id } = request.params;
|
|
22
|
+
const run = await requireAccessibleRun({
|
|
23
|
+
request,
|
|
24
|
+
id,
|
|
25
|
+
projects
|
|
26
|
+
});
|
|
27
|
+
const attempts = await listRunAttempts({
|
|
28
|
+
workflowRunId: run.id,
|
|
29
|
+
projectId: run.projectId
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
attempts: attempts.map(toRunAttemptDto)
|
|
33
|
+
};
|
|
17
34
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
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
|
-
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
34
37
|
|
|
35
38
|
//# sourceMappingURL=list-run-attempts.js.map
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-run-attempts.ts"],"sourcesContent":["import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {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 function listRunAttemptsRoute(projects: ProjectsModuleClient) {\n return 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, projects});\n const attempts = await listRunAttempts({workflowRunId: run.id, projectId: run.projectId});\n\n return {attempts: attempts.map(toRunAttemptDto)};\n },\n });\n}\n"],"names":["workflowRunAttemptsResponseSchema","defineRoute","z","listRunAttempts","toRunAttemptDto","requireAccessibleRun","listRunAttemptsRoute","projects","method","path","description","schema","params","object","id","string","uuid","response","handler","request","run","attempts","workflowRunId","projectId","map"],"mappings":"AACA,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,SAASC,qBAAqBC,QAA8B;IACjE,OAAON,YAAY;QACjBO,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQV,EAAEW,MAAM,CAAC;gBACfC,IAAIZ,EAAEa,MAAM,GAAGC,IAAI;YACrB;YACAC,UAAU;gBACR,KAAKjB;YACP;QACF;QACAkB,SAAS,OAAOC;YACd,MAAM,EAACL,EAAE,EAAC,GAAGK,QAAQP,MAAM;YAC3B,MAAMQ,MAAM,MAAMf,qBAAqB;gBAACc;gBAASL;gBAAIP;YAAQ;YAC7D,MAAMc,WAAW,MAAMlB,gBAAgB;gBAACmB,eAAeF,IAAIN,EAAE;gBAAES,WAAWH,IAAIG,SAAS;YAAA;YAEvF,OAAO;gBAACF,UAAUA,SAASG,GAAG,CAACpB;YAAgB;QACjD;IACF;AACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
|
+
export declare function listRunsRoute(projects: ProjectsModuleClient): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=list-runs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-runs.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-runs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-runs.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-runs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAYpE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,oBAAoB,mDAmE3D"}
|
|
@@ -1,70 +1,61 @@
|
|
|
1
|
-
import { ProjectNotFoundError, requireProjectAccess } from '@shipfox/api-projects';
|
|
2
1
|
import { workflowRunListQuerySchema, workflowRunListResponseSchema } from '@shipfox/api-workflows-dto';
|
|
3
2
|
import { decodeTimestampIdCursor, encodeTimestampIdCursor } from '@shipfox/node-drizzle';
|
|
4
3
|
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
4
|
import { logger } from '@shipfox/node-opentelemetry';
|
|
6
5
|
import { listWorkflowRuns } from '#db/index.js';
|
|
7
6
|
import { toRunDto } from '#presentation/dto/index.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
7
|
+
import { requireProjectAccess } from './project-access.js';
|
|
8
|
+
export function listRunsRoute(projects) {
|
|
9
|
+
return defineRoute({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/',
|
|
12
|
+
description: 'List workflow runs for a project',
|
|
13
|
+
schema: {
|
|
14
|
+
querystring: workflowRunListQuerySchema,
|
|
15
|
+
response: {
|
|
16
|
+
200: workflowRunListResponseSchema
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
handler: async (request)=>{
|
|
20
|
+
const startedAt = performance.now();
|
|
21
|
+
const { project_id: projectId, limit, cursor, status, definition_id: definitionId, trigger_source: triggerSource, created_from: createdFrom, created_to: createdTo } = request.query;
|
|
22
|
+
const decodedCursor = decodeTimestampIdCursor(cursor);
|
|
23
|
+
if (cursor && !decodedCursor) {
|
|
24
|
+
throw new ClientError('Invalid cursor', 'invalid-cursor', {
|
|
25
|
+
status: 400
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const project = await requireProjectAccess(request, projectId, projects);
|
|
29
|
+
const filters = {
|
|
30
|
+
status,
|
|
31
|
+
definitionId,
|
|
32
|
+
triggerSource,
|
|
33
|
+
createdFrom: createdFrom ? new Date(createdFrom) : undefined,
|
|
34
|
+
createdTo: createdTo ? new Date(createdTo) : undefined
|
|
35
|
+
};
|
|
36
|
+
const result = await listWorkflowRuns({
|
|
37
|
+
projectId: project.id,
|
|
38
|
+
limit,
|
|
39
|
+
cursor: decodedCursor,
|
|
40
|
+
filters,
|
|
41
|
+
includeTotal: !decodedCursor
|
|
33
42
|
});
|
|
43
|
+
logger().info({
|
|
44
|
+
projectId: project.id,
|
|
45
|
+
filterKeys: Object.entries(filters).filter(([, value])=>value !== undefined).map(([key])=>key),
|
|
46
|
+
limit,
|
|
47
|
+
cursorPresent: Boolean(cursor),
|
|
48
|
+
resultCount: result.runs.length,
|
|
49
|
+
nextCursorPresent: Boolean(result.nextCursor),
|
|
50
|
+
durationMs: Math.round(performance.now() - startedAt)
|
|
51
|
+
}, 'Listed workflow runs');
|
|
52
|
+
return {
|
|
53
|
+
runs: result.runs.map((run)=>toRunDto(run)),
|
|
54
|
+
next_cursor: result.nextCursor ? encodeTimestampIdCursor(result.nextCursor) : null,
|
|
55
|
+
filtered_total_count: result.filteredTotalCount
|
|
56
|
+
};
|
|
34
57
|
}
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
69
60
|
|
|
70
61
|
//# sourceMappingURL=list-runs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/list-runs.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-runs.ts"],"sourcesContent":["import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\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';\nimport {requireProjectAccess} from './project-access.js';\n\nexport function listRunsRoute(projects: ProjectsModuleClient) {\n return 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 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, projects);\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}\n"],"names":["workflowRunListQuerySchema","workflowRunListResponseSchema","decodeTimestampIdCursor","encodeTimestampIdCursor","ClientError","defineRoute","logger","listWorkflowRuns","toRunDto","requireProjectAccess","listRunsRoute","projects","method","path","description","schema","querystring","response","handler","request","startedAt","performance","now","project_id","projectId","limit","cursor","status","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":"AACA,SACEA,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;AACpD,SAAQC,oBAAoB,QAAO,sBAAsB;AAEzD,OAAO,SAASC,cAAcC,QAA8B;IAC1D,OAAON,YAAY;QACjBO,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,aAAahB;YACbiB,UAAU;gBACR,KAAKhB;YACP;QACF;QACAiB,SAAS,OAAOC;YACd,MAAMC,YAAYC,YAAYC,GAAG;YACjC,MAAM,EACJC,YAAYC,SAAS,EACrBC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,eAAeC,YAAY,EAC3BC,gBAAgBC,aAAa,EAC7BC,cAAcC,WAAW,EACzBC,YAAYC,SAAS,EACtB,GAAGhB,QAAQiB,KAAK;YACjB,MAAMC,gBAAgBnC,wBAAwBwB;YAC9C,IAAIA,UAAU,CAACW,eAAe;gBAC5B,MAAM,IAAIjC,YAAY,kBAAkB,kBAAkB;oBAACuB,QAAQ;gBAAG;YACxE;YAEA,MAAMW,UAAU,MAAM7B,qBAAqBU,SAASK,WAAWb;YAE/D,MAAM4B,UAAU;gBACdZ;gBACAE;gBACAE;gBACAE,aAAaA,cAAc,IAAIO,KAAKP,eAAeQ;gBACnDN,WAAWA,YAAY,IAAIK,KAAKL,aAAaM;YAC/C;YACA,MAAMC,SAAS,MAAMnC,iBAAiB;gBACpCiB,WAAWc,QAAQK,EAAE;gBACrBlB;gBACAC,QAAQW;gBACRE;gBACAK,cAAc,CAACP;YACjB;YAEA/B,SAASuC,IAAI,CACX;gBACErB,WAAWc,QAAQK,EAAE;gBACrBG,YAAYC,OAAOC,OAAO,CAACT,SACxBU,MAAM,CAAC,CAAC,GAAGC,MAAM,GAAKA,UAAUT,WAChCU,GAAG,CAAC,CAAC,CAACC,IAAI,GAAKA;gBAClB3B;gBACA4B,eAAeC,QAAQ5B;gBACvB6B,aAAab,OAAOc,IAAI,CAACC,MAAM;gBAC/BC,mBAAmBJ,QAAQZ,OAAOiB,UAAU;gBAC5CC,YAAYC,KAAKC,KAAK,CAACzC,YAAYC,GAAG,KAAKF;YAC7C,GACA;YAGF,OAAO;gBACLoC,MAAMd,OAAOc,IAAI,CAACL,GAAG,CAAC,CAACY,MAAQvD,SAASuD;gBACxCC,aAAatB,OAAOiB,UAAU,GAAGxD,wBAAwBuC,OAAOiB,UAAU,IAAI;gBAC9EM,sBAAsBvB,OAAOwB,kBAAkB;YACjD;QACF;IACF;AACF"}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AnnotationsInterModuleClient } from '@shipfox/annotations-dto/inter-module';
|
|
2
|
+
import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
|
|
3
|
+
import type { AuthInterModuleClient } from '@shipfox/api-auth-dto/inter-module';
|
|
4
|
+
import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
|
|
5
|
+
export declare function createNextStepRoute(params: {
|
|
6
|
+
agent: AgentInterModuleClient;
|
|
7
|
+
annotations: AnnotationsInterModuleClient;
|
|
8
|
+
auth: AuthInterModuleClient;
|
|
9
|
+
runners: RunnersInterModuleClient;
|
|
10
|
+
}): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
11
|
//# sourceMappingURL=next-step.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/next-step.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"next-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/next-step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,uCAAuC,CAAC;AACxF,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAQpF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,4BAA4B,CAAC;IAC1C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,wBAAwB,CAAC;CACnC,mDAgEA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { issueJobLeaseToken, jobLeaseParamsFrom } from '@shipfox/api-auth';
|
|
2
1
|
import { requireLeasedJobContext } from '@shipfox/api-auth-context';
|
|
3
2
|
import { nextStepResponseSchema } from '@shipfox/api-workflows-dto';
|
|
4
3
|
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
@@ -6,60 +5,75 @@ import { warnAgentToolCapabilityMismatchOnDispatch } from '#core/agent-tool-capa
|
|
|
6
5
|
import { JobLeaseNotActiveError, JobNotFoundError } from '#core/errors.js';
|
|
7
6
|
import { nextStepForLeasedJobExecution } from '#core/job-execution.js';
|
|
8
7
|
import { toStepDto } from '#presentation/dto/step.js';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
export function createNextStepRoute(params) {
|
|
9
|
+
return 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
|
+
agent: params.agent
|
|
27
38
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}));
|
|
43
|
-
if (next.dispatched) {
|
|
44
|
-
await warnAgentToolCapabilityMismatchOnDispatch({
|
|
45
|
-
leaseIdentity: leasedJob,
|
|
46
|
-
step: next.step
|
|
39
|
+
if (next.kind === 'step') {
|
|
40
|
+
const { token: leaseToken } = await params.auth.mintJobLeaseToken({
|
|
41
|
+
workflowRunId: leasedJob.workflowRunId,
|
|
42
|
+
...leasedJob.workflowRunAttempt === undefined ? {} : {
|
|
43
|
+
workflowRunAttempt: leasedJob.workflowRunAttempt
|
|
44
|
+
},
|
|
45
|
+
workflowRunAttemptId: leasedJob.workflowRunAttemptId,
|
|
46
|
+
jobId: leasedJob.jobId,
|
|
47
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
48
|
+
projectId: leasedJob.projectId,
|
|
49
|
+
workspaceId: leasedJob.workspaceId,
|
|
50
|
+
runnerSessionId: leasedJob.runnerSessionId,
|
|
51
|
+
currentStepId: next.step.id,
|
|
52
|
+
currentStepAttempt: next.step.currentAttempt
|
|
47
53
|
});
|
|
54
|
+
if (next.dispatched) {
|
|
55
|
+
await warnAgentToolCapabilityMismatchOnDispatch({
|
|
56
|
+
annotations: params.annotations,
|
|
57
|
+
runners: params.runners,
|
|
58
|
+
leaseIdentity: leasedJob,
|
|
59
|
+
step: next.step
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// The runner echoes this back on report so a stale report from a superseded
|
|
63
|
+
// attempt is ignored.
|
|
64
|
+
return {
|
|
65
|
+
kind: 'step',
|
|
66
|
+
step: toStepDto(next.step),
|
|
67
|
+
attempt: next.step.currentAttempt,
|
|
68
|
+
lease_token: leaseToken
|
|
69
|
+
};
|
|
48
70
|
}
|
|
49
|
-
// The runner echoes this back on report so a stale report from a superseded
|
|
50
|
-
// attempt is ignored.
|
|
51
71
|
return {
|
|
52
|
-
kind: '
|
|
53
|
-
|
|
54
|
-
attempt: next.step.currentAttempt,
|
|
55
|
-
lease_token: leaseToken
|
|
72
|
+
kind: 'done',
|
|
73
|
+
status: next.status
|
|
56
74
|
};
|
|
57
75
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
status: next.status
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
64
78
|
|
|
65
79
|
//# sourceMappingURL=next-step.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/next-step.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/next-step.ts"],"sourcesContent":["import type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\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 function createNextStepRoute(params: {\n agent: AgentInterModuleClient;\n annotations: AnnotationsInterModuleClient;\n auth: AuthInterModuleClient;\n runners: RunnersInterModuleClient;\n}) {\n return 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 const next = await nextStepForLeasedJobExecution({\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n runnerSessionId: leasedJob.runnerSessionId,\n agent: params.agent,\n });\n\n if (next.kind === 'step') {\n const {token: leaseToken} = await params.auth.mintJobLeaseToken({\n workflowRunId: leasedJob.workflowRunId,\n ...(leasedJob.workflowRunAttempt === undefined\n ? {}\n : {workflowRunAttempt: leasedJob.workflowRunAttempt}),\n workflowRunAttemptId: leasedJob.workflowRunAttemptId,\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n projectId: leasedJob.projectId,\n workspaceId: leasedJob.workspaceId,\n runnerSessionId: leasedJob.runnerSessionId,\n currentStepId: next.step.id,\n currentStepAttempt: next.step.currentAttempt,\n });\n if (next.dispatched) {\n await warnAgentToolCapabilityMismatchOnDispatch({\n annotations: params.annotations,\n runners: params.runners,\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}\n"],"names":["requireLeasedJobContext","nextStepResponseSchema","ClientError","defineRoute","warnAgentToolCapabilityMismatchOnDispatch","JobLeaseNotActiveError","JobNotFoundError","nextStepForLeasedJobExecution","toStepDto","createNextStepRoute","params","method","path","description","schema","response","errorHandler","error","message","status","handler","request","leasedJob","next","jobId","jobExecutionId","runnerSessionId","agent","kind","token","leaseToken","auth","mintJobLeaseToken","workflowRunId","workflowRunAttempt","undefined","workflowRunAttemptId","projectId","workspaceId","currentStepId","step","id","currentStepAttempt","currentAttempt","dispatched","annotations","runners","leaseIdentity","attempt","lease_token"],"mappings":"AAEA,SAAQA,uBAAuB,QAAO,4BAA4B;AAGlE,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,SAASC,oBAAoBC,MAKnC;IACC,OAAOP,YAAY;QACjBQ,QAAQ;QACRC,MAAM;QACNC,aACE;QACFC,QAAQ;YACNC,UAAU;gBACR,KAAKd;YACP;QACF;QACAe,cAAc,CAACC;YACb,IAAIA,iBAAiBX,kBAAkB;gBACrC,MAAM,IAAIJ,YAAYe,MAAMC,OAAO,EAAE,iBAAiB;oBAACC,QAAQ;gBAAG;YACpE;YACA,IAAIF,iBAAiBZ,wBAAwB;gBAC3C,MAAM,IAAIH,YAAY,iCAAiC,oBAAoB;oBAACiB,QAAQ;gBAAG;YACzF;YACA,MAAMF;QACR;QACAG,SAAS,OAAOC;YACd,MAAMC,YAAYtB,wBAAwBqB;YAC1C,MAAME,OAAO,MAAMhB,8BAA8B;gBAC/CiB,OAAOF,UAAUE,KAAK;gBACtBC,gBAAgBH,UAAUG,cAAc;gBACxCC,iBAAiBJ,UAAUI,eAAe;gBAC1CC,OAAOjB,OAAOiB,KAAK;YACrB;YAEA,IAAIJ,KAAKK,IAAI,KAAK,QAAQ;gBACxB,MAAM,EAACC,OAAOC,UAAU,EAAC,GAAG,MAAMpB,OAAOqB,IAAI,CAACC,iBAAiB,CAAC;oBAC9DC,eAAeX,UAAUW,aAAa;oBACtC,GAAIX,UAAUY,kBAAkB,KAAKC,YACjC,CAAC,IACD;wBAACD,oBAAoBZ,UAAUY,kBAAkB;oBAAA,CAAC;oBACtDE,sBAAsBd,UAAUc,oBAAoB;oBACpDZ,OAAOF,UAAUE,KAAK;oBACtBC,gBAAgBH,UAAUG,cAAc;oBACxCY,WAAWf,UAAUe,SAAS;oBAC9BC,aAAahB,UAAUgB,WAAW;oBAClCZ,iBAAiBJ,UAAUI,eAAe;oBAC1Ca,eAAehB,KAAKiB,IAAI,CAACC,EAAE;oBAC3BC,oBAAoBnB,KAAKiB,IAAI,CAACG,cAAc;gBAC9C;gBACA,IAAIpB,KAAKqB,UAAU,EAAE;oBACnB,MAAMxC,0CAA0C;wBAC9CyC,aAAanC,OAAOmC,WAAW;wBAC/BC,SAASpC,OAAOoC,OAAO;wBACvBC,eAAezB;wBACfkB,MAAMjB,KAAKiB,IAAI;oBACjB;gBACF;gBACA,4EAA4E;gBAC5E,sBAAsB;gBACtB,OAAO;oBACLZ,MAAM;oBACNY,MAAMhC,UAAUe,KAAKiB,IAAI;oBACzBQ,SAASzB,KAAKiB,IAAI,CAACG,cAAc;oBACjCM,aAAanB;gBACf;YACF;YACA,OAAO;gBAACF,MAAM;gBAAiBT,QAAQI,KAAKJ,MAAM;YAAA;QACpD;IACF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
|
+
import type { FastifyRequest } from 'fastify';
|
|
3
|
+
export declare function requireProjectAccess(request: FastifyRequest, projectId: string, projects: ProjectsModuleClient): Promise<{
|
|
4
|
+
id: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
sourceConnectionId: string;
|
|
7
|
+
sourceExternalRepositoryId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=project-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-access.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/project-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,oBAAoB;;;;;;GAO/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { requireWorkspaceAccess } from '@shipfox/api-auth-context';
|
|
2
|
+
import { ClientError } from '@shipfox/node-fastify';
|
|
3
|
+
export async function requireProjectAccess(request, projectId, projects) {
|
|
4
|
+
const result = await projects.getProjectById({
|
|
5
|
+
projectId
|
|
6
|
+
});
|
|
7
|
+
if (result.project === null) throw new ClientError('Project not found', 'project-not-found', {
|
|
8
|
+
status: 404
|
|
9
|
+
});
|
|
10
|
+
requireWorkspaceAccess({
|
|
11
|
+
request,
|
|
12
|
+
workspaceId: result.project.workspaceId
|
|
13
|
+
});
|
|
14
|
+
return result.project;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=project-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/project-access.ts"],"sourcesContent":["import {requireWorkspaceAccess} from '@shipfox/api-auth-context';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {ClientError} from '@shipfox/node-fastify';\nimport type {FastifyRequest} from 'fastify';\n\nexport async function requireProjectAccess(\n request: FastifyRequest,\n projectId: string,\n projects: ProjectsModuleClient,\n) {\n const result = await projects.getProjectById({projectId});\n if (result.project === null)\n throw new ClientError('Project not found', 'project-not-found', {status: 404});\n requireWorkspaceAccess({request, workspaceId: result.project.workspaceId});\n return result.project;\n}\n"],"names":["requireWorkspaceAccess","ClientError","requireProjectAccess","request","projectId","projects","result","getProjectById","project","status","workspaceId"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,4BAA4B;AAEjE,SAAQC,WAAW,QAAO,wBAAwB;AAGlD,OAAO,eAAeC,qBACpBC,OAAuB,EACvBC,SAAiB,EACjBC,QAA8B;IAE9B,MAAMC,SAAS,MAAMD,SAASE,cAAc,CAAC;QAACH;IAAS;IACvD,IAAIE,OAAOE,OAAO,KAAK,MACrB,MAAM,IAAIP,YAAY,qBAAqB,qBAAqB;QAACQ,QAAQ;IAAG;IAC9ET,uBAAuB;QAACG;QAASO,aAAaJ,OAAOE,OAAO,CAACE,WAAW;IAAA;IACxE,OAAOJ,OAAOE,OAAO;AACvB"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
|
|
2
|
+
export declare function createReportStepRoute(runners: RunnersInterModuleClient): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=report-step.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/report-step.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"report-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/report-step.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAQpF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,wBAAwB,mDAqDtE"}
|
|
@@ -1,73 +1,74 @@
|
|
|
1
1
|
import { requireLeasedJobContext } from '@shipfox/api-auth-context';
|
|
2
|
-
import { isJobLeaseActive } from '@shipfox/api-runners';
|
|
3
2
|
import { reportStepBodySchema, reportStepResponseSchema } from '@shipfox/api-workflows-dto';
|
|
4
3
|
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
4
|
import { z } from 'zod';
|
|
6
5
|
import { StepAttemptAheadError, StepNotFoundError, StepNotRunningError } from '#core/errors.js';
|
|
7
6
|
import { recordStepResult } from '#core/job-execution.js';
|
|
8
7
|
import { fromStepErrorDto } from '#presentation/dto/step.js';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
export function createReportStepRoute(runners) {
|
|
9
|
+
return 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 { active: leaseIsActive } = await runners.getLeaseState({
|
|
44
|
+
jobId: leasedJob.jobId,
|
|
45
|
+
jobExecutionId: leasedJob.jobExecutionId,
|
|
46
|
+
runnerSessionId: leasedJob.runnerSessionId
|
|
31
47
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
throw new ClientError('Job lease is no longer active', 'lease-not-active', {
|
|
50
|
-
status: 404
|
|
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
|
+
} : {}
|
|
51
65
|
});
|
|
66
|
+
return {
|
|
67
|
+
ok: true,
|
|
68
|
+
cancel: outcome.jobFinished && outcome.status === 'failed'
|
|
69
|
+
};
|
|
52
70
|
}
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
72
73
|
|
|
73
74
|
//# sourceMappingURL=report-step.js.map
|