@usine/expression 0.0.1 → 0.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
@@ -1,5 +1,17 @@
1
1
  # @usine/expression
2
2
 
3
- CEL expression seam for usine: check and evaluate the selection expressions loop files use.
3
+ Typed CEL checking and evaluation for [usine](https://github.com/basaltbytes/usine). Callers describe object types and root variables with `Environment`, then use `ExpressionEngine` to check boolean trigger expressions, check scalar prompt expressions, or evaluate either form over plain JSON.
4
4
 
5
- Part of [usine](https://github.com/basaltbytes/usine), an agent-agnostic software factory. This block is not implemented yet — its 0.0.x releases reserve the seam while the engine grows. Everything here is 0.x: APIs change without notice.
5
+ Unknown variables and object paths fail during checking, including paths inside CEL macros such as `exists`. Failures are typed values: `ExpressionCheckError` from parsing, type checking, or result-type checking, `ExpressionEvaluationError` from evaluation, and the `ExpressionError` union covering both. JSON integers declared as CEL `int` or `uint` are converted to `bigint` before evaluation so GraphQL payloads keep CEL integer semantics.
6
+
7
+ `relatedStringLiterals(source, memberPath)` reports string literals from the smallest expression subtrees that use a member path. Config validation uses it to diagnose undeclared GitHub labels without coupling `@usine/config` to the CEL adapter's AST.
8
+
9
+ `MarcbachmannCelLayer` uses `@marcbachmann/cel-js@8.0.0`. The exported `ExpressionEngine` contract contains CEL type names and usine-owned descriptors rather than library objects; an `@bufbuild/cel` adapter can provide the same service tag without changing callers.
10
+
11
+ All APIs remain 0.x and can change between minor releases.
12
+
13
+ Import `ExpressionEngine`, `Source`, `Environment`, the environment descriptors,
14
+ `Scalar`, and the typed expression errors from `@usine/expression/expression-engine`.
15
+ This entry point replaces `@usine/expression/model`; existing imports from that
16
+ subpath must use `/expression-engine`. Import the CEL adapter layer separately
17
+ from `@usine/expression/marcbachmann-cel`.
@@ -0,0 +1,34 @@
1
+ import { Schema } from "effect";
2
+ /** A type name in CEL syntax such as `string`, `Issue`, or `list<Label>`. */
3
+ export declare const TypeReference: Schema.brand<Schema.String, "CelTypeReference">;
4
+ export type TypeReference = typeof TypeReference.Type;
5
+ declare const ObjectField_base: Schema.Class<ObjectField, Schema.Struct<{
6
+ readonly name: Schema.String;
7
+ readonly type: Schema.brand<Schema.String, "CelTypeReference">;
8
+ }>, {}>;
9
+ /** One named field and its CEL type within an object descriptor. */
10
+ export declare class ObjectField extends ObjectField_base {
11
+ }
12
+ declare const ObjectType_base: Schema.Class<ObjectType, Schema.Struct<{
13
+ readonly name: Schema.String;
14
+ readonly fields: Schema.$Array<typeof ObjectField>;
15
+ }>, {}>;
16
+ /** A CEL object type. Declare a type before the types that reference it. */
17
+ export declare class ObjectType extends ObjectType_base {
18
+ }
19
+ declare const Variable_base: Schema.Class<Variable, Schema.Struct<{
20
+ readonly name: Schema.String;
21
+ readonly type: Schema.brand<Schema.String, "CelTypeReference">;
22
+ }>, {}>;
23
+ /** A root variable available to CEL expressions in an Environment. */
24
+ export declare class Variable extends Variable_base {
25
+ }
26
+ declare const Environment_base: Schema.Class<Environment, Schema.Struct<{
27
+ readonly types: Schema.$Array<typeof ObjectType>;
28
+ readonly variables: Schema.$Array<typeof Variable>;
29
+ }>, {}>;
30
+ /** The types and root variables an expression is checked and evaluated against. */
31
+ export declare class Environment extends Environment_base {
32
+ }
33
+ export {};
34
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,6EAA6E;AAC7E,eAAO,MAAM,aAAa,iDAKc,CAAC;AACzC,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;;;;;AAkBtD,oEAAoE;AACpE,qBAAa,WAAY,SAAQ,gBAG/B;CAAG;;;;;AAEL,4EAA4E;AAC5E,qBAAa,UAAW,SAAQ,eAG9B;CAAG;;;;;AAEL,sEAAsE;AACtE,qBAAa,QAAS,SAAQ,aAG5B;CAAG;;;;;AAEL,mFAAmF;AACnF,qBAAa,WAAY,SAAQ,gBAG/B;CAAG"}
@@ -0,0 +1,33 @@
1
+ import { Schema } from "effect";
2
+ /** A type name in CEL syntax such as `string`, `Issue`, or `list<Label>`. */
3
+ export const TypeReference = Schema.String.check(Schema.isPattern(/^(?:[A-Za-z_][A-Za-z0-9_.]*|list<[A-Za-z_][A-Za-z0-9_.]*>|map<[A-Za-z_][A-Za-z0-9_.]*,[A-Za-z_][A-Za-z0-9_.]*>)$/u, { message: "Expected a CEL type reference" })).pipe(Schema.brand("CelTypeReference"));
4
+ const Identifier = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_]*$/u, { message: "Expected a CEL identifier" }));
5
+ const ObjectTypeName = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_.]*$/u, {
6
+ message: "Expected a CEL object-type name",
7
+ }));
8
+ const uniqueNames = (message) => Schema.makeFilter((values) => new Set(values.map(({ name }) => name)).size === values.length, { message });
9
+ /** One named field and its CEL type within an object descriptor. */
10
+ export class ObjectField extends Schema.Class("@usine/expression/ObjectField")({
11
+ name: Identifier,
12
+ type: TypeReference,
13
+ }) {
14
+ }
15
+ /** A CEL object type. Declare a type before the types that reference it. */
16
+ export class ObjectType extends Schema.Class("@usine/expression/ObjectType")({
17
+ name: ObjectTypeName,
18
+ fields: Schema.Array(ObjectField).check(uniqueNames("Expected unique CEL object-field names")),
19
+ }) {
20
+ }
21
+ /** A root variable available to CEL expressions in an Environment. */
22
+ export class Variable extends Schema.Class("@usine/expression/Variable")({
23
+ name: Identifier,
24
+ type: TypeReference,
25
+ }) {
26
+ }
27
+ /** The types and root variables an expression is checked and evaluated against. */
28
+ export class Environment extends Schema.Class("@usine/expression/Environment")({
29
+ types: Schema.Array(ObjectType).check(uniqueNames("Expected unique CEL object-type names")),
30
+ variables: Schema.Array(Variable).check(uniqueNames("Expected unique CEL variable names")),
31
+ }) {
32
+ }
33
+ //# sourceM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AAE,cAAc;IACpB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,wCAAwC,CAAC,CAAC;CAC/F,CAAC;CAAG;AAEL,sEAAsE;AACtE,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,KAAK,CAAW,4BAA4B,CAAC,CAAC;IACjF,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,aAAa;CACpB,CAAC;CAAG;AAEL,mFAAmF;AACnF,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,KAAK,CAAc,+BAA+B,CAAC,CAAC;IAC1F,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAC3F,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,oCAAoC,CAAC,CAAC;CAC3F,CAAC;CAAG"}
@@ -0,0 +1,53 @@
1
+ import { Context, type Effect, Schema } from "effect";
2
+ import type { Environment } from "./environment.ts";
3
+ /** Non-blank CEL source text. */
4
+ export declare const Source: Schema.brand<Schema.String, "ExpressionSource">;
5
+ export type Source = typeof Source.Type;
6
+ /** Whether checking failed during parsing, type resolution, or result-type validation. */
7
+ export declare const CheckErrorCode: Schema.Literals<readonly ["check_failed", "parse_error", "type_error", "unexpected_result_type"]>;
8
+ export type CheckErrorCode = typeof CheckErrorCode.Type;
9
+ declare const ExpressionCheckError_base: Schema.Class<ExpressionCheckError, Schema.TaggedStruct<"ExpressionCheckError", {
10
+ readonly source: Schema.brand<Schema.String, "ExpressionSource">;
11
+ readonly code: Schema.Literals<readonly ["check_failed", "parse_error", "type_error", "unexpected_result_type"]>;
12
+ readonly message: Schema.NonEmptyString;
13
+ readonly position: Schema.Option<Schema.Int>;
14
+ }>, import("effect/Cause").YieldableError>;
15
+ /** The expression failed to parse, to type-check, or to produce the expected result type. */
16
+ export declare class ExpressionCheckError extends ExpressionCheckError_base {
17
+ }
18
+ declare const ExpressionEvaluationError_base: Schema.Class<ExpressionEvaluationError, Schema.TaggedStruct<"ExpressionEvaluationError", {
19
+ readonly source: Schema.brand<Schema.String, "ExpressionSource">;
20
+ readonly message: Schema.NonEmptyString;
21
+ }>, import("effect/Cause").YieldableError>;
22
+ /** Evaluation failed on an expression that had already checked. */
23
+ export declare class ExpressionEvaluationError extends ExpressionEvaluationError_base {
24
+ }
25
+ /** The failures callers can receive when checking or evaluating a CEL expression. */
26
+ export declare const ExpressionError: Schema.Union<readonly [typeof ExpressionCheckError, typeof ExpressionEvaluationError]>;
27
+ export type ExpressionError = typeof ExpressionError.Type;
28
+ /** Values prompt interpolation can render. CEL ints stay bigint. */
29
+ export declare const Scalar: Schema.Union<readonly [Schema.String, Schema.Number, Schema.BigInt, Schema.Boolean, Schema.Null]>;
30
+ export type Scalar = typeof Scalar.Type;
31
+ /** Checks and evaluates the expressions used to select Items and fill Loop task templates. */
32
+ export interface ExpressionEngineService {
33
+ /**
34
+ * The string literals the expression compares against the `name` field of
35
+ * values reached from `memberPath`, following macro bindings and collection
36
+ * transformations. Config validation uses it to spot undeclared labels.
37
+ */
38
+ readonly relatedStringLiterals: (source: Source, memberPath: ReadonlyArray<string>) => Effect.Effect<ReadonlyArray<string>, ExpressionCheckError>;
39
+ /** Checks whether the expression can select Items, without evaluating a payload. */
40
+ readonly checkBoolean: (source: Source, environment: Environment) => Effect.Effect<void, ExpressionCheckError>;
41
+ /** Checks whether the expression can produce one value for prompt interpolation. */
42
+ readonly checkScalar: (source: Source, environment: Environment) => Effect.Effect<void, ExpressionCheckError>;
43
+ /** Checks and evaluates a selection condition; `context` supplies values for the environment's root variables. */
44
+ readonly evaluateBoolean: (source: Source, environment: Environment, context: Schema.JsonObject) => Effect.Effect<boolean, ExpressionError>;
45
+ /** Checks and evaluates a prompt interpolation; `context` supplies values for the environment's root variables. */
46
+ readonly evaluateScalar: (source: Source, environment: Environment, context: Schema.JsonObject) => Effect.Effect<Scalar, ExpressionError>;
47
+ }
48
+ declare const ExpressionEngine_base: Context.ServiceClass<ExpressionEngine, "@usine/expression/ExpressionEngine", ExpressionEngineService>;
49
+ /** Evaluates Loop conditions and prompt expressions against their declared payload context. */
50
+ export declare class ExpressionEngine extends ExpressionEngine_base {
51
+ }
52
+ export { TypeReference, ObjectField, ObjectType, Variable, Environment } from "./environment.ts";
53
+ //# sourceMappingURL=expression-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expression-engine.d.ts","sourceRoot":"","sources":["../src/expression-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,iCAAiC;AACjC,eAAO,MAAM,MAAM,iDAEqB,CAAC;AACzC,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;AAIxC,0FAA0F;AAC1F,eAAO,MAAM,cAAc,mGAKzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;;;;;;;AAExD,6FAA6F;AAC7F,qBAAa,oBAAqB,SAAQ,yBAOxC;CAAG;;;;;AAEL,mEAAmE;AACnE,qBAAa,yBAA0B,SAAQ,8BAK7C;CAAG;AAEL,qFAAqF;AACrF,eAAO,MAAM,eAAe,wFAAkE,CAAC;AAC/F,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAE1D,oEAAoE;AACpE,eAAO,MAAM,MAAM,mGAMjB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;AAExC,8FAA8F;AAC9F,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,EAAE,CAC9B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,KAC9B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAChE,oFAAoF;IACpF,QAAQ,CAAC,YAAY,EAAE,CACrB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IAC/C,oFAAoF;IACpF,QAAQ,CAAC,WAAW,EAAE,CACpB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IAC/C,kHAAkH;IAClH,QAAQ,CAAC,eAAe,EAAE,CACxB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,MAAM,CAAC,UAAU,KACvB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC7C,mHAAmH;IACnH,QAAQ,CAAC,cAAc,EAAE,CACvB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,MAAM,CAAC,UAAU,KACvB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC7C;;AAED,+FAA+F;AAC/F,qBAAa,gBAAiB,SAAQ,qBAErC;CAAG;AAEJ,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Context, Schema } from "effect";
2
+ /** Non-blank CEL source text. */
3
+ export const Source = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank CEL expression" })).pipe(Schema.brand("ExpressionSource"));
4
+ const Position = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
5
+ /** Whether checking failed during parsing, type resolution, or result-type validation. */
6
+ export const CheckErrorCode = Schema.Literals([
7
+ "check_failed",
8
+ "parse_error",
9
+ "type_error",
10
+ "unexpected_result_type",
11
+ ]);
12
+ /** The expression failed to parse, to type-check, or to produce the expected result type. */
13
+ export class ExpressionCheckError extends Schema.TaggedError("@usine/expression/ExpressionCheckError")("ExpressionCheckError", {
14
+ source: Source,
15
+ code: CheckErrorCode,
16
+ message: Schema.NonEmptyString,
17
+ position: Schema.Option(Position),
18
+ }) {
19
+ }
20
+ /** Evaluation failed on an expression that had already checked. */
21
+ export class ExpressionEvaluationError extends Schema.TaggedError("@usine/expression/ExpressionEvaluationError")("ExpressionEvaluationError", {
22
+ source: Source,
23
+ message: Schema.NonEmptyString,
24
+ }) {
25
+ }
26
+ /** The failures callers can receive when checking or evaluating a CEL expression. */
27
+ export const ExpressionError = Schema.Union([ExpressionCheckError, ExpressionEvaluationError]);
28
+ /** Values prompt interpolation can render. CEL ints stay bigint. */
29
+ export const Scalar = Schema.Union([
30
+ Schema.String,
31
+ Schema.Number,
32
+ Schema.BigInt,
33
+ Schema.Boolean,
34
+ Schema.Null,
35
+ ]);
36
+ /** Evaluates Loop conditions and prompt expressions against their declared payload context. */
37
+ export class ExpressionEngine extends Context.Service()("@usine/expression/ExpressionEngine") {
38
+ }
39
+ export { TypeReference, ObjectField, ObjectType, Variable, Environment } from "./environment.js";
40
+ //# sourceMappingURL=expression-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expression-engine.js","sourceRoot":"","sources":["../src/expression-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGtD,iCAAiC;AACjC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACvC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,qCAAqC,EAAE,CAAC,CAC5E,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;A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M,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Layer } from "effect";
2
+ import { ExpressionEngine } from "./expression-engine.ts";
3
+ /** The ExpressionEngine implementation on @marcbachmann/cel-js. */
4
+ export declare const MarcbachmannCelLayer: Layer.Layer<ExpressionEngine, never, never>;
5
+ //# sourceMappingURL=marcbachmann-cel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marcbachmann-cel.d.ts","sourceRoot":"","sources":["../src/marcbachmann-cel.ts"],"names":[],"mappings":"AAOA,OAAO,EAAU,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAEvD,OAAO,EACL,gBAAgB,EAKjB,MAAM,wBAAwB,CAAC;AA6XhC,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,6CAM/B,CAAC"}
@@ -0,0 +1,279 @@
1
+ import { Environment as CelEnvironment, ParseError as CelParseError, TypeError as CelTypeError, parse, } from "@marcbachmann/cel-js";
2
+ import { Effect, Layer, Option, Schema } from "effect";
3
+ import { TypeReference } from "./environment.js";
4
+ import { ExpressionEngine, ExpressionCheckError, ExpressionEvaluationError, Scalar, } from "./expression-engine.js";
5
+ const decodeTypeReference = Schema.decodeUnknownSync(TypeReference);
6
+ const acceptedScalarTypes = new Set([
7
+ "bool",
8
+ "double",
9
+ "int",
10
+ "null_type",
11
+ "string",
12
+ "uint",
13
+ ]);
14
+ const messageFromCause = (cause, fallback) => Option.match(Schema.decodeUnknownOption(Schema.Struct({ message: Schema.NonEmptyString }))(cause), {
15
+ onNone: () => fallback,
16
+ onSome: ({ message }) => message,
17
+ });
18
+ const checkFailure = (source, error) => error === undefined
19
+ ? new ExpressionCheckError({
20
+ source,
21
+ code: "check_failed",
22
+ message: "CEL check failed without an error detail",
23
+ position: Option.none(),
24
+ })
25
+ : new ExpressionCheckError({
26
+ source,
27
+ code: error instanceof CelParseError ? "parse_error" : "type_error",
28
+ message: error.message,
29
+ position: Option.fromNullishOr(error.range?.start),
30
+ });
31
+ const childNodes = (node) => {
32
+ switch (node.op) {
33
+ case "value":
34
+ case "id":
35
+ return [];
36
+ case ".":
37
+ case ".?":
38
+ return [node.args[0]];
39
+ case "!_":
40
+ case "-_":
41
+ return [node.args];
42
+ case "call":
43
+ return node.args[1];
44
+ case "rcall":
45
+ return [node.args[1], ...node.args[2]];
46
+ case "list":
47
+ return node.args;
48
+ case "map":
49
+ return node.args.flatMap(([key, value]) => [key, value]);
50
+ default:
51
+ return node.args;
52
+ }
53
+ };
54
+ const pathOf = (node) => {
55
+ if (node.op === "id")
56
+ return [node.args];
57
+ if (node.op !== "." && node.op !== ".?")
58
+ return undefined;
59
+ const parent = pathOf(node.args[0]);
60
+ return parent === undefined ? undefined : [...parent, node.args[1]];
61
+ };
62
+ const decodeStringLiteral = Schema.decodeUnknownOption(Schema.String);
63
+ const MACROS_WITH_BINDINGS = new Set([
64
+ "all",
65
+ "exists",
66
+ "exists_one",
67
+ "filter",
68
+ "map",
69
+ ]);
70
+ /** The member path a node reads from, followed back through macro bindings and collection transformations. */
71
+ const lineagePathOf = (node, bindings) => {
72
+ const path = pathOf(node);
73
+ if (path !== undefined) {
74
+ const boundPath = bindings.get(path[0]);
75
+ return boundPath === undefined ? path : [...boundPath, ...path.slice(1)];
76
+ }
77
+ if (node.op !== "rcall")
78
+ return undefined;
79
+ const [macro, receiver, args] = node.args;
80
+ const receiverPath = lineagePathOf(receiver, bindings);
81
+ if (receiverPath === undefined)
82
+ return undefined;
83
+ if (macro === "filter")
84
+ return receiverPath;
85
+ if (macro !== "map")
86
+ return undefined;
87
+ const [binding, ...body] = args;
88
+ const projection = body[body.length - 1];
89
+ if (binding?.op !== "id" || projection === undefined)
90
+ return undefined;
91
+ return lineagePathOf(projection, new Map(bindings).set(binding.args, receiverPath));
92
+ };
93
+ const startsWithPath = (path, prefix) => prefix.every((part, index) => path[index] === part);
94
+ /**
95
+ * The string literals an operand can evaluate to. Only result positions count:
96
+ * a conditional contributes its branches and not its test, a list its
97
+ * elements. `item.state == "OPEN" ? "ready" : "review"` yields the two labels
98
+ * and not the state.
99
+ */
100
+ const resultStringLiterals = (node) => {
101
+ switch (node.op) {
102
+ case "value":
103
+ return Option.match(decodeStringLiteral(node.args), {
104
+ onNone: () => [],
105
+ onSome: (literal) => [literal],
106
+ });
107
+ case "?:": {
108
+ const [, whenTrue, whenFalse] = node.args;
109
+ return [...resultStringLiterals(whenTrue), ...resultStringLiterals(whenFalse)];
110
+ }
111
+ case "list":
112
+ return node.args.flatMap(resultStringLiterals);
113
+ default:
114
+ return [];
115
+ }
116
+ };
117
+ const isRelatedName = (node, memberPath, bindings) => {
118
+ const path = lineagePathOf(node, bindings);
119
+ return path !== undefined && startsWithPath(path, memberPath) && path[path.length - 1] === "name";
120
+ };
121
+ const comparisonLiterals = (node, memberPath, bindings) => {
122
+ switch (node.op) {
123
+ case "!=":
124
+ case "==":
125
+ case "in": {
126
+ const [left, right] = node.args;
127
+ return [
128
+ ...(isRelatedName(left, memberPath, bindings) ? resultStringLiterals(right) : []),
129
+ ...(isRelatedName(right, memberPath, bindings) ? resultStringLiterals(left) : []),
130
+ ];
131
+ }
132
+ default:
133
+ return [];
134
+ }
135
+ };
136
+ /** Collects the literals compared against `name` on members bound by macros over the watched collection. */
137
+ const scanRelatedLiterals = (node, memberPath, bindings) => {
138
+ const related = comparisonLiterals(node, memberPath, bindings);
139
+ if (node.op !== "rcall" || !MACROS_WITH_BINDINGS.has(node.args[0])) {
140
+ return [
141
+ ...related,
142
+ ...childNodes(node).flatMap((child) => scanRelatedLiterals(child, memberPath, bindings)),
143
+ ];
144
+ }
145
+ const [, receiver, args] = node.args;
146
+ const [binding, ...body] = args;
147
+ const receiverPath = lineagePathOf(receiver, bindings);
148
+ if (binding?.op !== "id" || receiverPath === undefined) {
149
+ return [
150
+ ...related,
151
+ ...childNodes(node).flatMap((child) => scanRelatedLiterals(child, memberPath, bindings)),
152
+ ];
153
+ }
154
+ const bodyBindings = new Map(bindings).set(binding.args, receiverPath);
155
+ return [
156
+ ...related,
157
+ ...scanRelatedLiterals(receiver, memberPath, bindings),
158
+ ...body.flatMap((child) => scanRelatedLiterals(child, memberPath, bodyBindings)),
159
+ ];
160
+ };
161
+ const relatedStringLiterals = Effect.fn("ExpressionEngine.relatedStringLiterals")(function* (source, memberPath) {
162
+ if (memberPath.length === 0)
163
+ return [];
164
+ const ast = yield* Effect.try({
165
+ try: () => parse(source).ast,
166
+ catch: (cause) => cause instanceof CelParseError
167
+ ? checkFailure(source, cause)
168
+ : new ExpressionCheckError({
169
+ source,
170
+ code: "check_failed",
171
+ message: messageFromCause(cause, "CEL analysis failed"),
172
+ position: Option.none(),
173
+ }),
174
+ });
175
+ return [...new Set(scanRelatedLiterals(ast, memberPath, new Map()))];
176
+ });
177
+ const makeEnvironment = (descriptor) => {
178
+ const environment = new CelEnvironment({ unlistedVariablesAreDyn: false });
179
+ for (const objectType of descriptor.types) {
180
+ environment.registerType(objectType.name, {
181
+ fields: Object.fromEntries(objectType.fields.map((field) => [field.name, field.type])),
182
+ });
183
+ }
184
+ for (const variable of descriptor.variables) {
185
+ environment.registerVariable(variable.name, variable.type);
186
+ }
187
+ return environment;
188
+ };
189
+ const normalizeValue = (value, type, objectTypes) => {
190
+ if ((type === "int" || type === "uint") &&
191
+ Schema.is(Schema.Number)(value) &&
192
+ Number.isInteger(value)) {
193
+ return BigInt(value);
194
+ }
195
+ if (type.startsWith("list<") && type.endsWith(">") && Array.isArray(value)) {
196
+ const itemType = decodeTypeReference(type.slice(5, -1));
197
+ return value.map((item) => normalizeValue(item, itemType, objectTypes));
198
+ }
199
+ const objectType = objectTypes.get(type);
200
+ if (objectType !== undefined && Schema.is(Schema.JsonObject)(value)) {
201
+ return Object.fromEntries(Object.entries(value).map(([key, fieldValue]) => {
202
+ const field = objectType.fields.find(({ name }) => name === key);
203
+ return [
204
+ key,
205
+ field === undefined ? fieldValue : normalizeValue(fieldValue, field.type, objectTypes),
206
+ ];
207
+ }));
208
+ }
209
+ return value;
210
+ };
211
+ const normalizeContext = (context, descriptor) => {
212
+ const objectTypes = new Map(descriptor.types.map((type) => [type.name, type]));
213
+ return Object.fromEntries(Object.entries(context).map(([key, value]) => {
214
+ const variable = descriptor.variables.find(({ name }) => name === key);
215
+ return [
216
+ key,
217
+ variable === undefined ? value : normalizeValue(value, variable.type, objectTypes),
218
+ ];
219
+ }));
220
+ };
221
+ const checkExpected = (source, environment, accepts, expected) => Effect.gen(function* () {
222
+ const result = yield* Effect.try({
223
+ try: () => makeEnvironment(environment).check(source),
224
+ catch: (cause) => new ExpressionCheckError({
225
+ source,
226
+ code: "check_failed",
227
+ message: messageFromCause(cause, "CEL check failed"),
228
+ position: Option.none(),
229
+ }),
230
+ });
231
+ if (!result.valid)
232
+ return yield* checkFailure(source, result.error);
233
+ const resultType = result.type;
234
+ if (resultType === undefined || !accepts(resultType)) {
235
+ return yield* new ExpressionCheckError({
236
+ source,
237
+ code: "unexpected_result_type",
238
+ message: `Expected ${expected}, got ${resultType ?? "an unknown type"}`,
239
+ position: Option.none(),
240
+ });
241
+ }
242
+ });
243
+ const evaluateRaw = (source, environment, context) => Effect.try({
244
+ try: () =>
245
+ // SAFETY: CEL evaluates to the same value vocabulary the context is built
246
+ // from, and every caller decodes the expected result type before use.
247
+ makeEnvironment(environment).evaluate(source, normalizeContext(context, environment)),
248
+ catch: (cause) => new ExpressionEvaluationError({
249
+ source,
250
+ message: messageFromCause(cause, "CEL evaluation failed"),
251
+ }),
252
+ });
253
+ const unexpectedResult = (source, expected) => () => new ExpressionEvaluationError({
254
+ source,
255
+ message: `CEL evaluation returned a value that is not ${expected}`,
256
+ });
257
+ const checkBoolean = Effect.fn("ExpressionEngine.checkBoolean")((source, environment) => checkExpected(source, environment, (resultType) => resultType === "bool", "bool"));
258
+ const checkScalar = Effect.fn("ExpressionEngine.checkScalar")((source, environment) => checkExpected(source, environment, (resultType) => acceptedScalarTypes.has(resultType), "a scalar value"));
259
+ const decodeBoolean = Schema.decodeUnknownEffect(Schema.Boolean);
260
+ const decodeScalar = Schema.decodeUnknownEffect(Scalar);
261
+ const evaluateBoolean = Effect.fn("ExpressionEngine.evaluateBoolean")(function* (source, environment, context) {
262
+ yield* checkBoolean(source, environment);
263
+ const value = yield* evaluateRaw(source, environment, context);
264
+ return yield* decodeBoolean(value).pipe(Effect.mapError(unexpectedResult(source, "a boolean")));
265
+ });
266
+ const evaluateScalar = Effect.fn("ExpressionEngine.evaluateScalar")(function* (source, environment, context) {
267
+ yield* checkScalar(source, environment);
268
+ const value = yield* evaluateRaw(source, environment, context);
269
+ return yield* decodeScalar(value).pipe(Effect.mapError(unexpectedResult(source, "a scalar value")));
270
+ });
271
+ /** The ExpressionEngine implementation on @marcbachmann/cel-js. */
272
+ export const MarcbachmannCelLayer = Layer.succeed(ExpressionEngine, {
273
+ relatedStringLiterals,
274
+ checkBoolean,
275
+ checkScalar,
276
+ evaluateBoolean,
277
+ evaluateScalar,
278
+ });
279
+ //# sourceMappingURL=marcbachmann-cel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marcbachmann-cel.js","sourceRoot":"","sources":["../src/marcbachmann-cel.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,IAAI,cAAc,EAC7B,UAAU,IAAI,aAAa,EAC3B,SAAS,IAAI,YAAY,EACzB,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAqC,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,MAAM,GAEP,MAAM,wBAAwB,CAAC;AAEhC,MAAM,mBAAmB,GAAG,MAAM,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAiBpE,MAAM,mBAAmB,GAAwB,IAAI,GAAG,CAAC;IACvD,MAAM;IACN,QAAQ;IACR,KAAK;IACL,WAAW;IACX,QAAQ;IACR,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AC;AAEH,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE;IAClE,qBAAqB;IACrB,YAAY;IACZ,WAAW;IACX,eAAe;IACf,cAAc;CACf,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usine/expression",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "CEL expression seam for usine: check and evaluate the selection expressions loop files use.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,16 +14,26 @@
14
14
  "type": "module",
15
15
  "sideEffects": false,
16
16
  "exports": {
17
- ".": {
18
- "types": "./dist/index.d.ts",
19
- "default": "./dist/index.js"
17
+ "./expression-engine": {
18
+ "types": "./dist/expression-engine.d.ts",
19
+ "default": "./dist/expression-engine.js"
20
+ },
21
+ "./marcbachmann-cel": {
22
+ "types": "./dist/marcbachmann-cel.d.ts",
23
+ "default": "./dist/marcbachmann-cel.js"
20
24
  }
21
25
  },
22
26
  "publishConfig": {
23
27
  "access": "public"
24
28
  },
29
+ "dependencies": {
30
+ "@marcbachmann/cel-js": "8.0.0"
31
+ },
25
32
  "devDependencies": {
33
+ "@effect/vitest": "4.0.0-rc.111",
34
+ "effect": "4.0.0-rc.111",
26
35
  "typescript": "7.0.2",
36
+ "vitest": "4.1.11",
27
37
  "@usine/tsconfig": "0.0.0"
28
38
  },
29
39
  "peerDependencies": {
@@ -33,6 +43,8 @@
33
43
  "node": ">=22"
34
44
  },
35
45
  "scripts": {
36
- "build": "tsc -b"
46
+ "build": "tsc -b",
47
+ "check": "tsc -p tsconfig.check.json",
48
+ "test": "vitest run"
37
49
  }
38
50
  }
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * @usine/expression — CEL expression seam for usine: check and evaluate the selection expressions loop files use.
3
- *
4
- * Not implemented yet: this 0.0.x release reserves the block's seam while the
5
- * engine grows.
6
- */
7
- export {};
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC"}
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * @usine/expression — CEL expression seam for usine: check and evaluate the selection expressions loop files use.
3
- *
4
- * Not implemented yet: this 0.0.x release reserves the block's seam while the
5
- * engine grows.
6
- */
7
- export {};
8
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC"}