@usine/expression 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/dist/environment.d.ts +44 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +43 -0
- package/dist/environment.js.map +1 -0
- package/dist/expression-engine.d.ts +73 -4
- package/dist/expression-engine.d.ts.map +1 -1
- package/dist/expression-engine.js +63 -1
- package/dist/expression-engine.js.map +1 -1
- package/dist/marcbachmann-cel.d.ts +16 -1
- package/dist/marcbachmann-cel.d.ts.map +1 -1
- package/dist/marcbachmann-cel.js +355 -62
- package/dist/marcbachmann-cel.js.map +1 -1
- package/package.json +10 -5
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/model.d.ts +0 -61
- package/dist/model.d.ts.map +0 -1
- package/dist/model.js +0 -66
- package/dist/model.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# @usine/expression
|
|
2
2
|
|
|
3
|
-
Typed CEL checking and evaluation for [usine](https://github.com/basaltbytes/usine).
|
|
3
|
+
Typed CEL checking and evaluation for [usine](https://github.com/basaltbytes/usine). Describe types and root variables with `Environment`. `ExpressionEngine` then checks boolean trigger and scalar prompt expressions, and evaluates them over plain JSON.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Import `ExpressionEngine`, `Source`, `Environment`, the environment descriptors, `Scalar`, and the typed errors from `@usine/expression/expression-engine`, which replaces `@usine/expression/model`. The CEL adapter layer is in `@usine/expression/marcbachmann-cel`.
|
|
6
6
|
|
|
7
|
-
`
|
|
7
|
+
A `nullable` `ObjectField` can be `null`, and an absent key reads as `null`. Expressions compare it with `null` in either order, and paths below it stay type-checked. Unknown variables and paths fail checking, also inside macros such as `exists`.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Expressions can use CEL optional values: `.?` and `[?]` select a value that might be missing, and `optional` helpers such as `orValue` give a fallback. `item.?milestone.?title.orValue("none")` is `"none"` if `milestone` is null or absent. A null field counts as present, so `item.?milestone` holds `null`, not an empty optional.
|
|
10
|
+
|
|
11
|
+
Errors: `ExpressionCheckError` (parse, type, or result type), `ExpressionEvaluationError`, and the union `ExpressionError`. JSON integers declared as CEL `int` or `uint` become `bigint` before evaluation, so GraphQL payloads keep CEL integer semantics.
|
|
12
|
+
|
|
13
|
+
`relatedStringLiterals(source, memberPath)` returns string literals from the smallest subtrees that use a member path. It accepts the same syntax as the checks, including `.?`. Config validation uses it to report undeclared labels without depending on the CEL AST.
|
|
14
|
+
|
|
15
|
+
`MarcbachmannCelLayer` uses `@marcbachmann/cel-js@8.0.0`. The contract uses CEL type names and usine descriptors, not library objects; an `@bufbuild/cel` adapter can provide the same tag.
|
|
16
|
+
|
|
17
|
+
The 0.x APIs can change between minor releases.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* A CEL type name without spaces, such as `string`, `Label`, `list<T>`, or `map<K,V>`.
|
|
4
|
+
* Decoding checks only the syntax; an undeclared object type fails when an expression is checked.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TypeReference: Schema.brand<Schema.String, "CelTypeReference">;
|
|
7
|
+
export type TypeReference = typeof TypeReference.Type;
|
|
8
|
+
declare const ObjectField_base: Schema.Class<ObjectField, Schema.Struct<{
|
|
9
|
+
readonly name: Schema.String;
|
|
10
|
+
/** The CEL type of a non-`null` value. */
|
|
11
|
+
readonly type: Schema.brand<Schema.String, "CelTypeReference">;
|
|
12
|
+
/** Whether the value can be `null` or absent. Reading an absent non-nullable field fails evaluation. */
|
|
13
|
+
readonly nullable: Schema.withConstructorDefault<Schema.Boolean>;
|
|
14
|
+
}>, {}>;
|
|
15
|
+
/** A field of an {@link ObjectType}. If the field is nullable and its key is absent, it evaluates to `null`. */
|
|
16
|
+
export declare class ObjectField extends ObjectField_base {
|
|
17
|
+
}
|
|
18
|
+
declare const ObjectType_base: Schema.Class<ObjectType, Schema.Struct<{
|
|
19
|
+
readonly name: Schema.String;
|
|
20
|
+
readonly fields: Schema.$Array<typeof ObjectField>;
|
|
21
|
+
}>, {}>;
|
|
22
|
+
/** An object type that expressions can read fields from, such as `IssuePayload`. */
|
|
23
|
+
export declare class ObjectType extends ObjectType_base {
|
|
24
|
+
}
|
|
25
|
+
declare const Variable_base: Schema.Class<Variable, Schema.Struct<{
|
|
26
|
+
readonly name: Schema.String;
|
|
27
|
+
readonly type: Schema.brand<Schema.String, "CelTypeReference">;
|
|
28
|
+
}>, {}>;
|
|
29
|
+
/** A root variable, such as `repo` or `item`, whose value is the `context` entry with the same name. */
|
|
30
|
+
export declare class Variable extends Variable_base {
|
|
31
|
+
}
|
|
32
|
+
declare const Environment_base: Schema.Class<Environment, Schema.Struct<{
|
|
33
|
+
/** The object types, each declared before any type whose fields reference it. */
|
|
34
|
+
readonly types: Schema.$Array<typeof ObjectType>;
|
|
35
|
+
readonly variables: Schema.$Array<typeof Variable>;
|
|
36
|
+
}>, {}>;
|
|
37
|
+
/**
|
|
38
|
+
* The types and root variables that expressions are checked and evaluated against. An
|
|
39
|
+
* expression that references anything else fails checking.
|
|
40
|
+
*/
|
|
41
|
+
export declare class Environment extends Environment_base {
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,aAAa,iDAKc,CAAC;AACzC,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;;;IAqBpD,0CAA0C;;IAE1C,wGAAwG;;;AAL1G,gHAAgH;AAChH,qBAAa,WAAY,SAAQ,gBAM/B;CAAG;;;;;AAEL,oFAAoF;AACpF,qBAAa,UAAW,SAAQ,eAG9B;CAAG;;;;;AAEL,wGAAwG;AACxG,qBAAa,QAAS,SAAQ,aAG5B;CAAG;;IAOH,iFAAiF;;;;AALnF;;;GAGG;AACH,qBAAa,WAAY,SAAQ,gBAI/B;CAAG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* A CEL type name without spaces, such as `string`, `Label`, `list<T>`, or `map<K,V>`.
|
|
4
|
+
* Decoding checks only the syntax; an undeclared object type fails when an expression is checked.
|
|
5
|
+
*/
|
|
6
|
+
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"));
|
|
7
|
+
const Identifier = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_]*$/u, { message: "Expected a CEL identifier" }));
|
|
8
|
+
const ObjectTypeName = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_.]*$/u, {
|
|
9
|
+
message: "Expected a CEL object-type name",
|
|
10
|
+
}));
|
|
11
|
+
const uniqueNames = (message) => Schema.makeFilter((values) => new Set(values.map(({ name }) => name)).size === values.length, { message });
|
|
12
|
+
/** A field of an {@link ObjectType}. If the field is nullable and its key is absent, it evaluates to `null`. */
|
|
13
|
+
export class ObjectField extends Schema.Class("@usine/expression/ObjectField")({
|
|
14
|
+
name: Identifier,
|
|
15
|
+
/** The CEL type of a non-`null` value. */
|
|
16
|
+
type: TypeReference,
|
|
17
|
+
/** Whether the value can be `null` or absent. Reading an absent non-nullable field fails evaluation. */
|
|
18
|
+
nullable: Schema.Boolean.pipe(Schema.withConstructorDefault(Effect.succeed(false))),
|
|
19
|
+
}) {
|
|
20
|
+
}
|
|
21
|
+
/** An object type that expressions can read fields from, such as `IssuePayload`. */
|
|
22
|
+
export class ObjectType extends Schema.Class("@usine/expression/ObjectType")({
|
|
23
|
+
name: ObjectTypeName,
|
|
24
|
+
fields: Schema.Array(ObjectField).check(uniqueNames("Expected unique CEL object-field names")),
|
|
25
|
+
}) {
|
|
26
|
+
}
|
|
27
|
+
/** A root variable, such as `repo` or `item`, whose value is the `context` entry with the same name. */
|
|
28
|
+
export class Variable extends Schema.Class("@usine/expression/Variable")({
|
|
29
|
+
name: Identifier,
|
|
30
|
+
type: TypeReference,
|
|
31
|
+
}) {
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The types and root variables that expressions are checked and evaluated against. An
|
|
35
|
+
* expression that references anything else fails checking.
|
|
36
|
+
*/
|
|
37
|
+
export class Environment extends Schema.Class("@usine/expression/Environment")({
|
|
38
|
+
/** The object types, each declared before any type whose fields reference it. */
|
|
39
|
+
types: Schema.Array(ObjectType).check(uniqueNames("Expected unique CEL object-type names")),
|
|
40
|
+
variables: Schema.Array(Variable).check(uniqueNames("Expected unique CEL variable names")),
|
|
41
|
+
}) {
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC9C,MAAM,CAAC,SAAS,CACd,mHAAmH,EACnH,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAC7C,CACF,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAGzC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,C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C;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,KAAK,CAAc,+BAA+B,CAAC,CAAC;IAC1F,iFAAiF;IACjF,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"}
|
|
@@ -1,14 +1,83 @@
|
|
|
1
|
-
import { Context, type Effect, type Schema } from "effect";
|
|
2
|
-
import type { Environment
|
|
3
|
-
/**
|
|
1
|
+
import { Context, type Effect, type Result, Schema } from "effect";
|
|
2
|
+
import type { Environment } from "./environment.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The text of a CEL expression, such as a Loop's `if:` condition or a `{{ }}` interpolation.
|
|
5
|
+
* Decoding rejects blank text; {@link ExpressionEngine} checks syntax and types.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Source: Schema.brand<Schema.String, "ExpressionSource">;
|
|
8
|
+
export type Source = typeof Source.Type;
|
|
9
|
+
/**
|
|
10
|
+
* - `parse_error`: the source is not valid CEL syntax.
|
|
11
|
+
* - `type_error`: the source references an unknown variable or field, or combines
|
|
12
|
+
* incompatible types.
|
|
13
|
+
* - `unexpected_result_type`: the result type is wrong for the operation, such as a non-`bool`
|
|
14
|
+
* selection condition.
|
|
15
|
+
* - `check_failed`: the CEL implementation rejected the {@link Environment} itself, such as an
|
|
16
|
+
* undeclared type name, or failed without a detail.
|
|
17
|
+
*/
|
|
18
|
+
export declare const CheckErrorCode: Schema.Literals<readonly ["check_failed", "parse_error", "type_error", "unexpected_result_type"]>;
|
|
19
|
+
export type CheckErrorCode = typeof CheckErrorCode.Type;
|
|
20
|
+
declare const ExpressionCheckError_base: Schema.Class<ExpressionCheckError, Schema.TaggedStruct<"ExpressionCheckError", {
|
|
21
|
+
readonly source: Schema.brand<Schema.String, "ExpressionSource">;
|
|
22
|
+
readonly code: Schema.Literals<readonly ["check_failed", "parse_error", "type_error", "unexpected_result_type"]>;
|
|
23
|
+
/**
|
|
24
|
+
* A human-readable description, possibly multi-line with a marked excerpt of `source`. The
|
|
25
|
+
* wording isn't stable; branch on `code`.
|
|
26
|
+
*/
|
|
27
|
+
readonly message: Schema.NonEmptyString;
|
|
28
|
+
/**
|
|
29
|
+
* The zero-based offset in `source` where the failure starts. Always `None` for
|
|
30
|
+
* `unexpected_result_type` and `check_failed`.
|
|
31
|
+
*/
|
|
32
|
+
readonly position: Schema.Option<Schema.Int>;
|
|
33
|
+
}>, import("effect/Cause").YieldableError>;
|
|
34
|
+
/** An error from checking an expression against an {@link Environment}; checking never reads a payload. */
|
|
35
|
+
export declare class ExpressionCheckError extends ExpressionCheckError_base {
|
|
36
|
+
}
|
|
37
|
+
declare const ExpressionEvaluationError_base: Schema.Class<ExpressionEvaluationError, Schema.TaggedStruct<"ExpressionEvaluationError", {
|
|
38
|
+
readonly source: Schema.brand<Schema.String, "ExpressionSource">;
|
|
39
|
+
/** A human-readable description, possibly multi-line with a marked excerpt of `source`. The wording isn't stable. */
|
|
40
|
+
readonly message: Schema.NonEmptyString;
|
|
41
|
+
}>, import("effect/Cause").YieldableError>;
|
|
42
|
+
/**
|
|
43
|
+
* An error from evaluating a checked expression, such as a missing `context` key, a value of the
|
|
44
|
+
* wrong type, division by zero, or an out-of-range list index.
|
|
45
|
+
*/
|
|
46
|
+
export declare class ExpressionEvaluationError extends ExpressionEvaluationError_base {
|
|
47
|
+
}
|
|
48
|
+
export declare const ExpressionError: Schema.Union<readonly [typeof ExpressionCheckError, typeof ExpressionEvaluationError]>;
|
|
49
|
+
export type ExpressionError = typeof ExpressionError.Type;
|
|
50
|
+
/**
|
|
51
|
+
* The result of a prompt interpolation; CEL `int` is a `bigint` and `double` is a `number`. A
|
|
52
|
+
* `uint` result passes `checkScalar`, but `evaluateScalar` fails with
|
|
53
|
+
* {@link ExpressionEvaluationError}; wrap it in `string(...)` or `double(...)`.
|
|
54
|
+
*/
|
|
55
|
+
export declare const Scalar: Schema.Union<readonly [Schema.String, Schema.Number, Schema.BigInt, Schema.Boolean, Schema.Null]>;
|
|
56
|
+
export type Scalar = typeof Scalar.Type;
|
|
4
57
|
export interface ExpressionEngineService {
|
|
58
|
+
/**
|
|
59
|
+
* Returns the string literals compared with the `name` field of values under `memberPath`,
|
|
60
|
+
* following macro bindings and collection transformations. Accepts the same syntax as
|
|
61
|
+
* `checkBoolean` and `checkScalar`, including optional selection (`.?`).
|
|
62
|
+
*/
|
|
63
|
+
readonly relatedStringLiterals: (source: Source, memberPath: ReadonlyArray<string>) => Effect.Effect<ReadonlyArray<string>, ExpressionCheckError>;
|
|
64
|
+
/** Checks that the expression has type `bool`. */
|
|
5
65
|
readonly checkBoolean: (source: Source, environment: Environment) => Effect.Effect<void, ExpressionCheckError>;
|
|
66
|
+
/** Checks that the expression can be a prompt interpolation. */
|
|
6
67
|
readonly checkScalar: (source: Source, environment: Environment) => Effect.Effect<void, ExpressionCheckError>;
|
|
68
|
+
/** Checks and evaluates a selection condition against `context`. */
|
|
7
69
|
readonly evaluateBoolean: (source: Source, environment: Environment, context: Schema.JsonObject) => Effect.Effect<boolean, ExpressionError>;
|
|
70
|
+
/**
|
|
71
|
+
* Checks the condition once and evaluates it against each of `contexts`, returning one
|
|
72
|
+
* `Result` per context in order. Fails with `ExpressionCheckError` if the check fails.
|
|
73
|
+
*/
|
|
74
|
+
readonly evaluateBooleanEach: (source: Source, environment: Environment, contexts: ReadonlyArray<Schema.JsonObject>) => Effect.Effect<ReadonlyArray<Result.Result<boolean, ExpressionEvaluationError>>, ExpressionCheckError>;
|
|
75
|
+
/** Checks and evaluates a prompt interpolation against `context`. */
|
|
8
76
|
readonly evaluateScalar: (source: Source, environment: Environment, context: Schema.JsonObject) => Effect.Effect<Scalar, ExpressionError>;
|
|
9
77
|
}
|
|
10
78
|
declare const ExpressionEngine_base: Context.ServiceClass<ExpressionEngine, "@usine/expression/ExpressionEngine", ExpressionEngineService>;
|
|
79
|
+
/** The CEL expression service, provided by `MarcbachmannCelLayer` from `@usine/expression/marcbachmann-cel`. */
|
|
11
80
|
export declare class ExpressionEngine extends ExpressionEngine_base {
|
|
12
81
|
}
|
|
13
|
-
export {};
|
|
82
|
+
export { TypeReference, ObjectField, ObjectType, Variable, Environment } from "./environment.ts";
|
|
14
83
|
//# sourceMappingURL=expression-engine.d.ts.map
|
|
@@ -1 +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,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"expression-engine.d.ts","sourceRoot":"","sources":["../src/expression-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,MAAM,iDAEqB,CAAC;AACzC,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;AAIxC;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,mGAKzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;;;;IAQtD;;;OAGG;;IAEH;;;OAGG;;;AAdL,2GAA2G;AAC3G,qBAAa,oBAAqB,SAAQ,yBAexC;CAAG;;;IAUH,qHAAqH;;;AARvH;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,8BAM7C;CAAG;AAEL,eAAO,MAAM,eAAe,wFAAkE,CAAC;AAC/F,MAAM,MAAM,eAAe,GAAG,OAAO,e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B,OAAO,EAAE,MAAM,CAAC,UAAU,KACvB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC7C;;AAED,gHAAgH;AAChH,qBAAa,gBAAiB,SAAQ,qBAErC;CAAG;AAEJ,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,66 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
1
|
+
import { Context, Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* The text of a CEL expression, such as a Loop's `if:` condition or a `{{ }}` interpolation.
|
|
4
|
+
* Decoding rejects blank text; {@link ExpressionEngine} checks syntax and types.
|
|
5
|
+
*/
|
|
6
|
+
export const Source = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank CEL expression" })).pipe(Schema.brand("ExpressionSource"));
|
|
7
|
+
const Position = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
8
|
+
/**
|
|
9
|
+
* - `parse_error`: the source is not valid CEL syntax.
|
|
10
|
+
* - `type_error`: the source references an unknown variable or field, or combines
|
|
11
|
+
* incompatible types.
|
|
12
|
+
* - `unexpected_result_type`: the result type is wrong for the operation, such as a non-`bool`
|
|
13
|
+
* selection condition.
|
|
14
|
+
* - `check_failed`: the CEL implementation rejected the {@link Environment} itself, such as an
|
|
15
|
+
* undeclared type name, or failed without a detail.
|
|
16
|
+
*/
|
|
17
|
+
export const CheckErrorCode = Schema.Literals([
|
|
18
|
+
"check_failed",
|
|
19
|
+
"parse_error",
|
|
20
|
+
"type_error",
|
|
21
|
+
"unexpected_result_type",
|
|
22
|
+
]);
|
|
23
|
+
/** An error from checking an expression against an {@link Environment}; checking never reads a payload. */
|
|
24
|
+
export class ExpressionCheckError extends Schema.TaggedError("@usine/expression/ExpressionCheckError")("ExpressionCheckError", {
|
|
25
|
+
source: Source,
|
|
26
|
+
code: CheckErrorCode,
|
|
27
|
+
/**
|
|
28
|
+
* A human-readable description, possibly multi-line with a marked excerpt of `source`. The
|
|
29
|
+
* wording isn't stable; branch on `code`.
|
|
30
|
+
*/
|
|
31
|
+
message: Schema.NonEmptyString,
|
|
32
|
+
/**
|
|
33
|
+
* The zero-based offset in `source` where the failure starts. Always `None` for
|
|
34
|
+
* `unexpected_result_type` and `check_failed`.
|
|
35
|
+
*/
|
|
36
|
+
position: Schema.Option(Position),
|
|
37
|
+
}) {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An error from evaluating a checked expression, such as a missing `context` key, a value of the
|
|
41
|
+
* wrong type, division by zero, or an out-of-range list index.
|
|
42
|
+
*/
|
|
43
|
+
export class ExpressionEvaluationError extends Schema.TaggedError("@usine/expression/ExpressionEvaluationError")("ExpressionEvaluationError", {
|
|
44
|
+
source: Source,
|
|
45
|
+
/** A human-readable description, possibly multi-line with a marked excerpt of `source`. The wording isn't stable. */
|
|
46
|
+
message: Schema.NonEmptyString,
|
|
47
|
+
}) {
|
|
48
|
+
}
|
|
49
|
+
export const ExpressionError = Schema.Union([ExpressionCheckError, ExpressionEvaluationError]);
|
|
50
|
+
/**
|
|
51
|
+
* The result of a prompt interpolation; CEL `int` is a `bigint` and `double` is a `number`. A
|
|
52
|
+
* `uint` result passes `checkScalar`, but `evaluateScalar` fails with
|
|
53
|
+
* {@link ExpressionEvaluationError}; wrap it in `string(...)` or `double(...)`.
|
|
54
|
+
*/
|
|
55
|
+
export const Scalar = Schema.Union([
|
|
56
|
+
Schema.String,
|
|
57
|
+
Schema.Number,
|
|
58
|
+
Schema.BigInt,
|
|
59
|
+
Schema.Boolean,
|
|
60
|
+
Schema.Null,
|
|
61
|
+
]);
|
|
62
|
+
/** The CEL expression service, provided by `MarcbachmannCelLayer` from `@usine/expression/marcbachmann-cel`. */
|
|
2
63
|
export class ExpressionEngine extends Context.Service()("@usine/expression/ExpressionEngine") {
|
|
3
64
|
}
|
|
65
|
+
export { TypeReference, ObjectField, ObjectType, Variable, Environment } from "./environment.js";
|
|
4
66
|
//# sourceMappingURL=expression-engine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-engine.js","sourceRoot":"","sources":["../src/expression-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"expression-engine.js","sourceRoot":"","sources":["../src/expression-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA4B,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGnE;;;GAGG;AACH,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;AAGzC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC5C,cAAc;IACd,aAAa;IACb,YAAY;IACZ,wBAAwB;CACzB,CAAC,CAAC;AAGH,2GAA2G;AAC3G,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,CAC1D,wCAAwC,CACzC,CAAC,sBAAsB,EAAE;IACxB,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,cAAc;IACpB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,cAAc;IAC9B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;CAClC,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,MAAM,CAAC,WAAW,CAC/D,6CAA6C,CAC9C,CAAC,2BAA2B,EAAE;IAC7B,MAAM,EAAE,MAAM;IACd,qHAAqH;IACrH,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,EAAE,yBAAyB,CAAC,CAAC,CAAC;AAG/F;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;IACjC,MAAM,CAAC,MAAM;IACb,MAAM,CAAC,MAAM;IACb,MAAM,CAAC,MAAM;IACb,MAAM,CAAC,OAAO;IACd,MAAM,CAAC,IAAI;CACZ,CAAC,CAAC;AAiDH,gHAAgH;AAChH,MAAM,OAAO,gBAAiB,SAAQ,OAAO,CAAC,OAAO,EAA6C,CAChG,oCAAoC,CACrC;CAAG;AAEJ,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
2
|
import { ExpressionEngine } from "./expression-engine.ts";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Provides {@link ExpressionEngine} with `@marcbachmann/cel-js` 8.0.0
|
|
5
|
+
* ([ADR 0004](../../../docs/adr/0004-loop-files-markdown-cel-frontmatter.md)).
|
|
6
|
+
*
|
|
7
|
+
* Expressions can use CEL optional values, such as `item.?milestone.?title.orValue("none")`. A
|
|
8
|
+
* nullable field that holds `null` counts as present, so `item.?milestone` holds `null` and
|
|
9
|
+
* `item.?milestone.?title` is empty.
|
|
10
|
+
*
|
|
11
|
+
* Before evaluation, converts JSON integers to `bigint` wherever the {@link Environment}
|
|
12
|
+
* declares `int`, at any depth, and sets absent nullable fields to `null`. Values inside a
|
|
13
|
+
* `map<K,V>` aren't converted, so declare integer map values as `double`.
|
|
14
|
+
*
|
|
15
|
+
* `uint` isn't supported in `context`; declare such values as `int`. An expression that reads a
|
|
16
|
+
* non-nullable `uint` value type-checks but fails evaluation. On a nullable field, comparing with a
|
|
17
|
+
* `uint` literal works but `uint` arithmetic fails. A `uint` result fails `evaluateScalar`.
|
|
18
|
+
*/
|
|
4
19
|
export declare const MarcbachmannCelLayer: Layer.Layer<ExpressionEngine, never, never>;
|
|
5
20
|
//# sourceMappingURL=marcbachmann-cel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marcbachmann-cel.d.ts","sourceRoot":"","sources":["../src/marcbachmann-cel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"marcbachmann-cel.d.ts","sourceRoot":"","sources":["../src/marcbachmann-cel.ts"],"names":[],"mappings":"AASA,OAAO,EAAU,KAAK,EAAqC,MAAM,QAAQ,CAAC;AAE1E,OAAO,EACL,gBAAgB,EAKjB,MAAM,wBAAwB,CAAC;AAsjBhC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,6CAAqD,CAAC"}
|
package/dist/marcbachmann-cel.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { Environment as CelEnvironment, ParseError as CelParseError, TypeError as CelTypeError, } from "@marcbachmann/cel-js";
|
|
2
|
-
import { Effect, Layer, Option, Schema } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
import { ExpressionCheckError, ExpressionEvaluationError, Scalar,
|
|
2
|
+
import { Effect, Layer, Option, Predicate, Result, Schema } from "effect";
|
|
3
|
+
import { TypeReference } from "./environment.js";
|
|
4
|
+
import { ExpressionEngine, ExpressionCheckError, ExpressionEvaluationError, Scalar, } from "./expression-engine.js";
|
|
5
5
|
const decodeTypeReference = Schema.decodeUnknownSync(TypeReference);
|
|
6
|
+
const ENVIRONMENT_OPTIONS = {
|
|
7
|
+
unlistedVariablesAreDyn: false,
|
|
8
|
+
enableOptionalTypes: true,
|
|
9
|
+
};
|
|
10
|
+
/** Parser for {@link relatedStringLiterals}, with the checking options so that it accepts `.?`. */
|
|
11
|
+
const parser = new CelEnvironment(ENVIRONMENT_OPTIONS);
|
|
6
12
|
const acceptedScalarTypes = new Set([
|
|
7
13
|
"bool",
|
|
8
14
|
"double",
|
|
9
15
|
"int",
|
|
10
|
-
"
|
|
16
|
+
"null",
|
|
11
17
|
"string",
|
|
12
18
|
"uint",
|
|
13
19
|
]);
|
|
@@ -19,7 +25,7 @@ const checkFailure = (source, error) => error === undefined
|
|
|
19
25
|
? new ExpressionCheckError({
|
|
20
26
|
source,
|
|
21
27
|
code: "check_failed",
|
|
22
|
-
message: "CEL check failed
|
|
28
|
+
message: "The CEL check failed and returned no error details",
|
|
23
29
|
position: Option.none(),
|
|
24
30
|
})
|
|
25
31
|
: new ExpressionCheckError({
|
|
@@ -28,53 +34,314 @@ const checkFailure = (source, error) => error === undefined
|
|
|
28
34
|
message: error.message,
|
|
29
35
|
position: Option.fromNullishOr(error.range?.start),
|
|
30
36
|
});
|
|
31
|
-
const
|
|
32
|
-
|
|
37
|
+
const childNodes = (node) => {
|
|
38
|
+
switch (node.op) {
|
|
39
|
+
case "value":
|
|
40
|
+
case "id":
|
|
41
|
+
return [];
|
|
42
|
+
case ".":
|
|
43
|
+
case ".?":
|
|
44
|
+
return [node.args[0]];
|
|
45
|
+
case "!_":
|
|
46
|
+
case "-_":
|
|
47
|
+
return [node.args];
|
|
48
|
+
case "call":
|
|
49
|
+
return node.args[1];
|
|
50
|
+
case "rcall":
|
|
51
|
+
return [node.args[1], ...node.args[2]];
|
|
52
|
+
case "list":
|
|
53
|
+
return node.args;
|
|
54
|
+
case "map":
|
|
55
|
+
return node.args.flatMap(([key, value]) => [key, value]);
|
|
56
|
+
default:
|
|
57
|
+
return node.args;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const pathOf = (node) => {
|
|
61
|
+
if (node.op === "id")
|
|
62
|
+
return [node.args];
|
|
63
|
+
if (node.op !== "." && node.op !== ".?")
|
|
64
|
+
return undefined;
|
|
65
|
+
const parent = pathOf(node.args[0]);
|
|
66
|
+
return parent === undefined ? undefined : [...parent, node.args[1]];
|
|
67
|
+
};
|
|
68
|
+
const decodeStringLiteral = Schema.decodeUnknownOption(Schema.String);
|
|
69
|
+
const MACROS_WITH_BINDINGS = new Set([
|
|
70
|
+
"all",
|
|
71
|
+
"exists",
|
|
72
|
+
"exists_one",
|
|
73
|
+
"filter",
|
|
74
|
+
"map",
|
|
75
|
+
]);
|
|
76
|
+
/** Returns the member path that a node reads, resolved through macro bindings and `filter`/`map` receivers, or `undefined`. */
|
|
77
|
+
const lineagePathOf = (node, bindings) => {
|
|
78
|
+
const path = pathOf(node);
|
|
79
|
+
if (path !== undefined) {
|
|
80
|
+
const boundPath = bindings.get(path[0]);
|
|
81
|
+
return boundPath === undefined ? path : [...boundPath, ...path.slice(1)];
|
|
82
|
+
}
|
|
83
|
+
if (node.op !== "rcall")
|
|
84
|
+
return undefined;
|
|
85
|
+
const [macro, receiver, args] = node.args;
|
|
86
|
+
const receiverPath = lineagePathOf(receiver, bindings);
|
|
87
|
+
if (receiverPath === undefined)
|
|
88
|
+
return undefined;
|
|
89
|
+
if (macro === "filter")
|
|
90
|
+
return receiverPath;
|
|
91
|
+
if (macro !== "map")
|
|
92
|
+
return undefined;
|
|
93
|
+
const [binding, ...body] = args;
|
|
94
|
+
const projection = body[body.length - 1];
|
|
95
|
+
if (binding?.op !== "id" || projection === undefined)
|
|
96
|
+
return undefined;
|
|
97
|
+
return lineagePathOf(projection, new Map(bindings).set(binding.args, receiverPath));
|
|
98
|
+
};
|
|
99
|
+
const startsWithPath = (path, prefix) => prefix.every((part, index) => path[index] === part);
|
|
100
|
+
/** Returns the string literals an operand can evaluate to: a literal, both branches of `?:`, and list elements. */
|
|
101
|
+
const resultStringLiterals = (node) => {
|
|
102
|
+
switch (node.op) {
|
|
103
|
+
case "value":
|
|
104
|
+
return Option.match(decodeStringLiteral(node.args), {
|
|
105
|
+
onNone: () => [],
|
|
106
|
+
onSome: (literal) => [literal],
|
|
107
|
+
});
|
|
108
|
+
case "?:": {
|
|
109
|
+
const [, whenTrue, whenFalse] = node.args;
|
|
110
|
+
return [...resultStringLiterals(whenTrue), ...resultStringLiterals(whenFalse)];
|
|
111
|
+
}
|
|
112
|
+
case "list":
|
|
113
|
+
return node.args.flatMap(resultStringLiterals);
|
|
114
|
+
default:
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const isRelatedName = (node, memberPath, bindings) => {
|
|
119
|
+
const path = lineagePathOf(node, bindings);
|
|
120
|
+
return path !== undefined && startsWithPath(path, memberPath) && path[path.length - 1] === "name";
|
|
121
|
+
};
|
|
122
|
+
const comparisonLiterals = (node, memberPath, bindings) => {
|
|
123
|
+
switch (node.op) {
|
|
124
|
+
case "!=":
|
|
125
|
+
case "==":
|
|
126
|
+
case "in": {
|
|
127
|
+
const [left, right] = node.args;
|
|
128
|
+
return [
|
|
129
|
+
...(isRelatedName(left, memberPath, bindings) ? resultStringLiterals(right) : []),
|
|
130
|
+
...(isRelatedName(right, memberPath, bindings) ? resultStringLiterals(left) : []),
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
default:
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/** Returns the literals compared with `name` on values under `memberPath`, including through macro variables. */
|
|
138
|
+
const scanRelatedLiterals = (node, memberPath, bindings) => {
|
|
139
|
+
const related = comparisonLiterals(node, memberPath, bindings);
|
|
140
|
+
if (node.op !== "rcall" || !MACROS_WITH_BINDINGS.has(node.args[0])) {
|
|
141
|
+
return [
|
|
142
|
+
...related,
|
|
143
|
+
...childNodes(node).flatMap((child) => scanRelatedLiterals(child, memberPath, bindings)),
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
const [, receiver, args] = node.args;
|
|
147
|
+
const [binding, ...body] = args;
|
|
148
|
+
const receiverPath = lineagePathOf(receiver, bindings);
|
|
149
|
+
if (binding?.op !== "id" || receiverPath === undefined) {
|
|
150
|
+
return [
|
|
151
|
+
...related,
|
|
152
|
+
...childNodes(node).flatMap((child) => scanRelatedLiterals(child, memberPath, bindings)),
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
const bodyBindings = new Map(bindings).set(binding.args, receiverPath);
|
|
156
|
+
return [
|
|
157
|
+
...related,
|
|
158
|
+
...scanRelatedLiterals(receiver, memberPath, bindings),
|
|
159
|
+
...body.flatMap((child) => scanRelatedLiterals(child, memberPath, bodyBindings)),
|
|
160
|
+
];
|
|
161
|
+
};
|
|
162
|
+
const relatedStringLiterals = Effect.fn("ExpressionEngine.relatedStringLiterals")(function* (source, memberPath) {
|
|
163
|
+
if (memberPath.length === 0)
|
|
164
|
+
return [];
|
|
165
|
+
const ast = yield* Effect.try({
|
|
166
|
+
try: () => parser.parse(source).ast,
|
|
167
|
+
catch: (cause) => cause instanceof CelParseError
|
|
168
|
+
? checkFailure(source, cause)
|
|
169
|
+
: new ExpressionCheckError({
|
|
170
|
+
source,
|
|
171
|
+
code: "check_failed",
|
|
172
|
+
message: messageFromCause(cause, "CEL analysis failed"),
|
|
173
|
+
position: Option.none(),
|
|
174
|
+
}),
|
|
175
|
+
});
|
|
176
|
+
return [...new Set(scanRelatedLiterals(ast, memberPath, new Map()))];
|
|
177
|
+
});
|
|
178
|
+
/**
|
|
179
|
+
* Creates the cel-js environment for checking or evaluating `descriptor`. Because cel-js rejects
|
|
180
|
+
* `null` in a typed field and can't index `dyn<T>`, evaluation declares nullable fields as `dyn`.
|
|
181
|
+
* Both register `T == null`; cel-js derives `!=` and the reversed operand order from it.
|
|
182
|
+
*/
|
|
183
|
+
const makeEnvironment = (descriptor, purpose) => {
|
|
184
|
+
const environment = new CelEnvironment(ENVIRONMENT_OPTIONS);
|
|
185
|
+
const nullableTypes = new Set();
|
|
33
186
|
for (const objectType of descriptor.types) {
|
|
34
187
|
environment.registerType(objectType.name, {
|
|
35
|
-
fields: Object.fromEntries(objectType.fields.map((field) =>
|
|
188
|
+
fields: Object.fromEntries(objectType.fields.map((field) => {
|
|
189
|
+
if (!field.nullable)
|
|
190
|
+
return [field.name, field.type];
|
|
191
|
+
nullableTypes.add(field.type);
|
|
192
|
+
return [field.name, purpose === "check" ? field.type : "dyn"];
|
|
193
|
+
})),
|
|
36
194
|
});
|
|
37
195
|
}
|
|
196
|
+
for (const type of nullableTypes) {
|
|
197
|
+
environment.registerOperator(`${type} == null`, (left, right) => left === right);
|
|
198
|
+
}
|
|
38
199
|
for (const variable of descriptor.variables) {
|
|
39
200
|
environment.registerVariable(variable.name, variable.type);
|
|
40
201
|
}
|
|
41
202
|
return environment;
|
|
42
203
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
204
|
+
/** Returns whether `value` is a JSON object, checking only the top level because the context is already `Schema.Json` (#464). */
|
|
205
|
+
const isJsonObject = (value) => Predicate.isObject(value);
|
|
206
|
+
/** The identity normalizer, compared by reference to skip types that need no normalization. */
|
|
207
|
+
const unchanged = (value) => value;
|
|
208
|
+
/** Sets `name` as an own property, including `__proto__`. */
|
|
209
|
+
const setField = (target, name, value) => {
|
|
210
|
+
if (name === "__proto__") {
|
|
211
|
+
Object.defineProperty(target, name, {
|
|
212
|
+
value,
|
|
213
|
+
enumerable: true,
|
|
214
|
+
writable: true,
|
|
215
|
+
configurable: true,
|
|
216
|
+
});
|
|
48
217
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return value.map((item) => normalizeValue(item, itemType, objectTypes));
|
|
218
|
+
else {
|
|
219
|
+
target[name] = value;
|
|
52
220
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Returns the context normalizer for `descriptor`, which converts `int` and `uint` numbers to
|
|
224
|
+
* `bigint` and sets absent nullable fields to `null`, recursing into `list<T>` items and declared
|
|
225
|
+
* object fields. Returns unchanged values as is, and shallow-copies changed objects.
|
|
226
|
+
*/
|
|
227
|
+
const contextNormalizer = (descriptor) => {
|
|
228
|
+
const objectTypes = new Map(descriptor.types.map((type) => [type.name, type]));
|
|
229
|
+
const compiled = new Map();
|
|
230
|
+
// Can't recurse forever: the Environment declares each type before any type that references it.
|
|
231
|
+
const normalizerOf = (type) => {
|
|
232
|
+
const existing = compiled.get(type);
|
|
233
|
+
if (existing !== undefined)
|
|
234
|
+
return existing;
|
|
235
|
+
const normalize = compile(type);
|
|
236
|
+
compiled.set(type, normalize);
|
|
237
|
+
return normalize;
|
|
238
|
+
};
|
|
239
|
+
const compile = (type) => {
|
|
240
|
+
if (type === "int" || type === "uint") {
|
|
241
|
+
return (value) => Predicate.isNumber(value) && Number.isInteger(value) ? BigInt(value) : value;
|
|
242
|
+
}
|
|
243
|
+
if (type.startsWith("list<") && type.endsWith(">")) {
|
|
244
|
+
const normalizeItem = normalizerOf(decodeTypeReference(type.slice(5, -1)));
|
|
245
|
+
if (normalizeItem === unchanged)
|
|
246
|
+
return unchanged;
|
|
247
|
+
return (value) => (Array.isArray(value) ? value.map(normalizeItem) : value);
|
|
248
|
+
}
|
|
249
|
+
const objectType = objectTypes.get(type);
|
|
250
|
+
if (objectType === undefined)
|
|
251
|
+
return unchanged;
|
|
252
|
+
const fields = objectType.fields.flatMap(({ name, type: fieldType }) => {
|
|
253
|
+
const normalize = normalizerOf(fieldType);
|
|
254
|
+
return normalize === unchanged ? [] : [[name, normalize]];
|
|
255
|
+
});
|
|
256
|
+
const nullable = objectType.fields.filter((field) => field.nullable).map(({ name }) => name);
|
|
257
|
+
if (fields.length === 0 && nullable.length === 0)
|
|
258
|
+
return unchanged;
|
|
259
|
+
return (value) => {
|
|
260
|
+
if (!isJsonObject(value))
|
|
261
|
+
return value;
|
|
262
|
+
const normalized = { ...value };
|
|
263
|
+
for (const [name, normalize] of fields) {
|
|
264
|
+
const fieldValue = value[name];
|
|
265
|
+
if (fieldValue !== undefined && Object.hasOwn(value, name)) {
|
|
266
|
+
setField(normalized, name, normalize(fieldValue));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
for (const name of nullable) {
|
|
270
|
+
if (!Object.hasOwn(value, name))
|
|
271
|
+
setField(normalized, name, null);
|
|
272
|
+
}
|
|
273
|
+
return normalized;
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
const variables = new Map(descriptor.variables.map((variable) => [variable.name, normalizerOf(variable.type)]));
|
|
277
|
+
return (context) => {
|
|
278
|
+
const normalized = { ...context };
|
|
279
|
+
for (const [name, normalize] of variables) {
|
|
280
|
+
const value = context[name];
|
|
281
|
+
if (value !== undefined && Object.hasOwn(context, name)) {
|
|
282
|
+
setField(normalized, name, normalize(value));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return normalized;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
/** The maximum number of cached check results, and of parse results, per environment. */
|
|
289
|
+
const KEPT_EXPRESSIONS = 256;
|
|
290
|
+
/** Stores `value` under `key` and returns it, evicting the oldest entry if the map is full. */
|
|
291
|
+
const keep = (kept, key, value) => {
|
|
292
|
+
if (kept.size >= KEPT_EXPRESSIONS) {
|
|
293
|
+
const oldest = kept.keys().next();
|
|
294
|
+
if (oldest.done !== true)
|
|
295
|
+
kept.delete(oldest.value);
|
|
62
296
|
}
|
|
297
|
+
kept.set(key, value);
|
|
63
298
|
return value;
|
|
64
299
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Creates a cache of cel-js environments, check results, and parse results, keyed by descriptor
|
|
302
|
+
* in a `WeakMap` (#464). Doesn't cache a build or parse that throws, and keeps the
|
|
303
|
+
* {@link KEPT_EXPRESSIONS} newest entries per cache. A cached parse result retains the last
|
|
304
|
+
* evaluated context until the next evaluation.
|
|
305
|
+
*/
|
|
306
|
+
const celRuntimes = () => {
|
|
307
|
+
const runtimes = new WeakMap();
|
|
308
|
+
const runtimeOf = (descriptor) => {
|
|
309
|
+
const existing = runtimes.get(descriptor);
|
|
310
|
+
if (existing !== undefined)
|
|
311
|
+
return existing;
|
|
312
|
+
const runtime = {
|
|
313
|
+
normalize: contextNormalizer(descriptor),
|
|
314
|
+
check: Option.none(),
|
|
315
|
+
evaluate: Option.none(),
|
|
316
|
+
checked: new Map(),
|
|
317
|
+
parsed: new Map(),
|
|
318
|
+
};
|
|
319
|
+
runtimes.set(descriptor, runtime);
|
|
320
|
+
return runtime;
|
|
321
|
+
};
|
|
322
|
+
const environmentOf = (runtime, descriptor, purpose) => Option.getOrElse(runtime[purpose], () => {
|
|
323
|
+
const environment = makeEnvironment(descriptor, purpose);
|
|
324
|
+
runtime[purpose] = Option.some(environment);
|
|
325
|
+
return environment;
|
|
326
|
+
});
|
|
327
|
+
return {
|
|
328
|
+
check: (descriptor, source) => {
|
|
329
|
+
const runtime = runtimeOf(descriptor);
|
|
330
|
+
return (runtime.checked.get(source) ??
|
|
331
|
+
keep(runtime.checked, source, environmentOf(runtime, descriptor, "check").check(source)));
|
|
332
|
+
},
|
|
333
|
+
evaluate: (descriptor, source, context) => {
|
|
334
|
+
const runtime = runtimeOf(descriptor);
|
|
335
|
+
const parsed = runtime.parsed.get(source) ??
|
|
336
|
+
keep(runtime.parsed, source, environmentOf(runtime, descriptor, "evaluate").parse(source));
|
|
337
|
+
// SAFETY: CEL returns values of the context's types, and callers decode the result type.
|
|
338
|
+
return parsed(runtime.normalize(context));
|
|
339
|
+
},
|
|
340
|
+
};
|
|
74
341
|
};
|
|
75
|
-
const checkExpected = (source, environment, accepts, expected) => Effect.gen(function* () {
|
|
342
|
+
const checkExpected = (runtimes, source, environment, accepts, expected) => Effect.gen(function* () {
|
|
76
343
|
const result = yield* Effect.try({
|
|
77
|
-
try: () =>
|
|
344
|
+
try: () => runtimes.check(environment, source),
|
|
78
345
|
catch: (cause) => new ExpressionCheckError({
|
|
79
346
|
source,
|
|
80
347
|
code: "check_failed",
|
|
@@ -94,12 +361,8 @@ const checkExpected = (source, environment, accepts, expected) => Effect.gen(fun
|
|
|
94
361
|
});
|
|
95
362
|
}
|
|
96
363
|
});
|
|
97
|
-
const
|
|
98
|
-
try: () =>
|
|
99
|
-
// SAFETY: CEL evaluation yields the same value vocabulary the context is
|
|
100
|
-
// built from; the callers below still decode the expected result type
|
|
101
|
-
// before anything leaves the seam.
|
|
102
|
-
makeEnvironment(environment).evaluate(source, normalizeContext(context, environment)),
|
|
364
|
+
const evaluated = (runtimes, source, environment, context) => Result.try({
|
|
365
|
+
try: () => runtimes.evaluate(environment, source, context),
|
|
103
366
|
catch: (cause) => new ExpressionEvaluationError({
|
|
104
367
|
source,
|
|
105
368
|
message: messageFromCause(cause, "CEL evaluation failed"),
|
|
@@ -109,25 +372,55 @@ const unexpectedResult = (source, expected) => () => new ExpressionEvaluationErr
|
|
|
109
372
|
source,
|
|
110
373
|
message: `CEL evaluation returned a value that is not ${expected}`,
|
|
111
374
|
});
|
|
112
|
-
const
|
|
113
|
-
const checkScalar = Effect.fn("ExpressionEngine.checkScalar")((source, environment) => checkExpected(source, environment, (resultType) => acceptedScalarTypes.has(resultType), "a scalar value"));
|
|
114
|
-
const decodeBoolean = Schema.decodeUnknownEffect(Schema.Boolean);
|
|
375
|
+
const isBooleanType = (resultType) => resultType === "bool";
|
|
115
376
|
const decodeScalar = Schema.decodeUnknownEffect(Scalar);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
377
|
+
const makeExpressionEngine = () => {
|
|
378
|
+
const runtimes = celRuntimes();
|
|
379
|
+
const checkBoolean = Effect.fn("ExpressionEngine.checkBoolean")((source, environment) => checkExpected(runtimes, source, environment, isBooleanType, "bool"));
|
|
380
|
+
const checkScalar = Effect.fn("ExpressionEngine.checkScalar")((source, environment) => checkExpected(runtimes, source, environment, (resultType) => acceptedScalarTypes.has(resultType), "a scalar value"));
|
|
381
|
+
/** Evaluates an already checked condition on `context`. Fails if the result isn't a boolean. */
|
|
382
|
+
const booleanOn = (source, environment, context) => Result.flatMap(evaluated(runtimes, source, environment, context), (value) => Predicate.isBoolean(value)
|
|
383
|
+
? Result.succeed(value)
|
|
384
|
+
: Result.fail(unexpectedResult(source, "a boolean")()));
|
|
385
|
+
const evaluateBoolean = Effect.fn("ExpressionEngine.evaluateBoolean")(function* (source, environment, context) {
|
|
386
|
+
yield* checkBoolean(source, environment);
|
|
387
|
+
return yield* Effect.fromResult(booleanOn(source, environment, context));
|
|
388
|
+
});
|
|
389
|
+
// One span and one check for all contexts; per-context Effects cost several times more (#464).
|
|
390
|
+
const evaluateBooleanEach = Effect.fn("ExpressionEngine.evaluateBooleanEach")(function* (source, environment, contexts) {
|
|
391
|
+
yield* Effect.annotateCurrentSpan({ contexts: contexts.length });
|
|
392
|
+
yield* checkBoolean(source, environment);
|
|
393
|
+
return contexts.map((context) => booleanOn(source, environment, context));
|
|
394
|
+
});
|
|
395
|
+
const evaluateScalar = Effect.fn("ExpressionEngine.evaluateScalar")(function* (source, environment, context) {
|
|
396
|
+
yield* checkScalar(source, environment);
|
|
397
|
+
const value = yield* Effect.fromResult(evaluated(runtimes, source, environment, context));
|
|
398
|
+
return yield* decodeScalar(value).pipe(Effect.mapError(unexpectedResult(source, "a scalar value")));
|
|
399
|
+
});
|
|
400
|
+
return ExpressionEngine.of({
|
|
401
|
+
relatedStringLiterals,
|
|
402
|
+
checkBoolean,
|
|
403
|
+
checkScalar,
|
|
404
|
+
evaluateBoolean,
|
|
405
|
+
evaluateBooleanEach,
|
|
406
|
+
evaluateScalar,
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* Provides {@link ExpressionEngine} with `@marcbachmann/cel-js` 8.0.0
|
|
411
|
+
* ([ADR 0004](../../../docs/adr/0004-loop-files-markdown-cel-frontmatter.md)).
|
|
412
|
+
*
|
|
413
|
+
* Expressions can use CEL optional values, such as `item.?milestone.?title.orValue("none")`. A
|
|
414
|
+
* nullable field that holds `null` counts as present, so `item.?milestone` holds `null` and
|
|
415
|
+
* `item.?milestone.?title` is empty.
|
|
416
|
+
*
|
|
417
|
+
* Before evaluation, converts JSON integers to `bigint` wherever the {@link Environment}
|
|
418
|
+
* declares `int`, at any depth, and sets absent nullable fields to `null`. Values inside a
|
|
419
|
+
* `map<K,V>` aren't converted, so declare integer map values as `double`.
|
|
420
|
+
*
|
|
421
|
+
* `uint` isn't supported in `context`; declare such values as `int`. An expression that reads a
|
|
422
|
+
* non-nullable `uint` value type-checks but fails evaluation. On a nullable field, comparing with a
|
|
423
|
+
* `uint` literal works but `uint` arithmetic fails. A `uint` result fails `evaluateScalar`.
|
|
424
|
+
*/
|
|
425
|
+
export const MarcbachmannCelLayer = Layer.sync(ExpressionEngine)(makeExpressionEngine);
|
|
133
426
|
//# sourceMappingURL=marcbachmann-cel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marcbachmann-cel.js","sourceRoot":"","sources":["../src/marcbachmann-cel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,IAAI,cAAc,EAC7B,UAAU,IAAI,aAAa,EAC3B,SAAS,IAAI,YAAY,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAEL,oBAAoB,EACpB,yBAAyB,EAEzB,MAAM,EAEN,aAAa,GACd,MA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AC,IAAI,CACpC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAC5D,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC,EAAE,CAAC;QACzB,qBAAqB;QACrB,YAAY;QACZ,WAAW;QACX,eAAe;QACf,mBAAmB;QACnB,cAAc;KACf,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usine/expression",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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": {
|
|
@@ -9,14 +9,19 @@
|
|
|
9
9
|
"directory": "packages/expression"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
13
14
|
],
|
|
14
15
|
"type": "module",
|
|
15
16
|
"sideEffects": false,
|
|
16
17
|
"exports": {
|
|
17
|
-
"
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"default": "./dist/
|
|
18
|
+
"./expression-engine": {
|
|
19
|
+
"types": "./dist/expression-engine.d.ts",
|
|
20
|
+
"default": "./dist/expression-engine.js"
|
|
21
|
+
},
|
|
22
|
+
"./marcbachmann-cel": {
|
|
23
|
+
"types": "./dist/marcbachmann-cel.d.ts",
|
|
24
|
+
"default": "./dist/marcbachmann-cel.js"
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
"publishConfig": {
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @usine/expression — a vendor-neutral CEL check/evaluation seam. The live
|
|
3
|
-
* layer exact-pins @marcbachmann/cel-js; callers depend only on CEL types and
|
|
4
|
-
* typed Effect failures, so another backend can implement the service.
|
|
5
|
-
*/
|
|
6
|
-
export * from "./expression-engine.ts";
|
|
7
|
-
export * from "./marcbachmann-cel.ts";
|
|
8
|
-
export * from "./model.ts";
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @usine/expression — a vendor-neutral CEL check/evaluation seam. The live
|
|
3
|
-
* layer exact-pins @marcbachmann/cel-js; callers depend only on CEL types and
|
|
4
|
-
* typed Effect failures, so another backend can implement the service.
|
|
5
|
-
*/
|
|
6
|
-
export * from "./expression-engine.js";
|
|
7
|
-
export * from "./marcbachmann-cel.js";
|
|
8
|
-
export * from "./model.js";
|
|
9
|
-
//# 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;;;;GAIG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC"}
|
package/dist/model.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
/** CEL source accepted at the config boundary. */
|
|
3
|
-
export declare const Source: Schema.brand<Schema.String, "ExpressionSource">;
|
|
4
|
-
export type Source = typeof Source.Type;
|
|
5
|
-
/** A CEL-spec type reference such as `string`, `Issue`, or `list<Label>`. */
|
|
6
|
-
export declare const TypeReference: Schema.brand<Schema.String, "CelTypeReference">;
|
|
7
|
-
export type TypeReference = typeof TypeReference.Type;
|
|
8
|
-
declare const ObjectField_base: Schema.Class<ObjectField, Schema.Struct<{
|
|
9
|
-
readonly name: Schema.String;
|
|
10
|
-
readonly type: Schema.brand<Schema.String, "CelTypeReference">;
|
|
11
|
-
}>, {}>;
|
|
12
|
-
/** One field in a backend-neutral CEL object-type declaration. */
|
|
13
|
-
export declare class ObjectField extends ObjectField_base {
|
|
14
|
-
}
|
|
15
|
-
declare const ObjectType_base: Schema.Class<ObjectType, Schema.Struct<{
|
|
16
|
-
readonly name: Schema.String;
|
|
17
|
-
readonly fields: Schema.$Array<typeof ObjectField>;
|
|
18
|
-
}>, {}>;
|
|
19
|
-
/** A CEL object type. Types are registered in declaration order. */
|
|
20
|
-
export declare class ObjectType extends ObjectType_base {
|
|
21
|
-
}
|
|
22
|
-
declare const Variable_base: Schema.Class<Variable, Schema.Struct<{
|
|
23
|
-
readonly name: Schema.String;
|
|
24
|
-
readonly type: Schema.brand<Schema.String, "CelTypeReference">;
|
|
25
|
-
}>, {}>;
|
|
26
|
-
/** One root variable available to a CEL expression. */
|
|
27
|
-
export declare class Variable extends Variable_base {
|
|
28
|
-
}
|
|
29
|
-
declare const Environment_base: Schema.Class<Environment, Schema.Struct<{
|
|
30
|
-
readonly types: Schema.$Array<typeof ObjectType>;
|
|
31
|
-
readonly variables: Schema.$Array<typeof Variable>;
|
|
32
|
-
}>, {}>;
|
|
33
|
-
/** The checked namespace for one expression family, expressed in CEL's type vocabulary. */
|
|
34
|
-
export declare class Environment extends Environment_base {
|
|
35
|
-
}
|
|
36
|
-
export declare const CheckErrorCode: Schema.Literals<readonly ["check_failed", "parse_error", "type_error", "unexpected_result_type"]>;
|
|
37
|
-
export type CheckErrorCode = typeof CheckErrorCode.Type;
|
|
38
|
-
declare const ExpressionCheckError_base: Schema.Class<ExpressionCheckError, Schema.TaggedStruct<"ExpressionCheckError", {
|
|
39
|
-
readonly source: Schema.brand<Schema.String, "ExpressionSource">;
|
|
40
|
-
readonly code: Schema.Literals<readonly ["check_failed", "parse_error", "type_error", "unexpected_result_type"]>;
|
|
41
|
-
readonly message: Schema.NonEmptyString;
|
|
42
|
-
readonly position: Schema.Option<Schema.Int>;
|
|
43
|
-
}>, import("effect/Cause").YieldableError>;
|
|
44
|
-
/** Typed failure from CEL parsing, type checking, or expected-result checking. */
|
|
45
|
-
export declare class ExpressionCheckError extends ExpressionCheckError_base {
|
|
46
|
-
}
|
|
47
|
-
declare const ExpressionEvaluationError_base: Schema.Class<ExpressionEvaluationError, Schema.TaggedStruct<"ExpressionEvaluationError", {
|
|
48
|
-
readonly source: Schema.brand<Schema.String, "ExpressionSource">;
|
|
49
|
-
readonly message: Schema.NonEmptyString;
|
|
50
|
-
}>, import("effect/Cause").YieldableError>;
|
|
51
|
-
/** Typed failure from evaluating an expression that previously checked. */
|
|
52
|
-
export declare class ExpressionEvaluationError extends ExpressionEvaluationError_base {
|
|
53
|
-
}
|
|
54
|
-
/** Every failure mode this package's service can produce. */
|
|
55
|
-
export declare const ExpressionError: Schema.Union<readonly [typeof ExpressionCheckError, typeof ExpressionEvaluationError]>;
|
|
56
|
-
export type ExpressionError = typeof ExpressionError.Type;
|
|
57
|
-
/** Values admitted by prompt interpolation. CEL ints deliberately remain bigint here. */
|
|
58
|
-
export declare const Scalar: Schema.Union<readonly [Schema.String, Schema.Number, Schema.BigInt, Schema.Boolean, Schema.Null]>;
|
|
59
|
-
export type Scalar = typeof Scalar.Type;
|
|
60
|
-
export {};
|
|
61
|
-
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,kDAAkD;AAClD,eAAO,MAAM,MAAM,iDAEqB,CAAC;AACzC,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;AAExC,6EAA6E;AAC7E,eAAO,MAAM,aAAa,iDAKc,CAAC;AACzC,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;;;;;AAkBtD,kEAAkE;AAClE,qBAAa,WAAY,SAAQ,gBAG/B;CAAG;;;;;AAEL,oEAAoE;AACpE,qBAAa,UAAW,SAAQ,eAG9B;CAAG;;;;;AAEL,uDAAuD;AACvD,qBAAa,QAAS,SAAQ,aAG5B;CAAG;;;;;AAEL,2FAA2F;AAC3F,qBAAa,WAAY,SAAQ,gBAG/B;CAAG;AAIL,eAAO,MAAM,cAAc,mGAKzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;;;;;;;AAExD,kFAAkF;AAClF,qBAAa,oBAAqB,SAAQ,yBAOxC;CAAG;;;;;AAEL,2EAA2E;AAC3E,qBAAa,yBAA0B,SAAQ,8BAK7C;CAAG;AAEL,6DAA6D;AAC7D,eAAO,MAAM,eAAe,wFAAkE,CAAC;AAC/F,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAE1D,yFAAyF;AACzF,eAAO,MAAM,MAAM,mGAMjB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC"}
|
package/dist/model.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
/** CEL source accepted at the config boundary. */
|
|
3
|
-
export const Source = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank CEL expression" })).pipe(Schema.brand("ExpressionSource"));
|
|
4
|
-
/** A CEL-spec type reference such as `string`, `Issue`, or `list<Label>`. */
|
|
5
|
-
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"));
|
|
6
|
-
const Identifier = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_]*$/u, { message: "Expected a CEL identifier" }));
|
|
7
|
-
const ObjectTypeName = Schema.String.check(Schema.isPattern(/^[A-Za-z_][A-Za-z0-9_.]*$/u, {
|
|
8
|
-
message: "Expected a CEL object-type name",
|
|
9
|
-
}));
|
|
10
|
-
const uniqueNames = (message) => Schema.makeFilter((values) => new Set(values.map(({ name }) => name)).size === values.length, { message });
|
|
11
|
-
/** One field in a backend-neutral CEL object-type declaration. */
|
|
12
|
-
export class ObjectField extends Schema.Class("@usine/expression/ObjectField")({
|
|
13
|
-
name: Identifier,
|
|
14
|
-
type: TypeReference,
|
|
15
|
-
}) {
|
|
16
|
-
}
|
|
17
|
-
/** A CEL object type. Types are registered in declaration order. */
|
|
18
|
-
export class ObjectType extends Schema.Class("@usine/expression/ObjectType")({
|
|
19
|
-
name: ObjectTypeName,
|
|
20
|
-
fields: Schema.Array(ObjectField).check(uniqueNames("Expected unique CEL object-field names")),
|
|
21
|
-
}) {
|
|
22
|
-
}
|
|
23
|
-
/** One root variable available to a CEL expression. */
|
|
24
|
-
export class Variable extends Schema.Class("@usine/expression/Variable")({
|
|
25
|
-
name: Identifier,
|
|
26
|
-
type: TypeReference,
|
|
27
|
-
}) {
|
|
28
|
-
}
|
|
29
|
-
/** The checked namespace for one expression family, expressed in CEL's type vocabulary. */
|
|
30
|
-
export class Environment extends Schema.Class("@usine/expression/Environment")({
|
|
31
|
-
types: Schema.Array(ObjectType).check(uniqueNames("Expected unique CEL object-type names")),
|
|
32
|
-
variables: Schema.Array(Variable).check(uniqueNames("Expected unique CEL variable names")),
|
|
33
|
-
}) {
|
|
34
|
-
}
|
|
35
|
-
const Position = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
36
|
-
export const CheckErrorCode = Schema.Literals([
|
|
37
|
-
"check_failed",
|
|
38
|
-
"parse_error",
|
|
39
|
-
"type_error",
|
|
40
|
-
"unexpected_result_type",
|
|
41
|
-
]);
|
|
42
|
-
/** Typed failure from CEL parsing, type checking, or expected-result checking. */
|
|
43
|
-
export class ExpressionCheckError extends Schema.TaggedError("@usine/expression/ExpressionCheckError")("ExpressionCheckError", {
|
|
44
|
-
source: Source,
|
|
45
|
-
code: CheckErrorCode,
|
|
46
|
-
message: Schema.NonEmptyString,
|
|
47
|
-
position: Schema.Option(Position),
|
|
48
|
-
}) {
|
|
49
|
-
}
|
|
50
|
-
/** Typed failure from evaluating an expression that previously checked. */
|
|
51
|
-
export class ExpressionEvaluationError extends Schema.TaggedError("@usine/expression/ExpressionEvaluationError")("ExpressionEvaluationError", {
|
|
52
|
-
source: Source,
|
|
53
|
-
message: Schema.NonEmptyString,
|
|
54
|
-
}) {
|
|
55
|
-
}
|
|
56
|
-
/** Every failure mode this package's service can produce. */
|
|
57
|
-
export const ExpressionError = Schema.Union([ExpressionCheckError, ExpressionEvaluationError]);
|
|
58
|
-
/** Values admitted by prompt interpolation. CEL ints deliberately remain bigint here. */
|
|
59
|
-
export const Scalar = Schema.Union([
|
|
60
|
-
Schema.String,
|
|
61
|
-
Schema.Number,
|
|
62
|
-
Schema.BigInt,
|
|
63
|
-
Schema.Boolean,
|
|
64
|
-
Schema.Null,
|
|
65
|
-
]);
|
|
66
|
-
//# sourceMappingURL=model.js.map
|
package/dist/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,kDAAkD;AAClD,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,K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