@telorun/templating 0.107.0 → 0.108.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/dist/builtins.d.ts +2 -2
- package/dist/builtins.d.ts.map +1 -1
- package/dist/cel/analyze.d.ts +6 -6
- package/dist/cel/analyze.d.ts.map +1 -1
- package/dist/cel/analyze.js +138 -183
- package/dist/cel/compile.d.ts +47 -17
- package/dist/cel/compile.d.ts.map +1 -1
- package/dist/cel/compile.js +135 -83
- package/dist/cel/diagnose.d.ts +52 -57
- package/dist/cel/diagnose.d.ts.map +1 -1
- package/dist/cel/diagnose.js +69 -291
- package/dist/cel/environment.d.ts +33 -37
- package/dist/cel/environment.d.ts.map +1 -1
- package/dist/cel/environment.js +54 -86
- package/dist/cel/module-call.d.ts +68 -79
- package/dist/cel/module-call.d.ts.map +1 -1
- package/dist/cel/module-call.js +118 -194
- package/dist/cel/value-brands.d.ts +14 -12
- package/dist/cel/value-brands.d.ts.map +1 -1
- package/dist/cel/value-brands.js +26 -24
- package/dist/cel/verdict-codes.d.ts +13 -2
- package/dist/cel/verdict-codes.d.ts.map +1 -1
- package/dist/cel/verdict-codes.js +20 -1
- package/dist/engine.d.ts +4 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engines/cel.d.ts +2 -2
- package/dist/engines/cel.d.ts.map +1 -1
- package/dist/engines/cel.js +53 -81
- package/dist/engines/hole-analysis.d.ts +3 -3
- package/dist/engines/hole-analysis.d.ts.map +1 -1
- package/dist/engines/interpolate.js +11 -8
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/package.json +4 -4
- package/src/builtins.ts +2 -2
- package/src/cel/analyze.ts +152 -193
- package/src/cel/compile.ts +160 -77
- package/src/cel/diagnose.ts +115 -370
- package/src/cel/environment.ts +64 -87
- package/src/cel/module-call.ts +129 -292
- package/src/cel/value-brands.ts +26 -25
- package/src/cel/verdict-codes.ts +20 -1
- package/src/engine.ts +4 -4
- package/src/engines/cel.ts +52 -84
- package/src/engines/hole-analysis.ts +3 -3
- package/src/engines/interpolate.ts +16 -13
- package/src/index.ts +8 -11
- package/dist/cel/catalog.d.ts +0 -70
- package/dist/cel/catalog.d.ts.map +0 -1
- package/dist/cel/catalog.js +0 -1320
- package/dist/cel/json-prefix-scan.d.ts +0 -17
- package/dist/cel/json-prefix-scan.d.ts.map +0 -1
- package/dist/cel/json-prefix-scan.js +0 -160
- package/dist/cel/value-identity.d.ts +0 -18
- package/dist/cel/value-identity.d.ts.map +0 -1
- package/dist/cel/value-identity.js +0 -25
- package/src/cel/catalog.ts +0 -1455
- package/src/cel/json-prefix-scan.ts +0 -152
- package/src/cel/value-identity.ts +0 -34
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where a text stops being a prefix of any RFC 8259 JSON text — the offset
|
|
3
|
-
* `parseJson`'s refusal names, computed here so the wording never comes from the
|
|
4
|
-
* host's JSON parser.
|
|
5
|
-
*/
|
|
6
|
-
export interface JsonRefusal {
|
|
7
|
-
/** UTF-16 offset of the first offending code unit; the text's length when
|
|
8
|
-
* every prefix is viable and the text is merely incomplete. */
|
|
9
|
-
readonly offset: number;
|
|
10
|
-
readonly endOfInput: boolean;
|
|
11
|
-
}
|
|
12
|
-
/** The refusal of `text`, or `undefined` when it is a JSON text. Iterative, so
|
|
13
|
-
* nesting depth is bounded by memory rather than by the call stack. Never
|
|
14
|
-
* stricter or laxer than RFC 8259: over 400,000 fuzzed texts it agreed with
|
|
15
|
-
* V8's `JSON.parse` on which are JSON every time. */
|
|
16
|
-
export declare function scanJsonPrefix(text: string): JsonRefusal | undefined;
|
|
17
|
-
//# sourceMappingURL=json-prefix-scan.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json-prefix-scan.d.ts","sourceRoot":"","sources":["../../src/cel/json-prefix-scan.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;oEACgE;IAChE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAYD;;;sDAGsD;AACtD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CA6HpE"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
const QUOTE = 0x22;
|
|
2
|
-
const BACKSLASH = 0x5c;
|
|
3
|
-
const SIMPLE_ESCAPES = '"\\/bfnrt';
|
|
4
|
-
const isWhitespace = (c) => c === " " || c === "\t" || c === "\n" || c === "\r";
|
|
5
|
-
const isDigit = (c) => c !== undefined && c >= "0" && c <= "9";
|
|
6
|
-
const isHexDigit = (c) => isDigit(c) || (c >= "a" && c <= "f") || (c >= "A" && c <= "F");
|
|
7
|
-
/** The refusal of `text`, or `undefined` when it is a JSON text. Iterative, so
|
|
8
|
-
* nesting depth is bounded by memory rather than by the call stack. Never
|
|
9
|
-
* stricter or laxer than RFC 8259: over 400,000 fuzzed texts it agreed with
|
|
10
|
-
* V8's `JSON.parse` on which are JSON every time. */
|
|
11
|
-
export function scanJsonPrefix(text) {
|
|
12
|
-
const length = text.length;
|
|
13
|
-
let at = 0;
|
|
14
|
-
// Each token reader returns the offset it refuses, or `undefined` once `at`
|
|
15
|
-
// is past the token.
|
|
16
|
-
const readString = () => {
|
|
17
|
-
at++;
|
|
18
|
-
for (;;) {
|
|
19
|
-
if (at >= length)
|
|
20
|
-
return length;
|
|
21
|
-
const code = text.charCodeAt(at);
|
|
22
|
-
if (code === QUOTE) {
|
|
23
|
-
at++;
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
if (code < 0x20)
|
|
27
|
-
return at;
|
|
28
|
-
at++;
|
|
29
|
-
if (code !== BACKSLASH)
|
|
30
|
-
continue;
|
|
31
|
-
if (at >= length)
|
|
32
|
-
return length;
|
|
33
|
-
const escape = text[at];
|
|
34
|
-
if (escape === "u") {
|
|
35
|
-
at++;
|
|
36
|
-
for (let digit = 0; digit < 4; digit++, at++) {
|
|
37
|
-
if (at >= length)
|
|
38
|
-
return length;
|
|
39
|
-
if (!isHexDigit(text[at]))
|
|
40
|
-
return at;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if (SIMPLE_ESCAPES.includes(escape))
|
|
44
|
-
at++;
|
|
45
|
-
else
|
|
46
|
-
return at;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const readDigits = () => {
|
|
50
|
-
if (!isDigit(text[at]))
|
|
51
|
-
return at;
|
|
52
|
-
while (isDigit(text[at]))
|
|
53
|
-
at++;
|
|
54
|
-
return undefined;
|
|
55
|
-
};
|
|
56
|
-
const readNumber = () => {
|
|
57
|
-
if (text[at] === "-")
|
|
58
|
-
at++;
|
|
59
|
-
if (text[at] === "0")
|
|
60
|
-
at++;
|
|
61
|
-
else {
|
|
62
|
-
const refused = readDigits();
|
|
63
|
-
if (refused !== undefined)
|
|
64
|
-
return refused;
|
|
65
|
-
}
|
|
66
|
-
if (text[at] === ".") {
|
|
67
|
-
at++;
|
|
68
|
-
const refused = readDigits();
|
|
69
|
-
if (refused !== undefined)
|
|
70
|
-
return refused;
|
|
71
|
-
}
|
|
72
|
-
if (text[at] === "e" || text[at] === "E") {
|
|
73
|
-
at++;
|
|
74
|
-
if (text[at] === "+" || text[at] === "-")
|
|
75
|
-
at++;
|
|
76
|
-
return readDigits();
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
79
|
-
};
|
|
80
|
-
const readLiteral = (literal) => {
|
|
81
|
-
for (const expected of literal) {
|
|
82
|
-
if (text[at] !== expected)
|
|
83
|
-
return at;
|
|
84
|
-
at++;
|
|
85
|
-
}
|
|
86
|
-
return undefined;
|
|
87
|
-
};
|
|
88
|
-
const refusedAt = (offset) => ({ offset, endOfInput: offset >= length });
|
|
89
|
-
const open = [];
|
|
90
|
-
let state = "value";
|
|
91
|
-
for (;;) {
|
|
92
|
-
while (isWhitespace(text[at]))
|
|
93
|
-
at++;
|
|
94
|
-
const c = text[at];
|
|
95
|
-
if (state === "after") {
|
|
96
|
-
const container = open[open.length - 1];
|
|
97
|
-
if (container === undefined)
|
|
98
|
-
return at === length ? undefined : refusedAt(at);
|
|
99
|
-
if (c === ",") {
|
|
100
|
-
at++;
|
|
101
|
-
state = container === "{" ? "key" : "value";
|
|
102
|
-
}
|
|
103
|
-
else if (c === (container === "{" ? "}" : "]")) {
|
|
104
|
-
at++;
|
|
105
|
-
open.pop();
|
|
106
|
-
}
|
|
107
|
-
else
|
|
108
|
-
return refusedAt(at);
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (state === "key" || state === "keyOrClose") {
|
|
112
|
-
if (state === "keyOrClose" && c === "}") {
|
|
113
|
-
at++;
|
|
114
|
-
open.pop();
|
|
115
|
-
state = "after";
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (c !== '"')
|
|
119
|
-
return refusedAt(at);
|
|
120
|
-
const refused = readString();
|
|
121
|
-
if (refused !== undefined)
|
|
122
|
-
return refusedAt(refused);
|
|
123
|
-
while (isWhitespace(text[at]))
|
|
124
|
-
at++;
|
|
125
|
-
if (text[at] !== ":")
|
|
126
|
-
return refusedAt(at);
|
|
127
|
-
at++;
|
|
128
|
-
state = "value";
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (state === "valueOrClose" && c === "]") {
|
|
132
|
-
at++;
|
|
133
|
-
open.pop();
|
|
134
|
-
state = "after";
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
if (c === "{" || c === "[") {
|
|
138
|
-
at++;
|
|
139
|
-
open.push(c);
|
|
140
|
-
state = c === "{" ? "keyOrClose" : "valueOrClose";
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
let refused;
|
|
144
|
-
if (c === '"')
|
|
145
|
-
refused = readString();
|
|
146
|
-
else if (c === "-" || isDigit(c))
|
|
147
|
-
refused = readNumber();
|
|
148
|
-
else if (c === "t")
|
|
149
|
-
refused = readLiteral("true");
|
|
150
|
-
else if (c === "f")
|
|
151
|
-
refused = readLiteral("false");
|
|
152
|
-
else if (c === "n")
|
|
153
|
-
refused = readLiteral("null");
|
|
154
|
-
else
|
|
155
|
-
refused = at;
|
|
156
|
-
if (refused !== undefined)
|
|
157
|
-
return refusedAt(refused);
|
|
158
|
-
state = "after";
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** The classes the CEL value domain is typed by. */
|
|
2
|
-
export interface CelValueClasses {
|
|
3
|
-
readonly Duration: abstract new (...args: never[]) => unknown;
|
|
4
|
-
readonly UnsignedInt: abstract new (...args: never[]) => unknown;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Refuse to run with a CEL engine whose values are not the SDK's.
|
|
8
|
-
*
|
|
9
|
-
* cel-js dispatches by constructor, so a second installed copy of it gives the
|
|
10
|
-
* engine a `Duration` / `UnsignedInt` no controller can construct: every value a
|
|
11
|
-
* controller builds from `@telorun/sdk` would fail `+`, `type()` and every
|
|
12
|
-
* overload, at the first expression that meets one. Checked once, where the
|
|
13
|
-
* engine is loaded, so the cause is named before anything evaluates.
|
|
14
|
-
*/
|
|
15
|
-
export declare function assertCelValueIdentity(classes: CelValueClasses): void;
|
|
16
|
-
/** The SDK's classes — the identity every Telo package and controller shares. */
|
|
17
|
-
export declare const SDK_CEL_VALUE_CLASSES: CelValueClasses;
|
|
18
|
-
//# sourceMappingURL=value-identity.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"value-identity.d.ts","sourceRoot":"","sources":["../../src/cel/value-identity.ts"],"names":[],"mappings":"AAGA,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;IAC9D,QAAQ,CAAC,WAAW,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;CAClE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAYrE;AAED,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,EAAE,eAA2C,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Environment } from "@marcbachmann/cel-js";
|
|
2
|
-
import { Duration, UnsignedInt } from "@telorun/sdk";
|
|
3
|
-
/**
|
|
4
|
-
* Refuse to run with a CEL engine whose values are not the SDK's.
|
|
5
|
-
*
|
|
6
|
-
* cel-js dispatches by constructor, so a second installed copy of it gives the
|
|
7
|
-
* engine a `Duration` / `UnsignedInt` no controller can construct: every value a
|
|
8
|
-
* controller builds from `@telorun/sdk` would fail `+`, `type()` and every
|
|
9
|
-
* overload, at the first expression that meets one. Checked once, where the
|
|
10
|
-
* engine is loaded, so the cause is named before anything evaluates.
|
|
11
|
-
*/
|
|
12
|
-
export function assertCelValueIdentity(classes) {
|
|
13
|
-
const probe = new Environment();
|
|
14
|
-
const duration = probe.evaluate("duration('1s')");
|
|
15
|
-
const uint = probe.evaluate("1u");
|
|
16
|
-
if (duration instanceof classes.Duration && uint instanceof classes.UnsignedInt)
|
|
17
|
-
return;
|
|
18
|
-
throw new Error("@telorun/templating's CEL engine is a different copy of @marcbachmann/cel-js than the one " +
|
|
19
|
-
"@telorun/sdk exports Duration and UnsignedInt from, so a duration or uint a controller " +
|
|
20
|
-
"builds would be rejected by every CEL expression. Two copies of @marcbachmann/cel-js are " +
|
|
21
|
-
"installed: every Telo package pins the same exact version, so deduplicate the install " +
|
|
22
|
-
"(`pnpm dedupe` / `npm dedupe`) until one remains.");
|
|
23
|
-
}
|
|
24
|
-
/** The SDK's classes — the identity every Telo package and controller shares. */
|
|
25
|
-
export const SDK_CEL_VALUE_CLASSES = { Duration, UnsignedInt };
|