@shipfox/expression 1.1.4 → 1.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.
package/README.md CHANGED
@@ -9,6 +9,14 @@ CEL checks and run-time evaluation for Shipfox workflow expressions.
9
9
  - **`WorkflowExpression`**: Stores the CEL tag, source, and check level.
10
10
  - **`ExpressionTypeEnvironment`**: Lists names and field types for typed checks.
11
11
  - **`evaluateWorkflowExpression`**: Runs a checked value against caller data.
12
+ - **`evaluateWorkflowExpressionWithEnvironment`**: Runs a checked value against
13
+ a caller-owned CEL environment for explicitly scoped custom functions.
14
+ - **`WorkflowExpressionEnvironment`**: The evaluate-only environment shape
15
+ accepted by the scoped evaluator.
16
+ - **`createRangeEnvironment`**: Creates an opt-in evaluator with the bounded,
17
+ inclusive `range(start, stop, step)` config-templating function.
18
+ - **`MAX_RANGE_ELEMENTS`**: The per-evaluation range materialization limit,
19
+ currently 1,000 values.
12
20
  - **`evaluateWorkflowPredicate`**: Returns `true` only for the boolean `true`.
13
21
  - **`parseWorkflowTemplate`**: Splits strings with `${{ ... }}` spans into
14
22
  ordered literal and expression segments.
@@ -69,6 +77,18 @@ const passed = evaluateWorkflowPredicate(expression, {
69
77
  - Treat the `event`, `inputs`, and open `jobs` contexts as untrusted.
70
78
  Interpolation field policies decide what untrusted data may reach each field.
71
79
  - Evaluation is deterministic and has no side effects.
80
+ - Workflow evaluation does not include config-templating functions. Use a
81
+ caller-owned environment when a custom function is intentionally needed.
82
+ - The config-templating range evaluator accepts CEL integers and safe integer
83
+ values from JavaScript contexts. It creates a fresh CEL environment and one
84
+ materialization budget for each evaluation, shared by nested range calls;
85
+ each evaluation can materialize at most 1,000 values.
86
+ - Field resolution remains string-based by default. Callers rendering config
87
+ objects may opt into raw values for an exact single expression with
88
+ `preserveSingleExpressionType: true`; mixed literal and expression fields
89
+ remain strings. Under the `fail` policy, missing exact typed fields fail
90
+ rather than silently becoming an empty string; `runner-fill` segments remain
91
+ deferred for the runner instead of being hard-failed server-side.
72
92
  - The caller must pass values that match the checked data shape.
73
93
  - The evaluator does not read secrets, database rows, events, files, or external
74
94
  services.
@@ -1,7 +1,17 @@
1
+ import { type Environment } from '@marcbachmann/cel-js';
1
2
  import type { WorkflowExpression } from '../expression/workflow-expression.js';
2
3
  export type WorkflowExpressionEvaluationContext = Readonly<Record<string, unknown>>;
3
4
  export type WorkflowExpressionEvaluationValue = unknown;
5
+ export type WorkflowExpressionEnvironment = Pick<Environment, 'evaluate'>;
4
6
  export declare function evaluateWorkflowExpression(expression: WorkflowExpression, context: WorkflowExpressionEvaluationContext): WorkflowExpressionEvaluationValue;
7
+ /**
8
+ * Evaluate an expression against a caller-owned CEL environment.
9
+ *
10
+ * Workflow expressions deliberately continue to use the global CEL evaluator.
11
+ * Callers that need custom functions, such as config templating, must opt in
12
+ * by creating and passing their own environment.
13
+ */
14
+ export declare function evaluateWorkflowExpressionWithEnvironment(expression: WorkflowExpression, context: WorkflowExpressionEvaluationContext, environment: WorkflowExpressionEnvironment): WorkflowExpressionEvaluationValue;
5
15
  export declare function evaluateWorkflowPredicate(expression: WorkflowExpression, context: WorkflowExpressionEvaluationContext): boolean;
6
16
  export interface FailClosedPredicateOutcome {
7
17
  readonly value: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate-workflow-expression.d.ts","sourceRoot":"","sources":["../../src/evaluator/evaluate-workflow-expression.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAG7E,MAAM,MAAM,mCAAmC,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACpF,MAAM,MAAM,iCAAiC,GAAG,OAAO,CAAC;AAExD,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,mCAAmC,GAC3C,iCAAiC,CAMnC;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAET;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED,wBAAgB,mCAAmC,CACjD,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,mCAAmC,GAC3C,0BAA0B,CAS5B"}
1
+ {"version":3,"file":"evaluate-workflow-expression.d.ts","sourceRoot":"","sources":["../../src/evaluator/evaluate-workflow-expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,WAAW,EAAW,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAG7E,MAAM,MAAM,mCAAmC,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACpF,MAAM,MAAM,iCAAiC,GAAG,OAAO,CAAC;AACxD,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAE1E,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,mCAAmC,GAC3C,iCAAiC,CAMnC;AAED;;;;;;GAMG;AACH,wBAAgB,yCAAyC,CACvD,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,mCAAmC,EAC5C,WAAW,EAAE,6BAA6B,GACzC,iCAAiC,CAMnC;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAET;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED,wBAAgB,mCAAmC,CACjD,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,mCAAmC,GAC3C,0BAA0B,CAS5B"}
@@ -7,6 +7,19 @@ export function evaluateWorkflowExpression(expression, context) {
7
7
  throw new WorkflowExpressionEvaluationError(error);
8
8
  }
9
9
  }
10
+ /**
11
+ * Evaluate an expression against a caller-owned CEL environment.
12
+ *
13
+ * Workflow expressions deliberately continue to use the global CEL evaluator.
14
+ * Callers that need custom functions, such as config templating, must opt in
15
+ * by creating and passing their own environment.
16
+ */ export function evaluateWorkflowExpressionWithEnvironment(expression, context, environment) {
17
+ try {
18
+ return environment.evaluate(expression.source, context);
19
+ } catch (error) {
20
+ throw new WorkflowExpressionEvaluationError(error);
21
+ }
22
+ }
10
23
  export function evaluateWorkflowPredicate(expression, context) {
11
24
  return evaluateWorkflowExpression(expression, context) === true;
12
25
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/evaluator/evaluate-workflow-expression.ts"],"sourcesContent":["import {evaluate} from '@marcbachmann/cel-js';\nimport type {WorkflowExpression} from '../expression/workflow-expression.js';\nimport {WorkflowExpressionEvaluationError} from './errors.js';\n\nexport type WorkflowExpressionEvaluationContext = Readonly<Record<string, unknown>>;\nexport type WorkflowExpressionEvaluationValue = unknown;\n\nexport function evaluateWorkflowExpression(\n expression: WorkflowExpression,\n context: WorkflowExpressionEvaluationContext,\n): WorkflowExpressionEvaluationValue {\n try {\n return evaluate(expression.source, context);\n } catch (error) {\n throw new WorkflowExpressionEvaluationError(error);\n }\n}\n\nexport function evaluateWorkflowPredicate(\n expression: WorkflowExpression,\n context: WorkflowExpressionEvaluationContext,\n): boolean {\n return evaluateWorkflowExpression(expression, context) === true;\n}\n\nexport interface FailClosedPredicateOutcome {\n readonly value: boolean;\n readonly evaluationFailed: boolean;\n}\n\nexport function evaluateWorkflowPredicateFailClosed(\n expression: WorkflowExpression,\n context: WorkflowExpressionEvaluationContext,\n): FailClosedPredicateOutcome {\n try {\n return {value: evaluateWorkflowPredicate(expression, context), evaluationFailed: false};\n } catch (error) {\n if (error instanceof WorkflowExpressionEvaluationError) {\n return {value: false, evaluationFailed: true};\n }\n throw error;\n }\n}\n"],"names":["evaluate","WorkflowExpressionEvaluationError","evaluateWorkflowExpression","expression","context","source","error","evaluateWorkflowPredicate","evaluateWorkflowPredicateFailClosed","value","evaluationFailed"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,uBAAuB;AAE9C,SAAQC,iCAAiC,QAAO,cAAc;AAK9D,OAAO,SAASC,2BACdC,UAA8B,EAC9BC,OAA4C;IAE5C,IAAI;QACF,OAAOJ,SAASG,WAAWE,MAAM,EAAED;IACrC,EAAE,OAAOE,OAAO;QACd,MAAM,IAAIL,kCAAkCK;IAC9C;AACF;AAEA,OAAO,SAASC,0BACdJ,UAA8B,EAC9BC,OAA4C;IAE5C,OAAOF,2BAA2BC,YAAYC,aAAa;AAC7D;AAOA,OAAO,SAASI,oCACdL,UAA8B,EAC9BC,OAA4C;IAE5C,IAAI;QACF,OAAO;YAACK,OAAOF,0BAA0BJ,YAAYC;YAAUM,kBAAkB;QAAK;IACxF,EAAE,OAAOJ,OAAO;QACd,IAAIA,iBAAiBL,mCAAmC;YACtD,OAAO;gBAACQ,OAAO;gBAAOC,kBAAkB;YAAI;QAC9C;QACA,MAAMJ;IACR;AACF"}
1
+ {"version":3,"sources":["../../src/evaluator/evaluate-workflow-expression.ts"],"sourcesContent":["import {type Environment, evaluate} from '@marcbachmann/cel-js';\nimport type {WorkflowExpression} from '../expression/workflow-expression.js';\nimport {WorkflowExpressionEvaluationError} from './errors.js';\n\nexport type WorkflowExpressionEvaluationContext = Readonly<Record<string, unknown>>;\nexport type WorkflowExpressionEvaluationValue = unknown;\nexport type WorkflowExpressionEnvironment = Pick<Environment, 'evaluate'>;\n\nexport function evaluateWorkflowExpression(\n expression: WorkflowExpression,\n context: WorkflowExpressionEvaluationContext,\n): WorkflowExpressionEvaluationValue {\n try {\n return evaluate(expression.source, context);\n } catch (error) {\n throw new WorkflowExpressionEvaluationError(error);\n }\n}\n\n/**\n * Evaluate an expression against a caller-owned CEL environment.\n *\n * Workflow expressions deliberately continue to use the global CEL evaluator.\n * Callers that need custom functions, such as config templating, must opt in\n * by creating and passing their own environment.\n */\nexport function evaluateWorkflowExpressionWithEnvironment(\n expression: WorkflowExpression,\n context: WorkflowExpressionEvaluationContext,\n environment: WorkflowExpressionEnvironment,\n): WorkflowExpressionEvaluationValue {\n try {\n return environment.evaluate(expression.source, context);\n } catch (error) {\n throw new WorkflowExpressionEvaluationError(error);\n }\n}\n\nexport function evaluateWorkflowPredicate(\n expression: WorkflowExpression,\n context: WorkflowExpressionEvaluationContext,\n): boolean {\n return evaluateWorkflowExpression(expression, context) === true;\n}\n\nexport interface FailClosedPredicateOutcome {\n readonly value: boolean;\n readonly evaluationFailed: boolean;\n}\n\nexport function evaluateWorkflowPredicateFailClosed(\n expression: WorkflowExpression,\n context: WorkflowExpressionEvaluationContext,\n): FailClosedPredicateOutcome {\n try {\n return {value: evaluateWorkflowPredicate(expression, context), evaluationFailed: false};\n } catch (error) {\n if (error instanceof WorkflowExpressionEvaluationError) {\n return {value: false, evaluationFailed: true};\n }\n throw error;\n }\n}\n"],"names":["evaluate","WorkflowExpressionEvaluationError","evaluateWorkflowExpression","expression","context","source","error","evaluateWorkflowExpressionWithEnvironment","environment","evaluateWorkflowPredicate","evaluateWorkflowPredicateFailClosed","value","evaluationFailed"],"mappings":"AAAA,SAA0BA,QAAQ,QAAO,uBAAuB;AAEhE,SAAQC,iCAAiC,QAAO,cAAc;AAM9D,OAAO,SAASC,2BACdC,UAA8B,EAC9BC,OAA4C;IAE5C,IAAI;QACF,OAAOJ,SAASG,WAAWE,MAAM,EAAED;IACrC,EAAE,OAAOE,OAAO;QACd,MAAM,IAAIL,kCAAkCK;IAC9C;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,0CACdJ,UAA8B,EAC9BC,OAA4C,EAC5CI,WAA0C;IAE1C,IAAI;QACF,OAAOA,YAAYR,QAAQ,CAACG,WAAWE,MAAM,EAAED;IACjD,EAAE,OAAOE,OAAO;QACd,MAAM,IAAIL,kCAAkCK;IAC9C;AACF;AAEA,OAAO,SAASG,0BACdN,UAA8B,EAC9BC,OAA4C;IAE5C,OAAOF,2BAA2BC,YAAYC,aAAa;AAC7D;AAOA,OAAO,SAASM,oCACdP,UAA8B,EAC9BC,OAA4C;IAE5C,IAAI;QACF,OAAO;YAACO,OAAOF,0BAA0BN,YAAYC;YAAUQ,kBAAkB;QAAK;IACxF,EAAE,OAAON,OAAO;QACd,IAAIA,iBAAiBL,mCAAmC;YACtD,OAAO;gBAACU,OAAO;gBAAOC,kBAAkB;YAAI;QAC9C;QACA,MAAMN;IACR;AACF"}
@@ -1,3 +1,4 @@
1
1
  export { WorkflowExpressionEvaluationError, type WorkflowExpressionEvaluationFailureReason, workflowExpressionEvaluationErrorCode, } from './errors.js';
2
- export { evaluateWorkflowExpression, evaluateWorkflowPredicate, evaluateWorkflowPredicateFailClosed, type FailClosedPredicateOutcome, type WorkflowExpressionEvaluationContext, type WorkflowExpressionEvaluationValue, } from './evaluate-workflow-expression.js';
2
+ export { evaluateWorkflowExpression, evaluateWorkflowExpressionWithEnvironment, evaluateWorkflowPredicate, evaluateWorkflowPredicateFailClosed, type FailClosedPredicateOutcome, type WorkflowExpressionEnvironment, type WorkflowExpressionEvaluationContext, type WorkflowExpressionEvaluationValue, } from './evaluate-workflow-expression.js';
3
+ export { createRangeEnvironment, MAX_RANGE_ELEMENTS } from './range.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,KAAK,yCAAyC,EAC9C,qCAAqC,GACtC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,mCAAmC,EACnC,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EACxC,KAAK,iCAAiC,GACvC,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,KAAK,yCAAyC,EAC9C,qCAAqC,GACtC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,0BAA0B,EAC1B,yCAAyC,EACzC,yBAAyB,EACzB,mCAAmC,EACnC,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,mCAAmC,EACxC,KAAK,iCAAiC,GACvC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { WorkflowExpressionEvaluationError, workflowExpressionEvaluationErrorCode } from './errors.js';
2
- export { evaluateWorkflowExpression, evaluateWorkflowPredicate, evaluateWorkflowPredicateFailClosed } from './evaluate-workflow-expression.js';
2
+ export { evaluateWorkflowExpression, evaluateWorkflowExpressionWithEnvironment, evaluateWorkflowPredicate, evaluateWorkflowPredicateFailClosed } from './evaluate-workflow-expression.js';
3
+ export { createRangeEnvironment, MAX_RANGE_ELEMENTS } from './range.js';
3
4
 
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/evaluator/index.ts"],"sourcesContent":["export {\n WorkflowExpressionEvaluationError,\n type WorkflowExpressionEvaluationFailureReason,\n workflowExpressionEvaluationErrorCode,\n} from './errors.js';\nexport {\n evaluateWorkflowExpression,\n evaluateWorkflowPredicate,\n evaluateWorkflowPredicateFailClosed,\n type FailClosedPredicateOutcome,\n type WorkflowExpressionEvaluationContext,\n type WorkflowExpressionEvaluationValue,\n} from './evaluate-workflow-expression.js';\n"],"names":["WorkflowExpressionEvaluationError","workflowExpressionEvaluationErrorCode","evaluateWorkflowExpression","evaluateWorkflowPredicate","evaluateWorkflowPredicateFailClosed"],"mappings":"AAAA,SACEA,iCAAiC,EAEjCC,qCAAqC,QAChC,cAAc;AACrB,SACEC,0BAA0B,EAC1BC,yBAAyB,EACzBC,mCAAmC,QAI9B,oCAAoC"}
1
+ {"version":3,"sources":["../../src/evaluator/index.ts"],"sourcesContent":["export {\n WorkflowExpressionEvaluationError,\n type WorkflowExpressionEvaluationFailureReason,\n workflowExpressionEvaluationErrorCode,\n} from './errors.js';\nexport {\n evaluateWorkflowExpression,\n evaluateWorkflowExpressionWithEnvironment,\n evaluateWorkflowPredicate,\n evaluateWorkflowPredicateFailClosed,\n type FailClosedPredicateOutcome,\n type WorkflowExpressionEnvironment,\n type WorkflowExpressionEvaluationContext,\n type WorkflowExpressionEvaluationValue,\n} from './evaluate-workflow-expression.js';\nexport {createRangeEnvironment, MAX_RANGE_ELEMENTS} from './range.js';\n"],"names":["WorkflowExpressionEvaluationError","workflowExpressionEvaluationErrorCode","evaluateWorkflowExpression","evaluateWorkflowExpressionWithEnvironment","evaluateWorkflowPredicate","evaluateWorkflowPredicateFailClosed","createRangeEnvironment","MAX_RANGE_ELEMENTS"],"mappings":"AAAA,SACEA,iCAAiC,EAEjCC,qCAAqC,QAChC,cAAc;AACrB,SACEC,0BAA0B,EAC1BC,yCAAyC,EACzCC,yBAAyB,EACzBC,mCAAmC,QAK9B,oCAAoC;AAC3C,SAAQC,sBAAsB,EAAEC,kBAAkB,QAAO,aAAa"}
@@ -0,0 +1,6 @@
1
+ import type { WorkflowExpressionEnvironment } from './evaluate-workflow-expression.js';
2
+ /** Maximum number of values a config-template range may materialize. */
3
+ export declare const MAX_RANGE_ELEMENTS = 1000;
4
+ /** Create the opt-in range evaluator for config templating. */
5
+ export declare function createRangeEnvironment(): WorkflowExpressionEnvironment;
6
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/evaluator/range.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,6BAA6B,EAAC,MAAM,mCAAmC,CAAC;AAErF,wEAAwE;AACxE,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AA+CxC,+DAA+D;AAC/D,wBAAgB,sBAAsB,IAAI,6BAA6B,CAWtE"}
@@ -0,0 +1,46 @@
1
+ import { Environment } from '@marcbachmann/cel-js';
2
+ /** Maximum number of values a config-template range may materialize. */ export const MAX_RANGE_ELEMENTS = 1_000;
3
+ const RANGE_FUNCTION_SIGNATURE = 'range(dyn, dyn, dyn): list<int>';
4
+ function materializeRange(start, stop, step) {
5
+ const values = [];
6
+ for(let value = start; value <= stop; value += step)values.push(value);
7
+ return values;
8
+ }
9
+ function rangeElementCount(start, stop, step) {
10
+ if (step <= 0n) throw new RangeError('range step must be positive');
11
+ if (start > stop) return 0n;
12
+ return (stop - start) / step + 1n;
13
+ }
14
+ function toCelInteger(value, name) {
15
+ if (typeof value === 'bigint') return value;
16
+ if (typeof value === 'number' && Number.isSafeInteger(value)) return BigInt(value);
17
+ throw new RangeError(`${name} must be a safe integer`);
18
+ }
19
+ function evaluateRange(budget, start, stop, step) {
20
+ const startValue = toCelInteger(start, 'range start');
21
+ const stopValue = toCelInteger(stop, 'range stop');
22
+ const stepValue = toCelInteger(step, 'range step');
23
+ const count = rangeElementCount(startValue, stopValue, stepValue);
24
+ if (count > BigInt(budget.remaining)) {
25
+ throw new RangeError(`range evaluation budget exceeded; ${count} elements requested with ${budget.remaining} remaining`);
26
+ }
27
+ const values = materializeRange(startValue, stopValue, stepValue);
28
+ budget.remaining -= values.length;
29
+ return values;
30
+ }
31
+ /** Create the opt-in range evaluator for config templating. */ export function createRangeEnvironment() {
32
+ return {
33
+ evaluate (expression, context) {
34
+ const budget = {
35
+ remaining: MAX_RANGE_ELEMENTS
36
+ };
37
+ const environment = new Environment({
38
+ unlistedVariablesAreDyn: true
39
+ });
40
+ environment.registerFunction(RANGE_FUNCTION_SIGNATURE, (start, stop, step)=>evaluateRange(budget, start, stop, step));
41
+ return environment.evaluate(expression, context);
42
+ }
43
+ };
44
+ }
45
+
46
+ //# sourceMappingURL=range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/evaluator/range.ts"],"sourcesContent":["import {type Context, Environment} from '@marcbachmann/cel-js';\nimport type {WorkflowExpressionEnvironment} from './evaluate-workflow-expression.js';\n\n/** Maximum number of values a config-template range may materialize. */\nexport const MAX_RANGE_ELEMENTS = 1_000;\nconst RANGE_FUNCTION_SIGNATURE = 'range(dyn, dyn, dyn): list<int>';\n\ninterface RangeBudget {\n remaining: number;\n}\n\nfunction materializeRange(start: bigint, stop: bigint, step: bigint): bigint[] {\n const values: bigint[] = [];\n for (let value = start; value <= stop; value += step) values.push(value);\n return values;\n}\n\nfunction rangeElementCount(start: bigint, stop: bigint, step: bigint): bigint {\n if (step <= 0n) throw new RangeError('range step must be positive');\n if (start > stop) return 0n;\n\n return (stop - start) / step + 1n;\n}\n\nfunction toCelInteger(value: unknown, name: string): bigint {\n if (typeof value === 'bigint') return value;\n if (typeof value === 'number' && Number.isSafeInteger(value)) return BigInt(value);\n throw new RangeError(`${name} must be a safe integer`);\n}\n\nfunction evaluateRange(\n budget: RangeBudget,\n start: unknown,\n stop: unknown,\n step: unknown,\n): bigint[] {\n const startValue = toCelInteger(start, 'range start');\n const stopValue = toCelInteger(stop, 'range stop');\n const stepValue = toCelInteger(step, 'range step');\n const count = rangeElementCount(startValue, stopValue, stepValue);\n if (count > BigInt(budget.remaining)) {\n throw new RangeError(\n `range evaluation budget exceeded; ${count} elements requested with ${budget.remaining} remaining`,\n );\n }\n\n const values = materializeRange(startValue, stopValue, stepValue);\n budget.remaining -= values.length;\n return values;\n}\n\n/** Create the opt-in range evaluator for config templating. */\nexport function createRangeEnvironment(): WorkflowExpressionEnvironment {\n return {\n evaluate(expression: string, context?: Context) {\n const budget = {remaining: MAX_RANGE_ELEMENTS};\n const environment = new Environment({unlistedVariablesAreDyn: true});\n environment.registerFunction(RANGE_FUNCTION_SIGNATURE, (start, stop, step) =>\n evaluateRange(budget, start, stop, step),\n );\n return environment.evaluate(expression, context);\n },\n };\n}\n"],"names":["Environment","MAX_RANGE_ELEMENTS","RANGE_FUNCTION_SIGNATURE","materializeRange","start","stop","step","values","value","push","rangeElementCount","RangeError","toCelInteger","name","Number","isSafeInteger","BigInt","evaluateRange","budget","startValue","stopValue","stepValue","count","remaining","length","createRangeEnvironment","evaluate","expression","context","environment","unlistedVariablesAreDyn","registerFunction"],"mappings":"AAAA,SAAsBA,WAAW,QAAO,uBAAuB;AAG/D,sEAAsE,GACtE,OAAO,MAAMC,qBAAqB,MAAM;AACxC,MAAMC,2BAA2B;AAMjC,SAASC,iBAAiBC,KAAa,EAAEC,IAAY,EAAEC,IAAY;IACjE,MAAMC,SAAmB,EAAE;IAC3B,IAAK,IAAIC,QAAQJ,OAAOI,SAASH,MAAMG,SAASF,KAAMC,OAAOE,IAAI,CAACD;IAClE,OAAOD;AACT;AAEA,SAASG,kBAAkBN,KAAa,EAAEC,IAAY,EAAEC,IAAY;IAClE,IAAIA,QAAQ,EAAE,EAAE,MAAM,IAAIK,WAAW;IACrC,IAAIP,QAAQC,MAAM,OAAO,EAAE;IAE3B,OAAO,AAACA,CAAAA,OAAOD,KAAI,IAAKE,OAAO,EAAE;AACnC;AAEA,SAASM,aAAaJ,KAAc,EAAEK,IAAY;IAChD,IAAI,OAAOL,UAAU,UAAU,OAAOA;IACtC,IAAI,OAAOA,UAAU,YAAYM,OAAOC,aAAa,CAACP,QAAQ,OAAOQ,OAAOR;IAC5E,MAAM,IAAIG,WAAW,GAAGE,KAAK,uBAAuB,CAAC;AACvD;AAEA,SAASI,cACPC,MAAmB,EACnBd,KAAc,EACdC,IAAa,EACbC,IAAa;IAEb,MAAMa,aAAaP,aAAaR,OAAO;IACvC,MAAMgB,YAAYR,aAAaP,MAAM;IACrC,MAAMgB,YAAYT,aAAaN,MAAM;IACrC,MAAMgB,QAAQZ,kBAAkBS,YAAYC,WAAWC;IACvD,IAAIC,QAAQN,OAAOE,OAAOK,SAAS,GAAG;QACpC,MAAM,IAAIZ,WACR,CAAC,kCAAkC,EAAEW,MAAM,yBAAyB,EAAEJ,OAAOK,SAAS,CAAC,UAAU,CAAC;IAEtG;IAEA,MAAMhB,SAASJ,iBAAiBgB,YAAYC,WAAWC;IACvDH,OAAOK,SAAS,IAAIhB,OAAOiB,MAAM;IACjC,OAAOjB;AACT;AAEA,6DAA6D,GAC7D,OAAO,SAASkB;IACd,OAAO;QACLC,UAASC,UAAkB,EAAEC,OAAiB;YAC5C,MAAMV,SAAS;gBAACK,WAAWtB;YAAkB;YAC7C,MAAM4B,cAAc,IAAI7B,YAAY;gBAAC8B,yBAAyB;YAAI;YAClED,YAAYE,gBAAgB,CAAC7B,0BAA0B,CAACE,OAAOC,MAAMC,OACnEW,cAAcC,QAAQd,OAAOC,MAAMC;YAErC,OAAOuB,YAAYH,QAAQ,CAACC,YAAYC;QAC1C;IACF;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { WorkflowExpressionEvaluationError, type WorkflowExpressionEvaluationFailureReason, workflowExpressionEvaluationErrorCode, } from './evaluator/errors.js';
2
- export { evaluateWorkflowExpression, evaluateWorkflowPredicate, evaluateWorkflowPredicateFailClosed, type FailClosedPredicateOutcome, type WorkflowExpressionEvaluationContext, type WorkflowExpressionEvaluationValue, } from './evaluator/evaluate-workflow-expression.js';
2
+ export { evaluateWorkflowExpression, evaluateWorkflowExpressionWithEnvironment, evaluateWorkflowPredicate, evaluateWorkflowPredicateFailClosed, type FailClosedPredicateOutcome, type WorkflowExpressionEnvironment, type WorkflowExpressionEvaluationContext, type WorkflowExpressionEvaluationValue, } from './evaluator/evaluate-workflow-expression.js';
3
+ export { createRangeEnvironment, MAX_RANGE_ELEMENTS } from './evaluator/range.js';
3
4
  export { createWorkflowExpression, unsafeWorkflowExpressionFromSource, } from './expression/create-workflow-expression.js';
4
5
  export { InvalidWorkflowExpressionError, invalidWorkflowExpressionErrorCode, } from './expression/errors.js';
5
6
  export type { CreateWorkflowExpressionParams, ExpressionScalarType, ExpressionType, ExpressionTypeEnvironment, ValidCelExpression, WorkflowExpression, WorkflowExpressionCheck, WorkflowExpressionCheckOptions, } from './expression/workflow-expression.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,KAAK,yCAAyC,EAC9C,qCAAqC,GACtC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,mCAAmC,EACnC,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EACxC,KAAK,iCAAiC,GACvC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,8BAA8B,EAC9B,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,8BAA8B,EAC9B,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,0BAA0B,EAC/B,0BAA0B,EAC1B,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,oCAAoC,EACpC,iCAAiC,EACjC,WAAW,EACX,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,GACnC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAC,8BAA8B,EAAC,MAAM,sCAAsC,CAAC;AACpF,O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3B,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,gBAAgB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,KAAK,UAAU,EACf,8BAA8B,EAC9B,4BAA4B,EAC5B,sBAAsB,EACtB,6BAA6B,EAC7B,iCAAiC,EACjC,gCAAgC,EAChC,0CAA0C,EAC1C,0CAA0C,EAC1C,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,+BAA+B,EACpC,8BAA8B,EAC9B,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,8BAA8B,EACnC,kBAAkB,EAClB,KAAK,yCAAyC,EAC9C,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,kCAAkC,EACvC,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACrC,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,oCAAoC,EACpC,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,qCAAqC,EACrC,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,EAC5B,wCAAwC,EACxC,qCAAqC,EACrC,0CAA0C,EAC1C,kCAAkC,EAClC,2BAA2B,EAC3B,mCAAmC,EACnC,uBAAuB,GACxB,MAAM,wCAAwC,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { WorkflowExpressionEvaluationError, workflowExpressionEvaluationErrorCode } from './evaluator/errors.js';
2
- export { evaluateWorkflowExpression, evaluateWorkflowPredicate, evaluateWorkflowPredicateFailClosed } from './evaluator/evaluate-workflow-expression.js';
2
+ export { evaluateWorkflowExpression, evaluateWorkflowExpressionWithEnvironment, evaluateWorkflowPredicate, evaluateWorkflowPredicateFailClosed } from './evaluator/evaluate-workflow-expression.js';
3
+ export { createRangeEnvironment, MAX_RANGE_ELEMENTS } from './evaluator/range.js';
3
4
  export { createWorkflowExpression, unsafeWorkflowExpressionFromSource } from './expression/create-workflow-expression.js';
4
5
  export { InvalidWorkflowExpressionError, invalidWorkflowExpressionErrorCode } from './expression/errors.js';
5
6
  export { coerceStepOutputs, jsonSchemaToExpressionType, outputDeclarationsToExpressionFields, outputDeclarationToExpressionType, outputTypes, validateJsonSchema } from './outputs/index.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n WorkflowExpressionEvaluationError,\n type WorkflowExpressionEvaluationFailureReason,\n workflowExpressionEvaluationErrorCode,\n} from './evaluator/errors.js';\nexport {\n evaluateWorkflowExpression,\n evaluateWorkflowPredicate,\n evaluateWorkflowPredicateFailClosed,\n type FailClosedPredicateOutcome,\n type WorkflowExpressionEvaluationContext,\n type WorkflowExpressionEvaluationValue,\n} from './evaluator/evaluate-workflow-expression.js';\nexport {\n createWorkflowExpression,\n unsafeWorkflowExpressionFromSource,\n} from './expression/create-workflow-expression.js';\nexport {\n InvalidWorkflowExpressionError,\n invalidWorkflowExpressionErrorCode,\n} from './expression/errors.js';\nexport type {\n CreateWorkflowExpressionParams,\n ExpressionScalarType,\n ExpressionType,\n ExpressionTypeEnvironment,\n ValidCelExpression,\n WorkflowExpression,\n WorkflowExpressionCheck,\n WorkflowExpressionCheckOptions,\n} from './expression/workflow-expression.js';\nexport {\n type CoerceStepOutputsResult,\n coerceStepOutputs,\n type JsonSchemaValidationResult,\n jsonSchemaToExpressionType,\n type OutputDeclarations,\n type OutputType,\n type OutputTypeDeclaration,\n outputDeclarationsToExpressionFields,\n outputDeclarationToExpressionType,\n outputTypes,\n type StepOutputCoercionError,\n type StepOutputCoercionErrorReason,\n validateJsonSchema,\n} from './outputs/index.js';\nexport {isBareContextReference} from './plan/bare-reference.js';\nexport {\n analyzeContextKeyAccess,\n analyzeContextRootKeyAccess,\n type ContextKeyAccessAnalysis,\n type ContextKeyAccessReference,\n type ContextKeyAccessViolation,\n type ContextRootKeyAccessAnalysis,\n type ContextRootKeyAccessReference,\n} from './plan/context-key-access.js';\nexport {evaluatePlannedPredicateAtSite} from './plan/evaluate-planned-predicate.js';\nexport {\n capTraceEntries,\n capTraceValue,\n EVALUATION_TRACE_MAX_ENTRIES,\n EVALUATION_TRACE_VALUE_CAP_BYTES,\n type EvaluationTraceEntry,\n type EvaluationTraceLimitEntry,\n type EvaluationTraceRowEntry,\n evaluationTraceEntry,\n predicateTraceEntry,\n} from './plan/evaluation-trace.js';\nexport {extractExactContextRoots} from './plan/extract-exact-context-roots.js';\nexport {\n type FrozenResolvedField,\n freezeResolvedFieldAtSite,\n resolveFieldAtSite,\n type SiteResolvedField,\n type WorkflowTemplateDiagnostic,\n type WorkflowTemplateFailurePolicy,\n} from './plan/freeze.js';\nexport {\n type FrozenPlannedRunCommand,\n freezePlannedRunCommandAtSite,\n} from './plan/freeze-run-command.js';\nexport {\n type FieldPlan,\n type FieldPlanResult,\n type PlanViolation,\n planInterpolationField,\n} from './plan/plan-field.js';\nexport {predicateSourceIsBooleanShaped} from './plan/predicate-shape.js';\nexport type {\n ResolvedField,\n ResolvedFieldDeferredSegment,\n ResolvedFieldLiteralSegment,\n ResolvedFieldSegment,\n} from './plan/resolved-field.js';\nexport {type RoutedExpression, routeExpression} from './plan/route-expression.js';\nexport {\n type ServerEvaluabilityResult,\n type ServerEvaluabilityViolation,\n validateServerEvaluable,\n} from './plan/validate-server-evaluable.js';\nexport {\n WorkflowTemplateResolutionError,\n workflowTemplateResolutionErrorCode,\n} from './resolver/errors.js';\nexport {\n type HoistedPlannedRunCommand,\n hoistPlannedRunCommand,\n type PlannedRunCommandBinding,\n type RunCommandHoistOptions,\n UnsafeRunInterpolationError,\n unsafeRunInterpolationErrorCode,\n} from './run/hoist-run-command.js';\nexport {\n InvalidWorkflowTemplateError,\n invalidWorkflowTemplateErrorCode,\n} from './template/errors.js';\nexport {extractCelContextRoots} from './template/extract-cel-context-roots.js';\nexport {extractCelUntrustedPathAccesses} from './template/extract-cel-untrusted-path-accesses.js';\nexport {parseWorkflowTemplate} from './template/parse-workflow-template.js';\nexport type {\n WorkflowTemplateExprSegment,\n WorkflowTemplateLiteralSegment,\n WorkflowTemplateSegment,\n} from './template/template-segment.js';\nexport {\n type AvailabilitySite,\n availabilitySites,\n buildTypedRootsEnvironment,\n type FillTarget,\n getWorkflowContextAvailability,\n getWorkflowContextDefinition,\n getWorkflowContextHost,\n getWorkflowContextSensitivity,\n getWorkflowContextTypeEnvironment,\n getWorkflowContextUntrustedPaths,\n getWorkflowInterpolationFieldFailurePolicy,\n getWorkflowPredicateFieldMinimumFillTarget,\n type OpenWorkflowContextDefinition,\n type ReservedRootDefinition,\n type RunnerWorkflowContextDefinition,\n resolveContextRootAvailability,\n resolveContextRootHost,\n rootsAvailableAt,\n runnerFillTarget,\n type TypedWorkflowContextDefinition,\n unavailableRootsAt,\n type WorkflowContextAvailabilityReferenceEntry,\n type WorkflowContextDefinition,\n type WorkflowContextHost,\n type WorkflowContextName,\n type WorkflowContextReservedRoot,\n type WorkflowContextSensitivity,\n type WorkflowContextShape,\n type WorkflowContextTrustTier,\n type WorkflowFieldFailurePolicy,\n type WorkflowInterpolationFailurePolicy,\n type WorkflowInterpolationField,\n type WorkflowInterpolationFieldPolicy,\n type WorkflowJobTypeOverlay,\n type WorkflowPredicateField,\n type WorkflowStepTypeOverlay,\n workflowContextAvailabilityReference,\n workflowContextDefinitions,\n workflowContextHosts,\n workflowContextNames,\n workflowContextReservedRoots,\n workflowContextRootRequiresLiteralKey,\n workflowContextSensitivities,\n workflowContextTrustTiers,\n workflowFieldFailurePolicies,\n workflowInterpolationFieldAcceptsContext,\n workflowInterpolationFieldAcceptsHost,\n workflowInterpolationFieldAcceptsTrustTier,\n workflowInterpolationFieldPolicies,\n workflowInterpolationFields,\n workflowPredicateFieldFailurePolicy,\n workflowPredicateFields,\n} from './workflow-context/workflow-context.js';\n"],"names":["WorkflowExpressionEvaluationError","workflowExpressionEvaluationErrorCode","evaluateWorkflowExpression","evaluateWorkflowPredicate","evaluateWorkflowPredicateFailClosed","createWorkflowExpression","unsafeWorkflowExpressionFromSource","InvalidWorkflowExpressionError","invalidWorkflowExpressionErrorCode","coerceStepOutputs","jsonSchemaToExpressionType","outputDeclarationsToExpressionFields","outputDeclarationToExpressionType","outputTypes","validateJsonSchema","isBareContextReference","analyzeContextKeyAccess","analyzeContextRootKeyAccess","evaluatePlannedPredicateAtSite","capTraceEntries","capTraceValue","EVALUATION_TRACE_MAX_ENTRIES","EVALUATION_TRACE_VALUE_CAP_BYTES","evaluationTraceEntry","predicateTraceEntry","extractExactContextRoots","freezeResolvedFieldAtSite","resolveFieldAtSite","freezePlannedRunCommandAtSite","planInterpolationField","predicateSourceIsBooleanShaped","routeExpression","validateServerEvaluable","WorkflowTemplateResolutionError","workflowTemplateResolutionErrorCode","hoistPlannedRunCommand","UnsafeRunInterpolationError","unsafeRunInterpolationErrorCode","InvalidWorkflowTemplateError","invalidWorkflowTemplateErrorCode","extractCelContextRoots","extractCelUntrustedPathAccesses","parseWorkflowTemplate","availabilitySites","buildTypedRootsEnvironment","getWorkflowContextAvailability","getWorkflowContextDefinition","getWorkflowContextHost","getWorkflowContextSensitivity","getWorkflowContextTypeEnvironment","getWorkflowContextUntrustedPaths","getWorkflowInterpolationFieldFailurePolicy","getWorkflowPredicateFieldMinimumFillTarget","resolveContextRootAvailability","resolveContextRootHost","rootsAvailableAt","runnerFillTarget","unavailableRootsAt","workflowContextAvailabilityReference","workflowContextDefinitions","workflowContextHosts","workflowContextNames","workflowContextReservedRoots","workflowContextRootRequiresLiteralKey","workflowContextSensitivities","workflowContextTrustTiers","workflowFieldFailurePolicies","workflowInterpolationFieldAcceptsContext","workflowInterpolationFieldAcceptsHost","workflowInterpolationFieldAcceptsTrustTier","workflowInterpolationFieldPolicies","workflowInterpolationFields","workflowPredicateFieldFailurePolicy","workflowPredicateFields"],"mappings":"AAAA,SACEA,iCAAiC,EAEjCC,qCAAqC,QAChC,wBAAwB;AAC/B,SACEC,0BAA0B,EAC1BC,yBAAyB,EACzBC,mCAAmC,QAI9B,8CAA8C;AACrD,SACEC,wBAAwB,EACxBC,kCAAkC,QAC7B,6CAA6C;AACpD,SACEC,8BAA8B,EAC9BC,kCAAkC,QAC7B,yBAAyB;AAWhC,SAEEC,iBAAiB,EAEjBC,0BAA0B,EAI1BC,oCAAoC,EACpCC,iCAAiC,EACjCC,WAAW,EAGXC,kBAAkB,QACb,qBAAqB;AAC5B,SAAQC,sBAAsB,QAAO,2BAA2B;AAChE,SACEC,uBAAuB,EACvBC,2BAA2B,QAMtB,+BAA+B;AACtC,SAAQC,8BAA8B,QAAO,uCAAuC;AACpF,SACEC,eAAe,EACfC,aAAa,EACbC,4BAA4B,EAC5BC,gCAAgC,EAIhCC,oBAAoB,EACpBC,mBAAmB,QACd,6BAA6B;AACpC,SAAQC,wBAAwB,QAAO,wCAAwC;AAC/E,SAEEC,yBAAyB,EACzBC,kBAAkB,QAIb,mBAAmB;AAC1B,SAEEC,6BAA6B,QACxB,+BAA+B;AACtC,SAIEC,sBAAsB,QACjB,uBAAuB;AAC9B,SAAQC,8BAA8B,QAAO,4BAA4B;AAOzE,SAA+BC,eAAe,QAAO,6BAA6B;AAClF,SAGEC,uBAAuB,QAClB,sCAAsC;AAC7C,SACEC,+BAA+B,EAC/BC,mCAAmC,QAC9B,uBAAuB;AAC9B,SAEEC,sBAAsB,EAGtBC,2BAA2B,EAC3BC,+BAA+B,QAC1B,6BAA6B;AACpC,SACEC,4BAA4B,EAC5BC,gCAAgC,QAC3B,uBAAuB;AAC9B,SAAQC,sBAAsB,QAAO,0CAA0C;AAC/E,SAAQC,+BAA+B,QAAO,oDAAoD;AAClG,SAAQC,qBAAqB,QAAO,wCAAwC;AAM5E,SAEEC,iBAAiB,EACjBC,0BAA0B,EAE1BC,8BAA8B,EAC9BC,4BAA4B,EAC5BC,sBAAsB,EACtBC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gCAAgC,EAChCC,0CAA0C,EAC1CC,0CAA0C,EAI1CC,8BAA8B,EAC9BC,sBAAsB,EACtBC,gBAAgB,EAChBC,gBAAgB,EAEhBC,kBAAkB,EAgBlBC,oCAAoC,EACpCC,0BAA0B,EAC1BC,oBAAoB,EACpBC,oBAAoB,EACpBC,4BAA4B,EAC5BC,qCAAqC,EACrCC,4BAA4B,EAC5BC,yBAAyB,EACzBC,4BAA4B,EAC5BC,wCAAwC,EACxCC,qCAAqC,EACrCC,0CAA0C,EAC1CC,kCAAkC,EAClCC,2BAA2B,EAC3BC,mCAAmC,EACnCC,uBAAuB,QAClB,yCAAyC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n WorkflowExpressionEvaluationError,\n type WorkflowExpressionEvaluationFailureReason,\n workflowExpressionEvaluationErrorCode,\n} from './evaluator/errors.js';\nexport {\n evaluateWorkflowExpression,\n evaluateWorkflowExpressionWithEnvironment,\n evaluateWorkflowPredicate,\n evaluateWorkflowPredicateFailClosed,\n type FailClosedPredicateOutcome,\n type WorkflowExpressionEnvironment,\n type WorkflowExpressionEvaluationContext,\n type WorkflowExpressionEvaluationValue,\n} from './evaluator/evaluate-workflow-expression.js';\nexport {createRangeEnvironment, MAX_RANGE_ELEMENTS} from './evaluator/range.js';\nexport {\n createWorkflowExpression,\n unsafeWorkflowExpressionFromSource,\n} from './expression/create-workflow-expression.js';\nexport {\n InvalidWorkflowExpressionError,\n invalidWorkflowExpressionErrorCode,\n} from './expression/errors.js';\nexport type {\n CreateWorkflowExpressionParams,\n ExpressionScalarType,\n ExpressionType,\n ExpressionTypeEnvironment,\n ValidCelExpression,\n WorkflowExpression,\n WorkflowExpressionCheck,\n WorkflowExpressionCheckOptions,\n} from './expression/workflow-expression.js';\nexport {\n type CoerceStepOutputsResult,\n coerceStepOutputs,\n type JsonSchemaValidationResult,\n jsonSchemaToExpressionType,\n type OutputDeclarations,\n type OutputType,\n type OutputTypeDeclaration,\n outputDeclarationsToExpressionFields,\n outputDeclarationToExpressionType,\n outputTypes,\n type StepOutputCoercionError,\n type StepOutputCoercionErrorReason,\n validateJsonSchema,\n} from './outputs/index.js';\nexport {isBareContextReference} from './plan/bare-reference.js';\nexport {\n analyzeContextKeyAccess,\n analyzeContextRootKeyAccess,\n type ContextKeyAccessAnalysis,\n type ContextKeyAccessReference,\n type ContextKeyAccessViolation,\n type ContextRootKeyAccessAnalysis,\n type ContextRootKeyAccessReference,\n} from './plan/context-key-access.js';\nexport {evaluatePlannedPredicateAtSite} from './plan/evaluate-planned-predicate.js';\nexport {\n capTraceEntries,\n capTraceValue,\n EVALUATION_TRACE_MAX_ENTRIES,\n EVALUATION_TRACE_VALUE_CAP_BYTES,\n type EvaluationTraceEntry,\n type EvaluationTraceLimitEntry,\n type EvaluationTraceRowEntry,\n evaluationTraceEntry,\n predicateTraceEntry,\n} from './plan/evaluation-trace.js';\nexport {extractExactContextRoots} from './plan/extract-exact-context-roots.js';\nexport {\n type FrozenResolvedField,\n freezeResolvedFieldAtSite,\n resolveFieldAtSite,\n type SiteResolvedField,\n type WorkflowTemplateDiagnostic,\n type WorkflowTemplateFailurePolicy,\n} from './plan/freeze.js';\nexport {\n type FrozenPlannedRunCommand,\n freezePlannedRunCommandAtSite,\n} from './plan/freeze-run-command.js';\nexport {\n type FieldPlan,\n type FieldPlanResult,\n type PlanViolation,\n planInterpolationField,\n} from './plan/plan-field.js';\nexport {predicateSourceIsBooleanShaped} from './plan/predicate-shape.js';\nexport type {\n ResolvedField,\n ResolvedFieldDeferredSegment,\n ResolvedFieldLiteralSegment,\n ResolvedFieldSegment,\n} from './plan/resolved-field.js';\nexport {type RoutedExpression, routeExpression} from './plan/route-expression.js';\nexport {\n type ServerEvaluabilityResult,\n type ServerEvaluabilityViolation,\n validateServerEvaluable,\n} from './plan/validate-server-evaluable.js';\nexport {\n WorkflowTemplateResolutionError,\n workflowTemplateResolutionErrorCode,\n} from './resolver/errors.js';\nexport {\n type HoistedPlannedRunCommand,\n hoistPlannedRunCommand,\n type PlannedRunCommandBinding,\n type RunCommandHoistOptions,\n UnsafeRunInterpolationError,\n unsafeRunInterpolationErrorCode,\n} from './run/hoist-run-command.js';\nexport {\n InvalidWorkflowTemplateError,\n invalidWorkflowTemplateErrorCode,\n} from './template/errors.js';\nexport {extractCelContextRoots} from './template/extract-cel-context-roots.js';\nexport {extractCelUntrustedPathAccesses} from './template/extract-cel-untrusted-path-accesses.js';\nexport {parseWorkflowTemplate} from './template/parse-workflow-template.js';\nexport type {\n WorkflowTemplateExprSegment,\n WorkflowTemplateLiteralSegment,\n WorkflowTemplateSegment,\n} from './template/template-segment.js';\nexport {\n type AvailabilitySite,\n availabilitySites,\n buildTypedRootsEnvironment,\n type FillTarget,\n getWorkflowContextAvailability,\n getWorkflowContextDefinition,\n getWorkflowContextHost,\n getWorkflowContextSensitivity,\n getWorkflowContextTypeEnvironment,\n getWorkflowContextUntrustedPaths,\n getWorkflowInterpolationFieldFailurePolicy,\n getWorkflowPredicateFieldMinimumFillTarget,\n type OpenWorkflowContextDefinition,\n type ReservedRootDefinition,\n type RunnerWorkflowContextDefinition,\n resolveContextRootAvailability,\n resolveContextRootHost,\n rootsAvailableAt,\n runnerFillTarget,\n type TypedWorkflowContextDefinition,\n unavailableRootsAt,\n type WorkflowContextAvailabilityReferenceEntry,\n type WorkflowContextDefinition,\n type WorkflowContextHost,\n type WorkflowContextName,\n type WorkflowContextReservedRoot,\n type WorkflowContextSensitivity,\n type WorkflowContextShape,\n type WorkflowContextTrustTier,\n type WorkflowFieldFailurePolicy,\n type WorkflowInterpolationFailurePolicy,\n type WorkflowInterpolationField,\n type WorkflowInterpolationFieldPolicy,\n type WorkflowJobTypeOverlay,\n type WorkflowPredicateField,\n type WorkflowStepTypeOverlay,\n workflowContextAvailabilityReference,\n workflowContextDefinitions,\n workflowContextHosts,\n workflowContextNames,\n workflowContextReservedRoots,\n workflowContextRootRequiresLiteralKey,\n workflowContextSensitivities,\n workflowContextTrustTiers,\n workflowFieldFailurePolicies,\n workflowInterpolationFieldAcceptsContext,\n workflowInterpolationFieldAcceptsHost,\n workflowInterpolationFieldAcceptsTrustTier,\n workflowInterpolationFieldPolicies,\n workflowInterpolationFields,\n workflowPredicateFieldFailurePolicy,\n workflowPredicateFields,\n} from './workflow-context/workflow-context.js';\n"],"names":["WorkflowExpressionEvaluationError","workflowExpressionEvaluationErrorCode","evaluateWorkflowExpression","evaluateWorkflowExpressionWithEnvironment","evaluateWorkflowPredicate","evaluateWorkflowPredicateFailClosed","createRangeEnvironment","MAX_RANGE_ELEMENTS","createWorkflowExpression","unsafeWorkflowExpressionFromSource","InvalidWorkflowExpressionError","invalidWorkflowExpressionErrorCode","coerceStepOutputs","jsonSchemaToExpressionType","outputDeclarationsToExpressionFields","outputDeclarationToExpressionType","outputTypes","validateJsonSchema","isBareContextReference","analyzeContextKeyAccess","analyzeContextRootKeyAccess","evaluatePlannedPredicateAtSite","capTraceEntries","capTraceValue","EVALUATION_TRACE_MAX_ENTRIES","EVALUATION_TRACE_VALUE_CAP_BYTES","evaluationTraceEntry","predicateTraceEntry","extractExactContextRoots","freezeResolvedFieldAtSite","resolveFieldAtSite","freezePlannedRunCommandAtSite","planInterpolationField","predicateSourceIsBooleanShaped","routeExpression","validateServerEvaluable","WorkflowTemplateResolutionError","workflowTemplateResolutionErrorCode","hoistPlannedRunCommand","UnsafeRunInterpolationError","unsafeRunInterpolationErrorCode","InvalidWorkflowTemplateError","invalidWorkflowTemplateErrorCode","extractCelContextRoots","extractCelUntrustedPathAccesses","parseWorkflowTemplate","availabilitySites","buildTypedRootsEnvironment","getWorkflowContextAvailability","getWorkflowContextDefinition","getWorkflowContextHost","getWorkflowContextSensitivity","getWorkflowContextTypeEnvironment","getWorkflowContextUntrustedPaths","getWorkflowInterpolationFieldFailurePolicy","getWorkflowPredicateFieldMinimumFillTarget","resolveContextRootAvailability","resolveContextRootHost","rootsAvailableAt","runnerFillTarget","unavailableRootsAt","workflowContextAvailabilityReference","workflowContextDefinitions","workflowContextHosts","workflowContextNames","workflowContextReservedRoots","workflowContextRootRequiresLiteralKey","workflowContextSensitivities","workflowContextTrustTiers","workflowFieldFailurePolicies","workflowInterpolationFieldAcceptsContext","workflowInterpolationFieldAcceptsHost","workflowInterpolationFieldAcceptsTrustTier","workflowInterpolationFieldPolicies","workflowInterpolationFields","workflowPredicateFieldFailurePolicy","workflowPredicateFields"],"mappings":"AAAA,SACEA,iCAAiC,EAEjCC,qCAAqC,QAChC,wBAAwB;AAC/B,SACEC,0BAA0B,EAC1BC,yCAAyC,EACzCC,yBAAyB,EACzBC,mCAAmC,QAK9B,8CAA8C;AACrD,SAAQC,sBAAsB,EAAEC,kBAAkB,QAAO,uBAAuB;AAChF,SACEC,wBAAwB,EACxBC,kCAAkC,QAC7B,6CAA6C;AACpD,SACEC,8BAA8B,EAC9BC,kCAAkC,QAC7B,yBAAyB;AAWhC,SAEEC,iBAAiB,EAEjBC,0BAA0B,EAI1BC,oCAAoC,EACpCC,iCAAiC,EACjCC,WAAW,EAGXC,kBAAkB,QACb,qBAAqB;AAC5B,SAAQC,sBAAsB,QAAO,2BAA2B;AAChE,SACEC,uBAAuB,EACvBC,2BAA2B,QAMtB,+BAA+B;AACtC,SAAQC,8BAA8B,QAAO,uCAAuC;AACpF,SACEC,eAAe,EACfC,aAAa,EACbC,4BAA4B,EAC5BC,gCAAgC,EAIhCC,oBAAoB,EACpBC,mBAAmB,QACd,6BAA6B;AACpC,SAAQC,wBAAwB,QAAO,wCAAwC;AAC/E,SAEEC,yBAAyB,EACzBC,kBAAkB,QAIb,mBAAmB;AAC1B,SAEEC,6BAA6B,QACxB,+BAA+B;AACtC,SAIEC,sBAAsB,QACjB,uBAAuB;AAC9B,SAAQC,8BAA8B,QAAO,4BAA4B;AAOzE,SAA+BC,eAAe,QAAO,6BAA6B;AAClF,SAGEC,uBAAuB,QAClB,sCAAsC;AAC7C,SACEC,+BAA+B,EAC/BC,mCAAmC,QAC9B,uBAAuB;AAC9B,SAEEC,sBAAsB,EAGtBC,2BAA2B,EAC3BC,+BAA+B,QAC1B,6BAA6B;AACpC,SACEC,4BAA4B,EAC5BC,gCAAgC,QAC3B,uBAAuB;AAC9B,SAAQC,sBAAsB,QAAO,0CAA0C;AAC/E,SAAQC,+BAA+B,QAAO,oDAAoD;AAClG,SAAQC,qBAAqB,QAAO,wCAAwC;AAM5E,SAEEC,iBAAiB,EACjBC,0BAA0B,EAE1BC,8BAA8B,EAC9BC,4BAA4B,EAC5BC,sBAAsB,EACtBC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gCAAgC,EAChCC,0CAA0C,EAC1CC,0CAA0C,EAI1CC,8BAA8B,EAC9BC,sBAAsB,EACtBC,gBAAgB,EAChBC,gBAAgB,EAEhBC,kBAAkB,EAgBlBC,oCAAoC,EACpCC,0BAA0B,EAC1BC,oBAAoB,EACpBC,oBAAoB,EACpBC,4BAA4B,EAC5BC,qCAAqC,EACrCC,4BAA4B,EAC5BC,yBAAyB,EACzBC,4BAA4B,EAC5BC,wCAAwC,EACxCC,qCAAqC,EACrCC,0CAA0C,EAC1CC,kCAAkC,EAClCC,2BAA2B,EAC3BC,mCAAmC,EACnCC,uBAAuB,QAClB,yCAAyC"}
@@ -8,14 +8,14 @@ export interface WorkflowTemplateDiagnostic {
8
8
  readonly expression: string;
9
9
  readonly contextRoots: readonly string[];
10
10
  }
11
- export interface FrozenResolvedField {
12
- readonly value: string;
11
+ export interface FrozenResolvedField<Value = string> {
12
+ readonly value: Value;
13
13
  readonly diagnostics: readonly WorkflowTemplateDiagnostic[];
14
14
  readonly trace: readonly EvaluationTraceEntry[];
15
15
  }
16
- export type SiteResolvedField = {
16
+ export type SiteResolvedField<Value = string> = {
17
17
  readonly kind: 'frozen';
18
- readonly value: string;
18
+ readonly value: Value;
19
19
  readonly diagnostics: readonly WorkflowTemplateDiagnostic[];
20
20
  readonly trace: readonly EvaluationTraceEntry[];
21
21
  } | {
@@ -24,6 +24,14 @@ export type SiteResolvedField = {
24
24
  readonly diagnostics: readonly WorkflowTemplateDiagnostic[];
25
25
  readonly trace: readonly EvaluationTraceEntry[];
26
26
  };
27
+ interface ResolveFieldAtSiteParams {
28
+ readonly field: ResolvedField;
29
+ readonly failurePolicy: WorkflowInterpolationFailurePolicy;
30
+ readonly site: AvailabilitySite;
31
+ readonly context: WorkflowExpressionEvaluationContext;
32
+ /** Preserve the value of an exact single expression instead of stringifying it. */
33
+ readonly preserveSingleExpressionType?: boolean;
34
+ }
27
35
  /**
28
36
  * Segment lifecycle:
29
37
  *
@@ -33,16 +41,19 @@ export type SiteResolvedField = {
33
41
  * Value fields follow their declared policy at their fill target. Predicates use
34
42
  * the planned predicate entry point and fail closed when evaluation is deferred.
35
43
  */
36
- export declare function freezeResolvedFieldAtSite(params: {
37
- readonly field: ResolvedField;
38
- readonly failurePolicy: WorkflowInterpolationFailurePolicy;
39
- readonly site: AvailabilitySite;
40
- readonly context: WorkflowExpressionEvaluationContext;
44
+ export declare function freezeResolvedFieldAtSite(params: ResolveFieldAtSiteParams & {
45
+ readonly preserveSingleExpressionType: true;
46
+ }): FrozenResolvedField<unknown>;
47
+ export declare function freezeResolvedFieldAtSite(params: ResolveFieldAtSiteParams & {
48
+ readonly preserveSingleExpressionType?: false;
41
49
  }): FrozenResolvedField;
42
- export declare function resolveFieldAtSite(params: {
43
- readonly field: ResolvedField;
44
- readonly failurePolicy: WorkflowInterpolationFailurePolicy;
45
- readonly site: AvailabilitySite;
46
- readonly context: WorkflowExpressionEvaluationContext;
50
+ export declare function freezeResolvedFieldAtSite(params: ResolveFieldAtSiteParams): FrozenResolvedField<unknown>;
51
+ export declare function resolveFieldAtSite(params: ResolveFieldAtSiteParams & {
52
+ readonly preserveSingleExpressionType: true;
53
+ }): SiteResolvedField<unknown>;
54
+ export declare function resolveFieldAtSite(params: ResolveFieldAtSiteParams & {
55
+ readonly preserveSingleExpressionType?: false;
47
56
  }): SiteResolvedField;
57
+ export declare function resolveFieldAtSite(params: ResolveFieldAtSiteParams): SiteResolvedField<unknown>;
58
+ export {};
48
59
  //# sourceMappingURL=freeze.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"freeze.d.ts","sourceRoot":"","sources":["../../src/plan/freeze.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mCAAmC,EAEzC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,KAAK,gBAAgB,EAErB,KAAK,kCAAkC,EACxC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAC,KAAK,oBAAoB,EAAuB,MAAM,uBAAuB,CAAC;AAEtF,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,6BAA6B,GAAG,kCAAkC,CAAC;AAE/E,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,SAAS,0BAA0B,EAAE,CAAC;IAC5D,QAAQ,CAAC,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACjD;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,SAAS,0BAA0B,EAAE,CAAC;IAC5D,QAAQ,CAAC,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACjD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,K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C,EAAE,KAAK,CAAA;CAAC,GACjF,mBAAmB,CAAC;AACvB,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,wBAAwB,GAC/B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AA+ChC,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,wBAAwB,GAAG;IAAC,QAAQ,CAAC,4BAA4B,EAAE,IAAI,CAAA;CAAC,GAC/E,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC9B,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,wBAAwB,GAAG;IAAC,QAAQ,CAAC,4BAA4B,CAAC,EAAE,KAAK,CAAA;CAAC,GACjF,iBAAiB,CAAC;AACrB,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC"}
@@ -4,61 +4,53 @@ import { WorkflowTemplateResolutionError } from '../resolver/errors.js';
4
4
  import { resolveContextRootAvailability } from '../workflow-context/workflow-context.js';
5
5
  import { evaluationTraceEntry } from './evaluation-trace.js';
6
6
  import { shouldFillAtSite } from './fill.js';
7
- /**
8
- * Segment lifecycle:
9
- *
10
- * `{expr}` -> plan -> `{deferred, fillTarget}` -> freeze at a site at or after
11
- * `fillTarget` -> `{literal}`. Runner-fill segments are never filled server-side.
12
- *
13
- * Value fields follow their declared policy at their fill target. Predicates use
14
- * the planned predicate entry point and fail closed when evaluation is deferred.
15
- */ export function freezeResolvedFieldAtSite(params) {
7
+ export function freezeResolvedFieldAtSite(params) {
16
8
  let value = '';
9
+ let typedValue;
10
+ let hasTypedValue = false;
17
11
  const diagnostics = [];
18
12
  const trace = [];
13
+ const preserveSingleExpressionType = isExactSingleExpressionField(params);
19
14
  for (const segment of params.field.segments){
20
15
  if (segment.kind === 'literal') {
21
16
  value += segment.value;
22
17
  continue;
23
18
  }
24
19
  if (!shouldFillAtSite(segment.fillTarget, params.site)) {
20
+ if (exactTypedFieldRequiresFailure(params, segment)) {
21
+ throw typedFieldNotFillableAtSite(segment);
22
+ }
25
23
  diagnostics.push(missingPathDiagnostic(segment));
26
24
  continue;
27
25
  }
28
- try {
29
- const literal = coerceWorkflowValueToString(evaluateWorkflowExpression(segment.expression, params.context));
30
- value += literal;
31
- trace.push(fillTraceEntry(segment, params.site, literal));
32
- } catch (error) {
33
- if (error instanceof WorkflowExpressionEvaluationError && error.reason === 'missing-path') {
34
- if (missingPathRequiresFailure(segment, params.failurePolicy, params.site)) {
35
- throw new WorkflowTemplateResolutionError({
36
- source: segment.expression.source,
37
- cause: error
38
- });
39
- }
40
- diagnostics.push(missingPathDiagnostic(segment));
41
- trace.push(fillTraceEntry(segment, params.site, '', true));
42
- continue;
43
- }
44
- throw new WorkflowTemplateResolutionError({
45
- source: segment.expression.source,
46
- cause: error
47
- });
26
+ const evaluated = evaluateFillableSegment(params, segment);
27
+ trace.push(evaluated.trace);
28
+ if (evaluated.kind === 'degraded') {
29
+ diagnostics.push(evaluated.diagnostic);
30
+ continue;
31
+ }
32
+ if (preserveSingleExpressionType) {
33
+ typedValue = evaluated.value;
34
+ hasTypedValue = true;
35
+ } else {
36
+ value += evaluated.literal;
48
37
  }
49
38
  }
50
39
  return {
51
- value,
40
+ value: preserveSingleExpressionType && hasTypedValue ? typedValue : value,
52
41
  diagnostics,
53
42
  trace
54
43
  };
55
44
  }
56
45
  export function resolveFieldAtSite(params) {
57
46
  let value = '';
47
+ let typedValue;
48
+ let hasTypedValue = false;
58
49
  const diagnostics = [];
59
50
  const trace = [];
60
51
  const segments = [];
61
52
  let hasResidual = false;
53
+ const preserveSingleExpressionType = isExactSingleExpressionField(params);
62
54
  for (const segment of params.field.segments){
63
55
  if (segment.kind === 'literal') {
64
56
  value += segment.value;
@@ -70,35 +62,26 @@ export function resolveFieldAtSite(params) {
70
62
  segments.push(segment);
71
63
  continue;
72
64
  }
73
- try {
74
- const literal = coerceWorkflowValueToString(evaluateWorkflowExpression(segment.expression, params.context));
75
- value += literal;
65
+ const evaluated = evaluateFillableSegment(params, segment);
66
+ trace.push(evaluated.trace);
67
+ if (evaluated.kind === 'degraded') {
68
+ diagnostics.push(evaluated.diagnostic);
76
69
  segments.push({
77
70
  kind: 'literal',
78
- value: literal
79
- });
80
- trace.push(fillTraceEntry(segment, params.site, literal));
81
- } catch (error) {
82
- if (error instanceof WorkflowExpressionEvaluationError && error.reason === 'missing-path') {
83
- if (missingPathRequiresFailure(segment, params.failurePolicy, params.site)) {
84
- throw new WorkflowTemplateResolutionError({
85
- source: segment.expression.source,
86
- cause: error
87
- });
88
- }
89
- diagnostics.push(missingPathDiagnostic(segment));
90
- segments.push({
91
- kind: 'literal',
92
- value: ''
93
- });
94
- trace.push(fillTraceEntry(segment, params.site, '', true));
95
- continue;
96
- }
97
- throw new WorkflowTemplateResolutionError({
98
- source: segment.expression.source,
99
- cause: error
71
+ value: ''
100
72
  });
73
+ continue;
74
+ }
75
+ if (preserveSingleExpressionType) {
76
+ typedValue = evaluated.value;
77
+ hasTypedValue = true;
78
+ } else {
79
+ value += evaluated.literal;
101
80
  }
81
+ segments.push({
82
+ kind: 'literal',
83
+ value: evaluated.literal
84
+ });
102
85
  }
103
86
  if (hasResidual) return {
104
87
  kind: 'residual',
@@ -110,11 +93,44 @@ export function resolveFieldAtSite(params) {
110
93
  };
111
94
  return {
112
95
  kind: 'frozen',
113
- value,
96
+ value: preserveSingleExpressionType && hasTypedValue ? typedValue : value,
114
97
  diagnostics,
115
98
  trace
116
99
  };
117
100
  }
101
+ function isExactSingleExpressionField(params) {
102
+ return params.preserveSingleExpressionType === true && params.field.segments.length === 1 && params.field.segments[0]?.kind === 'deferred';
103
+ }
104
+ function evaluateFillableSegment(params, segment) {
105
+ try {
106
+ const value = evaluateWorkflowExpression(segment.expression, params.context);
107
+ const literal = coerceWorkflowValueToString(value);
108
+ return {
109
+ kind: 'evaluated',
110
+ value,
111
+ literal,
112
+ trace: fillTraceEntry(segment, params.site, literal)
113
+ };
114
+ } catch (error) {
115
+ if (error instanceof WorkflowExpressionEvaluationError && error.reason === 'missing-path') {
116
+ if (fieldMissingPathRequiresFailure(params, segment)) {
117
+ throw new WorkflowTemplateResolutionError({
118
+ source: segment.expression.source,
119
+ cause: error
120
+ });
121
+ }
122
+ return {
123
+ kind: 'degraded',
124
+ diagnostic: missingPathDiagnostic(segment),
125
+ trace: fillTraceEntry(segment, params.site, '', true)
126
+ };
127
+ }
128
+ throw new WorkflowTemplateResolutionError({
129
+ source: segment.expression.source,
130
+ cause: error
131
+ });
132
+ }
133
+ }
118
134
  function fillTraceEntry(segment, site, value, degraded = false) {
119
135
  return evaluationTraceEntry({
120
136
  expression: segment.expression.source,
@@ -127,6 +143,18 @@ function fillTraceEntry(segment, site, value, degraded = false) {
127
143
  } : {}
128
144
  });
129
145
  }
146
+ function fieldMissingPathRequiresFailure(params, segment) {
147
+ return isExactSingleExpressionField(params) && params.failurePolicy === 'fail' || missingPathRequiresFailure(segment, params.failurePolicy, params.site);
148
+ }
149
+ function exactTypedFieldRequiresFailure(params, segment) {
150
+ return isExactSingleExpressionField(params) && params.failurePolicy === 'fail' && segment.fillTarget !== 'runner-fill';
151
+ }
152
+ function typedFieldNotFillableAtSite(segment) {
153
+ return new WorkflowTemplateResolutionError({
154
+ source: segment.expression.source,
155
+ cause: new Error('Typed field is not fillable at this site.')
156
+ });
157
+ }
130
158
  function missingPathDiagnostic(segment) {
131
159
  return {
132
160
  reason: 'missing-path',