@shipfox/api-workflows 12.0.0 → 12.2.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 (73) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +36 -0
  3. package/dist/core/entities/job.d.ts +1 -1
  4. package/dist/core/entities/job.d.ts.map +1 -1
  5. package/dist/core/entities/step.d.ts +2 -2
  6. package/dist/core/entities/step.d.ts.map +1 -1
  7. package/dist/core/errors.d.ts +16 -0
  8. package/dist/core/errors.d.ts.map +1 -1
  9. package/dist/core/errors.js +18 -0
  10. package/dist/core/errors.js.map +1 -1
  11. package/dist/core/step-config/assemble-run-context.d.ts +15 -5
  12. package/dist/core/step-config/assemble-run-context.d.ts.map +1 -1
  13. package/dist/core/step-config/assemble-run-context.js +77 -27
  14. package/dist/core/step-config/assemble-run-context.js.map +1 -1
  15. package/dist/core/step-config/fields.d.ts +5 -0
  16. package/dist/core/step-config/fields.d.ts.map +1 -1
  17. package/dist/core/step-config/fields.js +21 -3
  18. package/dist/core/step-config/fields.js.map +1 -1
  19. package/dist/core/step-config/index.d.ts +1 -1
  20. package/dist/core/step-config/index.d.ts.map +1 -1
  21. package/dist/core/step-config/index.js +1 -1
  22. package/dist/core/step-config/index.js.map +1 -1
  23. package/dist/core/step-config/job-output-limits.d.ts +11 -0
  24. package/dist/core/step-config/job-output-limits.d.ts.map +1 -0
  25. package/dist/core/step-config/job-output-limits.js +88 -0
  26. package/dist/core/step-config/job-output-limits.js.map +1 -0
  27. package/dist/core/step-config/materialize-workflow-model.d.ts +1 -1
  28. package/dist/core/step-config/materialize-workflow-model.d.ts.map +1 -1
  29. package/dist/core/step-config/materialize-workflow-model.js +41 -14
  30. package/dist/core/step-config/materialize-workflow-model.js.map +1 -1
  31. package/dist/db/db.d.ts +50 -50
  32. package/dist/db/job-listeners.d.ts.map +1 -1
  33. package/dist/db/job-listeners.js +6 -5
  34. package/dist/db/job-listeners.js.map +1 -1
  35. package/dist/db/schema/job-executions.d.ts +3 -3
  36. package/dist/db/schema/job-listener-events.d.ts +1 -1
  37. package/dist/db/schema/jobs.d.ts +7 -7
  38. package/dist/db/schema/outbox.d.ts +1 -1
  39. package/dist/db/schema/step-attempts.d.ts +2 -2
  40. package/dist/db/schema/steps.d.ts +5 -5
  41. package/dist/db/schema/workflow-run-attempts.d.ts +3 -3
  42. package/dist/db/schema/workflow-run-counters.d.ts +1 -1
  43. package/dist/db/schema/workflow-runs.d.ts +2 -2
  44. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
  45. package/dist/db/workflow-runs/job-executions.js +4 -2
  46. package/dist/db/workflow-runs/job-executions.js.map +1 -1
  47. package/dist/db/workflow-runs/jobs.d.ts.map +1 -1
  48. package/dist/db/workflow-runs/jobs.js +29 -3
  49. package/dist/db/workflow-runs/jobs.js.map +1 -1
  50. package/dist/presentation/routes/project-access.d.ts +1 -1
  51. package/dist/temporal/activities/index.d.ts +1 -1
  52. package/dist/temporal/activities/index.d.ts.map +1 -1
  53. package/dist/temporal/activities/orchestration-activities.d.ts +1 -1
  54. package/dist/temporal/activities/orchestration-activities.d.ts.map +1 -1
  55. package/dist/temporal/workflows/test-env.d.ts +2 -2
  56. package/dist/tsconfig.test.tsbuildinfo +1 -1
  57. package/package.json +16 -16
  58. package/src/core/errors.ts +35 -0
  59. package/src/core/step-config/assemble-run-context.test.ts +232 -20
  60. package/src/core/step-config/assemble-run-context.ts +126 -28
  61. package/src/core/step-config/fields.ts +42 -3
  62. package/src/core/step-config/index.ts +2 -0
  63. package/src/core/step-config/job-output-limits.ts +130 -0
  64. package/src/core/step-config/materialize-workflow-model.test.ts +306 -1
  65. package/src/core/step-config/materialize-workflow-model.ts +60 -15
  66. package/src/db/job-listeners.ts +14 -3
  67. package/src/db/workflow-runs/job-executions.test.ts +207 -1
  68. package/src/db/workflow-runs/job-executions.ts +15 -2
  69. package/src/db/workflow-runs/jobs.test.ts +49 -0
  70. package/src/db/workflow-runs/jobs.ts +46 -6
  71. package/src/db/workflow-runs/run-create.test.ts +56 -0
  72. package/test/factories/workflow-model.ts +2 -0
  73. package/tsconfig.build.tsbuildinfo +1 -1
@@ -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;YACt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rC,MAAMzB,OAAOyB,IAAI,IAAI,CAAC;QACxB;IACF;AACF;AAEA,OAAO,SAASgJ,mCAAmCzK,MAWlD;IACC,MAAMiD,aAAaC,0BAA0BlD,OAAOiD,UAAU;IAC9D,MAAMyH,iBAAiB1K,OAAOiD,UAAU,CAAC0H,SAAS,CAChD,CAAC5I,YAAcA,UAAU3B,EAAE,KAAKJ,OAAO8I,YAAY,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,QAC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EACnB2B,iBAAiB,IAAI3L,OAAOgK,YAAY,CAAC5H,QAAQ,GAAG,IAAIuJ;YAE1DxJ,KAAK;gBACHqB,KAAKxD,OAAOmC,GAAG,CAACqB,GAAG;gBACnB,GAAIxD,OAAOmC,GAAG,CAAC5B,IAAI,KAAKsB,YAAY,CAAC,IAAI;oBAACtB,MAAMP,OAAOmC,GAAG,CAAC5B,IAAI,IAAIP,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,KA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
@@ -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,OA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AU;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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,SAASlB,6BACdZ,MAIC,EACDW,KAAoE;IAEpE,OAAO,IAAIb,+BAA+BE,OAAO4B,YAAY,EAAE;QAC7DvB,OAAOL,OAAO6B,UAAU;QACxBN,QAAQZ,MAAMY,MAAM;QACpB,GAAIvB,OAAO8B,MAAM,KAAKC,YAAY,CAAC,IAAI;YAACD,QAAQ9B,OAAO8B,MAAM;QAAA,CAAC;QAC9DE,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"}
@@ -0,0 +1,88 @@
1
+ import { WORKFLOW_DOCUMENT_JOB_OUTPUTS_MAX_ENTRIES, WORKFLOW_DOCUMENT_STEP_OUTPUT_SCHEMA_MAX_DEPTH } from '@shipfox/workflow-document';
2
+ import { JobOutputNotJsonSafeError } from '#core/errors.js';
3
+ export const MAX_JOB_OUTPUT_ENTRIES = WORKFLOW_DOCUMENT_JOB_OUTPUTS_MAX_ENTRIES;
4
+ export const MAX_JOB_OUTPUT_NESTING_DEPTH = WORKFLOW_DOCUMENT_STEP_OUTPUT_SCHEMA_MAX_DEPTH;
5
+ export const MAX_JOB_OUTPUTS_TOTAL_BYTES = 64 * 1024;
6
+ export const MAX_JOB_OUTPUT_VALUE_BYTES = 16 * 1024;
7
+ const textEncoder = new TextEncoder();
8
+ export function normalizeJobOutputValue(value, outputKey) {
9
+ return normalize(value, outputKey, new WeakSet(), 0);
10
+ }
11
+ export function jobOutputValueByteLength(value) {
12
+ if (typeof value === 'string') return textEncoder.encode(value).byteLength;
13
+ return jsonByteLength(value);
14
+ }
15
+ export function jobOutputRecordEntryByteLength(key, value) {
16
+ return textEncoder.encode(JSON.stringify(key)).byteLength + 1 + jsonByteLength(value);
17
+ }
18
+ function jsonByteLength(value) {
19
+ const serialized = JSON.stringify(value);
20
+ return textEncoder.encode(serialized ?? '').byteLength;
21
+ }
22
+ function normalize(value, outputKey, ancestors, depth) {
23
+ if (value === null) return null;
24
+ switch(typeof value){
25
+ case 'string':
26
+ case 'boolean':
27
+ return value;
28
+ case 'number':
29
+ if (!Number.isFinite(value)) {
30
+ throw new JobOutputNotJsonSafeError(outputKey, 'numbers must be finite');
31
+ }
32
+ return value;
33
+ case 'bigint':
34
+ {
35
+ const numberValue = Number(value);
36
+ return Number.isSafeInteger(numberValue) ? numberValue : value.toString();
37
+ }
38
+ case 'undefined':
39
+ throw new JobOutputNotJsonSafeError(outputKey, 'undefined is not a JSON value');
40
+ case 'function':
41
+ case 'symbol':
42
+ throw new JobOutputNotJsonSafeError(outputKey, `values of type ${typeof value} are not JSON values`);
43
+ case 'object':
44
+ return normalizeObject(value, outputKey, ancestors, depth);
45
+ }
46
+ throw new JobOutputNotJsonSafeError(outputKey, 'the value has an unsupported type');
47
+ }
48
+ function normalizeObject(value, outputKey, ancestors, depth) {
49
+ if (value instanceof Date) {
50
+ if (Number.isNaN(value.getTime())) {
51
+ throw new JobOutputNotJsonSafeError(outputKey, 'dates must be valid');
52
+ }
53
+ return value.toISOString();
54
+ }
55
+ if (ancestors.has(value)) {
56
+ throw new JobOutputNotJsonSafeError(outputKey, 'the value contains a circular reference');
57
+ }
58
+ if (depth >= MAX_JOB_OUTPUT_NESTING_DEPTH) {
59
+ throw new JobOutputNotJsonSafeError(outputKey, `values cannot be nested deeper than ${MAX_JOB_OUTPUT_NESTING_DEPTH} levels`);
60
+ }
61
+ if (Array.isArray(value)) {
62
+ ancestors.add(value);
63
+ try {
64
+ const normalized = [];
65
+ for (const item of value){
66
+ normalized.push(normalize(item, outputKey, ancestors, depth + 1));
67
+ }
68
+ return normalized;
69
+ } finally{
70
+ ancestors.delete(value);
71
+ }
72
+ }
73
+ const prototype = Object.getPrototypeOf(value);
74
+ if (prototype !== Object.prototype && prototype !== null) {
75
+ throw new JobOutputNotJsonSafeError(outputKey, 'the value has an unsupported object type');
76
+ }
77
+ ancestors.add(value);
78
+ try {
79
+ return Object.fromEntries(Object.keys(value).map((key)=>[
80
+ key,
81
+ normalize(value[key], outputKey, ancestors, depth + 1)
82
+ ]));
83
+ } finally{
84
+ ancestors.delete(value);
85
+ }
86
+ }
87
+
88
+ //# sourceMappingURL=job-output-limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/step-config/job-output-limits.ts"],"sourcesContent":["import {\n WORKFLOW_DOCUMENT_JOB_OUTPUTS_MAX_ENTRIES,\n WORKFLOW_DOCUMENT_STEP_OUTPUT_SCHEMA_MAX_DEPTH,\n} from '@shipfox/workflow-document';\nimport {JobOutputNotJsonSafeError} from '#core/errors.js';\n\nexport const MAX_JOB_OUTPUT_ENTRIES = WORKFLOW_DOCUMENT_JOB_OUTPUTS_MAX_ENTRIES;\nexport const MAX_JOB_OUTPUT_NESTING_DEPTH = WORKFLOW_DOCUMENT_STEP_OUTPUT_SCHEMA_MAX_DEPTH;\nexport const MAX_JOB_OUTPUTS_TOTAL_BYTES = 64 * 1024;\nexport const MAX_JOB_OUTPUT_VALUE_BYTES = 16 * 1024;\n\nconst textEncoder = new TextEncoder();\n\nexport type JsonSafeJobOutputValue =\n | null\n | string\n | number\n | boolean\n | readonly JsonSafeJobOutputValue[]\n | {[key: string]: JsonSafeJobOutputValue};\n\nexport function normalizeJobOutputValue(value: unknown, outputKey: string): JsonSafeJobOutputValue {\n return normalize(value, outputKey, new WeakSet<object>(), 0);\n}\n\nexport function jobOutputValueByteLength(value: unknown): number {\n if (typeof value === 'string') return textEncoder.encode(value).byteLength;\n\n return jsonByteLength(value);\n}\n\nexport function jobOutputRecordEntryByteLength(key: string, value: JsonSafeJobOutputValue): number {\n return textEncoder.encode(JSON.stringify(key)).byteLength + 1 + jsonByteLength(value);\n}\n\nfunction jsonByteLength(value: unknown): number {\n const serialized = JSON.stringify(value);\n return textEncoder.encode(serialized ?? '').byteLength;\n}\n\nfunction normalize(\n value: unknown,\n outputKey: string,\n ancestors: WeakSet<object>,\n depth: number,\n): JsonSafeJobOutputValue {\n if (value === null) return null;\n\n switch (typeof value) {\n case 'string':\n case 'boolean':\n return value;\n case 'number':\n if (!Number.isFinite(value)) {\n throw new JobOutputNotJsonSafeError(outputKey, 'numbers must be finite');\n }\n return value;\n case 'bigint': {\n const numberValue = Number(value);\n return Number.isSafeInteger(numberValue) ? numberValue : value.toString();\n }\n case 'undefined':\n throw new JobOutputNotJsonSafeError(outputKey, 'undefined is not a JSON value');\n case 'function':\n case 'symbol':\n throw new JobOutputNotJsonSafeError(\n outputKey,\n `values of type ${typeof value} are not JSON values`,\n );\n case 'object':\n return normalizeObject(value, outputKey, ancestors, depth);\n }\n\n throw new JobOutputNotJsonSafeError(outputKey, 'the value has an unsupported type');\n}\n\nfunction normalizeObject(\n value: object,\n outputKey: string,\n ancestors: WeakSet<object>,\n depth: number,\n): JsonSafeJobOutputValue {\n if (value instanceof Date) {\n if (Number.isNaN(value.getTime())) {\n throw new JobOutputNotJsonSafeError(outputKey, 'dates must be valid');\n }\n return value.toISOString();\n }\n\n if (ancestors.has(value)) {\n throw new JobOutputNotJsonSafeError(outputKey, 'the value contains a circular reference');\n }\n\n if (depth >= MAX_JOB_OUTPUT_NESTING_DEPTH) {\n throw new JobOutputNotJsonSafeError(\n outputKey,\n `values cannot be nested deeper than ${MAX_JOB_OUTPUT_NESTING_DEPTH} levels`,\n );\n }\n\n if (Array.isArray(value)) {\n ancestors.add(value);\n try {\n const normalized: JsonSafeJobOutputValue[] = [];\n for (const item of value) {\n normalized.push(normalize(item, outputKey, ancestors, depth + 1));\n }\n return normalized;\n } finally {\n ancestors.delete(value);\n }\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new JobOutputNotJsonSafeError(outputKey, 'the value has an unsupported object type');\n }\n\n ancestors.add(value);\n try {\n return Object.fromEntries(\n Object.keys(value).map((key) => [\n key,\n normalize((value as Record<string, unknown>)[key], outputKey, ancestors, depth + 1),\n ]),\n ) as {[key: string]: JsonSafeJobOutputValue};\n } finally {\n ancestors.delete(value);\n }\n}\n"],"names":["WORKFLOW_DOCUMENT_JOB_OUTPUTS_MAX_ENTRIES","WORKFLOW_DOCUMENT_STEP_OUTPUT_SCHEMA_MAX_DEPTH","JobOutputNotJsonSafeError","MAX_JOB_OUTPUT_ENTRIES","MAX_JOB_OUTPUT_NESTING_DEPTH","MAX_JOB_OUTPUTS_TOTAL_BYTES","MAX_JOB_OUTPUT_VALUE_BYTES","textEncoder","TextEncoder","normalizeJobOutputValue","value","outputKey","normalize","WeakSet","jobOutputValueByteLength","encode","byteLength","jsonByteLength","jobOutputRecordEntryByteLength","key","JSON","stringify","serialized","ancestors","depth","Number","isFinite","numberValue","isSafeInteger","toString","normalizeObject","Date","isNaN","getTime","toISOString","has","Array","isArray","add","normalized","item","push","delete","prototype","Object","getPrototypeOf","fromEntries","keys","map"],"mappings":"AAAA,SACEA,yCAAyC,EACzCC,8CAA8C,QACzC,6BAA6B;AACpC,SAAQC,yBAAyB,QAAO,kBAAkB;AAE1D,OAAO,MAAMC,yBAAyBH,0CAA0C;AAChF,OAAO,MAAMI,+BAA+BH,+CAA+C;AAC3F,OAAO,MAAMI,8BAA8B,KAAK,KAAK;AACrD,OAAO,MAAMC,6BAA6B,KAAK,KAAK;AAEpD,MAAMC,cAAc,IAAIC;AAUxB,OAAO,SAASC,wBAAwBC,KAAc,EAAEC,SAAiB;IACvE,OAAOC,UAAUF,OAAOC,WAAW,IAAIE,WAAmB;AAC5D;AAEA,OAAO,SAASC,yBAAyBJ,KAAc;IACrD,IAAI,OAAOA,UAAU,UAAU,OAAOH,YAAYQ,MAAM,CAACL,OAAOM,UAAU;IAE1E,OAAOC,eAAeP;AACxB;AAEA,OAAO,SAASQ,+BAA+BC,GAAW,EAAET,KAA6B;IACvF,OAAOH,YAAYQ,MAAM,CAACK,KAAKC,SAAS,CAACF,MAAMH,UAAU,GAAG,IAAIC,eAAeP;AACjF;AAEA,SAASO,eAAeP,KAAc;IACpC,MAAMY,aAAaF,KAAKC,SAAS,CAACX;IAClC,OAAOH,YAAYQ,MAAM,CAACO,cAAc,IAAIN,UAAU;AACxD;AAEA,SAASJ,UACPF,KAAc,EACdC,SAAiB,EACjBY,SAA0B,EAC1BC,KAAa;IAEb,IAAId,UAAU,MAAM,OAAO;IAE3B,OAAQ,OAAOA;QACb,KAAK;QACL,KAAK;YACH,OAAOA;QACT,KAAK;YACH,IAAI,CAACe,OAAOC,Q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AAc,MAAM;QACxD,MAAM,IAAIzC,0BAA0BS,WAAW;IACjD;IAEAY,UAAUe,GAAG,CAAC5B;IACd,IAAI;QACF,OAAOkC,OAAOE,WAAW,CACvBF,OAAOG,IAAI,CAACrC,OAAOsC,GAAG,CAAC,CAAC7B,MAAQ;gBAC9BA;gBACAP,UAAU,AAACF,KAAiC,CAACS,IAAI,EAAER,WAAWY,WAAWC,QAAQ;aAClF;IAEL,SAAU;QACRD,UAAUmB,MAAM,CAAChC;IACnB;AACF"}
@@ -36,7 +36,7 @@ export declare function materializeJobOutputs(params: {
36
36
  readonly job: WorkflowModelJob;
37
37
  readonly context: WorkflowEvaluationContext;
38
38
  readonly definitionId: string;
39
- }): Record<string, string> | null;
39
+ }): Record<string, unknown> | null;
40
40
  export declare function modelHasAgentStep(model: WorkflowModel): boolean;
41
41
  export {};
42
42
  //# sourceMappingURL=materialize-workflow-model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"materialize-workflow-model.d.ts","sourceRoot":"","sources":["../../../src/core/step-config/materialize-workflow-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,aAAa,EAAC,MAAM,8BAA8B,CAAC;AAEtF,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EACV,+BAA+B,EAC/B,gCAAgC,EACjC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,kCAAkC,CAAC;AAEhF,KAAK,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AACtD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,CAAC,EAAE,M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BAAyB,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAgDjC;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAE/D"}
@@ -1,7 +1,8 @@
1
1
  import { DEFAULT_JOB_CHECKOUT } from '@shipfox/api-definitions-dto';
2
2
  import { canonicalizeLabels, findInvalidLabels, MAX_RUNNER_LABELS } from '@shipfox/runner-labels';
3
- import { InvalidJobRunnerLabelsError } from '#core/errors.js';
4
- import { completeStepField } from './fields.js';
3
+ import { InvalidJobRunnerLabelsError, JobOutputTooLargeError, JobOutputTooManyEntriesError } from '#core/errors.js';
4
+ import { completeStepField, completeStepFieldWithType } from './fields.js';
5
+ import { jobOutputRecordEntryByteLength, jobOutputValueByteLength, MAX_JOB_OUTPUT_ENTRIES, MAX_JOB_OUTPUT_VALUE_BYTES, MAX_JOB_OUTPUTS_TOTAL_BYTES, normalizeJobOutputValue } from './job-output-limits.js';
5
6
  import { materializeJobExecutionSteps } from './materialize-job-execution-steps.js';
6
7
  export async function materializeWorkflowModel(params) {
7
8
  const { model, context = {
@@ -71,18 +72,44 @@ export function materializeJobRunner(params) {
71
72
  export function materializeJobOutputs(params) {
72
73
  const outputs = params.job.outputs;
73
74
  if (outputs === undefined) return null;
74
- return Object.fromEntries(Object.entries(outputs).map(([key, template])=>[
75
- key,
76
- completeStepField({
77
- field: 'job.outputs',
78
- errorField: 'job.outputs',
79
- template: {
80
- segments: template
81
- },
82
- context: params.context,
83
- definitionId: params.definitionId
84
- })
85
- ]));
75
+ const outputEntries = Object.entries(outputs);
76
+ if (outputEntries.length > MAX_JOB_OUTPUT_ENTRIES) {
77
+ throw new JobOutputTooManyEntriesError(outputEntries.length, MAX_JOB_OUTPUT_ENTRIES);
78
+ }
79
+ const materialized = {};
80
+ // This is exactly JSON.stringify(materialized): start with "{}", then add each
81
+ // key/value pair and its comma (except for the first entry).
82
+ let recordBytes = 2;
83
+ for (const [index, [key, template]] of outputEntries.entries()){
84
+ const outputTypes = params.job.outputTypes;
85
+ const outputType = outputTypes !== undefined && Object.hasOwn(outputTypes, key) ? outputTypes[key] : undefined;
86
+ const completionParams = {
87
+ field: 'job.outputs',
88
+ errorField: 'job.outputs',
89
+ template: {
90
+ segments: template
91
+ },
92
+ context: params.context,
93
+ definitionId: params.definitionId
94
+ };
95
+ const value = outputType === undefined || outputType === 'string' ? completeStepField(completionParams) : completeStepFieldWithType(completionParams);
96
+ const normalizedValue = normalizeJobOutputValue(value, key);
97
+ const valueBytes = jobOutputValueByteLength(normalizedValue);
98
+ if (valueBytes > MAX_JOB_OUTPUT_VALUE_BYTES) {
99
+ throw new JobOutputTooLargeError(key, MAX_JOB_OUTPUT_VALUE_BYTES, 'value');
100
+ }
101
+ recordBytes += (index === 0 ? 0 : 1) + jobOutputRecordEntryByteLength(key, normalizedValue);
102
+ Object.defineProperty(materialized, key, {
103
+ configurable: true,
104
+ enumerable: true,
105
+ value: normalizedValue,
106
+ writable: true
107
+ });
108
+ if (recordBytes > MAX_JOB_OUTPUTS_TOTAL_BYTES) {
109
+ throw new JobOutputTooLargeError(key, MAX_JOB_OUTPUTS_TOTAL_BYTES, 'total');
110
+ }
111
+ }
112
+ return materialized;
86
113
  }
87
114
  export function modelHasAgentStep(model) {
88
115
  return model.jobs.some((job)=>job.steps.some((step)=>step.kind === 'agent'));