@telorun/templating 0.106.0 → 0.107.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 +9 -0
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +10 -0
- package/dist/cel/catalog.d.ts +3 -0
- package/dist/cel/catalog.d.ts.map +1 -1
- package/dist/cel/catalog.js +82 -15
- package/dist/cel/compile.d.ts +9 -1
- package/dist/cel/compile.d.ts.map +1 -1
- package/dist/cel/compile.js +40 -0
- package/dist/cel/diagnose.d.ts +2 -1
- package/dist/cel/diagnose.d.ts.map +1 -1
- package/dist/cel/environment.d.ts +4 -0
- package/dist/cel/environment.d.ts.map +1 -1
- package/dist/cel/environment.js +8 -2
- package/dist/cel/json-prefix-scan.d.ts +17 -0
- package/dist/cel/json-prefix-scan.d.ts.map +1 -0
- package/dist/cel/json-prefix-scan.js +160 -0
- package/dist/cel/value-brands.d.ts +16 -0
- package/dist/cel/value-brands.d.ts.map +1 -0
- package/dist/cel/value-brands.js +31 -0
- package/dist/cel/verdict-codes.d.ts +29 -0
- package/dist/cel/verdict-codes.d.ts.map +1 -0
- package/dist/cel/verdict-codes.js +24 -0
- package/dist/engine.d.ts +15 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engines/cel.d.ts +4 -3
- package/dist/engines/cel.d.ts.map +1 -1
- package/dist/engines/cel.js +4 -1
- package/dist/engines/hole-analysis.d.ts +7 -3
- package/dist/engines/hole-analysis.d.ts.map +1 -1
- package/dist/engines/hole-analysis.js +7 -1
- package/dist/engines/include.js +1 -1
- package/dist/engines/interpolate.d.ts.map +1 -1
- package/dist/engines/interpolate.js +6 -3
- package/dist/engines/module-path.js +1 -1
- package/dist/engines/sql.d.ts.map +1 -1
- package/dist/engines/sql.js +4 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/package.json +4 -4
- package/src/builtins.ts +12 -0
- package/src/cel/catalog.ts +93 -17
- package/src/cel/compile.ts +37 -1
- package/src/cel/diagnose.ts +4 -3
- package/src/cel/environment.ts +9 -2
- package/src/cel/json-prefix-scan.ts +152 -0
- package/src/cel/value-brands.ts +33 -0
- package/src/cel/verdict-codes.ts +47 -0
- package/src/engine.ts +16 -0
- package/src/engines/cel.ts +12 -13
- package/src/engines/hole-analysis.ts +15 -15
- package/src/engines/include.ts +1 -1
- package/src/engines/interpolate.ts +17 -6
- package/src/engines/module-path.ts +1 -1
- package/src/engines/sql.ts +11 -1
- package/src/index.ts +3 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RuntimeError } from "@telorun/sdk";
|
|
2
|
+
import type { AnalyzeResult, EngineDiagnostic } from "../engine.js";
|
|
3
|
+
import type { CallAudit } from "./diagnose.js";
|
|
4
|
+
/** Every code the `!cel`, `!interpolate` and `!sql` engines emit: `diagnostics`
|
|
5
|
+
* from `analyze`, `errors` thrown by compiling or evaluating. Stated once here;
|
|
6
|
+
* the types below hold every emit site to it, and the conformance runner
|
|
7
|
+
* requires a `verdicts.json` row for each. */
|
|
8
|
+
export declare const CEL_VERDICT_CODES: {
|
|
9
|
+
readonly diagnostics: readonly ["BINDING_NAME_RESERVED", "CEL_INVALID_ARGUMENT", "CEL_NULLABLE_ACCESS", "CEL_SYNTAX_ERROR", "CEL_TYPE_ERROR", "CEL_UNKNOWN_FIELD", "CEL_UNKNOWN_FUNCTION", "CEL_UNKNOWN_IDENTIFIER", "CEL_WRONG_CALL_FORM", "INTERPOLATION_HOLE_NOT_CONVERTIBLE"];
|
|
10
|
+
readonly errors: readonly ["ERR_INTERPOLATION_HOLE_NOT_CONVERTIBLE"];
|
|
11
|
+
};
|
|
12
|
+
export type CelDiagnosticCode = (typeof CEL_VERDICT_CODES.diagnostics)[number];
|
|
13
|
+
export type CelErrorCode = (typeof CEL_VERDICT_CODES.errors)[number];
|
|
14
|
+
/** A diagnostic one of the three engines builds. */
|
|
15
|
+
export interface CelDiagnostic extends EngineDiagnostic {
|
|
16
|
+
readonly code: CelDiagnosticCode;
|
|
17
|
+
}
|
|
18
|
+
/** What those engines' `analyze` answers. */
|
|
19
|
+
export interface CelAnalyzeResult extends AnalyzeResult {
|
|
20
|
+
readonly diagnostics: readonly CelDiagnostic[];
|
|
21
|
+
}
|
|
22
|
+
/** The call audit, as those engines read it. */
|
|
23
|
+
export interface CelCallAudit extends CallAudit {
|
|
24
|
+
readonly diagnostics: readonly CelDiagnostic[];
|
|
25
|
+
readonly argumentIssues: readonly CelDiagnostic[];
|
|
26
|
+
}
|
|
27
|
+
/** The one constructor of a coded error those engines throw. */
|
|
28
|
+
export declare function celVerdictError(code: CelErrorCode, message: string): RuntimeError;
|
|
29
|
+
//# sourceMappingURL=verdict-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict-codes.d.ts","sourceRoot":"","sources":["../../src/cel/verdict-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;+CAG+C;AAC/C,eAAO,MAAM,iBAAiB;;;CAcpB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/E,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE,oDAAoD;AACpD,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;CAClC;AAED,6CAA6C;AAC7C,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;CAChD;AAED,gDAAgD;AAChD,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,QAAQ,CAAC,WAAW,EAAE,SAAS,aAAa,EAAE,CAAC;IAC/C,QAAQ,CAAC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;CACnD;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAEjF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RuntimeError } from "@telorun/sdk";
|
|
2
|
+
/** Every code the `!cel`, `!interpolate` and `!sql` engines emit: `diagnostics`
|
|
3
|
+
* from `analyze`, `errors` thrown by compiling or evaluating. Stated once here;
|
|
4
|
+
* the types below hold every emit site to it, and the conformance runner
|
|
5
|
+
* requires a `verdicts.json` row for each. */
|
|
6
|
+
export const CEL_VERDICT_CODES = {
|
|
7
|
+
diagnostics: [
|
|
8
|
+
"BINDING_NAME_RESERVED",
|
|
9
|
+
"CEL_INVALID_ARGUMENT",
|
|
10
|
+
"CEL_NULLABLE_ACCESS",
|
|
11
|
+
"CEL_SYNTAX_ERROR",
|
|
12
|
+
"CEL_TYPE_ERROR",
|
|
13
|
+
"CEL_UNKNOWN_FIELD",
|
|
14
|
+
"CEL_UNKNOWN_FUNCTION",
|
|
15
|
+
"CEL_UNKNOWN_IDENTIFIER",
|
|
16
|
+
"CEL_WRONG_CALL_FORM",
|
|
17
|
+
"INTERPOLATION_HOLE_NOT_CONVERTIBLE",
|
|
18
|
+
],
|
|
19
|
+
errors: ["ERR_INTERPOLATION_HOLE_NOT_CONVERTIBLE"],
|
|
20
|
+
};
|
|
21
|
+
/** The one constructor of a coded error those engines throw. */
|
|
22
|
+
export function celVerdictError(code, message) {
|
|
23
|
+
return new RuntimeError(code, message);
|
|
24
|
+
}
|
package/dist/engine.d.ts
CHANGED
|
@@ -191,6 +191,10 @@ export interface EngineFileClaim {
|
|
|
191
191
|
/** The path may name a directory, which then claims every file beneath it.
|
|
192
192
|
* Whether it does is a question for whoever holds the directory. */
|
|
193
193
|
readonly directory?: boolean;
|
|
194
|
+
/** The diagnostic code reporting a claim that names nothing — the static twin
|
|
195
|
+
* of the runtime's refusal, declared by the engine so the existence check
|
|
196
|
+
* recognises no tag by name. */
|
|
197
|
+
readonly notFoundCode: string;
|
|
194
198
|
}
|
|
195
199
|
/** One CEL expression inside a tagged scalar, by offset into the scalar's
|
|
196
200
|
* source. */
|
|
@@ -261,5 +265,16 @@ export interface TemplatingEngine {
|
|
|
261
265
|
* engine whose scalar holds no CEL. A source the engine cannot read yields
|
|
262
266
|
* no regions; `analyze` is what reports why. */
|
|
263
267
|
expressionRegions?(source: string): readonly ExpressionRegion[];
|
|
268
|
+
/** Whether the tagged text, written twice in one value, means one value both
|
|
269
|
+
* times — the engine's verdict on the TEXT ALONE, with no module name set and
|
|
270
|
+
* nothing evaluated: no expression in it calls a catalog function whose
|
|
271
|
+
* result differs per call, and none makes a call that may be a module's (a
|
|
272
|
+
* method on a bare identifier), whose determinism is its callee's.
|
|
273
|
+
*
|
|
274
|
+
* What lets a consumer holding two character-identical tagged scalars say
|
|
275
|
+
* they are equal without evaluating either. Absent on an engine that gives no
|
|
276
|
+
* such verdict, which reads as "not repeatable". A source the engine cannot
|
|
277
|
+
* read is not repeatable; `analyze` is what reports why. */
|
|
278
|
+
repeatable?(source: string, celEnv: Environment): boolean;
|
|
264
279
|
}
|
|
265
280
|
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAA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AAG,aAAa,CAAC;IAExD;;;;;;;;;;;;uBAYmB;IACnB,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,eAAe,EAAE,CAAC;IAExD;;;;;;;;;;;;;;;;;2CAiBuC;IACvC,YAAY,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzC;;;;;;qDAMiD;IACjD,iBAAiB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,gBAAgB,EAAE,CAAC;IAEhE;;;;;;;;;iEAS6D;IAC7D,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC;CAC3D"}
|
package/dist/engines/cel.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ASTNode } from "@marcbachmann/cel-js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CelAnalyzeResult } from "../cel/verdict-codes.js";
|
|
3
|
+
import type { AnalyzeEnv, TemplatingEngine } from "../engine.js";
|
|
3
4
|
/** Statically analyze one CEL expression against the effective context schema:
|
|
4
5
|
* parse → classify every call → type-check → validate member-access chains →
|
|
5
6
|
* flag nullable access. Single source of truth shared by the `!cel` engine
|
|
@@ -11,11 +12,11 @@ import type { AnalyzeEnv, AnalyzeResult, TemplatingEngine } from "../engine.js";
|
|
|
11
12
|
* "no matching overload" survive next to the diagnostic that actually
|
|
12
13
|
* explained it, and left `${{ }}` interpolations chain-validated but never
|
|
13
14
|
* type-checked at all. */
|
|
14
|
-
export declare function analyzeCelExpression(source: string, env: AnalyzeEnv):
|
|
15
|
+
export declare function analyzeCelExpression(source: string, env: AnalyzeEnv): CelAnalyzeResult;
|
|
15
16
|
/** {@link analyzeCelExpression}, with the resolved tree it built — for a tag
|
|
16
17
|
* that asks its own questions of one expression without parsing it again. */
|
|
17
18
|
export declare function analyzeCelWithTree(source: string, env: AnalyzeEnv): {
|
|
18
|
-
result:
|
|
19
|
+
result: CelAnalyzeResult;
|
|
19
20
|
ast?: ASTNode;
|
|
20
21
|
};
|
|
21
22
|
/** The `!cel` engine. Treats the entire tagged scalar as a single CEL
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAE,gBAAgB,EAAiB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAY,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE3E;;;;;;;;;;2BAU2B;AAC3B,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,gBAAgB,CAEtF;AAED;8EAC8E;AAC9E,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,UAAU,GACd;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,CAoL7C;AA4ED;yCACyC;AACzC,eAAO,MAAM,SAAS,EAAE,gBAmBvB,CAAC"}
|
package/dist/engines/cel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extractAccessChains, extractCallResultAccesses, findNullableAccessIssues, INDEX_SEGMENT, moduleCallArgumentChains, validateChainAgainstSchema, } from "../cel/analyze.js";
|
|
2
|
-
import { compileExpression } from "../cel/compile.js";
|
|
2
|
+
import { compileExpression, repeatableExpression } from "../cel/compile.js";
|
|
3
3
|
import { auditCalls, explainUnresolved } from "../cel/diagnose.js";
|
|
4
4
|
import { moduleCallNodes, moduleNameBindings, resolveModuleCalls, unresolvedCallReceivers, } from "../cel/module-call.js";
|
|
5
5
|
/** Statically analyze one CEL expression against the effective context schema:
|
|
@@ -279,4 +279,7 @@ export const celEngine = {
|
|
|
279
279
|
expressionRegions(source) {
|
|
280
280
|
return [{ start: 0, end: source.length }];
|
|
281
281
|
},
|
|
282
|
+
repeatable(source, celEnv) {
|
|
283
|
+
return repeatableExpression(source, celEnv);
|
|
284
|
+
},
|
|
282
285
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ASTNode } from "@marcbachmann/cel-js";
|
|
1
|
+
import type { ASTNode, Environment } from "@marcbachmann/cel-js";
|
|
2
2
|
import type { CompiledValue } from "@telorun/sdk";
|
|
3
3
|
import { type InterpolationHole } from "../cel/interpolation-holes.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { CelAnalyzeResult, CelDiagnostic } from "../cel/verdict-codes.js";
|
|
5
|
+
import type { AnalyzeEnv, CompileEnv, ExpressionRegion } from "../engine.js";
|
|
5
6
|
/** The holes of a scalar a hole-bearing tag compiles, or a thrown error naming
|
|
6
7
|
* where the reading failed — a tag's scalar that cannot be read is not a value. */
|
|
7
8
|
export declare function requireHoles(tag: string, source: string): readonly InterpolationHole[];
|
|
@@ -17,7 +18,10 @@ export declare function compileHoles(holes: readonly InterpolationHole[], env: C
|
|
|
17
18
|
* as they do under `!cel`; a fix computed against one hole's expression is
|
|
18
19
|
* re-anchored onto the whole scalar, and call offsets onto the scalar too.
|
|
19
20
|
* `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:
|
|
21
|
+
export declare function analyzeHoles(source: string, env: AnalyzeEnv, perHole?: (hole: InterpolationHole, result: CelAnalyzeResult, ast: ASTNode | undefined) => readonly CelDiagnostic[]): CelAnalyzeResult;
|
|
21
22
|
/** The CEL expressions of a hole-bearing scalar, by offset. */
|
|
22
23
|
export declare function holeRegions(source: string): readonly ExpressionRegion[];
|
|
24
|
+
/** Whether every hole of a hole-bearing scalar is repeatable; the literal text
|
|
25
|
+
* between them always is. */
|
|
26
|
+
export declare function holesRepeatable(source: string, celEnv: Environment): boolean;
|
|
23
27
|
//# sourceMappingURL=hole-analysis.d.ts.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"hole-analysis.d.ts","sourceRoot":"","sources":["../../src/engines/hole-analysis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAY,UAAU,EAAiB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGtG;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,gBAAgB,EACxB,GAAG,EAAE,OAAO,GAAG,SAAS,KACrB,SAAS,aAAa,EAAE,GAC5B,gBAAgB,CAkBlB;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,gBAAgB,EAAE,CAIvE;AAED;8BAC8B;AAC9B,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAG5E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compileExpression } from "../cel/compile.js";
|
|
1
|
+
import { compileExpression, repeatableExpression } from "../cel/compile.js";
|
|
2
2
|
import { readInterpolationHoles, } from "../cel/interpolation-holes.js";
|
|
3
3
|
import { analyzeCelWithTree } from "./cel.js";
|
|
4
4
|
/** The holes of a scalar a hole-bearing tag compiles, or a thrown error naming
|
|
@@ -57,6 +57,12 @@ export function holeRegions(source) {
|
|
|
57
57
|
return [];
|
|
58
58
|
return reading.holes.map((h) => ({ start: h.exprStart, end: h.exprStart + h.expr.length }));
|
|
59
59
|
}
|
|
60
|
+
/** Whether every hole of a hole-bearing scalar is repeatable; the literal text
|
|
61
|
+
* between them always is. */
|
|
62
|
+
export function holesRepeatable(source, celEnv) {
|
|
63
|
+
const reading = readInterpolationHoles(source);
|
|
64
|
+
return reading.ok && reading.holes.every((h) => repeatableExpression(h.expr, celEnv));
|
|
65
|
+
}
|
|
60
66
|
function reanchor(source, hole, fix) {
|
|
61
67
|
return {
|
|
62
68
|
replacement: source.slice(0, hole.exprStart) +
|
package/dist/engines/include.js
CHANGED
|
@@ -146,7 +146,7 @@ function includeEngine(name, produced) {
|
|
|
146
146
|
// A malformed path claims nothing. `analyze` is what says why, so
|
|
147
147
|
// claiming a half-understood path here would produce a second, worse
|
|
148
148
|
// report from publish about the same mistake.
|
|
149
|
-
return path ? [{ path }] : [];
|
|
149
|
+
return path ? [{ path, notFoundCode: "INCLUDE_FILE_NOT_FOUND" }] : [];
|
|
150
150
|
},
|
|
151
151
|
};
|
|
152
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/engines/interpolate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/engines/interpolate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAWjE;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAwC/B,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EvaluationError } from "@marcbachmann/cel-js";
|
|
2
|
-
import { RuntimeError } from "@telorun/sdk";
|
|
3
2
|
import { nullableValueChain } from "../cel/analyze.js";
|
|
4
3
|
import { literalFragments } from "../cel/interpolation-holes.js";
|
|
5
|
-
import {
|
|
4
|
+
import { celVerdictError } from "../cel/verdict-codes.js";
|
|
5
|
+
import { analyzeHoles, compileHoles, holeRegions, holesRepeatable, requireHoles, } from "./hole-analysis.js";
|
|
6
6
|
const INTERPOLATE_ENGINE = "interpolate";
|
|
7
7
|
/**
|
|
8
8
|
* The `!interpolate` engine: literal text with `${{ expr }}` holes, always a
|
|
@@ -46,6 +46,9 @@ export const interpolateEngine = {
|
|
|
46
46
|
expressionRegions(source) {
|
|
47
47
|
return holeRegions(source);
|
|
48
48
|
},
|
|
49
|
+
repeatable(source, celEnv) {
|
|
50
|
+
return holesRepeatable(source, celEnv);
|
|
51
|
+
},
|
|
49
52
|
};
|
|
50
53
|
/** A clean hole's own checks, over the tree its analysis already built:
|
|
51
54
|
* whether it may be null, and whether CEL can turn its type into text at all. */
|
|
@@ -104,7 +107,7 @@ function stringConversion(env) {
|
|
|
104
107
|
catch (error) {
|
|
105
108
|
if (!(error instanceof EvaluationError))
|
|
106
109
|
throw error;
|
|
107
|
-
throw
|
|
110
|
+
throw celVerdictError("ERR_INTERPOLATION_HOLE_NOT_CONVERTIBLE", `the hole '\${{ ${hole.expr} }}' at offset ${hole.start} of !interpolate ${JSON.stringify(source)} ` +
|
|
108
111
|
`evaluated to ${runtimeTypeOf(value)}, which CEL's string() cannot convert to text. ` +
|
|
109
112
|
`Declare outputType on the resource producing it so the check sees its type, or guard it inside the hole.`);
|
|
110
113
|
}
|
|
@@ -28,6 +28,6 @@ export const modulePathEngine = {
|
|
|
28
28
|
},
|
|
29
29
|
fileClaims(source) {
|
|
30
30
|
const { path } = normalizeModulePath(source);
|
|
31
|
-
return path ? [{ path, directory: true }] : [];
|
|
31
|
+
return path ? [{ path, directory: true, notFoundCode: "MODULE_PATH_NOT_FOUND" }] : [];
|
|
32
32
|
},
|
|
33
33
|
};
|
|
@@ -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;AAE7F,OAAO,KAAK,EAAE,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;AASrD,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,CAAC;AAErD;;;;;kFAKkF;AAClF,eAAO,MAAM,SAAS,EAAE,gBAsCvB,CAAC"}
|
package/dist/engines/sql.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isParameterizedSql } from "@telorun/sdk";
|
|
2
2
|
import { literalFragments } from "../cel/interpolation-holes.js";
|
|
3
|
-
import { analyzeHoles, compileHoles, holeRegions, requireHoles } from "./hole-analysis.js";
|
|
3
|
+
import { analyzeHoles, compileHoles, holeRegions, holesRepeatable, requireHoles, } from "./hole-analysis.js";
|
|
4
4
|
export { isParameterizedSql };
|
|
5
5
|
/** The `!sql` engine. Treats the tagged scalar as a SQL string with `${{ }}`
|
|
6
6
|
* holes whose values are *bound*, not spliced. Unlike `!cel` (one bare
|
|
@@ -39,4 +39,7 @@ export const sqlEngine = {
|
|
|
39
39
|
expressionRegions(source) {
|
|
40
40
|
return holeRegions(source);
|
|
41
41
|
},
|
|
42
|
+
repeatable(source, celEnv) {
|
|
43
|
+
return holesRepeatable(source, celEnv);
|
|
44
|
+
},
|
|
42
45
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { buildCelEnvironment, celBuiltinFunctions, deriveSignatures, type CelHandlers, } from "./cel/environment.js";
|
|
1
|
+
export { buildCelEnvironment, buildCelLanguageEnvironment, 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
3
|
export { compileExpression } from "./cel/compile.js";
|
|
4
|
+
export { registerValueBrands } from "./cel/value-brands.js";
|
|
4
5
|
export { interpolationShape, literalFragments, readInterpolationHoles, type HoleReading, type InterpolationHole, type InterpolationShape, } from "./cel/interpolation-holes.js";
|
|
5
6
|
export { extractAccessChains, findNullableAccessIssues, INDEX_SEGMENT, validateChainAgainstSchema, } from "./cel/analyze.js";
|
|
6
7
|
export { auditCalls, explainUnresolved, functionIndex, type CallAudit, type ModuleCallFlags, } from "./cel/diagnose.js";
|
|
@@ -14,7 +15,7 @@ export { modulePathEngine } from "./engines/module-path.js";
|
|
|
14
15
|
export { refEngine } from "./engines/ref.js";
|
|
15
16
|
export { sqlEngine, isParameterizedSql, type ParameterizedSql } from "./engines/sql.js";
|
|
16
17
|
export { TemplatingEngineRegistry } from "./registry.js";
|
|
17
|
-
export { builtinEngines, celExpressionsOf, createDefaultRegistry, defaultRegistry, producedTypeOf, } from "./builtins.js";
|
|
18
|
+
export { builtinEngines, celExpressionsOf, createDefaultRegistry, defaultRegistry, producedTypeOf, repeatableSource, } from "./builtins.js";
|
|
18
19
|
export type { AnalyzeEnv, AnalyzeResult, CallArgument, CallSite, CompileEnv, DiagnosticFix, EngineDiagnostic, EngineFileClaim, ExpressionRegion, TemplatingEngine, } from "./engine.js";
|
|
19
20
|
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";
|
|
20
21
|
export { buildCustomTags, defaultCustomTags } from "./yaml-tags.js";
|
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,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,mBAAmB,E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d,gBAAgB,GACjB,MAAM,eAAe,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
|
-
export { buildCelEnvironment, celBuiltinFunctions, deriveSignatures, } from "./cel/environment.js";
|
|
1
|
+
export { buildCelEnvironment, buildCelLanguageEnvironment, celBuiltinFunctions, deriveSignatures, } from "./cel/environment.js";
|
|
2
2
|
export { celFunctionCatalog, CEL_FUNCTIONS, } from "./cel/catalog.js";
|
|
3
3
|
export { compileExpression } from "./cel/compile.js";
|
|
4
|
+
export { registerValueBrands } from "./cel/value-brands.js";
|
|
4
5
|
export { interpolationShape, literalFragments, readInterpolationHoles, } from "./cel/interpolation-holes.js";
|
|
5
6
|
export { extractAccessChains, findNullableAccessIssues, INDEX_SEGMENT, validateChainAgainstSchema, } from "./cel/analyze.js";
|
|
6
7
|
export { auditCalls, explainUnresolved, functionIndex, } from "./cel/diagnose.js";
|
|
@@ -19,6 +20,6 @@ export { modulePathEngine } from "./engines/module-path.js";
|
|
|
19
20
|
export { refEngine } from "./engines/ref.js";
|
|
20
21
|
export { sqlEngine, isParameterizedSql } from "./engines/sql.js";
|
|
21
22
|
export { TemplatingEngineRegistry } from "./registry.js";
|
|
22
|
-
export { builtinEngines, celExpressionsOf, createDefaultRegistry, defaultRegistry, producedTypeOf, } from "./builtins.js";
|
|
23
|
+
export { builtinEngines, celExpressionsOf, createDefaultRegistry, defaultRegistry, producedTypeOf, repeatableSource, } from "./builtins.js";
|
|
23
24
|
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";
|
|
24
25
|
export { buildCustomTags, defaultCustomTags } from "./yaml-tags.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/templating",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.107.0",
|
|
4
4
|
"description": "Telo Templating - Engine registry and shared CEL core for Telo manifests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"telo",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@marcbachmann/cel-js": "7.6.1",
|
|
39
39
|
"d3-format": "3.1.2",
|
|
40
|
-
"re2js": "
|
|
41
|
-
"uuid": "
|
|
40
|
+
"re2js": "2.8.3",
|
|
41
|
+
"uuid": "14.0.1",
|
|
42
42
|
"yaml": "^2.8.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/node": "^20.0.0",
|
|
47
47
|
"typescript": "^5.0.0",
|
|
48
48
|
"vitest": "^2.1.8",
|
|
49
|
-
"@telorun/sdk": "0.
|
|
49
|
+
"@telorun/sdk": "0.107.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@telorun/sdk": "*"
|
package/src/builtins.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Environment } from "@marcbachmann/cel-js";
|
|
1
2
|
import { celEngine } from "./engines/cel.js";
|
|
2
3
|
import { includeBytesEngine, includeTextEngine } from "./engines/include.js";
|
|
3
4
|
import { interpolateEngine } from "./engines/interpolate.js";
|
|
@@ -59,6 +60,17 @@ export function celExpressionsOf(engineName: string, source: string): string[] {
|
|
|
59
60
|
return regions.map((r) => source.slice(r.start, r.end));
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Whether a tagged scalar's text, written twice in one value, means one value
|
|
65
|
+
* both times — false for a tag whose engine gives no such verdict.
|
|
66
|
+
*
|
|
67
|
+
* The single reader of `TemplatingEngine.repeatable`, so a consumer comparing
|
|
68
|
+
* two tagged scalars never recognises a tag by name.
|
|
69
|
+
*/
|
|
70
|
+
export function repeatableSource(engineName: string, source: string, celEnv: Environment): boolean {
|
|
71
|
+
return defaultRegistry().get(engineName)?.repeatable?.(source, celEnv) ?? false;
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
let defaultRegistryCache: TemplatingEngineRegistry | undefined;
|
|
63
75
|
|
|
64
76
|
/** Memoized singleton: returns the default registry. Hosts that don't need
|
package/src/cel/catalog.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { formatLocale } from "d3-format";
|
|
2
|
-
import { RE2JS } from "re2js";
|
|
2
|
+
import { RE2JS, RE2JSSyntaxException } from "re2js";
|
|
3
3
|
import { v1, v3, v4, v5, v6, v7, validate as uuidValidate, version as uuidVersion } from "uuid";
|
|
4
4
|
import { PLAIN_ENCODINGS } from "@telorun/sdk";
|
|
5
|
+
import { scanJsonPrefix } from "./json-prefix-scan.js";
|
|
5
6
|
|
|
6
7
|
/** Host-injected functions that need platform APIs the templating package must
|
|
7
8
|
* not import directly (Node `crypto` / `Buffer`), keeping it browser-safe. The
|
|
@@ -44,23 +45,62 @@ const RE2_FLAG: Record<string, number> = {
|
|
|
44
45
|
s: RE2JS.DOTALL,
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
/** RE2's parse-error kinds, in RE2's own words — the closed vocabulary an
|
|
49
|
+
* invalid-pattern refusal ends with, so every engine words one identically. */
|
|
50
|
+
export const RE2_PATTERN_ERROR_KINDS: readonly string[] = [
|
|
51
|
+
"missing closing )",
|
|
52
|
+
"missing closing ]",
|
|
53
|
+
"unexpected )",
|
|
54
|
+
"trailing backslash at end of expression",
|
|
55
|
+
"invalid escape sequence",
|
|
56
|
+
"invalid character class range",
|
|
57
|
+
"invalid named capture",
|
|
58
|
+
"duplicate capture group name",
|
|
59
|
+
"invalid or unsupported Perl syntax",
|
|
60
|
+
"missing argument to repetition operator",
|
|
61
|
+
"invalid nested repetition operator",
|
|
62
|
+
"invalid repeat count",
|
|
63
|
+
"expression nests too deeply",
|
|
64
|
+
"expression too large",
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/** A refusal a catalog function makes of its arguments — the one failure a
|
|
68
|
+
* literal guard reports. It reads as a plain `Error` wherever it is printed. */
|
|
69
|
+
class CatalogRefusal extends Error {}
|
|
70
|
+
Object.defineProperty(CatalogRefusal, "name", { value: "Error" });
|
|
71
|
+
|
|
72
|
+
const re2Flags = (fn: string, flags: string | undefined): number => {
|
|
48
73
|
let bits = 0;
|
|
49
74
|
for (const c of flags ?? "") {
|
|
50
75
|
if (c === "g") continue; // global is implicit in replaceAll / find-loop
|
|
51
76
|
const bit = RE2_FLAG[c];
|
|
52
|
-
if (bit === undefined) throw new
|
|
77
|
+
if (bit === undefined) throw new CatalogRefusal(`${fn}: unknown regex flag '${c}' (supported: i, m, s)`);
|
|
53
78
|
bits |= bit;
|
|
54
79
|
}
|
|
80
|
+
return bits;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** The refusal is Telo's: the library's `error parsing regexp:` prefix and the
|
|
84
|
+
* fragment it quotes never reach it. A failure outside the vocabulary is a
|
|
85
|
+
* defect here, raised as one with the library's error as its cause. */
|
|
86
|
+
const re2Pattern = (fn: string, pattern: string, bits: number): RE2JS => {
|
|
55
87
|
try {
|
|
56
88
|
return RE2JS.compile(pattern, bits);
|
|
57
89
|
} catch (e) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
90
|
+
const kind = e instanceof RE2JSSyntaxException ? e.error : undefined;
|
|
91
|
+
if (kind === undefined || !RE2_PATTERN_ERROR_KINDS.includes(kind)) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`${fn}: the RE2 compiler failed on pattern ${JSON.stringify(pattern)} with an error outside Telo's parse-error vocabulary`,
|
|
94
|
+
{ cause: e },
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
throw new CatalogRefusal(`${fn}: invalid RE2 pattern ${JSON.stringify(pattern)}: ${kind}`);
|
|
61
98
|
}
|
|
62
99
|
};
|
|
63
100
|
|
|
101
|
+
const compileRe2 = (fn: string, pattern: string, flags?: string): RE2JS =>
|
|
102
|
+
re2Pattern(fn, pattern, re2Flags(fn, flags));
|
|
103
|
+
|
|
64
104
|
export type CelFunctionCategory =
|
|
65
105
|
| "conversion"
|
|
66
106
|
| "time"
|
|
@@ -119,13 +159,45 @@ export interface CelFunctionDoc {
|
|
|
119
159
|
readonly checkArgs?: (literals: readonly unknown[]) => string | undefined;
|
|
120
160
|
}
|
|
121
161
|
|
|
122
|
-
/** Run a runtime guard for its refusal, so a `checkArgs` never restates one.
|
|
162
|
+
/** Run a runtime guard for its refusal, so a `checkArgs` never restates one.
|
|
163
|
+
* Anything else it throws is the engine failing, not the argument. */
|
|
123
164
|
const literalGuard = (run: () => void): string | undefined => {
|
|
124
165
|
try {
|
|
125
166
|
run();
|
|
126
167
|
return undefined;
|
|
127
168
|
} catch (e) {
|
|
128
|
-
|
|
169
|
+
if (e instanceof CatalogRefusal) return e.message;
|
|
170
|
+
throw e;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/** A regex function's literal guard: the flags and the pattern, each judged
|
|
175
|
+
* only when written as a literal, by the compile the runtime runs. */
|
|
176
|
+
const regexLiteralGuard =
|
|
177
|
+
(fn: string, patternAt: number, flagsAt: number): NonNullable<CelFunctionDoc["checkArgs"]> =>
|
|
178
|
+
(literals) =>
|
|
179
|
+
literalGuard(() => {
|
|
180
|
+
const pattern = literals[patternAt];
|
|
181
|
+
const flags = literals[flagsAt];
|
|
182
|
+
const bits = typeof flags === "string" ? re2Flags(fn, flags) : 0;
|
|
183
|
+
if (typeof pattern === "string") re2Pattern(fn, pattern, bits);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
/** The host parser's verdict stands; Telo's scan only words its refusal. The
|
|
187
|
+
* scan reading as JSON a text the host refused is a defect here. */
|
|
188
|
+
const parseJsonText = (text: string): unknown => {
|
|
189
|
+
try {
|
|
190
|
+
return JSON.parse(text);
|
|
191
|
+
} catch (hostRefusal) {
|
|
192
|
+
const refusal = scanJsonPrefix(text);
|
|
193
|
+
if (refusal === undefined) {
|
|
194
|
+
throw new Error("parseJson: the host JSON parser refused a text Telo's scan reads as valid JSON", {
|
|
195
|
+
cause: hostRefusal,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
throw new Error(
|
|
199
|
+
`parseJson: invalid JSON at offset ${refusal.offset}${refusal.endOfInput ? " (unexpected end of input)" : ""}`,
|
|
200
|
+
);
|
|
129
201
|
}
|
|
130
202
|
};
|
|
131
203
|
|
|
@@ -187,7 +259,7 @@ const MAX_EXACT_INT = 9007199254740991n;
|
|
|
187
259
|
const formattable = (fn: string, x: unknown): number => {
|
|
188
260
|
if (typeof x === "bigint") {
|
|
189
261
|
if (x > MAX_EXACT_INT || x < -MAX_EXACT_INT) {
|
|
190
|
-
throw new
|
|
262
|
+
throw new CatalogRefusal(
|
|
191
263
|
`${fn}: integer ${x} exceeds 2^53-1 and cannot be formatted exactly as a double`,
|
|
192
264
|
);
|
|
193
265
|
}
|
|
@@ -199,7 +271,7 @@ const formattable = (fn: string, x: unknown): number => {
|
|
|
199
271
|
// to remove: it looks like an answer and prints into a document. Named here
|
|
200
272
|
// rather than coerced, the way an instant argument is.
|
|
201
273
|
if (!Number.isFinite(n)) {
|
|
202
|
-
throw new
|
|
274
|
+
throw new CatalogRefusal(`${fn}: expected a finite number, got ${JSON.stringify(x)}`);
|
|
203
275
|
}
|
|
204
276
|
return n;
|
|
205
277
|
};
|
|
@@ -225,7 +297,7 @@ const formatter = (fn: string, spec: unknown): ((n: number) => string) => {
|
|
|
225
297
|
if (cached) return cached;
|
|
226
298
|
const type = text.slice(-1);
|
|
227
299
|
if (text !== "" && /[a-zA-Z%]/.test(type) && !FORMAT_TYPES.has(type)) {
|
|
228
|
-
throw new
|
|
300
|
+
throw new CatalogRefusal(`${fn}: unknown format type '${type}' (one of ${[...FORMAT_TYPES].join("")})`);
|
|
229
301
|
}
|
|
230
302
|
// The `.precision` group — width is the digits BEFORE the dot, so this is the
|
|
231
303
|
// only `.`-digits sequence the grammar admits.
|
|
@@ -235,7 +307,7 @@ const formatter = (fn: string, spec: unknown): ((n: number) => string) => {
|
|
|
235
307
|
try {
|
|
236
308
|
built = FORMAT_LOCALE.format(text);
|
|
237
309
|
} catch {
|
|
238
|
-
throw new
|
|
310
|
+
throw new CatalogRefusal(`${fn}: invalid format specifier ${JSON.stringify(text)}`);
|
|
239
311
|
}
|
|
240
312
|
if (formatterCache.size >= FORMATTER_CACHE_MAX) formatterCache.clear();
|
|
241
313
|
formatterCache.set(text, built);
|
|
@@ -257,7 +329,7 @@ const MAX_DECIMALS = 10;
|
|
|
257
329
|
const digitCount = (fn: string, digits: unknown): number => {
|
|
258
330
|
const n = Number(digits);
|
|
259
331
|
if (!Number.isInteger(n) || n < 0 || n > MAX_DECIMALS) {
|
|
260
|
-
throw new
|
|
332
|
+
throw new CatalogRefusal(
|
|
261
333
|
`${fn}: decimal places must be an integer 0-${MAX_DECIMALS}, got ${String(digits)}`,
|
|
262
334
|
);
|
|
263
335
|
}
|
|
@@ -269,11 +341,11 @@ const digitCount = (fn: string, digits: unknown): number => {
|
|
|
269
341
|
const durationText = (minutes: unknown, minutesPerDay: unknown): string => {
|
|
270
342
|
const perDay = Math.round(formattable("formatDuration", minutesPerDay));
|
|
271
343
|
if (!Number.isFinite(perDay) || perDay <= 0) {
|
|
272
|
-
throw new
|
|
344
|
+
throw new CatalogRefusal(`formatDuration: minutesPerDay must be a positive number, got ${perDay}`);
|
|
273
345
|
}
|
|
274
346
|
const total = Math.round(formattable("formatDuration", minutes));
|
|
275
347
|
if (!Number.isFinite(total)) {
|
|
276
|
-
throw new
|
|
348
|
+
throw new CatalogRefusal(`formatDuration: minutes must be a finite number`);
|
|
277
349
|
}
|
|
278
350
|
const magnitude = Math.abs(total);
|
|
279
351
|
const days = Math.floor(magnitude / perDay);
|
|
@@ -298,7 +370,7 @@ const assertZone = (fn: string, tz: string): string => {
|
|
|
298
370
|
try {
|
|
299
371
|
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
300
372
|
} catch {
|
|
301
|
-
throw new
|
|
373
|
+
throw new CatalogRefusal(`${fn}: unknown IANA time zone ${JSON.stringify(tz)}`);
|
|
302
374
|
}
|
|
303
375
|
return tz;
|
|
304
376
|
};
|
|
@@ -685,6 +757,7 @@ export const CEL_FUNCTIONS: readonly CelFunctionDoc[] = [
|
|
|
685
757
|
"Replace every regex match (RE2 syntax) with a replacement ($1 backrefs); flags like 'i', 'm', 's'.",
|
|
686
758
|
deterministic: true,
|
|
687
759
|
hostBacked: false,
|
|
760
|
+
checkArgs: regexLiteralGuard("regexReplace", 1, 3),
|
|
688
761
|
build: () => (s: string, pattern: string, replacement: string, flags?: string) =>
|
|
689
762
|
compileRe2("regexReplace", pattern, flags).matcher(s).replaceAll(replacement),
|
|
690
763
|
},
|
|
@@ -695,6 +768,7 @@ export const CEL_FUNCTIONS: readonly CelFunctionDoc[] = [
|
|
|
695
768
|
summary: "First whole match of a regex (RE2 syntax), or '' when there is none.",
|
|
696
769
|
deterministic: true,
|
|
697
770
|
hostBacked: false,
|
|
771
|
+
checkArgs: regexLiteralGuard("regexExtract", 1, 2),
|
|
698
772
|
build: () => (s: string, pattern: string, flags?: string) => {
|
|
699
773
|
const m = compileRe2("regexExtract", pattern, flags).matcher(s);
|
|
700
774
|
return m.find() ? (m.group() ?? "") : "";
|
|
@@ -707,6 +781,7 @@ export const CEL_FUNCTIONS: readonly CelFunctionDoc[] = [
|
|
|
707
781
|
summary: "Every whole match of a regex (RE2 syntax), in order.",
|
|
708
782
|
deterministic: true,
|
|
709
783
|
hostBacked: false,
|
|
784
|
+
checkArgs: regexLiteralGuard("regexExtractAll", 1, 2),
|
|
710
785
|
build: () => (s: string, pattern: string, flags?: string) => {
|
|
711
786
|
const m = compileRe2("regexExtractAll", pattern, flags).matcher(s);
|
|
712
787
|
const out: string[] = [];
|
|
@@ -722,6 +797,7 @@ export const CEL_FUNCTIONS: readonly CelFunctionDoc[] = [
|
|
|
722
797
|
"Capture groups of the first regex match (RE2 syntax); empty list when there is no match.",
|
|
723
798
|
deterministic: true,
|
|
724
799
|
hostBacked: false,
|
|
800
|
+
checkArgs: regexLiteralGuard("regexGroups", 1, 2),
|
|
725
801
|
build: () => (s: string, pattern: string, flags?: string) => {
|
|
726
802
|
const m = compileRe2("regexGroups", pattern, flags).matcher(s);
|
|
727
803
|
if (!m.find()) return [];
|
|
@@ -899,7 +975,7 @@ export const CEL_FUNCTIONS: readonly CelFunctionDoc[] = [
|
|
|
899
975
|
summary: "Parse a JSON string into a value (numbers come back as doubles).",
|
|
900
976
|
deterministic: true,
|
|
901
977
|
hostBacked: false,
|
|
902
|
-
build: () => (s: string) =>
|
|
978
|
+
build: () => (s: string) => parseJsonText(s),
|
|
903
979
|
},
|
|
904
980
|
// Paths. The one way to extend a host path: `variables.dataDir.joinPath('reports')`
|
|
905
981
|
// keeps it a `Telo.HostPath` (the analyzer types that overload), where `+`
|