@shipfox/api-workflows 12.1.0 → 12.3.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 (159) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +45 -0
  3. package/README.md +20 -0
  4. package/dist/config.d.ts +11 -0
  5. package/dist/config.d.ts.map +1 -0
  6. package/dist/config.js +56 -0
  7. package/dist/config.js.map +1 -0
  8. package/dist/core/entities/job.d.ts +1 -1
  9. package/dist/core/entities/job.d.ts.map +1 -1
  10. package/dist/core/entities/step.d.ts +2 -2
  11. package/dist/core/entities/step.d.ts.map +1 -1
  12. package/dist/core/errors.d.ts +18 -1
  13. package/dist/core/errors.d.ts.map +1 -1
  14. package/dist/core/errors.js +21 -2
  15. package/dist/core/errors.js.map +1 -1
  16. package/dist/core/step-config/assemble-run-context.d.ts +15 -5
  17. package/dist/core/step-config/assemble-run-context.d.ts.map +1 -1
  18. package/dist/core/step-config/assemble-run-context.js +77 -27
  19. package/dist/core/step-config/assemble-run-context.js.map +1 -1
  20. package/dist/core/step-config/fields.d.ts +5 -0
  21. package/dist/core/step-config/fields.d.ts.map +1 -1
  22. package/dist/core/step-config/fields.js +21 -3
  23. package/dist/core/step-config/fields.js.map +1 -1
  24. package/dist/core/step-config/index.d.ts +1 -1
  25. package/dist/core/step-config/index.d.ts.map +1 -1
  26. package/dist/core/step-config/index.js +1 -1
  27. package/dist/core/step-config/index.js.map +1 -1
  28. package/dist/core/step-config/job-output-limits.d.ts +11 -0
  29. package/dist/core/step-config/job-output-limits.d.ts.map +1 -0
  30. package/dist/core/step-config/job-output-limits.js +88 -0
  31. package/dist/core/step-config/job-output-limits.js.map +1 -0
  32. package/dist/core/step-config/materialize-workflow-model.d.ts +1 -1
  33. package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
  34. package/dist/core/step-config/materialize-workflow-model.js +47 -18
  35. package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
  36. package/dist/db/db.d.ts +50 -50
  37. package/dist/db/index.d.ts +2 -2
  38. package/dist/db/index.d.ts.map +1 -1
  39. package/dist/db/index.js +1 -1
  40. package/dist/db/index.js.map +1 -1
  41. package/dist/db/job-listeners.d.ts.map +1 -1
  42. package/dist/db/job-listeners.js +6 -5
  43. package/dist/db/job-listeners.js.map +1 -1
  44. package/dist/db/schema/job-executions.d.ts +3 -3
  45. package/dist/db/schema/job-listener-events.d.ts +1 -1
  46. package/dist/db/schema/jobs.d.ts +7 -7
  47. package/dist/db/schema/outbox.d.ts +1 -1
  48. package/dist/db/schema/step-attempts.d.ts +2 -2
  49. package/dist/db/schema/steps.d.ts +5 -5
  50. package/dist/db/schema/workflow-run-attempts.d.ts +3 -3
  51. package/dist/db/schema/workflow-run-counters.d.ts +1 -1
  52. package/dist/db/schema/workflow-runs.d.ts +2 -2
  53. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
  54. package/dist/db/workflow-runs/job-executions.js +4 -2
  55. package/dist/db/workflow-runs/job-executions.js.map +1 -1
  56. package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
  57. package/dist/db/workflow-runs/jobs.js +33 -3
  58. package/dist/db/workflow-runs/jobs.js.map +1 -1
  59. package/dist/db/workflow-runs/outbox.d.ts +1 -0
  60. package/dist/db/workflow-runs/outbox.d.ts.map +1 -1
  61. package/dist/db/workflow-runs/outbox.js +1 -0
  62. package/dist/db/workflow-runs/outbox.js.map +1 -1
  63. package/dist/db/workflow-runs/steps.d.ts +28 -0
  64. package/dist/db/workflow-runs/steps.d.ts.map +1 -1
  65. package/dist/db/workflow-runs/steps.js +49 -1
  66. package/dist/db/workflow-runs/steps.js.map +1 -1
  67. package/dist/db/workflow-runs.d.ts +2 -2
  68. package/dist/db/workflow-runs.d.ts.map +1 -1
  69. package/dist/db/workflow-runs.js +1 -1
  70. package/dist/db/workflow-runs.js.map +1 -1
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +4 -2
  73. package/dist/index.js.map +1 -1
  74. package/dist/metrics/instance.d.ts +1 -0
  75. package/dist/metrics/instance.d.ts.map +1 -1
  76. package/dist/metrics/instance.js +8 -0
  77. package/dist/metrics/instance.js.map +1 -1
  78. package/dist/presentation/dto/evaluation-trace.d.ts +4 -0
  79. package/dist/presentation/dto/evaluation-trace.d.ts.map +1 -0
  80. package/dist/presentation/dto/evaluation-trace.js +39 -0
  81. package/dist/presentation/dto/evaluation-trace.js.map +1 -0
  82. package/dist/presentation/dto/index.d.ts +2 -1
  83. package/dist/presentation/dto/index.d.ts.map +1 -1
  84. package/dist/presentation/dto/index.js +2 -1
  85. package/dist/presentation/dto/index.js.map +1 -1
  86. package/dist/presentation/dto/job.d.ts.map +1 -1
  87. package/dist/presentation/dto/job.js +6 -0
  88. package/dist/presentation/dto/job.js.map +1 -1
  89. package/dist/presentation/dto/step.d.ts +2 -1
  90. package/dist/presentation/dto/step.d.ts.map +1 -1
  91. package/dist/presentation/dto/step.js +12 -0
  92. package/dist/presentation/dto/step.js.map +1 -1
  93. package/dist/presentation/index.d.ts +1 -1
  94. package/dist/presentation/index.d.ts.map +1 -1
  95. package/dist/presentation/index.js +1 -1
  96. package/dist/presentation/index.js.map +1 -1
  97. package/dist/presentation/routes/get-step-attempt-detail.d.ts +3 -0
  98. package/dist/presentation/routes/get-step-attempt-detail.d.ts.map +1 -0
  99. package/dist/presentation/routes/get-step-attempt-detail.js +38 -0
  100. package/dist/presentation/routes/get-step-attempt-detail.js.map +1 -0
  101. package/dist/presentation/routes/index.d.ts.map +1 -1
  102. package/dist/presentation/routes/index.js +2 -0
  103. package/dist/presentation/routes/index.js.map +1 -1
  104. package/dist/presentation/routes/project-access.d.ts +1 -1
  105. package/dist/presentation/subscribers/index.d.ts +1 -0
  106. package/dist/presentation/subscribers/index.d.ts.map +1 -1
  107. package/dist/presentation/subscribers/index.js +1 -0
  108. package/dist/presentation/subscribers/index.js.map +1 -1
  109. package/dist/presentation/subscribers/on-failure-annotations.d.ts +5 -0
  110. package/dist/presentation/subscribers/on-failure-annotations.d.ts.map +1 -0
  111. package/dist/presentation/subscribers/on-failure-annotations.js +160 -0
  112. package/dist/presentation/subscribers/on-failure-annotations.js.map +1 -0
  113. package/dist/temporal/activities/index.d.ts +1 -1
  114. package/dist/temporal/activities/index.d.ts.map +1 -1
  115. package/dist/temporal/activities/orchestration-activities.d.ts +1 -1
  116. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
  117. package/dist/temporal/workflows/test-env.d.ts +2 -2
  118. package/dist/tsconfig.test.tsbuildinfo +1 -1
  119. package/package.json +18 -16
  120. package/src/config.test.ts +85 -0
  121. package/src/config.ts +71 -0
  122. package/src/core/errors.ts +44 -2
  123. package/src/core/job-execution.test.ts +1 -0
  124. package/src/core/step-config/assemble-run-context.test.ts +232 -20
  125. package/src/core/step-config/assemble-run-context.ts +126 -28
  126. package/src/core/step-config/fields.ts +42 -3
  127. package/src/core/step-config/index.ts +2 -0
  128. package/src/core/step-config/job-output-limits.ts +130 -0
  129. package/src/core/step-config/materialize-workflow-model.catalog.test.ts +117 -0
  130. package/src/core/step-config/materialize-workflow-model.test.ts +306 -1
  131. package/src/core/step-config/materialize-workflow-model.ts +65 -18
  132. package/src/db/index.ts +4 -0
  133. package/src/db/job-listeners.ts +14 -3
  134. package/src/db/workflow-runs/job-executions.test.ts +207 -1
  135. package/src/db/workflow-runs/job-executions.ts +15 -2
  136. package/src/db/workflow-runs/job-status.test.ts +10 -3
  137. package/src/db/workflow-runs/jobs.test.ts +49 -0
  138. package/src/db/workflow-runs/jobs.ts +53 -6
  139. package/src/db/workflow-runs/outbox.ts +7 -1
  140. package/src/db/workflow-runs/run-create.test.ts +56 -0
  141. package/src/db/workflow-runs/steps.test.ts +148 -0
  142. package/src/db/workflow-runs/steps.ts +105 -1
  143. package/src/db/workflow-runs.ts +4 -0
  144. package/src/index.ts +9 -0
  145. package/src/metrics/instance.ts +10 -0
  146. package/src/presentation/dto/evaluation-trace.ts +27 -0
  147. package/src/presentation/dto/index.ts +2 -1
  148. package/src/presentation/dto/job.ts +6 -0
  149. package/src/presentation/dto/step.test.ts +96 -1
  150. package/src/presentation/dto/step.ts +17 -0
  151. package/src/presentation/index.ts +2 -0
  152. package/src/presentation/routes/get-step-attempt-detail.test.ts +159 -0
  153. package/src/presentation/routes/get-step-attempt-detail.ts +33 -0
  154. package/src/presentation/routes/index.ts +2 -0
  155. package/src/presentation/subscribers/index.ts +4 -0
  156. package/src/presentation/subscribers/on-failure-annotations.test.ts +510 -0
  157. package/src/presentation/subscribers/on-failure-annotations.ts +237 -0
  158. package/test/factories/workflow-model.ts +2 -0
  159. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,5 +1,5 @@
1
- import { analyzeContextRootKeyAccess, extractExactContextRoots, getWorkflowPredicateContextRoots } from '@shipfox/expression';
2
- export function assembleWorkflowRunContext(params) {
1
+ import { analyzeContextRootKeyAccess, extractExactContextRoots, getWorkflowPredicateContextRoots, rehydrateJsonExpressionRecord } from '@shipfox/expression';
2
+ export function assembleWorkflowRunContext(params, options = {}) {
3
3
  const triggerReference = params.run.triggerReference;
4
4
  return {
5
5
  workflow: {
@@ -8,7 +8,7 @@ export function assembleWorkflowRunContext(params) {
8
8
  },
9
9
  run: {
10
10
  id: params.run.id,
11
- number: params.run.number,
11
+ number: options.skipCelNativeRehydration === true ? params.run.number : BigInt(params.run.number),
12
12
  name: params.run.name,
13
13
  project_id: params.run.projectId,
14
14
  workspace_id: params.run.workspaceId,
@@ -78,27 +78,42 @@ export function assembleExecutionCreationContext(params) {
78
78
  /**
79
79
  * Keeps job-success predicate values aligned with the registry's `executions`
80
80
  * type environment.
81
- */ export function assembleExecutionsContext(executions) {
81
+ */ export function assembleExecutionsContext(executions, outputTypes, options = {}) {
82
82
  return {
83
- executions: executions.map((execution, index)=>assembleExecutionContext(execution, index))
83
+ executions: executions.map((execution, index)=>assembleExecutionContext(execution, index, outputTypes, options))
84
84
  };
85
85
  }
86
- function assembleExecutionContext(execution, index) {
86
+ function assembleExecutionContext(execution, index, outputTypes, options = {}) {
87
+ const skipCelNativeRehydration = options.skipCelNativeRehydration === true;
87
88
  return {
88
- index,
89
+ index: skipCelNativeRehydration ? index : BigInt(index),
89
90
  name: execution.name,
90
91
  status: execution.status,
91
92
  started_at: execution.startedAt,
92
93
  finished_at: execution.finishedAt,
93
- events: execution.triggerEvents,
94
- outputs: execution.outputs ?? {}
94
+ events: skipCelNativeRehydration ? execution.triggerEvents : execution.triggerEvents.map(assembleExecutionEventContext),
95
+ outputs: options.skipTypedOutputRehydration === true ? execution.outputs ?? {} : rehydrateJsonExpressionRecord(execution.outputs, outputTypes)
95
96
  };
96
97
  }
97
- export function assembleJobsContext(jobs) {
98
+ function assembleExecutionEventContext(event) {
99
+ const receivedAt = new Date(event.received_at);
100
+ /**
101
+ * An unparseable stored timestamp would become an `Invalid Date`, which compares
102
+ * false against every CEL `timestamp` and throws on `toISOString` during template
103
+ * resolution. Keeping the raw value fails loudly as a type mismatch instead.
104
+ */ if (Number.isNaN(receivedAt.getTime())) return {
105
+ ...event
106
+ };
107
+ return {
108
+ ...event,
109
+ received_at: receivedAt
110
+ };
111
+ }
112
+ export function assembleJobsContext(jobs, options = {}) {
98
113
  return {
99
114
  jobs: Object.fromEntries(jobs.map((input)=>[
100
115
  input.job.key,
101
- assembleJobContext(input)
116
+ assembleJobContext(input, options)
102
117
  ]))
103
118
  };
104
119
  }
@@ -108,7 +123,7 @@ export function assembleJobActivationContext(params) {
108
123
  values: {
109
124
  ...assembleWorkflowRunContext(params),
110
125
  ...assembleJobsContext(params.jobs),
111
- needs: params.jobs.map(assembleJobContext),
126
+ needs: params.jobs.map((input)=>assembleJobContext(input, {})),
112
127
  vars: params.vars ?? {}
113
128
  }
114
129
  };
@@ -168,6 +183,8 @@ export function assembleListenerSnapshotContext(params) {
168
183
  triggerPayload: params.triggerPayload,
169
184
  inputs: params.inputs,
170
185
  vars: params.vars
186
+ }, {
187
+ skipCelNativeRehydration: true
171
188
  });
172
189
  if (params.plan.roots.has('workflow')) context.workflow = runContext.workflow;
173
190
  if (params.plan.roots.has('run')) context.run = runContext.run;
@@ -193,20 +210,58 @@ export function assembleListenerSnapshotContext(params) {
193
210
  return context;
194
211
  }
195
212
  function requestedJobsContext(dependencyJobs, jobKeys) {
196
- if (jobKeys.size === 0) return assembleJobsContext(dependencyJobs).jobs;
213
+ // Listener snapshots cross a JSON outbox boundary; their type metadata is persisted separately.
214
+ const options = {
215
+ skipCelNativeRehydration: true,
216
+ skipTypedOutputRehydration: true
217
+ };
218
+ if (jobKeys.size === 0) {
219
+ return assembleJobsContext(dependencyJobs, options).jobs;
220
+ }
197
221
  const filtered = dependencyJobs.filter(({ job })=>jobKeys.has(job.key));
198
- return assembleJobsContext(filtered).jobs;
222
+ return assembleJobsContext(filtered, options).jobs;
199
223
  }
200
- export function applyListenerFilterSnapshots(plans, context) {
224
+ export function applyListenerFilterSnapshots(plans, context, outputTypes) {
201
225
  return plans.map((plan)=>{
202
226
  const filterSnapshot = filterSnapshotForPlan(plan, context);
203
227
  if (filterSnapshot === undefined) return plan.matcher;
228
+ const filterOutputTypes = filterOutputTypesForPlan(plan, context, outputTypes);
204
229
  return {
205
230
  ...plan.matcher,
206
- filter_snapshot: filterSnapshot
231
+ filter_snapshot: filterSnapshot,
232
+ ...filterOutputTypes === undefined ? {} : {
233
+ filter_output_types: filterOutputTypes
234
+ }
207
235
  };
208
236
  });
209
237
  }
238
+ export function listenerFilterOutputTypesForJobs(jobs) {
239
+ return Object.fromEntries(jobs.flatMap(({ job, outputTypes })=>outputTypes === undefined ? [] : [
240
+ [
241
+ job.key,
242
+ {
243
+ ...outputTypes
244
+ }
245
+ ]
246
+ ]));
247
+ }
248
+ function filterOutputTypesForPlan(plan, context, outputTypes) {
249
+ if (outputTypes === undefined || !plan.roots.has('jobs')) return undefined;
250
+ const jobsSnapshot = jobsSnapshotForPlan(plan, context);
251
+ if (jobsSnapshot === undefined) return undefined;
252
+ const entries = Object.keys(jobsSnapshot).flatMap((jobKey)=>{
253
+ const types = outputTypes[jobKey];
254
+ return types === undefined ? [] : [
255
+ [
256
+ jobKey,
257
+ {
258
+ ...types
259
+ }
260
+ ]
261
+ ];
262
+ });
263
+ return entries.length === 0 ? undefined : Object.fromEntries(entries);
264
+ }
210
265
  function filterSnapshotForPlan(plan, context) {
211
266
  const snapshot = {};
212
267
  for (const root of plan.roots){
@@ -237,12 +292,13 @@ function jobsSnapshotForPlan(plan, context) {
237
292
  ] : []));
238
293
  return snapshot;
239
294
  }
240
- function assembleJobContext({ job, executions }) {
295
+ function assembleJobContext({ job, outputTypes, executions }, options) {
296
+ const outputs = options.skipTypedOutputRehydration === true ? job.outputs ?? {} : rehydrateJsonExpressionRecord(job.outputs, outputTypes);
241
297
  return {
242
298
  key: job.key,
243
299
  status: job.status,
244
- outputs: job.outputs ?? {},
245
- executions: assembleExecutionsContext(executions).executions
300
+ outputs,
301
+ executions: assembleExecutionsContext(executions, options.skipTypedOutputRehydration === true ? undefined : outputTypes, options).executions
246
302
  };
247
303
  }
248
304
  function assembleStepsContext(params) {
@@ -300,14 +356,8 @@ export function assembleStepDispatchContext(params) {
300
356
  ...assembleJobsContext(params.jobs ?? []),
301
357
  ...params.jobExecution === undefined ? {} : {
302
358
  execution: {
303
- index: params.jobExecution.sequence,
304
- name: params.jobExecution.name,
305
- status: params.jobExecution.status,
306
- failed: stepAttemptContext.stepsFailed,
307
- started_at: params.jobExecution.startedAt,
308
- finished_at: params.jobExecution.finishedAt,
309
- events: params.jobExecution.triggerEvents,
310
- outputs: params.jobExecution.outputs ?? {}
359
+ ...assembleExecutionContext(params.jobExecution, params.jobExecution.sequence - 1),
360
+ failed: stepAttemptContext.stepsFailed
311
361
  }
312
362
  },
313
363
  ...targetStep === undefined ? {} : {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/step-config/assemble-run-context.ts"],"sourcesContent":["import {\n analyzeContextRootKeyAccess,\n extractExactContextRoots,\n getWorkflowPredicateContextRoots,\n type WorkflowExpressionEvaluationContext,\n type WorkflowPredicateContextRoot,\n} from '@shipfox/expression';\nimport type {Job, JobListeningTrigger} from '#core/entities/job.js';\nimport type {JobExecution} from '#core/entities/job-execution.js';\nimport type {Step, StepAttempt, StepStatus} from '#core/entities/step.js';\nimport type {\n TriggerPayload,\n WorkflowRun,\n WorkflowRunTriggerReference,\n} from '#core/entities/workflow-run.js';\nimport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n\nexport interface JobContextInput {\n readonly job: Pick<Job, 'key' | 'status' | 'outputs'>;\n readonly executions: readonly JobExecution[];\n}\n\nexport interface AssembleWorkflowRunContextParams {\n readonly run: Pick<\n WorkflowRun,\n | 'id'\n | 'number'\n | 'name'\n | 'workflowName'\n | 'definitionId'\n | 'projectId'\n | 'workspaceId'\n | 'createdAt'\n > & {readonly triggerReference?: WorkflowRunTriggerReference | null | undefined};\n readonly triggerPayload: TriggerPayload;\n readonly inputs?: Record<string, unknown> | null | undefined;\n readonly vars?: Record<string, string> | undefined;\n}\n\nexport function assembleWorkflowRunContext(\n params: AssembleWorkflowRunContextParams,\n): WorkflowExpressionEvaluationContext {\n const triggerReference = params.run.triggerReference;\n return {\n workflow: {\n id: params.run.definitionId,\n name: params.run.workflowName,\n },\n run: {\n id: params.run.id,\n number: params.run.number,\n name: params.run.name,\n project_id: params.run.projectId,\n workspace_id: params.run.workspaceId,\n created_at: params.run.createdAt,\n },\n trigger: {\n source: params.triggerPayload.source,\n event: params.triggerPayload.event,\n project: triggerReference?.project ?? null,\n repository: triggerReference?.repository ?? null,\n ref: triggerReference?.ref ?? null,\n commit: triggerReference?.commit ?? null,\n },\n event: 'data' in params.triggerPayload ? params.triggerPayload.data : null,\n inputs: params.inputs ?? null,\n ...(params.vars === undefined ? {} : {vars: params.vars}),\n };\n}\n\nexport function assembleCreationContext(\n params: AssembleWorkflowRunContextParams,\n): WorkflowEvaluationContext {\n return {\n site: 'run-creation',\n values: assembleWorkflowRunContext(params),\n };\n}\n\nexport interface AssembleExecutionCreationContextParams extends AssembleWorkflowRunContextParams {\n readonly job: Pick<Job, 'id' | 'key' | 'name'>;\n readonly sequence: number;\n readonly nameOverride: string | null;\n readonly executionName: string;\n readonly status: JobExecution['status'];\n readonly triggerEvents: readonly JobExecution['triggerEvents'][number][];\n readonly priorExecutions: readonly JobExecution[];\n}\n\nexport function assembleExecutionCreationContext(\n params: AssembleExecutionCreationContextParams,\n): WorkflowEvaluationContext {\n const execution: JobExecution = {\n id: `${params.job.id}:${params.sequence}`,\n jobId: params.job.id,\n sequence: params.sequence,\n nameOverride: params.nameOverride,\n name: params.executionName,\n runner: null,\n status: params.status,\n statusReason: null,\n triggerEvents: [...params.triggerEvents],\n outputs: null,\n version: 1,\n createdAt: new Date(),\n updatedAt: new Date(),\n queuedAt: null,\n startedAt: null,\n finishedAt: null,\n timedOutAt: null,\n };\n const executions = assembleExecutionsContext([...params.priorExecutions, execution]);\n const executionValues = executions.executions as unknown[];\n return {\n site: 'execution-creation',\n values: {\n ...assembleWorkflowRunContext(params),\n ...executions,\n job: {key: params.job.key, name: params.job.name ?? params.job.key},\n execution: executionValues.at(-1),\n },\n };\n}\n\n/**\n * Keeps job-success predicate values aligned with the registry's `executions`\n * type environment.\n */\nexport function assembleExecutionsContext(\n executions: readonly JobExecution[],\n): WorkflowExpressionEvaluationContext {\n return {\n executions: executions.map((execution, index) => assembleExecutionContext(execution, index)),\n };\n}\n\nfunction assembleExecutionContext(execution: JobExecution, index: number): Record<string, unknown> {\n return {\n index,\n name: execution.name,\n status: execution.status,\n started_at: execution.startedAt,\n finished_at: execution.finishedAt,\n events: execution.triggerEvents,\n outputs: execution.outputs ?? {},\n };\n}\n\nexport function assembleJobsContext(\n jobs: readonly JobContextInput[],\n): WorkflowExpressionEvaluationContext & {readonly jobs: Record<string, unknown>} {\n return {\n jobs: Object.fromEntries(jobs.map((input) => [input.job.key, assembleJobContext(input)])),\n };\n}\n\nexport interface AssembleJobActivationContextParams extends AssembleWorkflowRunContextParams {\n readonly jobs: readonly JobContextInput[];\n}\n\nexport function assembleJobActivationContext(\n params: AssembleJobActivationContextParams,\n): WorkflowEvaluationContext {\n return {\n site: 'job-activation',\n values: {\n ...assembleWorkflowRunContext(params),\n ...assembleJobsContext(params.jobs),\n needs: params.jobs.map(assembleJobContext),\n vars: params.vars ?? {},\n },\n };\n}\n\ntype ListenerPredicateField = 'listener.on' | 'listener.until';\ntype ListenerSnapshotRoot = Exclude<WorkflowPredicateContextRoot<ListenerPredicateField>, 'event'>;\n\nexport interface MatcherSnapshotPlan {\n readonly matcher: JobListeningTrigger;\n readonly roots: ReadonlySet<ListenerSnapshotRoot>;\n readonly jobKeys: ReadonlySet<string>;\n}\n\nexport interface ListenerSnapshotPlan {\n readonly on: readonly MatcherSnapshotPlan[];\n readonly until: readonly MatcherSnapshotPlan[];\n readonly roots: ReadonlySet<ListenerSnapshotRoot>;\n readonly jobKeys: ReadonlySet<string>;\n}\n\nexport function planListenerFilterSnapshots(params: {\n readonly on: readonly JobListeningTrigger[];\n readonly until: readonly JobListeningTrigger[] | null;\n}): ListenerSnapshotPlan {\n const roots = new Set<ListenerSnapshotRoot>();\n const jobKeys = new Set<string>();\n const on = params.on.map((matcher) =>\n planMatcherFilterSnapshot('listener.on', matcher, roots, jobKeys),\n );\n const until = (params.until ?? []).map((matcher) =>\n planMatcherFilterSnapshot('listener.until', matcher, roots, jobKeys),\n );\n return {on, until, roots, jobKeys};\n}\n\nfunction planMatcherFilterSnapshot(\n field: ListenerPredicateField,\n matcher: JobListeningTrigger,\n allRoots: Set<ListenerSnapshotRoot>,\n allJobKeys: Set<string>,\n): MatcherSnapshotPlan {\n if (matcher.filter === undefined) return {matcher, roots: new Set(), jobKeys: new Set()};\n\n let roots: ListenerSnapshotRoot[];\n try {\n roots = extractExactContextRoots(matcher.filter).filter((root) =>\n isListenerSnapshotRoot(field, root),\n );\n } catch {\n return {matcher, roots: new Set(), jobKeys: new Set()};\n }\n\n if (roots.length === 0) return {matcher, roots: new Set(), jobKeys: new Set()};\n\n const jobKeys =\n roots.includes('jobs') && matcher.filter !== undefined\n ? new Set(\n analyzeContextRootKeyAccess(matcher.filter, ['jobs']).references.map(\n (reference) => reference.key,\n ),\n )\n : new Set<string>();\n for (const root of roots) allRoots.add(root);\n for (const key of jobKeys) allJobKeys.add(key);\n return {matcher, roots: new Set(roots), jobKeys};\n}\n\nfunction isListenerSnapshotRoot(\n field: ListenerPredicateField,\n root: string,\n): root is ListenerSnapshotRoot {\n return (\n root !== 'event' &&\n getWorkflowPredicateContextRoots(field).includes(\n root as WorkflowPredicateContextRoot<ListenerPredicateField>,\n )\n );\n}\n\nexport function assembleListenerSnapshotContext(params: {\n readonly job: Pick<Job, 'key'> & Partial<Pick<Job, 'name'>>;\n readonly run: AssembleWorkflowRunContextParams['run'];\n readonly triggerPayload: TriggerPayload;\n readonly inputs?: Record<string, unknown> | null | undefined;\n readonly vars?: Record<string, string> | undefined;\n readonly plan: ListenerSnapshotPlan;\n readonly dependencyJobs: readonly JobContextInput[];\n}): WorkflowExpressionEvaluationContext {\n const context: Record<string, unknown> = {};\n if (\n params.plan.roots.has('workflow') ||\n params.plan.roots.has('run') ||\n params.plan.roots.has('trigger')\n ) {\n const runContext = assembleWorkflowRunContext({\n run: params.run,\n triggerPayload: params.triggerPayload,\n inputs: params.inputs,\n vars: params.vars,\n });\n if (params.plan.roots.has('workflow')) context.workflow = runContext.workflow;\n if (params.plan.roots.has('run')) context.run = runContext.run;\n if (params.plan.roots.has('trigger')) context.trigger = runContext.trigger;\n }\n\n if (params.plan.roots.has('inputs')) {\n context.inputs = params.inputs ?? null;\n }\n if (params.plan.roots.has('vars')) {\n context.vars = params.vars ?? {};\n }\n if (params.plan.roots.has('job')) {\n context.job = {\n key: params.job.key,\n ...(params.job.name === undefined ? {} : {name: params.job.name ?? params.job.key}),\n };\n }\n if (params.plan.roots.has('jobs')) {\n context.jobs = requestedJobsContext(params.dependencyJobs, params.plan.jobKeys);\n }\n\n return context;\n}\n\nfunction requestedJobsContext(\n dependencyJobs: readonly JobContextInput[],\n jobKeys: ReadonlySet<string>,\n): Record<string, unknown> {\n if (jobKeys.size === 0) return assembleJobsContext(dependencyJobs).jobs;\n\n const filtered = dependencyJobs.filter(({job}) => jobKeys.has(job.key));\n\n return assembleJobsContext(filtered).jobs;\n}\n\nexport type ListenerTriggerWithSnapshot = JobListeningTrigger & {\n readonly filter_snapshot?: Record<string, unknown>;\n};\n\nexport function applyListenerFilterSnapshots(\n plans: readonly MatcherSnapshotPlan[],\n context: WorkflowExpressionEvaluationContext,\n): ListenerTriggerWithSnapshot[] {\n return plans.map((plan) => {\n const filterSnapshot = filterSnapshotForPlan(plan, context);\n if (filterSnapshot === undefined) return plan.matcher;\n\n return {...plan.matcher, filter_snapshot: filterSnapshot};\n });\n}\n\nfunction filterSnapshotForPlan(\n plan: MatcherSnapshotPlan,\n context: WorkflowExpressionEvaluationContext,\n): Record<string, unknown> | undefined {\n const snapshot: Record<string, unknown> = {};\n for (const root of plan.roots) {\n if (root === 'jobs') {\n const jobsSnapshot = jobsSnapshotForPlan(plan, context);\n if (jobsSnapshot !== undefined) snapshot.jobs = jobsSnapshot;\n continue;\n }\n\n if (root in context) snapshot[root] = context[root];\n }\n\n return Object.keys(snapshot).length === 0 ? undefined : snapshot;\n}\n\nfunction jobsSnapshotForPlan(\n plan: MatcherSnapshotPlan,\n context: WorkflowExpressionEvaluationContext,\n): Record<string, unknown> | undefined {\n if (typeof context.jobs !== 'object' || context.jobs === null) {\n return undefined;\n }\n\n const jobsContext = context.jobs as Record<string, unknown>;\n if (plan.jobKeys.size === 0) return {...jobsContext};\n\n const snapshot = Object.fromEntries(\n [...plan.jobKeys].flatMap((key) =>\n Object.hasOwn(jobsContext, key) ? [[key, jobsContext[key]]] : [],\n ),\n );\n return snapshot;\n}\n\nfunction assembleJobContext({job, executions}: JobContextInput): Record<string, unknown> {\n return {\n key: job.key,\n status: job.status,\n outputs: job.outputs ?? {},\n executions: assembleExecutionsContext(executions).executions,\n };\n}\n\nfunction assembleStepsContext(params: {\n readonly steps: readonly Step[];\n readonly attempts: readonly StepAttempt[];\n}): Record<string, Record<string, unknown>> {\n return buildStepAttemptContext(params).stepsContext;\n}\n\nfunction buildStepAttemptContext(params: {\n readonly steps: readonly Step[];\n readonly attempts: readonly StepAttempt[];\n}): {\n readonly stepsContext: Record<string, Record<string, unknown>>;\n readonly stepsFailed: boolean;\n readonly orderedAttempts: readonly StepAttempt[];\n readonly stepsByKey: ReadonlyMap<string, Step>;\n readonly terminalAttemptsByStepId: ReadonlyMap<string, readonly StepAttempt[]>;\n} {\n const stepsByKey = new Map(\n params.steps.flatMap((step) => (step.key === null ? [] : [[step.key, step] as const])),\n );\n const terminalAttemptsByStepId = new Map<string, StepAttempt[]>();\n const orderedAttempts = [...params.attempts].sort(\n (left, right) => left.executionOrder - right.executionOrder,\n );\n\n for (const attempt of orderedAttempts) {\n if (attempt.status === 'running') continue;\n const attemptsForStep = terminalAttemptsByStepId.get(attempt.stepId) ?? [];\n attemptsForStep.push(attempt);\n terminalAttemptsByStepId.set(attempt.stepId, attemptsForStep);\n }\n\n const stepsContext: Record<string, Record<string, unknown>> = {};\n\n for (const step of params.steps) {\n if (step.key === null) continue;\n const attempts = terminalAttemptsByStepId.get(step.id) ?? [];\n const latestAttempt = attempts.at(-1);\n stepsContext[step.key] = {\n status: step.status,\n ...(latestAttempt === undefined ? {} : latestAttemptFields(latestAttempt)),\n attempts: attempts.map(attemptFields),\n };\n }\n\n return {\n stepsContext,\n stepsFailed: params.steps.some((step) => step.status === 'failed'),\n orderedAttempts,\n stepsByKey,\n terminalAttemptsByStepId,\n };\n}\n\nexport function assembleStepDispatchContext(params: {\n readonly steps: readonly Step[];\n readonly attempts: readonly StepAttempt[];\n readonly targetStepId: string;\n readonly jobExecution?: JobExecution;\n readonly jobs?: readonly JobContextInput[];\n readonly vars?: Record<string, string> | undefined;\n}): WorkflowEvaluationContext {\n const targetStep = params.steps.find((step) => step.id === params.targetStepId);\n const stepAttemptContext = buildStepAttemptContext(params);\n const restart =\n targetStep === undefined || targetStep.currentAttempt <= 1\n ? undefined\n : restartProvenance({\n targetStep,\n orderedAttempts: stepAttemptContext.orderedAttempts,\n stepsByKey: stepAttemptContext.stepsByKey,\n terminalAttemptsByStepId: stepAttemptContext.terminalAttemptsByStepId,\n });\n\n return {\n site: 'step-dispatch',\n values: {\n vars: params.vars ?? {},\n ...assembleJobsContext(params.jobs ?? []),\n ...(params.jobExecution === undefined\n ? {}\n : {\n execution: {\n index: params.jobExecution.sequence,\n name: params.jobExecution.name,\n status: params.jobExecution.status,\n failed: stepAttemptContext.stepsFailed,\n started_at: params.jobExecution.startedAt,\n finished_at: params.jobExecution.finishedAt,\n events: params.jobExecution.triggerEvents,\n outputs: params.jobExecution.outputs ?? {},\n },\n }),\n ...(targetStep === undefined\n ? {}\n : {\n step: {\n attempt: BigInt(targetStep.currentAttempt),\n is_retry: targetStep.currentAttempt > 1,\n ...(restart === undefined ? {} : {restart}),\n },\n }),\n steps: stepAttemptContext.stepsContext,\n },\n };\n}\n\nfunction restartProvenance(params: {\n readonly targetStep: Step;\n readonly orderedAttempts: readonly StepAttempt[];\n readonly stepsByKey: ReadonlyMap<string, Step>;\n readonly terminalAttemptsByStepId: ReadonlyMap<string, readonly StepAttempt[]>;\n}): Record<string, unknown> | undefined {\n for (const attempt of [...params.orderedAttempts].reverse()) {\n if (attempt.status !== 'failed' || attempt.restartFeedback === null) continue;\n const restartFromKey = restartFromStepKey(attempt);\n if (restartFromKey === undefined) continue;\n\n const restartFromStep = params.stepsByKey.get(restartFromKey);\n if (restartFromStep === undefined || restartFromStep.position > params.targetStep.position) {\n continue;\n }\n\n const gatingAttempts = params.terminalAttemptsByStepId.get(attempt.stepId) ?? [];\n return {\n from: {\n ...attemptFields(attempt),\n attempts: gatingAttempts.map(attemptFields),\n },\n feedback: attempt.restartFeedback,\n };\n }\n\n return undefined;\n}\n\nfunction restartFromStepKey(attempt: StepAttempt): string | undefined {\n const gate = attempt.config?.gate;\n if (gate === null || typeof gate !== 'object') return undefined;\n const onFailure = (gate as Record<string, unknown>).on_failure;\n if (onFailure === null || typeof onFailure !== 'object') return undefined;\n const restartFrom = (onFailure as Record<string, unknown>).restart_from;\n return typeof restartFrom === 'string' ? restartFrom : undefined;\n}\n\nfunction attemptFields(attempt: StepAttempt): Record<string, unknown> {\n return {\n status: attempt.status,\n outputs: attempt.output ?? {},\n ...(attempt.response === null ? {} : {response: attempt.response}),\n ...(attempt.exitCode === null ? {} : {exit_code: BigInt(attempt.exitCode)}),\n ...(attempt.gateResult === null ? {} : {gate: attempt.gateResult}),\n };\n}\n\nfunction latestAttemptFields(attempt: StepAttempt): Record<string, unknown> {\n const fields = attemptFields(attempt);\n delete fields.status;\n return fields;\n}\n\nexport function assembleGateContext(params: {\n readonly status: StepStatus;\n readonly exitCode: number | null;\n readonly output?: Record<string, unknown> | null | undefined;\n readonly vars?: Record<string, string> | undefined;\n}): WorkflowEvaluationContext {\n return {\n site: 'step-report',\n values: {\n vars: params.vars ?? {},\n step: {\n ...(params.exitCode === null ? {} : {exit_code: BigInt(params.exitCode)}),\n status: params.status,\n outputs: params.output ?? {},\n },\n },\n };\n}\n\nexport function assembleJobResolutionContext(params: {\n readonly executions: readonly JobExecution[];\n readonly jobs: readonly JobContextInput[];\n readonly vars?: Record<string, string> | undefined;\n}): WorkflowEvaluationContext {\n return {\n site: 'job-resolution',\n values: {\n ...assembleExecutionsContext(params.executions),\n ...assembleJobsContext(params.jobs),\n vars: params.vars ?? {},\n },\n };\n}\n\nexport function assembleExecutionResolutionContext(params: {\n readonly run: AssembleWorkflowRunContextParams['run'];\n readonly triggerPayload: TriggerPayload;\n readonly inputs?: Record<string, unknown> | null | undefined;\n readonly vars?: Record<string, string> | undefined;\n readonly job: Pick<Job, 'key'> & Partial<Pick<Job, 'name'>>;\n readonly jobExecution: JobExecution;\n readonly executions: readonly JobExecution[];\n readonly steps: readonly Step[];\n readonly attempts: readonly StepAttempt[];\n readonly jobs?: readonly JobContextInput[];\n}): WorkflowEvaluationContext {\n const executions = assembleExecutionsContext(params.executions);\n const executionIndex = params.executions.findIndex(\n (execution) => execution.id === params.jobExecution.id,\n );\n\n return {\n site: 'execution-resolution',\n values: {\n ...assembleWorkflowRunContext(params),\n ...executions,\n ...(params.jobs === undefined ? {} : assembleJobsContext(params.jobs)),\n execution: assembleExecutionContext(\n params.jobExecution,\n executionIndex < 0 ? params.jobExecution.sequence - 1 : executionIndex,\n ),\n job: {\n key: params.job.key,\n ...(params.job.name === undefined ? {} : {name: params.job.name ?? params.job.key}),\n },\n steps: assembleStepsContext({steps: params.steps, attempts: params.attempts}),\n },\n };\n}\n"],"names":["analyzeContextRootKeyAccess","extractExactContextRoots","getWorkflowPredicateContextRoots","assembleWorkflowRunContext","params","triggerReference","run","workflow","id","definitionId","name","workflowName","number","project_id","projectId","workspace_id","workspaceId","created_at","createdAt","trigger","source","triggerPayload","event","project","repository","ref","commit","data","inputs","vars","undefined","assembleCreationContext","site","values","assembleExecutionCreationContext","execution","job","sequence","jobId","nameOverride","executionName","runner","status","statusReason","triggerEvents","outputs","version","Date","updatedAt","queuedAt","startedAt","finishedAt","timedOutAt","executions","assembleExecutionsContext","priorExecutions","executionValues","key","at","map","index","assembleExecutionContext","started_at","finished_at","events","assembleJobsContext","jobs","Object","fromEntries","input","assembleJobContext","assembleJobActivationContext","needs","planListenerFilterSnapshots","roots","Set","jobKeys","on","matcher","planMatcherFilterSnapshot","until","field","allRoots","allJobKeys","filter","root","isListenerSnapshotRoot","length","includes","references","reference","add","assembleListenerSnapshotContext","context","plan","has","runContext","requestedJobsContext","dependencyJobs","size","filtered","applyListenerFilterSnapshots","plans","filterSnapshot","filterSnapshotForPlan","filter_snapshot","snapshot","jobsSnapshot","jobsSnapshotForPlan","keys","jobsContext","flatMap","hasOwn","assembleStepsContext","buildStepAttemptContext","stepsContext","stepsByKey","Map","steps","step","terminalAttemptsByStepId","orderedAttempts","attempts","sort","left","right","executionOrder","attempt","attemptsForStep","get","stepId","push","set","latestAttempt","latestAttemptFields","attemptFields","stepsFailed","some","assembleStepDispatchContext","targetStep","find","targetStepId","stepAttemptContext","restart","currentAttempt","restartProvenance","jobExecution","failed","BigInt","is_retry","reverse","restartFeedback","restartFromKey","restartFromStepKey","restartFromStep","position","gatingAttempts","from","feedback","gate","config","onFailure","on_failure","restartFrom","restart_from","output","response","exitCode","exit_code","gateResult","fields","assembleGateContext","assembleJobResolutionContext","assembleExecutionResolutionContext","executionIndex","findIndex"],"mappings":"AAAA,SACEA,2BAA2B,EAC3BC,wBAAwB,EACxBC,gCAAgC,QAG3B,sBAAsB;AAiC7B,OAAO,SAASC,2BACdC,MAAwC;IAExC,MAAMC,mBAAmBD,OAAOE,GAAG,CAACD,gBAAgB;IACpD,OAAO;QACLE,UAAU;YACRC,IAAIJ,OAAOE,GAAG,CAACG,YAAY;YAC3BC,MAAMN,OAAOE,GAAG,CAACK,YAAY;QAC/B;QACAL,KAAK;YACHE,IAAIJ,OAAOE,GAAG,CAACE,EAAE;YACjBI,QAAQR,OAAOE,GAAG,CAACM,MAAM;YACzBF,MAAMN,OAAOE,GAAG,CAACI,IAAI;YACrBG,YAAYT,OAAOE,GAAG,CAACQ,SAAS;YAChCC,cAAcX,OAAOE,GAAG,CAACU,WAAW;YACpCC,YAAYb,OAAOE,GAAG,CAACY,SAAS;QAClC;QACAC,SAAS;YACPC,QAAQhB,OAAOiB,cAAc,CAACD,MAAM;YACpCE,OAAOlB,OAAOiB,cAAc,CAACC,KAAK;YAClCC,SAASlB,kBAAkBkB,WAAW;YACtCC,YAAYnB,kBAAkBmB,cAAc;YAC5CC,KAAKpB,kBAAkBoB,OAAO;YAC9BC,QAAQrB,kBAAkBqB,UAAU;QACtC;QACAJ,OAAO,UAAUlB,OAAOiB,cAAc,GAAGjB,OAAOiB,cAAc,CAACM,IAAI,GAAG;QACtEC,QAAQxB,OAAOwB,MAAM,IAAI;QACzB,GAAIxB,OAAOyB,IAAI,KAAKC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Y,CAAC1I,EAAE;IAGxD,OAAO;QACLwB,MAAM;QACNC,QAAQ;YACN,GAAG9B,2BAA2BC,OAAO;YACrC,GAAGiD,UAAU;YACb,GAAIjD,OAAO8D,IAAI,KAAKpC,YAAY,CAAC,IAAImC,oBAAoB7D,OAAO8D,IAAI,CAAC;YACrE/B,WAAW0B,yBACTzD,OAAO8I,YAAY,EACnB4B,iBAAiB,IAAI1K,OAAO8I,YAAY,CAAC7G,QAAQ,GAAG,IAAIyI;YAE1D1I,KAAK;gBACHqB,KAAKrD,OAAOgC,GAAG,CAACqB,GAAG;gBACnB,GAAIrD,OAAOgC,GAAG,CAAC1B,IAAI,KAAKoB,YAAY,CAAC,IAAI;oBAACpB,MAAMN,OAAOgC,GAAG,CAAC1B,IAAI,IAAIN,OAAOgC,GAAG,CAACqB,GAAG;gBAAA,CAAC;YACpF;YACA6D,OAAOL,qBAAqB;gBAACK,OAAOlH,OAAOkH,KAAK;gBAAEI,UAAUtH,OAAOsH,QAAQ;YAAA;QAC7E;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/core/step-config/assemble-run-context.ts"],"sourcesContent":["import {\n analyzeContextRootKeyAccess,\n type ExpressionType,\n extractExactContextRoots,\n getWorkflowPredicateContextRoots,\n rehydrateJsonExpressionRecord,\n type WorkflowExpressionEvaluationContext,\n type WorkflowPredicateContextRoot,\n} from '@shipfox/expression';\nimport type {Job, JobListeningTrigger} from '#core/entities/job.js';\nimport type {JobExecution, WorkflowExecutionEvent} from '#core/entities/job-execution.js';\nimport type {Step, StepAttempt, StepStatus} from '#core/entities/step.js';\nimport type {\n TriggerPayload,\n WorkflowRun,\n WorkflowRunTriggerReference,\n} from '#core/entities/workflow-run.js';\nimport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n\nexport interface JobContextInput {\n readonly job: Pick<Job, 'key' | 'status' | 'outputs'>;\n readonly outputTypes?: Readonly<Record<string, ExpressionType>>;\n readonly executions: readonly JobExecution[];\n}\n\nexport interface AssembleJobsContextOptions {\n readonly skipTypedOutputRehydration?: boolean;\n readonly skipCelNativeRehydration?: boolean;\n}\n\nexport interface AssembleWorkflowRunContextParams {\n readonly run: Pick<\n WorkflowRun,\n | 'id'\n | 'number'\n | 'name'\n | 'workflowName'\n | 'definitionId'\n | 'projectId'\n | 'workspaceId'\n | 'createdAt'\n > & {readonly triggerReference?: WorkflowRunTriggerReference | null | undefined};\n readonly triggerPayload: TriggerPayload;\n readonly inputs?: Record<string, unknown> | null | undefined;\n readonly vars?: Record<string, string> | undefined;\n}\n\ninterface AssembleContextOptions extends AssembleJobsContextOptions {}\n\nexport function assembleWorkflowRunContext(\n params: AssembleWorkflowRunContextParams,\n options: AssembleContextOptions = {},\n): WorkflowExpressionEvaluationContext {\n const triggerReference = params.run.triggerReference;\n return {\n workflow: {\n id: params.run.definitionId,\n name: params.run.workflowName,\n },\n run: {\n id: params.run.id,\n number:\n options.skipCelNativeRehydration === true ? params.run.number : BigInt(params.run.number),\n name: params.run.name,\n project_id: params.run.projectId,\n workspace_id: params.run.workspaceId,\n created_at: params.run.createdAt,\n },\n trigger: {\n source: params.triggerPayload.source,\n event: params.triggerPayload.event,\n project: triggerReference?.project ?? null,\n repository: triggerReference?.repository ?? null,\n ref: triggerReference?.ref ?? null,\n commit: triggerReference?.commit ?? null,\n },\n event: 'data' in params.triggerPayload ? params.triggerPayload.data : null,\n inputs: params.inputs ?? null,\n ...(params.vars === undefined ? {} : {vars: params.vars}),\n };\n}\n\nexport function assembleCreationContext(\n params: AssembleWorkflowRunContextParams,\n): WorkflowEvaluationContext {\n return {\n site: 'run-creation',\n values: assembleWorkflowRunContext(params),\n };\n}\n\nexport interface AssembleExecutionCreationContextParams extends AssembleWorkflowRunContextParams {\n readonly job: Pick<Job, 'id' | 'key' | 'name'>;\n readonly sequence: number;\n readonly nameOverride: string | null;\n readonly executionName: string;\n readonly status: JobExecution['status'];\n readonly triggerEvents: readonly JobExecution['triggerEvents'][number][];\n readonly priorExecutions: readonly JobExecution[];\n}\n\nexport function assembleExecutionCreationContext(\n params: AssembleExecutionCreationContextParams,\n): WorkflowEvaluationContext {\n const execution: JobExecution = {\n id: `${params.job.id}:${params.sequence}`,\n jobId: params.job.id,\n sequence: params.sequence,\n nameOverride: params.nameOverride,\n name: params.executionName,\n runner: null,\n status: params.status,\n statusReason: null,\n triggerEvents: [...params.triggerEvents],\n outputs: null,\n version: 1,\n createdAt: new Date(),\n updatedAt: new Date(),\n queuedAt: null,\n startedAt: null,\n finishedAt: null,\n timedOutAt: null,\n };\n const executions = assembleExecutionsContext([...params.priorExecutions, execution]);\n const executionValues = executions.executions as unknown[];\n return {\n site: 'execution-creation',\n values: {\n ...assembleWorkflowRunContext(params),\n ...executions,\n job: {key: params.job.key, name: params.job.name ?? params.job.key},\n execution: executionValues.at(-1),\n },\n };\n}\n\n/**\n * Keeps job-success predicate values aligned with the registry's `executions`\n * type environment.\n */\nexport function assembleExecutionsContext(\n executions: readonly JobExecution[],\n outputTypes?: Readonly<Record<string, ExpressionType>>,\n options: AssembleContextOptions = {},\n): WorkflowExpressionEvaluationContext {\n return {\n executions: executions.map((execution, index) =>\n assembleExecutionContext(execution, index, outputTypes, options),\n ),\n };\n}\n\nfunction assembleExecutionContext(\n execution: JobExecution,\n index: number,\n outputTypes?: Readonly<Record<string, ExpressionType>>,\n options: AssembleContextOptions = {},\n): Record<string, unknown> {\n const skipCelNativeRehydration = options.skipCelNativeRehydration === true;\n return {\n index: skipCelNativeRehydration ? index : BigInt(index),\n name: execution.name,\n status: execution.status,\n started_at: execution.startedAt,\n finished_at: execution.finishedAt,\n events: skipCelNativeRehydration\n ? execution.triggerEvents\n : execution.triggerEvents.map(assembleExecutionEventContext),\n outputs:\n options.skipTypedOutputRehydration === true\n ? (execution.outputs ?? {})\n : rehydrateJsonExpressionRecord(execution.outputs, outputTypes),\n };\n}\n\nfunction assembleExecutionEventContext(event: WorkflowExecutionEvent): Record<string, unknown> {\n const receivedAt = new Date(event.received_at);\n /**\n * An unparseable stored timestamp would become an `Invalid Date`, which compares\n * false against every CEL `timestamp` and throws on `toISOString` during template\n * resolution. Keeping the raw value fails loudly as a type mismatch instead.\n */\n if (Number.isNaN(receivedAt.getTime())) return {...event};\n\n return {\n ...event,\n received_at: receivedAt,\n };\n}\n\nexport function assembleJobsContext(\n jobs: readonly JobContextInput[],\n options: AssembleJobsContextOptions = {},\n): WorkflowExpressionEvaluationContext & {readonly jobs: Record<string, unknown>} {\n return {\n jobs: Object.fromEntries(\n jobs.map((input) => [input.job.key, assembleJobContext(input, options)]),\n ),\n };\n}\n\nexport interface AssembleJobActivationContextParams extends AssembleWorkflowRunContextParams {\n readonly jobs: readonly JobContextInput[];\n}\n\nexport function assembleJobActivationContext(\n params: AssembleJobActivationContextParams,\n): WorkflowEvaluationContext {\n return {\n site: 'job-activation',\n values: {\n ...assembleWorkflowRunContext(params),\n ...assembleJobsContext(params.jobs),\n needs: params.jobs.map((input) => assembleJobContext(input, {})),\n vars: params.vars ?? {},\n },\n };\n}\n\ntype ListenerPredicateField = 'listener.on' | 'listener.until';\ntype ListenerSnapshotRoot = Exclude<WorkflowPredicateContextRoot<ListenerPredicateField>, 'event'>;\n\nexport interface MatcherSnapshotPlan {\n readonly matcher: JobListeningTrigger;\n readonly roots: ReadonlySet<ListenerSnapshotRoot>;\n readonly jobKeys: ReadonlySet<string>;\n}\n\nexport interface ListenerSnapshotPlan {\n readonly on: readonly MatcherSnapshotPlan[];\n readonly until: readonly MatcherSnapshotPlan[];\n readonly roots: ReadonlySet<ListenerSnapshotRoot>;\n readonly jobKeys: ReadonlySet<string>;\n}\n\nexport type ListenerFilterOutputTypes = Record<string, Record<string, ExpressionType>>;\n\nexport function planListenerFilterSnapshots(params: {\n readonly on: readonly JobListeningTrigger[];\n readonly until: readonly JobListeningTrigger[] | null;\n}): ListenerSnapshotPlan {\n const roots = new Set<ListenerSnapshotRoot>();\n const jobKeys = new Set<string>();\n const on = params.on.map((matcher) =>\n planMatcherFilterSnapshot('listener.on', matcher, roots, jobKeys),\n );\n const until = (params.until ?? []).map((matcher) =>\n planMatcherFilterSnapshot('listener.until', matcher, roots, jobKeys),\n );\n return {on, until, roots, jobKeys};\n}\n\nfunction planMatcherFilterSnapshot(\n field: ListenerPredicateField,\n matcher: JobListeningTrigger,\n allRoots: Set<ListenerSnapshotRoot>,\n allJobKeys: Set<string>,\n): MatcherSnapshotPlan {\n if (matcher.filter === undefined) return {matcher, roots: new Set(), jobKeys: new Set()};\n\n let roots: ListenerSnapshotRoot[];\n try {\n roots = extractExactContextRoots(matcher.filter).filter((root) =>\n isListenerSnapshotRoot(field, root),\n );\n } catch {\n return {matcher, roots: new Set(), jobKeys: new Set()};\n }\n\n if (roots.length === 0) return {matcher, roots: new Set(), jobKeys: new Set()};\n\n const jobKeys =\n roots.includes('jobs') && matcher.filter !== undefined\n ? new Set(\n analyzeContextRootKeyAccess(matcher.filter, ['jobs']).references.map(\n (reference) => reference.key,\n ),\n )\n : new Set<string>();\n for (const root of roots) allRoots.add(root);\n for (const key of jobKeys) allJobKeys.add(key);\n return {matcher, roots: new Set(roots), jobKeys};\n}\n\nfunction isListenerSnapshotRoot(\n field: ListenerPredicateField,\n root: string,\n): root is ListenerSnapshotRoot {\n return (\n root !== 'event' &&\n getWorkflowPredicateContextRoots(field).includes(\n root as WorkflowPredicateContextRoot<ListenerPredicateField>,\n )\n );\n}\n\nexport function assembleListenerSnapshotContext(params: {\n readonly job: Pick<Job, 'key'> & Partial<Pick<Job, 'name'>>;\n readonly run: AssembleWorkflowRunContextParams['run'];\n readonly triggerPayload: TriggerPayload;\n readonly inputs?: Record<string, unknown> | null | undefined;\n readonly vars?: Record<string, string> | undefined;\n readonly plan: ListenerSnapshotPlan;\n readonly dependencyJobs: readonly JobContextInput[];\n}): WorkflowExpressionEvaluationContext {\n const context: Record<string, unknown> = {};\n if (\n params.plan.roots.has('workflow') ||\n params.plan.roots.has('run') ||\n params.plan.roots.has('trigger')\n ) {\n const runContext = assembleWorkflowRunContext(\n {\n run: params.run,\n triggerPayload: params.triggerPayload,\n inputs: params.inputs,\n vars: params.vars,\n },\n {skipCelNativeRehydration: true},\n );\n if (params.plan.roots.has('workflow')) context.workflow = runContext.workflow;\n if (params.plan.roots.has('run')) context.run = runContext.run;\n if (params.plan.roots.has('trigger')) context.trigger = runContext.trigger;\n }\n\n if (params.plan.roots.has('inputs')) {\n context.inputs = params.inputs ?? null;\n }\n if (params.plan.roots.has('vars')) {\n context.vars = params.vars ?? {};\n }\n if (params.plan.roots.has('job')) {\n context.job = {\n key: params.job.key,\n ...(params.job.name === undefined ? {} : {name: params.job.name ?? params.job.key}),\n };\n }\n if (params.plan.roots.has('jobs')) {\n context.jobs = requestedJobsContext(params.dependencyJobs, params.plan.jobKeys);\n }\n\n return context;\n}\n\nfunction requestedJobsContext(\n dependencyJobs: readonly JobContextInput[],\n jobKeys: ReadonlySet<string>,\n): Record<string, unknown> {\n // Listener snapshots cross a JSON outbox boundary; their type metadata is persisted separately.\n const options: AssembleJobsContextOptions = {\n skipCelNativeRehydration: true,\n skipTypedOutputRehydration: true,\n };\n if (jobKeys.size === 0) {\n return assembleJobsContext(dependencyJobs, options).jobs;\n }\n\n const filtered = dependencyJobs.filter(({job}) => jobKeys.has(job.key));\n\n return assembleJobsContext(filtered, options).jobs;\n}\n\nexport type ListenerTriggerWithSnapshot = JobListeningTrigger & {\n readonly filter_snapshot?: Record<string, unknown>;\n readonly filter_output_types?: ListenerFilterOutputTypes;\n};\n\nexport function applyListenerFilterSnapshots(\n plans: readonly MatcherSnapshotPlan[],\n context: WorkflowExpressionEvaluationContext,\n outputTypes?: ListenerFilterOutputTypes,\n): ListenerTriggerWithSnapshot[] {\n return plans.map((plan) => {\n const filterSnapshot = filterSnapshotForPlan(plan, context);\n if (filterSnapshot === undefined) return plan.matcher;\n\n const filterOutputTypes = filterOutputTypesForPlan(plan, context, outputTypes);\n\n return {\n ...plan.matcher,\n filter_snapshot: filterSnapshot,\n ...(filterOutputTypes === undefined ? {} : {filter_output_types: filterOutputTypes}),\n };\n });\n}\n\nexport function listenerFilterOutputTypesForJobs(\n jobs: readonly JobContextInput[],\n): ListenerFilterOutputTypes {\n return Object.fromEntries(\n jobs.flatMap(({job, outputTypes}) =>\n outputTypes === undefined ? [] : [[job.key, {...outputTypes}] as const],\n ),\n );\n}\n\nfunction filterOutputTypesForPlan(\n plan: MatcherSnapshotPlan,\n context: WorkflowExpressionEvaluationContext,\n outputTypes: ListenerFilterOutputTypes | undefined,\n): ListenerFilterOutputTypes | undefined {\n if (outputTypes === undefined || !plan.roots.has('jobs')) return undefined;\n\n const jobsSnapshot = jobsSnapshotForPlan(plan, context);\n if (jobsSnapshot === undefined) return undefined;\n\n const entries = Object.keys(jobsSnapshot).flatMap((jobKey) => {\n const types = outputTypes[jobKey];\n return types === undefined ? [] : [[jobKey, {...types}] as const];\n });\n return entries.length === 0 ? undefined : Object.fromEntries(entries);\n}\n\nfunction filterSnapshotForPlan(\n plan: MatcherSnapshotPlan,\n context: WorkflowExpressionEvaluationContext,\n): Record<string, unknown> | undefined {\n const snapshot: Record<string, unknown> = {};\n for (const root of plan.roots) {\n if (root === 'jobs') {\n const jobsSnapshot = jobsSnapshotForPlan(plan, context);\n if (jobsSnapshot !== undefined) snapshot.jobs = jobsSnapshot;\n continue;\n }\n\n if (root in context) snapshot[root] = context[root];\n }\n\n return Object.keys(snapshot).length === 0 ? undefined : snapshot;\n}\n\nfunction jobsSnapshotForPlan(\n plan: MatcherSnapshotPlan,\n context: WorkflowExpressionEvaluationContext,\n): Record<string, unknown> | undefined {\n if (typeof context.jobs !== 'object' || context.jobs === null) {\n return undefined;\n }\n\n const jobsContext = context.jobs as Record<string, unknown>;\n if (plan.jobKeys.size === 0) return {...jobsContext};\n\n const snapshot = Object.fromEntries(\n [...plan.jobKeys].flatMap((key) =>\n Object.hasOwn(jobsContext, key) ? [[key, jobsContext[key]]] : [],\n ),\n );\n return snapshot;\n}\n\nfunction assembleJobContext(\n {job, outputTypes, executions}: JobContextInput,\n options: AssembleJobsContextOptions,\n): Record<string, unknown> {\n const outputs =\n options.skipTypedOutputRehydration === true\n ? (job.outputs ?? {})\n : rehydrateJsonExpressionRecord(job.outputs, outputTypes);\n\n return {\n key: job.key,\n status: job.status,\n outputs,\n executions: assembleExecutionsContext(\n executions,\n options.skipTypedOutputRehydration === true ? undefined : outputTypes,\n options,\n ).executions,\n };\n}\n\nfunction assembleStepsContext(params: {\n readonly steps: readonly Step[];\n readonly attempts: readonly StepAttempt[];\n}): Record<string, Record<string, unknown>> {\n return buildStepAttemptContext(params).stepsContext;\n}\n\nfunction buildStepAttemptContext(params: {\n readonly steps: readonly Step[];\n readonly attempts: readonly StepAttempt[];\n}): {\n readonly stepsContext: Record<string, Record<string, unknown>>;\n readonly stepsFailed: boolean;\n readonly orderedAttempts: readonly StepAttempt[];\n readonly stepsByKey: ReadonlyMap<string, Step>;\n readonly terminalAttemptsByStepId: ReadonlyMap<string, readonly StepAttempt[]>;\n} {\n const stepsByKey = new Map(\n params.steps.flatMap((step) => (step.key === null ? [] : [[step.key, step] as const])),\n );\n const terminalAttemptsByStepId = new Map<string, StepAttempt[]>();\n const orderedAttempts = [...params.attempts].sort(\n (left, right) => left.executionOrder - right.executionOrder,\n );\n\n for (const attempt of orderedAttempts) {\n if (attempt.status === 'running') continue;\n const attemptsForStep = terminalAttemptsByStepId.get(attempt.stepId) ?? [];\n attemptsForStep.push(attempt);\n terminalAttemptsByStepId.set(attempt.stepId, attemptsForStep);\n }\n\n const stepsContext: Record<string, Record<string, unknown>> = {};\n\n for (const step of params.steps) {\n if (step.key === null) continue;\n const attempts = terminalAttemptsByStepId.get(step.id) ?? [];\n const latestAttempt = attempts.at(-1);\n stepsContext[step.key] = {\n status: step.status,\n ...(latestAttempt === undefined ? {} : latestAttemptFields(latestAttempt)),\n attempts: attempts.map(attemptFields),\n };\n }\n\n return {\n stepsContext,\n stepsFailed: params.steps.some((step) => step.status === 'failed'),\n orderedAttempts,\n stepsByKey,\n terminalAttemptsByStepId,\n };\n}\n\nexport function assembleStepDispatchContext(params: {\n readonly steps: readonly Step[];\n readonly attempts: readonly StepAttempt[];\n readonly targetStepId: string;\n readonly jobExecution?: JobExecution;\n readonly jobs?: readonly JobContextInput[];\n readonly vars?: Record<string, string> | undefined;\n}): WorkflowEvaluationContext {\n const targetStep = params.steps.find((step) => step.id === params.targetStepId);\n const stepAttemptContext = buildStepAttemptContext(params);\n const restart =\n targetStep === undefined || targetStep.currentAttempt <= 1\n ? undefined\n : restartProvenance({\n targetStep,\n orderedAttempts: stepAttemptContext.orderedAttempts,\n stepsByKey: stepAttemptContext.stepsByKey,\n terminalAttemptsByStepId: stepAttemptContext.terminalAttemptsByStepId,\n });\n\n return {\n site: 'step-dispatch',\n values: {\n vars: params.vars ?? {},\n ...assembleJobsContext(params.jobs ?? []),\n ...(params.jobExecution === undefined\n ? {}\n : {\n execution: {\n ...assembleExecutionContext(params.jobExecution, params.jobExecution.sequence - 1),\n failed: stepAttemptContext.stepsFailed,\n },\n }),\n ...(targetStep === undefined\n ? {}\n : {\n step: {\n attempt: BigInt(targetStep.currentAttempt),\n is_retry: targetStep.currentAttempt > 1,\n ...(restart === undefined ? {} : {restart}),\n },\n }),\n steps: stepAttemptContext.stepsContext,\n },\n };\n}\n\nfunction restartProvenance(params: {\n readonly targetStep: Step;\n readonly orderedAttempts: readonly StepAttempt[];\n readonly stepsByKey: ReadonlyMap<string, Step>;\n readonly terminalAttemptsByStepId: ReadonlyMap<string, readonly StepAttempt[]>;\n}): Record<string, unknown> | undefined {\n for (const attempt of [...params.orderedAttempts].reverse()) {\n if (attempt.status !== 'failed' || attempt.restartFeedback === null) continue;\n const restartFromKey = restartFromStepKey(attempt);\n if (restartFromKey === undefined) continue;\n\n const restartFromStep = params.stepsByKey.get(restartFromKey);\n if (restartFromStep === undefined || restartFromStep.position > params.targetStep.position) {\n continue;\n }\n\n const gatingAttempts = params.terminalAttemptsByStepId.get(attempt.stepId) ?? [];\n return {\n from: {\n ...attemptFields(attempt),\n attempts: gatingAttempts.map(attemptFields),\n },\n feedback: attempt.restartFeedback,\n };\n }\n\n return undefined;\n}\n\nfunction restartFromStepKey(attempt: StepAttempt): string | undefined {\n const gate = attempt.config?.gate;\n if (gate === null || typeof gate !== 'object') return undefined;\n const onFailure = (gate as Record<string, unknown>).on_failure;\n if (onFailure === null || typeof onFailure !== 'object') return undefined;\n const restartFrom = (onFailure as Record<string, unknown>).restart_from;\n return typeof restartFrom === 'string' ? restartFrom : undefined;\n}\n\nfunction attemptFields(attempt: StepAttempt): Record<string, unknown> {\n return {\n status: attempt.status,\n outputs: attempt.output ?? {},\n ...(attempt.response === null ? {} : {response: attempt.response}),\n ...(attempt.exitCode === null ? {} : {exit_code: BigInt(attempt.exitCode)}),\n ...(attempt.gateResult === null ? {} : {gate: attempt.gateResult}),\n };\n}\n\nfunction latestAttemptFields(attempt: StepAttempt): Record<string, unknown> {\n const fields = attemptFields(attempt);\n delete fields.status;\n return fields;\n}\n\nexport function assembleGateContext(params: {\n readonly status: StepStatus;\n readonly exitCode: number | null;\n readonly output?: Record<string, unknown> | null | undefined;\n readonly vars?: Record<string, string> | undefined;\n}): WorkflowEvaluationContext {\n return {\n site: 'step-report',\n values: {\n vars: params.vars ?? {},\n step: {\n ...(params.exitCode === null ? {} : {exit_code: BigInt(params.exitCode)}),\n status: params.status,\n outputs: params.output ?? {},\n },\n },\n };\n}\n\nexport function assembleJobResolutionContext(params: {\n readonly executions: readonly JobExecution[];\n readonly jobs: readonly JobContextInput[];\n readonly vars?: Record<string, string> | undefined;\n}): WorkflowEvaluationContext {\n return {\n site: 'job-resolution',\n values: {\n ...assembleExecutionsContext(params.executions),\n ...assembleJobsContext(params.jobs),\n vars: params.vars ?? {},\n },\n };\n}\n\nexport function assembleExecutionResolutionContext(params: {\n readonly run: AssembleWorkflowRunContextParams['run'];\n readonly triggerPayload: TriggerPayload;\n readonly inputs?: Record<string, unknown> | null | undefined;\n readonly vars?: Record<string, string> | undefined;\n readonly job: Pick<Job, 'key'> & Partial<Pick<Job, 'name'>>;\n readonly jobExecution: JobExecution;\n readonly executions: readonly JobExecution[];\n readonly steps: readonly Step[];\n readonly attempts: readonly StepAttempt[];\n readonly jobs?: readonly JobContextInput[];\n}): WorkflowEvaluationContext {\n const executions = assembleExecutionsContext(params.executions);\n const executionIndex = params.executions.findIndex(\n (execution) => execution.id === params.jobExecution.id,\n );\n\n return {\n site: 'execution-resolution',\n values: {\n ...assembleWorkflowRunContext(params),\n ...executions,\n ...(params.jobs === undefined ? {} : assembleJobsContext(params.jobs)),\n execution: assembleExecutionContext(\n params.jobExecution,\n executionIndex < 0 ? params.jobExecution.sequence - 1 : executionIndex,\n ),\n job: {\n key: params.job.key,\n ...(params.job.name === undefined ? {} : {name: params.job.name ?? params.job.key}),\n },\n steps: assembleStepsContext({steps: params.steps, attempts: params.attempts}),\n },\n };\n}\n"],"names":["analyzeContextRootKeyAccess","extractExactContextRoots","getWorkflowPredicateContextRoots","rehydrateJsonExpressionRecord","assembleWorkflowRunContext","params","options","triggerReference","run","workflow","id","definitionId","name","workflowName","number","skipCelNativeRehydration","BigInt","project_id","projectId","workspace_id","workspaceId","created_at","createdAt","trigger","source","triggerPayload","event","project","repository","ref","commit","data","inputs","vars","undefined","assembleCreationContext","site","values","assembleExecutionCreationContext","execution","job","sequence","jobId","nameOverride","executionName","runner","status","statusReason","triggerEvents","outputs","version","Date","updatedAt","queuedAt","startedAt","finishedAt","timedOutAt","executions","assembleExecutionsContext","priorExecutions","executionValues","key","at","outputTypes","map","index","assembleExecutionContext","started_at","finished_at","events","assembleExecutionEventContext","skipTypedOutputRehydration","receivedAt","received_at","Number","isNaN","getTime","assembleJobsContext","jobs","Object","fromEntries","input","assembleJobContext","assembleJobActivationContext","needs","planListenerFilterSnapshots","roots","Set","jobKeys","on","matcher","planMatcherFilterSnapshot","until","field","allRoots","allJobKeys","filter","root","isListenerSnapshotRoot","length","includes","references","reference","add","assembleListenerSnapshotContext","context","plan","has","runContext","requestedJobsContext","dependencyJobs","size","filtered","applyListenerFilterSnapshots","plans","filterSnapshot","filterSnapshotForPlan","filterOutputTypes","filterOutputTypesForPlan","filter_snapshot","filter_output_types","listenerFilterOutputTypesForJobs","flatMap","jobsSnapshot","jobsSnapshotForPlan","entries","keys","jobKey","types","snapshot","jobsContext","hasOwn","assembleStepsContext","buildStepAttemptContext","stepsContext","stepsByKey","Map","steps","step","terminalAttemptsByStepId","orderedAttempts","attempts","sort","left","right","executionOrder","attempt","attemptsForStep","get","stepId","push","set","latestAttempt","latestAttemptFields","attemptFields","stepsFailed","some","assembleStepDispatchContext","targetStep","find","targetStepId","stepAttemptContext","restart","currentAttempt","restartProvenance","jobExecution","failed","is_retry","reverse","restartFeedback","restartFromKey","restartFromStepKey","restartFromStep","position","gatingAttempts","from","feedback","gate","config","onFailure","on_failure","restartFrom","restart_from","output","response","exitCode","exit_code","gateResult","fields","assembleGateContext","assembleJobResolutionContext","assembleExecutionResolutionContext","executionIndex","findIndex"],"mappings":"AAAA,SACEA,2BAA2B,EAE3BC,wBAAwB,EACxBC,gCAAgC,EAChCC,6BAA6B,QAGxB,sBAAsB;AAyC7B,OAAO,SAASC,2BACdC,MAAwC,EACxCC,UAAkC,CAAC,CAAC;IAEpC,MAAMC,mBAAmBF,OAAOG,GAAG,CAACD,gBAAgB;IACpD,OAAO;QACLE,UAAU;YACRC,IAAIL,OAAOG,GAAG,CAACG,YAAY;YAC3BC,MAAMP,OAAOG,GAAG,CAACK,YAAY;QAC/B;QACAL,KAAK;YACHE,IAAIL,OAAOG,GAAG,CAACE,EAAE;YACjBI,QACER,QAAQS,wBAAwB,KAAK,OAAOV,OAAOG,GAAG,CAACM,MAAM,GAAGE,OAAOX,OAAOG,GAAG,CAACM,MAAM;YAC1FF,MAAMP,OAAOG,GAAG,CAACI,IAAI;YACrBK,YAAYZ,OAAOG,GAAG,CAACU,SAAS;YAChCC,cAAcd,OAAOG,GAAG,CAACY,WAAW;YACpCC,YAAYhB,OAAOG,GAAG,CAAC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AIP,OAAOmC,GAAG,CAACqB,GAAG;gBAAA,CAAC;YACpF;YACA4E,OAAOL,qBAAqB;gBAACK,OAAOpI,OAAOoI,KAAK;gBAAEI,UAAUxI,OAAOwI,QAAQ;YAAA;QAC7E;IACF;AACF"}
@@ -25,10 +25,15 @@ export declare function freezeStepField(params: ResolveStepFieldParams): {
25
25
  readonly trace: SiteResolvedField['trace'];
26
26
  };
27
27
  export declare function completeStepField(params: ResolveStepFieldParams): string;
28
+ export declare function completeStepFieldWithType(params: ResolveStepFieldParams): unknown;
28
29
  export declare function completeStepFieldWithTrace(params: ResolveStepFieldParams): {
29
30
  readonly value: string;
30
31
  readonly trace: SiteResolvedField['trace'];
31
32
  };
33
+ export declare function completeStepFieldWithTypeAndTrace(params: ResolveStepFieldParams): {
34
+ readonly value: unknown;
35
+ readonly trace: SiteResolvedField<unknown>['trace'];
36
+ };
32
37
  export declare function stepConfigInterpolationError(params: {
33
38
  readonly definitionId: string;
34
39
  readonly errorField: InterpolationUnresolvableField;
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/core/step-config/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EAGzB,KAAK,aAAa,EAElB,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,+BAA+B,EAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,8BAA8B,EAAE,KAAK,8BAA8B,EAAC,MAAM,iBAAiB,CAAC;AACpG,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,kCAAkC,CAAC;AAEhF,MAAM,MAAM,eAAe,GAAG,8BAA8B,CAAC;AAE7D,MAAM,WAAW,8BAA+B,SAAQ,0BAA0B;IAChF,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,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C,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACvD,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;CAC5C,CAcA;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAExE;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAEjF;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,sBAAsB,GAAG;IAC1E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;CAC5C,CAEA;AAED,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,sBAAsB,GAAG;IACjF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;CACrD,CAEA;AAiBD,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE;IACN,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,8BAA8B,CAAC;IACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,EACD,KAAK,EAAE,+BAA+B,GAAG,2BAA2B,GACnE,8BAA8B,CAOhC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAEzD"}
@@ -1,13 +1,23 @@
1
1
  import { freezeResolvedFieldAtSite, getWorkflowInterpolationFieldFailurePolicy, resolveFieldAtSite, WorkflowTemplateResolutionError } from '@shipfox/expression';
2
2
  import { InterpolationUnresolvableError } from '#core/errors.js';
3
3
  export function resolveStepField(params) {
4
+ return resolveStepFieldAtSite(params, false);
5
+ }
6
+ function resolveStepFieldWithType(params) {
7
+ return resolveStepFieldAtSite(params, true);
8
+ }
9
+ function resolveStepFieldAtSite(params, preserveSingleExpressionType) {
4
10
  try {
5
- return resolveFieldAtSite({
11
+ const resolveParams = {
6
12
  field: params.template,
7
13
  context: params.context.values,
8
14
  site: params.context.site,
9
15
  failurePolicy: getWorkflowInterpolationFieldFailurePolicy(params.field)
10
- });
16
+ };
17
+ return preserveSingleExpressionType ? resolveFieldAtSite({
18
+ ...resolveParams,
19
+ preserveSingleExpressionType: true
20
+ }) : resolveFieldAtSite(resolveParams);
11
21
  } catch (error) {
12
22
  if (error instanceof WorkflowTemplateResolutionError) {
13
23
  throw stepConfigInterpolationError(params, error);
@@ -33,8 +43,16 @@ export function freezeStepField(params) {
33
43
  export function completeStepField(params) {
34
44
  return completeStepFieldWithTrace(params).value;
35
45
  }
46
+ export function completeStepFieldWithType(params) {
47
+ return completeStepFieldWithTypeAndTrace(params).value;
48
+ }
36
49
  export function completeStepFieldWithTrace(params) {
37
- const resolved = resolveStepField(params);
50
+ return completeResolvedStepField(params, resolveStepField(params));
51
+ }
52
+ export function completeStepFieldWithTypeAndTrace(params) {
53
+ return completeResolvedStepField(params, resolveStepFieldWithType(params));
54
+ }
55
+ function completeResolvedStepField(params, resolved) {
38
56
  if (resolved.kind === 'frozen') return {
39
57
  value: resolved.value,
40
58
  trace: resolved.trace
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/step-config/fields.ts"],"sourcesContent":["import {\n type EvaluationTraceEntry,\n freezeResolvedFieldAtSite,\n getWorkflowInterpolationFieldFailurePolicy,\n type ResolvedField,\n resolveFieldAtSite,\n type SiteResolvedField,\n type UnsafeRunInterpolationError,\n type WorkflowInterpolationField,\n type WorkflowTemplateDiagnostic,\n WorkflowTemplateResolutionError,\n} from '@shipfox/expression';\nimport {InterpolationUnresolvableError, type InterpolationUnresolvableField} from '#core/errors.js';\nimport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n\nexport type StepConfigField = InterpolationUnresolvableField;\n\nexport interface WorkflowStepTemplateDiagnostic extends WorkflowTemplateDiagnostic {\n readonly field: StepConfigField;\n readonly envKey?: string;\n}\n\nexport interface WorkflowStepEvaluationTraceEntry extends EvaluationTraceEntry {\n readonly field: StepConfigField;\n readonly envKey?: string;\n}\n\nexport interface ResolveStepFieldParams {\n readonly field: WorkflowInterpolationField;\n readonly template: ResolvedField;\n readonly context: WorkflowEvaluationContext;\n readonly definitionId: string;\n readonly errorField: InterpolationUnresolvableField;\n readonly envKey?: string;\n}\n\nexport function resolveStepField(params: ResolveStepFieldParams): SiteResolvedField {\n try {\n return resolveFieldAtSite({\n field: params.template,\n context: params.context.values,\n site: params.context.site,\n failurePolicy: getWorkflowInterpolationFieldFailurePolicy(params.field),\n });\n } catch (error) {\n if (error instanceof WorkflowTemplateResolutionError) {\n throw stepConfigInterpolationError(params, error);\n }\n throw error;\n }\n}\n\nexport function freezeStepField(params: ResolveStepFieldParams): {\n readonly value: string;\n readonly diagnostics: SiteResolvedField['diagnostics'];\n readonly trace: SiteResolvedField['trace'];\n} {\n try {\n return freezeResolvedFieldAtSite({\n field: params.template,\n context: params.context.values,\n site: params.context.site,\n failurePolicy: getWorkflowInterpolationFieldFailurePolicy(params.field),\n });\n } catch (error) {\n if (error instanceof WorkflowTemplateResolutionError) {\n throw stepConfigInterpolationError(params, error);\n }\n throw error;\n }\n}\n\nexport function completeStepField(params: ResolveStepFieldParams): string {\n return completeStepFieldWithTrace(params).value;\n}\n\nexport function completeStepFieldWithTrace(params: ResolveStepFieldParams): {\n readonly value: string;\n readonly trace: SiteResolvedField['trace'];\n} {\n const resolved = resolveStepField(params);\n if (resolved.kind === 'frozen') return {value: resolved.value, trace: resolved.trace};\n\n const source = resolved.field.segments.find((segment) => segment.kind === 'deferred')?.expression\n .source;\n throw new InterpolationUnresolvableError(params.definitionId, {\n field: params.errorField,\n source: source ?? params.field,\n ...(params.envKey === undefined ? {} : {envKey: params.envKey}),\n });\n}\n\nexport function stepConfigInterpolationError(\n params: {\n readonly definitionId: string;\n readonly errorField: InterpolationUnresolvableField;\n readonly envKey?: string;\n },\n error: WorkflowTemplateResolutionError | UnsafeRunInterpolationError,\n): InterpolationUnresolvableError {\n return new InterpolationUnresolvableError(params.definitionId, {\n field: params.errorField,\n source: error.source,\n ...(params.envKey === undefined ? {} : {envKey: params.envKey}),\n cause: error,\n });\n}\n\nexport function literalField(value: string): ResolvedField {\n return {segments: [{kind: 'literal', value}]};\n}\n"],"names":["freezeResolvedFieldAtSite","getWorkflowInterpolationFieldFailurePolicy","resolveFieldAtSite","WorkflowTemplateResolutionError","InterpolationUnresolvableError","resolveStepField","params","field","template","context","values","site","failurePolicy","error","stepConfigInterpolationError","freezeStepField","completeStepField","completeStepFieldWithTrace","value","resolved","kind","trace","source","segments","find","segment","expression","definitionId","errorField","envKey","undefined","cause","literalField"],"mappings":"AAAA,SAEEA,yBAAyB,EACzBC,0CAA0C,EAE1CC,kBAAkB,EAKlBC,+BAA+B,QAC1B,sBAAsB;AAC7B,SAAQC,8BAA8B,QAA4C,kBAAkB;AAwBpG,OAAO,SAASC,iBAAiBC,MAA8B;IAC7D,IAAI;QACF,OAAOJ,mBAAmB;YACxBK,OAAOD,OAAOE,QAAQ;YACtBC,SAASH,OAAOG,OAAO,CAACC,MAAM;YAC9BC,MAAML,OAAOG,OAAO,CAACE,IAAI;YACzBC,eAAeX,2CAA2CK,OAAOC,KAAK;QACxE;IACF,EAAE,OAAOM,OAAO;QACd,IAAIA,iBAAiBV,iCAAiC;YACpD,MAAMW,6BAA6BR,QAAQO;QAC7C;QACA,MAAMA;IACR;AACF;AAEA,OAAO,SAASE,gBAAgBT,MAA8B;IAK5D,IAAI;QACF,OAAON,0BAA0B;YAC/BO,OAAOD,OAAOE,QAAQ;YACtBC,SAASH,OAAOG,OAAO,CAACC,MAAM;YAC9BC,MAAML,OAAOG,OAAO,CAACE,IAAI;YACzBC,eAAeX,2CAA2CK,OAAOC,KAAK;QACxE;IACF,EAAE,OAAOM,OAAO;QACd,IAAIA,iBAAiBV,iCAAiC;YACpD,MAAMW,6BAA6BR,QAAQO;QAC7C;QACA,MAAMA;IACR;AACF;AAEA,OAAO,SAASG,kBAAkBV,MAA8B;IAC9D,OAAOW,2BAA2BX,QAAQY,KAAK;AACjD;AAEA,OAAO,SAASD,2BAA2BX,MAA8B;IAIvE,MAAMa,WAAWd,iBAAiBC;IAClC,IAAIa,SAASC,IAAI,KAAK,UAAU,OAAO;QAACF,OAAOC,SAASD,KAAK;QAAEG,OAAOF,SAASE,KAAK;IAAA;IAEpF,MAAMC,SAASH,SAASZ,KAAK,CAACgB,QAAQ,CAACC,IAAI,CAAC,CAACC,UAAYA,QAAQL,IAAI,KAAK,aAAaM,WACpFJ;IACH,MAAM,IAAIlB,+BAA+BE,OAAOqB,YAAY,EAAE;QAC5DpB,OAAOD,OAAOsB,UAAU;QACxBN,QAAQA,UAAUhB,OAAOC,KAAK;QAC9B,GAAID,OAAOuB,MAAM,KAAKC,YAAY,CAAC,IAAI;YAACD,QAAQvB,OAAOuB,MAAM;QAAA,CAAC;IAChE;AACF;AAEA,OAAO,SAASf,6BACdR,MAIC,EACDO,KAAoE;IAEpE,OAAO,IAAIT,+BAA+BE,OAAOqB,YAAY,EAAE;QAC7DpB,OAAOD,OAAOsB,UAAU;QACxBN,QAAQT,MAAMS,MAAM;QACpB,GAAIhB,OAAOuB,MAAM,KAAKC,YAAY,CAAC,IAAI;YAACD,QAAQvB,OAAOuB,MAAM;QAAA,CAAC;QAC9DE,OAAOlB;IACT;AACF;AAEA,OAAO,SAASmB,aAAad,KAAa;IACxC,OAAO;QAACK,UAAU;YAAC;gBAACH,MAAM;gBAAWF;YAAK;SAAE;IAAA;AAC9C"}
1
+ {"version":3,"sources":["../../../src/core/step-config/fields.ts"],"sourcesContent":["import {\n type EvaluationTraceEntry,\n freezeResolvedFieldAtSite,\n getWorkflowInterpolationFieldFailurePolicy,\n type ResolvedField,\n resolveFieldAtSite,\n type SiteResolvedField,\n type UnsafeRunInterpolationError,\n type WorkflowInterpolationField,\n type WorkflowTemplateDiagnostic,\n WorkflowTemplateResolutionError,\n} from '@shipfox/expression';\nimport {InterpolationUnresolvableError, type InterpolationUnresolvableField} from '#core/errors.js';\nimport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n\nexport type StepConfigField = InterpolationUnresolvableField;\n\nexport interface WorkflowStepTemplateDiagnostic extends WorkflowTemplateDiagnostic {\n readonly field: StepConfigField;\n readonly envKey?: string;\n}\n\nexport interface WorkflowStepEvaluationTraceEntry extends EvaluationTraceEntry {\n readonly field: StepConfigField;\n readonly envKey?: string;\n}\n\nexport interface ResolveStepFieldParams {\n readonly field: WorkflowInterpolationField;\n readonly template: ResolvedField;\n readonly context: WorkflowEvaluationContext;\n readonly definitionId: string;\n readonly errorField: InterpolationUnresolvableField;\n readonly envKey?: string;\n}\n\nexport function resolveStepField(params: ResolveStepFieldParams): SiteResolvedField {\n return resolveStepFieldAtSite(params, false);\n}\n\nfunction resolveStepFieldWithType(params: ResolveStepFieldParams): SiteResolvedField<unknown> {\n return resolveStepFieldAtSite(params, true);\n}\n\nfunction resolveStepFieldAtSite(\n params: ResolveStepFieldParams,\n preserveSingleExpressionType: true,\n): SiteResolvedField<unknown>;\nfunction resolveStepFieldAtSite(\n params: ResolveStepFieldParams,\n preserveSingleExpressionType: false,\n): SiteResolvedField;\nfunction resolveStepFieldAtSite(\n params: ResolveStepFieldParams,\n preserveSingleExpressionType: boolean,\n): SiteResolvedField<unknown> {\n try {\n const resolveParams = {\n field: params.template,\n context: params.context.values,\n site: params.context.site,\n failurePolicy: getWorkflowInterpolationFieldFailurePolicy(params.field),\n };\n return preserveSingleExpressionType\n ? resolveFieldAtSite({...resolveParams, preserveSingleExpressionType: true})\n : resolveFieldAtSite(resolveParams);\n } catch (error) {\n if (error instanceof WorkflowTemplateResolutionError) {\n throw stepConfigInterpolationError(params, error);\n }\n throw error;\n }\n}\n\nexport function freezeStepField(params: ResolveStepFieldParams): {\n readonly value: string;\n readonly diagnostics: SiteResolvedField['diagnostics'];\n readonly trace: SiteResolvedField['trace'];\n} {\n try {\n return freezeResolvedFieldAtSite({\n field: params.template,\n context: params.context.values,\n site: params.context.site,\n failurePolicy: getWorkflowInterpolationFieldFailurePolicy(params.field),\n });\n } catch (error) {\n if (error instanceof WorkflowTemplateResolutionError) {\n throw stepConfigInterpolationError(params, error);\n }\n throw error;\n }\n}\n\nexport function completeStepField(params: ResolveStepFieldParams): string {\n return completeStepFieldWithTrace(params).value;\n}\n\nexport function completeStepFieldWithType(params: ResolveStepFieldParams): unknown {\n return completeStepFieldWithTypeAndTrace(params).value;\n}\n\nexport function completeStepFieldWithTrace(params: ResolveStepFieldParams): {\n readonly value: string;\n readonly trace: SiteResolvedField['trace'];\n} {\n return completeResolvedStepField(params, resolveStepField(params));\n}\n\nexport function completeStepFieldWithTypeAndTrace(params: ResolveStepFieldParams): {\n readonly value: unknown;\n readonly trace: SiteResolvedField<unknown>['trace'];\n} {\n return completeResolvedStepField(params, resolveStepFieldWithType(params));\n}\n\nfunction completeResolvedStepField<Value>(\n params: ResolveStepFieldParams,\n resolved: SiteResolvedField<Value>,\n): {readonly value: Value; readonly trace: SiteResolvedField<Value>['trace']} {\n if (resolved.kind === 'frozen') return {value: resolved.value, trace: resolved.trace};\n\n const source = resolved.field.segments.find((segment) => segment.kind === 'deferred')?.expression\n .source;\n throw new InterpolationUnresolvableError(params.definitionId, {\n field: params.errorField,\n source: source ?? params.field,\n ...(params.envKey === undefined ? {} : {envKey: params.envKey}),\n });\n}\n\nexport function stepConfigInterpolationError(\n params: {\n readonly definitionId: string;\n readonly errorField: InterpolationUnresolvableField;\n readonly envKey?: string;\n },\n error: WorkflowTemplateResolutionError | UnsafeRunInterpolationError,\n): InterpolationUnresolvableError {\n return new InterpolationUnresolvableError(params.definitionId, {\n field: params.errorField,\n source: error.source,\n ...(params.envKey === undefined ? {} : {envKey: params.envKey}),\n cause: error,\n });\n}\n\nexport function literalField(value: string): ResolvedField {\n return {segments: [{kind: 'literal', value}]};\n}\n"],"names":["freezeResolvedFieldAtSite","getWorkflowInterpolationFieldFailurePolicy","resolveFieldAtSite","WorkflowTemplateResolutionError","InterpolationUnresolvableError","resolveStepField","params","resolveStepFieldAtSite","resolveStepFieldWithType","preserveSingleExpressionType","resolveParams","field","template","context","values","site","failurePolicy","error","stepConfigInterpolationError","freezeStepField","completeStepField","completeStepFieldWithTrace","value","completeStepFieldWithType","completeStepFieldWithTypeAndTrace","completeResolvedStepField","resolved","kind","trace","source","segments","find","segment","expression","definitionId","errorField","envKey","undefined","cause","literalField"],"mappings":"AAAA,SAEEA,yBAAyB,EACzBC,0CAA0C,EAE1CC,kBAAkB,EAKlBC,+BAA+B,QAC1B,sBAAsB;AAC7B,SAAQC,8BAA8B,QAA4C,kBAAkB;AAwBpG,OAAO,SAASC,iBAAiBC,MAA8B;IAC7D,OAAOC,uBAAuBD,QAAQ;AACxC;AAEA,SAASE,yBAAyBF,MAA8B;IAC9D,OAAOC,uBAAuBD,QAAQ;AACxC;AAUA,SAASC,uBACPD,MAA8B,EAC9BG,4BAAqC;IAErC,IAAI;QACF,MAAMC,gBAAgB;YACpBC,OAAOL,OAAOM,QAAQ;YACtBC,SAASP,OAAOO,OAAO,CAACC,MAAM;YAC9BC,MAAMT,OAAOO,OAAO,CAACE,IAAI;YACzBC,eAAef,2CAA2CK,OAAOK,KAAK;QACxE;QACA,OAAOF,+BACHP,mBAAmB;YAAC,GAAGQ,aAAa;YAAED,8BAA8B;QAAI,KACxEP,mBAAmBQ;IACzB,EAAE,OAAOO,OAAO;QACd,IAAIA,iBAAiBd,iCAAiC;YACpD,MAAMe,6BAA6BZ,QAAQW;QAC7C;QACA,MAAMA;IACR;AACF;AAEA,OAAO,SAASE,gBAAgBb,MAA8B;IAK5D,IAAI;QACF,OAAON,0BAA0B;YAC/BW,OAAOL,OAAOM,QAAQ;YACtBC,SAASP,OAAOO,OAAO,CAACC,MAAM;YAC9BC,MAAMT,OAAOO,OAAO,CAACE,IAAI;YACz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,OAAOrB;IACT;AACF;AAEA,OAAO,SAASsB,aAAajB,KAAa;IACxC,OAAO;QAACQ,UAAU;YAAC;gBAACH,MAAM;gBAAWL;YAAK;SAAE;IAAA;AAC9C"}
@@ -1,4 +1,4 @@
1
- export { type AssembleExecutionCreationContextParams, type AssembleJobActivationContextParams, type AssembleWorkflowRunContextParams, applyListenerFilterSnapshots, assembleCreationContext, assembleExecutionCreationContext, assembleExecutionResolutionContext, assembleExecutionsContext, assembleGateContext, assembleJobActivationContext, assembleJobResolutionContext, assembleListenerSnapshotContext, assembleStepDispatchContext, assembleWorkflowRunContext, type JobContextInput, type ListenerSnapshotPlan, type ListenerTriggerWithSnapshot, type MatcherSnapshotPlan, planListenerFilterSnapshots, } from './assemble-run-context.js';
1
+ export { type AssembleExecutionCreationContextParams, type AssembleJobActivationContextParams, type AssembleWorkflowRunContextParams, applyListenerFilterSnapshots, assembleCreationContext, assembleExecutionCreationContext, assembleExecutionResolutionContext, assembleExecutionsContext, assembleGateContext, assembleJobActivationContext, assembleJobResolutionContext, assembleListenerSnapshotContext, assembleStepDispatchContext, assembleWorkflowRunContext, type JobContextInput, type ListenerFilterOutputTypes, type ListenerSnapshotPlan, type ListenerTriggerWithSnapshot, listenerFilterOutputTypesForJobs, type MatcherSnapshotPlan, planListenerFilterSnapshots, } from './assemble-run-context.js';
2
2
  export { completeStepDispatchConfig } from './complete-step-dispatch-config.js';
3
3
  export { type MaterializedWorkflowStep, type MaterializeJobExecutionStepsParams, materializeJobExecutionSteps, } from './materialize-job-execution-steps.js';
4
4
  export { type MaterializedWorkflowJob, type MaterializeWorkflowModelParams, materializeJobOutputs, materializeJobRunner, materializeWorkflowModel, modelHasAgentStep, } from './materialize-workflow-model.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/step-config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sCAAsC,EAC3C,KAAK,kCAAkC,EACvC,KAAK,gCAAgC,EACrC,4BAA4B,EAC5B,uBAAuB,EACvB,gCAAgC,EAChC,kCAAkC,EAClC,yBAAyB,EACzB,mBAAmB,EACnB,4BAA4B,EAC5B,4BAA4B,EAC5B,+BAA+B,EAC/B,2BAA2B,EAC3B,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,0BAA0B,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,kCAAkC,EACvC,4BAA4B,GAC7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,KAAK,6BAA6B,EAClC,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAC,8BAA8B,EAAC,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EACL,KAAK,4BAA4B,EACjC,sBAAsB,EACtB,2BAA2B,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,8BAA8B,GACpC,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAC,yBAAyB,EAAC,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/step-config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sCAAsC,EAC3C,KAAK,kCAAkC,EACvC,KAAK,gCAAgC,EACrC,4BAA4B,EAC5B,uBAAuB,EACvB,gCAAgC,EAChC,kCAAkC,EAClC,yBAAyB,EACzB,mBAAmB,EACnB,4BAA4B,EAC5B,4BAA4B,EAC5B,+BAA+B,EAC/B,2BAA2B,EAC3B,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,gCAAgC,EAChC,KAAK,mBAAmB,EACxB,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,0BAA0B,EAAC,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,kCAAkC,EACvC,4BAA4B,GAC7B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,KAAK,6BAA6B,EAClC,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAC,8BAA8B,EAAC,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EACL,KAAK,4BAA4B,EACjC,sBAAsB,EACtB,2BAA2B,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,8BAA8B,GACpC,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAC,yBAAyB,EAAC,MAAM,kCAAkC,CAAC"}
@@ -1,4 +1,4 @@
1
- export { applyListenerFilterSnapshots, assembleCreationContext, assembleExecutionCreationContext, assembleExecutionResolutionContext, assembleExecutionsContext, assembleGateContext, assembleJobActivationContext, assembleJobResolutionContext, assembleListenerSnapshotContext, assembleStepDispatchContext, assembleWorkflowRunContext, planListenerFilterSnapshots } from './assemble-run-context.js';
1
+ export { applyListenerFilterSnapshots, assembleCreationContext, assembleExecutionCreationContext, assembleExecutionResolutionContext, assembleExecutionsContext, assembleGateContext, assembleJobActivationContext, assembleJobResolutionContext, assembleListenerSnapshotContext, assembleStepDispatchContext, assembleWorkflowRunContext, listenerFilterOutputTypesForJobs, planListenerFilterSnapshots } from './assemble-run-context.js';
2
2
  export { completeStepDispatchConfig } from './complete-step-dispatch-config.js';
3
3
  export { materializeJobExecutionSteps } from './materialize-job-execution-steps.js';
4
4
  export { materializeJobOutputs, materializeJobRunner, materializeWorkflowModel, modelHasAgentStep } from './materialize-workflow-model.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/step-config/index.ts"],"sourcesContent":["export {\n type AssembleExecutionCreationContextParams,\n type AssembleJobActivationContextParams,\n type AssembleWorkflowRunContextParams,\n applyListenerFilterSnapshots,\n assembleCreationContext,\n assembleExecutionCreationContext,\n assembleExecutionResolutionContext,\n assembleExecutionsContext,\n assembleGateContext,\n assembleJobActivationContext,\n assembleJobResolutionContext,\n assembleListenerSnapshotContext,\n assembleStepDispatchContext,\n assembleWorkflowRunContext,\n type JobContextInput,\n type ListenerSnapshotPlan,\n type ListenerTriggerWithSnapshot,\n type MatcherSnapshotPlan,\n planListenerFilterSnapshots,\n} from './assemble-run-context.js';\nexport {completeStepDispatchConfig} from './complete-step-dispatch-config.js';\nexport {\n type MaterializedWorkflowStep,\n type MaterializeJobExecutionStepsParams,\n materializeJobExecutionSteps,\n} from './materialize-job-execution-steps.js';\nexport {\n type MaterializedWorkflowJob,\n type MaterializeWorkflowModelParams,\n materializeJobOutputs,\n materializeJobRunner,\n materializeWorkflowModel,\n modelHasAgentStep,\n} from './materialize-workflow-model.js';\nexport {\n type ResolveJobExecutionNameParams,\n resolveJobExecutionName,\n} from './resolve-job-execution-name.js';\nexport type {WorkflowStepTemplateDiagnostic} from './resolve-step-config.js';\nexport {\n type ResolveWorkflowRunNameResult,\n resolveWorkflowRunName,\n sanitizeWorkflowDisplayText,\n type WorkflowRunNameDegradation,\n type WorkflowRunNameResolutionCause,\n} from './resolve-workflow-run-name.js';\nexport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n"],"names":["applyListenerFilterSnapshots","assembleCreationContext","assembleExecutionCreationContext","assembleExecutionResolutionContext","assembleExecutionsContext","assembleGateContext","assembleJobActivationContext","assembleJobResolutionContext","assembleListenerSnapshotContext","assembleStepDispatchContext","assembleWorkflowRunContext","planListenerFilterSnapshots","completeStepDispatchConfig","materializeJobExecutionSteps","materializeJobOutputs","materializeJobRunner","materializeWorkflowModel","modelHasAgentStep","resolveJobExecutionName","resolveWorkflowRunName","sanitizeWorkflowDisplayText"],"mappings":"AAAA,SAIEA,4BAA4B,EAC5BC,uBAAuB,EACvBC,gCAAgC,EAChCC,kCAAkC,EAClCC,yBAAyB,EACzBC,mBAAmB,EACnBC,4BAA4B,EAC5BC,4BAA4B,EAC5BC,+BAA+B,EAC/BC,2BAA2B,EAC3BC,0BAA0B,EAK1BC,2BAA2B,QACtB,4BAA4B;AACnC,SAAQC,0BAA0B,QAAO,qCAAqC;AAC9E,SAGEC,4BAA4B,QACvB,uCAAuC;AAC9C,SAGEC,qBAAqB,EACrBC,oBAAoB,EACpBC,wBAAwB,EACxBC,iBAAiB,QACZ,kCAAkC;AACzC,SAEEC,uBAAuB,QAClB,kCAAkC;AAEzC,SAEEC,sBAAsB,EACtBC,2BAA2B,QAGtB,iCAAiC"}
1
+ {"version":3,"sources":["../../../src/core/step-config/index.ts"],"sourcesContent":["export {\n type AssembleExecutionCreationContextParams,\n type AssembleJobActivationContextParams,\n type AssembleWorkflowRunContextParams,\n applyListenerFilterSnapshots,\n assembleCreationContext,\n assembleExecutionCreationContext,\n assembleExecutionResolutionContext,\n assembleExecutionsContext,\n assembleGateContext,\n assembleJobActivationContext,\n assembleJobResolutionContext,\n assembleListenerSnapshotContext,\n assembleStepDispatchContext,\n assembleWorkflowRunContext,\n type JobContextInput,\n type ListenerFilterOutputTypes,\n type ListenerSnapshotPlan,\n type ListenerTriggerWithSnapshot,\n listenerFilterOutputTypesForJobs,\n type MatcherSnapshotPlan,\n planListenerFilterSnapshots,\n} from './assemble-run-context.js';\nexport {completeStepDispatchConfig} from './complete-step-dispatch-config.js';\nexport {\n type MaterializedWorkflowStep,\n type MaterializeJobExecutionStepsParams,\n materializeJobExecutionSteps,\n} from './materialize-job-execution-steps.js';\nexport {\n type MaterializedWorkflowJob,\n type MaterializeWorkflowModelParams,\n materializeJobOutputs,\n materializeJobRunner,\n materializeWorkflowModel,\n modelHasAgentStep,\n} from './materialize-workflow-model.js';\nexport {\n type ResolveJobExecutionNameParams,\n resolveJobExecutionName,\n} from './resolve-job-execution-name.js';\nexport type {WorkflowStepTemplateDiagnostic} from './resolve-step-config.js';\nexport {\n type ResolveWorkflowRunNameResult,\n resolveWorkflowRunName,\n sanitizeWorkflowDisplayText,\n type WorkflowRunNameDegradation,\n type WorkflowRunNameResolutionCause,\n} from './resolve-workflow-run-name.js';\nexport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n"],"names":["applyListenerFilterSnapshots","assembleCreationContext","assembleExecutionCreationContext","assembleExecutionResolutionContext","assembleExecutionsContext","assembleGateContext","assembleJobActivationContext","assembleJobResolutionContext","assembleListenerSnapshotContext","assembleStepDispatchContext","assembleWorkflowRunContext","listenerFilterOutputTypesForJobs","planListenerFilterSnapshots","completeStepDispatchConfig","materializeJobExecutionSteps","materializeJobOutputs","materializeJobRunner","materializeWorkflowModel","modelHasAgentStep","resolveJobExecutionName","resolveWorkflowRunName","sanitizeWorkflowDisplayText"],"mappings":"AAAA,SAIEA,4BAA4B,EAC5BC,uBAAuB,EACvBC,gCAAgC,EAChCC,kCAAkC,EAClCC,yBAAyB,EACzBC,mBAAmB,EACnBC,4BAA4B,EAC5BC,4BAA4B,EAC5BC,+BAA+B,EAC/BC,2BAA2B,EAC3BC,0BAA0B,EAK1BC,gCAAgC,EAEhCC,2BAA2B,QACtB,4BAA4B;AACnC,SAAQC,0BAA0B,QAAO,qCAAqC;AAC9E,SAGEC,4BAA4B,QACvB,uCAAuC;AAC9C,SAGEC,qBAAqB,EACrBC,oBAAoB,EACpBC,wBAAwB,EACxBC,iBAAiB,QACZ,kCAAkC;AACzC,SAEEC,uBAAuB,QAClB,kCAAkC;AAEzC,SAEEC,sBAAsB,EACtBC,2BAA2B,QAGtB,iCAAiC"}
@@ -0,0 +1,11 @@
1
+ export declare const MAX_JOB_OUTPUT_ENTRIES = 128;
2
+ export declare const MAX_JOB_OUTPUT_NESTING_DEPTH = 64;
3
+ export declare const MAX_JOB_OUTPUTS_TOTAL_BYTES: number;
4
+ export declare const MAX_JOB_OUTPUT_VALUE_BYTES: number;
5
+ export type JsonSafeJobOutputValue = null | string | number | boolean | readonly JsonSafeJobOutputValue[] | {
6
+ [key: string]: JsonSafeJobOutputValue;
7
+ };
8
+ export declare function normalizeJobOutputValue(value: unknown, outputKey: string): JsonSafeJobOutputValue;
9
+ export declare function jobOutputValueByteLength(value: unknown): number;
10
+ export declare function jobOutputRecordEntryByteLength(key: string, value: JsonSafeJobOutputValue): number;
11
+ //# sourceMappingURL=job-output-limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-output-limits.d.ts","sourceRoot":"","sources":["../../../src/core/step-config/job-output-limits.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB,MAA4C,CAAC;AAChF,eAAO,MAAM,4BAA4B,KAAiD,CAAC;AAC3F,eAAO,MAAM,2BAA2B,QAAY,CAAC;AACrD,eAAO,MAAM,0BAA0B,QAAY,CAAC;AAIpD,MAAM,MAAM,sBAAsB,GAC9B,IAAI,GACJ,MAAM,GACN,MAAM,GACN,OAAO,GACP,SAAS,sBAAsB,EAAE,GACjC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB,CAAA;CAAC,CAAC;AAE5C,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,sBAAsB,CAEjG;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI/D;AAED,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAEjG"}