@shipfox/api-definitions 12.3.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 +45 -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 +494 -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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/workflow-model/normalize-triggers.ts"],"sourcesContent":["import {triggerSourceConfigSchemas, type WorkflowDocument} from '@shipfox/workflow-document';\nimport type {\n WorkflowModelListeningTrigger,\n WorkflowModelTrigger,\n} from '../entities/workflow-model.js';\nimport {cronTriggerDefaultTimezone, validateCronTrigger} from './cron-trigger.js';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {stableId} from './stable-id.js';\nimport {validatePredicateExpression} from './validate-predicate-expression.js';\nimport {issue} from './validation-issue.js';\n\nconst manualTriggerSource = 'manual';\nconst cronTriggerSource = 'cron';\ntype WorkflowDocumentTrigger = NonNullable<WorkflowDocument['triggers']>[string];\n\nexport function normalizeTriggers(\n document: WorkflowDocument,\n issues: WorkflowModelValidationIssue[],\n): readonly WorkflowModelTrigger[] {\n const triggers = document.triggers ?? {};\n const manualTriggerKeys = Object.entries(triggers)\n .filter(([, trigger]) => trigger.source === manualTriggerSource)\n .map(([sourceKey]) => sourceKey);\n const usedTriggerIds = new Map<string, string>();\n\n if (manualTriggerKeys.length > 1) {\n issues.push(\n issue({\n code: 'multiple-manual-triggers',\n message: `A workflow may declare at most one manual trigger; found ${manualTriggerKeys.length}: ${manualTriggerKeys.join(', ')}.`,\n path: ['triggers'],\n details: {manualTriggerKeys},\n }),\n );\n }\n\n return Object.entries(triggers).flatMap(([sourceKey, trigger]) => {\n const id = stableId(sourceKey);\n const existingSourceKey = usedTriggerIds.get(id);\n if (existingSourceKey !== undefined) {\n issues.push(\n issue({\n code: 'duplicate-trigger-id',\n message: `Trigger keys \"${existingSourceKey}\" and \"${sourceKey}\" resolve to the same stable id \"${id}\".`,\n path: ['triggers', sourceKey],\n details: {id, sourceKeys: [existingSourceKey, sourceKey]},\n }),\n );\n return [];\n }\n usedTriggerIds.set(id, sourceKey);\n\n validateTriggerFilter({sourceKey, trigger, issues});\n\n const normalizedTrigger = normalizeTriggerEntry(trigger);\n if (trigger.source !== cronTriggerSource) {\n return [\n {\n id,\n key: sourceKey,\n ...normalizedTrigger,\n ...(trigger.config === undefined ? {} : {config: trigger.config}),\n },\n ];\n }\n\n const cronConfig = triggerSourceConfigSchemas.cron.parse(trigger.config ?? {});\n const normalizedCronConfig = {\n ...cronConfig,\n timezone: cronConfig.timezone ?? cronTriggerDefaultTimezone,\n };\n\n validateCronTrigger({trigger, config: cronConfig, sourceKey, issues});\n\n return [\n {\n id,\n key: sourceKey,\n ...normalizedTrigger,\n config: normalizedCronConfig,\n },\n ];\n });\n}\n\nfunction validateTriggerFilter(params: {\n sourceKey: string;\n trigger: WorkflowDocumentTrigger;\n issues: WorkflowModelValidationIssue[];\n}): void {\n const {sourceKey, trigger, issues} = params;\n if (trigger.filter === undefined) return;\n\n const path = ['triggers', sourceKey, 'filter'] as const;\n if (trigger.source === manualTriggerSource || trigger.source === cronTriggerSource) {\n issues.push(\n issue({\n code: 'invalid-trigger-filter',\n message: `A ${trigger.source} trigger cannot define a filter because it does not receive an event payload.`,\n path,\n details: {source: trigger.filter, triggerSource: trigger.source},\n }),\n );\n return;\n }\n\n validatePredicateExpression({\n field: 'trigger.filter',\n source: trigger.filter,\n path,\n invalidCode: 'invalid-trigger-filter',\n invalidMessage: 'Trigger filter must be a valid boolean predicate.',\n issues,\n });\n}\n\nexport function normalizeTriggerEntry(trigger: {\n readonly source: string;\n readonly event: string;\n readonly with?: Readonly<Record<string, unknown>> | undefined;\n readonly filter?: string | undefined;\n}): WorkflowModelListeningTrigger {\n return {\n source: trigger.source,\n event: trigger.event,\n ...(trigger.with === undefined ? {} : {inputs: trigger.with}),\n ...(trigger.filter === undefined ? {} : {filter: trigger.filter}),\n };\n}\n"],"names":["triggerSourceConfigSchemas","cronTriggerDefaultTimezone","validateCronTrigger","stableId","validatePredicateExpression","issue","manualTriggerSource","cronTriggerSource","normalizeTriggers","document","issues","triggers","manualTriggerKeys","Object","entries","filter","trigger","source","map","sourceKey","usedTriggerIds","Map","length","push","code","message","join","path","details","flatMap","id","existingSourceKey","get","undefined","sourceKeys","set","validateTriggerFilter","normalizedTrigger","normalizeTriggerEntry","key","config","cronConfig","cron","parse","normalizedCronConfig","timezone","params","triggerSource","field","invalidCode","invalidMessage","event","with","inputs"],"mappings":"AAAA,SAAQA,0BAA0B,QAA8B,6BAA6B;AAK7F,SAAQC,0BAA0B,EAAEC,mBAAmB,QAAO,oBAAoB;AAElF,SAAQC,QAAQ,QAAO,iBAAiB;AACxC,SAAQC,2BAA2B,QAAO,qCAAqC;AAC/E,SAAQC,KAAK,QAAO,wBAAwB;AAE5C,MAAMC,sBAAsB;AAC5B,MAAMC,oBAAoB;AAG1B,OAAO,SAASC,kBACdC,QAA0B,EAC1BC,MAAsC;IAEtC,MAAMC,WAAWF,SAASE,QAAQ,IAAI,CAAC;IACvC,MAAMC,oBAAoBC,OAAOC,OAAO,CAACH,UACtCI,MAAM,CAAC,CAAC,GAAGC,QAAQ,GAAKA,QAAQC,MAAM,KAAKX,qBAC3CY,GAAG,CAAC,CAAC,CAACC,UAAU,GAAKA;IACxB,MAAMC,iBAAiB,IAAIC;IAE3B,IAAIT,kBAAkBU,MAAM,GAAG,GAAG;QAChCZ,OAAOa,IAAI,CACTlB,MAAM;YACJmB,MAAM;YACNC,SAAS,CAAC,yDAAyD,EAAEb,kBAAkBU,MAAM,CAAC,EAAE,EAAEV,kBAAkBc,IAAI,CAAC,MAAM,CAAC,CAAC;YACjIC,MAAM;gBAAC;aAAW;YAClBC,SAAS;gBAAChB;YAAiB;QAC7B;IAEJ;IAEA,OAAOC,OAAOC,OAAO,CAACH,UAAUkB,OAAO,CAAC,CAAC,CAACV,WAAWH,QAAQ;QAC3D,MAAMc,KAAK3B,SAASgB;QACpB,MAAMY,oBAAoBX,eAAeY,GAAG,CAACF;QAC7C,IAAIC,sBAAsBE,WAAW;YACnCvB,OAAOa,IAAI,CACTlB,MAAM;gBACJmB,MAAM;gBACNC,SAAS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,6EAA6E,CAAC;YAC3GU;YACAC,SAAS;gBAACX,QAAQD,QAAQD,MAAM;gBAAEgC,eAAe/B,QAAQC,MAAM;YAAA;QACjE;QAEF;IACF;IAEAb,4BAA4B;QAC1B4C,OAAO;QACP/B,QAAQD,QAAQD,MAAM;QACtBY;QACAsB,aAAa;QACbC,gBAAgB;QAChBxC;IACF;AACF;AAEA,OAAO,SAAS4B,sBAAsBtB,OAKrC;IACC,OAAO;QACLC,QAAQD,QAAQC,MAAM;QACtBkC,OAAOnC,QAAQmC,KAAK;QACpB,GAAInC,QAAQoC,IAAI,KAAKnB,YAAY,CAAC,IAAI;YAACoB,QAAQrC,QAAQoC,IAAI;QAAA,CAAC;QAC5D,GAAIpC,QAAQD,MAAM,KAAKkB,YAAY,CAAC,IAAI;YAAClB,QAAQC,QAAQD,MAAM;QAAA,CAAC;IAClE;AACF"}
1
+ {"version":3,"sources":["../../../src/core/workflow-model/normalize-triggers.ts"],"sourcesContent":["import {triggerSourceConfigSchemas, type WorkflowDocument} from '@shipfox/workflow-document';\nimport type {\n WorkflowModelListeningTrigger,\n WorkflowModelTrigger,\n} from '../entities/workflow-model.js';\nimport {cronTriggerDefaultTimezone, validateCronTrigger} from './cron-trigger.js';\nimport type {WorkflowModelValidationIssue} from './invalid-workflow-model-error.js';\nimport {stableId} from './stable-id.js';\nimport {validatePredicateExpression} from './validate-predicate-expression.js';\nimport {issue} from './validation-issue.js';\n\nconst manualTriggerSource = 'manual';\nconst cronTriggerSource = 'cron';\ntype WorkflowDocumentTrigger = NonNullable<WorkflowDocument['triggers']>[string];\n\nexport function normalizeTriggers(\n document: WorkflowDocument,\n issues: WorkflowModelValidationIssue[],\n): readonly WorkflowModelTrigger[] {\n const triggers = document.triggers ?? {};\n const manualTriggerKeys = Object.entries(triggers)\n .filter(([, trigger]) => trigger.source === manualTriggerSource)\n .map(([sourceKey]) => sourceKey);\n const usedTriggerIds = new Map<string, string>();\n let activeManualTriggerSeen = false;\n\n return Object.entries(triggers).flatMap(([sourceKey, trigger]) => {\n const id = stableId(sourceKey);\n const existingSourceKey = usedTriggerIds.get(id);\n if (existingSourceKey !== undefined) {\n issues.push(\n issue({\n code: 'duplicate-trigger-id',\n message: `Trigger keys \"${existingSourceKey}\" and \"${sourceKey}\" resolve to the same stable id \"${id}\".`,\n path: ['triggers', sourceKey],\n details: {id, sourceKeys: [existingSourceKey, sourceKey]},\n scope: 'trigger',\n }),\n );\n return [];\n }\n usedTriggerIds.set(id, sourceKey);\n\n if (trigger.source === manualTriggerSource) {\n if (activeManualTriggerSeen) {\n issues.push(\n issue({\n code: 'multiple-manual-triggers',\n message: `A workflow may declare at most one manual trigger; found ${manualTriggerKeys.length}: ${manualTriggerKeys.join(', ')}. This trigger is inert because it is not the first manual trigger in document order.`,\n path: ['triggers', sourceKey],\n details: {manualTriggerKeys},\n scope: 'trigger',\n }),\n );\n return [];\n }\n }\n\n const triggerIssues: WorkflowModelValidationIssue[] = [];\n validateTriggerFilter({sourceKey, trigger, issues: triggerIssues});\n issues.push(...triggerIssues);\n\n const normalizedTrigger = normalizeTriggerEntry(trigger);\n const triggerIsInert = triggerIssues.some((candidate) => candidate.scope === 'trigger');\n if (trigger.source !== cronTriggerSource) {\n if (triggerIsInert) return [];\n if (trigger.source === manualTriggerSource) activeManualTriggerSeen = true;\n return [\n {\n id,\n key: sourceKey,\n ...normalizedTrigger,\n ...(trigger.config === undefined ? {} : {config: trigger.config}),\n },\n ];\n }\n\n const cronConfig = triggerSourceConfigSchemas.cron.parse(trigger.config ?? {});\n const normalizedCronConfig = {\n ...cronConfig,\n timezone: cronConfig.timezone ?? cronTriggerDefaultTimezone,\n };\n\n const cronIssues: WorkflowModelValidationIssue[] = [];\n validateCronTrigger({trigger, config: cronConfig, sourceKey, issues: cronIssues});\n issues.push(...cronIssues);\n\n const cronIsInert = cronIssues.some((candidate) => candidate.scope === 'trigger');\n if (triggerIsInert || cronIsInert) return [];\n\n return [\n {\n id,\n key: sourceKey,\n ...normalizedTrigger,\n config: normalizedCronConfig,\n },\n ];\n });\n}\n\nfunction validateTriggerFilter(params: {\n sourceKey: string;\n trigger: WorkflowDocumentTrigger;\n issues: WorkflowModelValidationIssue[];\n}): void {\n const {sourceKey, trigger, issues} = params;\n if (trigger.filter === undefined) return;\n\n const path = ['triggers', sourceKey, 'filter'] as const;\n if (trigger.source === manualTriggerSource || trigger.source === cronTriggerSource) {\n issues.push(\n issue({\n code: 'invalid-trigger-filter',\n message: `A ${trigger.source} trigger cannot define a filter because it does not receive an event payload.`,\n path,\n details: {source: trigger.filter, triggerSource: trigger.source},\n scope: 'trigger',\n }),\n );\n return;\n }\n\n validatePredicateExpression({\n field: 'trigger.filter',\n source: trigger.filter,\n path,\n invalidCode: 'invalid-trigger-filter',\n invalidMessage: 'Trigger filter must be a valid boolean predicate.',\n issues,\n scope: 'trigger',\n });\n}\n\nexport function normalizeTriggerEntry(trigger: {\n readonly source: string;\n readonly event?: string | undefined;\n readonly with?: Readonly<Record<string, unknown>> | undefined;\n readonly filter?: string | undefined;\n}): WorkflowModelListeningTrigger {\n // `manual` and `cron` have no delivered event to resolve against at fire\n // time, so materialize their built-in name when the author omitted it.\n // Integration sources keep the event absent, which becomes a source\n // subscription (NULL row) on the write path.\n const event = builtinEventForSource(trigger.source, trigger.event);\n return {\n source: trigger.source,\n ...(event === undefined ? {} : {event}),\n ...(trigger.with === undefined ? {} : {inputs: trigger.with}),\n ...(trigger.filter === undefined ? {} : {filter: trigger.filter}),\n };\n}\n\nfunction builtinEventForSource(source: string, event: string | undefined): string | undefined {\n if (source === manualTriggerSource) return event ?? 'fire';\n if (source === cronTriggerSource) return event ?? 'tick';\n return event;\n}\n"],"names":["triggerSourceConfigSchemas","cronTriggerDefaultTimezone","validateCronTrigger","stableId","validatePredicateExpression","issue","manualTriggerSource","cronTriggerSource","normalizeTriggers","document","issues","triggers","manualTriggerKeys","Object","entries","filter","trigger","source","map","sourceKey","usedTriggerIds","Map","activeManualTriggerSeen","flatMap","id","existingSourceKey","get","undefined","push","code","message","path","details","sourceKeys","scope","set","length","join","triggerIssues","validateTriggerFilter","normalizedTrigger","normalizeTriggerEntry","triggerIsInert","some","candidate","key","config","cronConfig","cron","parse","normalizedCronConfig","timezone","cronIssues","cronIsInert","params","triggerSource","field","invalidCode","invalidMessage","event","builtinEventForSource","with","inputs"],"mappings":"AAAA,SAAQA,0BAA0B,QAA8B,6BAA6B;AAK7F,SAAQC,0BAA0B,EAAEC,mBAAmB,QAAO,oBAAoB;AAElF,SAAQC,QAAQ,QAAO,iBAAiB;AACxC,SAAQC,2BAA2B,QAAO,qCAAqC;AAC/E,SAAQC,KAAK,QAAO,wBAAwB;AAE5C,MAAMC,sBAAsB;AAC5B,MAAMC,oBAAoB;AAG1B,OAAO,SAASC,kBACdC,QAA0B,EAC1BC,MAAsC;IAEtC,MAAMC,WAAWF,SAASE,QAAQ,IAAI,CAAC;IACvC,MAAMC,oBAAoBC,OAAOC,OAAO,CAACH,UACtCI,MAAM,CAAC,CAAC,GAAGC,QAAQ,GAAKA,QAAQC,MAAM,KAAKX,qBAC3CY,GAAG,CAAC,CAAC,CAACC,UAAU,GAAKA;IACxB,MAAMC,iBAAiB,IAAIC;IAC3B,IAAIC,0BAA0B;IAE9B,OAAOT,OAAOC,OAAO,CAACH,UAAUY,OAAO,CAAC,CAAC,CAACJ,WAAWH,QAAQ;QAC3D,MAAMQ,KAAKrB,SAASgB;QACpB,MAAMM,oBAAoBL,eAAeM,GAAG,CAACF;QAC7C,IAAIC,sBAAsBE,WAAW;YACnCjB,OAAOkB,IAAI,CACTvB,MAAM;gBACJwB,MAAM;gBACNC,SAAS,CAAC,cAAc,EAAEL,kBAAkB,OAAO,EAAEN,UAAU,iCAAiC,EAAEK,GAAG,EAAE,CAAC;gBACxGO,MAAM;oBAAC;oBAAYZ;iBAAU;gBAC7Ba,SAAS;oBAACR;oBAAIS,YAAY;wBAACR;wBAAmBN;qBAAU;gBAAA;gBACxDe,OAAO;YACT;YAEF,OAAO,EAAE;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CAAC,IAAI;YAACZ,QAAQC,QAAQD,MAAM;QAAA,CAAC;IAClE;AACF;AAEA,SAAS6C,sBAAsB3C,MAAc,EAAE0C,KAAyB;IACtE,IAAI1C,WAAWX,qBAAqB,OAAOqD,SAAS;IACpD,IAAI1C,WAAWV,mBAAmB,OAAOoD,SAAS;IAClD,OAAOA;AACT"}
@@ -9,6 +9,6 @@ export declare function normalizeWorkflowDocument(document: WorkflowDocument, op
9
9
  integrationValidationContext?: IntegrationValidationContext | undefined;
10
10
  stepSourceLocations?: WorkflowStepSourceLocationMap | undefined;
11
11
  /** Provide a fresh array for each call to collect non-fatal validation issues. */
12
- warnings?: WorkflowModelValidationIssue[] | undefined;
12
+ diagnostics?: WorkflowModelValidationIssue[] | undefined;
13
13
  }): WorkflowModel;
14
14
  //# sourceMappingURL=normalize-workflow-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-workflow-document.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-workflow-document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAC,aAAa,EAAE,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAChG,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,mCAAmC,CAAC;AAS3C,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE;IACP,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACpD,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,4BAA4B,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;IACxE,mBAAmB,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;IAChE,kFAAkF;IAClF,QAAQ,CAAC,EAAE,4BAA4B,EAAE,GAAG,SAAS,CAAC;CACvD,GACA,aAAa,CAuDf"}
1
+ {"version":3,"file":"normalize-workflow-document.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-workflow-document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAC,aAAa,EAAE,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAChG,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,mCAAmC,CAAC;AAS3C,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE;IACP,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACpD,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,4BAA4B,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;IACxE,mBAAmB,CAAC,EAAE,6BAA6B,GAAG,SAAS,CAAC;IAChE,kFAAkF;IAClF,WAAW,CAAC,EAAE,4BAA4B,EAAE,GAAG,SAAS,CAAC;CAC1D,GACA,aAAa,CA2Df"}
@@ -51,9 +51,9 @@ export function normalizeWorkflowDocument(document, options) {
51
51
  }
52
52
  ];
53
53
  validateCycles(document.jobs, jobIdBySourceName, issues);
54
- const warnings = issues.filter((issue)=>issue.severity === 'warning');
55
- options.warnings?.push(...warnings);
56
- const errors = issues.filter((issue)=>issue.severity !== 'warning');
54
+ const diagnostics = issues.filter((issue)=>!(issue.severity === 'error' && issue.scope === 'definition'));
55
+ options.diagnostics?.push(...diagnostics);
56
+ const errors = issues.filter((issue)=>issue.severity === 'error' && issue.scope === 'definition');
57
57
  if (errors.length > 0) throw new InvalidWorkflowModelError(errors);
58
58
  return {
59
59
  kind: 'workflow',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/workflow-model/normalize-workflow-document.ts"],"sourcesContent":["import type {AgentValidationCatalog} from '@shipfox/api-agent-dto/inter-module';\nimport {canonicalizeLabels} from '@shipfox/runner-labels';\nimport type {WorkflowDocument} from '@shipfox/workflow-document';\nimport type {IntegrationValidationContext} from '../entities/integration-context.js';\nimport type {WorkflowModel, WorkflowStepSourceLocationMap} from '../entities/workflow-model.js';\nimport {\n InvalidWorkflowModelError,\n type WorkflowModelValidationIssue,\n} from './invalid-workflow-model-error.js';\nimport {mapJobIds} from './map-job-ids.js';\nimport {normalizeDependencies, validateCycles} from './normalize-dependencies.js';\nimport {normalizeEnv} from './normalize-env.js';\nimport {normalizeJobs} from './normalize-jobs.js';\nimport {normalizeTriggers} from './normalize-triggers.js';\nimport {parseInterpolationField} from './parse-interpolation-field.js';\nimport {unescapeLiteralName, validateLiteralName} from './validate-literal-name.js';\n\nexport function normalizeWorkflowDocument(\n document: WorkflowDocument,\n options: {\n defaultRunnerLabels?: readonly string[] | undefined;\n agentValidationCatalog: AgentValidationCatalog;\n integrationValidationContext?: IntegrationValidationContext | undefined;\n stepSourceLocations?: WorkflowStepSourceLocationMap | undefined;\n /** Provide a fresh array for each call to collect non-fatal validation issues. */\n warnings?: WorkflowModelValidationIssue[] | undefined;\n },\n): WorkflowModel {\n const issues: WorkflowModelValidationIssue[] = [];\n const defaultRunnerLabels = canonicalizeLabels(options.defaultRunnerLabels);\n const context = {\n defaultRunnerLabels,\n agentValidationCatalog: options.agentValidationCatalog,\n integrationValidationContext: options.integrationValidationContext,\n };\n validateLiteralName({\n field: 'workflow.name',\n dynamicField: 'run_name',\n source: document.name,\n path: ['name'],\n message: 'Workflow name must be literal. Move runtime interpolation to run_name.',\n issues,\n });\n const jobIdBySourceName = mapJobIds(document, issues);\n const triggers = normalizeTriggers(document, issues);\n const jobs = normalizeJobs(\n document,\n jobIdBySourceName,\n issues,\n options.stepSourceLocations,\n context,\n );\n const dependencies = normalizeDependencies(document.jobs, jobIdBySourceName, issues);\n const workflowEnv = normalizeEnv({env: document.env, path: ['env'], issues});\n const runName =\n document.run_name === undefined\n ? undefined\n : (parseInterpolationField({\n field: 'workflow.run_name',\n source: document.run_name,\n path: ['run_name'],\n issues,\n fillSite: 'run-creation',\n }) ?? [{kind: 'literal' as const, value: document.run_name}]);\n\n validateCycles(document.jobs, jobIdBySourceName, issues);\n\n const warnings = issues.filter((issue) => issue.severity === 'warning');\n options.warnings?.push(...warnings);\n\n const errors = issues.filter((issue) => issue.severity !== 'warning');\n if (errors.length > 0) throw new InvalidWorkflowModelError(errors);\n\n return {\n kind: 'workflow',\n name: unescapeLiteralName(document.name),\n ...(runName === undefined ? {} : {runName}),\n ...workflowEnv,\n triggers,\n jobs,\n dependencies,\n };\n}\n"],"names":["canonicalizeLabels","InvalidWorkflowModelError","mapJobIds","normalizeDependencies","validateCycles","normalizeEnv","normalizeJobs","normalizeTriggers","parseInterpolationField","unescapeLiteralName","validateLiteralName","normalizeWorkflowDocument","document","options","issues","defaultRunnerLabels","context","agentValidationCatalog","integrationValidationContext","field","dynamicField","source","name","path","message","jobIdBySourceName","triggers","jobs","stepSourceLocations","dependencies","workflowEnv","env","runName","run_name","undefined","fillSite","kind","value","warnings","filter","issue","severity","push","errors","length"],"mappings":"AACA,SAAQA,kBAAkB,QAAO,yBAAyB;AAI1D,SACEC,yBAAyB,QAEpB,oCAAoC;AAC3C,SAAQC,SAAS,QAAO,mBAAmB;AAC3C,SAAQC,qBAAqB,EAAEC,cAAc,QAAO,8BAA8B;AAClF,SAAQC,YAAY,QAAO,qBAAqB;AAChD,SAAQC,aAAa,QAAO,sBAAsB;AAClD,SAAQC,iBAAiB,QAAO,0BAA0B;AAC1D,SAAQC,uBAAuB,QAAO,iCAAiC;AACvE,SAAQC,mBAAmB,EAAEC,mBAAmB,QAAO,6BAA6B;AAEpF,OAAO,SAASC,0BACdC,QAA0B,EAC1B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AACF;QAAO,CAAC;QAC1C,GAAGF,WAAW;QACdJ;QACAC;QACAE;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/core/workflow-model/normalize-workflow-document.ts"],"sourcesContent":["import type {AgentValidationCatalog} from '@shipfox/api-agent-dto/inter-module';\nimport {canonicalizeLabels} from '@shipfox/runner-labels';\nimport type {WorkflowDocument} from '@shipfox/workflow-document';\nimport type {IntegrationValidationContext} from '../entities/integration-context.js';\nimport type {WorkflowModel, WorkflowStepSourceLocationMap} from '../entities/workflow-model.js';\nimport {\n InvalidWorkflowModelError,\n type WorkflowModelValidationIssue,\n} from './invalid-workflow-model-error.js';\nimport {mapJobIds} from './map-job-ids.js';\nimport {normalizeDependencies, validateCycles} from './normalize-dependencies.js';\nimport {normalizeEnv} from './normalize-env.js';\nimport {normalizeJobs} from './normalize-jobs.js';\nimport {normalizeTriggers} from './normalize-triggers.js';\nimport {parseInterpolationField} from './parse-interpolation-field.js';\nimport {unescapeLiteralName, validateLiteralName} from './validate-literal-name.js';\n\nexport function normalizeWorkflowDocument(\n document: WorkflowDocument,\n options: {\n defaultRunnerLabels?: readonly string[] | undefined;\n agentValidationCatalog: AgentValidationCatalog;\n integrationValidationContext?: IntegrationValidationContext | undefined;\n stepSourceLocations?: WorkflowStepSourceLocationMap | undefined;\n /** Provide a fresh array for each call to collect non-fatal validation issues. */\n diagnostics?: WorkflowModelValidationIssue[] | undefined;\n },\n): WorkflowModel {\n const issues: WorkflowModelValidationIssue[] = [];\n const defaultRunnerLabels = canonicalizeLabels(options.defaultRunnerLabels);\n const context = {\n defaultRunnerLabels,\n agentValidationCatalog: options.agentValidationCatalog,\n integrationValidationContext: options.integrationValidationContext,\n };\n validateLiteralName({\n field: 'workflow.name',\n dynamicField: 'run_name',\n source: document.name,\n path: ['name'],\n message: 'Workflow name must be literal. Move runtime interpolation to run_name.',\n issues,\n });\n const jobIdBySourceName = mapJobIds(document, issues);\n const triggers = normalizeTriggers(document, issues);\n const jobs = normalizeJobs(\n document,\n jobIdBySourceName,\n issues,\n options.stepSourceLocations,\n context,\n );\n const dependencies = normalizeDependencies(document.jobs, jobIdBySourceName, issues);\n const workflowEnv = normalizeEnv({env: document.env, path: ['env'], issues});\n const runName =\n document.run_name === undefined\n ? undefined\n : (parseInterpolationField({\n field: 'workflow.run_name',\n source: document.run_name,\n path: ['run_name'],\n issues,\n fillSite: 'run-creation',\n }) ?? [{kind: 'literal' as const, value: document.run_name}]);\n\n validateCycles(document.jobs, jobIdBySourceName, issues);\n\n const diagnostics = issues.filter(\n (issue) => !(issue.severity === 'error' && issue.scope === 'definition'),\n );\n options.diagnostics?.push(...diagnostics);\n\n const errors = issues.filter(\n (issue) => issue.severity === 'error' && issue.scope === 'definition',\n );\n if (errors.length > 0) throw new InvalidWorkflowModelError(errors);\n\n return {\n kind: 'workflow',\n name: unescapeLiteralName(document.name),\n ...(runName === undefined ? {} : {runName}),\n ...workflowEnv,\n triggers,\n jobs,\n dependencies,\n };\n}\n"],"names":["canonicalizeLabels","InvalidWorkflowModelError","mapJobIds","normalizeDependencies","validateCycles","normalizeEnv","normalizeJobs","normalizeTriggers","parseInterpolationField","unescapeLiteralName","validateLiteralName","normalizeWorkflowDocument","document","options","issues","defaultRunnerLabels","context","agentValidationCatalog","integrationValidationContext","field","dynamicField","source","name","path","message","jobIdBySourceName","triggers","jobs","stepSourceLocations","dependencies","workflowEnv","env","runName","run_name","undefined","fillSite","kind","value","diagnostics","filter","issue","severity","scope","push","errors","length"],"mappings":"AACA,SAAQA,kBAAkB,QAAO,yBAAyB;AAI1D,SACEC,yBAAyB,QAEpB,oCAAoC;AAC3C,SAAQC,SAAS,QAAO,mBAAmB;AAC3C,SAAQC,qBAAqB,EAAEC,cAAc,QAAO,8BAA8B;AAClF,SAAQC,YAAY,QAAO,qBAAqB;AAChD,SAAQC,aAAa,QAAO,sBAAsB;AAClD,SAAQC,iBAAiB,QAAO,0BAA0B;AAC1D,SAAQC,uBAAuB,QAAO,iCAAiC;AACvE,SAA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OAAOC,MAAM,GAAG,GAAG,MAAM,IAAI5C,0BAA0B2C;IAE3D,OAAO;QACLR,MAAM;QACNd,MAAMb,oBAAoBG,SAASU,IAAI;QACvC,GAAIU,YAAYE,YAAY,CAAC,IAAI;YAACF;QAAO,CAAC;QAC1C,GAAGF,WAAW;QACdJ;QACAC;QACAE;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-interpolation-field.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/parse-interpolation-field.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,gBAAgB,EAIrB,KAAK,yBAAyB,EAkB/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EACV,4BAA4B,EAE5B,uCAAuC,EACxC,MAAM,mCAAmC,CAAC;AAG3C,MAAM,MAAM,wBAAwB,GAChC,KAAK,GACL,WAAW,GACX,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,oBAAoB,GACpB,YAAY,GACZ,WAAW,GACX,wBAAwB,GACxB,eAAe,GACf,kBAAkB,GAClB,qBAAqB,GACrB,qBAAqB,GACrB,cAAc,GACd,eAAe,CAAC;AAEpB,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,KAAK,EAAE,wBAAwB,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,SAAS,uCAAuC,EAAE,CAAC;IACzD,MAAM,EAAE,4BAA4B,EAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;CACrD,GAAG,qBAAqB,GAAG,SAAS,CAuBpC"}
1
+ {"version":3,"file":"parse-interpolation-field.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/parse-interpolation-field.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,gBAAgB,EAIrB,KAAK,yBAAyB,EAkB/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EACV,4BAA4B,EAC5B,uCAAuC,EACxC,MAAM,mCAAmC,CAAC;AAI3C,MAAM,MAAM,wBAAwB,GAChC,KAAK,GACL,WAAW,GACX,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,oBAAoB,GACpB,YAAY,GACZ,WAAW,GACX,wBAAwB,GACxB,eAAe,GACf,kBAAkB,GAClB,qBAAqB,GACrB,qBAAqB,GACrB,cAAc,GACd,eAAe,CAAC;AAEpB,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,KAAK,EAAE,wBAAwB,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,SAAS,uCAAuC,EAAE,CAAC;IACzD,MAAM,EAAE,4BAA4B,EAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;CACrD,GAAG,qBAAqB,GAAG,SAAS,CAuBpC"}
@@ -1,6 +1,7 @@
1
1
  import { secretKeySchema, secretStoreSchema } from '@shipfox/api-secrets-dto';
2
2
  import { analyzeContextKeyAccess, analyzeContextRootKeyAccess, createWorkflowExpression, getWorkflowContextAvailability, getWorkflowContextDefinition, getWorkflowContextHost, getWorkflowContextTypeEnvironment, getWorkflowInterpolationFieldSelfReference, InvalidWorkflowExpressionError, InvalidWorkflowTemplateError, parseWorkflowTemplate, planInterpolationField, unavailableRootsAt, workflowContextNames, workflowInterpolationFieldAcceptsHost } from '@shipfox/expression';
3
3
  import { validateDirectJobReferences } from './validate-job-references.js';
4
+ import { issue } from './validation-issue.js';
4
5
  export function parseInterpolationField(params) {
5
6
  const segments = parseTemplate(params);
6
7
  if (segments === undefined) return undefined;
@@ -328,20 +329,5 @@ function formatList(values) {
328
329
  function fieldLabel(field) {
329
330
  return `Workflow ${field}`;
330
331
  }
331
- function issue(params) {
332
- if (params.details === undefined) {
333
- return {
334
- code: params.code,
335
- message: params.message,
336
- path: params.path
337
- };
338
- }
339
- return {
340
- code: params.code,
341
- message: params.message,
342
- path: params.path,
343
- details: params.details
344
- };
345
- }
346
332
 
347
333
  //# sourceMappingURL=parse-interpolation-field.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/workflow-model/parse-interpolation-field.ts"],"sourcesContent":["import {secretKeySchema, secretStoreSchema} from '@shipfox/api-secrets-dto';\nimport {\n type AvailabilitySite,\n analyzeContextKeyAccess,\n analyzeContextRootKeyAccess,\n createWorkflowExpression,\n type ExpressionTypeEnvironment,\n getWorkflowContextAvailability,\n getWorkflowContextDefinition,\n getWorkflowContextHost,\n getWorkflowContextTypeEnvironment,\n getWorkflowInterpolationFieldSelfReference,\n InvalidWorkflowExpressionError,\n InvalidWorkflowTemplateError,\n type PlanViolation,\n parseWorkflowTemplate,\n planInterpolationField,\n unavailableRootsAt,\n type WorkflowContextName,\n type WorkflowInterpolationField,\n type WorkflowTemplateExprSegment,\n type WorkflowTemplateSegment,\n workflowContextNames,\n workflowInterpolationFieldAcceptsHost,\n} from '@shipfox/expression';\nimport type {WorkflowFieldTemplate} from '../entities/workflow-model.js';\nimport type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\nimport {validateDirectJobReferences} from './validate-job-references.js';\n\nexport type StoredInterpolationField =\n | 'run'\n | 'env.value'\n | 'agent.prompt'\n | 'agent.model'\n | 'agent.provider'\n | 'agent.thinking'\n | 'job.outputs'\n | 'workflow.run_name'\n | 'job.execution_name'\n | 'job.runner'\n | 'step.name'\n | 'step.working_directory'\n | 'step.feedback'\n | 'checkout.project'\n | 'checkout.connection'\n | 'checkout.repository'\n | 'checkout.ref'\n | 'checkout.path';\n\nexport function parseInterpolationField(params: {\n field: StoredInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n issues: WorkflowModelValidationIssue[];\n fillSite?: AvailabilitySite;\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowFieldTemplate | undefined {\n const segments = parseTemplate(params);\n if (segments === undefined) return undefined;\n\n const expressionSegments = segments.filter(isExpressionSegment);\n if (expressionSegments.length === 0) return undefined;\n\n const checkedSegments = segments.map((segment) => {\n if (segment.kind === 'literal') return segment;\n\n const validatedSegment = validateExpressionSegment({...params, segment});\n return validatedSegment ?? segment;\n });\n\n const plan = planInterpolationField({field: params.field, segments: checkedSegments});\n if (!plan.ok) {\n params.issues.push(\n ...plan.violations.map((violation) => planViolationIssue(params, violation)),\n );\n return undefined;\n }\n\n return plan.plan.field.segments;\n}\n\nfunction dynamicNameSelfReference(params: {\n field: StoredInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n segment: WorkflowTemplateExprSegment;\n}): WorkflowModelValidationIssue | undefined {\n const target = getWorkflowInterpolationFieldSelfReference(params.field);\n if (target === undefined) return undefined;\n\n const access = analyzeContextRootKeyAccess(params.segment.expression, [target.root]);\n const reference = access.references.find((entry) => entry.key === target.key);\n const computedReference = access.violations.find(\n (violation) =>\n violation.root === target.root &&\n (violation.key === undefined || violation.key === target.key),\n );\n if (reference === undefined && computedReference === undefined) return undefined;\n\n return issue({\n code: 'dynamic-name-self-reference',\n message: `${fieldLabel(params.field)} interpolation cannot reference its own dynamic name.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n reference:\n reference === undefined ? `${target.root}[computed]` : `${reference.root}.${reference.key}`,\n },\n });\n}\n\nfunction parseTemplate(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n issues: WorkflowModelValidationIssue[];\n}): WorkflowTemplateSegment[] | undefined {\n try {\n return parseWorkflowTemplate(params.source);\n } catch (error) {\n params.issues.push(\n issue({\n code: 'invalid-interpolation-template',\n message: `${fieldLabel(params.field)} must use valid $${'{{ }}'} interpolation syntax.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n reason:\n error instanceof InvalidWorkflowTemplateError\n ? error.reason\n : 'Template source did not parse.',\n },\n }),\n );\n return undefined;\n }\n}\n\nfunction validateExpressionSegment(params: {\n field: StoredInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n issues: WorkflowModelValidationIssue[];\n segment: WorkflowTemplateExprSegment;\n fillSite?: AvailabilitySite;\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowTemplateExprSegment | undefined {\n const contextRoots = uniqueStrings(params.segment.contextRoots);\n const knownRoots = contextRoots.filter(isWorkflowContextName);\n const unknownRoots = contextRoots.filter((root) => !isWorkflowContextName(root));\n\n const rejectedHostRoots = knownRoots.filter(\n (root) => !workflowInterpolationFieldAcceptsHost(params.field, getWorkflowContextHost(root)),\n );\n if (rejectedHostRoots.length > 0) {\n params.issues.push(runnerContextInFieldIssue({...params, contextRoots, rejectedHostRoots}));\n return undefined;\n }\n\n const keyAccess = analyzeContextKeyAccess(params.segment.expression);\n if (keyAccess.violations.length > 0) {\n params.issues.push(\n ...keyAccess.violations.map((violation) =>\n computedContextKeyIssue({\n ...params,\n contextRoots,\n root: violation.root,\n expression: violation.source,\n }),\n ),\n );\n return undefined;\n }\n\n const selfReference = dynamicNameSelfReference(params);\n if (selfReference !== undefined) {\n params.issues.push(selfReference);\n return undefined;\n }\n\n const invalidReferenceIssue = validateContextKeyReferences({\n ...params,\n contextRoots,\n references: keyAccess.references,\n });\n if (invalidReferenceIssue !== undefined) {\n params.issues.push(invalidReferenceIssue);\n return undefined;\n }\n\n const invalidJobReferenceIssue =\n params.allowedJobReferences === undefined\n ? undefined\n : validateDirectJobReferences({\n source: params.source,\n expression: params.segment.expression,\n field: params.field,\n path: params.path,\n allowedJobReferences: params.allowedJobReferences,\n });\n if (invalidJobReferenceIssue !== undefined) {\n params.issues.push(invalidJobReferenceIssue);\n return undefined;\n }\n\n if (unknownRoots.length > 0) {\n params.issues.push(\n issue({\n code: 'unknown-interpolation-context',\n message: `${fieldLabel(params.field)} interpolation references unknown context ${formatList(\n unknownRoots,\n )}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n contextRoots,\n unknownRoots,\n },\n }),\n );\n return undefined;\n }\n\n const fillSite = params.fillSite;\n if (fillSite !== undefined) {\n const serverRoots = knownRoots.filter((root) => getWorkflowContextHost(root) === 'server');\n const unavailableRoots = unavailableRootsAt(serverRoots, fillSite);\n if (unavailableRoots.length > 0) {\n params.issues.push(\n unavailableContextIssue({...params, contextRoots, unavailableRoots, fillSite}),\n );\n return undefined;\n }\n }\n\n if (\n params.typeOverlay === undefined &&\n (knownRoots.length === 0 || knownRoots.some((root) => hasSyntaxOnlyCheckMode(root)))\n ) {\n return params.segment;\n }\n\n try {\n return {\n ...params.segment,\n expression: createWorkflowExpression({\n source: params.segment.expression.source,\n check: {\n mode: 'typed',\n // `undefined` preserves the legacy syntax-only path above. `{}` means\n // callers intentionally requested typed checking with the standard roots.\n typeEnvironment: mergeTypeEnvironments(knownRoots, params.typeOverlay),\n },\n }),\n };\n } catch (error) {\n params.issues.push(\n issue({\n code: 'invalid-interpolation-expression',\n message: `${fieldLabel(params.field)} interpolation expression did not type-check.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n contextRoots,\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not type-check.',\n },\n }),\n );\n return undefined;\n }\n}\n\nfunction runnerContextInFieldIssue(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n rejectedHostRoots: readonly WorkflowContextName[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'runner-context-in-field',\n message: `${fieldLabel(params.field)} interpolation cannot use runner context ${formatList(\n params.rejectedHostRoots,\n )}. Bind secrets to a run-step env value instead.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n rejectedRoots: params.rejectedHostRoots,\n },\n });\n}\n\nfunction computedContextKeyIssue(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n root: string;\n expression: string;\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'computed-context-key',\n message: `${fieldLabel(params.field)} interpolation must reference ${params.root} with a literal dot key.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.expression,\n contextRoots: params.contextRoots,\n root: params.root,\n },\n });\n}\n\nfunction validateContextKeyReferences(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n segment: WorkflowTemplateExprSegment;\n references: ReturnType<typeof analyzeContextKeyAccess>['references'];\n}): WorkflowModelValidationIssue | undefined {\n for (const reference of params.references) {\n if (!secretKeySchema.safeParse(reference.key).success) {\n return computedContextKeyIssue({\n ...params,\n root: reference.root,\n expression: params.segment.expression.source,\n });\n }\n\n if (reference.root !== 'secrets' || reference.store === undefined) continue;\n if (secretStoreSchema.safeParse(reference.store).success) continue;\n\n return issue({\n code: 'unknown-secret-store',\n message: `${fieldLabel(params.field)} interpolation references unknown secret store \"${reference.store}\".`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n contextRoots: params.contextRoots,\n store: reference.store,\n },\n });\n }\n\n return undefined;\n}\n\nconst availabilitySiteLabels = {\n ingest: 'ingest',\n 'run-creation': 'run creation',\n 'execution-creation': 'execution creation',\n 'job-activation': 'job activation',\n 'step-dispatch': 'step dispatch',\n 'step-report': 'step reporting',\n 'execution-resolution': 'execution resolution',\n 'job-resolution': 'job resolution',\n} as const satisfies Record<AvailabilitySite, string>;\n\nfunction unavailableContextIssue(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n segment: WorkflowTemplateExprSegment;\n contextRoots: readonly string[];\n unavailableRoots: readonly WorkflowContextName[];\n fillSite: AvailabilitySite;\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-fill-site',\n message: `${fieldLabel(params.field)} interpolation references ${contextNoun(\n params.unavailableRoots,\n )} ${formatList(params.unavailableRoots)} that ${availabilityVerb(\n params.unavailableRoots,\n )} not available at ${describeAvailabilitySite(params.fillSite)}. ${params.unavailableRoots\n .map(unavailableRootAvailabilityMessage)\n .join(' ')}`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n contextRoots: params.contextRoots,\n unavailableRoots: params.unavailableRoots,\n fillSite: params.fillSite,\n },\n });\n}\n\nfunction planViolationIssue(\n params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n },\n violation: PlanViolation,\n): WorkflowModelValidationIssue {\n if (violation.reason === 'computed-context-key') {\n return issue({\n code: 'computed-context-key',\n message: `${fieldLabel(params.field)} interpolation must reference ${formatList(\n violation.contextRoots ?? [],\n )} with a literal dot key.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: violation.source,\n contextRoots: violation.contextRoots,\n },\n });\n }\n\n return issue({\n code: 'runner-context-not-bare',\n message: `${fieldLabel(params.field)} interpolation references runner context in a larger expression; ${violation.hint}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: violation.source,\n runnerRoots: violation.runnerRoots ?? [],\n },\n });\n}\n\nfunction contextNoun(roots: readonly WorkflowContextName[]): 'context' | 'contexts' {\n return roots.length === 1 ? 'context' : 'contexts';\n}\n\nfunction availabilityVerb(roots: readonly WorkflowContextName[]): 'is' | 'are' {\n return roots.length === 1 ? 'is' : 'are';\n}\n\nfunction unavailableRootAvailabilityMessage(root: WorkflowContextName): string {\n const availability = getWorkflowContextAvailability(root);\n if (availability === undefined) return `\"${root}\" is not available at any server site.`;\n return `\"${root}\" becomes available at ${describeAvailabilitySite(availability)}.`;\n}\n\nfunction describeAvailabilitySite(site: AvailabilitySite): string {\n return availabilitySiteLabels[site];\n}\n\nfunction hasSyntaxOnlyCheckMode(root: WorkflowContextName): boolean {\n return getWorkflowContextDefinition(root).checkMode === 'syntax';\n}\n\nfunction mergeTypeEnvironments(\n roots: readonly WorkflowContextName[],\n typeOverlay?: ExpressionTypeEnvironment,\n): ExpressionTypeEnvironment {\n const typeEnvironment: Record<string, ExpressionTypeEnvironment[string]> = {};\n\n for (const root of roots) {\n const overlayType = typeOverlay?.[root];\n if (overlayType !== undefined) {\n typeEnvironment[root] = overlayType;\n continue;\n }\n\n const contextTypeEnvironment = getWorkflowContextTypeEnvironment(root);\n if (contextTypeEnvironment === undefined) {\n if (typeOverlay !== undefined) typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n Object.assign(typeEnvironment, contextTypeEnvironment);\n }\n\n return typeEnvironment;\n}\n\nfunction isExpressionSegment(\n segment: WorkflowTemplateSegment,\n): segment is WorkflowTemplateExprSegment {\n return segment.kind === 'expr';\n}\n\nfunction isWorkflowContextName(root: string): root is WorkflowContextName {\n return (workflowContextNames as readonly string[]).includes(root);\n}\n\nfunction uniqueStrings(values: readonly string[]): readonly string[] {\n return [...new Set(values)];\n}\n\nfunction formatList(values: readonly string[]): string {\n return values.map((value) => `\"${value}\"`).join(', ');\n}\n\nfunction fieldLabel(field: WorkflowInterpolationField): string {\n return `Workflow ${field}`;\n}\n\nfunction issue(params: {\n code: WorkflowModelValidationIssueCode;\n message: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n details?: Readonly<Record<string, unknown>>;\n}): WorkflowModelValidationIssue {\n if (params.details === undefined) {\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n };\n }\n\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n details: params.details,\n };\n}\n"],"names":["secretKeySchema","secretStoreSchema","analyzeContextKeyAccess","analyzeContextRootKeyAccess","createWorkflowExpression","getWorkflowContextAvailability","getWorkflowContextDefinition","getWorkflowContextHost","getWorkflowContextTypeEnvironment","getWorkflowInterpolationFieldSelfReference","InvalidWorkflowExpressionError","InvalidWorkflowTemplateError","parseWorkflowTemplate","planInterpolationField","unavailableRootsAt","workflowContextNames","workflowInterpolationFieldAcceptsHost","validateDirectJobReferences","parseInterpolationField","params","segments","parseTemplate","undefined","expressionSegments","filter","isExpressionSegment","length","checkedSegments","map","segment","kind","validatedSegment","validateExpressionSegment","plan","field","ok","issues","push","violations","violation","planViolationIssue","dynamicNameSelfReference","target","access","expression","root","reference","references","find","entry","key","computedReference","issue","code","message","fieldLabel","path","details","source","error","reason","contextRoots","uniqueStrings","knownRoots","isWorkflowContextName","unknownRoots","rejectedHostRoots","runnerContextInFieldIssue","keyAccess","computedContextKeyIssue","selfReference","invalidReferenceIssue","validateContextKeyReferences","invalidJobReferenceIssue","allowedJobReferences","formatList","fillSite","serverRoots","unavailableRoots","unavailableContextIssue","typeOverlay","some","hasSyntaxOnlyCheckMode","check","mode","typeEnvironment","mergeTypeEnvironments","rejectedRoots","safeParse","success","store","availabilitySiteLabels","ingest","contextNoun","availabilityVerb","describeAvailabilitySite","unavailableRootAvailabilityMessage","join","hint","runnerRoots","roots","availability","site","checkMode","overlayType","contextTypeEnvironment","Object","assign","includes","values","Set","value"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,iBAAiB,QAAO,2BAA2B;AAC5E,SAEEC,uBAAuB,EACvBC,2BAA2B,EAC3BC,wBAAwB,EAExBC,8BAA8B,EAC9BC,4BAA4B,EAC5BC,sBAAsB,EACtBC,iCA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;QAChC,OAAO;YACL+B,MAAMlC,OAAOkC,IAAI;YACjBC,SAASnC,OAAOmC,OAAO;YACvBE,MAAMrC,OAAOqC,IAAI;QACnB;IACF;IAEA,OAAO;QACLH,MAAMlC,OAAOkC,IAAI;QACjBC,SAASnC,OAAOmC,OAAO;QACvBE,MAAMrC,OAAOqC,IAAI;QACjBC,SAAStC,OAAOsC,OAAO;IACzB;AACF"}
1
+ {"version":3,"sources":["../../../src/core/workflow-model/parse-interpolation-field.ts"],"sourcesContent":["import {secretKeySchema, secretStoreSchema} from '@shipfox/api-secrets-dto';\nimport {\n type AvailabilitySite,\n analyzeContextKeyAccess,\n analyzeContextRootKeyAccess,\n createWorkflowExpression,\n type ExpressionTypeEnvironment,\n getWorkflowContextAvailability,\n getWorkflowContextDefinition,\n getWorkflowContextHost,\n getWorkflowContextTypeEnvironment,\n getWorkflowInterpolationFieldSelfReference,\n InvalidWorkflowExpressionError,\n InvalidWorkflowTemplateError,\n type PlanViolation,\n parseWorkflowTemplate,\n planInterpolationField,\n unavailableRootsAt,\n type WorkflowContextName,\n type WorkflowInterpolationField,\n type WorkflowTemplateExprSegment,\n type WorkflowTemplateSegment,\n workflowContextNames,\n workflowInterpolationFieldAcceptsHost,\n} from '@shipfox/expression';\nimport type {WorkflowFieldTemplate} from '../entities/workflow-model.js';\nimport type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\nimport {validateDirectJobReferences} from './validate-job-references.js';\nimport {issue} from './validation-issue.js';\n\nexport type StoredInterpolationField =\n | 'run'\n | 'env.value'\n | 'agent.prompt'\n | 'agent.model'\n | 'agent.provider'\n | 'agent.thinking'\n | 'job.outputs'\n | 'workflow.run_name'\n | 'job.execution_name'\n | 'job.runner'\n | 'step.name'\n | 'step.working_directory'\n | 'step.feedback'\n | 'checkout.project'\n | 'checkout.connection'\n | 'checkout.repository'\n | 'checkout.ref'\n | 'checkout.path';\n\nexport function parseInterpolationField(params: {\n field: StoredInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n issues: WorkflowModelValidationIssue[];\n fillSite?: AvailabilitySite;\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowFieldTemplate | undefined {\n const segments = parseTemplate(params);\n if (segments === undefined) return undefined;\n\n const expressionSegments = segments.filter(isExpressionSegment);\n if (expressionSegments.length === 0) return undefined;\n\n const checkedSegments = segments.map((segment) => {\n if (segment.kind === 'literal') return segment;\n\n const validatedSegment = validateExpressionSegment({...params, segment});\n return validatedSegment ?? segment;\n });\n\n const plan = planInterpolationField({field: params.field, segments: checkedSegments});\n if (!plan.ok) {\n params.issues.push(\n ...plan.violations.map((violation) => planViolationIssue(params, violation)),\n );\n return undefined;\n }\n\n return plan.plan.field.segments;\n}\n\nfunction dynamicNameSelfReference(params: {\n field: StoredInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n segment: WorkflowTemplateExprSegment;\n}): WorkflowModelValidationIssue | undefined {\n const target = getWorkflowInterpolationFieldSelfReference(params.field);\n if (target === undefined) return undefined;\n\n const access = analyzeContextRootKeyAccess(params.segment.expression, [target.root]);\n const reference = access.references.find((entry) => entry.key === target.key);\n const computedReference = access.violations.find(\n (violation) =>\n violation.root === target.root &&\n (violation.key === undefined || violation.key === target.key),\n );\n if (reference === undefined && computedReference === undefined) return undefined;\n\n return issue({\n code: 'dynamic-name-self-reference',\n message: `${fieldLabel(params.field)} interpolation cannot reference its own dynamic name.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n reference:\n reference === undefined ? `${target.root}[computed]` : `${reference.root}.${reference.key}`,\n },\n });\n}\n\nfunction parseTemplate(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n issues: WorkflowModelValidationIssue[];\n}): WorkflowTemplateSegment[] | undefined {\n try {\n return parseWorkflowTemplate(params.source);\n } catch (error) {\n params.issues.push(\n issue({\n code: 'invalid-interpolation-template',\n message: `${fieldLabel(params.field)} must use valid $${'{{ }}'} interpolation syntax.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n reason:\n error instanceof InvalidWorkflowTemplateError\n ? error.reason\n : 'Template source did not parse.',\n },\n }),\n );\n return undefined;\n }\n}\n\nfunction validateExpressionSegment(params: {\n field: StoredInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n issues: WorkflowModelValidationIssue[];\n segment: WorkflowTemplateExprSegment;\n fillSite?: AvailabilitySite;\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowTemplateExprSegment | undefined {\n const contextRoots = uniqueStrings(params.segment.contextRoots);\n const knownRoots = contextRoots.filter(isWorkflowContextName);\n const unknownRoots = contextRoots.filter((root) => !isWorkflowContextName(root));\n\n const rejectedHostRoots = knownRoots.filter(\n (root) => !workflowInterpolationFieldAcceptsHost(params.field, getWorkflowContextHost(root)),\n );\n if (rejectedHostRoots.length > 0) {\n params.issues.push(runnerContextInFieldIssue({...params, contextRoots, rejectedHostRoots}));\n return undefined;\n }\n\n const keyAccess = analyzeContextKeyAccess(params.segment.expression);\n if (keyAccess.violations.length > 0) {\n params.issues.push(\n ...keyAccess.violations.map((violation) =>\n computedContextKeyIssue({\n ...params,\n contextRoots,\n root: violation.root,\n expression: violation.source,\n }),\n ),\n );\n return undefined;\n }\n\n const selfReference = dynamicNameSelfReference(params);\n if (selfReference !== undefined) {\n params.issues.push(selfReference);\n return undefined;\n }\n\n const invalidReferenceIssue = validateContextKeyReferences({\n ...params,\n contextRoots,\n references: keyAccess.references,\n });\n if (invalidReferenceIssue !== undefined) {\n params.issues.push(invalidReferenceIssue);\n return undefined;\n }\n\n const invalidJobReferenceIssue =\n params.allowedJobReferences === undefined\n ? undefined\n : validateDirectJobReferences({\n source: params.source,\n expression: params.segment.expression,\n field: params.field,\n path: params.path,\n allowedJobReferences: params.allowedJobReferences,\n });\n if (invalidJobReferenceIssue !== undefined) {\n params.issues.push(invalidJobReferenceIssue);\n return undefined;\n }\n\n if (unknownRoots.length > 0) {\n params.issues.push(\n issue({\n code: 'unknown-interpolation-context',\n message: `${fieldLabel(params.field)} interpolation references unknown context ${formatList(\n unknownRoots,\n )}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n contextRoots,\n unknownRoots,\n },\n }),\n );\n return undefined;\n }\n\n const fillSite = params.fillSite;\n if (fillSite !== undefined) {\n const serverRoots = knownRoots.filter((root) => getWorkflowContextHost(root) === 'server');\n const unavailableRoots = unavailableRootsAt(serverRoots, fillSite);\n if (unavailableRoots.length > 0) {\n params.issues.push(\n unavailableContextIssue({...params, contextRoots, unavailableRoots, fillSite}),\n );\n return undefined;\n }\n }\n\n if (\n params.typeOverlay === undefined &&\n (knownRoots.length === 0 || knownRoots.some((root) => hasSyntaxOnlyCheckMode(root)))\n ) {\n return params.segment;\n }\n\n try {\n return {\n ...params.segment,\n expression: createWorkflowExpression({\n source: params.segment.expression.source,\n check: {\n mode: 'typed',\n // `undefined` preserves the legacy syntax-only path above. `{}` means\n // callers intentionally requested typed checking with the standard roots.\n typeEnvironment: mergeTypeEnvironments(knownRoots, params.typeOverlay),\n },\n }),\n };\n } catch (error) {\n params.issues.push(\n issue({\n code: 'invalid-interpolation-expression',\n message: `${fieldLabel(params.field)} interpolation expression did not type-check.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n contextRoots,\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not type-check.',\n },\n }),\n );\n return undefined;\n }\n}\n\nfunction runnerContextInFieldIssue(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n rejectedHostRoots: readonly WorkflowContextName[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'runner-context-in-field',\n message: `${fieldLabel(params.field)} interpolation cannot use runner context ${formatList(\n params.rejectedHostRoots,\n )}. Bind secrets to a run-step env value instead.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n rejectedRoots: params.rejectedHostRoots,\n },\n });\n}\n\nfunction computedContextKeyIssue(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n root: string;\n expression: string;\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'computed-context-key',\n message: `${fieldLabel(params.field)} interpolation must reference ${params.root} with a literal dot key.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.expression,\n contextRoots: params.contextRoots,\n root: params.root,\n },\n });\n}\n\nfunction validateContextKeyReferences(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n segment: WorkflowTemplateExprSegment;\n references: ReturnType<typeof analyzeContextKeyAccess>['references'];\n}): WorkflowModelValidationIssue | undefined {\n for (const reference of params.references) {\n if (!secretKeySchema.safeParse(reference.key).success) {\n return computedContextKeyIssue({\n ...params,\n root: reference.root,\n expression: params.segment.expression.source,\n });\n }\n\n if (reference.root !== 'secrets' || reference.store === undefined) continue;\n if (secretStoreSchema.safeParse(reference.store).success) continue;\n\n return issue({\n code: 'unknown-secret-store',\n message: `${fieldLabel(params.field)} interpolation references unknown secret store \"${reference.store}\".`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n contextRoots: params.contextRoots,\n store: reference.store,\n },\n });\n }\n\n return undefined;\n}\n\nconst availabilitySiteLabels = {\n ingest: 'ingest',\n 'run-creation': 'run creation',\n 'execution-creation': 'execution creation',\n 'job-activation': 'job activation',\n 'step-dispatch': 'step dispatch',\n 'step-report': 'step reporting',\n 'execution-resolution': 'execution resolution',\n 'job-resolution': 'job resolution',\n} as const satisfies Record<AvailabilitySite, string>;\n\nfunction unavailableContextIssue(params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n segment: WorkflowTemplateExprSegment;\n contextRoots: readonly string[];\n unavailableRoots: readonly WorkflowContextName[];\n fillSite: AvailabilitySite;\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-fill-site',\n message: `${fieldLabel(params.field)} interpolation references ${contextNoun(\n params.unavailableRoots,\n )} ${formatList(params.unavailableRoots)} that ${availabilityVerb(\n params.unavailableRoots,\n )} not available at ${describeAvailabilitySite(params.fillSite)}. ${params.unavailableRoots\n .map(unavailableRootAvailabilityMessage)\n .join(' ')}`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: params.segment.expression.source,\n contextRoots: params.contextRoots,\n unavailableRoots: params.unavailableRoots,\n fillSite: params.fillSite,\n },\n });\n}\n\nfunction planViolationIssue(\n params: {\n field: WorkflowInterpolationField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n },\n violation: PlanViolation,\n): WorkflowModelValidationIssue {\n if (violation.reason === 'computed-context-key') {\n return issue({\n code: 'computed-context-key',\n message: `${fieldLabel(params.field)} interpolation must reference ${formatList(\n violation.contextRoots ?? [],\n )} with a literal dot key.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: violation.source,\n contextRoots: violation.contextRoots,\n },\n });\n }\n\n return issue({\n code: 'runner-context-not-bare',\n message: `${fieldLabel(params.field)} interpolation references runner context in a larger expression; ${violation.hint}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n expression: violation.source,\n runnerRoots: violation.runnerRoots ?? [],\n },\n });\n}\n\nfunction contextNoun(roots: readonly WorkflowContextName[]): 'context' | 'contexts' {\n return roots.length === 1 ? 'context' : 'contexts';\n}\n\nfunction availabilityVerb(roots: readonly WorkflowContextName[]): 'is' | 'are' {\n return roots.length === 1 ? 'is' : 'are';\n}\n\nfunction unavailableRootAvailabilityMessage(root: WorkflowContextName): string {\n const availability = getWorkflowContextAvailability(root);\n if (availability === undefined) return `\"${root}\" is not available at any server site.`;\n return `\"${root}\" becomes available at ${describeAvailabilitySite(availability)}.`;\n}\n\nfunction describeAvailabilitySite(site: AvailabilitySite): string {\n return availabilitySiteLabels[site];\n}\n\nfunction hasSyntaxOnlyCheckMode(root: WorkflowContextName): boolean {\n return getWorkflowContextDefinition(root).checkMode === 'syntax';\n}\n\nfunction mergeTypeEnvironments(\n roots: readonly WorkflowContextName[],\n typeOverlay?: ExpressionTypeEnvironment,\n): ExpressionTypeEnvironment {\n const typeEnvironment: Record<string, ExpressionTypeEnvironment[string]> = {};\n\n for (const root of roots) {\n const overlayType = typeOverlay?.[root];\n if (overlayType !== undefined) {\n typeEnvironment[root] = overlayType;\n continue;\n }\n\n const contextTypeEnvironment = getWorkflowContextTypeEnvironment(root);\n if (contextTypeEnvironment === undefined) {\n if (typeOverlay !== undefined) typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n Object.assign(typeEnvironment, contextTypeEnvironment);\n }\n\n return typeEnvironment;\n}\n\nfunction isExpressionSegment(\n segment: WorkflowTemplateSegment,\n): segment is WorkflowTemplateExprSegment {\n return segment.kind === 'expr';\n}\n\nfunction isWorkflowContextName(root: string): root is WorkflowContextName {\n return (workflowContextNames as readonly string[]).includes(root);\n}\n\nfunction uniqueStrings(values: readonly string[]): readonly string[] {\n return [...new Set(values)];\n}\n\nfunction formatList(values: readonly string[]): string {\n return values.map((value) => `\"${value}\"`).join(', ');\n}\n\nfunction fieldLabel(field: WorkflowInterpolationField): string {\n return `Workflow ${field}`;\n}\n"],"names":["secretKeySchema","secretStoreSchema","analyzeContextKeyAccess","analyzeContextRootKeyAccess","createWorkflowExpression","getWorkflowContextAvailability","getWorkflowContextDefinition","getWorkflowContextHost","getWorkflowContextTypeEnvironment","getWorkflowInterpolationFieldSelfReference","InvalidWorkflowExpressionError","InvalidWorkflowTemplateError","parseWorkflowTemplate","planInterpolationField","unavailableRootsAt","workflowContextNames","workflowInterpolationFieldAcceptsHost","validateDirectJobReferences","issue","parseInterpolationField","params","segments","parseTemplate","undefined","expressionSegments","filter","isExpressionSegment","length","checkedSegments","map","segment","kind","validatedSegment","validateExpressionSegment","plan","field","ok","issues","push","violations","violation","planViolationIssue","dynamicNameSelfReference","target","access","expression","root","reference","references","find","entry","key","computedReference","code","message","fieldLabel","path","details","source","error","reason","contextRoots","uniqueStrings","knownRoots","isWorkflowContextName","unknownRoots","rejectedHostRoots","runnerContextInFieldIssue","keyAccess","computedContextKeyIssue","selfReference","invalidReferenceIssue","validateContextKeyReferences","invalidJobReferenceIssue","allowedJobReferences","formatList","fillSite","serverRoots","unavailableRoots","unavailableContextIssue","typeOverlay","some","hasSyntaxOnlyCheckMode","check","mode","typeEnvironment","mergeTypeEnvironments","rejectedRoots","safeParse","success","store","availabilitySiteLabels","ingest","contextNoun","availabilityVerb","describeAvailabilitySite","unavailableRootAvailabilityMessage","join","hint","runnerRoots","roots","availability","site","checkMode","overlayType","contextTypeEnvironment","Object","assign","includes","values","Set","value"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,iBAAiB,QAAO,2BAA2B;AAC5E,SAEEC,uBAAuB,EACvBC,2BAA2B,EAC3BC,wBAAwB,EAExBC,8BAA8B,EAC9BC,4BAA4B,EAC5BC,sBAAsB,EACtBC,iCAAiC,EACjCC,0CAA0C,EAC1CC,8BAA8B,EAC9BC,4BAA4B,EAE5BC,qBAAqB,EACrBC,sBAAsB,EACtBC,kBAAkB,EAKlBC,oBAAoB,EACpBC,qCAAqC,QAChC,sBAAsB;AAM7B,SAAQC,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,KAAK,QAAO,wBAAwB;AAsB5C,OAAO,SAASC,wBAAwBC,MAQvC;IACC,MAAMC,WAAWC,cAAcF;IAC/B,IAAIC,aAAaE,WAAW,OAAOA;IAEnC,MAAMC,qBAAqBH,SAASI,MAAM,CAACC;IAC3C,IAAIF,mBAAmBG,MAAM,KAAK,GAAG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,QAAQsD,MAAO;QACxB,MAAMI,cAAcxB,aAAa,CAAClC,KAAK;QACvC,IAAI0D,gBAAgBjF,WAAW;YAC7B8D,eAAe,CAACvC,KAAK,GAAG0D;YACxB;QACF;QAEA,MAAMC,yBAAyBjG,kCAAkCsC;QACjE,IAAI2D,2BAA2BlF,WAAW;YACxC,IAAIyD,gBAAgBzD,WAAW8D,eAAe,CAACvC,KAAK,GAAG;gBAACf,MAAM;YAAK;YACnE;QACF;QAEA2E,OAAOC,MAAM,CAACtB,iBAAiBoB;IACjC;IAEA,OAAOpB;AACT;AAEA,SAAS3D,oBACPI,OAAgC;IAEhC,OAAOA,QAAQC,IAAI,KAAK;AAC1B;AAEA,SAASiC,sBAAsBlB,IAAY;IACzC,OAAO,AAAC/B,qBAA2C6F,QAAQ,CAAC9D;AAC9D;AAEA,SAASgB,cAAc+C,MAAyB;IAC9C,OAAO;WAAI,IAAIC,IAAID;KAAQ;AAC7B;AAEA,SAASlC,WAAWkC,MAAyB;IAC3C,OAAOA,OAAOhF,GAAG,CAAC,CAACkF,QAAU,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,EAAEd,IAAI,CAAC;AAClD;AAEA,SAAS1C,WAAWpB,KAAiC;IACnD,OAAO,CAAC,SAAS,EAAEA,OAAO;AAC5B"}
@@ -1,5 +1,5 @@
1
1
  import { type ExpressionTypeEnvironment, type WorkflowExpression, type WorkflowPredicateField } from '@shipfox/expression';
2
- import type { WorkflowModelValidationIssue, WorkflowModelValidationIssueCode, WorkflowModelValidationIssuePathSegment } from './invalid-workflow-model-error.js';
2
+ import type { WorkflowModelValidationIssue, WorkflowModelValidationIssueCode, WorkflowModelValidationIssuePathSegment, WorkflowModelValidationIssueScope } from './invalid-workflow-model-error.js';
3
3
  export declare function validatePredicateExpression(params: {
4
4
  field: WorkflowPredicateField;
5
5
  source: string;
@@ -9,5 +9,7 @@ export declare function validatePredicateExpression(params: {
9
9
  issues: WorkflowModelValidationIssue[];
10
10
  allowedJobReferences?: ReadonlySet<string>;
11
11
  typeOverlay?: ExpressionTypeEnvironment | undefined;
12
+ /** Scope for the invalidCode issue; other issues keep the definition scope. */
13
+ scope?: WorkflowModelValidationIssueScope | undefined;
12
14
  }): WorkflowExpression | undefined;
13
15
  //# sourceMappingURL=validate-predicate-expression.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-predicate-expression.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/validate-predicate-expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,yBAAyB,EAW9B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAE5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACxC,MAAM,mCAAmC,CAAC;AAK3C,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,KAAK,EAAE,sBAAsB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,SAAS,uCAAuC,EAAE,CAAC;IACzD,WAAW,EAAE,gCAAgC,CAAC;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,4BAA4B,EAAE,CAAC;IACvC,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;CACrD,GAAG,kBAAkB,GAAG,SAAS,CA0GjC"}
1
+ {"version":3,"file":"validate-predicate-expression.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/validate-predicate-expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,yBAAyB,EAW9B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAE5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACvC,iCAAiC,EAClC,MAAM,mCAAmC,CAAC;AAK3C,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,KAAK,EAAE,sBAAsB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,SAAS,uCAAuC,EAAE,CAAC;IACzD,WAAW,EAAE,gCAAgC,CAAC;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,4BAA4B,EAAE,CAAC;IACvC,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;IACpD,+EAA+E;IAC/E,KAAK,CAAC,EAAE,iCAAiC,GAAG,SAAS,CAAC;CACvD,GAAG,kBAAkB,GAAG,SAAS,CA0GjC"}
@@ -106,6 +106,9 @@ function invalidPredicateIssue(params) {
106
106
  source: params.source,
107
107
  contextRoots: params.contextRoots,
108
108
  reason: params.reason ?? 'Expression source did not parse or type-check.'
109
+ },
110
+ ...params.scope === undefined ? {} : {
111
+ scope: params.scope
109
112
  }
110
113
  });
111
114
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/workflow-model/validate-predicate-expression.ts"],"sourcesContent":["import {\n type AvailabilitySite,\n createWorkflowExpression,\n type ExpressionType,\n type ExpressionTypeEnvironment,\n extractExactContextRoots,\n getWorkflowContextDefinition,\n getWorkflowPredicateContextRoots,\n getWorkflowPredicateFieldMinimumFillTarget,\n getWorkflowPredicateFieldTypeEnvironment,\n InvalidWorkflowExpressionError,\n predicateSourceIsBooleanShaped,\n resolveContextRootHost,\n validateServerEvaluable,\n type WorkflowContextName,\n type WorkflowExpression,\n type WorkflowPredicateField,\n workflowContextNames,\n} from '@shipfox/expression';\nimport type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n} from './invalid-workflow-model-error.js';\nimport {validateDirectJobReferences} from './validate-job-references.js';\nimport {issue} from './validation-issue.js';\nimport {workflowFieldLabel} from './workflow-field-label.js';\n\nexport function validatePredicateExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n}): WorkflowExpression | undefined {\n const site = getWorkflowPredicateFieldMinimumFillTarget(params.field);\n const syntaxExpression = createSyntaxExpression(params);\n if (syntaxExpression === undefined) return undefined;\n\n const contextRoots = extractExactContextRoots(syntaxExpression.source);\n const knownRoots = contextRoots.filter((root) => resolveContextRootHost(root) !== undefined);\n const unknownRoots = contextRoots.filter((root) => resolveContextRootHost(root) === undefined);\n\n if (unknownRoots.length > 0) {\n params.issues.push(invalidPredicateIssue({...params, contextRoots}));\n return undefined;\n }\n\n const serverEvaluability = validateServerEvaluable(syntaxExpression);\n if (!serverEvaluability.ok) {\n params.issues.push(\n ...serverEvaluability.violations.map((violation) =>\n runnerContextInServerPredicateIssue({\n ...params,\n site,\n contextRoots,\n runnerRoots: violation.runnerRoots,\n }),\n ),\n );\n return undefined;\n }\n\n const predicateContextRoots = getWorkflowPredicateContextRoots(params.field);\n const unavailableRoots = knownRoots.filter(\n (root) => !predicateContextRoots.includes(root as (typeof predicateContextRoots)[number]),\n );\n if (unavailableRoots.length > 0) {\n params.issues.push(\n unavailablePredicateContextIssue({\n ...params,\n site,\n contextRoots,\n unavailableRoots,\n }),\n );\n return undefined;\n }\n\n const invalidJobReferenceIssue =\n params.allowedJobReferences === undefined\n ? undefined\n : validateDirectJobReferences({\n source: params.source,\n expression: syntaxExpression,\n field: params.field,\n path: params.path,\n allowedJobReferences: params.allowedJobReferences,\n });\n if (invalidJobReferenceIssue !== undefined) {\n params.issues.push(invalidJobReferenceIssue);\n return undefined;\n }\n\n if (\n params.typeOverlay === undefined &&\n knownRoots.length > 0 &&\n knownRoots.every((root) => hasSyntaxOnlyCheckMode(root))\n ) {\n if (\n isWorkflowFilterPredicateField(params.field) &&\n !predicateSourceIsBooleanShaped(syntaxExpression.source)\n ) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason: 'Predicate source must be boolean-shaped.',\n }),\n );\n return undefined;\n }\n\n return syntaxExpression;\n }\n\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {\n mode: 'typed',\n // `undefined` preserves the legacy syntax-only path above. `{}` means\n // callers intentionally requested typed checking with the standard roots.\n typeEnvironment: mergeTypeEnvironments(params.field, knownRoots, params.typeOverlay),\n expectedResultType: 'bool',\n },\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction createSyntaxExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n}): WorkflowExpression | undefined {\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {mode: 'syntax'},\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots: [],\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction invalidPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n contextRoots: readonly string[];\n reason?: string;\n}): WorkflowModelValidationIssue {\n return issue({\n code: params.invalidCode,\n message: params.invalidMessage,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n reason: params.reason ?? 'Expression source did not parse or type-check.',\n },\n });\n}\n\nconst availabilitySiteLabels = {\n ingest: 'ingest',\n 'run-creation': 'run creation',\n 'execution-creation': 'execution creation',\n 'job-activation': 'job activation',\n 'step-dispatch': 'step dispatch',\n 'step-report': 'step reporting',\n 'execution-resolution': 'execution resolution',\n 'job-resolution': 'job resolution',\n} as const satisfies Record<AvailabilitySite, string>;\n\nfunction runnerContextInServerPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n runnerRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'runner-context-in-server-predicate',\n message: `${fieldLabel(params.field)} cannot reference runner context ${formatList(\n params.runnerRoots,\n )} because it is evaluated on the server at ${describeAvailabilitySite(params.site)}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n runnerRoots: params.runnerRoots,\n site: params.site,\n },\n });\n}\n\nfunction unavailablePredicateContextIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n unavailableRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-predicate-site',\n message: `${fieldLabel(params.field)} references ${contextNoun(\n params.unavailableRoots,\n )} ${formatList(params.unavailableRoots)} that ${availabilityVerb(\n params.unavailableRoots,\n )} not supplied when ${fieldLabel(params.field)} is evaluated at ${describeAvailabilitySite(\n params.site,\n )}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n unavailableRoots: params.unavailableRoots,\n site: params.site,\n },\n });\n}\n\nfunction hasSyntaxOnlyCheckMode(root: string): boolean {\n if (!isWorkflowContextName(root)) return resolveContextRootHost(root) === 'server';\n return isWorkflowContextName(root) && getWorkflowContextDefinition(root).checkMode === 'syntax';\n}\n\nfunction mergeTypeEnvironments(\n field: WorkflowPredicateField,\n roots: readonly string[],\n typeOverlay?: ExpressionTypeEnvironment,\n): ExpressionTypeEnvironment {\n const typeEnvironment: Record<string, ExpressionTypeEnvironment[string]> = {};\n\n for (const root of roots) {\n const overlayType = typeOverlay?.[root];\n if (!isWorkflowContextName(root)) {\n if (overlayType !== undefined) typeEnvironment[root] = overlayType;\n else typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n const contextTypeEnvironment = getWorkflowPredicateFieldTypeEnvironment(field, root);\n if (contextTypeEnvironment === undefined) {\n if (overlayType !== undefined) typeEnvironment[root] = overlayType;\n else typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n const contextType = contextTypeEnvironment[root];\n if (contextType === undefined) continue;\n typeEnvironment[root] =\n overlayType === undefined ? contextType : overlayKnownFields(contextType, overlayType);\n }\n\n return typeEnvironment;\n}\n\nfunction overlayKnownFields(base: ExpressionType, overlay: ExpressionType): ExpressionType {\n if (typeof base === 'string' || typeof overlay === 'string') return overlay;\n if (base.kind !== 'object' || overlay.kind !== 'object') return overlay;\n\n // Preserve output specialization without reintroducing properties absent from this field's\n // runtime shape.\n return {\n kind: 'object',\n fields: Object.fromEntries(\n Object.entries(base.fields).map(([key, fieldType]) => [\n key,\n overlay.fields[key] ?? fieldType,\n ]),\n ),\n };\n}\n\nfunction isWorkflowContextName(root: string): root is WorkflowContextName {\n return (workflowContextNames as readonly string[]).includes(root);\n}\n\nfunction isWorkflowFilterPredicateField(field: WorkflowPredicateField): boolean {\n return field === 'trigger.filter' || field === 'listener.on' || field === 'listener.until';\n}\n\nfunction fieldLabel(field: WorkflowPredicateField): string {\n return workflowFieldLabel(field);\n}\n\nfunction contextNoun(roots: readonly string[]): 'context' | 'contexts' {\n return roots.length === 1 ? 'context' : 'contexts';\n}\n\nfunction availabilityVerb(roots: readonly string[]): 'is' | 'are' {\n return roots.length === 1 ? 'is' : 'are';\n}\n\nfunction describeAvailabilitySite(site: AvailabilitySite): string {\n return availabilitySiteLabels[site];\n}\n\nfunction formatList(values: readonly string[]): string {\n return values.map((value) => `\"${value}\"`).join(', ');\n}\n"],"names":["createWorkflowExpression","extractExactContextRoots","getWorkflowContextDefinition","getWorkflowPredicateContextRoots","getWorkflowPredicateFieldMinimumFillTarget","getWorkflowPredicateFieldTypeEnvironment","InvalidWorkflowExpressionError","predicateSourceIsBooleanShaped","resolveContextRootHost","validateServerEvaluable","workflowContextNames","validateDirectJobReferences","issue","workflowFieldLabel","validatePredicateExpression","params","site","field","syntaxExpression","createSyntaxExpression","undefined","contextRoots","source","knownRoots","filter","root","unknownRoots","length","issues","push","invalidPredicateIssue","serverEvaluability","ok","violations","map","violation","runnerContextInServerPredicateIssue","runnerRoots","predicateContextRoots","unavailableRoots","includes","unavailablePredicateContextIssue","invalidJobReferenceIssue","allowedJobReferences","expression","path","typeOverlay","every","hasSyntaxOnlyCheckMode","isWorkflowFilterPredicateField","reason","check","mode","typeEnvironment","mergeTypeEnvironments","expectedResultType","error","code","invalidCode","message","invalidMessage","details","availabilitySiteLabels","ingest","fieldLabel","formatList","describeAvailabilitySite","contextNoun","availabilityVerb","isWorkflowContextName","checkMode","roots","overlayType","kind","contextTypeEnvironment","contextType","overlayKnownFields","base","overlay","fields","Object","fromEntries","entries","key","fieldType","values","value","join"],"mappings":"AAAA,SAEEA,wBAAwB,EAGxBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,gCAAgC,EAChCC,0CAA0C,EAC1CC,wCAAwC,EACxCC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,sBAAsB,EACtBC,uBAAuB,EAIvBC,oBAAoB,QACf,sBAAsB;AAM7B,SAAQC,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,KAAK,QAAO,wBAAwB;AAC5C,SAAQC,kBAAkB,QAAO,4BAA4B;AAE7D,OAAO,SAASC,4BAA4BC,MAS3C;IACC,MAAMC,OAAOZ,2CAA2CW,OAAOE,KAAK;IACpE,MAAMC,mBAAmBC,uBAAuBJ;IAChD,IAAIG,qBAAqBE,WAAW,OAAOA;IAE3C,MAAMC,eAAepB,yBAAyBiB,iBAAiBI,MAAM;IACrE,MAAMC,aAAaF,aAAaG,MAAM,CAAC,CA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,CAACf;AAC9D;AAEA,SAASwB,+BAA+BhC,KAA6B;IACnE,OAAOA,UAAU,oBAAoBA,UAAU,iBAAiBA,UAAU;AAC5E;AAEA,SAAS+C,WAAW/C,KAA6B;IAC/C,OAAOJ,mBAAmBI;AAC5B;AAEA,SAASkD,YAAYI,KAAwB;IAC3C,OAAOA,MAAM5C,MAAM,KAAK,IAAI,YAAY;AAC1C;AAEA,SAASyC,iBAAiBG,KAAwB;IAChD,OAAOA,MAAM5C,MAAM,KAAK,IAAI,OAAO;AACrC;AAEA,SAASuC,yBAAyBlD,IAAsB;IACtD,OAAO8C,sBAAsB,CAAC9C,KAAK;AACrC;AAEA,SAASiD,WAAWoB,MAAyB;IAC3C,OAAOA,OAAOnD,GAAG,CAAC,CAACoD,QAAU,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,EAAEC,IAAI,CAAC;AAClD"}
1
+ {"version":3,"sources":["../../../src/core/workflow-model/validate-predicate-expression.ts"],"sourcesContent":["import {\n type AvailabilitySite,\n createWorkflowExpression,\n type ExpressionType,\n type ExpressionTypeEnvironment,\n extractExactContextRoots,\n getWorkflowContextDefinition,\n getWorkflowPredicateContextRoots,\n getWorkflowPredicateFieldMinimumFillTarget,\n getWorkflowPredicateFieldTypeEnvironment,\n InvalidWorkflowExpressionError,\n predicateSourceIsBooleanShaped,\n resolveContextRootHost,\n validateServerEvaluable,\n type WorkflowContextName,\n type WorkflowExpression,\n type WorkflowPredicateField,\n workflowContextNames,\n} from '@shipfox/expression';\nimport type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n WorkflowModelValidationIssueScope,\n} from './invalid-workflow-model-error.js';\nimport {validateDirectJobReferences} from './validate-job-references.js';\nimport {issue} from './validation-issue.js';\nimport {workflowFieldLabel} from './workflow-field-label.js';\n\nexport function validatePredicateExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n allowedJobReferences?: ReadonlySet<string>;\n typeOverlay?: ExpressionTypeEnvironment | undefined;\n /** Scope for the invalidCode issue; other issues keep the definition scope. */\n scope?: WorkflowModelValidationIssueScope | undefined;\n}): WorkflowExpression | undefined {\n const site = getWorkflowPredicateFieldMinimumFillTarget(params.field);\n const syntaxExpression = createSyntaxExpression(params);\n if (syntaxExpression === undefined) return undefined;\n\n const contextRoots = extractExactContextRoots(syntaxExpression.source);\n const knownRoots = contextRoots.filter((root) => resolveContextRootHost(root) !== undefined);\n const unknownRoots = contextRoots.filter((root) => resolveContextRootHost(root) === undefined);\n\n if (unknownRoots.length > 0) {\n params.issues.push(invalidPredicateIssue({...params, contextRoots}));\n return undefined;\n }\n\n const serverEvaluability = validateServerEvaluable(syntaxExpression);\n if (!serverEvaluability.ok) {\n params.issues.push(\n ...serverEvaluability.violations.map((violation) =>\n runnerContextInServerPredicateIssue({\n ...params,\n site,\n contextRoots,\n runnerRoots: violation.runnerRoots,\n }),\n ),\n );\n return undefined;\n }\n\n const predicateContextRoots = getWorkflowPredicateContextRoots(params.field);\n const unavailableRoots = knownRoots.filter(\n (root) => !predicateContextRoots.includes(root as (typeof predicateContextRoots)[number]),\n );\n if (unavailableRoots.length > 0) {\n params.issues.push(\n unavailablePredicateContextIssue({\n ...params,\n site,\n contextRoots,\n unavailableRoots,\n }),\n );\n return undefined;\n }\n\n const invalidJobReferenceIssue =\n params.allowedJobReferences === undefined\n ? undefined\n : validateDirectJobReferences({\n source: params.source,\n expression: syntaxExpression,\n field: params.field,\n path: params.path,\n allowedJobReferences: params.allowedJobReferences,\n });\n if (invalidJobReferenceIssue !== undefined) {\n params.issues.push(invalidJobReferenceIssue);\n return undefined;\n }\n\n if (\n params.typeOverlay === undefined &&\n knownRoots.length > 0 &&\n knownRoots.every((root) => hasSyntaxOnlyCheckMode(root))\n ) {\n if (\n isWorkflowFilterPredicateField(params.field) &&\n !predicateSourceIsBooleanShaped(syntaxExpression.source)\n ) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason: 'Predicate source must be boolean-shaped.',\n }),\n );\n return undefined;\n }\n\n return syntaxExpression;\n }\n\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {\n mode: 'typed',\n // `undefined` preserves the legacy syntax-only path above. `{}` means\n // callers intentionally requested typed checking with the standard roots.\n typeEnvironment: mergeTypeEnvironments(params.field, knownRoots, params.typeOverlay),\n expectedResultType: 'bool',\n },\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots,\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction createSyntaxExpression(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n issues: WorkflowModelValidationIssue[];\n scope?: WorkflowModelValidationIssueScope | undefined;\n}): WorkflowExpression | undefined {\n try {\n return createWorkflowExpression({\n source: params.source,\n check: {mode: 'syntax'},\n });\n } catch (error) {\n params.issues.push(\n invalidPredicateIssue({\n ...params,\n contextRoots: [],\n reason:\n error instanceof InvalidWorkflowExpressionError\n ? error.reason\n : 'Expression source did not parse or type-check.',\n }),\n );\n return undefined;\n }\n}\n\nfunction invalidPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n invalidCode: WorkflowModelValidationIssueCode;\n invalidMessage: string;\n contextRoots: readonly string[];\n reason?: string;\n scope?: WorkflowModelValidationIssueScope | undefined;\n}): WorkflowModelValidationIssue {\n return issue({\n code: params.invalidCode,\n message: params.invalidMessage,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n reason: params.reason ?? 'Expression source did not parse or type-check.',\n },\n ...(params.scope === undefined ? {} : {scope: params.scope}),\n });\n}\n\nconst availabilitySiteLabels = {\n ingest: 'ingest',\n 'run-creation': 'run creation',\n 'execution-creation': 'execution creation',\n 'job-activation': 'job activation',\n 'step-dispatch': 'step dispatch',\n 'step-report': 'step reporting',\n 'execution-resolution': 'execution resolution',\n 'job-resolution': 'job resolution',\n} as const satisfies Record<AvailabilitySite, string>;\n\nfunction runnerContextInServerPredicateIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n runnerRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'runner-context-in-server-predicate',\n message: `${fieldLabel(params.field)} cannot reference runner context ${formatList(\n params.runnerRoots,\n )} because it is evaluated on the server at ${describeAvailabilitySite(params.site)}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n runnerRoots: params.runnerRoots,\n site: params.site,\n },\n });\n}\n\nfunction unavailablePredicateContextIssue(params: {\n field: WorkflowPredicateField;\n source: string;\n site: AvailabilitySite;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n contextRoots: readonly string[];\n unavailableRoots: readonly string[];\n}): WorkflowModelValidationIssue {\n return issue({\n code: 'context-unavailable-at-predicate-site',\n message: `${fieldLabel(params.field)} references ${contextNoun(\n params.unavailableRoots,\n )} ${formatList(params.unavailableRoots)} that ${availabilityVerb(\n params.unavailableRoots,\n )} not supplied when ${fieldLabel(params.field)} is evaluated at ${describeAvailabilitySite(\n params.site,\n )}.`,\n path: params.path,\n details: {\n field: params.field,\n source: params.source,\n contextRoots: params.contextRoots,\n unavailableRoots: params.unavailableRoots,\n site: params.site,\n },\n });\n}\n\nfunction hasSyntaxOnlyCheckMode(root: string): boolean {\n if (!isWorkflowContextName(root)) return resolveContextRootHost(root) === 'server';\n return isWorkflowContextName(root) && getWorkflowContextDefinition(root).checkMode === 'syntax';\n}\n\nfunction mergeTypeEnvironments(\n field: WorkflowPredicateField,\n roots: readonly string[],\n typeOverlay?: ExpressionTypeEnvironment,\n): ExpressionTypeEnvironment {\n const typeEnvironment: Record<string, ExpressionTypeEnvironment[string]> = {};\n\n for (const root of roots) {\n const overlayType = typeOverlay?.[root];\n if (!isWorkflowContextName(root)) {\n if (overlayType !== undefined) typeEnvironment[root] = overlayType;\n else typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n const contextTypeEnvironment = getWorkflowPredicateFieldTypeEnvironment(field, root);\n if (contextTypeEnvironment === undefined) {\n if (overlayType !== undefined) typeEnvironment[root] = overlayType;\n else typeEnvironment[root] = {kind: 'map'};\n continue;\n }\n\n const contextType = contextTypeEnvironment[root];\n if (contextType === undefined) continue;\n typeEnvironment[root] =\n overlayType === undefined ? contextType : overlayKnownFields(contextType, overlayType);\n }\n\n return typeEnvironment;\n}\n\nfunction overlayKnownFields(base: ExpressionType, overlay: ExpressionType): ExpressionType {\n if (typeof base === 'string' || typeof overlay === 'string') return overlay;\n if (base.kind !== 'object' || overlay.kind !== 'object') return overlay;\n\n // Preserve output specialization without reintroducing properties absent from this field's\n // runtime shape.\n return {\n kind: 'object',\n fields: Object.fromEntries(\n Object.entries(base.fields).map(([key, fieldType]) => [\n key,\n overlay.fields[key] ?? fieldType,\n ]),\n ),\n };\n}\n\nfunction isWorkflowContextName(root: string): root is WorkflowContextName {\n return (workflowContextNames as readonly string[]).includes(root);\n}\n\nfunction isWorkflowFilterPredicateField(field: WorkflowPredicateField): boolean {\n return field === 'trigger.filter' || field === 'listener.on' || field === 'listener.until';\n}\n\nfunction fieldLabel(field: WorkflowPredicateField): string {\n return workflowFieldLabel(field);\n}\n\nfunction contextNoun(roots: readonly string[]): 'context' | 'contexts' {\n return roots.length === 1 ? 'context' : 'contexts';\n}\n\nfunction availabilityVerb(roots: readonly string[]): 'is' | 'are' {\n return roots.length === 1 ? 'is' : 'are';\n}\n\nfunction describeAvailabilitySite(site: AvailabilitySite): string {\n return availabilitySiteLabels[site];\n}\n\nfunction formatList(values: readonly string[]): string {\n return values.map((value) => `\"${value}\"`).join(', ');\n}\n"],"names":["createWorkflowExpression","extractExactContextRoots","getWorkflowContextDefinition","getWorkflowPredicateContextRoots","getWorkflowPredicateFieldMinimumFillTarget","getWorkflowPredicateFieldTypeEnvironment","InvalidWorkflowExpressionError","predicateSourceIsBooleanShaped","resolveContextRootHost","validateServerEvaluable","workflowContextNames","validateDirectJobReferences","issue","workflowFieldLabel","validatePredicateExpression","params","site","field","syntaxExpression","createSyntaxExpression","undefined","contextRoots","source","knownRoots","filter","root","unknownRoots","length","issues","push","invalidPredicateIssue","serverEvaluability","ok","violations","map","violation","runnerContextInServerPredicateIssue","runnerRoots","predicateContextRoots","unavailableRoots","includes","unavailablePredicateContextIssue","invalidJobReferenceIssue","allowedJobReferences","expression","path","typeOverlay","every","hasSyntaxOnlyCheckMode","isWorkflowFilterPredicateField","reason","check","mode","typeEnvironment","mergeTypeEnvironments","expectedResultType","error","code","invalidCode","message","invalidMessage","details","scope","availabilitySiteLabels","ingest","fieldLabel","formatList","describeAvailabilitySite","contextNoun","availabilityVerb","isWorkflowContextName","checkMode","roots","overlayType","kind","contextTypeEnvironment","contextType","overlayKnownFields","base","overlay","fields","Object","fromEntries","entries","key","fieldType","values","value","join"],"mappings":"AAAA,SAEEA,wBAAwB,EAGxBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,gCAAgC,EAChCC,0CAA0C,EAC1CC,wCAAwC,EACxCC,8BAA8B,EAC9BC,8BAA8B,EAC9BC,sBAAsB,EACtBC,uBAAuB,EAIvBC,oBAAoB,QACf,sBAAsB;AAO7B,SAAQC,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,KAAK,QAAO,wBAAwB;AAC5C,SAAQC,kBAAkB,QAAO,4BAA4B;AAE7D,OAAO,SAASC,4BAA4BC,MAW3C;IACC,MAAMC,OAAOZ,2CAA2CW,OAAOE,KAAK;IACpE,MAAMC,mBAAmBC,uBAAuBJ;IAChD,IAAIG,qBAAqBE,WAAW,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,KAAKE,MAAM,EAAE9C,GAAG,CAAC,CAAC,CAACkD,KAAKC,UAAU,GAAK;gBACpDD;gBACAL,QAAQC,MAAM,CAACI,IAAI,IAAIC;aACxB;IAEL;AACF;AAEA,SAASf,sBAAsB7C,IAAY;IACzC,OAAO,AAACf,qBAA2C8B,QAAQ,CAACf;AAC9D;AAEA,SAASwB,+BAA+BhC,KAA6B;IACnE,OAAOA,UAAU,oBAAoBA,UAAU,iBAAiBA,UAAU;AAC5E;AAEA,SAASgD,WAAWhD,KAA6B;IAC/C,OAAOJ,mBAAmBI;AAC5B;AAEA,SAASmD,YAAYI,KAAwB;IAC3C,OAAOA,MAAM7C,MAAM,KAAK,IAAI,YAAY;AAC1C;AAEA,SAAS0C,iBAAiBG,KAAwB;IAChD,OAAOA,MAAM7C,MAAM,KAAK,IAAI,OAAO;AACrC;AAEA,SAASwC,yBAAyBnD,IAAsB;IACtD,OAAO+C,sBAAsB,CAAC/C,KAAK;AACrC;AAEA,SAASkD,WAAWoB,MAAyB;IAC3C,OAAOA,OAAOpD,GAAG,CAAC,CAACqD,QAAU,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,EAAEC,IAAI,CAAC;AAClD"}
@@ -1,9 +1,10 @@
1
- import type { WorkflowModelValidationIssue, WorkflowModelValidationIssueCode, WorkflowModelValidationIssuePathSegment, WorkflowModelValidationIssueSeverity } from './invalid-workflow-model-error.js';
1
+ import type { WorkflowModelValidationIssue, WorkflowModelValidationIssueCode, WorkflowModelValidationIssuePathSegment, WorkflowModelValidationIssueScope, WorkflowModelValidationIssueSeverity } from './invalid-workflow-model-error.js';
2
2
  export declare function issue(params: {
3
3
  code: WorkflowModelValidationIssueCode;
4
4
  message: string;
5
5
  path: readonly WorkflowModelValidationIssuePathSegment[];
6
6
  details?: Readonly<Record<string, unknown>>;
7
7
  severity?: WorkflowModelValidationIssueSeverity;
8
+ scope?: WorkflowModelValidationIssueScope;
8
9
  }): WorkflowModelValidationIssue;
9
10
  //# sourceMappingURL=validation-issue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-issue.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/validation-issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACvC,oCAAoC,EACrC,MAAM,mCAAmC,CAAC;AAE3C,wBAAgB,KAAK,CAAC,MAAM,EAAE;IAC5B,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,uCAAuC,EAAE,CAAC;IACzD,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,oCAAoC,CAAC;CACjD,GAAG,4BAA4B,CAiB/B"}
1
+ {"version":3,"file":"validation-issue.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/validation-issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,uCAAuC,EACvC,iCAAiC,EACjC,oCAAoC,EACrC,MAAM,mCAAmC,CAAC;AAE3C,wBAAgB,KAAK,CAAC,MAAM,EAAE;IAC5B,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,uCAAuC,EAAE,CAAC;IACzD,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,oCAAoC,CAAC;IAChD,KAAK,CAAC,EAAE,iCAAiC,CAAC;CAC3C,GAAG,4BAA4B,CAU/B"}
@@ -1,22 +1,19 @@
1
1
  export function issue(params) {
2
- if (params.details === undefined) {
3
- return {
4
- code: params.code,
5
- message: params.message,
6
- path: params.path,
7
- ...params.severity === undefined ? {} : {
8
- severity: params.severity
9
- }
10
- };
11
- }
12
- return {
2
+ const severity = params.severity ?? 'error';
3
+ const scope = params.scope ?? 'definition';
4
+ const base = {
13
5
  code: params.code,
14
6
  message: params.message,
15
7
  path: params.path,
16
- details: params.details,
17
- ...params.severity === undefined ? {} : {
18
- severity: params.severity
19
- }
8
+ severity,
9
+ scope
10
+ };
11
+ if (params.details === undefined) {
12
+ return base;
13
+ }
14
+ return {
15
+ ...base,
16
+ details: params.details
20
17
  };
21
18
  }
22
19
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/workflow-model/validation-issue.ts"],"sourcesContent":["import type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n WorkflowModelValidationIssueSeverity,\n} from './invalid-workflow-model-error.js';\n\nexport function issue(params: {\n code: WorkflowModelValidationIssueCode;\n message: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n details?: Readonly<Record<string, unknown>>;\n severity?: WorkflowModelValidationIssueSeverity;\n}): WorkflowModelValidationIssue {\n if (params.details === undefined) {\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n ...(params.severity === undefined ? {} : {severity: params.severity}),\n };\n }\n\n return {\n code: params.code,\n message: params.message,\n path: params.path,\n details: params.details,\n ...(params.severity === undefined ? {} : {severity: params.severity}),\n };\n}\n"],"names":["issue","params","details","undefined","code","message","path","severity"],"mappings":"AAOA,OAAO,SAASA,MAAMC,MAMrB;IACC,IAAIA,OAAOC,OAAO,KAAKC,WAAW;QAChC,OAAO;YACLC,MAAMH,OAAOG,IAAI;YACjBC,SAASJ,OAAOI,OAAO;YACvBC,MAAML,OAAOK,IAAI;YACjB,GAAIL,OAAOM,QAAQ,KAAKJ,YAAY,CAAC,IAAI;gBAACI,UAAUN,OAAOM,QAAQ;YAAA,CAAC;QACtE;IACF;IAEA,OAAO;QACLH,MAAMH,OAAOG,IAAI;QACjBC,SAASJ,OAAOI,OAAO;QACvBC,MAAML,OAAOK,IAAI;QACjBJ,SAASD,OAAOC,OAAO;QACvB,GAAID,OAAOM,QAAQ,KAAKJ,YAAY,CAAC,IAAI;YAACI,UAAUN,OAAOM,QAAQ;QAAA,CAAC;IACtE;AACF"}
1
+ {"version":3,"sources":["../../../src/core/workflow-model/validation-issue.ts"],"sourcesContent":["import type {\n WorkflowModelValidationIssue,\n WorkflowModelValidationIssueCode,\n WorkflowModelValidationIssuePathSegment,\n WorkflowModelValidationIssueScope,\n WorkflowModelValidationIssueSeverity,\n} from './invalid-workflow-model-error.js';\n\nexport function issue(params: {\n code: WorkflowModelValidationIssueCode;\n message: string;\n path: readonly WorkflowModelValidationIssuePathSegment[];\n details?: Readonly<Record<string, unknown>>;\n severity?: WorkflowModelValidationIssueSeverity;\n scope?: WorkflowModelValidationIssueScope;\n}): WorkflowModelValidationIssue {\n const severity = params.severity ?? 'error';\n const scope = params.scope ?? 'definition';\n const base = {code: params.code, message: params.message, path: params.path, severity, scope};\n\n if (params.details === undefined) {\n return base;\n }\n\n return {...base, details: params.details};\n}\n"],"names":["issue","params","severity","scope","base","code","message","path","details","undefined"],"mappings":"AAQA,OAAO,SAASA,MAAMC,MAOrB;IACC,MAAMC,WAAWD,OAAOC,QAAQ,IAAI;IACpC,MAAMC,QAAQF,OAAOE,KAAK,IAAI;IAC9B,MAAMC,OAAO;QAACC,MAAMJ,OAAOI,IAAI;QAAEC,SAASL,OAAOK,OAAO;QAAEC,MAAMN,OAAOM,IAAI;QAAEL;QAAUC;IAAK;IAE5F,IAAIF,OAAOO,OAAO,KAAKC,WAAW;QAChC,OAAOL;IACT;IAEA,OAAO;QAAC,GAAGA,IAAI;QAAEI,SAASP,OAAOO,OAAO;IAAA;AAC1C"}