@shipfox/api-workflows 5.0.0 → 6.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 +4 -4
- package/CHANGELOG.md +72 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/get-run-aggregates.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/get-run-aggregates.ts"],"sourcesContent":["import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {\n workflowRunAggregatesQuerySchema,\n workflowRunAggregatesResponseSchema,\n} from '@shipfox/api-workflows-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {getWorkflowRunAggregates} from '#db/index.js';\nimport {requireProjectAccess} from './project-access.js';\n\nexport function getRunAggregatesRoute(projects: ProjectsModuleClient) {\n return defineRoute({\n method: 'GET',\n path: '/aggregates',\n description: 'Get faceted workflow run counts for a project',\n schema: {\n querystring: workflowRunAggregatesQuerySchema,\n response: {\n 200: workflowRunAggregatesResponseSchema,\n },\n },\n handler: async (request) => {\n const startedAt = performance.now();\n const {\n project_id: projectId,\n status,\n definition_id: definitionId,\n trigger_source: triggerSource,\n created_from: createdFrom,\n created_to: createdTo,\n } = request.query;\n\n const project = await requireProjectAccess(request, projectId, projects);\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 aggregates = await getWorkflowRunAggregates({projectId: project.id, filters});\n\n logger().info(\n {\n projectId: project.id,\n filterKeys: Object.entries(filters)\n .filter(([, value]) => value !== undefined)\n .map(([key]) => key),\n aggregateBucketSizes: {\n status: aggregates.status.length,\n triggerSource: aggregates.triggerSource.length,\n workflow: aggregates.workflow.length,\n },\n durationMs: Math.round(performance.now() - startedAt),\n },\n 'Aggregated workflow runs',\n );\n\n return {\n status: aggregates.status,\n trigger_source: aggregates.triggerSource,\n workflow: aggregates.workflow,\n };\n },\n });\n}\n"],"names":["workflowRunAggregatesQuerySchema","workflowRunAggregatesResponseSchema","defineRoute","logger","getWorkflowRunAggregates","requireProjectAccess","getRunAggregatesRoute","projects","method","path","description","schema","querystring","response","handler","request","startedAt","performance","now","project_id","projectId","status","definition_id","definitionId","trigger_source","triggerSource","created_from","createdFrom","created_to","createdTo","query","project","filters","Date","undefined","aggregates","id","info","filterKeys","Object","entries","filter","value","map","key","aggregateBucketSizes","length","workflow","durationMs","Math","round"],"mappings":"AACA,SACEA,gCAAgC,EAChCC,mCAAmC,QAC9B,6BAA6B;AACpC,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,wBAAwB,QAAO,eAAe;AACtD,SAAQC,oBAAoB,QAAO,sBAAsB;AAEzD,OAAO,SAASC,sBAAsBC,QAA8B;IAClE,OAAOL,YAAY;QACjBM,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,aAAaZ;YACba,UAAU;gBACR,KAAKZ;YACP;QACF;QACAa,SAAS,OAAOC;YACd,MAAMC,YAAYC,YAAYC,GAAG;YACjC,MAAM,EACJC,YAAYC,SAAS,EACrBC,MAAM,EACNC,eAAeC,YAAY,EAC3BC,gBAAgBC,aAAa,EAC7BC,cAAcC,WAAW,EACzBC,YAAYC,SAAS,EACtB,GAAGd,QAAQe,KAAK;YAEjB,MAAMC,UAAU,MAAM1B,qBAAqBU,SAASK,WAAWb;YAC/D,MAAMyB,UAAU;gBACdX;gBACAE;gBACAE;gBACAE,aAAaA,cAAc,IAAIM,KAAKN,eAAeO;gBACnDL,WAAWA,YAAY,IAAII,KAAKJ,aAAaK;YAC/C;YACA,MAAMC,aAAa,MAAM/B,yBAAyB;gBAACgB,WAAWW,QAAQK,EAAE;gBAAEJ;YAAO;YAEjF7B,SAASkC,IAAI,CACX;gBACEjB,WAAWW,QAAQK,EAAE;gBACrBE,YAAYC,OAAOC,OAAO,CAACR,SACxBS,MAAM,CAAC,CAAC,GAAGC,MAAM,GAAKA,UAAUR,WAChCS,GAAG,CAAC,CAAC,CAACC,IAAI,GAAKA;gBAClBC,sBAAsB;oBACpBxB,QAAQc,WAAWd,MAAM,CAACyB,MAAM;oBAChCrB,eAAeU,WAAWV,aAAa,CAACqB,MAAM;oBAC9CC,UAAUZ,WAAWY,QAAQ,CAACD,MAAM;gBACtC;gBACAE,YAAYC,KAAKC,KAAK,CAACjC,YAAYC,GAAG,KAAKF;YAC7C,GACA;YAGF,OAAO;gBACLK,QAAQc,WAAWd,MAAM;gBACzBG,gBAAgBW,WAAWV,aAAa;gBACxCsB,UAAUZ,WAAWY,QAAQ;YAC/B;QACF;IACF;AACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
|
+
export declare function getRunRoute(projects: ProjectsModuleClient): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=get-run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-run.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-run.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAepE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,oBAAoB,mDAqDzD"}
|
|
@@ -4,57 +4,60 @@ import { z } from 'zod';
|
|
|
4
4
|
import { getWorkflowRunDetail } from '#db/index.js';
|
|
5
5
|
import { toJobDto, toJobExecutionDto, toRunAttemptDto, toRunDto, toStepAttemptDto, toStepDto } 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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!run) {
|
|
30
|
-
throw new ClientError('Run not found', 'not-found', {
|
|
31
|
-
status: 404
|
|
7
|
+
export function getRunRoute(projects) {
|
|
8
|
+
return defineRoute({
|
|
9
|
+
method: 'GET',
|
|
10
|
+
path: '/:id',
|
|
11
|
+
description: 'Get a workflow run by ID with jobs and steps',
|
|
12
|
+
schema: {
|
|
13
|
+
params: z.object({
|
|
14
|
+
id: z.string().uuid()
|
|
15
|
+
}),
|
|
16
|
+
querystring: z.object({
|
|
17
|
+
attempt: z.coerce.number().int().positive().optional()
|
|
18
|
+
}),
|
|
19
|
+
response: {
|
|
20
|
+
200: workflowRunDetailResponseSchema
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
handler: async (request)=>{
|
|
24
|
+
const { id } = request.params;
|
|
25
|
+
await requireAccessibleRun({
|
|
26
|
+
request,
|
|
27
|
+
id,
|
|
28
|
+
projects
|
|
32
29
|
});
|
|
30
|
+
const run = await getWorkflowRunDetail(id, request.query.attempt);
|
|
31
|
+
if (!run) {
|
|
32
|
+
throw new ClientError('Run not found', 'not-found', {
|
|
33
|
+
status: 404
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const jobDtos = run.jobs.map((job)=>({
|
|
37
|
+
...toJobDto(job),
|
|
38
|
+
job_executions: job.jobExecutions.map((jobExecution)=>({
|
|
39
|
+
...toJobExecutionDto(jobExecution),
|
|
40
|
+
steps: jobExecution.steps.map((step)=>{
|
|
41
|
+
const attempts = step.attempts.map(toStepAttemptDto);
|
|
42
|
+
const latestTerminalAttempt = attempts.filter((attempt)=>attempt.status !== 'running').at(-1);
|
|
43
|
+
return {
|
|
44
|
+
...toStepDto(step),
|
|
45
|
+
exit_code: latestTerminalAttempt?.exit_code ?? null,
|
|
46
|
+
outputs: latestTerminalAttempt?.outputs ?? null,
|
|
47
|
+
response: latestTerminalAttempt?.response ?? null,
|
|
48
|
+
gate_result: latestTerminalAttempt?.gate_result ?? null,
|
|
49
|
+
attempts
|
|
50
|
+
};
|
|
51
|
+
})
|
|
52
|
+
}))
|
|
53
|
+
}));
|
|
54
|
+
return {
|
|
55
|
+
...toRunDto(run, run.latestAttempt),
|
|
56
|
+
run_attempt: toRunAttemptDto(run.runAttempt),
|
|
57
|
+
jobs: jobDtos
|
|
58
|
+
};
|
|
33
59
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
job_executions: job.jobExecutions.map((jobExecution)=>({
|
|
37
|
-
...toJobExecutionDto(jobExecution),
|
|
38
|
-
steps: jobExecution.steps.map((step)=>{
|
|
39
|
-
const attempts = step.attempts.map(toStepAttemptDto);
|
|
40
|
-
const latestTerminalAttempt = attempts.filter((attempt)=>attempt.status !== 'running').at(-1);
|
|
41
|
-
return {
|
|
42
|
-
...toStepDto(step),
|
|
43
|
-
exit_code: latestTerminalAttempt?.exit_code ?? null,
|
|
44
|
-
outputs: latestTerminalAttempt?.outputs ?? null,
|
|
45
|
-
response: latestTerminalAttempt?.response ?? null,
|
|
46
|
-
gate_result: latestTerminalAttempt?.gate_result ?? null,
|
|
47
|
-
attempts
|
|
48
|
-
};
|
|
49
|
-
})
|
|
50
|
-
}))
|
|
51
|
-
}));
|
|
52
|
-
return {
|
|
53
|
-
...toRunDto(run, run.latestAttempt),
|
|
54
|
-
run_attempt: toRunAttemptDto(run.runAttempt),
|
|
55
|
-
jobs: jobDtos
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
59
62
|
|
|
60
63
|
//# sourceMappingURL=get-run.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/get-run.ts"],"sourcesContent":["import {workflowRunDetailResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {getWorkflowRunDetail} from '#db/index.js';\nimport {\n toJobDto,\n toJobExecutionDto,\n toRunAttemptDto,\n toRunDto,\n toStepAttemptDto,\n toStepDto,\n} from '#presentation/dto/index.js';\nimport {requireAccessibleRun} from './require-accessible-run.js';\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/get-run.ts"],"sourcesContent":["import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {workflowRunDetailResponseSchema} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {getWorkflowRunDetail} from '#db/index.js';\nimport {\n toJobDto,\n toJobExecutionDto,\n toRunAttemptDto,\n toRunDto,\n toStepAttemptDto,\n toStepDto,\n} from '#presentation/dto/index.js';\nimport {requireAccessibleRun} from './require-accessible-run.js';\n\nexport function getRunRoute(projects: ProjectsModuleClient) {\n return defineRoute({\n method: 'GET',\n path: '/:id',\n description: 'Get a workflow run by ID with jobs and steps',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n querystring: z.object({\n attempt: z.coerce.number().int().positive().optional(),\n }),\n response: {\n 200: workflowRunDetailResponseSchema,\n },\n },\n handler: async (request) => {\n const {id} = request.params;\n await requireAccessibleRun({request, id, projects});\n\n const run = await getWorkflowRunDetail(id, request.query.attempt);\n if (!run) {\n throw new ClientError('Run not found', 'not-found', {status: 404});\n }\n\n const jobDtos = run.jobs.map((job) => ({\n ...toJobDto(job),\n job_executions: job.jobExecutions.map((jobExecution) => ({\n ...toJobExecutionDto(jobExecution),\n steps: jobExecution.steps.map((step) => {\n const attempts = step.attempts.map(toStepAttemptDto);\n const latestTerminalAttempt = attempts\n .filter((attempt) => attempt.status !== 'running')\n .at(-1);\n return {\n ...toStepDto(step),\n exit_code: latestTerminalAttempt?.exit_code ?? null,\n outputs: latestTerminalAttempt?.outputs ?? null,\n response: latestTerminalAttempt?.response ?? null,\n gate_result: latestTerminalAttempt?.gate_result ?? null,\n attempts,\n };\n }),\n })),\n }));\n\n return {\n ...toRunDto(run, run.latestAttempt),\n run_attempt: toRunAttemptDto(run.runAttempt),\n jobs: jobDtos,\n };\n },\n });\n}\n"],"names":["workflowRunDetailResponseSchema","ClientError","defineRoute","z","getWorkflowRunDetail","toJobDto","toJobExecutionDto","toRunAttemptDto","toRunDto","toStepAttemptDto","toStepDto","requireAccessibleRun","getRunRoute","projects","method","path","description","schema","params","object","id","string","uuid","querystring","attempt","coerce","number","int","positive","optional","response","handler","request","run","query","status","jobDtos","jobs","map","job","job_executions","jobExecutions","jobExecution","steps","step","attempts","latestTerminalAttempt","filter","at","exit_code","outputs","gate_result","latestAttempt","run_attempt","runAttempt"],"mappings":"AACA,SAAQA,+BAA+B,QAAO,6BAA6B;AAC3E,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,oBAAoB,QAAO,eAAe;AAClD,SACEC,QAAQ,EACRC,iBAAiB,EACjBC,eAAe,EACfC,QAAQ,EACRC,gBAAgB,EAChBC,SAAS,QACJ,6BAA6B;AACpC,SAAQC,oBAAoB,QAAO,8BAA8B;AAEjE,OAAO,SAASC,YAAYC,QAA8B;IACxD,OAAOX,YAAY;QACjBY,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQf,EAAEgB,MAAM,CAAC;gBACfC,IAAIjB,EAAEkB,MAAM,GAAGC,IAAI;YACrB;YACAC,aAAapB,EAAEgB,MAAM,CAAC;gBACpBK,SAASrB,EAAEsB,MAAM,CAACC,MAAM,GAAGC,GAAG,GAAGC,QAAQ,GAAGC,QAAQ;YACtD;YACAC,UAAU;gBACR,KAAK9B;YACP;QACF;QACA+B,SAAS,OAAOC;YACd,MAAM,EAACZ,EAAE,EAAC,GAAGY,QAAQd,MAAM;YAC3B,MAAMP,qBAAqB;gBAACqB;gBAASZ;gBAAIP;YAAQ;YAEjD,MAAMoB,MAAM,MAAM7B,qBAAqBgB,IAAIY,QAAQE,KAAK,CAACV,OAAO;YAChE,IAAI,CAACS,KAAK;gBACR,MAAM,IAAIhC,YAAY,iBAAiB,aAAa;oBAACkC,QAAQ;gBAAG;YAClE;YAEA,MAAMC,UAAUH,IAAII,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;oBACrC,GAAGlC,SAASkC,IAAI;oBAChBC,gBAAgBD,IAAIE,aAAa,CAACH,GAAG,CAAC,CAACI,eAAkB,CAAA;4BACvD,GAAGpC,kBAAkBoC,aAAa;4BAClCC,OAAOD,aAAaC,KAAK,CAACL,GAAG,CAAC,CAACM;gCAC7B,MAAMC,WAAWD,KAAKC,QAAQ,CAACP,GAAG,CAAC7B;gCACnC,MAAMqC,wBAAwBD,SAC3BE,MAAM,CAAC,CAACvB,UAAYA,QAAQW,MAAM,KAAK,WACvCa,EAAE,CAAC,CAAC;gCACP,OAAO;oCACL,GAAGtC,UAAUkC,KAAK;oCAClBK,WAAWH,uBAAuBG,aAAa;oCAC/CC,SAASJ,uBAAuBI,WAAW;oCAC3CpB,UAAUgB,uBAAuBhB,YAAY;oCAC7CqB,aAAaL,uBAAuBK,eAAe;oCACnDN;gCACF;4BACF;wBACF,CAAA;gBACF,CAAA;YAEA,OAAO;gBACL,GAAGrC,SAASyB,KAAKA,IAAImB,aAAa,CAAC;gBACnCC,aAAa9C,gBAAgB0B,IAAIqB,UAAU;gBAC3CjB,MAAMD;YACR;QACF;IACF;AACF"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
|
|
2
|
+
import { type SecretsInterModuleClient } from '@shipfox/api-secrets-dto/inter-module';
|
|
3
|
+
export declare function createGetStepSecretsRoute(runners: RunnersInterModuleClient, secretsClient: SecretsInterModuleClient): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
4
|
//# sourceMappingURL=get-step-secrets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-step-secrets.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-step-secrets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-step-secrets.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-step-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAQpF,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,uCAAuC,CAAC;AAU/C,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,wBAAwB,EACjC,aAAa,EAAE,wBAAwB,mDAqExC"}
|
|
@@ -1,83 +1,87 @@
|
|
|
1
|
-
import { getSecret, SecretDecryptionError } from '@shipfox/api-secrets';
|
|
2
1
|
import { materializedSecretBindingSchema, stepSecretsParamsSchema, stepSecretsQuerySchema, stepSecretsResponseSchema } from '@shipfox/api-secrets-dto';
|
|
2
|
+
import { secretsInterModuleContract } from '@shipfox/api-secrets-dto/inter-module';
|
|
3
|
+
import { isInterModuleKnownError } from '@shipfox/inter-module';
|
|
3
4
|
import { captureException } from '@shipfox/node-error-monitoring';
|
|
4
5
|
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
6
|
import { logger } from '@shipfox/node-opentelemetry';
|
|
6
7
|
import { ZodError, z } from 'zod';
|
|
7
8
|
import { loadRunningLeasedStep } from './leased-step.js';
|
|
8
9
|
const secretBindingsSchema = z.array(materializedSecretBindingSchema);
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
throw new ClientError('Step is not a run step', 'step-not-run', {
|
|
40
|
-
status: 409
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
const secretBindings = parseSecretBindings(step.config.secret_bindings);
|
|
44
|
-
const references = distinctSecretReferences(secretBindings);
|
|
45
|
-
const secrets = await Promise.all(references.map(async (reference)=>{
|
|
46
|
-
const value = await getSecret({
|
|
47
|
-
workspaceId,
|
|
48
|
-
projectId,
|
|
49
|
-
namespace: '',
|
|
50
|
-
key: reference.key,
|
|
51
|
-
store: reference.store
|
|
10
|
+
export function createGetStepSecretsRoute(runners, secretsClient) {
|
|
11
|
+
return defineRoute({
|
|
12
|
+
method: 'GET',
|
|
13
|
+
path: '/steps/:stepId/secrets',
|
|
14
|
+
description: "Returns decrypted secret values referenced by the runner's currently leased running run step. The job scope and secret bindings are re-derived from server state; the runner supplies only the step id and current attempt.",
|
|
15
|
+
schema: {
|
|
16
|
+
params: stepSecretsParamsSchema,
|
|
17
|
+
querystring: stepSecretsQuerySchema,
|
|
18
|
+
response: {
|
|
19
|
+
200: stepSecretsResponseSchema
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
errorHandler: (error)=>{
|
|
23
|
+
if (isInterModuleKnownError(secretsInterModuleContract.methods.getSecret, error)) {
|
|
24
|
+
captureException(error);
|
|
25
|
+
throw new ClientError('Step secret could not be decrypted', 'secret-value-invalid', {
|
|
26
|
+
status: 409,
|
|
27
|
+
cause: error
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
},
|
|
32
|
+
handler: async (request, reply)=>{
|
|
33
|
+
const { stepId } = request.params;
|
|
34
|
+
const { attempt } = request.query;
|
|
35
|
+
const { leasedJob, step, workspaceId, projectId } = await loadRunningLeasedStep({
|
|
36
|
+
runners,
|
|
37
|
+
request,
|
|
38
|
+
stepId,
|
|
39
|
+
attempt
|
|
52
40
|
});
|
|
53
|
-
if (
|
|
54
|
-
throw new ClientError('
|
|
55
|
-
status:
|
|
41
|
+
if (step.type !== 'run') {
|
|
42
|
+
throw new ClientError('Step is not a run step', 'step-not-run', {
|
|
43
|
+
status: 409
|
|
56
44
|
});
|
|
57
45
|
}
|
|
46
|
+
const secretBindings = parseSecretBindings(step.config.secret_bindings);
|
|
47
|
+
const references = distinctSecretReferences(secretBindings);
|
|
48
|
+
const secrets = await Promise.all(references.map(async (reference)=>{
|
|
49
|
+
const { value } = await secretsClient.getSecret({
|
|
50
|
+
workspaceId,
|
|
51
|
+
projectId,
|
|
52
|
+
namespace: '',
|
|
53
|
+
key: reference.key,
|
|
54
|
+
store: reference.store
|
|
55
|
+
});
|
|
56
|
+
if (value === null) {
|
|
57
|
+
throw new ClientError('Secret not found', 'secret-not-found', {
|
|
58
|
+
status: 422
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...reference,
|
|
63
|
+
value
|
|
64
|
+
};
|
|
65
|
+
}));
|
|
66
|
+
logger().info({
|
|
67
|
+
jobId: leasedJob.jobId,
|
|
68
|
+
workspaceId,
|
|
69
|
+
stepId,
|
|
70
|
+
keyCount: references.length
|
|
71
|
+
}, 'Resolved step secrets');
|
|
72
|
+
logger().debug({
|
|
73
|
+
jobId: leasedJob.jobId,
|
|
74
|
+
workspaceId,
|
|
75
|
+
stepId,
|
|
76
|
+
keys: references.map((ref)=>ref.key)
|
|
77
|
+
}, 'Resolved step secret keys');
|
|
78
|
+
reply.header('cache-control', 'no-store');
|
|
58
79
|
return {
|
|
59
|
-
|
|
60
|
-
value
|
|
80
|
+
secrets
|
|
61
81
|
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
workspaceId,
|
|
66
|
-
stepId,
|
|
67
|
-
keyCount: references.length
|
|
68
|
-
}, 'Resolved step secrets');
|
|
69
|
-
logger().debug({
|
|
70
|
-
jobId: leasedJob.jobId,
|
|
71
|
-
workspaceId,
|
|
72
|
-
stepId,
|
|
73
|
-
keys: references.map((ref)=>ref.key)
|
|
74
|
-
}, 'Resolved step secret keys');
|
|
75
|
-
reply.header('cache-control', 'no-store');
|
|
76
|
-
return {
|
|
77
|
-
secrets
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
81
85
|
function parseSecretBindings(value) {
|
|
82
86
|
try {
|
|
83
87
|
return secretBindingsSchema.parse(value ?? []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/get-step-secrets.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/get-step-secrets.ts"],"sourcesContent":["import type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport {\n materializedSecretBindingSchema,\n type StepSecretDto,\n stepSecretsParamsSchema,\n stepSecretsQuerySchema,\n stepSecretsResponseSchema,\n} from '@shipfox/api-secrets-dto';\nimport {\n type SecretsInterModuleClient,\n secretsInterModuleContract,\n} from '@shipfox/api-secrets-dto/inter-module';\nimport {isInterModuleKnownError} from '@shipfox/inter-module';\nimport {captureException} from '@shipfox/node-error-monitoring';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {ZodError, z} from 'zod';\nimport {loadRunningLeasedStep} from './leased-step.js';\n\nconst secretBindingsSchema = z.array(materializedSecretBindingSchema);\n\nexport function createGetStepSecretsRoute(\n runners: RunnersInterModuleClient,\n secretsClient: SecretsInterModuleClient,\n) {\n return defineRoute({\n method: 'GET',\n path: '/steps/:stepId/secrets',\n description:\n \"Returns decrypted secret values referenced by the runner's currently leased running run step. The job scope and secret bindings are re-derived from server state; the runner supplies only the step id and current attempt.\",\n schema: {\n params: stepSecretsParamsSchema,\n querystring: stepSecretsQuerySchema,\n response: {\n 200: stepSecretsResponseSchema,\n },\n },\n errorHandler: (error) => {\n if (isInterModuleKnownError(secretsInterModuleContract.methods.getSecret, error)) {\n captureException(error);\n throw new ClientError('Step secret could not be decrypted', 'secret-value-invalid', {\n status: 409,\n cause: error,\n });\n }\n throw error;\n },\n handler: async (request, reply) => {\n const {stepId} = request.params;\n const {attempt} = request.query;\n const {leasedJob, step, workspaceId, projectId} = await loadRunningLeasedStep({\n runners,\n request,\n stepId,\n attempt,\n });\n\n if (step.type !== 'run') {\n throw new ClientError('Step is not a run step', 'step-not-run', {status: 409});\n }\n\n const secretBindings = parseSecretBindings(step.config.secret_bindings);\n const references = distinctSecretReferences(secretBindings);\n const secrets = await Promise.all(\n references.map(async (reference): Promise<StepSecretDto> => {\n const {value} = await secretsClient.getSecret({\n workspaceId,\n projectId,\n namespace: '',\n key: reference.key,\n store: reference.store,\n });\n if (value === null) {\n throw new ClientError('Secret not found', 'secret-not-found', {status: 422});\n }\n return {...reference, value};\n }),\n );\n\n logger().info(\n {jobId: leasedJob.jobId, workspaceId, stepId, keyCount: references.length},\n 'Resolved step secrets',\n );\n logger().debug(\n {jobId: leasedJob.jobId, workspaceId, stepId, keys: references.map((ref) => ref.key)},\n 'Resolved step secret keys',\n );\n\n reply.header('cache-control', 'no-store');\n return {secrets};\n },\n });\n}\n\nfunction parseSecretBindings(value: unknown): z.infer<typeof secretBindingsSchema> {\n try {\n return secretBindingsSchema.parse(value ?? []);\n } catch (error) {\n if (error instanceof ZodError) {\n throw new ClientError('Step secret bindings are invalid', 'secret-bindings-invalid', {\n status: 409,\n cause: error,\n });\n }\n throw error;\n }\n}\n\nfunction distinctSecretReferences(\n bindings: ReadonlyArray<z.infer<typeof materializedSecretBindingSchema>>,\n): Array<Pick<StepSecretDto, 'store' | 'key'>> {\n const seen = new Set<string>();\n const references: Array<Pick<StepSecretDto, 'store' | 'key'>> = [];\n for (const binding of bindings) {\n for (const segment of binding.segments) {\n if (segment.kind !== 'secret') continue;\n const id = secretReferenceId(segment);\n if (seen.has(id)) continue;\n seen.add(id);\n references.push({store: segment.store, key: segment.key});\n }\n }\n return references;\n}\n\nfunction secretReferenceId(reference: Pick<StepSecretDto, 'store' | 'key'>): string {\n return `${reference.store}\\0${reference.key}`;\n}\n"],"names":["materializedSecretBindingSchema","stepSecretsParamsSchema","stepSecretsQuerySchema","stepSecretsResponseSchema","secretsInterModuleContract","isInterModuleKnownError","captureException","ClientError","defineRoute","logger","ZodError","z","loadRunningLeasedStep","secretBindingsSchema","array","createGetStepSecretsRoute","runners","secretsClient","method","path","description","schema","params","querystring","response","errorHandler","error","methods","getSecret","status","cause","handler","request","reply","stepId","attempt","query","leasedJob","step","workspaceId","projectId","type","secretBindings","parseSecretBindings","config","secret_bindings","references","distinctSecretReferences","secrets","Promise","all","map","reference","value","namespace","key","store","info","jobId","keyCount","length","debug","keys","ref","header","parse","bindings","seen","Set","binding","segment","segments","kind","id","secretReferenceId","has","add","push"],"mappings":"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"}
|
|
@@ -1,4 +1,21 @@
|
|
|
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 { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto';
|
|
5
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
6
|
+
import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
|
|
7
|
+
import type { SecretsInterModuleClient } from '@shipfox/api-secrets-dto/inter-module';
|
|
1
8
|
import type { RouteGroup } from '@shipfox/node-fastify';
|
|
2
|
-
|
|
3
|
-
|
|
9
|
+
type WorkflowRouteClients = {
|
|
10
|
+
agent: AgentInterModuleClient;
|
|
11
|
+
annotations: AnnotationsInterModuleClient;
|
|
12
|
+
auth: AuthInterModuleClient;
|
|
13
|
+
integrations: IntegrationsModuleClient;
|
|
14
|
+
projects: ProjectsModuleClient;
|
|
15
|
+
runners: RunnersInterModuleClient;
|
|
16
|
+
secrets: SecretsInterModuleClient;
|
|
17
|
+
};
|
|
18
|
+
export declare function createLeaseTokenRouteGroup(params: WorkflowRouteClients): RouteGroup;
|
|
19
|
+
export declare function createWorkflowRoutes(params: WorkflowRouteClients): RouteGroup[];
|
|
20
|
+
export {};
|
|
4
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.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,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AACpF,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAatD,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,WAAW,EAAE,4BAA4B,CAAC;IAC1C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,YAAY,EAAE,wBAAwB,CAAC;IACvC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,OAAO,EAAE,wBAAwB,CAAC;IAClC,OAAO,EAAE,wBAAwB,CAAC;CACnC,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,oBAAoB,GAAG,UAAU,CAiBnF;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,UAAU,EAAE,CAgB/E"}
|
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
import { AUTH_LEASED_JOB, AUTH_USER } from '@shipfox/api-auth-context';
|
|
2
|
-
import {
|
|
2
|
+
import { createAgentRuntimeConfigRoute } from './agent-runtime-config.js';
|
|
3
3
|
import { cancelRunRoute } from './cancel-run.js';
|
|
4
|
-
import {
|
|
4
|
+
import { createCheckoutTokenRoute } from './checkout-token.js';
|
|
5
5
|
import { getRunRoute } from './get-run.js';
|
|
6
6
|
import { getRunAggregatesRoute } from './get-run-aggregates.js';
|
|
7
|
-
import {
|
|
7
|
+
import { createGetStepSecretsRoute } from './get-step-secrets.js';
|
|
8
8
|
import { listRunAttemptsRoute } from './list-run-attempts.js';
|
|
9
9
|
import { listRunsRoute } from './list-runs.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { createNextStepRoute } from './next-step.js';
|
|
11
|
+
import { createReportStepRoute } from './report-step.js';
|
|
12
12
|
import { rerunRunRoute } from './rerun-run.js';
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
nextStepRoute,
|
|
19
|
-
reportStepRoute,
|
|
20
|
-
checkoutTokenRoute,
|
|
21
|
-
agentRuntimeConfigRoute,
|
|
22
|
-
getStepSecretsRoute
|
|
23
|
-
]
|
|
24
|
-
};
|
|
25
|
-
export const workflowRoutes = [
|
|
26
|
-
{
|
|
27
|
-
prefix: '/workflows/runs',
|
|
28
|
-
auth: AUTH_USER,
|
|
13
|
+
export function createLeaseTokenRouteGroup(params) {
|
|
14
|
+
return {
|
|
15
|
+
// The lease token names the job, so the path carries no job id ("current").
|
|
16
|
+
prefix: '/runs/jobs/current',
|
|
17
|
+
auth: AUTH_LEASED_JOB,
|
|
29
18
|
routes: [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
createNextStepRoute(params),
|
|
20
|
+
createReportStepRoute(params.runners),
|
|
21
|
+
createCheckoutTokenRoute({
|
|
22
|
+
integrations: params.integrations,
|
|
23
|
+
projects: params.projects,
|
|
24
|
+
runners: params.runners
|
|
25
|
+
}),
|
|
26
|
+
createAgentRuntimeConfigRoute(params),
|
|
27
|
+
createGetStepSecretsRoute(params.runners, params.secrets)
|
|
36
28
|
]
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function createWorkflowRoutes(params) {
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
prefix: '/workflows/runs',
|
|
35
|
+
auth: AUTH_USER,
|
|
36
|
+
routes: [
|
|
37
|
+
listRunsRoute(params.projects),
|
|
38
|
+
getRunAggregatesRoute(params.projects),
|
|
39
|
+
listRunAttemptsRoute(params.projects),
|
|
40
|
+
getRunRoute(params.projects),
|
|
41
|
+
cancelRunRoute(params.projects),
|
|
42
|
+
rerunRunRoute(params.projects)
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
createLeaseTokenRouteGroup(params)
|
|
46
|
+
];
|
|
47
|
+
}
|
|
40
48
|
|
|
41
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import {AUTH_LEASED_JOB, AUTH_USER} from '@shipfox/api-auth-context';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import type {AnnotationsInterModuleClient} from '@shipfox/annotations-dto/inter-module';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {AUTH_LEASED_JOB, AUTH_USER} from '@shipfox/api-auth-context';\nimport type {AuthInterModuleClient} from '@shipfox/api-auth-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport type {SecretsInterModuleClient} from '@shipfox/api-secrets-dto/inter-module';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {createAgentRuntimeConfigRoute} from './agent-runtime-config.js';\nimport {cancelRunRoute} from './cancel-run.js';\nimport {createCheckoutTokenRoute} from './checkout-token.js';\nimport {getRunRoute} from './get-run.js';\nimport {getRunAggregatesRoute} from './get-run-aggregates.js';\nimport {createGetStepSecretsRoute} from './get-step-secrets.js';\nimport {listRunAttemptsRoute} from './list-run-attempts.js';\nimport {listRunsRoute} from './list-runs.js';\nimport {createNextStepRoute} from './next-step.js';\nimport {createReportStepRoute} from './report-step.js';\nimport {rerunRunRoute} from './rerun-run.js';\n\ntype WorkflowRouteClients = {\n agent: AgentInterModuleClient;\n annotations: AnnotationsInterModuleClient;\n auth: AuthInterModuleClient;\n integrations: IntegrationsModuleClient;\n projects: ProjectsModuleClient;\n runners: RunnersInterModuleClient;\n secrets: SecretsInterModuleClient;\n};\n\nexport function createLeaseTokenRouteGroup(params: WorkflowRouteClients): RouteGroup {\n return {\n // The lease token names the job, so the path carries no job id (\"current\").\n prefix: '/runs/jobs/current',\n auth: AUTH_LEASED_JOB,\n routes: [\n createNextStepRoute(params),\n createReportStepRoute(params.runners),\n createCheckoutTokenRoute({\n integrations: params.integrations,\n projects: params.projects,\n runners: params.runners,\n }),\n createAgentRuntimeConfigRoute(params),\n createGetStepSecretsRoute(params.runners, params.secrets),\n ],\n };\n}\n\nexport function createWorkflowRoutes(params: WorkflowRouteClients): RouteGroup[] {\n return [\n {\n prefix: '/workflows/runs',\n auth: AUTH_USER,\n routes: [\n listRunsRoute(params.projects),\n getRunAggregatesRoute(params.projects),\n listRunAttemptsRoute(params.projects),\n getRunRoute(params.projects),\n cancelRunRoute(params.projects),\n rerunRunRoute(params.projects),\n ],\n },\n createLeaseTokenRouteGroup(params),\n ];\n}\n"],"names":["AUTH_LEASED_JOB","AUTH_USER","createAgentRuntimeConfigRoute","cancelRunRoute","createCheckoutTokenRoute","getRunRoute","getRunAggregatesRoute","createGetStepSecretsRoute","listRunAttemptsRoute","listRunsRoute","createNextStepRoute","createReportStepRoute","rerunRunRoute","createLeaseTokenRouteGroup","params","prefix","auth","routes","runners","integrations","projects","secrets","createWorkflowRoutes"],"mappings":"AAEA,SAAQA,eAAe,EAAEC,SAAS,QAAO,4BAA4B;AAOrE,SAAQC,6BAA6B,QAAO,4BAA4B;AACxE,SAAQC,cAAc,QAAO,kBAAkB;AAC/C,SAAQC,wBAAwB,QAAO,sBAAsB;AAC7D,SAAQC,WAAW,QAAO,eAAe;AACzC,SAAQC,qBAAqB,QAAO,0BAA0B;AAC9D,SAAQC,yBAAyB,QAAO,wBAAwB;AAChE,SAAQC,oBAAoB,QAAO,yBAAyB;AAC5D,SAAQC,aAAa,QAAO,iBAAiB;AAC7C,SAAQC,mBAAmB,QAAO,iBAAiB;AACnD,SAAQC,qBAAqB,QAAO,mBAAmB;AACvD,SAAQC,aAAa,QAAO,iBAAiB;AAY7C,OAAO,SAASC,2BAA2BC,MAA4B;IACrE,OAAO;QACL,4EAA4E;QAC5EC,QAAQ;QACRC,MAAMhB;QACNiB,QAAQ;YACNP,oBAAoBI;YACpBH,sBAAsBG,OAAOI,OAAO;YACpCd,yBAAyB;gBACvBe,cAAcL,OAAOK,YAAY;gBACjCC,UAAUN,OAAOM,QAAQ;gBACzBF,SAASJ,OAAOI,OAAO;YACzB;YACAhB,8BAA8BY;YAC9BP,0BAA0BO,OAAOI,OAAO,EAAEJ,OAAOO,OAAO;SACzD;IACH;AACF;AAEA,OAAO,SAASC,qBAAqBR,MAA4B;IAC/D,OAAO;QACL;YACEC,QAAQ;YACRC,MAAMf;YACNgB,QAAQ;gBACNR,cAAcK,OAAOM,QAAQ;gBAC7Bd,sBAAsBQ,OAAOM,QAAQ;gBACrCZ,qBAAqBM,OAAOM,QAAQ;gBACpCf,YAAYS,OAAOM,QAAQ;gBAC3BjB,eAAeW,OAAOM,QAAQ;gBAC9BR,cAAcE,OAAOM,QAAQ;aAC9B;QACH;QACAP,2BAA2BC;KAC5B;AACH"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type LeasedJobContext } from '@shipfox/api-auth-context';
|
|
2
|
+
import type { RunnersInterModuleClient } from '@shipfox/api-runners-dto/inter-module';
|
|
2
3
|
import type { Step } from '#core/entities/step.js';
|
|
3
4
|
export interface LoadedRunningLeasedStep {
|
|
4
5
|
leasedJob: LeasedJobContext;
|
|
@@ -7,6 +8,7 @@ export interface LoadedRunningLeasedStep {
|
|
|
7
8
|
projectId: string;
|
|
8
9
|
}
|
|
9
10
|
export declare function loadRunningLeasedStep(params: {
|
|
11
|
+
runners: RunnersInterModuleClient;
|
|
10
12
|
request: object;
|
|
11
13
|
stepId: string;
|
|
12
14
|
attempt: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leased-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/leased-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,gBAAgB,EAA0B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"leased-step.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/leased-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,gBAAgB,EAA0B,MAAM,2BAA2B,CAAC;AACzF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAEpF,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAGjD,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE,wBAAwB,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAoCnC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { requireLeasedJobContext } from '@shipfox/api-auth-context';
|
|
2
|
-
import { isJobLeaseActive } from '@shipfox/api-runners';
|
|
3
2
|
import { ClientError } from '@shipfox/node-fastify';
|
|
4
3
|
import { getJobScope, getStepByIdForJobExecution } from '#db/index.js';
|
|
5
4
|
export async function loadRunningLeasedStep(params) {
|
|
6
5
|
const leasedJob = requireLeasedJobContext(params.request);
|
|
7
|
-
const leaseIsActive = await
|
|
6
|
+
const { active: leaseIsActive } = await params.runners.getLeaseState({
|
|
8
7
|
jobId: leasedJob.jobId,
|
|
9
8
|
jobExecutionId: leasedJob.jobExecutionId,
|
|
10
9
|
runnerSessionId: leasedJob.runnerSessionId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/leased-step.ts"],"sourcesContent":["import {type LeasedJobContext, requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/leased-step.ts"],"sourcesContent":["import {type LeasedJobContext, requireLeasedJobContext} from '@shipfox/api-auth-context';\nimport type {RunnersInterModuleClient} from '@shipfox/api-runners-dto/inter-module';\nimport {ClientError} from '@shipfox/node-fastify';\nimport type {Step} from '#core/entities/step.js';\nimport {getJobScope, getStepByIdForJobExecution} from '#db/index.js';\n\nexport interface LoadedRunningLeasedStep {\n leasedJob: LeasedJobContext;\n step: Step;\n workspaceId: string;\n projectId: string;\n}\n\nexport async function loadRunningLeasedStep(params: {\n runners: RunnersInterModuleClient;\n request: object;\n stepId: string;\n attempt: number;\n}): Promise<LoadedRunningLeasedStep> {\n const leasedJob = requireLeasedJobContext(params.request);\n\n const {active: leaseIsActive} = await params.runners.getLeaseState({\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n runnerSessionId: leasedJob.runnerSessionId,\n });\n if (!leaseIsActive) {\n throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});\n }\n\n const step = await getStepByIdForJobExecution({\n stepId: params.stepId,\n jobExecutionId: leasedJob.jobExecutionId,\n });\n if (!step) {\n throw new ClientError('Step not found for leased job', 'step-not-found', {status: 404});\n }\n\n const scope = await getJobScope(leasedJob.jobId);\n if (!scope) {\n throw new ClientError('Leased job not found', 'job-not-found', {status: 404});\n }\n\n if (step.currentAttempt !== params.attempt) {\n throw new ClientError('Step attempt does not match current attempt', 'step-attempt-mismatch', {\n status: 409,\n });\n }\n\n if (step.status !== 'running') {\n throw new ClientError('Step is not running', 'step-not-running', {status: 409});\n }\n\n return {leasedJob, step, workspaceId: scope.workspaceId, projectId: scope.projectId};\n}\n"],"names":["requireLeasedJobContext","ClientError","getJobScope","getStepByIdForJobExecution","loadRunningLeasedStep","params","leasedJob","request","active","leaseIsActive","runners","getLeaseState","jobId","jobExecutionId","runnerSessionId","status","step","stepId","scope","currentAttempt","attempt","workspaceId","projectId"],"mappings":"AAAA,SAA+BA,uBAAuB,QAAO,4BAA4B;AAEzF,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,WAAW,EAAEC,0BAA0B,QAAO,eAAe;AASrE,OAAO,eAAeC,sBAAsBC,MAK3C;IACC,MAAMC,YAAYN,wBAAwBK,OAAOE,OAAO;IAExD,MAAM,EAACC,QAAQC,aAAa,EAAC,GAAG,MAAMJ,OAAOK,OAAO,CAACC,aAAa,CAAC;QACjEC,OAAON,UAAUM,KAAK;QACtBC,gBAAgBP,UAAUO,cAAc;QACxCC,iBAAiBR,UAAUQ,eAAe;IAC5C;IACA,IAAI,CAACL,eAAe;QAClB,MAAM,IAAIR,YAAY,iCAAiC,oBAAoB;YAACc,QAAQ;QAAG;IACzF;IAEA,MAAMC,OAAO,MAAMb,2BAA2B;QAC5Cc,QAAQZ,OAAOY,MAAM;QACrBJ,gBAAgBP,UAAUO,cAAc;IAC1C;IACA,IAAI,CAACG,MAAM;QACT,MAAM,IAAIf,YAAY,iCAAiC,kBAAkB;YAACc,QAAQ;QAAG;IACvF;IAEA,MAAMG,QAAQ,MAAMhB,YAAYI,UAAUM,KAAK;IAC/C,IAAI,CAACM,OAAO;QACV,MAAM,IAAIjB,YAAY,wBAAwB,iBAAiB;YAACc,QAAQ;QAAG;IAC7E;IAEA,IAAIC,KAAKG,cAAc,KAAKd,OAAOe,OAAO,EAAE;QAC1C,MAAM,IAAInB,YAAY,+CAA+C,yBAAyB;YAC5Fc,QAAQ;QACV;IACF;IAEA,IAAIC,KAAKD,MAAM,KAAK,WAAW;QAC7B,MAAM,IAAId,YAAY,uBAAuB,oBAAoB;YAACc,QAAQ;QAAG;IAC/E;IAEA,OAAO;QAACT;QAAWU;QAAMK,aAAaH,MAAMG,WAAW;QAAEC,WAAWJ,MAAMI,SAAS;IAAA;AACrF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
|
+
export declare function listRunAttemptsRoute(projects: ProjectsModuleClient): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=list-run-attempts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-run-attempts.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-run-attempts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-run-attempts.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-run-attempts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAQpE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB,mDAqBlE"}
|