@telorun/templating 0.23.0 → 0.25.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 +1 -1
- package/dist/builtins.d.ts +8 -0
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +13 -0
- package/dist/cel/analyze.d.ts +4 -0
- package/dist/cel/analyze.d.ts.map +1 -1
- package/dist/cel/analyze.js +9 -0
- package/dist/cel/catalog.d.ts.map +1 -1
- package/dist/cel/catalog.js +12 -4
- package/dist/cel/compile.d.ts +4 -26
- package/dist/cel/compile.d.ts.map +1 -1
- package/dist/cel/compile.js +3 -88
- package/dist/cel/interpolation-holes.d.ts +43 -0
- package/dist/cel/interpolation-holes.d.ts.map +1 -0
- package/dist/cel/interpolation-holes.js +121 -0
- package/dist/cel/walk.d.ts +7 -28
- package/dist/cel/walk.d.ts.map +1 -1
- package/dist/cel/walk.js +7 -39
- package/dist/engine.d.ts +30 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engines/cel.d.ts +7 -0
- package/dist/engines/cel.d.ts.map +1 -1
- package/dist/engines/cel.js +78 -14
- package/dist/engines/hole-analysis.d.ts +23 -0
- package/dist/engines/hole-analysis.d.ts.map +1 -0
- package/dist/engines/hole-analysis.js +66 -0
- package/dist/engines/interpolate.d.ts +13 -0
- package/dist/engines/interpolate.d.ts.map +1 -0
- package/dist/engines/interpolate.js +123 -0
- package/dist/engines/sql.d.ts +3 -3
- package/dist/engines/sql.d.ts.map +1 -1
- package/dist/engines/sql.js +24 -58
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/sentinel.d.ts +4 -5
- package/dist/sentinel.d.ts.map +1 -1
- package/dist/sentinel.js +6 -14
- package/package.json +2 -2
- package/src/builtins.ts +14 -0
- package/src/cel/analyze.ts +12 -0
- package/src/cel/catalog.ts +14 -4
- package/src/cel/compile.ts +4 -92
- package/src/cel/interpolation-holes.ts +138 -0
- package/src/cel/walk.ts +8 -54
- package/src/engine.ts +33 -0
- package/src/engines/cel.ts +85 -16
- package/src/engines/hole-analysis.ts +96 -0
- package/src/engines/interpolate.ts +139 -0
- package/src/engines/sql.ts +26 -67
- package/src/index.ts +12 -7
- package/src/sentinel.ts +6 -14
package/dist/engines/cel.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ASTNode } from "@marcbachmann/cel-js";
|
|
1
2
|
import type { AnalyzeEnv, AnalyzeResult, TemplatingEngine } from "../engine.js";
|
|
2
3
|
/** Statically analyze one CEL expression against the effective context schema:
|
|
3
4
|
* parse → classify every call → type-check → validate member-access chains →
|
|
@@ -11,6 +12,12 @@ import type { AnalyzeEnv, AnalyzeResult, TemplatingEngine } from "../engine.js";
|
|
|
11
12
|
* explained it, and left `${{ }}` interpolations chain-validated but never
|
|
12
13
|
* type-checked at all. */
|
|
13
14
|
export declare function analyzeCelExpression(source: string, env: AnalyzeEnv): AnalyzeResult;
|
|
15
|
+
/** {@link analyzeCelExpression}, with the resolved tree it built — for a tag
|
|
16
|
+
* that asks its own questions of one expression without parsing it again. */
|
|
17
|
+
export declare function analyzeCelWithTree(source: string, env: AnalyzeEnv): {
|
|
18
|
+
result: AnalyzeResult;
|
|
19
|
+
ast?: ASTNode;
|
|
20
|
+
};
|
|
14
21
|
/** The `!cel` engine. Treats the entire tagged scalar as a single CEL
|
|
15
22
|
* expression — no `${{ }}` wrapping. */
|
|
16
23
|
export declare const celEngine: TemplatingEngine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cel.d.ts","sourceRoot":"","sources":["../../src/engines/cel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cel.d.ts","sourceRoot":"","sources":["../../src/engines/cel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAkBpD,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EAGb,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;2BAU2B;AAC3B,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,aAAa,CAEnF;AAED;8EAC8E;AAC9E,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,UAAU,GACd;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,CAoL1C;AA4ED;yCACyC;AACzC,eAAO,MAAM,SAAS,EAAE,gBAevB,CAAC"}
|
package/dist/engines/cel.js
CHANGED
|
@@ -14,6 +14,11 @@ import { moduleCallNodes, moduleNameBindings, resolveModuleCalls, unresolvedCall
|
|
|
14
14
|
* explained it, and left `${{ }}` interpolations chain-validated but never
|
|
15
15
|
* type-checked at all. */
|
|
16
16
|
export function analyzeCelExpression(source, env) {
|
|
17
|
+
return analyzeCelWithTree(source, env).result;
|
|
18
|
+
}
|
|
19
|
+
/** {@link analyzeCelExpression}, with the resolved tree it built — for a tag
|
|
20
|
+
* that asks its own questions of one expression without parsing it again. */
|
|
21
|
+
export function analyzeCelWithTree(source, env) {
|
|
17
22
|
const out = [];
|
|
18
23
|
let parsed;
|
|
19
24
|
try {
|
|
@@ -21,10 +26,13 @@ export function analyzeCelExpression(source, env) {
|
|
|
21
26
|
}
|
|
22
27
|
catch (e) {
|
|
23
28
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
result: {
|
|
30
|
+
diagnostics: [{ code: "CEL_SYNTAX_ERROR", message: e instanceof Error ? e.message : String(e) }],
|
|
31
|
+
calls: [],
|
|
32
|
+
},
|
|
26
33
|
};
|
|
27
34
|
}
|
|
35
|
+
const ast = parsed.ast;
|
|
28
36
|
// Resolution, before anything reads the tree — the audit, the type check and
|
|
29
37
|
// every chain walk below all see the resolved shape, so none of them has to
|
|
30
38
|
// know a module name from a variable.
|
|
@@ -68,13 +76,16 @@ export function analyzeCelExpression(source, env) {
|
|
|
68
76
|
// crash here silently retires static typing for that expression. Report it
|
|
69
77
|
// instead: degrading is acceptable, degrading invisibly is not.
|
|
70
78
|
return {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
result: {
|
|
80
|
+
diagnostics: [
|
|
81
|
+
{
|
|
82
|
+
code: "CEL_TYPE_ERROR",
|
|
83
|
+
message: `the CEL type-checker failed on this expression: ${e instanceof Error ? e.message : String(e)}`,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
calls: audit.calls,
|
|
87
|
+
},
|
|
88
|
+
ast,
|
|
78
89
|
};
|
|
79
90
|
}
|
|
80
91
|
// The audit only ever EXPLAINS a rejection — it never overrules acceptance.
|
|
@@ -84,11 +95,18 @@ export function analyzeCelExpression(source, env) {
|
|
|
84
95
|
// not become a hard error on valid CEL. Reporting nothing where cel-js is
|
|
85
96
|
// happy makes an unknown future macro a silent no-op rather than a manifest
|
|
86
97
|
// this analyzer refuses and the kernel would run fine.
|
|
98
|
+
// What explaining a rejection already reported, so the context's own chain
|
|
99
|
+
// check below does not report it twice.
|
|
100
|
+
const explained = new Set();
|
|
87
101
|
if (checkError !== undefined) {
|
|
88
102
|
// `check()` stops at its first problem; the audit enumerates every bad call,
|
|
89
103
|
// which is the whole reason it exists as more than a message rewriter.
|
|
90
104
|
out.push(...audit.diagnostics);
|
|
91
|
-
|
|
105
|
+
const unknownFields = audit.diagnostics.length === 0 ? explainUnknownFields(parsed.ast, env) : [];
|
|
106
|
+
out.push(...unknownFields);
|
|
107
|
+
for (const d of unknownFields)
|
|
108
|
+
explained.add(d.message);
|
|
109
|
+
if (audit.diagnostics.length === 0 && unknownFields.length === 0) {
|
|
92
110
|
out.push({
|
|
93
111
|
code: "CEL_TYPE_ERROR",
|
|
94
112
|
message: checkError + explainUnresolved(audit.unresolved, env.celEnv) + DYN_HINT(checkError),
|
|
@@ -148,7 +166,7 @@ export function analyzeCelExpression(source, env) {
|
|
|
148
166
|
const contextSchema = env.contextSchema;
|
|
149
167
|
for (const chain of extractAccessChains(parsed.ast)) {
|
|
150
168
|
const err = validateChainAgainstSchema(chain, contextSchema);
|
|
151
|
-
if (err)
|
|
169
|
+
if (err && !explained.has(err))
|
|
152
170
|
out.push({ code: "CEL_UNKNOWN_FIELD", message: err });
|
|
153
171
|
}
|
|
154
172
|
for (const issue of findNullableAccessIssues(parsed.ast, contextSchema)) {
|
|
@@ -162,11 +180,54 @@ export function analyzeCelExpression(source, env) {
|
|
|
162
180
|
}
|
|
163
181
|
}
|
|
164
182
|
return {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
183
|
+
result: {
|
|
184
|
+
diagnostics: out,
|
|
185
|
+
calls: resolvedCalls ? withCallArguments(audit.calls, parsed.ast) : audit.calls,
|
|
186
|
+
...(type === undefined ? {} : { type }),
|
|
187
|
+
...(ast.op === "value" && typeof ast.args === "string" ? { stringLiteral: ast.args } : {}),
|
|
188
|
+
...(checkError === undefined ? {} : { readTypes: chainTypes(parsed.ast, env) }),
|
|
189
|
+
},
|
|
190
|
+
ast,
|
|
168
191
|
};
|
|
169
192
|
}
|
|
193
|
+
/** Every chain naming a field the site's names do not declare, as the host's
|
|
194
|
+
* explain schema reads them — the readable half of a rejection the checker
|
|
195
|
+
* reported in its own words. The explain schema is not the checker's
|
|
196
|
+
* environment, so a chain is reported only when the checker rejects it too;
|
|
197
|
+
* otherwise the rejection was about something else and keeps its own words. */
|
|
198
|
+
function explainUnknownFields(ast, env) {
|
|
199
|
+
const schema = env.explainSchema?.();
|
|
200
|
+
if (!schema)
|
|
201
|
+
return [];
|
|
202
|
+
const out = [];
|
|
203
|
+
const reported = new Set();
|
|
204
|
+
for (const chain of extractAccessChains(ast)) {
|
|
205
|
+
const message = validateChainAgainstSchema(chain, schema);
|
|
206
|
+
if (message && !reported.has(message) && checkerRejects(chain, env)) {
|
|
207
|
+
reported.add(message);
|
|
208
|
+
out.push({ code: "CEL_UNKNOWN_FIELD", message });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
213
|
+
/** The checked type of each distinct plain chain the expression reads. */
|
|
214
|
+
function chainTypes(ast, env) {
|
|
215
|
+
const types = new Set();
|
|
216
|
+
for (const chain of extractAccessChains(ast)) {
|
|
217
|
+
if (chain.includes(INDEX_SEGMENT))
|
|
218
|
+
continue;
|
|
219
|
+
const result = env.celEnv.check(chain.join("."));
|
|
220
|
+
if (result.valid && result.type !== undefined)
|
|
221
|
+
types.add(result.type);
|
|
222
|
+
}
|
|
223
|
+
return [...types];
|
|
224
|
+
}
|
|
225
|
+
/** Does the checker reject the chain's named prefix (up to its first index)? */
|
|
226
|
+
function checkerRejects(chain, env) {
|
|
227
|
+
const end = chain.indexOf(INDEX_SEGMENT);
|
|
228
|
+
const named = end === -1 ? chain : chain.slice(0, end);
|
|
229
|
+
return !env.celEnv.check(named.join(".")).valid;
|
|
230
|
+
}
|
|
170
231
|
/** The audited call sites, each module call carrying its arguments as the type
|
|
171
232
|
* check saw them. Matched by position, which is what identifies one call among
|
|
172
233
|
* several of the same name. */
|
|
@@ -215,4 +276,7 @@ export const celEngine = {
|
|
|
215
276
|
analyze(source, env) {
|
|
216
277
|
return analyzeCelExpression(source, env);
|
|
217
278
|
},
|
|
279
|
+
expressionRegions(source) {
|
|
280
|
+
return [{ start: 0, end: source.length }];
|
|
281
|
+
},
|
|
218
282
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ASTNode } from "@marcbachmann/cel-js";
|
|
2
|
+
import type { CompiledValue } from "@telorun/sdk";
|
|
3
|
+
import { type InterpolationHole } from "../cel/interpolation-holes.js";
|
|
4
|
+
import type { AnalyzeEnv, AnalyzeResult, CompileEnv, EngineDiagnostic, ExpressionRegion } from "../engine.js";
|
|
5
|
+
/** The holes of a scalar a hole-bearing tag compiles, or a thrown error naming
|
|
6
|
+
* where the reading failed — a tag's scalar that cannot be read is not a value. */
|
|
7
|
+
export declare function requireHoles(tag: string, source: string): readonly InterpolationHole[];
|
|
8
|
+
/** Every hole compiled as its own CEL expression, with the roots, module calls
|
|
9
|
+
* and volatility of all of them carried together. */
|
|
10
|
+
export declare function compileHoles(holes: readonly InterpolationHole[], env: CompileEnv): {
|
|
11
|
+
readonly compiled: readonly CompiledValue[];
|
|
12
|
+
readonly refs: readonly string[];
|
|
13
|
+
readonly calls: readonly string[];
|
|
14
|
+
readonly volatile: boolean;
|
|
15
|
+
};
|
|
16
|
+
/** Analyze each hole with the shared CEL analysis, so diagnostics read exactly
|
|
17
|
+
* as they do under `!cel`; a fix computed against one hole's expression is
|
|
18
|
+
* re-anchored onto the whole scalar, and call offsets onto the scalar too.
|
|
19
|
+
* `perHole` adds a tag's own verdict on a hole that analyzed clean. */
|
|
20
|
+
export declare function analyzeHoles(source: string, env: AnalyzeEnv, perHole?: (hole: InterpolationHole, result: AnalyzeResult, ast: ASTNode | undefined) => readonly EngineDiagnostic[]): AnalyzeResult;
|
|
21
|
+
/** The CEL expressions of a hole-bearing scalar, by offset. */
|
|
22
|
+
export declare function holeRegions(source: string): readonly ExpressionRegion[];
|
|
23
|
+
//# sourceMappingURL=hole-analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hole-analysis.d.ts","sourceRoot":"","sources":["../../src/engines/hole-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EAEb,UAAU,EAEV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAGtB;oFACoF;AACpF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,iBAAiB,EAAE,CAItF;AAED;sDACsD;AACtD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,iBAAiB,EAAE,EACnC,GAAG,EAAE,UAAU,GACd;IACD,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B,CAWA;AAED;;;wEAGwE;AACxE,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,CACR,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,OAAO,GAAG,SAAS,KACrB,SAAS,gBAAgB,EAAE,GAC/B,aAAa,CAkBf;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,gBAAgB,EAAE,CAIvE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { compileExpression } from "../cel/compile.js";
|
|
2
|
+
import { readInterpolationHoles, } from "../cel/interpolation-holes.js";
|
|
3
|
+
import { analyzeCelWithTree } from "./cel.js";
|
|
4
|
+
/** The holes of a scalar a hole-bearing tag compiles, or a thrown error naming
|
|
5
|
+
* where the reading failed — a tag's scalar that cannot be read is not a value. */
|
|
6
|
+
export function requireHoles(tag, source) {
|
|
7
|
+
const reading = readInterpolationHoles(source);
|
|
8
|
+
if (!reading.ok)
|
|
9
|
+
throw new Error(`!${tag}: ${reading.message}`);
|
|
10
|
+
return reading.holes;
|
|
11
|
+
}
|
|
12
|
+
/** Every hole compiled as its own CEL expression, with the roots, module calls
|
|
13
|
+
* and volatility of all of them carried together. */
|
|
14
|
+
export function compileHoles(holes, env) {
|
|
15
|
+
const compiled = holes.map((h) => compileExpression(h.expr, env.celEnv, env.moduleNames));
|
|
16
|
+
const refs = new Set();
|
|
17
|
+
const calls = new Set();
|
|
18
|
+
let volatile = false;
|
|
19
|
+
for (const c of compiled) {
|
|
20
|
+
for (const r of c.refs ?? [])
|
|
21
|
+
refs.add(r);
|
|
22
|
+
for (const q of c.calls ?? [])
|
|
23
|
+
calls.add(q);
|
|
24
|
+
if (c.volatile)
|
|
25
|
+
volatile = true;
|
|
26
|
+
}
|
|
27
|
+
return { compiled, refs: [...refs], calls: [...calls], volatile };
|
|
28
|
+
}
|
|
29
|
+
/** Analyze each hole with the shared CEL analysis, so diagnostics read exactly
|
|
30
|
+
* as they do under `!cel`; a fix computed against one hole's expression is
|
|
31
|
+
* re-anchored onto the whole scalar, and call offsets onto the scalar too.
|
|
32
|
+
* `perHole` adds a tag's own verdict on a hole that analyzed clean. */
|
|
33
|
+
export function analyzeHoles(source, env, perHole) {
|
|
34
|
+
const reading = readInterpolationHoles(source);
|
|
35
|
+
if (!reading.ok) {
|
|
36
|
+
return { diagnostics: [{ code: "CEL_SYNTAX_ERROR", message: reading.message }], calls: [] };
|
|
37
|
+
}
|
|
38
|
+
const diagnostics = [];
|
|
39
|
+
const calls = [];
|
|
40
|
+
for (const hole of reading.holes) {
|
|
41
|
+
const { result, ast } = analyzeCelWithTree(hole.expr, env);
|
|
42
|
+
for (const d of result.diagnostics) {
|
|
43
|
+
diagnostics.push(d.fix ? { ...d, fix: reanchor(source, hole, d.fix) } : d);
|
|
44
|
+
}
|
|
45
|
+
for (const c of result.calls) {
|
|
46
|
+
calls.push({ ...c, start: hole.exprStart + c.start, end: hole.exprStart + c.end });
|
|
47
|
+
}
|
|
48
|
+
if (perHole && result.diagnostics.length === 0)
|
|
49
|
+
diagnostics.push(...perHole(hole, result, ast));
|
|
50
|
+
}
|
|
51
|
+
return { diagnostics, calls };
|
|
52
|
+
}
|
|
53
|
+
/** The CEL expressions of a hole-bearing scalar, by offset. */
|
|
54
|
+
export function holeRegions(source) {
|
|
55
|
+
const reading = readInterpolationHoles(source);
|
|
56
|
+
if (!reading.ok)
|
|
57
|
+
return [];
|
|
58
|
+
return reading.holes.map((h) => ({ start: h.exprStart, end: h.exprStart + h.expr.length }));
|
|
59
|
+
}
|
|
60
|
+
function reanchor(source, hole, fix) {
|
|
61
|
+
return {
|
|
62
|
+
replacement: source.slice(0, hole.exprStart) +
|
|
63
|
+
fix.replacement +
|
|
64
|
+
source.slice(hole.exprStart + hole.expr.length),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TemplatingEngine } from "../engine.js";
|
|
2
|
+
/**
|
|
3
|
+
* The `!interpolate` engine: literal text with `${{ expr }}` holes, always a
|
|
4
|
+
* string. Its meaning is exactly the CEL expression that joins the text with
|
|
5
|
+
* `string(<hole>)` for each hole — every hole converts through CEL's own
|
|
6
|
+
* `string()` overloads (RFC 3339 for a timestamp, `5400s` for a duration, UTF-8
|
|
7
|
+
* for bytes), never the host language's conversion, so any CEL engine renders
|
|
8
|
+
* the same text. A hole whose type has no `string()` overload is refused
|
|
9
|
+
* statically, and a `dyn` hole that turns out null, a list or a map is refused
|
|
10
|
+
* at runtime with the hole it came from.
|
|
11
|
+
*/
|
|
12
|
+
export declare const interpolateEngine: TemplatingEngine;
|
|
13
|
+
//# sourceMappingURL=interpolate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/engines/interpolate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA+C,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKlG;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAoC/B,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { EvaluationError } from "@marcbachmann/cel-js";
|
|
2
|
+
import { RuntimeError } from "@telorun/sdk";
|
|
3
|
+
import { nullableValueChain } from "../cel/analyze.js";
|
|
4
|
+
import { literalFragments } from "../cel/interpolation-holes.js";
|
|
5
|
+
import { analyzeHoles, compileHoles, holeRegions, requireHoles } from "./hole-analysis.js";
|
|
6
|
+
const INTERPOLATE_ENGINE = "interpolate";
|
|
7
|
+
/**
|
|
8
|
+
* The `!interpolate` engine: literal text with `${{ expr }}` holes, always a
|
|
9
|
+
* string. Its meaning is exactly the CEL expression that joins the text with
|
|
10
|
+
* `string(<hole>)` for each hole — every hole converts through CEL's own
|
|
11
|
+
* `string()` overloads (RFC 3339 for a timestamp, `5400s` for a duration, UTF-8
|
|
12
|
+
* for bytes), never the host language's conversion, so any CEL engine renders
|
|
13
|
+
* the same text. A hole whose type has no `string()` overload is refused
|
|
14
|
+
* statically, and a `dyn` hole that turns out null, a list or a map is refused
|
|
15
|
+
* at runtime with the hole it came from.
|
|
16
|
+
*/
|
|
17
|
+
export const interpolateEngine = {
|
|
18
|
+
name: INTERPOLATE_ENGINE,
|
|
19
|
+
language: "cel",
|
|
20
|
+
compile(source, env) {
|
|
21
|
+
const holes = requireHoles(INTERPOLATE_ENGINE, source);
|
|
22
|
+
const fragments = literalFragments(source, holes);
|
|
23
|
+
const { compiled, refs, calls, volatile } = compileHoles(holes, env);
|
|
24
|
+
const convert = stringConversion(env.celEnv);
|
|
25
|
+
return {
|
|
26
|
+
__compiled: true,
|
|
27
|
+
source,
|
|
28
|
+
refs,
|
|
29
|
+
calls,
|
|
30
|
+
...(volatile ? { volatile: true } : {}),
|
|
31
|
+
call: (ctx) => {
|
|
32
|
+
let out = fragments[0];
|
|
33
|
+
for (let i = 0; i < holes.length; i++) {
|
|
34
|
+
out += convert(compiled[i].call(ctx), holes[i], source) + fragments[i + 1];
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
analyze(source, env) {
|
|
41
|
+
return analyzeHoles(source, env, (hole, result, ast) => holeVerdict(hole, result, ast, env));
|
|
42
|
+
},
|
|
43
|
+
producedType() {
|
|
44
|
+
return { type: "string" };
|
|
45
|
+
},
|
|
46
|
+
expressionRegions(source) {
|
|
47
|
+
return holeRegions(source);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/** A clean hole's own checks, over the tree its analysis already built:
|
|
51
|
+
* whether it may be null, and whether CEL can turn its type into text at all. */
|
|
52
|
+
function holeVerdict(hole, result, ast, env) {
|
|
53
|
+
if (ast && env.contextSchema) {
|
|
54
|
+
const chain = nullableValueChain(ast, env.contextSchema);
|
|
55
|
+
if (chain !== null) {
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
code: "CEL_NULLABLE_ACCESS",
|
|
59
|
+
message: `'${chain}' may be null, and a null has no text — guard it in the hole ` +
|
|
60
|
+
`(e.g. '\${{ ${chain} != null ? ${chain} : "" }}').`,
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (result.type === undefined || convertibleTypes(env.celEnv).has(result.type))
|
|
66
|
+
return [];
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
code: "INTERPOLATION_HOLE_NOT_CONVERTIBLE",
|
|
70
|
+
message: `the hole '\${{ ${hole.expr} }}' is ${result.type}, which CEL's string() cannot convert to text. ` +
|
|
71
|
+
`Convert it inside the hole (e.g. join a list, or read the field you meant), or write the whole value as !cel.`,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
const CONVERTIBLE = new WeakMap();
|
|
76
|
+
/** The types a `string()` overload of `env` accepts, `dyn` among them — read
|
|
77
|
+
* off the registered overloads, so the check is the one evaluation applies. */
|
|
78
|
+
function convertibleTypes(env) {
|
|
79
|
+
const cached = CONVERTIBLE.get(env);
|
|
80
|
+
if (cached)
|
|
81
|
+
return cached;
|
|
82
|
+
const types = new Set(["dyn"]);
|
|
83
|
+
for (const fn of env.getDefinitions().functions) {
|
|
84
|
+
if (fn.name === "string" && fn.receiverType === null && fn.params?.length === 1) {
|
|
85
|
+
types.add(fn.params[0].type);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
CONVERTIBLE.set(env, types);
|
|
89
|
+
return types;
|
|
90
|
+
}
|
|
91
|
+
const CONVERSIONS = new WeakMap();
|
|
92
|
+
/** CEL's `string(v)` in `env`, with every overload the environment registers. */
|
|
93
|
+
function stringConversion(env) {
|
|
94
|
+
const cached = CONVERSIONS.get(env);
|
|
95
|
+
if (cached)
|
|
96
|
+
return cached;
|
|
97
|
+
const program = env.parse("string(value)");
|
|
98
|
+
const conversion = (value, hole, source) => {
|
|
99
|
+
if (typeof value === "string")
|
|
100
|
+
return value;
|
|
101
|
+
try {
|
|
102
|
+
return program({ value });
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (!(error instanceof EvaluationError))
|
|
106
|
+
throw error;
|
|
107
|
+
throw new RuntimeError("ERR_INTERPOLATION_HOLE_NOT_CONVERTIBLE", `the hole '\${{ ${hole.expr} }}' at offset ${hole.start} of !interpolate ${JSON.stringify(source)} ` +
|
|
108
|
+
`evaluated to ${runtimeTypeOf(value)}, which CEL's string() cannot convert to text. ` +
|
|
109
|
+
`Declare outputType on the resource producing it so the check sees its type, or guard it inside the hole.`);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
CONVERSIONS.set(env, conversion);
|
|
113
|
+
return conversion;
|
|
114
|
+
}
|
|
115
|
+
function runtimeTypeOf(value) {
|
|
116
|
+
if (value === null || value === undefined)
|
|
117
|
+
return "null";
|
|
118
|
+
if (Array.isArray(value))
|
|
119
|
+
return "a list";
|
|
120
|
+
if (value instanceof Map || Object.getPrototypeOf(value) === Object.prototype)
|
|
121
|
+
return "a map";
|
|
122
|
+
return `a value of type ${value.constructor?.name ?? typeof value}`;
|
|
123
|
+
}
|
package/dist/engines/sql.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { isParameterizedSql, type ParameterizedSql } from "@telorun/sdk";
|
|
|
2
2
|
import type { TemplatingEngine } from "../engine.js";
|
|
3
3
|
export { isParameterizedSql, type ParameterizedSql };
|
|
4
4
|
/** The `!sql` engine. Treats the tagged scalar as a SQL string with `${{ }}`
|
|
5
|
-
*
|
|
6
|
-
* expression) it keeps the literal text and each
|
|
7
|
-
*
|
|
5
|
+
* holes whose values are *bound*, not spliced. Unlike `!cel` (one bare
|
|
6
|
+
* expression) it keeps the literal text and each hole separate: at runtime
|
|
7
|
+
* `call()` returns a {@link ParameterizedSql} the consumer turns into a
|
|
8
8
|
* parameterized query. Generic expansion passes that object through untouched
|
|
9
9
|
* (it is the `call()` result), so it survives the step-level input expansion. */
|
|
10
10
|
export declare const sqlEngine: TemplatingEngine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/engines/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAsB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/engines/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAsB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,CAAC;AAErD;;;;;kFAKkF;AAClF,eAAO,MAAM,SAAS,EAAE,gBAkCvB,CAAC"}
|
package/dist/engines/sql.js
CHANGED
|
@@ -1,76 +1,42 @@
|
|
|
1
1
|
import { isParameterizedSql } from "@telorun/sdk";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { literalFragments } from "../cel/interpolation-holes.js";
|
|
3
|
+
import { analyzeHoles, compileHoles, holeRegions, requireHoles } from "./hole-analysis.js";
|
|
4
4
|
export { isParameterizedSql };
|
|
5
5
|
/** The `!sql` engine. Treats the tagged scalar as a SQL string with `${{ }}`
|
|
6
|
-
*
|
|
7
|
-
* expression) it keeps the literal text and each
|
|
8
|
-
*
|
|
6
|
+
* holes whose values are *bound*, not spliced. Unlike `!cel` (one bare
|
|
7
|
+
* expression) it keeps the literal text and each hole separate: at runtime
|
|
8
|
+
* `call()` returns a {@link ParameterizedSql} the consumer turns into a
|
|
9
9
|
* parameterized query. Generic expansion passes that object through untouched
|
|
10
10
|
* (it is the `call()` result), so it survives the step-level input expansion. */
|
|
11
11
|
export const sqlEngine = {
|
|
12
12
|
name: "sql",
|
|
13
13
|
language: "sql",
|
|
14
14
|
compile(source, env) {
|
|
15
|
-
const
|
|
15
|
+
const holes = requireHoles("sql", source);
|
|
16
|
+
const fragments = literalFragments(source, holes);
|
|
17
|
+
const { compiled, refs, calls, volatile } = compileHoles(holes, env);
|
|
16
18
|
return {
|
|
17
19
|
__compiled: true,
|
|
18
20
|
source,
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
call: (ctx) => {
|
|
31
|
-
const { fragments, values } = toParameterized(inner, ctx);
|
|
32
|
-
return { __teloParameterized: true, fragments, values };
|
|
33
|
-
},
|
|
21
|
+
// Carried for the reason `!cel` carries them: a consumer asking what an
|
|
22
|
+
// expression READS or CALLS cannot re-derive it from SQL text, which
|
|
23
|
+
// cannot tell an identifier from a word inside a string literal.
|
|
24
|
+
refs,
|
|
25
|
+
calls,
|
|
26
|
+
...(volatile ? { volatile: true } : {}),
|
|
27
|
+
call: (ctx) => ({
|
|
28
|
+
__teloParameterized: true,
|
|
29
|
+
fragments: fragments.slice(),
|
|
30
|
+
values: compiled.map((c) => c.call(ctx)),
|
|
31
|
+
}),
|
|
34
32
|
};
|
|
35
33
|
},
|
|
36
34
|
analyze(source, env) {
|
|
37
|
-
//
|
|
38
|
-
// per-expression analyzer so diagnostics match the `!cel` engine exactly.
|
|
39
|
-
// Each interpolation's offset is kept so a fix computed against the bare
|
|
40
|
-
// expression is re-anchored to the whole SQL scalar — the only thing that
|
|
41
|
-
// ever made `!sql` fix-less was dropping it here.
|
|
42
|
-
const diagnostics = [];
|
|
43
|
-
const calls = [];
|
|
44
|
-
for (const { expr, start } of expressionsOf(source)) {
|
|
45
|
-
const result = analyzeCelExpression(expr, env);
|
|
46
|
-
for (const d of result.diagnostics) {
|
|
47
|
-
diagnostics.push(d.fix ? { ...d, fix: reanchor(source, expr, start, d.fix) } : d);
|
|
48
|
-
}
|
|
49
|
-
for (const c of result.calls) {
|
|
50
|
-
calls.push({ ...c, start: start + c.start, end: start + c.end });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// No `type`: a SQL template is a string built from many expressions, so
|
|
35
|
+
// No `type`: a SQL template is a query built from many expressions, so
|
|
54
36
|
// there is no single checked type to report.
|
|
55
|
-
return
|
|
37
|
+
return analyzeHoles(source, env);
|
|
38
|
+
},
|
|
39
|
+
expressionRegions(source) {
|
|
40
|
+
return holeRegions(source);
|
|
56
41
|
},
|
|
57
42
|
};
|
|
58
|
-
/** Re-anchor a fix computed against one interpolation onto the full source. */
|
|
59
|
-
function reanchor(source, expr, start, fix) {
|
|
60
|
-
return {
|
|
61
|
-
replacement: source.slice(0, start) + fix.replacement + source.slice(start + expr.length),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/** Each `${{ expr }}` body in a `!sql` template, with the body's offset in the
|
|
65
|
-
* source. The offset is derived from the opening delimiter and the leading
|
|
66
|
-
* whitespace the capture group already trims, never by searching for the
|
|
67
|
-
* body text — which a body appearing twice would defeat. */
|
|
68
|
-
function expressionsOf(source) {
|
|
69
|
-
const out = [];
|
|
70
|
-
for (const m of source.matchAll(TEMPLATE_REGEX)) {
|
|
71
|
-
const lead = /^\s*/.exec(m[0].slice(OPEN.length))[0].length;
|
|
72
|
-
out.push({ expr: m[1], start: m.index + OPEN.length + lead });
|
|
73
|
-
}
|
|
74
|
-
return out;
|
|
75
|
-
}
|
|
76
|
-
const OPEN = "${{";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
export { buildCelEnvironment, celBuiltinFunctions, deriveSignatures, type CelHandlers, } from "./cel/environment.js";
|
|
2
2
|
export { celFunctionCatalog, CEL_FUNCTIONS, type CelFunctionInfo, type CelFunctionDoc, type CelFunctionCategory, } from "./cel/catalog.js";
|
|
3
|
-
export { compileExpression
|
|
3
|
+
export { compileExpression } from "./cel/compile.js";
|
|
4
|
+
export { interpolationShape, literalFragments, readInterpolationHoles, type HoleReading, type InterpolationHole, type InterpolationShape, } from "./cel/interpolation-holes.js";
|
|
4
5
|
export { extractAccessChains, findNullableAccessIssues, INDEX_SEGMENT, validateChainAgainstSchema, } from "./cel/analyze.js";
|
|
5
6
|
export { auditCalls, explainUnresolved, functionIndex, type CallAudit, type ModuleCallFlags, } from "./cel/diagnose.js";
|
|
6
7
|
export { MODULE_CALL_DISPATCH_KEY, moduleCallOf, resolveModuleCalls, type ModuleCallDispatch, type ModuleCallTypeResolver, } from "./cel/module-call.js";
|
|
7
|
-
export { walkCelExpressions
|
|
8
|
+
export { walkCelExpressions } from "./cel/walk.js";
|
|
8
9
|
export { celEngine } from "./engines/cel.js";
|
|
9
10
|
export { includeBytesEngine, includeTextEngine, normalizeIncludePath, normalizeModulePath, type NormalizedIncludePath, } from "./engines/include.js";
|
|
11
|
+
export { interpolateEngine } from "./engines/interpolate.js";
|
|
10
12
|
export { literalEngine } from "./engines/literal.js";
|
|
11
13
|
export { modulePathEngine } from "./engines/module-path.js";
|
|
12
14
|
export { refEngine } from "./engines/ref.js";
|
|
13
15
|
export { sqlEngine, isParameterizedSql, type ParameterizedSql } from "./engines/sql.js";
|
|
14
16
|
export { TemplatingEngineRegistry } from "./registry.js";
|
|
15
|
-
export { builtinEngines, createDefaultRegistry, defaultRegistry, producedTypeOf, } from "./builtins.js";
|
|
16
|
-
export type { AnalyzeEnv, AnalyzeResult, CallArgument, CallSite, CompileEnv, DiagnosticFix, EngineDiagnostic, EngineFileClaim, TemplatingEngine, } from "./engine.js";
|
|
17
|
+
export { builtinEngines, celExpressionsOf, createDefaultRegistry, defaultRegistry, producedTypeOf, } from "./builtins.js";
|
|
18
|
+
export type { AnalyzeEnv, AnalyzeResult, CallArgument, CallSite, CompileEnv, DiagnosticFix, EngineDiagnostic, EngineFileClaim, ExpressionRegion, TemplatingEngine, } from "./engine.js";
|
|
17
19
|
export { CEL_ENGINE, INCLUDE_BYTES_ENGINE, INCLUDE_ENGINE_NAMES, INCLUDE_TEXT_ENGINE, isIncludeSentinel, isModulePathSentinel, isRefSentinel, isTaggedSentinel, makeTaggedSentinel, MODULE_FILE_ENGINE_NAMES, MODULE_PATH_ENGINE, plainChainOf, type TaggedSentinel, } from "./sentinel.js";
|
|
18
20
|
export { buildCustomTags, defaultCustomTags } from "./yaml-tags.js";
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,WAAW,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,WAAW,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,KAAK,eAAe,EACpB,KA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,CAAC;AACvB,YAAY,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACZ,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { buildCelEnvironment, celBuiltinFunctions, deriveSignatures, } from "./cel/environment.js";
|
|
2
2
|
export { celFunctionCatalog, CEL_FUNCTIONS, } from "./cel/catalog.js";
|
|
3
|
-
export { compileExpression
|
|
3
|
+
export { compileExpression } from "./cel/compile.js";
|
|
4
|
+
export { interpolationShape, literalFragments, readInterpolationHoles, } from "./cel/interpolation-holes.js";
|
|
4
5
|
export { extractAccessChains, findNullableAccessIssues, INDEX_SEGMENT, validateChainAgainstSchema, } from "./cel/analyze.js";
|
|
5
6
|
export { auditCalls, explainUnresolved, functionIndex, } from "./cel/diagnose.js";
|
|
6
7
|
// The rewrite, its reader, and the activation key the kernel binds a scope's
|
|
@@ -12,11 +13,12 @@ export { MODULE_CALL_DISPATCH_KEY, moduleCallOf, resolveModuleCalls, } from "./c
|
|
|
12
13
|
export { walkCelExpressions } from "./cel/walk.js";
|
|
13
14
|
export { celEngine } from "./engines/cel.js";
|
|
14
15
|
export { includeBytesEngine, includeTextEngine, normalizeIncludePath, normalizeModulePath, } from "./engines/include.js";
|
|
16
|
+
export { interpolateEngine } from "./engines/interpolate.js";
|
|
15
17
|
export { literalEngine } from "./engines/literal.js";
|
|
16
18
|
export { modulePathEngine } from "./engines/module-path.js";
|
|
17
19
|
export { refEngine } from "./engines/ref.js";
|
|
18
20
|
export { sqlEngine, isParameterizedSql } from "./engines/sql.js";
|
|
19
21
|
export { TemplatingEngineRegistry } from "./registry.js";
|
|
20
|
-
export { builtinEngines, createDefaultRegistry, defaultRegistry, producedTypeOf, } from "./builtins.js";
|
|
22
|
+
export { builtinEngines, celExpressionsOf, createDefaultRegistry, defaultRegistry, producedTypeOf, } from "./builtins.js";
|
|
21
23
|
export { CEL_ENGINE, INCLUDE_BYTES_ENGINE, INCLUDE_ENGINE_NAMES, INCLUDE_TEXT_ENGINE, isIncludeSentinel, isModulePathSentinel, isRefSentinel, isTaggedSentinel, makeTaggedSentinel, MODULE_FILE_ENGINE_NAMES, MODULE_PATH_ENGINE, plainChainOf, } from "./sentinel.js";
|
|
22
24
|
export { buildCustomTags, defaultCustomTags } from "./yaml-tags.js";
|
package/dist/sentinel.d.ts
CHANGED
|
@@ -34,11 +34,10 @@ export declare const MODULE_PATH_ENGINE = "module-path";
|
|
|
34
34
|
/**
|
|
35
35
|
* The dotted chain a value names, or undefined.
|
|
36
36
|
*
|
|
37
|
-
* Only a PLAIN CHAIN — `steps.encode.result.output
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* the analyzer knows least is the conservative direction.
|
|
37
|
+
* Only a PLAIN CHAIN written as a `!cel` value — `steps.encode.result.output`.
|
|
38
|
+
* An expression that COMPUTES rather than names has no schema to read off a
|
|
39
|
+
* context, so a caller that navigates one gets nothing and reports nothing:
|
|
40
|
+
* silence where the analyzer knows least is the conservative direction.
|
|
42
41
|
*
|
|
43
42
|
* Here rather than in each caller because "is this expression a plain chain" is
|
|
44
43
|
* one question, and two copies of the answer would eventually disagree about a
|
package/dist/sentinel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentinel.d.ts","sourceRoot":"","sources":["../src/sentinel.ts"],"names":[],"mappings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