@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.
Files changed (277) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +89 -0
  3. package/dist/core/agent-defaults.d.ts +17 -0
  4. package/dist/core/agent-defaults.d.ts.map +1 -0
  5. package/dist/core/agent-defaults.js +21 -0
  6. package/dist/core/agent-defaults.js.map +1 -0
  7. package/dist/core/agent-tool-capability-warning.d.ts +4 -0
  8. package/dist/core/agent-tool-capability-warning.d.ts.map +1 -1
  9. package/dist/core/agent-tool-capability-warning.js +15 -17
  10. package/dist/core/agent-tool-capability-warning.js.map +1 -1
  11. package/dist/core/agent-tools.d.ts +11 -9
  12. package/dist/core/agent-tools.d.ts.map +1 -1
  13. package/dist/core/agent-tools.js +23 -18
  14. package/dist/core/agent-tools.js.map +1 -1
  15. package/dist/core/checkout.d.ts +21 -7
  16. package/dist/core/checkout.d.ts.map +1 -1
  17. package/dist/core/checkout.js +23 -11
  18. package/dist/core/checkout.js.map +1 -1
  19. package/dist/core/entities/workflow-run-attempt.d.ts +1 -1
  20. package/dist/core/entities/workflow-run-attempt.d.ts.map +1 -1
  21. package/dist/core/entities/workflow-run-attempt.js.map +1 -1
  22. package/dist/core/job-execution.d.ts +3 -1
  23. package/dist/core/job-execution.d.ts.map +1 -1
  24. package/dist/core/job-execution.js +14 -12
  25. package/dist/core/job-execution.js.map +1 -1
  26. package/dist/core/job-transition/derive-job-execution-outputs.d.ts +1 -1
  27. package/dist/core/job-transition/derive-job-execution-outputs.d.ts.map +1 -1
  28. package/dist/core/job-transition/derive-job-execution-outputs.js.map +1 -1
  29. package/dist/core/job-transition/derive-job-success.js +1 -1
  30. package/dist/core/job-transition/derive-job-success.js.map +1 -1
  31. package/dist/core/listener-execution-materialization.d.ts +3 -3
  32. package/dist/core/listener-execution-materialization.d.ts.map +1 -1
  33. package/dist/core/listener-execution-materialization.js +3 -4
  34. package/dist/core/listener-execution-materialization.js.map +1 -1
  35. package/dist/core/run-workflow.d.ts +12 -1
  36. package/dist/core/run-workflow.d.ts.map +1 -1
  37. package/dist/core/run-workflow.js +13 -8
  38. package/dist/core/run-workflow.js.map +1 -1
  39. package/dist/core/step-config/agent.d.ts +8 -8
  40. package/dist/core/step-config/agent.d.ts.map +1 -1
  41. package/dist/core/step-config/agent.js +12 -10
  42. package/dist/core/step-config/agent.js.map +1 -1
  43. package/dist/core/step-config/complete-step-dispatch-config.d.ts +4 -4
  44. package/dist/core/step-config/complete-step-dispatch-config.d.ts.map +1 -1
  45. package/dist/core/step-config/complete-step-dispatch-config.js +2 -2
  46. package/dist/core/step-config/complete-step-dispatch-config.js.map +1 -1
  47. package/dist/core/step-config/materialize-job-execution-steps.d.ts +3 -3
  48. package/dist/core/step-config/materialize-job-execution-steps.d.ts.map +1 -1
  49. package/dist/core/step-config/materialize-job-execution-steps.js +5 -6
  50. package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
  51. package/dist/core/step-config/materialize-workflow-model.d.ts +3 -3
  52. package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
  53. package/dist/core/step-config/materialize-workflow-model.js +4 -4
  54. package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
  55. package/dist/core/step-config/resolve-job-execution-name.d.ts +1 -1
  56. package/dist/core/step-config/resolve-job-execution-name.d.ts.map +1 -1
  57. package/dist/core/step-config/resolve-job-execution-name.js.map +1 -1
  58. package/dist/core/step-config/resolve-step-config.d.ts +4 -4
  59. package/dist/core/step-config/resolve-step-config.d.ts.map +1 -1
  60. package/dist/core/step-config/resolve-step-config.js +6 -6
  61. package/dist/core/step-config/resolve-step-config.js.map +1 -1
  62. package/dist/core/step-config/run.d.ts +1 -1
  63. package/dist/core/step-config/run.d.ts.map +1 -1
  64. package/dist/core/step-config/run.js.map +1 -1
  65. package/dist/core/workflow-run-creation.d.ts +3 -3
  66. package/dist/core/workflow-run-creation.d.ts.map +1 -1
  67. package/dist/core/workflow-run-creation.js +3 -4
  68. package/dist/core/workflow-run-creation.js.map +1 -1
  69. package/dist/db/db.d.ts +16 -4
  70. package/dist/db/db.d.ts.map +1 -1
  71. package/dist/db/job-listeners.d.ts +7 -1
  72. package/dist/db/job-listeners.d.ts.map +1 -1
  73. package/dist/db/job-listeners.js +10 -5
  74. package/dist/db/job-listeners.js.map +1 -1
  75. package/dist/db/runner-lease-table.d.ts +5 -5
  76. package/dist/db/runner-lease-table.d.ts.map +1 -1
  77. package/dist/db/runner-lease-table.js +3 -2
  78. package/dist/db/runner-lease-table.js.map +1 -1
  79. package/dist/db/schema/workflow-run-attempts.d.ts +9 -3
  80. package/dist/db/schema/workflow-run-attempts.d.ts.map +1 -1
  81. package/dist/db/schema/workflow-run-attempts.js +2 -1
  82. package/dist/db/schema/workflow-run-attempts.js.map +1 -1
  83. package/dist/db/schema/workflow-runs.js +1 -1
  84. package/dist/db/schema/workflow-runs.js.map +1 -1
  85. package/dist/db/workflow-runs/job-executions.d.ts +5 -0
  86. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
  87. package/dist/db/workflow-runs/job-executions.js +14 -7
  88. package/dist/db/workflow-runs/job-executions.js.map +1 -1
  89. package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
  90. package/dist/db/workflow-runs/jobs.js +3 -1
  91. package/dist/db/workflow-runs/jobs.js.map +1 -1
  92. package/dist/db/workflow-runs/run-create.d.ts +9 -2
  93. package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
  94. package/dist/db/workflow-runs/run-create.js +12 -9
  95. package/dist/db/workflow-runs/run-create.js.map +1 -1
  96. package/dist/db/workflow-runs/run-rerun.d.ts.map +1 -1
  97. package/dist/db/workflow-runs/run-rerun.js +3 -1
  98. package/dist/db/workflow-runs/run-rerun.js.map +1 -1
  99. package/dist/index.d.ts +18 -4
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +61 -37
  102. package/dist/index.js.map +1 -1
  103. package/dist/presentation/dto/checkout-token.d.ts +14 -1
  104. package/dist/presentation/dto/checkout-token.d.ts.map +1 -1
  105. package/dist/presentation/dto/checkout-token.js.map +1 -1
  106. package/dist/presentation/index.d.ts +1 -1
  107. package/dist/presentation/index.d.ts.map +1 -1
  108. package/dist/presentation/index.js +1 -1
  109. package/dist/presentation/index.js.map +1 -1
  110. package/dist/presentation/inter-module.d.ts +18 -0
  111. package/dist/presentation/inter-module.d.ts.map +1 -0
  112. package/dist/presentation/inter-module.js +113 -0
  113. package/dist/presentation/inter-module.js.map +1 -0
  114. package/dist/presentation/routes/agent-runtime-config.d.ts +6 -1
  115. package/dist/presentation/routes/agent-runtime-config.d.ts.map +1 -1
  116. package/dist/presentation/routes/agent-runtime-config.js +59 -57
  117. package/dist/presentation/routes/agent-runtime-config.js.map +1 -1
  118. package/dist/presentation/routes/cancel-run.d.ts +2 -1
  119. package/dist/presentation/routes/cancel-run.d.ts.map +1 -1
  120. package/dist/presentation/routes/cancel-run.js +37 -34
  121. package/dist/presentation/routes/cancel-run.js.map +1 -1
  122. package/dist/presentation/routes/checkout-token.d.ts +8 -1
  123. package/dist/presentation/routes/checkout-token.d.ts.map +1 -1
  124. package/dist/presentation/routes/checkout-token.js +65 -47
  125. package/dist/presentation/routes/checkout-token.js.map +1 -1
  126. package/dist/presentation/routes/get-run-aggregates.d.ts +2 -1
  127. package/dist/presentation/routes/get-run-aggregates.d.ts.map +1 -1
  128. package/dist/presentation/routes/get-run-aggregates.js +44 -53
  129. package/dist/presentation/routes/get-run-aggregates.js.map +1 -1
  130. package/dist/presentation/routes/get-run.d.ts +2 -1
  131. package/dist/presentation/routes/get-run.d.ts.map +1 -1
  132. package/dist/presentation/routes/get-run.js +53 -50
  133. package/dist/presentation/routes/get-run.js.map +1 -1
  134. package/dist/presentation/routes/get-step-secrets.d.ts +3 -1
  135. package/dist/presentation/routes/get-step-secrets.d.ts.map +1 -1
  136. package/dist/presentation/routes/get-step-secrets.js +72 -68
  137. package/dist/presentation/routes/get-step-secrets.js.map +1 -1
  138. package/dist/presentation/routes/index.d.ts +19 -2
  139. package/dist/presentation/routes/index.d.ts.map +1 -1
  140. package/dist/presentation/routes/index.js +38 -30
  141. package/dist/presentation/routes/index.js.map +1 -1
  142. package/dist/presentation/routes/leased-step.d.ts +2 -0
  143. package/dist/presentation/routes/leased-step.d.ts.map +1 -1
  144. package/dist/presentation/routes/leased-step.js +1 -2
  145. package/dist/presentation/routes/leased-step.js.map +1 -1
  146. package/dist/presentation/routes/list-run-attempts.d.ts +2 -1
  147. package/dist/presentation/routes/list-run-attempts.d.ts.map +1 -1
  148. package/dist/presentation/routes/list-run-attempts.js +29 -26
  149. package/dist/presentation/routes/list-run-attempts.js.map +1 -1
  150. package/dist/presentation/routes/list-runs.d.ts +2 -1
  151. package/dist/presentation/routes/list-runs.d.ts.map +1 -1
  152. package/dist/presentation/routes/list-runs.js +51 -60
  153. package/dist/presentation/routes/list-runs.js.map +1 -1
  154. package/dist/presentation/routes/next-step.d.ts +10 -1
  155. package/dist/presentation/routes/next-step.d.ts.map +1 -1
  156. package/dist/presentation/routes/next-step.js +64 -50
  157. package/dist/presentation/routes/next-step.js.map +1 -1
  158. package/dist/presentation/routes/project-access.d.ts +10 -0
  159. package/dist/presentation/routes/project-access.d.ts.map +1 -0
  160. package/dist/presentation/routes/project-access.js +17 -0
  161. package/dist/presentation/routes/project-access.js.map +1 -0
  162. package/dist/presentation/routes/report-step.d.ts +2 -1
  163. package/dist/presentation/routes/report-step.d.ts.map +1 -1
  164. package/dist/presentation/routes/report-step.js +62 -61
  165. package/dist/presentation/routes/report-step.js.map +1 -1
  166. package/dist/presentation/routes/require-accessible-run.d.ts +3 -1
  167. package/dist/presentation/routes/require-accessible-run.d.ts.map +1 -1
  168. package/dist/presentation/routes/require-accessible-run.js +3 -6
  169. package/dist/presentation/routes/require-accessible-run.js.map +1 -1
  170. package/dist/presentation/routes/rerun-run.d.ts +2 -1
  171. package/dist/presentation/routes/rerun-run.d.ts.map +1 -1
  172. package/dist/presentation/routes/rerun-run.js +46 -43
  173. package/dist/presentation/routes/rerun-run.js.map +1 -1
  174. package/dist/temporal/activities/index.d.ts +44 -9
  175. package/dist/temporal/activities/index.d.ts.map +1 -1
  176. package/dist/temporal/activities/index.js +13 -9
  177. package/dist/temporal/activities/index.js.map +1 -1
  178. package/dist/temporal/activities/orchestration-activities.d.ts +20 -11
  179. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
  180. package/dist/temporal/activities/orchestration-activities.js +48 -33
  181. package/dist/temporal/activities/orchestration-activities.js.map +1 -1
  182. package/dist/tsconfig.test.tsbuildinfo +1 -1
  183. package/package.json +28 -21
  184. package/src/core/agent-defaults.test.ts +28 -0
  185. package/src/core/agent-defaults.ts +36 -0
  186. package/src/core/agent-tool-capability-warning.test.ts +36 -11
  187. package/src/core/agent-tool-capability-warning.ts +27 -25
  188. package/src/core/agent-tools.ts +33 -36
  189. package/src/core/checkout.test.ts +38 -25
  190. package/src/core/checkout.ts +41 -14
  191. package/src/core/entities/workflow-run-attempt.ts +1 -1
  192. package/src/core/job-execution.ts +19 -9
  193. package/src/core/job-transition/derive-job-execution-outputs.ts +1 -1
  194. package/src/core/job-transition/derive-job-success.ts +1 -1
  195. package/src/core/listener-execution-materialization.test.ts +4 -2
  196. package/src/core/listener-execution-materialization.ts +6 -9
  197. package/src/core/run-workflow.test.ts +43 -38
  198. package/src/core/run-workflow.ts +26 -9
  199. package/src/core/step-config/agent.ts +24 -26
  200. package/src/core/step-config/complete-step-dispatch-config.test.ts +22 -23
  201. package/src/core/step-config/complete-step-dispatch-config.ts +6 -6
  202. package/src/core/step-config/materialize-job-execution-steps.test.ts +34 -23
  203. package/src/core/step-config/materialize-job-execution-steps.ts +38 -39
  204. package/src/core/step-config/materialize-workflow-model.test.ts +94 -82
  205. package/src/core/step-config/materialize-workflow-model.ts +31 -29
  206. package/src/core/step-config/resolve-job-execution-name.ts +1 -1
  207. package/src/core/step-config/resolve-step-config.ts +11 -9
  208. package/src/core/step-config/run.ts +1 -1
  209. package/src/core/workflow-run-creation.test.ts +14 -10
  210. package/src/core/workflow-run-creation.ts +6 -9
  211. package/src/db/job-listeners.ts +20 -5
  212. package/src/db/runner-lease-table.ts +2 -2
  213. package/src/db/schema/workflow-run-attempts.ts +7 -3
  214. package/src/db/schema/workflow-runs.ts +1 -1
  215. package/src/db/workflow-runs/job-executions.ts +15 -1
  216. package/src/db/workflow-runs/jobs.ts +4 -1
  217. package/src/db/workflow-runs/run-create.test.ts +7 -1
  218. package/src/db/workflow-runs/run-create.ts +25 -15
  219. package/src/db/workflow-runs/run-rerun.test.ts +1 -1
  220. package/src/db/workflow-runs/run-rerun.ts +6 -3
  221. package/src/index.ts +75 -33
  222. package/src/presentation/dto/checkout-token.ts +7 -1
  223. package/src/presentation/index.ts +1 -1
  224. package/src/presentation/inter-module.test.ts +149 -0
  225. package/src/presentation/inter-module.ts +132 -0
  226. package/src/presentation/routes/agent-runtime-config.test.ts +53 -10
  227. package/src/presentation/routes/agent-runtime-config.ts +89 -64
  228. package/src/presentation/routes/cancel-run.test.ts +10 -20
  229. package/src/presentation/routes/cancel-run.ts +30 -27
  230. package/src/presentation/routes/checkout-token.test.ts +52 -33
  231. package/src/presentation/routes/checkout-token.ts +109 -49
  232. package/src/presentation/routes/get-run-aggregates.test.ts +13 -7
  233. package/src/presentation/routes/get-run-aggregates.ts +54 -57
  234. package/src/presentation/routes/get-run.test.ts +10 -18
  235. package/src/presentation/routes/get-run.ts +51 -48
  236. package/src/presentation/routes/get-step-secrets.test.ts +29 -7
  237. package/src/presentation/routes/get-step-secrets.ts +72 -61
  238. package/src/presentation/routes/index.test.ts +16 -1
  239. package/src/presentation/routes/index.ts +54 -29
  240. package/src/presentation/routes/leased-step.ts +3 -2
  241. package/src/presentation/routes/list-run-attempts.test.ts +9 -19
  242. package/src/presentation/routes/list-run-attempts.ts +21 -18
  243. package/src/presentation/routes/list-runs.test.ts +13 -7
  244. package/src/presentation/routes/list-runs.ts +64 -67
  245. package/src/presentation/routes/next-step.test.ts +30 -11
  246. package/src/presentation/routes/next-step.ts +68 -48
  247. package/src/presentation/routes/project-access.ts +16 -0
  248. package/src/presentation/routes/report-step.test.ts +18 -2
  249. package/src/presentation/routes/report-step.ts +51 -49
  250. package/src/presentation/routes/require-accessible-run.ts +5 -2
  251. package/src/presentation/routes/rerun-run.test.ts +9 -19
  252. package/src/presentation/routes/rerun-run.ts +39 -36
  253. package/src/temporal/activities/index.ts +32 -12
  254. package/src/temporal/activities/orchestration-activities.test.ts +10 -8
  255. package/src/temporal/activities/orchestration-activities.ts +74 -50
  256. package/src/temporal/workflows/job-execution-orchestration.test.ts +47 -2
  257. package/test/env.ts +1 -3
  258. package/test/factories/project.ts +10 -5
  259. package/test/factories/workflow-model.test.ts +5 -1
  260. package/test/factories/workflow-model.ts +1 -1
  261. package/test/factories/workflow-run.ts +1 -1
  262. package/test/fixtures/agent-inter-module.ts +27 -0
  263. package/test/fixtures/annotations-inter-module.ts +5 -0
  264. package/test/fixtures/auth-inter-module.ts +22 -0
  265. package/test/fixtures/lease-token.ts +2 -1
  266. package/test/fixtures/projects-inter-module.ts +8 -0
  267. package/test/fixtures/runners-inter-module.ts +52 -0
  268. package/test/fixtures/secrets-inter-module.ts +61 -0
  269. package/test/globalSetup.ts +11 -11
  270. package/tsconfig.build.tsbuildinfo +1 -1
  271. package/dist/core/source-control.d.ts +0 -5
  272. package/dist/core/source-control.d.ts.map +0 -1
  273. package/dist/core/source-control.js +0 -19
  274. package/dist/core/source-control.js.map +0 -1
  275. package/src/core/source-control.test.ts +0 -17
  276. package/src/core/source-control.ts +0 -22
  277. 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 {ProjectNotFoundError, requireProjectAccess} from '@shipfox/api-projects';\nimport {\n workflowRunAggregatesQuerySchema,\n workflowRunAggregatesResponseSchema,\n} from '@shipfox/api-workflows-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {getWorkflowRunAggregates} from '#db/index.js';\n\nexport const getRunAggregatesRoute = 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 errorHandler: (error) => {\n if (error instanceof ProjectNotFoundError) {\n throw new ClientError(error.message, 'project-not-found', {status: 404});\n }\n throw error;\n },\n handler: async (request) => {\n const startedAt = performance.now();\n const {\n project_id: projectId,\n 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});\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"],"names":["ProjectNotFoundError","requireProjectAccess","workflowRunAggregatesQuerySchema","workflowRunAggregatesResponseSchema","ClientError","defineRoute","logger","getWorkflowRunAggregates","getRunAggregatesRoute","method","path","description","schema","querystring","response","errorHandler","error","message","status","handler","request","startedAt","performance","now","project_id","projectId","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","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B;gBACpB/B,QAAQqB,WAAWrB,MAAM,CAACgC,MAAM;gBAChCrB,eAAeU,WAAWV,aAAa,CAACqB,MAAM;gBAC9CC,UAAUZ,WAAWY,QAAQ,CAACD,MAAM;YACtC;YACAE,YAAYC,KAAKC,KAAK,CAAChC,YAAYC,GAAG,KAAKF;QAC7C,GACA;QAGF,OAAO;YACLH,QAAQqB,WAAWrB,MAAM;YACzBU,gBAAgBW,WAAWV,aAAa;YACxCsB,UAAUZ,WAAWY,QAAQ;QAC/B;IACF;AACF,GAAG"}
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
- export declare const getRunRoute: import("@shipfox/node-fastify").RouteDefinition;
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":"AAcA,eAAO,MAAM,WAAW,iDAmDtB,CAAC"}
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 const getRunRoute = defineRoute({
8
- method: 'GET',
9
- path: '/:id',
10
- description: 'Get a workflow run by ID with jobs and steps',
11
- schema: {
12
- params: z.object({
13
- id: z.string().uuid()
14
- }),
15
- querystring: z.object({
16
- attempt: z.coerce.number().int().positive().optional()
17
- }),
18
- response: {
19
- 200: workflowRunDetailResponseSchema
20
- }
21
- },
22
- handler: async (request)=>{
23
- const { id } = request.params;
24
- await requireAccessibleRun({
25
- request,
26
- id
27
- });
28
- const run = await getWorkflowRunDetail(id, request.query.attempt);
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
- const jobDtos = run.jobs.map((job)=>({
35
- ...toJobDto(job),
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 const getRunRoute = 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});\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"],"names":["workflowRunDetailResponseSchema","ClientError","defineRoute","z","getWorkflowRunDetail","toJobDto","toJobExecutionDto","toRunAttemptDto","toRunDto","toStepAttemptDto","toStepDto","requireAccessibleRun","getRunRoute","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":"AAAA,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;AAC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ACF;wBACF;oBACF,CAAA;YACF,CAAA;QAEA,OAAO;YACL,GAAGpC,SAASwB,KAAKA,IAAImB,aAAa,CAAC;YACnCC,aAAa7C,gBAAgByB,IAAIqB,UAAU;YAC3CjB,MAAMD;QACR;IACF;AACF,GAAG"}
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
- export declare const getStepSecretsRoute: import("@shipfox/node-fastify").RouteDefinition;
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":"AAgBA,eAAO,MAAM,mBAAmB,iDAiE9B,CAAC"}
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 const getStepSecretsRoute = defineRoute({
10
- method: 'GET',
11
- path: '/steps/:stepId/secrets',
12
- 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.",
13
- schema: {
14
- params: stepSecretsParamsSchema,
15
- querystring: stepSecretsQuerySchema,
16
- response: {
17
- 200: stepSecretsResponseSchema
18
- }
19
- },
20
- errorHandler: (error)=>{
21
- if (error instanceof SecretDecryptionError) {
22
- captureException(error);
23
- throw new ClientError('Step secret could not be decrypted', 'secret-value-invalid', {
24
- status: 409,
25
- cause: error
26
- });
27
- }
28
- throw error;
29
- },
30
- handler: async (request, reply)=>{
31
- const { stepId } = request.params;
32
- const { attempt } = request.query;
33
- const { leasedJob, step, workspaceId, projectId } = await loadRunningLeasedStep({
34
- request,
35
- stepId,
36
- attempt
37
- });
38
- if (step.type !== 'run') {
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 (value === null) {
54
- throw new ClientError('Secret not found', 'secret-not-found', {
55
- status: 422
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
- ...reference,
60
- value
80
+ secrets
61
81
  };
62
- }));
63
- logger().info({
64
- jobId: leasedJob.jobId,
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 {getSecret, SecretDecryptionError} from '@shipfox/api-secrets';\nimport {\n materializedSecretBindingSchema,\n type StepSecretDto,\n stepSecretsParamsSchema,\n stepSecretsQuerySchema,\n stepSecretsResponseSchema,\n} from '@shipfox/api-secrets-dto';\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 const getStepSecretsRoute = 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 (error instanceof SecretDecryptionError) {\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 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 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\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":["getSecret","SecretDecryptionError","materializedSecretBindingSchema","stepSecretsParamsSchema","stepSecretsQuerySchema","stepSecretsResponseSchema","captureException","ClientError","defineRoute","logger","ZodError","z","loadRunningLeasedStep","secretBindingsSchema","array","getStepSecretsRoute","method","path","description","schema","params","querystring","response","errorHandler","error","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":"AAAA,SAAQA,SAAS,EAAEC,qBAAqB,QAAO,uBAAuB;AACtE,SACEC,+BAA+B,EAE/BC,uBAAuB,EACvBC,sBAAsB,EACtBC,yBAAyB,QACpB,2BAA2B;AAClC,SAAQC,gBAAgB,QAAO,iCAAiC;AAChE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,QAAQ,EAAEC,CAAC,QAAO,MAAM;AAChC,SAAQC,qBAAqB,QAAO,mBAAmB;AAEvD,MAAMC,uBAAuBF,EAAEG,KAAK,CAACZ;AAErC,OAAO,MAAMa,sBAAsBP,YAAY;IAC7CQ,QAAQ;IACRC,MAAM;IACNC,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AEnB;YAAaL;YAAQ4B,MAAMhB,WAAWK,GAAG,CAAC,CAACY,MAAQA,IAAIR,GAAG;QAAC,GACpF;QAGFtB,MAAM+B,MAAM,CAAC,iBAAiB;QAC9B,OAAO;YAAChB;QAAO;IACjB;AACF,GAAG;AAEH,SAASL,oBAAoBU,KAAc;IACzC,IAAI;QACF,OAAOpC,qBAAqBgD,KAAK,CAACZ,SAAS,EAAE;IAC/C,EAAE,OAAOzB,OAAO;QACd,IAAIA,iBAAiBd,UAAU;YAC7B,MAAM,IAAIH,YAAY,oCAAoC,2BAA2B;gBACnFkB,QAAQ;gBACRC,OAAOF;YACT;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAASmB,yBACPmB,QAAwE;IAExE,MAAMC,OAAO,IAAIC;IACjB,MAAMtB,aAA0D,EAAE;IAClE,KAAK,MAAMuB,WAAWH,SAAU;QAC9B,KAAK,MAAMI,WAAWD,QAAQE,QAAQ,CAAE;YACtC,IAAID,QAAQE,IAAI,KAAK,UAAU;YAC/B,MAAMC,KAAKC,kBAAkBJ;YAC7B,IAAIH,KAAKQ,GAAG,CAACF,KAAK;YAClBN,KAAKS,GAAG,CAACH;YACT3B,WAAW+B,IAAI,CAAC;gBAACrB,OAAOc,QAAQd,KAAK;gBAAED,KAAKe,QAAQf,GAAG;YAAA;QACzD;IACF;IACA,OAAOT;AACT;AAEA,SAAS4B,kBAAkBtB,SAA+C;IACxE,OAAO,GAAGA,UAAUI,KAAK,CAAC,EAAE,EAAEJ,UAAUG,GAAG,EAAE;AAC/C"}
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":"AACA,SACEA,+BAA+B,EAE/BC,uBAAuB,EACvBC,sBAAsB,EACtBC,yBAAyB,QACpB,2BAA2B;AAClC,SAEEC,0BAA0B,QACrB,wCAAwC;AAC/C,SAAQC,uBAAuB,QAAO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BAAED,KAAKe,QAAQf,GAAG;YAAA;QACzD;IACF;IACA,OAAOT;AACT;AAEA,SAAS4B,kBAAkBtB,SAA+C;IACxE,OAAO,GAAGA,UAAUI,KAAK,CAAC,EAAE,EAAEJ,UAAUG,GAAG,EAAE;AAC/C"}
@@ -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
- export declare const leaseTokenRouteGroup: RouteGroup;
3
- export declare const workflowRoutes: RouteGroup[];
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":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAatD,eAAO,MAAM,oBAAoB,EAAE,UAWlC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,UAAU,EActC,CAAC"}
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 { agentRuntimeConfigRoute } from './agent-runtime-config.js';
2
+ import { createAgentRuntimeConfigRoute } from './agent-runtime-config.js';
3
3
  import { cancelRunRoute } from './cancel-run.js';
4
- import { checkoutTokenRoute } from './checkout-token.js';
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 { getStepSecretsRoute } from './get-step-secrets.js';
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 { nextStepRoute } from './next-step.js';
11
- import { reportStepRoute } from './report-step.js';
10
+ import { createNextStepRoute } from './next-step.js';
11
+ import { createReportStepRoute } from './report-step.js';
12
12
  import { rerunRunRoute } from './rerun-run.js';
13
- export const leaseTokenRouteGroup = {
14
- // The lease token names the job, so the path carries no job id ("current").
15
- prefix: '/runs/jobs/current',
16
- auth: AUTH_LEASED_JOB,
17
- routes: [
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
- listRunsRoute,
31
- getRunAggregatesRoute,
32
- listRunAttemptsRoute,
33
- getRunRoute,
34
- cancelRunRoute,
35
- rerunRunRoute
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
- leaseTokenRouteGroup
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 {agentRuntimeConfigRoute} from './agent-runtime-config.js';\nimport {cancelRunRoute} from './cancel-run.js';\nimport {checkoutTokenRoute} from './checkout-token.js';\nimport {getRunRoute} from './get-run.js';\nimport {getRunAggregatesRoute} from './get-run-aggregates.js';\nimport {getStepSecretsRoute} from './get-step-secrets.js';\nimport {listRunAttemptsRoute} from './list-run-attempts.js';\nimport {listRunsRoute} from './list-runs.js';\nimport {nextStepRoute} from './next-step.js';\nimport {reportStepRoute} from './report-step.js';\nimport {rerunRunRoute} from './rerun-run.js';\n\nexport const leaseTokenRouteGroup: RouteGroup = {\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 nextStepRoute,\n reportStepRoute,\n checkoutTokenRoute,\n agentRuntimeConfigRoute,\n getStepSecretsRoute,\n ],\n};\n\nexport const workflowRoutes: RouteGroup[] = [\n {\n prefix: '/workflows/runs',\n auth: AUTH_USER,\n routes: [\n listRunsRoute,\n getRunAggregatesRoute,\n listRunAttemptsRoute,\n getRunRoute,\n cancelRunRoute,\n rerunRunRoute,\n ],\n },\n leaseTokenRouteGroup,\n];\n"],"names":["AUTH_LEASED_JOB","AUTH_USER","agentRuntimeConfigRoute","cancelRunRoute","checkoutTokenRoute","getRunRoute","getRunAggregatesRoute","getStepSecretsRoute","listRunAttemptsRoute","listRunsRoute","nextStepRoute","reportStepRoute","rerunRunRoute","leaseTokenRouteGroup","prefix","auth","routes","workflowRoutes"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,SAAS,QAAO,4BAA4B;AAErE,SAAQC,uBAAuB,QAAO,4BAA4B;AAClE,SAAQC,cAAc,QAAO,kBAAkB;AAC/C,SAAQC,kBAAkB,QAAO,sBAAsB;AACvD,SAAQC,WAAW,QAAO,eAAe;AACzC,SAAQC,qBAAqB,QAAO,0BAA0B;AAC9D,SAAQC,mBAAmB,QAAO,wBAAwB;AAC1D,SAAQC,oBAAoB,QAAO,yBAAyB;AAC5D,SAAQC,aAAa,QAAO,iBAAiB;AAC7C,SAAQC,aAAa,QAAO,iBAAiB;AAC7C,SAAQC,eAAe,QAAO,mBAAmB;AACjD,SAAQC,aAAa,QAAO,iBAAiB;AAE7C,OAAO,MAAMC,uBAAmC;IAC9C,4EAA4E;IAC5EC,QAAQ;IACRC,MAAMf;IACNgB,QAAQ;QACNN;QACAC;QACAP;QACAF;QACAK;KACD;AACH,EAAE;AAEF,OAAO,MAAMU,iBAA+B;IAC1C;QACEH,QAAQ;QACRC,MAAMd;QACNe,QAAQ;YACNP;YACAH;YACAE;YACAH;YACAF;YACAS;SACD;IACH;IACAC;CACD,CAAC"}
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;AAGzF,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,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAoCnC"}
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 isJobLeaseActive({
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 {isJobLeaseActive} from '@shipfox/api-runners';\nimport {ClientError} from '@shipfox/node-fastify';\nimport type {Step} from '#core/entities/step.js';\nimport {getJobScope, getStepByIdForJobExecution} from '#db/index.js';\n\nexport interface LoadedRunningLeasedStep {\n leasedJob: LeasedJobContext;\n step: Step;\n workspaceId: string;\n projectId: string;\n}\n\nexport async function loadRunningLeasedStep(params: {\n request: object;\n stepId: string;\n attempt: number;\n}): Promise<LoadedRunningLeasedStep> {\n const leasedJob = requireLeasedJobContext(params.request);\n\n const leaseIsActive = await isJobLeaseActive({\n jobId: leasedJob.jobId,\n jobExecutionId: leasedJob.jobExecutionId,\n runnerSessionId: leasedJob.runnerSessionId,\n });\n if (!leaseIsActive) {\n throw new ClientError('Job lease is no longer active', 'lease-not-active', {status: 404});\n }\n\n const step = await getStepByIdForJobExecution({\n stepId: params.stepId,\n jobExecutionId: leasedJob.jobExecutionId,\n });\n if (!step) {\n throw new ClientError('Step not found for leased job', 'step-not-found', {status: 404});\n }\n\n const scope = await getJobScope(leasedJob.jobId);\n if (!scope) {\n throw new ClientError('Leased job not found', 'job-not-found', {status: 404});\n }\n\n if (step.currentAttempt !== params.attempt) {\n throw new ClientError('Step attempt does not match current attempt', 'step-attempt-mismatch', {\n status: 409,\n });\n }\n\n if (step.status !== 'running') {\n throw new ClientError('Step is not running', 'step-not-running', {status: 409});\n }\n\n return {leasedJob, step, workspaceId: scope.workspaceId, projectId: scope.projectId};\n}\n"],"names":["requireLeasedJobContext","isJobLeaseActive","ClientError","getJobScope","getStepByIdForJobExecution","loadRunningLeasedStep","params","leasedJob","request","leaseIsActive","jobId","jobExecutionId","runnerSessionId","status","step","stepId","scope","currentAttempt","attempt","workspaceId","projectId"],"mappings":"AAAA,SAA+BA,uBAAuB,QAAO,4BAA4B;AACzF,SAAQC,gBAAgB,QAAO,uBAAuB;AACtD,SAAQC,WAAW,QAAO,wBAAwB;AAElD,SAAQC,WAAW,EAAEC,0BAA0B,QAAO,eAAe;AASrE,OAAO,eAAeC,sBAAsBC,MAI3C;IACC,MAAMC,YAAYP,wBAAwBM,OAAOE,OAAO;IAExD,MAAMC,gBAAgB,MAAMR,iBAAiB;QAC3CS,OAAOH,UAAUG,KAAK;QACtBC,gBAAgBJ,UAAUI,cAAc;QACxCC,iBAAiBL,UAAUK,eAAe;IAC5C;IACA,IAAI,CAACH,eAAe;QAClB,MAAM,IAAIP,YAAY,iCAAiC,oBAAoB;YAACW,QAAQ;QAAG;IACzF;IAEA,MAAMC,OAAO,MAAMV,2BAA2B;QAC5CW,QAAQT,OAAOS,MAAM;QACrBJ,gBAAgBJ,UAAUI,cAAc;IAC1C;IACA,IAAI,CAACG,MAAM;QACT,MAAM,IAAIZ,YAAY,iCAAiC,kBAAkB;YAACW,QAAQ;QAAG;IACvF;IAEA,MAAMG,QAAQ,MAAMb,YAAYI,UAAUG,KAAK;IAC/C,IAAI,CAACM,OAAO;QACV,MAAM,IAAId,YAAY,wBAAwB,iBAAiB;YAACW,QAAQ;QAAG;IAC7E;IAEA,IAAIC,KAAKG,cAAc,KAAKX,OAAOY,OAAO,EAAE;QAC1C,MAAM,IAAIhB,YAAY,+CAA+C,yBAAyB;YAC5FW,QAAQ;QACV;IACF;IAEA,IAAIC,KAAKD,MAAM,KAAK,WAAW;QAC7B,MAAM,IAAIX,YAAY,uBAAuB,oBAAoB;YAACW,QAAQ;QAAG;IAC/E;IAEA,OAAO;QAACN;QAAWO;QAAMK,aAAaH,MAAMG,WAAW;QAAEC,WAAWJ,MAAMI,SAAS;IAAA;AACrF"}
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
- export declare const listRunAttemptsRoute: import("@shipfox/node-fastify").RouteDefinition;
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":"AAOA,eAAO,MAAM,oBAAoB,iDAmB/B,CAAC"}
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"}