@telorun/templating 0.107.0 → 0.109.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.
Files changed (60) hide show
  1. package/dist/builtins.d.ts +2 -2
  2. package/dist/builtins.d.ts.map +1 -1
  3. package/dist/cel/analyze.d.ts +6 -6
  4. package/dist/cel/analyze.d.ts.map +1 -1
  5. package/dist/cel/analyze.js +138 -183
  6. package/dist/cel/compile.d.ts +47 -17
  7. package/dist/cel/compile.d.ts.map +1 -1
  8. package/dist/cel/compile.js +135 -83
  9. package/dist/cel/diagnose.d.ts +52 -57
  10. package/dist/cel/diagnose.d.ts.map +1 -1
  11. package/dist/cel/diagnose.js +69 -291
  12. package/dist/cel/environment.d.ts +33 -37
  13. package/dist/cel/environment.d.ts.map +1 -1
  14. package/dist/cel/environment.js +54 -86
  15. package/dist/cel/module-call.d.ts +68 -79
  16. package/dist/cel/module-call.d.ts.map +1 -1
  17. package/dist/cel/module-call.js +118 -194
  18. package/dist/cel/value-brands.d.ts +14 -12
  19. package/dist/cel/value-brands.d.ts.map +1 -1
  20. package/dist/cel/value-brands.js +26 -24
  21. package/dist/cel/verdict-codes.d.ts +13 -2
  22. package/dist/cel/verdict-codes.d.ts.map +1 -1
  23. package/dist/cel/verdict-codes.js +20 -1
  24. package/dist/engine.d.ts +4 -4
  25. package/dist/engine.d.ts.map +1 -1
  26. package/dist/engines/cel.d.ts +2 -2
  27. package/dist/engines/cel.d.ts.map +1 -1
  28. package/dist/engines/cel.js +53 -81
  29. package/dist/engines/hole-analysis.d.ts +3 -3
  30. package/dist/engines/hole-analysis.d.ts.map +1 -1
  31. package/dist/engines/interpolate.js +11 -8
  32. package/dist/index.d.ts +4 -5
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +8 -5
  35. package/package.json +4 -4
  36. package/src/builtins.ts +2 -2
  37. package/src/cel/analyze.ts +152 -193
  38. package/src/cel/compile.ts +160 -77
  39. package/src/cel/diagnose.ts +115 -370
  40. package/src/cel/environment.ts +64 -87
  41. package/src/cel/module-call.ts +129 -292
  42. package/src/cel/value-brands.ts +26 -25
  43. package/src/cel/verdict-codes.ts +20 -1
  44. package/src/engine.ts +4 -4
  45. package/src/engines/cel.ts +52 -84
  46. package/src/engines/hole-analysis.ts +3 -3
  47. package/src/engines/interpolate.ts +16 -13
  48. package/src/index.ts +8 -11
  49. package/dist/cel/catalog.d.ts +0 -70
  50. package/dist/cel/catalog.d.ts.map +0 -1
  51. package/dist/cel/catalog.js +0 -1320
  52. package/dist/cel/json-prefix-scan.d.ts +0 -17
  53. package/dist/cel/json-prefix-scan.d.ts.map +0 -1
  54. package/dist/cel/json-prefix-scan.js +0 -160
  55. package/dist/cel/value-identity.d.ts +0 -18
  56. package/dist/cel/value-identity.d.ts.map +0 -1
  57. package/dist/cel/value-identity.js +0 -25
  58. package/src/cel/catalog.ts +0 -1455
  59. package/src/cel/json-prefix-scan.ts +0 -152
  60. package/src/cel/value-identity.ts +0 -34
@@ -1,4 +1,4 @@
1
- import type { ASTNode } from "@marcbachmann/cel-js";
1
+ import { formatType, qualifiedCalls, type CelNode } from "@telorun/cel";
2
2
  import {
3
3
  extractAccessChains,
4
4
  extractCallResultAccesses,
@@ -9,13 +9,7 @@ import {
9
9
  } from "../cel/analyze.js";
10
10
  import { compileExpression, repeatableExpression } from "../cel/compile.js";
11
11
  import { auditCalls, explainUnresolved } from "../cel/diagnose.js";
12
- import {
13
- moduleCallNodes,
14
- moduleNameBindings,
15
- resolveModuleCalls,
16
- unresolvedCallReceivers,
17
- type ModuleCall,
18
- } from "../cel/module-call.js";
12
+ import { moduleNameBindings, unresolvedCallReceivers } from "../cel/module-call.js";
19
13
  import type { CelAnalyzeResult, CelDiagnostic } from "../cel/verdict-codes.js";
20
14
  import type { AnalyzeEnv, CallSite, TemplatingEngine } from "../engine.js";
21
15
 
@@ -39,33 +33,34 @@ export function analyzeCelExpression(source: string, env: AnalyzeEnv): CelAnalyz
39
33
  export function analyzeCelWithTree(
40
34
  source: string,
41
35
  env: AnalyzeEnv,
42
- ): { result: CelAnalyzeResult; ast?: ASTNode } {
36
+ ): { result: CelAnalyzeResult; ast?: CelNode } {
43
37
  const out: CelDiagnostic[] = [];
44
38
 
45
- let parsed: ReturnType<typeof env.celEnv.parse>;
46
- try {
47
- parsed = env.celEnv.parse(source);
48
- } catch (e) {
39
+ // **Reading never throws and never discards what it read**: the first unreadable thing is
40
+ // one ranged diagnostic and the tree keeps the longest prefix, so a scalar an author is
41
+ // mid-way through typing still reports its chains and its calls.
42
+ const parsed = env.celEnv.parse(source);
43
+ if (parsed.diagnostics.length > 0) {
44
+ const first = parsed.diagnostics[0]!;
49
45
  return {
50
46
  result: {
51
- diagnostics: [{ code: "CEL_SYNTAX_ERROR", message: e instanceof Error ? e.message : String(e) }],
47
+ diagnostics: [{ code: "CEL_SYNTAX_ERROR", message: first.message }],
52
48
  calls: [],
53
49
  },
54
50
  };
55
51
  }
56
- const ast: ASTNode = parsed.ast;
52
+ const ast: CelNode = parsed.root;
57
53
 
58
- // Resolution, before anything reads the tree — the audit, the type check and
59
- // every chain walk below all see the resolved shape, so none of them has to
60
- // know a module name from a variable.
61
- // The walks that read resolved calls below are skipped when there are none.
62
- const resolvedCalls = resolveModuleCalls(parsed.ast, env.moduleNames, env.moduleCallType).length > 0;
54
+ // Resolution happened as the expression was READ, over the environment's own namespaces —
55
+ // `qcall` is a node of its own rather than a rewrite — so every walk below already sees
56
+ // the resolved shape and none of them has to know a module name from a variable.
57
+ const resolvedCalls = qualifiedCalls(ast).length > 0;
63
58
 
64
59
  // A name bound inside the expression can never be read once a module owns it:
65
60
  // `Billing.f(x)` under a comprehension variable named `Billing` resolves to
66
61
  // the module. Reported rather than silently shadowed, the rule every other
67
62
  // name in CEL scope follows.
68
- for (const name of moduleNameBindings(parsed.ast, env.moduleNames)) {
63
+ for (const name of moduleNameBindings(ast, env.moduleNames)) {
69
64
  out.push({
70
65
  code: "BINDING_NAME_RESERVED",
71
66
  message:
@@ -75,7 +70,8 @@ export function analyzeCelWithTree(
75
70
  });
76
71
  }
77
72
 
78
- const audit = auditCalls(source, parsed.ast, env.celEnv, env.moduleCallFlags);
73
+ const checked = env.celEnv.check(parsed);
74
+ const audit = auditCalls(source, ast, env.celEnv, env.moduleCallFlags, checked);
79
75
 
80
76
  // Reported whatever the type-checker concludes. A literal argument a guard
81
77
  // will refuse is a defect the manifest states outright, and leaving it to the
@@ -86,15 +82,24 @@ export function analyzeCelWithTree(
86
82
  let type: string | undefined;
87
83
  let checkError: string | undefined;
88
84
  try {
89
- // `parsed.check()`, never `celEnv.check(source)`: the latter RE-PARSES, so
90
- // it would type a tree in which no module call was ever resolved — every
91
- // one of them reported as a missing method on an unknown receiver.
92
- const result = parsed.check();
93
- if (result.valid) type = result.type;
94
- else if (result.error) {
95
- checkError = String((result.error as { message?: string }).message ?? result.error)
96
- .split("\n")[0]!
97
- .trim();
85
+ // The TREE is checked, never the source again: `check(source)` would re-read it, and a
86
+ // tree resolved under another site's names is refused rather than answered about.
87
+ if (checked.valid) type = checked.typeName;
88
+ else {
89
+ // **Every verdict is the engine's, coded and ranged.** This used to be one opaque
90
+ // sentence — `found no matching overload for 'f(...)'` for three unrelated mistakes —
91
+ // which is why a classifier sat beside it rewriting the message. The engine decides an
92
+ // unknown name, a name called in the other form, an unknown field, a type no overload
93
+ // takes and a refusal over a literal argument each where its cause is known, so they
94
+ // come through as they are.
95
+ for (const diagnostic of checked.diagnostics) {
96
+ out.push({
97
+ code: diagnostic.code,
98
+ message: diagnostic.message,
99
+ ...(diagnostic.fix ? { fix: diagnostic.fix } : {}),
100
+ });
101
+ }
102
+ checkError = checked.diagnostics[0]?.message;
98
103
  }
99
104
  } catch (e) {
100
105
  // The checker is now the ONLY type verdict for every CEL expression, so a
@@ -125,22 +130,9 @@ export function analyzeCelWithTree(
125
130
  // this analyzer refuses and the kernel would run fine.
126
131
  // What explaining a rejection already reported, so the context's own chain
127
132
  // check below does not report it twice.
128
- const explained = new Set<string>();
129
- if (checkError !== undefined) {
130
- // `check()` stops at its first problem; the audit enumerates every bad call,
131
- // which is the whole reason it exists as more than a message rewriter.
132
- out.push(...audit.diagnostics);
133
- const unknownFields =
134
- audit.diagnostics.length === 0 ? explainUnknownFields(parsed.ast, env) : [];
135
- out.push(...unknownFields);
136
- for (const d of unknownFields) explained.add(d.message);
137
- if (audit.diagnostics.length === 0 && unknownFields.length === 0) {
138
- out.push({
139
- code: "CEL_TYPE_ERROR",
140
- message: checkError + explainUnresolved(audit.unresolved, env.celEnv) + DYN_HINT(checkError),
141
- });
142
- }
143
- }
133
+ // What the engine already said, so the host's own schema reading below does not say it
134
+ // twice in different words.
135
+ const explained = new Set(out.map((diagnostic) => diagnostic.message));
144
136
 
145
137
  // An undeclared ROOT identifier. cel-js types an unknown name as `dyn` and
146
138
  // accepts it, so `!cel "fff"` type-checked, reached the runtime and resolved
@@ -159,11 +151,11 @@ export function analyzeCelWithTree(
159
151
  // Walked only once a root is unknown, which a correct expression never has.
160
152
  let callReceivers: Set<string> | undefined;
161
153
  const reported = new Set<string>();
162
- for (const chain of extractAccessChains(parsed.ast)) {
154
+ for (const chain of extractAccessChains(ast)) {
163
155
  const root = chain[0];
164
156
  if (!root || reported.has(root) || env.celEnv.hasVariable(root)) continue;
165
157
  reported.add(root);
166
- callReceivers ??= unresolvedCallReceivers(parsed.ast, env.moduleNames);
158
+ callReceivers ??= unresolvedCallReceivers(ast, env.moduleNames);
167
159
  out.push({
168
160
  code: "CEL_UNKNOWN_IDENTIFIER",
169
161
  message:
@@ -179,7 +171,7 @@ export function analyzeCelWithTree(
179
171
  // caller resolves: member access on it is checked exactly as a read off the
180
172
  // context would be, under the call as written.
181
173
  if (resolvedCalls && env.moduleCallResult) {
182
- for (const access of extractCallResultAccesses(parsed.ast)) {
174
+ for (const access of extractCallResultAccesses(ast)) {
183
175
  const schema = env.moduleCallResult(access.qualified);
184
176
  if (!schema) continue;
185
177
  const label = `${access.qualified}(…)`;
@@ -193,12 +185,12 @@ export function analyzeCelWithTree(
193
185
 
194
186
  if (env.contextSchema) {
195
187
  const contextSchema = env.contextSchema as Record<string, any>;
196
- for (const chain of extractAccessChains(parsed.ast)) {
188
+ for (const chain of extractAccessChains(ast)) {
197
189
  const err = validateChainAgainstSchema(chain, contextSchema);
198
190
  if (err && !explained.has(err)) out.push({ code: "CEL_UNKNOWN_FIELD", message: err });
199
191
  }
200
192
 
201
- for (const issue of findNullableAccessIssues(parsed.ast, contextSchema)) {
193
+ for (const issue of findNullableAccessIssues(ast, contextSchema)) {
202
194
  // Index access (member "[index]") attaches without a dot; a named field
203
195
  // attaches with one — so the suggested CEL stays valid either way.
204
196
  const access = issue.member === "[index]" ? issue.member : `.${issue.member}`;
@@ -212,10 +204,12 @@ export function analyzeCelWithTree(
212
204
  return {
213
205
  result: {
214
206
  diagnostics: out,
215
- calls: resolvedCalls ? withCallArguments(audit.calls, parsed.ast) : audit.calls,
207
+ calls: audit.calls,
216
208
  ...(type === undefined ? {} : { type }),
217
- ...(ast.op === "value" && typeof ast.args === "string" ? { stringLiteral: ast.args } : {}),
218
- ...(checkError === undefined ? {} : { readTypes: chainTypes(parsed.ast, env) }),
209
+ ...(ast.kind === "literal" && ast.literal.type === "string"
210
+ ? { stringLiteral: ast.literal.value }
211
+ : {}),
212
+ ...(checkError === undefined ? {} : { readTypes: chainTypes(ast, env) }),
219
213
  },
220
214
  ast,
221
215
  };
@@ -226,7 +220,7 @@ export function analyzeCelWithTree(
226
220
  * reported in its own words. The explain schema is not the checker's
227
221
  * environment, so a chain is reported only when the checker rejects it too;
228
222
  * otherwise the rejection was about something else and keeps its own words. */
229
- function explainUnknownFields(ast: ASTNode, env: AnalyzeEnv): CelDiagnostic[] {
223
+ function explainUnknownFields(ast: CelNode, env: AnalyzeEnv): CelDiagnostic[] {
230
224
  const schema = env.explainSchema?.();
231
225
  if (!schema) return [];
232
226
  const out: CelDiagnostic[] = [];
@@ -242,12 +236,12 @@ function explainUnknownFields(ast: ASTNode, env: AnalyzeEnv): CelDiagnostic[] {
242
236
  }
243
237
 
244
238
  /** The checked type of each distinct plain chain the expression reads. */
245
- function chainTypes(ast: ASTNode, env: AnalyzeEnv): string[] {
239
+ function chainTypes(ast: CelNode, env: AnalyzeEnv): string[] {
246
240
  const types = new Set<string>();
247
241
  for (const chain of extractAccessChains(ast)) {
248
242
  if (chain.includes(INDEX_SEGMENT)) continue;
249
243
  const result = env.celEnv.check(chain.join("."));
250
- if (result.valid && result.type !== undefined) types.add(result.type);
244
+ if (result.valid) types.add(result.typeName);
251
245
  }
252
246
  return [...types];
253
247
  }
@@ -259,32 +253,6 @@ function checkerRejects(chain: readonly string[], env: AnalyzeEnv): boolean {
259
253
  return !env.celEnv.check(named.join(".")).valid;
260
254
  }
261
255
 
262
- /** The audited call sites, each module call carrying its arguments as the type
263
- * check saw them. Matched by position, which is what identifies one call among
264
- * several of the same name. */
265
- function withCallArguments(calls: readonly CallSite[], ast: ASTNode): CallSite[] {
266
- const byStart = new Map<number, ModuleCall>();
267
- for (const { node, call } of moduleCallNodes(ast)) byStart.set(node.start, call);
268
- const chainsByStart = new Map<number, Array<string[] | null>>();
269
- for (const [node, chains] of moduleCallArgumentChains(ast)) chainsByStart.set(node.start, chains);
270
- return calls.map((site) => {
271
- const call = site.moduleCall ? byStart.get(site.start) : undefined;
272
- if (!call) return site;
273
- const chains = chainsByStart.get(site.start);
274
- return {
275
- ...site,
276
- arguments: call.args.map((arg, index) => {
277
- const type = call.argumentTypes?.[index];
278
- const chain = chains?.[index] ?? null;
279
- return {
280
- ...(type !== undefined ? { type } : {}),
281
- ...(chain && !chain.includes(INDEX_SEGMENT) ? { chain } : {}),
282
- };
283
- }),
284
- };
285
- });
286
- }
287
-
288
256
  /** `dyn` in a checker message means an operand whose type is unknown here —
289
257
  * almost always a step result whose invoked resource declares no
290
258
  * `outputType:`. Without this, the reader takes `dyn` for a cast problem. */
@@ -1,4 +1,4 @@
1
- import type { ASTNode, Environment } from "@marcbachmann/cel-js";
1
+ import type { CelEnvironment, CelNode } from "@telorun/cel";
2
2
  import type { CompiledValue } from "@telorun/sdk";
3
3
  import { compileExpression, repeatableExpression } from "../cel/compile.js";
4
4
  import {
@@ -50,7 +50,7 @@ export function analyzeHoles(
50
50
  perHole?: (
51
51
  hole: InterpolationHole,
52
52
  result: CelAnalyzeResult,
53
- ast: ASTNode | undefined,
53
+ ast: CelNode | undefined,
54
54
  ) => readonly CelDiagnostic[],
55
55
  ): CelAnalyzeResult {
56
56
  const reading = readInterpolationHoles(source);
@@ -81,7 +81,7 @@ export function holeRegions(source: string): readonly ExpressionRegion[] {
81
81
 
82
82
  /** Whether every hole of a hole-bearing scalar is repeatable; the literal text
83
83
  * between them always is. */
84
- export function holesRepeatable(source: string, celEnv: Environment): boolean {
84
+ export function holesRepeatable(source: string, celEnv: CelEnvironment): boolean {
85
85
  const reading = readInterpolationHoles(source);
86
86
  return reading.ok && reading.holes.every((h) => repeatableExpression(h.expr, celEnv));
87
87
  }
@@ -1,4 +1,4 @@
1
- import { Environment, EvaluationError, type ASTNode } from "@marcbachmann/cel-js";
1
+ import { CelEnvironment, CelEvaluationError, isCelMap, isCelRecord, type CelNode } from "@telorun/cel";
2
2
  import type { CompiledValue } from "@telorun/sdk";
3
3
  import { nullableValueChain } from "../cel/analyze.js";
4
4
  import { literalFragments, type InterpolationHole } from "../cel/interpolation-holes.js";
@@ -71,7 +71,7 @@ export const interpolateEngine: TemplatingEngine = {
71
71
  function holeVerdict(
72
72
  hole: InterpolationHole,
73
73
  result: CelAnalyzeResult,
74
- ast: ASTNode | undefined,
74
+ ast: CelNode | undefined,
75
75
  env: AnalyzeEnv,
76
76
  ): readonly CelDiagnostic[] {
77
77
  if (ast && env.contextSchema) {
@@ -98,17 +98,17 @@ function holeVerdict(
98
98
  ];
99
99
  }
100
100
 
101
- const CONVERTIBLE = new WeakMap<Environment, ReadonlySet<string>>();
101
+ const CONVERTIBLE = new WeakMap<CelEnvironment, ReadonlySet<string>>();
102
102
 
103
103
  /** The types a `string()` overload of `env` accepts, `dyn` among them — read
104
104
  * off the registered overloads, so the check is the one evaluation applies. */
105
- function convertibleTypes(env: Environment): ReadonlySet<string> {
105
+ function convertibleTypes(env: CelEnvironment): ReadonlySet<string> {
106
106
  const cached = CONVERTIBLE.get(env);
107
107
  if (cached) return cached;
108
108
  const types = new Set<string>(["dyn"]);
109
- for (const fn of env.getDefinitions().functions) {
110
- if (fn.name === "string" && fn.receiverType === null && fn.params?.length === 1) {
111
- types.add(fn.params[0]!.type);
109
+ for (const fn of env.definitions().functions) {
110
+ if (fn.name === "string" && fn.receiverType === null && fn.parameters.length === 1) {
111
+ types.add(fn.parameters[0]!);
112
112
  }
113
113
  }
114
114
  CONVERTIBLE.set(env, types);
@@ -117,19 +117,19 @@ function convertibleTypes(env: Environment): ReadonlySet<string> {
117
117
 
118
118
  type Conversion = (value: unknown, hole: InterpolationHole, source: string) => string;
119
119
 
120
- const CONVERSIONS = new WeakMap<Environment, Conversion>();
120
+ const CONVERSIONS = new WeakMap<CelEnvironment, Conversion>();
121
121
 
122
122
  /** CEL's `string(v)` in `env`, with every overload the environment registers. */
123
- function stringConversion(env: Environment): Conversion {
123
+ function stringConversion(env: CelEnvironment): Conversion {
124
124
  const cached = CONVERSIONS.get(env);
125
125
  if (cached) return cached;
126
- const program = env.parse("string(value)") as (ctx: { value: unknown }) => unknown;
126
+ const program = env.compile("string(value)");
127
127
  const conversion: Conversion = (value, hole, source) => {
128
128
  if (typeof value === "string") return value;
129
129
  try {
130
- return program({ value }) as string;
130
+ return program.evaluate({ value }) as string;
131
131
  } catch (error) {
132
- if (!(error instanceof EvaluationError)) throw error;
132
+ if (!(error instanceof CelEvaluationError)) throw error;
133
133
  throw celVerdictError(
134
134
  "ERR_INTERPOLATION_HOLE_NOT_CONVERTIBLE",
135
135
  `the hole '\${{ ${hole.expr} }}' at offset ${hole.start} of !interpolate ${JSON.stringify(source)} ` +
@@ -145,6 +145,9 @@ function stringConversion(env: Environment): Conversion {
145
145
  function runtimeTypeOf(value: unknown): string {
146
146
  if (value === null || value === undefined) return "null";
147
147
  if (Array.isArray(value)) return "a list";
148
- if (value instanceof Map || Object.getPrototypeOf(value) === Object.prototype) return "a map";
148
+ // Both of the value domain's map representations, asked of the domain rather than of the
149
+ // prototype: a branded value is a plain object, so a prototype test named an optional, a
150
+ // type and every host named type "a map".
151
+ if (isCelMap(value) || isCelRecord(value)) return "a map";
149
152
  return `a value of type ${(value as object).constructor?.name ?? typeof value}`;
150
153
  }
package/src/index.ts CHANGED
@@ -2,17 +2,14 @@ export {
2
2
  buildCelEnvironment,
3
3
  buildCelLanguageEnvironment,
4
4
  celBuiltinFunctions,
5
- deriveSignatures,
5
+ celFunctionCatalog,
6
6
  type CelHandlers,
7
7
  } from "./cel/environment.js";
8
- export {
9
- celFunctionCatalog,
10
- CEL_FUNCTIONS,
11
- type CelFunctionInfo,
12
- type CelFunctionDoc,
13
- type CelFunctionCategory,
14
- } from "./cel/catalog.js";
15
- export { compileExpression } from "./cel/compile.js";
8
+ // `namespaceDispatchOf` is the ONE adapter a host's dispatch table crosses to
9
+ // become the engine's namespace seam — exported because the analyzer evaluates
10
+ // rule conditions and function bodies through the same table, and a second
11
+ // adapter is what let it convert arguments differently from the kernel.
12
+ export { compileExpression, namespaceDispatchOf } from "./cel/compile.js";
16
13
  export { registerValueBrands } from "./cel/value-brands.js";
17
14
  export {
18
15
  interpolationShape,
@@ -31,7 +28,6 @@ export {
31
28
  export {
32
29
  auditCalls,
33
30
  explainUnresolved,
34
- functionIndex,
35
31
  type CallAudit,
36
32
  type ModuleCallFlags,
37
33
  } from "./cel/diagnose.js";
@@ -41,9 +37,10 @@ export {
41
37
  // `ModuleCallTypeResolver` is here because `AnalyzeEnv` names it: an exported
42
38
  // interface whose field type cannot be named is not usable from outside.
43
39
  export {
40
+ celNamespaceNames,
44
41
  MODULE_CALL_DISPATCH_KEY,
42
+ moduleCallNames,
45
43
  moduleCallOf,
46
- resolveModuleCalls,
47
44
  type ModuleCallDispatch,
48
45
  type ModuleCallTypeResolver,
49
46
  } from "./cel/module-call.js";
@@ -1,70 +0,0 @@
1
- /** Host-injected functions that need platform APIs the templating package must
2
- * not import directly (Node `crypto` / `Buffer`), keeping it browser-safe. The
3
- * kernel supplies real implementations; the analyzer omits them (the stubs
4
- * throw, since static analysis never executes these). */
5
- export interface CelHandlers {
6
- sha256: (s: string) => string;
7
- md5: (s: string) => string;
8
- sha1: (s: string) => string;
9
- sha512: (s: string) => string;
10
- hmac: (algorithm: string, key: string, message: string) => string;
11
- base64Encode: (s: string) => string;
12
- base64Decode: (s: string) => string;
13
- json: (value: unknown) => string;
14
- /** Join a relative path onto a base with the HOST's path rules. */
15
- joinPath: (base: string, relative: string) => string;
16
- }
17
- /** RE2's parse-error kinds, in RE2's own words — the closed vocabulary an
18
- * invalid-pattern refusal ends with, so every engine words one identically. */
19
- export declare const RE2_PATTERN_ERROR_KINDS: readonly string[];
20
- export type CelFunctionCategory = "conversion" | "time" | "uuid" | "string" | "math" | "collection" | "json" | "encoding" | "hashing" | "formatting" | "null";
21
- /** One entry in the CEL standard library — the single source of truth that both
22
- * registers the function (`build`) and documents it (everything else). `telo
23
- * cel functions` and `celFunctionCatalog()` read the metadata; `buildCelEnvironment`
24
- * calls `build`. */
25
- export interface CelFunctionDoc {
26
- /** Bare function name (`nowIso`, `uuidv4`). */
27
- readonly name: string;
28
- /** Human-facing signature for docs (`nowIso(tz?): string`). May use `?` for
29
- * optional args even though cel-js itself has no optional syntax. */
30
- readonly signature: string;
31
- /** Actual cel-js signatures to register — one per arity for an overloaded
32
- * function. When omitted, `deriveSignatures(signature)` is used: if the
33
- * signature contains `type?`-marked optional params (e.g. `fn(string?): T`),
34
- * it auto-expands to one registration per arity. Set `register` explicitly
35
- * only when the auto-derivation is insufficient. */
36
- readonly register?: readonly string[];
37
- readonly category: CelFunctionCategory;
38
- readonly summary: string;
39
- /** False → re-evaluates per call; in an `x-telo-eval: compile` field it bakes
40
- * once at load. */
41
- readonly deterministic: boolean;
42
- /** Needs a `CelHandlers` implementation (Node `crypto` / `Buffer`); the
43
- * analyzer's stub throws if such a function is actually evaluated. */
44
- readonly hostBacked: boolean;
45
- readonly build: (h: CelHandlers) => (...args: any[]) => unknown;
46
- /**
47
- * Check the arguments that were written as LITERALS, at analysis time.
48
- *
49
- * A type is all a signature can constrain, so a guard over a value —
50
- * an unparseable format specifier, a decimal count out of range, a day length
51
- * of zero, an unknown IANA zone — fires only when the expression is evaluated.
52
- * That puts a defect the manifest states in plain sight behind a run, which is
53
- * the opposite of what static analysis is for.
54
- *
55
- * `literals[i]` is the value of argument `i` when it was written as a literal,
56
- * and `undefined` when it is an expression whose value is not statically
57
- * known — so a checker MUST skip an `undefined` rather than judge it.
58
- * Returns a message, or `undefined` when there is nothing to report.
59
- *
60
- * Implementations call the SAME guard the runtime calls, so the static and
61
- * dynamic answers cannot drift into disagreement.
62
- */
63
- readonly checkArgs?: (literals: readonly unknown[]) => string | undefined;
64
- }
65
- /** Public, build-free view of a catalog entry (for `--json` / docs). */
66
- export type CelFunctionInfo = Omit<CelFunctionDoc, "build">;
67
- export declare const CEL_FUNCTIONS: readonly CelFunctionDoc[];
68
- /** Build-free catalog for the CLI / docs (`telo cel functions`). */
69
- export declare function celFunctionCatalog(): CelFunctionInfo[];
70
- //# sourceMappingURL=catalog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/cel/catalog.ts"],"names":[],"mappings":"AAMA;;;0DAG0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9B,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9B,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IAClE,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IACjC,mEAAmE;IACnE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACtD;AA0BD;gFACgF;AAChF,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAepD,CAAC;AAuCF,MAAM,MAAM,mBAAmB,GAC3B,YAAY,GACZ,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,MAAM,GACN,UAAU,GACV,SAAS,GACT,YAAY,GACZ,MAAM,CAAC;AAEX;;;qBAGqB;AACrB,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;0EACsE;IACtE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;yDAIqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;wBACoB;IACpB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC;2EACuE;IACvE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;IAChE;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,KAAK,MAAM,GAAG,SAAS,CAAC;CAC3E;AA4CD,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AA8Z5D,eAAO,MAAM,aAAa,EAAE,SAAS,cAAc,EA+zBlD,CAAC;AAEF,oEAAoE;AACpE,wBAAgB,kBAAkB,IAAI,eAAe,EAAE,CAEtD"}