@telorun/templating 0.20.0 → 0.21.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 (40) hide show
  1. package/dist/cel/analyze.d.ts +26 -0
  2. package/dist/cel/analyze.d.ts.map +1 -1
  3. package/dist/cel/analyze.js +114 -8
  4. package/dist/cel/catalog.d.ts.map +1 -1
  5. package/dist/cel/catalog.js +10 -0
  6. package/dist/cel/compile.d.ts +9 -3
  7. package/dist/cel/compile.d.ts.map +1 -1
  8. package/dist/cel/compile.js +25 -11
  9. package/dist/cel/diagnose.d.ts +10 -1
  10. package/dist/cel/diagnose.d.ts.map +1 -1
  11. package/dist/cel/diagnose.js +42 -6
  12. package/dist/cel/environment.d.ts.map +1 -1
  13. package/dist/cel/environment.js +2 -0
  14. package/dist/cel/module-call.d.ts +108 -0
  15. package/dist/cel/module-call.d.ts.map +1 -0
  16. package/dist/cel/module-call.js +245 -0
  17. package/dist/cel/value-identity.d.ts +18 -0
  18. package/dist/cel/value-identity.d.ts.map +1 -0
  19. package/dist/cel/value-identity.js +25 -0
  20. package/dist/engine.d.ts +66 -0
  21. package/dist/engine.d.ts.map +1 -1
  22. package/dist/engines/cel.d.ts.map +1 -1
  23. package/dist/engines/cel.js +87 -6
  24. package/dist/engines/sql.d.ts.map +1 -1
  25. package/dist/engines/sql.js +5 -1
  26. package/dist/index.d.ts +3 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +7 -1
  29. package/package.json +3 -3
  30. package/src/cel/analyze.ts +131 -9
  31. package/src/cel/catalog.ts +10 -0
  32. package/src/cel/compile.ts +32 -12
  33. package/src/cel/diagnose.ts +56 -6
  34. package/src/cel/environment.ts +3 -0
  35. package/src/cel/module-call.ts +369 -0
  36. package/src/cel/value-identity.ts +34 -0
  37. package/src/engine.ts +72 -0
  38. package/src/engines/cel.ts +104 -6
  39. package/src/engines/sql.ts +5 -1
  40. package/src/index.ts +20 -1
@@ -0,0 +1 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uBAAuB,CACrC,GAAG,EAAE,OAAO,GAAG,SAAS,EACxB,WAAW,GAAE,WAAW,CAAC,MAAM,CAAY,GAC1C,GAAG,CAAC,MAAM,CAAC,CAkBb;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,GAAG,SAAS,EACxB,WAAW,GAAE,WAAW,CAAC,MAAM,CAAY,GAC1C,MAAM,EAAE,CAUV"}
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Activation key the per-scope dispatch table is read from.
3
+ *
4
+ * `@` and `:` are outside CEL's identifier grammar and there is no other way to
5
+ * reach the activation, so no expression can name this — a spellable dispatcher
6
+ * would let an author call past the export gate and past the dependency edge
7
+ * that orders the callee before its caller.
8
+ */
9
+ export const MODULE_CALL_DISPATCH_KEY = "@telo:module-functions";
10
+ /** cel-js's `ASTNode` is a union over its operators, so it has no statically
11
+ * known members to extend — the internals are read through this cast, in one
12
+ * place. */
13
+ const metaOf = (node) => node;
14
+ export function moduleCallOf(node) {
15
+ const macro = metaOf(node).meta?.macro;
16
+ return macro?.teloModuleCall === true
17
+ ? {
18
+ qualified: macro.qualified,
19
+ args: macro.args,
20
+ ...(macro.argumentTypes ? { argumentTypes: macro.argumentTypes } : {}),
21
+ }
22
+ : undefined;
23
+ }
24
+ /** Message for a call nothing has bound. Not a fallback value: a call that
25
+ * cannot reach its function has no result, and inventing one would make a
26
+ * missing export read as a null. */
27
+ export function unboundModuleCallMessage(qualified) {
28
+ const dot = qualified.indexOf(".");
29
+ const receiver = qualified.slice(0, dot);
30
+ const fn = qualified.slice(dot + 1);
31
+ return (`unbound function '${qualified}' — nothing is bound under that name in this scope. ` +
32
+ `'${receiver}' must be an imports: alias (or Self, or this module's own name) whose ` +
33
+ `module declares a callable named '${fn}' and exports it.`);
34
+ }
35
+ const NO_NAMES = new Set();
36
+ /**
37
+ * Rewrite every module call in `ast` in place and report them in source order.
38
+ *
39
+ * Returns the qualified names as written (`["Billing.format", "Self.y"]`), which
40
+ * is what a compiled value carries so no consumer has to re-parse to learn what
41
+ * an expression calls. Idempotent: a node already resolved is rewritten once and
42
+ * reported again, so two passes over one tree agree about what it calls.
43
+ */
44
+ export function resolveModuleCalls(ast, moduleNames = NO_NAMES, typeOf) {
45
+ const calls = [];
46
+ if (ast && moduleNames.size > 0)
47
+ visit(ast, moduleNames, typeOf, calls);
48
+ return calls;
49
+ }
50
+ function visit(node, moduleNames, typeOf, calls) {
51
+ // Already resolved: rewritten once, reported every time, so the return value
52
+ // is what the TREE calls rather than what this pass happened to change.
53
+ const resolved = moduleCallOf(node);
54
+ if (resolved) {
55
+ calls.push(resolved.qualified);
56
+ for (const arg of resolved.args)
57
+ visit(arg, moduleNames, typeOf, calls);
58
+ return;
59
+ }
60
+ const receiver = moduleCallReceiver(node, moduleNames);
61
+ if (receiver) {
62
+ const [method, , args] = node.args;
63
+ const qualified = `${receiver}.${method}`;
64
+ calls.push(qualified);
65
+ rewrite(node, qualified, args, typeOf);
66
+ // The receiver names a MODULE, not a value, so it is not descended into:
67
+ // that is what keeps it out of every access chain, out of `refs`, and out
68
+ // of the undeclared-root check.
69
+ for (const arg of args)
70
+ visit(arg, moduleNames, typeOf, calls);
71
+ return;
72
+ }
73
+ descend(node, (child) => visit(child, moduleNames, typeOf, calls));
74
+ }
75
+ /** The module name a node's receiver is, or undefined when the node is not a
76
+ * module call. `a.b.c(x)` is not one — its receiver is a member access, not a
77
+ * bare identifier. */
78
+ function moduleCallReceiver(node, moduleNames) {
79
+ if (node.op !== "rcall" || !Array.isArray(node.args))
80
+ return undefined;
81
+ const [method, receiver, args] = node.args;
82
+ if (typeof method !== "string" || !Array.isArray(args))
83
+ return undefined;
84
+ if (!isNode(receiver) || receiver.op !== "id")
85
+ return undefined;
86
+ const name = receiver.args;
87
+ return moduleNames.has(name) ? name : undefined;
88
+ }
89
+ function rewrite(node, qualified, args, typeOf) {
90
+ const macro = {
91
+ teloModuleCall: true,
92
+ qualified,
93
+ args,
94
+ typeCheck(chk, m, ctx) {
95
+ // The arguments are checked in the CURRENT context, so a mistake inside
96
+ // one is reported where it is written — and each argument's type is kept,
97
+ // so whoever knows the callee's signature can compare against it.
98
+ m.argumentTypes = m.args.map((arg) => typeNameOf(chk.check(arg, ctx)));
99
+ // cel-js derives an rcall's asyncness from `receiverWithArgs`, which only
100
+ // the rcall checker this macro replaces fills in — so it is stated: the
101
+ // dispatch is synchronous, so the node is async exactly when one of its
102
+ // arguments is. Asked only now, once each argument is checked: an
103
+ // argument's answer is cached on first reading, and read before its own
104
+ // check it is the conservative `true` for every operator and call.
105
+ metaOf(node).setMeta("async", m.args.some((arg) => arg.maybeAsync === true));
106
+ const declared = typeOf?.(m.qualified);
107
+ return declared === undefined ? chk.dynType : chk.getType(declared);
108
+ },
109
+ evaluate(ev, m, ctx) {
110
+ const table = ctx.getValue(MODULE_CALL_DISPATCH_KEY);
111
+ const fn = table?.get(m.qualified);
112
+ if (!fn)
113
+ throw new Error(unboundModuleCallMessage(m.qualified));
114
+ const values = m.args.map((arg) => ev.eval(arg, ctx));
115
+ // A callable's `call` is synchronous; an ARGUMENT need not be, and every
116
+ // other dispatch in cel-js settles its operands first. Handing a pending
117
+ // Promise to the function instead would pass it a value of the wrong type
118
+ // with nothing reported.
119
+ return values.some((value) => value instanceof Promise)
120
+ ? Promise.all(values).then((settled) => fn(settled))
121
+ : fn(values);
122
+ },
123
+ };
124
+ metaOf(node)
125
+ // A comprehension macro expands into an `alternate`, which cel-js consults
126
+ // BEFORE `macro`. Left in place, `Billing.map(i, i)` would evaluate as a
127
+ // comprehension over an identifier rather than as the module call it names.
128
+ .setMeta("alternate", undefined)
129
+ .setMeta("macro", macro);
130
+ }
131
+ /** Every resolved module call in `ast` with its node, outermost first. */
132
+ export function moduleCallNodes(ast) {
133
+ const out = [];
134
+ if (ast)
135
+ walk(ast);
136
+ return out;
137
+ function walk(node) {
138
+ const call = moduleCallOf(node);
139
+ if (call) {
140
+ out.push({ node, call });
141
+ for (const arg of call.args)
142
+ walk(arg);
143
+ return;
144
+ }
145
+ descend(node, walk);
146
+ }
147
+ }
148
+ /** The name of a checker type object (`int`, `list<string>`), or `dyn` for one
149
+ * that carries none. */
150
+ function typeNameOf(type) {
151
+ const name = type?.name;
152
+ return typeof name === "string" ? name : "dyn";
153
+ }
154
+ /**
155
+ * Bare identifiers used as a call receiver that resolved to NO module name.
156
+ *
157
+ * `Foo.bar()` with no `Foo` import is an unknown identifier like any other, but
158
+ * the repair is not the usual one — it needs an `imports:` alias, not a
159
+ * different spelling — so the caller that reports the root says so.
160
+ */
161
+ export function unresolvedCallReceivers(ast, moduleNames = NO_NAMES) {
162
+ const out = new Set();
163
+ if (ast)
164
+ walk(ast);
165
+ return out;
166
+ function walk(node) {
167
+ if (moduleCallOf(node)) {
168
+ for (const arg of node.args[2])
169
+ walk(arg);
170
+ return;
171
+ }
172
+ if (node.op === "rcall" && Array.isArray(node.args)) {
173
+ const receiver = node.args[1];
174
+ if (isNode(receiver) && receiver.op === "id" && !moduleNames.has(receiver.args)) {
175
+ out.add(receiver.args);
176
+ }
177
+ }
178
+ descend(node, walk);
179
+ }
180
+ }
181
+ /**
182
+ * Names bound INSIDE the expression — a comprehension variable, a `cel.bind`
183
+ * name — that collide with one of the module's names.
184
+ *
185
+ * Such a binding is unreachable through a call: `Billing.f(x)` inside it
186
+ * resolves to the module, never to the bound value. Reported as a reserved name
187
+ * rather than silently shadowed, which is the rule every other name in CEL
188
+ * scope already follows.
189
+ */
190
+ export function moduleNameBindings(ast, moduleNames = NO_NAMES) {
191
+ const out = [];
192
+ if (ast && moduleNames.size > 0)
193
+ walk(ast);
194
+ return [...new Set(out)];
195
+ function walk(node) {
196
+ const bound = boundNameOf(node);
197
+ if (bound !== undefined && moduleNames.has(bound))
198
+ out.push(bound);
199
+ descend(node, walk);
200
+ }
201
+ }
202
+ /** The name a binding form introduces: `cel.bind(<name>, …)`'s first argument,
203
+ * or a comprehension macro's iteration variable. */
204
+ function boundNameOf(node) {
205
+ if (node.op !== "rcall" || !Array.isArray(node.args))
206
+ return undefined;
207
+ if (moduleCallOf(node))
208
+ return undefined;
209
+ const [method, receiver, args] = node.args;
210
+ if (!Array.isArray(args) || args.length === 0)
211
+ return undefined;
212
+ const first = args[0];
213
+ if (!isNode(first) || first.op !== "id")
214
+ return undefined;
215
+ if (method === "bind") {
216
+ return isNode(receiver) && receiver.op === "id" && receiver.args === "cel"
217
+ ? first.args
218
+ : undefined;
219
+ }
220
+ return COMPREHENSION_METHODS.has(method) ? first.args : undefined;
221
+ }
222
+ /** cel-js's comprehension macros, which bind their first argument as the
223
+ * iteration variable. Mirrors the set `analyze.ts` walks with. */
224
+ const COMPREHENSION_METHODS = new Set(["filter", "map", "exists", "all", "exists_one"]);
225
+ /** Generic descent over a node's operands — an array, a single node, or an
226
+ * array of arrays (a map literal's entries). */
227
+ function descend(node, fn) {
228
+ const args = node.args;
229
+ if (Array.isArray(args)) {
230
+ for (const arg of args) {
231
+ if (isNode(arg))
232
+ fn(arg);
233
+ else if (Array.isArray(arg))
234
+ for (const item of arg)
235
+ if (isNode(item))
236
+ fn(item);
237
+ }
238
+ return;
239
+ }
240
+ if (isNode(args))
241
+ fn(args);
242
+ }
243
+ function isNode(v) {
244
+ return v !== null && typeof v === "object" && "op" in v;
245
+ }
@@ -0,0 +1,18 @@
1
+ /** The classes the CEL value domain is typed by. */
2
+ export interface CelValueClasses {
3
+ readonly Duration: abstract new (...args: never[]) => unknown;
4
+ readonly UnsignedInt: abstract new (...args: never[]) => unknown;
5
+ }
6
+ /**
7
+ * Refuse to run with a CEL engine whose values are not the SDK's.
8
+ *
9
+ * cel-js dispatches by constructor, so a second installed copy of it gives the
10
+ * engine a `Duration` / `UnsignedInt` no controller can construct: every value a
11
+ * controller builds from `@telorun/sdk` would fail `+`, `type()` and every
12
+ * overload, at the first expression that meets one. Checked once, where the
13
+ * engine is loaded, so the cause is named before anything evaluates.
14
+ */
15
+ export declare function assertCelValueIdentity(classes: CelValueClasses): void;
16
+ /** The SDK's classes — the identity every Telo package and controller shares. */
17
+ export declare const SDK_CEL_VALUE_CLASSES: CelValueClasses;
18
+ //# sourceMappingURL=value-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value-identity.d.ts","sourceRoot":"","sources":["../../src/cel/value-identity.ts"],"names":[],"mappings":"AAGA,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;IAC9D,QAAQ,CAAC,WAAW,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;CAClE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAYrE;AAED,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,EAAE,eAA2C,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { Environment } from "@marcbachmann/cel-js";
2
+ import { Duration, UnsignedInt } from "@telorun/sdk";
3
+ /**
4
+ * Refuse to run with a CEL engine whose values are not the SDK's.
5
+ *
6
+ * cel-js dispatches by constructor, so a second installed copy of it gives the
7
+ * engine a `Duration` / `UnsignedInt` no controller can construct: every value a
8
+ * controller builds from `@telorun/sdk` would fail `+`, `type()` and every
9
+ * overload, at the first expression that meets one. Checked once, where the
10
+ * engine is loaded, so the cause is named before anything evaluates.
11
+ */
12
+ export function assertCelValueIdentity(classes) {
13
+ const probe = new Environment();
14
+ const duration = probe.evaluate("duration('1s')");
15
+ const uint = probe.evaluate("1u");
16
+ if (duration instanceof classes.Duration && uint instanceof classes.UnsignedInt)
17
+ return;
18
+ throw new Error("@telorun/templating's CEL engine is a different copy of @marcbachmann/cel-js than the one " +
19
+ "@telorun/sdk exports Duration and UnsignedInt from, so a duration or uint a controller " +
20
+ "builds would be rejected by every CEL expression. Two copies of @marcbachmann/cel-js are " +
21
+ "installed: every Telo package pins the same exact version, so deduplicate the install " +
22
+ "(`pnpm dedupe` / `npm dedupe`) until one remains.");
23
+ }
24
+ /** The SDK's classes — the identity every Telo package and controller shares. */
25
+ export const SDK_CEL_VALUE_CLASSES = { Duration, UnsignedInt };
package/dist/engine.d.ts CHANGED
@@ -1,10 +1,24 @@
1
1
  import type { Environment } from "@marcbachmann/cel-js";
2
2
  import type { CompiledValue } from "@telorun/sdk";
3
+ import type { ModuleCallFlags } from "./cel/diagnose.js";
4
+ import type { ModuleCallTypeResolver } from "./cel/module-call.js";
3
5
  /** Compile-time environment passed to `engine.compile`. Engines that need to
4
6
  * parse against a CEL environment (the `cel` engine) read it from `celEnv`;
5
7
  * engines that resolve fully at compile time (`literal`) ignore it. */
6
8
  export interface CompileEnv {
7
9
  readonly celEnv: Environment;
10
+ /**
11
+ * The names a call's receiver may be for the call to resolve as a MODULE
12
+ * call — the declaring module's `imports:` keys, `Self`, its `metadata.name`
13
+ * and `Telo`.
14
+ *
15
+ * An INPUT, not something an engine derives: they are known from the module's
16
+ * own file before any import resolves, and a partial compiles with the names
17
+ * of the module that includes it. Absent means "no module names here", which
18
+ * leaves every call an ordinary catalog call — the reading every caller had
19
+ * before module functions existed.
20
+ */
21
+ readonly moduleNames?: ReadonlySet<string>;
8
22
  }
9
23
  /** Analyze-time environment passed to `engine.analyze`. The walker resolves
10
24
  * the path-specific effective context (kernel globals merged in, x-telo-context
@@ -31,6 +45,33 @@ export interface AnalyzeEnv {
31
45
  * did before it existed.
32
46
  */
33
47
  readonly rootsDeclared?: boolean;
48
+ /** The declaring module's names — see {@link CompileEnv.moduleNames}. An
49
+ * analysis that does not supply them reads a module call as an ordinary
50
+ * method call, so the compile and analyze halves must be given the same set
51
+ * or they disagree about what the expression says. */
52
+ readonly moduleNames?: ReadonlySet<string>;
53
+ /** The type a module call yields, when the caller can resolve one. Absent
54
+ * leaves every module call `dyn` — its arguments are still checked where
55
+ * they are written, and nothing is claimed about its result. */
56
+ readonly moduleCallType?: ModuleCallTypeResolver;
57
+ /** The JSON Schema a module call's RESULT carries, when the caller can resolve
58
+ * one — what member access on the result (`Billing.total(xs).amont`) is
59
+ * checked against. Absent leaves such access unchecked. */
60
+ readonly moduleCallResult?: (qualified: string) => Record<string, unknown> | undefined;
61
+ /** The derived flags of the module function a qualified call reaches, carried
62
+ * onto its {@link CallSite} — boolean wherever the call resolves, so a
63
+ * consumer reading `deterministic === false` sees every impure one. */
64
+ readonly moduleCallFlags?: ModuleCallFlags;
65
+ /**
66
+ * Whether a bare identifier could denote a MODULE at all.
67
+ *
68
+ * The host's naming rule, which this package does not own: an unknown call
69
+ * receiver is repaired by an `imports:` alias only where the name could be
70
+ * one, and telling the author of `dbb.query(1)` to add an import is advice
71
+ * for a different mistake. Absent leaves the unknown-identifier message
72
+ * unqualified, which is what it says with no host rule to consult.
73
+ */
74
+ readonly couldNameModule?: (name: string) => boolean;
34
75
  }
35
76
  /** A mechanically applicable repair for a diagnostic. `replacement` is the
36
77
  * **whole analyzed source**, corrected — never a fragment — so a consumer can
@@ -63,11 +104,26 @@ export interface EngineDiagnostic {
63
104
  * call), and policy that depends on manifest context does not belong in a
64
105
  * templating engine. */
65
106
  export interface CallSite {
107
+ /** The name called. For a module call this is the QUALIFIED name as written
108
+ * (`Billing.format`), which is what keeps a module function and a catalog
109
+ * function of the same bare name apart in every consumer that keys on it. */
66
110
  readonly name: string;
67
111
  /** How it was written — `f(x)` vs `x.f()`. */
68
112
  readonly form: "global" | "receiver";
113
+ /** Set when the receiver is one of the declaring module's names, so the call
114
+ * resolved to a module function rather than to the catalog. Its determinism
115
+ * and host-backedness are not this engine's to know — they follow from the
116
+ * callable the name resolves to — so they are carried only as the host's
117
+ * {@link AnalyzeEnv.moduleCallFlags} reports them. */
118
+ readonly moduleCall?: true;
69
119
  /** Argument count as written; excludes the receiver. */
70
120
  readonly arity: number;
121
+ /** For a module call, each argument as the analysis saw it: the type the
122
+ * checker gave it (absent when the expression did not type-check) and, when
123
+ * the argument is a plain member chain (`variables.price`), that chain — so a
124
+ * caller holding the callee's signature can compare a declared shape rather
125
+ * than a CEL type alone. */
126
+ readonly arguments?: readonly CallArgument[];
71
127
  /** Offsets of the whole call within the analyzed source. */
72
128
  readonly start: number;
73
129
  readonly end: number;
@@ -75,6 +131,16 @@ export interface CallSite {
75
131
  * name resolves to nothing, or to a function carrying no determinism
76
132
  * metadata — absent is not "deterministic". */
77
133
  readonly deterministic?: boolean;
134
+ /** Whether the resolved function is supplied by the host rather than written
135
+ * in CEL — a catalog function the kernel implements natively, or a module
136
+ * function reaching native code — so nothing without that host can run it.
137
+ * `undefined` under the same rule as {@link CallSite.deterministic}. */
138
+ readonly hostBacked?: boolean;
139
+ }
140
+ /** One argument of a module call. */
141
+ export interface CallArgument {
142
+ readonly type?: string;
143
+ readonly chain?: readonly string[];
78
144
  }
79
145
  /** What one `analyze` call establishes about one source. Everything derivable
80
146
  * from the expression alone is derived here, once; everything that needs
@@ -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;AAElD;;wEAEwE;AACxE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAC9B;AAED;;;;;;;;;eASe;AACf,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACvD;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;;;;;;;;;0EAa0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;oDAEoD;AACpD,MAA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,EAAE,GAAG,EAAE,UAAU,GAAG,aAAa,CA2GnF;AAYD;yCACyC;AACzC,eAAO,MAAM,SAAS,EAAE,gBAWvB,CAAC"}
1
+ {"version":3,"file":"cel.d.ts","sourceRoot":"","sources":["../../src/engines/cel.ts"],"names":[],"mappings":"AAkBA,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,CAkKnF;AAsCD;yCACyC;AACzC,eAAO,MAAM,SAAS,EAAE,gBAWvB,CAAC"}
@@ -1,6 +1,7 @@
1
- import { extractAccessChains, findNullableAccessIssues, validateChainAgainstSchema, } from "../cel/analyze.js";
1
+ import { extractAccessChains, extractCallResultAccesses, findNullableAccessIssues, INDEX_SEGMENT, moduleCallArgumentChains, validateChainAgainstSchema, } from "../cel/analyze.js";
2
2
  import { compileExpression } from "../cel/compile.js";
3
3
  import { auditCalls, explainUnresolved } from "../cel/diagnose.js";
4
+ import { moduleCallNodes, moduleNameBindings, resolveModuleCalls, unresolvedCallReceivers, } from "../cel/module-call.js";
4
5
  /** Statically analyze one CEL expression against the effective context schema:
5
6
  * parse → classify every call → type-check → validate member-access chains →
6
7
  * flag nullable access. Single source of truth shared by the `!cel` engine
@@ -24,7 +25,24 @@ export function analyzeCelExpression(source, env) {
24
25
  calls: [],
25
26
  };
26
27
  }
27
- const audit = auditCalls(source, parsed.ast, env.celEnv);
28
+ // Resolution, before anything reads the tree — the audit, the type check and
29
+ // every chain walk below all see the resolved shape, so none of them has to
30
+ // know a module name from a variable.
31
+ // The walks that read resolved calls below are skipped when there are none.
32
+ const resolvedCalls = resolveModuleCalls(parsed.ast, env.moduleNames, env.moduleCallType).length > 0;
33
+ // A name bound inside the expression can never be read once a module owns it:
34
+ // `Billing.f(x)` under a comprehension variable named `Billing` resolves to
35
+ // the module. Reported rather than silently shadowed, the rule every other
36
+ // name in CEL scope follows.
37
+ for (const name of moduleNameBindings(parsed.ast, env.moduleNames)) {
38
+ out.push({
39
+ code: "BINDING_NAME_RESERVED",
40
+ message: `'${name}' names a module here (an imports: alias, Self, or this module's own name), ` +
41
+ `so a call written '${name}.f(…)' resolves to that module and this binding could never ` +
42
+ `be read. Rename the bound variable.`,
43
+ });
44
+ }
45
+ const audit = auditCalls(source, parsed.ast, env.celEnv, env.moduleCallFlags);
28
46
  // Reported whatever the type-checker concludes. A literal argument a guard
29
47
  // will refuse is a defect the manifest states outright, and leaving it to the
30
48
  // run is the thing static analysis exists to prevent — so it is not gated on
@@ -33,7 +51,10 @@ export function analyzeCelExpression(source, env) {
33
51
  let type;
34
52
  let checkError;
35
53
  try {
36
- const result = env.celEnv.check(source);
54
+ // `parsed.check()`, never `celEnv.check(source)`: the latter RE-PARSES, so
55
+ // it would type a tree in which no module call was ever resolved — every
56
+ // one of them reported as a missing method on an unknown receiver.
57
+ const result = parsed.check();
37
58
  if (result.valid)
38
59
  type = result.type;
39
60
  else if (result.error) {
@@ -83,16 +104,44 @@ export function analyzeCelExpression(source, env) {
83
104
  // Comprehension variables are not roots: `extractAccessChains` drops the
84
105
  // names a `.all(x, …)` binds, so the check never sees them.
85
106
  if (env.rootsDeclared) {
107
+ // A receiver that resolved to no module name AND could be one — the host
108
+ // decides the second half, since a name's level is its naming rule, not
109
+ // this engine's. `Foo.bar()` is an unknown identifier like any other, but
110
+ // its repair is an `imports:` alias rather than a different spelling, so it
111
+ // says so; `dbb.query(1)` is a misspelled value and gets no such advice.
112
+ // Walked only once a root is unknown, which a correct expression never has.
113
+ let callReceivers;
86
114
  const reported = new Set();
87
115
  for (const chain of extractAccessChains(parsed.ast)) {
88
116
  const root = chain[0];
89
117
  if (!root || reported.has(root) || env.celEnv.hasVariable(root))
90
118
  continue;
91
119
  reported.add(root);
120
+ callReceivers ??= unresolvedCallReceivers(parsed.ast, env.moduleNames);
92
121
  out.push({
93
122
  code: "CEL_UNKNOWN_IDENTIFIER",
94
- message: `unknown identifier '${root}' — nothing by that name is in scope here.`,
123
+ message: `unknown identifier '${root}' — nothing by that name is in scope here.` +
124
+ (callReceivers.has(root) && env.couldNameModule?.(root) === true
125
+ ? ` To call a function another module declares, '${root}' must be one of this module's names — an 'imports:' alias, 'Self', or the module's own metadata.name.`
126
+ : ""),
127
+ });
128
+ }
129
+ }
130
+ // A module call's result is typed by the callee's declared `returns`, which the
131
+ // caller resolves: member access on it is checked exactly as a read off the
132
+ // context would be, under the call as written.
133
+ if (resolvedCalls && env.moduleCallResult) {
134
+ for (const access of extractCallResultAccesses(parsed.ast)) {
135
+ const schema = env.moduleCallResult(access.qualified);
136
+ if (!schema)
137
+ continue;
138
+ const label = `${access.qualified}(…)`;
139
+ const err = validateChainAgainstSchema([label, ...access.members], {
140
+ type: "object",
141
+ properties: { [label]: schema },
95
142
  });
143
+ if (err)
144
+ out.push({ code: "CEL_UNKNOWN_FIELD", message: err });
96
145
  }
97
146
  }
98
147
  if (env.contextSchema) {
@@ -112,7 +161,39 @@ export function analyzeCelExpression(source, env) {
112
161
  });
113
162
  }
114
163
  }
115
- return { diagnostics: out, calls: audit.calls, ...(type === undefined ? {} : { type }) };
164
+ return {
165
+ diagnostics: out,
166
+ calls: resolvedCalls ? withCallArguments(audit.calls, parsed.ast) : audit.calls,
167
+ ...(type === undefined ? {} : { type }),
168
+ };
169
+ }
170
+ /** The audited call sites, each module call carrying its arguments as the type
171
+ * check saw them. Matched by position, which is what identifies one call among
172
+ * several of the same name. */
173
+ function withCallArguments(calls, ast) {
174
+ const byStart = new Map();
175
+ for (const { node, call } of moduleCallNodes(ast))
176
+ byStart.set(node.start, call);
177
+ const chainsByStart = new Map();
178
+ for (const [node, chains] of moduleCallArgumentChains(ast))
179
+ chainsByStart.set(node.start, chains);
180
+ return calls.map((site) => {
181
+ const call = site.moduleCall ? byStart.get(site.start) : undefined;
182
+ if (!call)
183
+ return site;
184
+ const chains = chainsByStart.get(site.start);
185
+ return {
186
+ ...site,
187
+ arguments: call.args.map((arg, index) => {
188
+ const type = call.argumentTypes?.[index];
189
+ const chain = chains?.[index] ?? null;
190
+ return {
191
+ ...(type !== undefined ? { type } : {}),
192
+ ...(chain && !chain.includes(INDEX_SEGMENT) ? { chain } : {}),
193
+ };
194
+ }),
195
+ };
196
+ });
116
197
  }
117
198
  /** `dyn` in a checker message means an operand whose type is unknown here —
118
199
  * almost always a step result whose invoked resource declares no
@@ -129,7 +210,7 @@ export const celEngine = {
129
210
  name: "cel",
130
211
  language: "cel",
131
212
  compile(source, env) {
132
- return compileExpression(source, env.celEnv);
213
+ return compileExpression(source, env.celEnv, env.moduleNames);
133
214
  },
134
215
  analyze(source, env) {
135
216
  return analyzeCelExpression(source, env);
@@ -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;AAG7F,OAAO,KAAK,EAIV,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,CAAC;AAErD;;;;;kFAKkF;AAClF,eAAO,MAAM,SAAS,EAAE,gBA4CvB,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;AAG7F,OAAO,KAAK,EAIV,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,CAAC;AAErD;;;;;kFAKkF;AAClF,eAAO,MAAM,SAAS,EAAE,gBAgDvB,CAAC"}
@@ -12,10 +12,14 @@ export const sqlEngine = {
12
12
  name: "sql",
13
13
  language: "sql",
14
14
  compile(source, env) {
15
- const inner = compileString(source, env.celEnv);
15
+ const inner = compileString(source, env.celEnv, env.moduleNames);
16
16
  return {
17
17
  __compiled: true,
18
18
  source,
19
+ // The qualified module calls of every interpolation, for the reason
20
+ // `refs` are carried: a consumer asking what an expression CALLS cannot
21
+ // re-derive it from the text without the declaring module's names.
22
+ calls: typeof inner === "string" ? [] : (inner.calls ?? []),
19
23
  // The AST-derived root identifiers of every interpolation, carried through
20
24
  // rather than dropped. `compileString` has already computed them one line
21
25
  // above, and a consumer that asks a compiled value what it READS —
package/dist/index.d.ts CHANGED
@@ -2,7 +2,8 @@ export { buildCelEnvironment, celBuiltinFunctions, deriveSignatures, type CelHan
2
2
  export { celFunctionCatalog, CEL_FUNCTIONS, type CelFunctionInfo, type CelFunctionDoc, type CelFunctionCategory, } from "./cel/catalog.js";
3
3
  export { compileExpression, compileString, toParameterized, TEMPLATE_REGEX, EXACT_TEMPLATE_REGEX, } from "./cel/compile.js";
4
4
  export { extractAccessChains, findNullableAccessIssues, INDEX_SEGMENT, validateChainAgainstSchema, } from "./cel/analyze.js";
5
- export { auditCalls, explainUnresolved, functionIndex, type CallAudit } from "./cel/diagnose.js";
5
+ export { auditCalls, explainUnresolved, functionIndex, type CallAudit, type ModuleCallFlags, } from "./cel/diagnose.js";
6
+ export { MODULE_CALL_DISPATCH_KEY, moduleCallOf, resolveModuleCalls, type ModuleCallDispatch, type ModuleCallTypeResolver, } from "./cel/module-call.js";
6
7
  export { walkCelExpressions, type CelSurface } from "./cel/walk.js";
7
8
  export { celEngine } from "./engines/cel.js";
8
9
  export { includeBytesEngine, includeTextEngine, normalizeIncludePath, type NormalizedIncludePath, } from "./engines/include.js";
@@ -11,7 +12,7 @@ export { refEngine } from "./engines/ref.js";
11
12
  export { sqlEngine, isParameterizedSql, type ParameterizedSql } from "./engines/sql.js";
12
13
  export { TemplatingEngineRegistry } from "./registry.js";
13
14
  export { builtinEngines, createDefaultRegistry, defaultRegistry, producedTypeOf, } from "./builtins.js";
14
- export type { AnalyzeEnv, AnalyzeResult, CallSite, CompileEnv, DiagnosticFix, EngineDiagnostic, EngineFileClaim, TemplatingEngine, } from "./engine.js";
15
+ export type { AnalyzeEnv, AnalyzeResult, CallArgument, CallSite, CompileEnv, DiagnosticFix, EngineDiagnostic, EngineFileClaim, TemplatingEngine, } from "./engine.js";
15
16
  export { CEL_ENGINE, INCLUDE_BYTES_ENGINE, INCLUDE_ENGINE_NAMES, INCLUDE_TEXT_ENGINE, isIncludeSentinel, isRefSentinel, isTaggedSentinel, makeTaggedSentinel, plainChainOf, type TaggedSentinel, } from "./sentinel.js";
16
17
  export { buildCustomTags, defaultCustomTags } from "./yaml-tags.js";
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -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,EACL,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAExF,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,aAAa,EACb,QAAQ,EACR,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
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,EACL,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACL,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAExF,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,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
@@ -2,7 +2,13 @@ export { buildCelEnvironment, celBuiltinFunctions, deriveSignatures, } from "./c
2
2
  export { celFunctionCatalog, CEL_FUNCTIONS, } from "./cel/catalog.js";
3
3
  export { compileExpression, compileString, toParameterized, TEMPLATE_REGEX, EXACT_TEMPLATE_REGEX, } from "./cel/compile.js";
4
4
  export { extractAccessChains, findNullableAccessIssues, INDEX_SEGMENT, validateChainAgainstSchema, } from "./cel/analyze.js";
5
- export { auditCalls, explainUnresolved, functionIndex } from "./cel/diagnose.js";
5
+ export { auditCalls, explainUnresolved, functionIndex, } from "./cel/diagnose.js";
6
+ // The rewrite, its reader, and the activation key the kernel binds a scope's
7
+ // dispatch table under. The unbound message and the receiver and bound-name
8
+ // walks are read inside this package only.
9
+ // `ModuleCallTypeResolver` is here because `AnalyzeEnv` names it: an exported
10
+ // interface whose field type cannot be named is not usable from outside.
11
+ export { MODULE_CALL_DISPATCH_KEY, moduleCallOf, resolveModuleCalls, } from "./cel/module-call.js";
6
12
  export { walkCelExpressions } from "./cel/walk.js";
7
13
  export { celEngine } from "./engines/cel.js";
8
14
  export { includeBytesEngine, includeTextEngine, normalizeIncludePath, } from "./engines/include.js";