@shipfox/api-definitions 13.1.0 → 14.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.
Files changed (223) hide show
  1. package/.turbo/turbo-build.log +11 -11
  2. package/CHANGELOG.md +35 -0
  3. package/dist/core/entities/index.d.ts +1 -1
  4. package/dist/core/entities/index.d.ts.map +1 -1
  5. package/dist/core/entities/index.js +1 -1
  6. package/dist/core/entities/index.js.map +1 -1
  7. package/dist/core/entities/integration-context.d.ts +4 -0
  8. package/dist/core/entities/integration-context.d.ts.map +1 -1
  9. package/dist/core/entities/integration-context.js.map +1 -1
  10. package/dist/core/entities/sync-state.d.ts +10 -4
  11. package/dist/core/entities/sync-state.d.ts.map +1 -1
  12. package/dist/core/entities/sync-state.js +26 -7
  13. package/dist/core/entities/sync-state.js.map +1 -1
  14. package/dist/core/entities/validation-diagnostic.d.ts +8 -0
  15. package/dist/core/entities/validation-diagnostic.d.ts.map +1 -0
  16. package/dist/core/entities/validation-diagnostic.js +3 -0
  17. package/dist/core/entities/validation-diagnostic.js.map +1 -0
  18. package/dist/core/entities/workflow-definition.d.ts +2 -0
  19. package/dist/core/entities/workflow-definition.d.ts.map +1 -1
  20. package/dist/core/entities/workflow-definition.js.map +1 -1
  21. package/dist/core/errors.d.ts +10 -0
  22. package/dist/core/errors.d.ts.map +1 -1
  23. package/dist/core/errors.js +9 -0
  24. package/dist/core/errors.js.map +1 -1
  25. package/dist/core/index.d.ts +2 -1
  26. package/dist/core/index.d.ts.map +1 -1
  27. package/dist/core/index.js +2 -1
  28. package/dist/core/index.js.map +1 -1
  29. package/dist/core/integrations.d.ts +3 -1
  30. package/dist/core/integrations.d.ts.map +1 -1
  31. package/dist/core/integrations.js +10 -2
  32. package/dist/core/integrations.js.map +1 -1
  33. package/dist/core/parse-definition.d.ts +4 -4
  34. package/dist/core/parse-definition.d.ts.map +1 -1
  35. package/dist/core/parse-definition.js +5 -5
  36. package/dist/core/parse-definition.js.map +1 -1
  37. package/dist/core/resolve-definition-at-ref.d.ts +66 -0
  38. package/dist/core/resolve-definition-at-ref.d.ts.map +1 -0
  39. package/dist/core/resolve-definition-at-ref.js +374 -0
  40. package/dist/core/resolve-definition-at-ref.js.map +1 -0
  41. package/dist/core/sync-definitions.d.ts +2 -2
  42. package/dist/core/sync-definitions.d.ts.map +1 -1
  43. package/dist/core/sync-definitions.js +5 -5
  44. package/dist/core/sync-definitions.js.map +1 -1
  45. package/dist/core/validate-definition.d.ts +3 -3
  46. package/dist/core/validate-definition.d.ts.map +1 -1
  47. package/dist/core/validate-definition.js +17 -12
  48. package/dist/core/validate-definition.js.map +1 -1
  49. package/dist/core/workflow-model/cron-trigger.d.ts +1 -1
  50. package/dist/core/workflow-model/cron-trigger.d.ts.map +1 -1
  51. package/dist/core/workflow-model/cron-trigger.js +9 -5
  52. package/dist/core/workflow-model/cron-trigger.js.map +1 -1
  53. package/dist/core/workflow-model/index.d.ts +1 -1
  54. package/dist/core/workflow-model/index.d.ts.map +1 -1
  55. package/dist/core/workflow-model/index.js.map +1 -1
  56. package/dist/core/workflow-model/invalid-workflow-model-error.d.ts +4 -2
  57. package/dist/core/workflow-model/invalid-workflow-model-error.d.ts.map +1 -1
  58. package/dist/core/workflow-model/invalid-workflow-model-error.js.map +1 -1
  59. package/dist/core/workflow-model/normalize-job-listening.d.ts.map +1 -1
  60. package/dist/core/workflow-model/normalize-job-listening.js +51 -30
  61. package/dist/core/workflow-model/normalize-job-listening.js.map +1 -1
  62. package/dist/core/workflow-model/normalize-triggers.d.ts +1 -1
  63. package/dist/core/workflow-model/normalize-triggers.d.ts.map +1 -1
  64. package/dist/core/workflow-model/normalize-triggers.js +48 -18
  65. package/dist/core/workflow-model/normalize-triggers.js.map +1 -1
  66. package/dist/core/workflow-model/normalize-workflow-document.d.ts +1 -1
  67. package/dist/core/workflow-model/normalize-workflow-document.d.ts.map +1 -1
  68. package/dist/core/workflow-model/normalize-workflow-document.js +3 -3
  69. package/dist/core/workflow-model/normalize-workflow-document.js.map +1 -1
  70. package/dist/core/workflow-model/parse-interpolation-field.d.ts.map +1 -1
  71. package/dist/core/workflow-model/parse-interpolation-field.js +1 -15
  72. package/dist/core/workflow-model/parse-interpolation-field.js.map +1 -1
  73. package/dist/core/workflow-model/validate-predicate-expression.d.ts +3 -1
  74. package/dist/core/workflow-model/validate-predicate-expression.d.ts.map +1 -1
  75. package/dist/core/workflow-model/validate-predicate-expression.js +3 -0
  76. package/dist/core/workflow-model/validate-predicate-expression.js.map +1 -1
  77. package/dist/core/workflow-model/validation-issue.d.ts +2 -1
  78. package/dist/core/workflow-model/validation-issue.d.ts.map +1 -1
  79. package/dist/core/workflow-model/validation-issue.js +12 -15
  80. package/dist/core/workflow-model/validation-issue.js.map +1 -1
  81. package/dist/db/db.d.ts +196 -4
  82. package/dist/db/db.d.ts.map +1 -1
  83. package/dist/db/db.js +3 -1
  84. package/dist/db/db.js.map +1 -1
  85. package/dist/db/definition-triggers.js +3 -1
  86. package/dist/db/definition-triggers.js.map +1 -1
  87. package/dist/db/definitions.d.ts +17 -0
  88. package/dist/db/definitions.d.ts.map +1 -1
  89. package/dist/db/definitions.js +190 -23
  90. package/dist/db/definitions.js.map +1 -1
  91. package/dist/db/index.d.ts +2 -1
  92. package/dist/db/index.d.ts.map +1 -1
  93. package/dist/db/index.js +2 -1
  94. package/dist/db/index.js.map +1 -1
  95. package/dist/db/schema/definitions.d.ts +17 -0
  96. package/dist/db/schema/definitions.d.ts.map +1 -1
  97. package/dist/db/schema/definitions.js +8 -0
  98. package/dist/db/schema/definitions.js.map +1 -1
  99. package/dist/db/schema/sync-states.d.ts +7 -3
  100. package/dist/db/schema/sync-states.d.ts.map +1 -1
  101. package/dist/db/schema/sync-states.js +5 -1
  102. package/dist/db/schema/sync-states.js.map +1 -1
  103. package/dist/db/schema/workflows.d.ts +78 -0
  104. package/dist/db/schema/workflows.d.ts.map +1 -0
  105. package/dist/db/schema/workflows.js +17 -0
  106. package/dist/db/schema/workflows.js.map +1 -0
  107. package/dist/db/sync-states.d.ts +2 -2
  108. package/dist/db/sync-states.d.ts.map +1 -1
  109. package/dist/db/sync-states.js +4 -4
  110. package/dist/db/sync-states.js.map +1 -1
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +5 -1
  113. package/dist/index.js.map +1 -1
  114. package/dist/metrics/index.d.ts +2 -0
  115. package/dist/metrics/index.d.ts.map +1 -0
  116. package/dist/metrics/index.js +3 -0
  117. package/dist/metrics/index.js.map +1 -0
  118. package/dist/metrics/instance.d.ts +4 -0
  119. package/dist/metrics/instance.d.ts.map +1 -0
  120. package/dist/metrics/instance.js +19 -0
  121. package/dist/metrics/instance.js.map +1 -0
  122. package/dist/presentation/dto/definition.d.ts.map +1 -1
  123. package/dist/presentation/dto/definition.js +11 -4
  124. package/dist/presentation/dto/definition.js.map +1 -1
  125. package/dist/presentation/inter-module.d.ts +9 -1
  126. package/dist/presentation/inter-module.d.ts.map +1 -1
  127. package/dist/presentation/inter-module.js +66 -2
  128. package/dist/presentation/inter-module.js.map +1 -1
  129. package/dist/presentation/routes/create-definition.d.ts.map +1 -1
  130. package/dist/presentation/routes/create-definition.js +16 -3
  131. package/dist/presentation/routes/create-definition.js.map +1 -1
  132. package/dist/presentation/routes/get-definition.d.ts.map +1 -1
  133. package/dist/presentation/routes/get-definition.js +18 -4
  134. package/dist/presentation/routes/get-definition.js.map +1 -1
  135. package/dist/presentation/routes/project-access.d.ts +1 -0
  136. package/dist/presentation/routes/project-access.d.ts.map +1 -1
  137. package/dist/presentation/routes/validate-definition.js +3 -3
  138. package/dist/presentation/routes/validate-definition.js.map +1 -1
  139. package/dist/temporal/activities/sync-activities.d.ts +3 -3
  140. package/dist/temporal/activities/sync-activities.d.ts.map +1 -1
  141. package/dist/temporal/activities/sync-activities.js +7 -4
  142. package/dist/temporal/activities/sync-activities.js.map +1 -1
  143. package/dist/temporal/workflows/definition-sync.js +1 -1
  144. package/dist/temporal/workflows/definition-sync.js.map +1 -1
  145. package/dist/temporal/workflows/index.bundle.js +50 -22
  146. package/dist/tsconfig.test.tsbuildinfo +1 -1
  147. package/drizzle/0003_nebulous_nemesis.sql +11 -0
  148. package/drizzle/0004_workflow_ref_lookup.sql +1 -0
  149. package/drizzle/meta/0003_snapshot.json +627 -0
  150. package/drizzle/meta/0004_snapshot.json +649 -0
  151. package/drizzle/meta/_journal.json +14 -0
  152. package/drizzle.config.ts +1 -0
  153. package/package.json +7 -7
  154. package/src/core/entities/index.ts +1 -1
  155. package/src/core/entities/integration-context.ts +4 -0
  156. package/src/core/entities/sync-state.test.ts +49 -0
  157. package/src/core/entities/sync-state.ts +35 -12
  158. package/src/core/entities/validation-diagnostic.ts +8 -0
  159. package/src/core/entities/workflow-definition.ts +2 -0
  160. package/src/core/errors.ts +26 -0
  161. package/src/core/index.ts +12 -0
  162. package/src/core/integrations.test.ts +38 -0
  163. package/src/core/integrations.ts +10 -1
  164. package/src/core/parse-definition-diagnostics.test.ts +47 -0
  165. package/src/core/parse-definition.test.ts +29 -5
  166. package/src/core/parse-definition.ts +7 -7
  167. package/src/core/resolve-definition-at-ref.test.ts +792 -0
  168. package/src/core/resolve-definition-at-ref.ts +551 -0
  169. package/src/core/sync-definitions.test.ts +61 -2
  170. package/src/core/sync-definitions.ts +7 -7
  171. package/src/core/validate-definition.test.ts +31 -22
  172. package/src/core/validate-definition.ts +21 -13
  173. package/src/core/workflow-model/cron-trigger.ts +6 -2
  174. package/src/core/workflow-model/index.ts +1 -0
  175. package/src/core/workflow-model/invalid-workflow-model-error.ts +5 -1
  176. package/src/core/workflow-model/normalize-job-listening.ts +55 -23
  177. package/src/core/workflow-model/normalize-triggers.ts +44 -15
  178. package/src/core/workflow-model/normalize-workflow-document.test.ts +444 -36
  179. package/src/core/workflow-model/normalize-workflow-document.ts +8 -4
  180. package/src/core/workflow-model/parse-interpolation-field.ts +1 -23
  181. package/src/core/workflow-model/validate-predicate-expression.ts +6 -0
  182. package/src/core/workflow-model/validation-issue.ts +8 -13
  183. package/src/db/db.ts +7 -1
  184. package/src/db/definition-triggers.test.ts +44 -0
  185. package/src/db/definition-triggers.ts +1 -1
  186. package/src/db/definitions.test.ts +300 -1
  187. package/src/db/definitions.ts +282 -28
  188. package/src/db/index.ts +2 -0
  189. package/src/db/schema/definitions.test.ts +1 -0
  190. package/src/db/schema/definitions.ts +11 -0
  191. package/src/db/schema/sync-states.ts +12 -3
  192. package/src/db/schema/workflows.ts +23 -0
  193. package/src/db/sync-states.test.ts +87 -18
  194. package/src/db/sync-states.ts +6 -6
  195. package/src/db/workflow-lineage-migration.test.ts +158 -0
  196. package/src/index.ts +3 -1
  197. package/src/metrics/index.ts +1 -0
  198. package/src/metrics/instance.test.ts +50 -0
  199. package/src/metrics/instance.ts +23 -0
  200. package/src/presentation/dto/definition.test.ts +89 -1
  201. package/src/presentation/dto/definition.ts +8 -5
  202. package/src/presentation/inter-module.test.ts +177 -0
  203. package/src/presentation/inter-module.ts +77 -4
  204. package/src/presentation/routes/create-definition.test.ts +38 -0
  205. package/src/presentation/routes/create-definition.ts +20 -3
  206. package/src/presentation/routes/get-definition.test.ts +125 -11
  207. package/src/presentation/routes/get-definition.ts +21 -4
  208. package/src/presentation/routes/list-definitions.test.ts +1 -1
  209. package/src/presentation/routes/validate-definition.test.ts +1 -1
  210. package/src/presentation/routes/validate-definition.ts +3 -3
  211. package/src/presentation/subscribers/on-integration-connection-available.test.ts +3 -0
  212. package/src/temporal/activities/sync-activities.test.ts +46 -2
  213. package/src/temporal/activities/sync-activities.ts +9 -7
  214. package/src/temporal/workflows/definition-sync.ts +1 -1
  215. package/test/factories/definition.ts +1 -0
  216. package/test/globalSetup.ts +2 -0
  217. package/tsconfig.build.tsbuildinfo +1 -1
  218. package/dist/core/entities/validation-warning.d.ts +0 -6
  219. package/dist/core/entities/validation-warning.d.ts.map +0 -1
  220. package/dist/core/entities/validation-warning.js +0 -3
  221. package/dist/core/entities/validation-warning.js.map +0 -1
  222. package/src/core/entities/validation-warning.ts +0 -5
  223. package/src/core/parse-definition-warnings.test.ts +0 -33
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n DEFINITION_RESOLVED,\n type DefinitionsEventMap,\n definitionsEventSchemas,\n} from '@shipfox/api-definitions-dto';\nimport {\n INTEGRATION_CONNECTION_AVAILABLE,\n type IntegrationsEventMap,\n} from '@shipfox/api-integration-core-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {\n PROJECT_SOURCE_BOUND,\n PROJECT_SOURCE_COMMIT_OBSERVED,\n type ProjectsEventMap,\n} from '@shipfox/api-projects-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {createDefinitionsSourceControl} from '#core/integrations.js';\nimport {db, definitionsOutbox, migrationsPath} from '#db/index.js';\nimport {createDefinitionRoutes} from '#presentation/index.js';\nimport {createDefinitionsInterModulePresentation} from '#presentation/inter-module.js';\nimport {\n createOnIntegrationConnectionAvailable,\n onProjectSourceBound,\n onProjectSourceCommitObserved,\n} from '#presentation/subscribers/index.js';\nimport {createDefinitionSyncActivities, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';\nimport {definitionWorkflowPath} from './config.js';\n\nexport type {\n WorkflowDefinition,\n WorkflowDefinitionPayload,\n WorkflowEnvTemplates,\n WorkflowModel,\n WorkflowModelJobCheckout,\n WorkflowSourceSnapshot,\n WorkflowSpec,\n} from '#core/index.js';\nexport {\n DEFAULT_JOB_CHECKOUT,\n DEFAULT_JOB_SUCCESS,\n DEFAULT_RUN_TIMEOUT_MS,\n normalizeWorkflowDocument,\n} from '#core/index.js';\nexport {db, definitionsOutbox, getDefinitionById, migrationsPath} from '#db/index.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<\n DefinitionsEventMap & IntegrationsEventMap & ProjectsEventMap\n>();\n\nexport interface CreateDefinitionsModuleOptions {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations: IntegrationsModuleClient;\n}\n\nexport function createDefinitionsModule({\n projects,\n agent,\n integrations,\n}: CreateDefinitionsModuleOptions): ShipfoxModule {\n const sourceControl = createDefinitionsSourceControl(integrations);\n\n return {\n name: 'definitions',\n database: {db, migrationsPath, databaseNamespace: 'definitions'},\n routes: createDefinitionRoutes({projects, agent, integrations}),\n publishers: [\n {name: 'definitions', table: definitionsOutbox, db, eventSchemas: definitionsEventSchemas},\n ],\n subscribers: [\n subscriber(DEFINITION_RESOLVED, (_payload, event) => {\n logger().info({event}, 'Definition resolved');\n return Promise.resolve();\n }),\n subscriber(\n INTEGRATION_CONNECTION_AVAILABLE,\n createOnIntegrationConnectionAvailable(projects),\n ),\n subscriber(PROJECT_SOURCE_BOUND, onProjectSourceBound),\n subscriber(PROJECT_SOURCE_COMMIT_OBSERVED, onProjectSourceCommitObserved),\n ],\n workers: [\n {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowsPath,\n activities: () =>\n createDefinitionSyncActivities(sourceControl, agent, integrations, {\n workflowPath: definitionWorkflowPath,\n }),\n workflows: [],\n },\n ],\n interModulePresentations: [createDefinitionsInterModulePresentation()],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","DEFINITION_RESOLVED","definitionsEventSchemas","INTEGRATION_CONNECTION_AVAILABLE","PROJECT_SOURCE_BOUND","PROJECT_SOURCE_COMMIT_OBSERVED","subscriberFactory","logger","createDefinitionsSourceControl","db","definitionsOutbox","migrationsPath","createDefinitionRoutes","createDefinitionsInterModulePresentation","createOnIntegrationConnectionAvailable","onProjectSourceBound","onProjectSourceCommitObserved","createDefinitionSyncActivities","DEFINITIONS_TASK_QUEUE","definitionWorkflowPath","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","getDefinitionById","packageRoot","url","workflowsPath","subscriber","createDefinitionsModule","projects","agent","integrations","sourceControl","name","database","databaseNamespace","routes","publishers","table","eventSchemas","subscribers","_payload","event","info","Promise","workers","taskQueue","activities","workflowPath","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAEvC,SACEC,mBAAmB,EAEnBC,uBAAuB,QAClB,+BAA+B;AACtC,SACEC,gCAAgC,QAE3B,oCAAoC;AAE3C,SACEC,oBAAoB,EACpBC,8BAA8B,QAEzB,4BAA4B;AAEnC,SAA4BC,iBAAiB,QAAO,uBAAuB;AAC3E,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,8BAA8B,QAAO,wBAAwB;AACrE,SAAQC,EAAE,EAAEC,iBAAiB,EAAEC,cAAc,QAAO,eAAe;AACnE,SAAQC,sBAAsB,QAAO,yBAAyB;AAC9D,SAAQC,wCAAwC,QAAO,gCAAgC;AACvF,SACEC,sCAAsC,EACtCC,oBAAoB,EACpBC,6BAA6B,QACxB,qCAAqC;AAC5C,SAAQC,8BAA8B,EAAEC,sBAAsB,QAAO,qBAAqB;AAC1F,SAAQC,sBAAsB,QAAO,cAAc;AAWnD,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,sBAAsB,EACtBC,yBAAyB,QACpB,iBAAiB;AACxB,SAAQd,EAAE,EAAEC,iBAAiB,EAAEc,iBAAiB,EAAEb,cAAc,QAAO,eAAe;AAEtF,MAAMc,cAAc1B,QAAQD,QAAQE,cAAc,YAAY0B,GAAG,IAAI;AACrE,MAAMC,gBAAgB5B,QAAQ0B,aAAa;AAE3C,MAAMG,aAAatB;AAUnB,OAAO,SAASuB,wBAAwB,EACtCC,QAAQ,EACRC,KAAK,EACLC,YAAY,EACmB;IAC/B,MAAMC,gBAAgBzB,+BAA+BwB;IAErD,OAAO;QACLE,MAAM;QACNC,UAAU;YAAC1B;YAAIE;YAAgByB,mBAAmB;QAAa;QAC/DC,QAAQzB,uBAAuB;YAACkB;YAAUC;YAAOC;QAAY;QAC7DM,YAAY;YACV;gBAACJ,MAAM;gBAAeK,OAAO7B;gBAAmBD;gBAAI+B,cAActC;YAAuB;SAC1F;QACDuC,aAAa;YACXb,WAAW3B,qBAAqB,CAACyC,UAAUC;gBACzCpC,SAASqC,IAAI,CAAC;oBAACD;gBAAK,GAAG;gBACvB,OAAOE,QAAQ9C,OAAO;YACxB;YACA6B,WACEzB,kCACAW,uCAAuCgB;YAEzCF,WAAWxB,sBAAsBW;YACjCa,WAAWvB,gCAAgCW;SAC5C;QACD8B,SAAS;YACP;gBACEC,WAAW7B;gBACXS;gBACAqB,YAAY,IACV/B,+BAA+BgB,eAAeF,OAAOC,cAAc;wBACjEiB,cAAc9B;oBAChB;gBACF+B,WAAW,EAAE;YACf;SACD;QACDC,0BAA0B;YAACtC;SAA2C;IACxE;AACF"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n DEFINITION_RESOLVED,\n type DefinitionsEventMap,\n definitionsEventSchemas,\n} from '@shipfox/api-definitions-dto';\nimport {\n INTEGRATION_CONNECTION_AVAILABLE,\n type IntegrationsEventMap,\n} from '@shipfox/api-integration-core-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {\n PROJECT_SOURCE_BOUND,\n PROJECT_SOURCE_COMMIT_OBSERVED,\n type ProjectsEventMap,\n} from '@shipfox/api-projects-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {createDefinitionsSourceControl} from '#core/integrations.js';\nimport {db, definitionsOutbox, migrationsPath} from '#db/index.js';\nimport {createDefinitionRoutes} from '#presentation/index.js';\nimport {createDefinitionsInterModulePresentation} from '#presentation/inter-module.js';\nimport {\n createOnIntegrationConnectionAvailable,\n onProjectSourceBound,\n onProjectSourceCommitObserved,\n} from '#presentation/subscribers/index.js';\nimport {createDefinitionSyncActivities, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';\nimport {definitionWorkflowPath} from './config.js';\n\nexport type {\n WorkflowDefinition,\n WorkflowDefinitionPayload,\n WorkflowEnvTemplates,\n WorkflowModel,\n WorkflowModelJobCheckout,\n WorkflowSourceSnapshot,\n WorkflowSpec,\n} from '#core/index.js';\nexport {\n DEFAULT_JOB_CHECKOUT,\n DEFAULT_JOB_SUCCESS,\n DEFAULT_RUN_TIMEOUT_MS,\n normalizeWorkflowDocument,\n} from '#core/index.js';\nexport {db, definitionsOutbox, getDefinitionById, migrationsPath} from '#db/index.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<\n DefinitionsEventMap & IntegrationsEventMap & ProjectsEventMap\n>();\n\nexport interface CreateDefinitionsModuleOptions {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations: IntegrationsModuleClient;\n}\n\nexport function createDefinitionsModule({\n projects,\n agent,\n integrations,\n}: CreateDefinitionsModuleOptions): ShipfoxModule {\n const sourceControl = createDefinitionsSourceControl(integrations);\n\n return {\n name: 'definitions',\n database: {db, migrationsPath, databaseNamespace: 'definitions'},\n routes: createDefinitionRoutes({projects, agent, integrations}),\n publishers: [\n {name: 'definitions', table: definitionsOutbox, db, eventSchemas: definitionsEventSchemas},\n ],\n subscribers: [\n subscriber(DEFINITION_RESOLVED, (_payload, event) => {\n logger().info({event}, 'Definition resolved');\n return Promise.resolve();\n }),\n subscriber(\n INTEGRATION_CONNECTION_AVAILABLE,\n createOnIntegrationConnectionAvailable(projects),\n ),\n subscriber(PROJECT_SOURCE_BOUND, onProjectSourceBound),\n subscriber(PROJECT_SOURCE_COMMIT_OBSERVED, onProjectSourceCommitObserved),\n ],\n workers: [\n {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowsPath,\n activities: () =>\n createDefinitionSyncActivities(sourceControl, agent, integrations, {\n workflowPath: definitionWorkflowPath,\n }),\n workflows: [],\n },\n ],\n interModulePresentations: [\n createDefinitionsInterModulePresentation({projects, agent, integrations}),\n ],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","DEFINITION_RESOLVED","definitionsEventSchemas","INTEGRATION_CONNECTION_AVAILABLE","PROJECT_SOURCE_BOUND","PROJECT_SOURCE_COMMIT_OBSERVED","subscriberFactory","logger","createDefinitionsSourceControl","db","definitionsOutbox","migrationsPath","createDefinitionRoutes","createDefinitionsInterModulePresentation","createOnIntegrationConnectionAvailable","onProjectSourceBound","onProjectSourceCommitObserved","createDefinitionSyncActivities","DEFINITIONS_TASK_QUEUE","definitionWorkflowPath","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","getDefinitionById","packageRoot","url","workflowsPath","subscriber","createDefinitionsModule","projects","agent","integrations","sourceControl","name","database","databaseNamespace","routes","publishers","table","eventSchemas","subscribers","_payload","event","info","Promise","workers","taskQueue","activities","workflowPath","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAEvC,SACEC,mBAAmB,EAEnBC,uBAAuB,QAClB,+BAA+B;AACtC,SACEC,gCAAgC,QAE3B,oCAAoC;AAE3C,SACEC,oBAAoB,EACpBC,8BAA8B,QAEzB,4BAA4B;AAEnC,SAA4BC,iBAAiB,QAAO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WAAW7B;gBACXS;gBACAqB,YAAY,IACV/B,+BAA+BgB,eAAeF,OAAOC,cAAc;wBACjEiB,cAAc9B;oBAChB;gBACF+B,WAAW,EAAE;YACf;SACD;QACDC,0BAA0B;YACxBtC,yCAAyC;gBAACiB;gBAAUC;gBAAOC;YAAY;SACxE;IACH;AACF"}
@@ -0,0 +1,2 @@
1
+ export { recordDefinitionRefResolution } from './instance.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { recordDefinitionRefResolution } from './instance.js';
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/metrics/index.ts"],"sourcesContent":["export {recordDefinitionRefResolution} from './instance.js';\n"],"names":["recordDefinitionRefResolution"],"mappings":"AAAA,SAAQA,6BAA6B,QAAO,gBAAgB"}
@@ -0,0 +1,4 @@
1
+ import type { DefinitionAtRefErrorCode } from '#core/errors.js';
2
+ export type DefinitionRefResolutionOutcome = DefinitionAtRefErrorCode | 'resolved';
3
+ export declare function recordDefinitionRefResolution(outcome: DefinitionRefResolutionOutcome): void;
4
+ //# sourceMappingURL=instance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/metrics/instance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,iBAAiB,CAAC;AAI9D,MAAM,MAAM,8BAA8B,GAAG,wBAAwB,GAAG,UAAU,CAAC;AAenF,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,8BAA8B,GAAG,IAAI,CAE3F"}
@@ -0,0 +1,19 @@
1
+ import { instanceMetrics } from '@shipfox/node-opentelemetry';
2
+ const meter = instanceMetrics.getMeter('definitions');
3
+ const refResolutionCount = meter.createCounter('definitions_ref_resolutions', {
4
+ description: 'Workflow definition resolutions at a git ref by outcome'
5
+ });
6
+ function recordMetric(record) {
7
+ try {
8
+ record();
9
+ } catch {
10
+ // Metrics must not affect definition resolution outcomes.
11
+ }
12
+ }
13
+ export function recordDefinitionRefResolution(outcome) {
14
+ recordMetric(()=>refResolutionCount.add(1, {
15
+ outcome
16
+ }));
17
+ }
18
+
19
+ //# sourceMappingURL=instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/metrics/instance.ts"],"sourcesContent":["import {instanceMetrics} from '@shipfox/node-opentelemetry';\nimport type {DefinitionAtRefErrorCode} from '#core/errors.js';\n\nconst meter = instanceMetrics.getMeter('definitions');\n\nexport type DefinitionRefResolutionOutcome = DefinitionAtRefErrorCode | 'resolved';\n\nconst refResolutionCount = meter.createCounter<{outcome: DefinitionRefResolutionOutcome}>(\n 'definitions_ref_resolutions',\n {description: 'Workflow definition resolutions at a git ref by outcome'},\n);\n\nfunction recordMetric(record: () => void): void {\n try {\n record();\n } catch {\n // Metrics must not affect definition resolution outcomes.\n }\n}\n\nexport function recordDefinitionRefResolution(outcome: DefinitionRefResolutionOutcome): void {\n recordMetric(() => refResolutionCount.add(1, {outcome}));\n}\n"],"names":["instanceMetrics","meter","getMeter","refResolutionCount","createCounter","description","recordMetric","record","recordDefinitionRefResolution","outcome","add"],"mappings":"AAAA,SAAQA,eAAe,QAAO,8BAA8B;AAG5D,MAAMC,QAAQD,gBAAgBE,QAAQ,CAAC;AAIvC,MAAMC,qBAAqBF,MAAMG,aAAa,CAC5C,+BACA;IAACC,aAAa;AAAyD;AAGzE,SAASC,aAAaC,MAAkB;IACtC,IAAI;QACFA;IACF,EAAE,OAAM;IACN,0DAA0D;IAC5D;AACF;AAEA,OAAO,SAASC,8BAA8BC,OAAuC;IACnFH,aAAa,IAAMH,mBAAmBO,GAAG,CAAC,GAAG;YAACD;QAAO;AACvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,wBAAwB,EAAC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAG9E,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAmB7E;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACzC,wBAAwB,GAAG,IAAI,CAajC"}
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,wBAAwB,EAAC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAG9E,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAmB7E;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACzC,wBAAwB,GAAG,IAAI,CAgBjC"}
@@ -1,6 +1,8 @@
1
1
  import { UNRESOLVED_SYNC_REF } from '#core/sync-definitions.js';
2
2
  export function toDefinitionDto(definition) {
3
- const manualEntry = Object.entries(definition.document.triggers ?? {}).find(([, trigger])=>trigger.source === 'manual');
3
+ // The model excludes inert triggers, so an inert manual trigger yields no Run
4
+ // button instead of a fire-route 404. The document keeps the authored entry.
5
+ const manualTrigger = definition.model.triggers.find((trigger)=>trigger.source === 'manual');
4
6
  return {
5
7
  id: definition.id,
6
8
  project_id: definition.projectId,
@@ -11,8 +13,8 @@ export function toDefinitionDto(definition) {
11
13
  name: definition.name,
12
14
  workflow_document: definition.document,
13
15
  workflow_model: definition.model,
14
- manual_trigger: manualEntry ? {
15
- name: manualEntry[0]
16
+ manual_trigger: manualTrigger ? {
17
+ name: manualTrigger.key
16
18
  } : null,
17
19
  fetched_at: definition.fetchedAt.toISOString(),
18
20
  created_at: definition.createdAt.toISOString(),
@@ -29,7 +31,12 @@ export function toDefinitionSyncSummaryDto(syncState) {
29
31
  finished_at: syncState.finishedAt?.toISOString() ?? null,
30
32
  last_error_code: syncState.lastErrorCode,
31
33
  last_error_message: syncState.lastErrorMessage,
32
- warnings: syncState.warnings
34
+ diagnostics: syncState.diagnostics.map(({ filePath, ...diagnostic })=>({
35
+ ...diagnostic,
36
+ ...filePath === undefined ? {} : {
37
+ file_path: filePath
38
+ }
39
+ }))
33
40
  };
34
41
  }
35
42
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/dto/definition.ts"],"sourcesContent":["import type {DefinitionDto, DefinitionSyncSummaryDto} from '@shipfox/api-definitions-dto';\nimport type {DefinitionSyncState} from '#core/entities/sync-state.js';\nimport type {WorkflowDefinition} from '#core/entities/workflow-definition.js';\nimport {UNRESOLVED_SYNC_REF} from '#core/sync-definitions.js';\n\nexport function toDefinitionDto(definition: WorkflowDefinition): DefinitionDto {\n const manualEntry = Object.entries(definition.document.triggers ?? {}).find(\n ([, trigger]) => trigger.source === 'manual',\n );\n return {\n id: definition.id,\n project_id: definition.projectId,\n config_path: definition.configPath,\n source: definition.source,\n sha: definition.sha,\n ref: definition.ref,\n name: definition.name,\n workflow_document: definition.document,\n workflow_model: definition.model,\n manual_trigger: manualEntry ? {name: manualEntry[0]} : null,\n fetched_at: definition.fetchedAt.toISOString(),\n created_at: definition.createdAt.toISOString(),\n updated_at: definition.updatedAt.toISOString(),\n };\n}\n\nexport function toDefinitionSyncSummaryDto(\n syncState: DefinitionSyncState | undefined,\n): DefinitionSyncSummaryDto | null {\n if (!syncState) return null;\n\n return {\n ref: syncState.ref === UNRESOLVED_SYNC_REF ? null : syncState.ref,\n status: syncState.status,\n last_sync_at: (syncState.finishedAt ?? syncState.updatedAt).toISOString(),\n started_at: syncState.startedAt?.toISOString() ?? null,\n finished_at: syncState.finishedAt?.toISOString() ?? null,\n last_error_code: syncState.lastErrorCode,\n last_error_message: syncState.lastErrorMessage,\n warnings: syncState.warnings,\n };\n}\n"],"names":["UNRESOLVED_SYNC_REF","toDefinitionDto","definition","manualEntry","Object","entries","document","triggers","find","trigger","source","id","project_id","projectId","config_path","configPath","sha","ref","name","workflow_document","workflow_model","model","manual_trigger","fetched_at","fetchedAt","toISOString","created_at","createdAt","updated_at","updatedAt","toDefinitionSyncSummaryDto","syncState","status","last_sync_at","finishedAt","started_at","startedAt","finished_at","last_error_code","lastErrorCode","last_error_message","lastErrorMessage","warnings"],"mappings":"AAGA,SAAQA,mBAAmB,QAAO,4BAA4B;AAE9D,OAAO,SAASC,gBAAgBC,UAA8B;IAC5D,MAAMC,cAAcC,OAAOC,OAAO,CAACH,WAAWI,QAAQ,CAACC,QAAQ,IAAI,CAAC,GAAGC,IAAI,CACzE,CAAC,GAAGC,QAAQ,GAAKA,QAAQC,MAAM,KAAK;IAEtC,OAAO;QACLC,IAAIT,WAAWS,EAAE;QACjBC,YAAYV,WAAWW,SAAS;QAChCC,aAAaZ,WAAWa,UAAU;QAClCL,QAAQR,WAAWQ,MAAM;QACzBM,KAAKd,WAAWc,GAAG;QACnBC,KAAKf,WAAWe,GAAG;QACnBC,MAAMhB,WAAWgB,IAAI;QACrBC,mBAAmBjB,WAAWI,QAAQ;QACtCc,gBAAgBlB,WAAWmB,KAAK;QAChCC,gBAAgBnB,cAAc;YAACe,MAAMf,WAAW,CAAC,EAAE;QAAA,IAAI;QACvDoB,YAAYrB,WAAWsB,SAAS,CAACC,WAAW;QAC5CC,YAAYxB,WAAWyB,SAAS,CAACF,WAAW;QAC5CG,YAAY1B,WAAW2B,SAAS,CAACJ,WAAW;IAC9C;AACF;AAEA,OAAO,SAASK,2BACdC,SAA0C;IAE1C,IAAI,CAACA,WAAW,OAAO;IAEvB,OAAO;QACLd,KAAKc,UAAUd,GAAG,KAAKjB,sBAAsB,OAAO+B,UAAUd,GAAG;QACjEe,QAAQD,UAAUC,MAAM;QACxBC,cAAc,AAACF,CAAAA,UAAUG,UAAU,IAAIH,UAAUF,SAAS,AAAD,EAAGJ,WAAW;QACvEU,YAAYJ,UAAUK,SAAS,EAAEX,iBAAiB;QAClDY,aAAaN,UAAUG,UAAU,EAAET,iBAAiB;QACpDa,iBAAiBP,UAAUQ,aAAa;QACxCC,oBAAoBT,UAAUU,gBAAgB;QAC9CC,UAAUX,UAAUW,QAAQ;IAC9B;AACF"}
1
+ {"version":3,"sources":["../../../src/presentation/dto/definition.ts"],"sourcesContent":["import type {DefinitionDto, DefinitionSyncSummaryDto} from '@shipfox/api-definitions-dto';\nimport type {DefinitionSyncState} from '#core/entities/sync-state.js';\nimport type {WorkflowDefinition} from '#core/entities/workflow-definition.js';\nimport {UNRESOLVED_SYNC_REF} from '#core/sync-definitions.js';\n\nexport function toDefinitionDto(definition: WorkflowDefinition): DefinitionDto {\n // The model excludes inert triggers, so an inert manual trigger yields no Run\n // button instead of a fire-route 404. The document keeps the authored entry.\n const manualTrigger = definition.model.triggers.find((trigger) => trigger.source === 'manual');\n return {\n id: definition.id,\n project_id: definition.projectId,\n config_path: definition.configPath,\n source: definition.source,\n sha: definition.sha,\n ref: definition.ref,\n name: definition.name,\n workflow_document: definition.document,\n workflow_model: definition.model,\n manual_trigger: manualTrigger ? {name: manualTrigger.key} : null,\n fetched_at: definition.fetchedAt.toISOString(),\n created_at: definition.createdAt.toISOString(),\n updated_at: definition.updatedAt.toISOString(),\n };\n}\n\nexport function toDefinitionSyncSummaryDto(\n syncState: DefinitionSyncState | undefined,\n): DefinitionSyncSummaryDto | null {\n if (!syncState) return null;\n\n return {\n ref: syncState.ref === UNRESOLVED_SYNC_REF ? null : syncState.ref,\n status: syncState.status,\n last_sync_at: (syncState.finishedAt ?? syncState.updatedAt).toISOString(),\n started_at: syncState.startedAt?.toISOString() ?? null,\n finished_at: syncState.finishedAt?.toISOString() ?? null,\n last_error_code: syncState.lastErrorCode,\n last_error_message: syncState.lastErrorMessage,\n diagnostics: syncState.diagnostics.map(({filePath, ...diagnostic}) => ({\n ...diagnostic,\n ...(filePath === undefined ? {} : {file_path: filePath}),\n })),\n };\n}\n"],"names":["UNRESOLVED_SYNC_REF","toDefinitionDto","definition","manualTrigger","model","triggers","find","trigger","source","id","project_id","projectId","config_path","configPath","sha","ref","name","workflow_document","document","workflow_model","manual_trigger","key","fetched_at","fetchedAt","toISOString","created_at","createdAt","updated_at","updatedAt","toDefinitionSyncSummaryDto","syncState","status","last_sync_at","finishedAt","started_at","startedAt","finished_at","last_error_code","lastErrorCode","last_error_message","lastErrorMessage","diagnostics","map","filePath","diagnostic","undefined","file_path"],"mappings":"AAGA,SAAQA,mBAAmB,QAAO,4BAA4B;AAE9D,OAAO,SAASC,gBAAgBC,UAA8B;IAC5D,8EAA8E;IAC9E,6EAA6E;IAC7E,MAAMC,gBAAgBD,WAAWE,KAAK,CAACC,QAAQ,CAACC,IAAI,CAAC,CAACC,UAAYA,QAAQC,MAAM,KAAK;IACrF,OAAO;QACLC,IAAIP,WAAWO,EAAE;QACjBC,YAAYR,WAAWS,SAAS;QAChCC,aAAaV,WAAWW,UAAU;QAClCL,QAAQN,WAAWM,MAAM;QACzBM,KAAKZ,WAAWY,GAAG;QACnBC,KAAKb,WAAWa,GAAG;QACnBC,MAAMd,WAAWc,IAAI;QACrBC,mBAAmBf,WAAWgB,QAAQ;QACtCC,gBAAgBjB,WAAWE,KAAK;QAChCgB,gBAAgBjB,gBAAgB;YAACa,MAAMb,cAAckB,GAAG;QAAA,IAAI;QAC5DC,YAAYpB,WAAWqB,SAAS,CAACC,WAAW;QAC5CC,YAAYvB,WAAWwB,SAAS,CAACF,WAAW;QAC5CG,YAAYzB,WAAW0B,SAAS,CAACJ,WAAW;IAC9C;AACF;AAEA,OAAO,SAASK,2BACdC,SAA0C;IAE1C,IAAI,CAACA,WAAW,OAAO;IAEvB,OAAO;QACLf,KAAKe,UAAUf,GAAG,KAAKf,sBAAsB,OAAO8B,UAAUf,GAAG;QACjEgB,QAAQD,UAAUC,MAAM;QACxBC,cAAc,AAACF,CAAAA,UAAUG,UAAU,IAAIH,UAAUF,SAAS,AAAD,EAAGJ,WAAW;QACvEU,YAAYJ,UAAUK,SAAS,EAAEX,iBAAiB;QAClDY,aAAaN,UAAUG,UAAU,EAAET,iBAAiB;QACpDa,iBAAiBP,UAAUQ,aAAa;QACxCC,oBAAoBT,UAAUU,gBAAgB;QAC9CC,aAAaX,UAAUW,WAAW,CAACC,GAAG,CAAC,CAAC,EAACC,QAAQ,EAAE,GAAGC,YAAW,GAAM,CAAA;gBACrE,GAAGA,UAAU;gBACb,GAAID,aAAaE,YAAY,CAAC,IAAI;oBAACC,WAAWH;gBAAQ,CAAC;YACzD,CAAA;IACF;AACF"}
@@ -1,4 +1,12 @@
1
+ import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
1
2
  import { definitionsInterModuleContract } from '@shipfox/api-definitions-dto/inter-module';
3
+ import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto/inter-module';
4
+ import type { ProjectsModuleClient } from '@shipfox/api-projects-dto/inter-module';
2
5
  import { type InterModulePresentation } from '@shipfox/inter-module';
3
- export declare function createDefinitionsInterModulePresentation(): InterModulePresentation<typeof definitionsInterModuleContract>;
6
+ export interface CreateDefinitionsInterModulePresentationParams {
7
+ projects: ProjectsModuleClient;
8
+ agent: AgentInterModuleClient;
9
+ integrations: IntegrationsModuleClient;
10
+ }
11
+ export declare function createDefinitionsInterModulePresentation(params: CreateDefinitionsInterModulePresentationParams): InterModulePresentation<typeof definitionsInterModuleContract>;
4
12
  //# sourceMappingURL=inter-module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,8BAA8B,EAAC,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAgC,KAAK,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAGlG,wBAAgB,wCAAwC,IAAI,uBAAuB,CACjF,OAAO,8BAA8B,CACtC,CAiBA"}
1
+ {"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAEhF,OAAO,EAAC,8BAA8B,EAAC,MAAM,2CAA2C,CAAC;AACzF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,8CAA8C;IAC7D,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,YAAY,EAAE,wBAAwB,CAAC;CACxC;AAED,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,8CAA8C,GACrD,uBAAuB,CAAC,OAAO,8BAA8B,CAAC,CAsChE"}
@@ -1,8 +1,9 @@
1
1
  import { createWorkflowModelSnapshot } from '@shipfox/api-definitions-dto';
2
2
  import { definitionsInterModuleContract } from '@shipfox/api-definitions-dto/inter-module';
3
- import { defineInterModulePresentation } from '@shipfox/inter-module';
3
+ import { createInterModuleKnownError, defineInterModulePresentation } from '@shipfox/inter-module';
4
+ import { DefinitionAtRefError, listDefinitionsAtRef, resolveDefinitionAtRef } from '#core/index.js';
4
5
  import { getDefinitionById } from '#db/definitions.js';
5
- export function createDefinitionsInterModulePresentation() {
6
+ export function createDefinitionsInterModulePresentation(params) {
6
7
  return defineInterModulePresentation(definitionsInterModuleContract, {
7
8
  getDefinitionForWorkflowRun: async ({ definitionId })=>{
8
9
  const definition = await getDefinitionById(definitionId);
@@ -12,14 +13,77 @@ export function createDefinitionsInterModulePresentation() {
12
13
  return {
13
14
  definition: {
14
15
  id: definition.id,
16
+ workflowId: definition.workflowId,
15
17
  projectId: definition.projectId,
16
18
  name: definition.name,
17
19
  model: createWorkflowModelSnapshot(definition.model),
18
20
  sourceSnapshot: definition.sourceSnapshot
19
21
  }
20
22
  };
23
+ },
24
+ resolveDefinitionAtRef: async (input, context)=>{
25
+ try {
26
+ return await resolveDefinitionAtRef({
27
+ ...input,
28
+ ...params,
29
+ signal: context.signal
30
+ });
31
+ } catch (error) {
32
+ throw toDefinitionAtRefKnownError(definitionsInterModuleContract.methods.resolveDefinitionAtRef, error);
33
+ }
34
+ },
35
+ listDefinitionsAtRef: async (input, context)=>{
36
+ try {
37
+ return await listDefinitionsAtRef({
38
+ ...input,
39
+ ...params,
40
+ signal: context.signal
41
+ });
42
+ } catch (error) {
43
+ throw toDefinitionAtRefKnownError(definitionsInterModuleContract.methods.listDefinitionsAtRef, error);
44
+ }
21
45
  }
22
46
  });
23
47
  }
48
+ function toDefinitionAtRefKnownError(method, error) {
49
+ if (!(error instanceof DefinitionAtRefError)) return error;
50
+ const { code, details } = error;
51
+ switch(code){
52
+ case 'project-not-found':
53
+ return createInterModuleKnownError(method, 'project-not-found', {
54
+ projectId: String(details.projectId)
55
+ });
56
+ case 'ref-not-found':
57
+ return createInterModuleKnownError(method, 'ref-not-found', {
58
+ ref: String(details.ref)
59
+ });
60
+ case 'ref-invalid':
61
+ return createInterModuleKnownError(method, 'ref-invalid', {
62
+ ref: String(details.ref)
63
+ });
64
+ case 'ref-moved':
65
+ return createInterModuleKnownError(method, 'ref-moved', {
66
+ ref: String(details.ref),
67
+ expectedCommit: String(details.expectedCommit)
68
+ });
69
+ case 'file-not-found':
70
+ return createInterModuleKnownError(method, 'file-not-found', {
71
+ ref: String(details.ref),
72
+ configPath: String(details.configPath)
73
+ });
74
+ case 'content-too-large':
75
+ return createInterModuleKnownError(method, 'content-too-large', {
76
+ configPath: String(details.configPath)
77
+ });
78
+ case 'invalid-definition':
79
+ return createInterModuleKnownError(method, 'invalid-definition', {
80
+ errors: details.errors
81
+ });
82
+ case 'too-many-files':
83
+ return createInterModuleKnownError(method, 'too-many-files', {});
84
+ case 'source-unavailable':
85
+ return createInterModuleKnownError(method, 'source-unavailable', {});
86
+ }
87
+ }
24
88
 
25
89
  //# sourceMappingURL=inter-module.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import {createWorkflowModelSnapshot} from '@shipfox/api-definitions-dto';\nimport {definitionsInterModuleContract} from '@shipfox/api-definitions-dto/inter-module';\nimport {defineInterModulePresentation, type InterModulePresentation} from '@shipfox/inter-module';\nimport {getDefinitionById} from '#db/definitions.js';\n\nexport function createDefinitionsInterModulePresentation(): InterModulePresentation<\n typeof definitionsInterModuleContract\n> {\n return defineInterModulePresentation(definitionsInterModuleContract, {\n getDefinitionForWorkflowRun: async ({definitionId}) => {\n const definition = await getDefinitionById(definitionId);\n if (!definition) return {definition: null};\n\n return {\n definition: {\n id: definition.id,\n projectId: definition.projectId,\n name: definition.name,\n model: createWorkflowModelSnapshot(definition.model),\n sourceSnapshot: definition.sourceSnapshot,\n },\n };\n },\n });\n}\n"],"names":["createWorkflowModelSnapshot","definitionsInterModuleContract","defineInterModulePresentation","getDefinitionById","createDefinitionsInterModulePresentation","getDefinitionForWorkflowRun","definitionId","definition","id","projectId","name","model","sourceSnapshot"],"mappings":"AAAA,SAAQA,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,8BAA8B,QAAO,4CAA4C;AACzF,SAAQC,6BAA6B,QAAqC,wBAAwB;AAClG,SAAQC,iBAAiB,QAAO,qBAAqB;AAErD,OAAO,SAASC;IAGd,OAAOF,8BAA8BD,gCAAgC;QACnEI,6BAA6B,OAAO,EAACC,YAAY,EAAC;YAChD,MAAMC,aAAa,MAAMJ,kBAAkBG;YAC3C,IAAI,CAACC,YAAY,OAAO;gBAACA,YAAY;YAAI;YAEzC,OAAO;gBACLA,YAAY;oBACVC,IAAID,WAAWC,EAAE;oBACjBC,WAAWF,WAAWE,SAAS;oBAC/BC,MAAMH,WAAWG,IAAI;oBACrBC,OAAOX,4BAA4BO,WAAWI,KAAK;oBACnDC,gBAAgBL,WAAWK,cAAc;gBAC3C;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {createWorkflowModelSnapshot} from '@shipfox/api-definitions-dto';\nimport {definitionsInterModuleContract} from '@shipfox/api-definitions-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {\n createInterModuleKnownError,\n defineInterModulePresentation,\n type InterModuleMethodContract,\n type InterModulePresentation,\n} from '@shipfox/inter-module';\nimport {DefinitionAtRefError, listDefinitionsAtRef, resolveDefinitionAtRef} from '#core/index.js';\nimport {getDefinitionById} from '#db/definitions.js';\n\nexport interface CreateDefinitionsInterModulePresentationParams {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations: IntegrationsModuleClient;\n}\n\nexport function createDefinitionsInterModulePresentation(\n params: CreateDefinitionsInterModulePresentationParams,\n): InterModulePresentation<typeof definitionsInterModuleContract> {\n return defineInterModulePresentation(definitionsInterModuleContract, {\n getDefinitionForWorkflowRun: async ({definitionId}) => {\n const definition = await getDefinitionById(definitionId);\n if (!definition) return {definition: null};\n\n return {\n definition: {\n id: definition.id,\n workflowId: definition.workflowId,\n projectId: definition.projectId,\n name: definition.name,\n model: createWorkflowModelSnapshot(definition.model),\n sourceSnapshot: definition.sourceSnapshot,\n },\n };\n },\n resolveDefinitionAtRef: async (input, context) => {\n try {\n return await resolveDefinitionAtRef({...input, ...params, signal: context.signal});\n } catch (error) {\n throw toDefinitionAtRefKnownError(\n definitionsInterModuleContract.methods.resolveDefinitionAtRef,\n error,\n );\n }\n },\n listDefinitionsAtRef: async (input, context) => {\n try {\n return await listDefinitionsAtRef({...input, ...params, signal: context.signal});\n } catch (error) {\n throw toDefinitionAtRefKnownError(\n definitionsInterModuleContract.methods.listDefinitionsAtRef,\n error,\n );\n }\n },\n });\n}\n\nfunction toDefinitionAtRefKnownError(method: InterModuleMethodContract, error: unknown): unknown {\n if (!(error instanceof DefinitionAtRefError)) return error;\n const {code, details} = error;\n switch (code) {\n case 'project-not-found':\n return createInterModuleKnownError(method, 'project-not-found', {\n projectId: String(details.projectId),\n });\n case 'ref-not-found':\n return createInterModuleKnownError(method, 'ref-not-found', {ref: String(details.ref)});\n case 'ref-invalid':\n return createInterModuleKnownError(method, 'ref-invalid', {ref: String(details.ref)});\n case 'ref-moved':\n return createInterModuleKnownError(method, 'ref-moved', {\n ref: String(details.ref),\n expectedCommit: String(details.expectedCommit),\n });\n case 'file-not-found':\n return createInterModuleKnownError(method, 'file-not-found', {\n ref: String(details.ref),\n configPath: String(details.configPath),\n });\n case 'content-too-large':\n return createInterModuleKnownError(method, 'content-too-large', {\n configPath: String(details.configPath),\n });\n case 'invalid-definition':\n return createInterModuleKnownError(method, 'invalid-definition', {\n errors: details.errors as Array<{message: string; path?: string}>,\n });\n case 'too-many-files':\n return createInterModuleKnownError(method, 'too-many-files', {});\n case 'source-unavailable':\n return createInterModuleKnownError(method, 'source-unavailable', {});\n }\n}\n"],"names":["createWorkflowModelSnapshot","definitionsInterModuleContract","createInterModuleKnownError","defineInterModulePresentation","DefinitionAtRefError","listDefinitionsAtRef","resolveDefinitionAtRef","getDefinitionById","createDefinitionsInterModulePresentation","params","getDefinitionForWorkflowRun","definitionId","definition","id","workflowId","projectId","name","model","sourceSnapshot","input","context","signal","error","toDefinitionAtRefKnownError","methods","method","code","details","String","ref","expectedCommit","configPath","errors"],"mappings":"AACA,SAAQA,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,8BAA8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C,OAAO,EAAC,GAAGL;IACxB,OAAQI;QACN,KAAK;YACH,OAAOxB,4BAA4BuB,QAAQ,qBAAqB;gBAC9DV,WAAWa,OAAOD,QAAQZ,SAAS;YACrC;QACF,KAAK;YACH,OAAOb,4BAA4BuB,QAAQ,iBAAiB;gBAACI,KAAKD,OAAOD,QAAQE,GAAG;YAAC;QACvF,KAAK;YACH,OAAO3B,4BAA4BuB,QAAQ,eAAe;gBAACI,KAAKD,OAAOD,QAAQE,GAAG;YAAC;QACrF,KAAK;YACH,OAAO3B,4BAA4BuB,QAAQ,aAAa;gBACtDI,KAAKD,OAAOD,QAAQE,GAAG;gBACvBC,gBAAgBF,OAAOD,QAAQG,cAAc;YAC/C;QACF,KAAK;YACH,OAAO5B,4BAA4BuB,QAAQ,kBAAkB;gBAC3DI,KAAKD,OAAOD,QAAQE,GAAG;gBACvBE,YAAYH,OAAOD,QAAQI,UAAU;YACvC;QACF,KAAK;YACH,OAAO7B,4BAA4BuB,QAAQ,qBAAqB;gBAC9DM,YAAYH,OAAOD,QAAQI,UAAU;YACvC;QACF,KAAK;YACH,OAAO7B,4BAA4BuB,QAAQ,sBAAsB;gBAC/DO,QAAQL,QAAQK,MAAM;YACxB;QACF,KAAK;YACH,OAAO9B,4BAA4BuB,QAAQ,kBAAkB,CAAC;QAChE,KAAK;YACH,OAAOvB,4BAA4BuB,QAAQ,sBAAsB,CAAC;IACtE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/create-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAMhF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAWjF,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,YAAY,CAAC,EAAE,wBAAwB,CAAC;CACzC;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,4BAA4B,mDA6D/E"}
1
+ {"version":3,"file":"create-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/create-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAMhF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAC7F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAejF,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,YAAY,CAAC,EAAE,wBAAwB,CAAC;CACzC;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,4BAA4B,mDA6D/E"}
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  import { DefinitionParseError } from '#core/errors.js';
5
5
  import { hasAgentStepIntegrations } from '#core/has-agent-step-integrations.js';
6
6
  import { loadIntegrationValidationContext } from '#core/integrations.js';
7
- import { parseDefinition } from '#core/parse-definition.js';
7
+ import { parseDefinitionWithDiagnostics, stripDefinitionDiagnostics } from '#core/parse-definition.js';
8
8
  import { upsertDefinition } from '#db/definitions.js';
9
9
  import { toDefinitionDto } from '#presentation/dto/index.js';
10
10
  import { requireProjectAccess } from './project-access.js';
@@ -40,11 +40,11 @@ export function buildCreateDefinitionRoute(options) {
40
40
  const { project_id: projectId, config_path, source, yaml: yamlString, sha, ref } = request.body;
41
41
  const project = await requireProjectAccess(request, projectId, options.projects);
42
42
  const agentValidationCatalog = await options.agent.getValidationCatalog({});
43
- const structurallyParsed = parseDefinition(yamlString, {
43
+ const structurallyParsed = parseDefinitionForCreate(yamlString, {
44
44
  agentValidationCatalog
45
45
  });
46
46
  const { integrations } = options;
47
- const parsed = integrations !== undefined && hasAgentStepIntegrations(structurallyParsed.document) ? parseDefinition(yamlString, {
47
+ const parsed = integrations !== undefined && hasAgentStepIntegrations(structurallyParsed.document) ? parseDefinitionForCreate(yamlString, {
48
48
  agentValidationCatalog,
49
49
  integrationValidationContext: await loadIntegrationValidationContext(integrations, project.workspaceId, project.sourceConnectionId)
50
50
  }) : structurallyParsed;
@@ -64,5 +64,18 @@ export function buildCreateDefinitionRoute(options) {
64
64
  }
65
65
  });
66
66
  }
67
+ function parseDefinitionForCreate(yamlString, options) {
68
+ const parsed = parseDefinitionWithDiagnostics(yamlString, options);
69
+ const errors = parsed.diagnostics.filter((diagnostic)=>diagnostic.severity === 'error').map(({ message, path })=>({
70
+ message,
71
+ ...path === undefined ? {} : {
72
+ path
73
+ }
74
+ }));
75
+ if (errors.length > 0) {
76
+ throw new DefinitionParseError(errors[0]?.message ?? 'Invalid definition', errors);
77
+ }
78
+ return stripDefinitionDiagnostics(parsed);
79
+ }
67
80
 
68
81
  //# sourceMappingURL=create-definition.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/create-definition.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n createDefinitionBodySchema,\n definitionResponseSchema,\n definitionValidationErrorSchema,\n} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {DefinitionParseError} from '#core/errors.js';\nimport {hasAgentStepIntegrations} from '#core/has-agent-step-integrations.js';\nimport {loadIntegrationValidationContext} from '#core/integrations.js';\nimport {parseDefinition} from '#core/parse-definition.js';\nimport {upsertDefinition} from '#db/definitions.js';\nimport {toDefinitionDto} from '#presentation/dto/index.js';\nimport {requireProjectAccess} from './project-access.js';\n\nexport interface CreateDefinitionRouteOptions {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations?: IntegrationsModuleClient;\n}\n\nexport function buildCreateDefinitionRoute(options: CreateDefinitionRouteOptions) {\n return defineRoute({\n method: 'POST',\n path: '/',\n description: 'Create or update a workflow definition',\n schema: {\n body: createDefinitionBodySchema,\n response: {\n 200: definitionResponseSchema,\n 400: z.object({\n code: z.string(),\n message: z.string().optional(),\n details: z.array(definitionValidationErrorSchema).optional(),\n }),\n 404: z.object({code: z.string()}),\n },\n },\n errorHandler: (error, _request, _reply) => {\n if (error instanceof DefinitionParseError) {\n throw new ClientError(error.message, 'invalid-workflow-definition', {\n details: error.details,\n status: 400,\n });\n }\n throw error;\n },\n handler: async (request) => {\n const {project_id: projectId, config_path, source, yaml: yamlString, sha, ref} = request.body;\n const project = await requireProjectAccess(request, projectId, options.projects);\n\n const agentValidationCatalog = await options.agent.getValidationCatalog({});\n const structurallyParsed = parseDefinition(yamlString, {agentValidationCatalog});\n const {integrations} = options;\n const parsed =\n integrations !== undefined && hasAgentStepIntegrations(structurallyParsed.document)\n ? parseDefinition(yamlString, {\n agentValidationCatalog,\n integrationValidationContext: await loadIntegrationValidationContext(\n integrations,\n project.workspaceId,\n project.sourceConnectionId,\n ),\n })\n : structurallyParsed;\n\n const definition = await upsertDefinition({\n projectId,\n workspaceId: project.workspaceId,\n configPath: config_path,\n source,\n name: parsed.document.name,\n document: parsed.document,\n model: parsed.model,\n sourceSnapshot: parsed.sourceSnapshot,\n sha,\n ref,\n });\n\n return toDefinitionDto(definition);\n },\n });\n}\n"],"names":["createDefinitionBodySchema","definitionResponseSchema","definitionValidationErrorSchema","ClientError","defineRoute","z","DefinitionParseError","hasAgentStepIntegrations","loadIntegrationValidationContext","parseDefinition","upsertDefinition","toDefinitionDto","requireProjectAccess","buildCreateDefinitionRoute","options","method","path","description","schema","body","response","object","code","string","message","optional","details","array","errorHandler","error","_request","_reply","status","handler","request","project_id","projectId","config_path","source","yaml","yamlString","sha","ref","project","projects","agentValidationCatalog","agent","getValidationCatalog","structurallyParsed","integrations","parsed","undefined","document","integrationValidationContext","workspaceId","sourceConnectionId","definition","configPath","name","model","sourceSnapshot"],"mappings":"AACA,SACEA,0BAA0B,EAC1BC,wBAAwB,EACxBC,+BAA+B,QAC1B,+BAA+B;AAGtC,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,oBAAoB,QAAO,kBAAkB;AACrD,SAAQC,wBAAwB,QAAO,uCAAuC;AAC9E,SAAQC,gCAAgC,QAAO,wBAAwB;AACvE,SAAQC,eAAe,QAAO,4BAA4B;AAC1D,SAAQC,gBAAgB,QAAO,qBAAqB;AACpD,SAAQC,eAAe,QAAO,6BAA6B;AAC3D,SAAQC,oBAAoB,QAAO,sBAAsB;AAQzD,OAAO,SAASC,2BAA2BC,OAAqC;IAC9E,OAAOV,YAAY;QACjBW,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,MAAMnB;YACNoB,UAAU;gBACR,KAAKnB;gBACL,KAAKI,EAAEgB,MAAM,CAAC;oBACZC,MAAMjB,EAAEkB,MAAM;oBACdC,SAASnB,EAAEkB,MAAM,GAAGE,QAAQ;oBAC5BC,SAASrB,EAAEsB,KAAK,CAACzB,iCAAiCuB,QAAQ;gBAC5D;gBACA,KAAKpB,EAAEgB,MAAM,CAAC;oBAACC,MAAMjB,EAAEkB,MAAM;gBAAE;YACjC;QACF;QACAK,cAAc,CAACC,OAAOC,UAAUC;YAC9B,IAAIF,iBAAiBvB,sBAAsB;gBACzC,MAAM,IAAIH,YAAY0B,MAAML,OAAO,EAAE,+BAA+B;oBAClEE,SAASG,MAAMH,OAAO;oBACtBM,QAAQ;gBACV;YACF;YACA,MAAMH;QACR;QACAI,SAAS,OAAOC;YACd,MAAM,EAACC,YAAYC,SAAS,EAAEC,WAAW,EAAEC,MAAM,EAAEC,MAAMC,UAAU,EAAEC,GAAG,EAAEC,GAAG,EAAC,GAAGR,QAAQf,IAAI;YAC7F,MAAMwB,UAAU,MAAM/B,qBAAqBsB,SAASE,WAAWtB,QAAQ8B,QAAQ;YAE/E,MAAMC,yBAAyB,MAAM/B,QAAQgC,KAAK,CAACC,oBAAoB,CAAC,CAAC;YACzE,MAAMC,qBAAqBvC,gBAAgB+B,YAAY;gBAACK;YAAsB;YAC9E,MAAM,EAACI,YAAY,EAAC,GAAGnC;YACvB,MAAMoC,SACJD,iBAAiBE,aAAa5C,yBAAyByC,mBAAmBI,QAAQ,IAC9E3C,gBAAgB+B,YAAY;gBAC1BK;gBACAQ,8BAA8B,MAAM7C,iCAClCyC,cACAN,QAAQW,WAAW,EACnBX,QAAQY,kBAAkB;YAE9B,KACAP;YAEN,MAAMQ,aAAa,MAAM9C,iBAAiB;gBACxC0B;gBACAkB,aAAaX,QAAQW,WAAW;gBAChCG,YAAYpB;gBACZC;gBACAoB,MAAMR,OAAOE,QAAQ,CAACM,IAAI;gBAC1BN,UAAUF,OAAOE,QAAQ;gBACzBO,OAAOT,OAAOS,KAAK;gBACnBC,gBAAgBV,OAAOU,cAAc;gBACrCnB;gBACAC;YACF;YAEA,OAAO/B,gBAAgB6C;QACzB;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/create-definition.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n createDefinitionBodySchema,\n definitionResponseSchema,\n definitionValidationErrorSchema,\n} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {DefinitionParseError} from '#core/errors.js';\nimport {hasAgentStepIntegrations} from '#core/has-agent-step-integrations.js';\nimport {loadIntegrationValidationContext} from '#core/integrations.js';\nimport {\n type ParseDefinitionOptions,\n parseDefinitionWithDiagnostics,\n stripDefinitionDiagnostics,\n} from '#core/parse-definition.js';\nimport {upsertDefinition} from '#db/definitions.js';\nimport {toDefinitionDto} from '#presentation/dto/index.js';\nimport {requireProjectAccess} from './project-access.js';\n\nexport interface CreateDefinitionRouteOptions {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations?: IntegrationsModuleClient;\n}\n\nexport function buildCreateDefinitionRoute(options: CreateDefinitionRouteOptions) {\n return defineRoute({\n method: 'POST',\n path: '/',\n description: 'Create or update a workflow definition',\n schema: {\n body: createDefinitionBodySchema,\n response: {\n 200: definitionResponseSchema,\n 400: z.object({\n code: z.string(),\n message: z.string().optional(),\n details: z.array(definitionValidationErrorSchema).optional(),\n }),\n 404: z.object({code: z.string()}),\n },\n },\n errorHandler: (error, _request, _reply) => {\n if (error instanceof DefinitionParseError) {\n throw new ClientError(error.message, 'invalid-workflow-definition', {\n details: error.details,\n status: 400,\n });\n }\n throw error;\n },\n handler: async (request) => {\n const {project_id: projectId, config_path, source, yaml: yamlString, sha, ref} = request.body;\n const project = await requireProjectAccess(request, projectId, options.projects);\n\n const agentValidationCatalog = await options.agent.getValidationCatalog({});\n const structurallyParsed = parseDefinitionForCreate(yamlString, {agentValidationCatalog});\n const {integrations} = options;\n const parsed =\n integrations !== undefined && hasAgentStepIntegrations(structurallyParsed.document)\n ? parseDefinitionForCreate(yamlString, {\n agentValidationCatalog,\n integrationValidationContext: await loadIntegrationValidationContext(\n integrations,\n project.workspaceId,\n project.sourceConnectionId,\n ),\n })\n : structurallyParsed;\n\n const definition = await upsertDefinition({\n projectId,\n workspaceId: project.workspaceId,\n configPath: config_path,\n source,\n name: parsed.document.name,\n document: parsed.document,\n model: parsed.model,\n sourceSnapshot: parsed.sourceSnapshot,\n sha,\n ref,\n });\n\n return toDefinitionDto(definition);\n },\n });\n}\n\nfunction parseDefinitionForCreate(yamlString: string, options: ParseDefinitionOptions) {\n const parsed = parseDefinitionWithDiagnostics(yamlString, options);\n const errors = parsed.diagnostics\n .filter((diagnostic) => diagnostic.severity === 'error')\n .map(({message, path}) => ({message, ...(path === undefined ? {} : {path})}));\n\n if (errors.length > 0) {\n throw new DefinitionParseError(errors[0]?.message ?? 'Invalid definition', errors);\n }\n\n return stripDefinitionDiagnostics(parsed);\n}\n"],"names":["createDefinitionBodySchema","definitionResponseSchema","definitionValidationErrorSchema","ClientError","defineRoute","z","DefinitionParseError","hasAgentStepIntegrations","loadIntegrationValidationContext","parseDefinitionWithDiagnostics","stripDefinitionDiagnostics","upsertDefinition","toDefinitionDto","requireProjectAccess","buildCreateDefinitionRoute","options","method","path","description","schema","body","response","object","code","string","message","optional","details","array","errorHandler","error","_request","_reply","status","handler","request","project_id","projectId","config_path","source","yaml","yamlString","sha","ref","project","projects","agentValidationCatalog","agent","getValidationCatalog","structurallyParsed","parseDefinitionForCreate","integrations","parsed","undefined","document","integrationValidationContext","workspaceId","sourceConnectionId","definition","configPath","name","model","sourceSnapshot","errors","diagnostics","filter","diagnostic","severity","map","length"],"mappings":"AACA,SACEA,0BAA0B,EAC1BC,wBAAwB,EACxBC,+BAA+B,QAC1B,+BAA+B;AAGtC,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,oBAAoB,QAAO,kBAAkB;AACrD,SAAQC,wBAAwB,QAAO,uCAAuC;AAC9E,SAAQC,gCAAgC,QAAO,wBAAwB;AACvE,SAEEC,8BAA8B,EAC9BC,0BAA0B,QACrB,4BAA4B;AACnC,SAAQC,gBAAgB,QAAO,qBAAqB;AACpD,SAAQC,eAAe,QAAO,6BAA6B;AAC3D,SAAQC,oBAAoB,QAAO,sBAAsB;AAQzD,OAAO,SAASC,2BAA2BC,OAAqC;IAC9E,OAAOX,YAAY;QACjBY,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,MAAMpB;YACNqB,UAAU;gBACR,KAAKpB;gBACL,KAAKI,EAAEiB,MAAM,CAAC;oBACZC,MAAMlB,EAAE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AAO/B,gBAAgB8C;QACzB;IACF;AACF;AAEA,SAASR,yBAAyBT,UAAkB,EAAE1B,OAA+B;IACnF,MAAMqC,SAAS3C,+BAA+BgC,YAAY1B;IAC1D,MAAMgD,SAASX,OAAOY,WAAW,CAC9BC,MAAM,CAAC,CAACC,aAAeA,WAAWC,QAAQ,KAAK,SAC/CC,GAAG,CAAC,CAAC,EAAC3C,OAAO,EAAER,IAAI,EAAC,GAAM,CAAA;YAACQ;YAAS,GAAIR,SAASoC,YAAY,CAAC,IAAI;gBAACpC;YAAI,CAAC;QAAC,CAAA;IAE5E,IAAI8C,OAAOM,MAAM,GAAG,GAAG;QACrB,MAAM,IAAI/D,qBAAqByD,MAAM,CAAC,EAAE,EAAEtC,WAAW,sBAAsBsC;IAC7E;IAEA,OAAOrD,2BAA2B0C;AACpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-definition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAOjF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB,mDAyBrE"}
1
+ {"version":3,"file":"get-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-definition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAWjF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB,mDAsCrE"}
@@ -1,7 +1,7 @@
1
1
  import { definitionResponseSchema } from '@shipfox/api-definitions-dto';
2
2
  import { ClientError, defineRoute } from '@shipfox/node-fastify';
3
3
  import { z } from 'zod';
4
- import { getDefinitionById } from '#db/definitions.js';
4
+ import { getDefinitionById, getDefinitionByWorkflowId, getWorkflowLineageById } from '#db/definitions.js';
5
5
  import { toDefinitionDto } from '#presentation/dto/index.js';
6
6
  import { requireProjectAccess } from './project-access.js';
7
7
  export function buildGetDefinitionRoute(projects) {
@@ -20,13 +20,27 @@ export function buildGetDefinitionRoute(projects) {
20
20
  handler: async (request)=>{
21
21
  const { id } = request.params;
22
22
  const definition = await getDefinitionById(id);
23
- if (!definition) {
23
+ if (definition) {
24
+ await requireProjectAccess(request, definition.projectId, projects);
25
+ return toDefinitionDto(definition);
26
+ }
27
+ const lineage = await getWorkflowLineageById(id);
28
+ if (!lineage) {
29
+ throw new ClientError('Definition not found', 'not-found', {
30
+ status: 404
31
+ });
32
+ }
33
+ const project = await requireProjectAccess(request, lineage.projectId, projects);
34
+ const syncedDefinition = project.sourceDefaultBranch ? await getDefinitionByWorkflowId({
35
+ workflowId: id,
36
+ ref: project.sourceDefaultBranch
37
+ }) : undefined;
38
+ if (!syncedDefinition) {
24
39
  throw new ClientError('Definition not found', 'not-found', {
25
40
  status: 404
26
41
  });
27
42
  }
28
- await requireProjectAccess(request, definition.projectId, projects);
29
- return toDefinitionDto(definition);
43
+ return toDefinitionDto(syncedDefinition);
30
44
  }
31
45
  });
32
46
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/get-definition.ts"],"sourcesContent":["import {definitionResponseSchema} from '@shipfox/api-definitions-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {getDefinitionById} from '#db/definitions.js';\nimport {toDefinitionDto} from '#presentation/dto/index.js';\nimport {requireProjectAccess} from './project-access.js';\n\nexport function buildGetDefinitionRoute(projects: ProjectsModuleClient) {\n return defineRoute({\n method: 'GET',\n path: '/:id',\n description: 'Get a definition by ID',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n response: {\n 200: definitionResponseSchema,\n },\n },\n handler: async (request) => {\n const {id} = request.params;\n const definition = await getDefinitionById(id);\n\n if (!definition) {\n throw new ClientError('Definition not found', 'not-found', {status: 404});\n }\n await requireProjectAccess(request, definition.projectId, projects);\n\n return toDefinitionDto(definition);\n },\n });\n}\n"],"names":["definitionResponseSchema","ClientError","defineRoute","z","getDefinitionById","toDefinitionDto","requireProjectAccess","buildGetDefinitionRoute","projects","method","path","description","schema","params","object","id","string","uuid","response","handler","request","definition","status","projectId"],"mappings":"AAAA,SAAQA,wBAAwB,QAAO,+BAA+B;AAEtE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,eAAe,QAAO,6BAA6B;AAC3D,SAAQC,oBAAoB,QAAO,sBAAsB;AAEzD,OAAO,SAASC,wBAAwBC,QAA8B;IACpE,OAAON,YAAY;QACjBO,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQV,EAAEW,MAAM,CAAC;gBACfC,IAAIZ,EAAEa,MAAM,GAAGC,IAAI;YACrB;YACAC,UAAU;gBACR,KAAKlB;YACP;QACF;QACAmB,SAAS,OAAOC;YACd,MAAM,EAACL,EAAE,EAAC,GAAGK,QAAQP,MAAM;YAC3B,MAAMQ,aAAa,MAAMjB,kBAAkBW;YAE3C,IAAI,CAACM,YAAY;gBACf,MAAM,IAAIpB,YAAY,wBAAwB,aAAa;oBAACqB,QAAQ;gBAAG;YACzE;YACA,MAAMhB,qBAAqBc,SAASC,WAAWE,SAAS,EAAEf;YAE1D,OAAOH,gBAAgBgB;QACzB;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/get-definition.ts"],"sourcesContent":["import {definitionResponseSchema} from '@shipfox/api-definitions-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {\n getDefinitionById,\n getDefinitionByWorkflowId,\n getWorkflowLineageById,\n} from '#db/definitions.js';\nimport {toDefinitionDto} from '#presentation/dto/index.js';\nimport {requireProjectAccess} from './project-access.js';\n\nexport function buildGetDefinitionRoute(projects: ProjectsModuleClient) {\n return defineRoute({\n method: 'GET',\n path: '/:id',\n description: 'Get a definition by ID',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n response: {\n 200: definitionResponseSchema,\n },\n },\n handler: async (request) => {\n const {id} = request.params;\n const definition = await getDefinitionById(id);\n\n if (definition) {\n await requireProjectAccess(request, definition.projectId, projects);\n return toDefinitionDto(definition);\n }\n\n const lineage = await getWorkflowLineageById(id);\n if (!lineage) {\n throw new ClientError('Definition not found', 'not-found', {status: 404});\n }\n\n const project = await requireProjectAccess(request, lineage.projectId, projects);\n const syncedDefinition = project.sourceDefaultBranch\n ? await getDefinitionByWorkflowId({workflowId: id, ref: project.sourceDefaultBranch})\n : undefined;\n if (!syncedDefinition) {\n throw new ClientError('Definition not found', 'not-found', {status: 404});\n }\n\n return toDefinitionDto(syncedDefinition);\n },\n });\n}\n"],"names":["definitionResponseSchema","ClientError","defineRoute","z","getDefinitionById","getDefinitionByWorkflowId","getWorkflowLineageById","toDefinitionDto","requireProjectAccess","buildGetDefinitionRoute","projects","method","path","description","schema","params","object","id","string","uuid","response","handler","request","definition","projectId","lineage","status","project","syncedDefinition","sourceDefaultBranch","workflowId","ref","undefined"],"mappings":"AAAA,SAAQA,wBAAwB,QAAO,+BAA+B;AAEtE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SACEC,iBAAiB,EACjBC,yBAAyB,EACzBC,sBAAsB,QACjB,qBAAqB;AAC5B,SAAQC,eAAe,QAAO,6BAA6B;AAC3D,SAAQC,oBAAoB,QAAO,sBAAsB;AAEzD,OAAO,SAASC,wBAAwBC,QAA8B;IACpE,OAAOR,YAAY;QACjBS,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQZ,EAAEa,MAAM,CAAC;gBACfC,IAAId,EAAEe,MAAM,GAAGC,IAAI;YACrB;YACAC,UAAU;gBACR,KAAKpB;YACP;QACF;QACAqB,SAAS,OAAOC;YACd,MAAM,EAACL,EAAE,EAAC,GAAGK,QAAQP,MAAM;YAC3B,MAAMQ,aAAa,MAAMnB,kBAAkBa;YAE3C,IAAIM,YAAY;gBACd,MAAMf,qBAAqBc,SAASC,WAAWC,SAAS,EAAEd;gBAC1D,OAAOH,gBAAgBgB;YACzB;YAEA,MAAME,UAAU,MAAMnB,uBAAuBW;YAC7C,IAAI,CAACQ,SAAS;gBACZ,MAAM,IAAIxB,YAAY,wBAAwB,aAAa;oBAACyB,QAAQ;gBAAG;YACzE;YAEA,MAAMC,UAAU,MAAMnB,qBAAqBc,SAASG,QAAQD,SAAS,EAAEd;YACvE,MAAMkB,mBAAmBD,QAAQE,mBAAmB,GAChD,MAAMxB,0BAA0B;gBAACyB,YAAYb;gBAAIc,KAAKJ,QAAQE,mBAAmB;YAAA,KACjFG;YACJ,IAAI,CAACJ,kBAAkB;gBACrB,MAAM,IAAI3B,YAAY,wBAAwB,aAAa;oBAACyB,QAAQ;gBAAG;YACzE;YAEA,OAAOnB,gBAAgBqB;QACzB;IACF;AACF"}
@@ -6,6 +6,7 @@ export declare function requireProjectAccess(request: FastifyRequest, projectId:
6
6
  sourceConnectionId: string;
7
7
  sourceExternalRepositoryId: string;
8
8
  sourceRepositoryOwner?: string | null | undefined;
9
+ sourceDefaultBranch?: string | null | undefined;
9
10
  name: string;
10
11
  }>;
11
12
  //# sourceMappingURL=project-access.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-access.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/project-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,oBAAoB;;;;;;;GAO/B"}
1
+ {"version":3,"file":"project-access.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/project-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,oBAAoB;;;;;;;;GAO/B"}
@@ -1,4 +1,4 @@
1
- import { definitionDtoSchema, definitionValidationErrorSchema, definitionValidationWarningSchema } from '@shipfox/api-definitions-dto';
1
+ import { definitionDtoSchema, definitionValidationDiagnosticSchema, definitionValidationErrorSchema } from '@shipfox/api-definitions-dto';
2
2
  import { defineRoute } from '@shipfox/node-fastify';
3
3
  import { z } from 'zod';
4
4
  import { validateDefinition } from '#core/validate-definition.js';
@@ -10,7 +10,7 @@ const validationResultSchema = z.union([
10
10
  valid: z.literal(true),
11
11
  workflow_document: definitionDtoSchema.shape.workflow_document,
12
12
  workflow_model: definitionDtoSchema.shape.workflow_model,
13
- warnings: z.array(definitionValidationWarningSchema)
13
+ diagnostics: z.array(definitionValidationDiagnosticSchema)
14
14
  }),
15
15
  z.object({
16
16
  valid: z.literal(false),
@@ -38,7 +38,7 @@ export function buildValidateDefinitionRoute(agent) {
38
38
  valid: true,
39
39
  workflow_document: result.definition.document,
40
40
  workflow_model: result.definition.model,
41
- warnings: result.warnings
41
+ diagnostics: result.diagnostics
42
42
  };
43
43
  }
44
44
  return result;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/validate-definition.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n definitionDtoSchema,\n definitionValidationErrorSchema,\n definitionValidationWarningSchema,\n} from '@shipfox/api-definitions-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {validateDefinition} from '#core/validate-definition.js';\n\nconst validateBodySchema = z.object({\n yaml: z.string().min(1).max(1_000_000),\n});\n\nconst validationResultSchema = z.union([\n z.object({\n valid: z.literal(true),\n workflow_document: definitionDtoSchema.shape.workflow_document,\n workflow_model: definitionDtoSchema.shape.workflow_model,\n warnings: z.array(definitionValidationWarningSchema),\n }),\n z.object({\n valid: z.literal(false),\n errors: z.array(definitionValidationErrorSchema),\n }),\n]);\n\nexport function buildValidateDefinitionRoute(agent: AgentInterModuleClient) {\n return defineRoute({\n method: 'POST',\n path: '/validate',\n description: 'Validate a workflow definition without persisting',\n schema: {\n body: validateBodySchema,\n response: {\n 200: validationResultSchema,\n },\n },\n handler: async (request) => {\n const {yaml} = request.body;\n const result = validateDefinition(yaml, {\n agentValidationCatalog: await agent.getValidationCatalog({}),\n });\n\n if (result.valid) {\n return {\n valid: true as const,\n workflow_document: result.definition.document,\n workflow_model: result.definition.model,\n warnings: result.warnings,\n };\n }\n\n return result;\n },\n });\n}\n"],"names":["definitionDtoSchema","definitionValidationErrorSchema","definitionValidationWarningSchema","defineRoute","z","validateDefinition","validateBodySchema","object","yaml","string","min","max","validationResultSchema","union","valid","literal","workflow_document","shape","workflow_model","warnings","array","errors","buildValidateDefinitionRoute","agent","method","path","description","schema","body","response","handler","request","result","agentValidationCatalog","getValidationCatalog","definition","document","model"],"mappings":"AACA,SACEA,mBAAmB,EACnBC,+BAA+B,EAC/BC,iCAAiC,QAC5B,+BAA+B;AACtC,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,kBAAkB,QAAO,+BAA+B;AAEhE,MAAMC,qBAAqBF,EAAEG,MAAM,CAAC;IAClCC,MAAMJ,EAAEK,MAAM,GAAGC,GAAG,CAAC,GAAGC,GAAG,CAAC;AAC9B;AAEA,MAAMC,yBAAyBR,EAAES,KAAK,CAAC;IACrCT,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEW,OAAO,CAAC;QACjBC,mBAAmBhB,oBAAoBiB,KAAK,CAACD,iBAAiB;QAC9DE,gBAAgBlB,oBAAoBiB,KAAK,CAACC,cAAc;QACxDC,UAAUf,EAAEgB,KAAK,CAAClB;IACpB;IACAE,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEW,OAAO,CAAC;QACjBM,QAAQjB,EAAEgB,KAAK,CAACnB;IAClB;CACD;AAED,OAAO,SAASqB,6BAA6BC,KAA6B;IACxE,OAAOpB,YAAY;QACjBqB,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,MAAMtB;YACNuB,UAAU;gBACR,KAAKjB;YACP;QACF;QACAkB,SAAS,OAAOC;YACd,MAAM,EAACvB,IAAI,EAAC,GAAGuB,QAAQH,IAAI;YAC3B,MAAMI,SAAS3B,mBAAmBG,MAAM;gBACtCyB,wBAAwB,MAAMV,MAAMW,oBAAoB,CAAC,CAAC;YAC5D;YAEA,IAAIF,OAAOlB,KAAK,EAAE;gBAChB,OAAO;oBACLA,OAAO;oBACPE,mBAAmBgB,OAAOG,UAAU,CAACC,QAAQ;oBAC7ClB,gBAAgBc,OAAOG,UAAU,CAACE,KAAK;oBACvClB,UAAUa,OAAOb,QAAQ;gBAC3B;YACF;YAEA,OAAOa;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/validate-definition.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n definitionDtoSchema,\n definitionValidationDiagnosticSchema,\n definitionValidationErrorSchema,\n} from '@shipfox/api-definitions-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {validateDefinition} from '#core/validate-definition.js';\n\nconst validateBodySchema = z.object({\n yaml: z.string().min(1).max(1_000_000),\n});\n\nconst validationResultSchema = z.union([\n z.object({\n valid: z.literal(true),\n workflow_document: definitionDtoSchema.shape.workflow_document,\n workflow_model: definitionDtoSchema.shape.workflow_model,\n diagnostics: z.array(definitionValidationDiagnosticSchema),\n }),\n z.object({\n valid: z.literal(false),\n errors: z.array(definitionValidationErrorSchema),\n }),\n]);\n\nexport function buildValidateDefinitionRoute(agent: AgentInterModuleClient) {\n return defineRoute({\n method: 'POST',\n path: '/validate',\n description: 'Validate a workflow definition without persisting',\n schema: {\n body: validateBodySchema,\n response: {\n 200: validationResultSchema,\n },\n },\n handler: async (request) => {\n const {yaml} = request.body;\n const result = validateDefinition(yaml, {\n agentValidationCatalog: await agent.getValidationCatalog({}),\n });\n\n if (result.valid) {\n return {\n valid: true as const,\n workflow_document: result.definition.document,\n workflow_model: result.definition.model,\n diagnostics: result.diagnostics,\n };\n }\n\n return result;\n },\n });\n}\n"],"names":["definitionDtoSchema","definitionValidationDiagnosticSchema","definitionValidationErrorSchema","defineRoute","z","validateDefinition","validateBodySchema","object","yaml","string","min","max","validationResultSchema","union","valid","literal","workflow_document","shape","workflow_model","diagnostics","array","errors","buildValidateDefinitionRoute","agent","method","path","description","schema","body","response","handler","request","result","agentValidationCatalog","getValidationCatalog","definition","document","model"],"mappings":"AACA,SACEA,mBAAmB,EACnBC,oCAAoC,EACpCC,+BAA+B,QAC1B,+BAA+B;AACtC,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,kBAAkB,QAAO,+BAA+B;AAEhE,MAAMC,qBAAqBF,EAAEG,MAAM,CAAC;IAClCC,MAAMJ,EAAEK,MAAM,GAAGC,GAAG,CAAC,GAAGC,GAAG,CAAC;AAC9B;AAEA,MAAMC,yBAAyBR,EAAES,KAAK,CAAC;IACrCT,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEW,OAAO,CAAC;QACjBC,mBAAmBhB,oBAAoBiB,KAAK,CAACD,iBAAiB;QAC9DE,gBAAgBlB,oBAAoBiB,KAAK,CAACC,cAAc;QACxDC,aAAaf,EAAEgB,KAAK,CAACnB;IACvB;IACAG,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEW,OAAO,CAAC;QACjBM,QAAQjB,EAAEgB,KAAK,CAAClB;IAClB;CACD;AAED,OAAO,SAASoB,6BAA6BC,KAA6B;IACxE,OAAOpB,YAAY;QACjBqB,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,MAAMtB;YACNuB,UAAU;gBACR,KAAKjB;YACP;QACF;QACAkB,SAAS,OAAOC;YACd,MAAM,EAACvB,IAAI,EAAC,GAAGuB,QAAQH,IAAI;YAC3B,MAAMI,SAAS3B,mBAAmBG,MAAM;gBACtCyB,wBAAwB,MAAMV,MAAMW,oBAAoB,CAAC,CAAC;YAC5D;YAEA,IAAIF,OAAOlB,KAAK,EAAE;gBAChB,OAAO;oBACLA,OAAO;oBACPE,mBAAmBgB,OAAOG,UAAU,CAACC,QAAQ;oBAC7ClB,gBAAgBc,OAAOG,UAAU,CAACE,KAAK;oBACvClB,aAAaa,OAAOb,WAAW;gBACjC;YACF;YAEA,OAAOa;QACT;IACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
2
2
  import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto/inter-module';
3
- import type { DefinitionSyncErrorCode, DefinitionSyncWarning } from '#core/entities/sync-state.js';
3
+ import type { DefinitionSyncDiagnostic, DefinitionSyncErrorCode } from '#core/entities/sync-state.js';
4
4
  import type { DefinitionsSourceControl } from '#core/integrations.js';
5
5
  export interface SyncWorkflowInput {
6
6
  projectId: string;
@@ -31,10 +31,10 @@ export interface DiscoverWorkflowsActivityResult {
31
31
  export interface FetchAndApplyActivityResult {
32
32
  appliedCount: number;
33
33
  deletedCount: number;
34
- warnings: DefinitionSyncWarning[];
34
+ diagnostics: DefinitionSyncDiagnostic[];
35
35
  }
36
36
  export interface MarkSyncSucceededActivityInput extends SyncRefScopedInput {
37
- warnings?: readonly DefinitionSyncWarning[] | undefined;
37
+ diagnostics?: readonly DefinitionSyncDiagnostic[] | undefined;
38
38
  }
39
39
  export interface DefinitionSyncActivityOptions {
40
40
  workflowPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAI7F,OAAO,KAAK,EAAC,uBAAuB,EAAE,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAQjG,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uBAAuB,CAAC;AAIpE,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC;IACvF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CA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,0BAA0B,KAChC,OAAO,CAAC,2BAA2B,CAAC;IAvDrC,2BAA2B,UAqGpB,8BAA8B,KACpC,OAAO,CAAC,IAAI,CAAC;IArGd,wBAAwB,UAsHjB,2BAA2B,KACjC,OAAO,CAAC,IAAI,CAAC;EArHjB"}
@@ -28,7 +28,7 @@ function createPrepareDefinitionSyncActivity(sourceControl) {
28
28
  status: 'syncing',
29
29
  lastErrorCode: null,
30
30
  lastErrorMessage: null,
31
- warnings: [],
31
+ diagnostics: [],
32
32
  startedAt: new Date(),
33
33
  finishedAt: null
34
34
  });
@@ -81,7 +81,10 @@ function createFetchAndApplyActivity(sourceControl, agent, integrations) {
81
81
  });
82
82
  return {
83
83
  ...result,
84
- warnings: definitions.flatMap((entry)=>entry.warnings)
84
+ diagnostics: definitions.flatMap((entry)=>entry.diagnostics.map((diagnostic)=>({
85
+ ...diagnostic,
86
+ filePath: entry.path
87
+ })))
85
88
  };
86
89
  });
87
90
  };
@@ -96,7 +99,7 @@ function createMarkSyncSucceededActivity() {
96
99
  status: 'succeeded',
97
100
  lastErrorCode: null,
98
101
  lastErrorMessage: null,
99
- warnings: input.warnings ?? [],
102
+ diagnostics: input.diagnostics ?? [],
100
103
  finishedAt: new Date()
101
104
  });
102
105
  };
@@ -111,7 +114,7 @@ function createMarkSyncFailedActivity() {
111
114
  status: 'failed',
112
115
  lastErrorCode: input.code,
113
116
  lastErrorMessage: input.message,
114
- warnings: [],
117
+ diagnostics: [],
115
118
  finishedAt: new Date()
116
119
  });
117
120
  };