@telorun/templating 0.134.0 → 0.136.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/cel/analyze.d.ts +17 -0
- package/dist/cel/analyze.d.ts.map +1 -1
- package/dist/cel/analyze.js +44 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/cel/analyze.ts +46 -9
- package/src/index.ts +2 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://github.com/telorun/telo/raw/v0.
|
|
2
|
+
<img src="https://github.com/telorun/telo/raw/v0.136.0/assets/telo.svg" alt="Telo" width="120" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<h1 align="center">Telo</h1>
|
|
@@ -59,7 +59,7 @@ Telo reads your YAML files, checks them, works out what depends on what, starts
|
|
|
59
59
|
|
|
60
60
|
## Example manifest
|
|
61
61
|
|
|
62
|
-
See [examples/](https://github.com/telorun/telo/tree/v0.
|
|
62
|
+
See [examples/](https://github.com/telorun/telo/tree/v0.136.0/examples/) for a list of working applications.
|
|
63
63
|
|
|
64
64
|
## Status
|
|
65
65
|
|
|
@@ -95,15 +95,15 @@ The architecture is inspired by Kubernetes-style manifests: declarative resource
|
|
|
95
95
|
|
|
96
96
|
## See more at
|
|
97
97
|
|
|
98
|
-
- [Telo Kernel](https://github.com/telorun/telo/blob/v0.
|
|
99
|
-
- [Telo SDK for module authors](https://github.com/telorun/telo/blob/v0.
|
|
100
|
-
- [Modules](https://github.com/telorun/telo/blob/v0.
|
|
98
|
+
- [Telo Kernel](https://github.com/telorun/telo/blob/v0.136.0/kernel/README.md)
|
|
99
|
+
- [Telo SDK for module authors](https://github.com/telorun/telo/blob/v0.136.0/sdk/README.md)
|
|
100
|
+
- [Modules](https://github.com/telorun/telo/blob/v0.136.0/modules/README.md)
|
|
101
101
|
|
|
102
102
|
## License
|
|
103
103
|
|
|
104
104
|
In plain terms: Telo is free to use, including commercially. You can build, host and sell your own products on it. You cannot offer Telo itself to others as a managed service without a commercial licence from CodeNet Sp. z o.o. (contact@codenet.pl). The modules, SDK, examples and docs you build with are MIT. Details: [Licensing](https://telo.run/learn/licensing).
|
|
105
105
|
|
|
106
|
-
Two licenses, split by directory. Each MIT directory carries its own `LICENSE`; everything else falls under the root [LICENSE](https://github.com/telorun/telo/blob/v0.
|
|
106
|
+
Two licenses, split by directory. Each MIT directory carries its own `LICENSE`; everything else falls under the root [LICENSE](https://github.com/telorun/telo/blob/v0.136.0/LICENSE), the Sustainable Use License.
|
|
107
107
|
|
|
108
108
|
| MIT | Sustainable Use |
|
|
109
109
|
| --- | --- |
|
package/dist/cel/analyze.d.ts
CHANGED
|
@@ -31,6 +31,13 @@ export declare const EACH_SEGMENT = "[]";
|
|
|
31
31
|
* presence test (`has(a.b)`) reads, which depends on the KEYS of what the chain
|
|
32
32
|
* before it reaches and on none of its values. */
|
|
33
33
|
export declare const PRESENCE_SEGMENT = "?";
|
|
34
|
+
/** Chain segment for "each element of the range, read whole", after
|
|
35
|
+
* {@link EACH_SEGMENT}: a bare use of the iteration variable, or the range of an
|
|
36
|
+
* `in` test. Over a list it reads every element; over a map it reads only the
|
|
37
|
+
* KEYS, because a comprehension's variable and an `in` test stand for a key
|
|
38
|
+
* there, so no value of the map is read. Which of the two a range is, is known
|
|
39
|
+
* only to the reader holding the data. */
|
|
40
|
+
export declare const ELEMENT_SEGMENT = "[]!";
|
|
34
41
|
/**
|
|
35
42
|
* What an expression READS of the values its roots name, as member chains —
|
|
36
43
|
* {@link extractAccessChains} with a comprehension's iteration variable followed
|
|
@@ -49,6 +56,16 @@ export declare const PRESENCE_SEGMENT = "?";
|
|
|
49
56
|
* output) names nothing a root holds, and a read through it contributes nothing.
|
|
50
57
|
*/
|
|
51
58
|
export declare function extractReadChains(node: CelNode): string[][];
|
|
59
|
+
/**
|
|
60
|
+
* {@link extractReadChains} told apart by what a range holds: a bare use of an
|
|
61
|
+
* iteration variable and the range of an `in` test read `<range>.[].[]!`
|
|
62
|
+
* ({@link ELEMENT_SEGMENT}) — each element whole over a list, and over a map
|
|
63
|
+
* nothing but its keys — where {@link extractReadChains} reads the range whole.
|
|
64
|
+
* The one question it answers is which VALUES an expression reads, which a
|
|
65
|
+
* caller holding the data answers per range: a rule iterating a map's keys must
|
|
66
|
+
* not be taken for one reading its values.
|
|
67
|
+
*/
|
|
68
|
+
export declare function extractValueReadChains(node: CelNode): string[][];
|
|
52
69
|
/** A member access on a module call's result: the call, and the members read
|
|
53
70
|
* off it in order (`Billing.total(xs).amount` → `amount`). */
|
|
54
71
|
export interface CallResultAccess {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/cel/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,cAAc,CAAC;AAItB;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,EAAE,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAS5F;AA8FD;;+DAE+D;AAC/D,eAAO,MAAM,aAAa,QAAQ,CAAC;AA6BnC;qDACqD;AACrD,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC;;mDAEmD;AACnD,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,EAAE,CAI3D;
|
|
1
|
+
{"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/cel/analyze.ts"],"names":[],"mappings":"AAA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;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,OAAO,EACb,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACjC,aAAa,EAAE,CAIjB;AA2ED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,MAAM,GAAG,IAAI,CAEf;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC/C,GAAG,CAAC,MAAM,CAAC,CAab;AAED,iFAAiF;AACjF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAiF1C;AAmDD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1C,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,SAAS,GACjD,CAAC,EAAE,GAAG,SAAS,CAYjB"}
|
package/dist/cel/analyze.js
CHANGED
|
@@ -156,6 +156,13 @@ export const EACH_SEGMENT = "[]";
|
|
|
156
156
|
* presence test (`has(a.b)`) reads, which depends on the KEYS of what the chain
|
|
157
157
|
* before it reaches and on none of its values. */
|
|
158
158
|
export const PRESENCE_SEGMENT = "?";
|
|
159
|
+
/** Chain segment for "each element of the range, read whole", after
|
|
160
|
+
* {@link EACH_SEGMENT}: a bare use of the iteration variable, or the range of an
|
|
161
|
+
* `in` test. Over a list it reads every element; over a map it reads only the
|
|
162
|
+
* KEYS, because a comprehension's variable and an `in` test stand for a key
|
|
163
|
+
* there, so no value of the map is read. Which of the two a range is, is known
|
|
164
|
+
* only to the reader holding the data. */
|
|
165
|
+
export const ELEMENT_SEGMENT = "[]!";
|
|
159
166
|
/**
|
|
160
167
|
* What an expression READS of the values its roots name, as member chains —
|
|
161
168
|
* {@link extractAccessChains} with a comprehension's iteration variable followed
|
|
@@ -175,7 +182,21 @@ export const PRESENCE_SEGMENT = "?";
|
|
|
175
182
|
*/
|
|
176
183
|
export function extractReadChains(node) {
|
|
177
184
|
const chains = [];
|
|
178
|
-
visitReads(node, chains, new Map());
|
|
185
|
+
visitReads(node, chains, new Map(), false);
|
|
186
|
+
return chains;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* {@link extractReadChains} told apart by what a range holds: a bare use of an
|
|
190
|
+
* iteration variable and the range of an `in` test read `<range>.[].[]!`
|
|
191
|
+
* ({@link ELEMENT_SEGMENT}) — each element whole over a list, and over a map
|
|
192
|
+
* nothing but its keys — where {@link extractReadChains} reads the range whole.
|
|
193
|
+
* The one question it answers is which VALUES an expression reads, which a
|
|
194
|
+
* caller holding the data answers per range: a rule iterating a map's keys must
|
|
195
|
+
* not be taken for one reading its values.
|
|
196
|
+
*/
|
|
197
|
+
export function extractValueReadChains(node) {
|
|
198
|
+
const chains = [];
|
|
199
|
+
visitReads(node, chains, new Map(), true);
|
|
179
200
|
return chains;
|
|
180
201
|
}
|
|
181
202
|
function readChainOf(node, bound) {
|
|
@@ -202,13 +223,27 @@ function readChainOf(node, bound) {
|
|
|
202
223
|
}
|
|
203
224
|
return null;
|
|
204
225
|
}
|
|
205
|
-
function visitReads(node, chains, bound) {
|
|
226
|
+
function visitReads(node, chains, bound, valueReads) {
|
|
206
227
|
const chain = readChainOf(node, bound);
|
|
207
228
|
if (chain !== null) {
|
|
208
229
|
// The variable itself, with no member read off it: the whole element.
|
|
209
|
-
|
|
230
|
+
if (chain[chain.length - 1] === EACH_SEGMENT) {
|
|
231
|
+
chains.push(valueReads ? [...chain, ELEMENT_SEGMENT] : chain.slice(0, -1));
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
chains.push(chain);
|
|
235
|
+
}
|
|
210
236
|
return;
|
|
211
237
|
}
|
|
238
|
+
if (valueReads && node.kind === "binary" && node.operator === "in") {
|
|
239
|
+
// `k in m` tests a key of a map and an element of a list.
|
|
240
|
+
const range = readChainOf(node.right, bound);
|
|
241
|
+
if (range !== null && range[range.length - 1] !== EACH_SEGMENT) {
|
|
242
|
+
chains.push([...range, EACH_SEGMENT, ELEMENT_SEGMENT]);
|
|
243
|
+
visitReads(node.left, chains, bound, valueReads);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
212
247
|
const presence = presenceOperand(node);
|
|
213
248
|
if (presence) {
|
|
214
249
|
const owner = readChainOf(presence, bound);
|
|
@@ -220,13 +255,13 @@ function visitReads(node, chains, bound) {
|
|
|
220
255
|
const moduleCall = moduleCallOf(node);
|
|
221
256
|
if (moduleCall) {
|
|
222
257
|
for (const arg of moduleCall.args)
|
|
223
|
-
visitReads(arg, chains, bound);
|
|
258
|
+
visitReads(arg, chains, bound, valueReads);
|
|
224
259
|
return;
|
|
225
260
|
}
|
|
226
261
|
const bind = bindCall(node);
|
|
227
262
|
if (bind) {
|
|
228
|
-
visitReads(bind.init, chains, bound);
|
|
229
|
-
visitReads(bind.body, chains, new Map(bound).set(bind.name, null));
|
|
263
|
+
visitReads(bind.init, chains, bound, valueReads);
|
|
264
|
+
visitReads(bind.body, chains, new Map(bound).set(bind.name, null), valueReads);
|
|
230
265
|
return;
|
|
231
266
|
}
|
|
232
267
|
const macro = comprehension(node);
|
|
@@ -235,14 +270,14 @@ function visitReads(node, chains, bound) {
|
|
|
235
270
|
if (range !== null)
|
|
236
271
|
chains.push([...range, EACH_SEGMENT]);
|
|
237
272
|
else
|
|
238
|
-
visitReads(macro.receiver, chains, bound);
|
|
273
|
+
visitReads(macro.receiver, chains, bound, valueReads);
|
|
239
274
|
const inner = new Map(bound).set(macro.bound, range);
|
|
240
275
|
for (const arg of macro.scoped)
|
|
241
|
-
visitReads(arg, chains, inner);
|
|
276
|
+
visitReads(arg, chains, inner, valueReads);
|
|
242
277
|
return;
|
|
243
278
|
}
|
|
244
279
|
for (const child of childNodes(node))
|
|
245
|
-
visitReads(child, chains, bound);
|
|
280
|
+
visitReads(child, chains, bound, valueReads);
|
|
246
281
|
}
|
|
247
282
|
/** What a presence test `has(<operand>.<member>)` asks the keys of. */
|
|
248
283
|
function presenceOperand(node) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { buildCelEnvironment, buildCelLanguageEnvironment, celBuiltinFunctions, celFunctionCatalog, type CelHandlers, } from "./cel/environment.js";
|
|
2
2
|
export { compileExpression, namespaceDispatchOf, siteEnvironment, type CelProgramSite, } from "./cel/compile.js";
|
|
3
3
|
export { interpolationShape, literalFragments, readInterpolationHoles, type HoleReading, type InterpolationHole, type InterpolationShape, } from "./cel/interpolation-holes.js";
|
|
4
|
-
export { EACH_SEGMENT, PRESENCE_SEGMENT, extractAccessChains, extractReadChains, findNullableAccessIssues, INDEX_SEGMENT, schemaConjuncts, validateChainAgainstSchema, } from "./cel/analyze.js";
|
|
4
|
+
export { EACH_SEGMENT, ELEMENT_SEGMENT, PRESENCE_SEGMENT, extractAccessChains, extractReadChains, extractValueReadChains, findNullableAccessIssues, INDEX_SEGMENT, schemaConjuncts, validateChainAgainstSchema, } from "./cel/analyze.js";
|
|
5
5
|
export { auditCalls, explainUnresolved, type CallAudit, type ModuleCallFlags, } from "./cel/diagnose.js";
|
|
6
6
|
export { celNamespaceNames, MODULE_CALL_DISPATCH_KEY, moduleCallNames, moduleCallOf, type ModuleCallDispatch, type ModuleCallTypeResolver, } from "./cel/module-call.js";
|
|
7
7
|
export { walkCelExpressions } from "./cel/walk.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,2BAA2B,EAC3B,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,WAAW,GACjB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,cAAc,EACd,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBA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MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { buildCelEnvironment, buildCelLanguageEnvironment, celBuiltinFunctions,
|
|
|
5
5
|
// adapter is what let it convert arguments differently from the kernel.
|
|
6
6
|
export { compileExpression, namespaceDispatchOf, siteEnvironment, } from "./cel/compile.js";
|
|
7
7
|
export { interpolationShape, literalFragments, readInterpolationHoles, } from "./cel/interpolation-holes.js";
|
|
8
|
-
export { EACH_SEGMENT, PRESENCE_SEGMENT, extractAccessChains, extractReadChains, findNullableAccessIssues, INDEX_SEGMENT, schemaConjuncts, validateChainAgainstSchema, } from "./cel/analyze.js";
|
|
8
|
+
export { EACH_SEGMENT, ELEMENT_SEGMENT, PRESENCE_SEGMENT, extractAccessChains, extractReadChains, extractValueReadChains, findNullableAccessIssues, INDEX_SEGMENT, schemaConjuncts, validateChainAgainstSchema, } from "./cel/analyze.js";
|
|
9
9
|
export { auditCalls, explainUnresolved, } from "./cel/diagnose.js";
|
|
10
10
|
// The rewrite, its reader, and the activation key the kernel binds a scope's
|
|
11
11
|
// dispatch table under. The unbound message and the receiver and bound-name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/templating",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.136.0",
|
|
4
4
|
"description": "Telo Templating - Engine registry and shared CEL core for Telo manifests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"telo",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"re2js": "2.8.3",
|
|
40
40
|
"uuid": "14.0.1",
|
|
41
41
|
"yaml": "^2.8.3",
|
|
42
|
-
"@telorun/cel": "0.
|
|
42
|
+
"@telorun/cel": "0.136.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/d3-format": "^3.0.4",
|
|
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.136.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@telorun/sdk": "*"
|
package/src/cel/analyze.ts
CHANGED
|
@@ -176,6 +176,14 @@ export const EACH_SEGMENT = "[]";
|
|
|
176
176
|
* before it reaches and on none of its values. */
|
|
177
177
|
export const PRESENCE_SEGMENT = "?";
|
|
178
178
|
|
|
179
|
+
/** Chain segment for "each element of the range, read whole", after
|
|
180
|
+
* {@link EACH_SEGMENT}: a bare use of the iteration variable, or the range of an
|
|
181
|
+
* `in` test. Over a list it reads every element; over a map it reads only the
|
|
182
|
+
* KEYS, because a comprehension's variable and an `in` test stand for a key
|
|
183
|
+
* there, so no value of the map is read. Which of the two a range is, is known
|
|
184
|
+
* only to the reader holding the data. */
|
|
185
|
+
export const ELEMENT_SEGMENT = "[]!";
|
|
186
|
+
|
|
179
187
|
/**
|
|
180
188
|
* What an expression READS of the values its roots name, as member chains —
|
|
181
189
|
* {@link extractAccessChains} with a comprehension's iteration variable followed
|
|
@@ -195,7 +203,22 @@ export const PRESENCE_SEGMENT = "?";
|
|
|
195
203
|
*/
|
|
196
204
|
export function extractReadChains(node: CelNode): string[][] {
|
|
197
205
|
const chains: string[][] = [];
|
|
198
|
-
visitReads(node, chains, new Map());
|
|
206
|
+
visitReads(node, chains, new Map(), false);
|
|
207
|
+
return chains;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* {@link extractReadChains} told apart by what a range holds: a bare use of an
|
|
212
|
+
* iteration variable and the range of an `in` test read `<range>.[].[]!`
|
|
213
|
+
* ({@link ELEMENT_SEGMENT}) — each element whole over a list, and over a map
|
|
214
|
+
* nothing but its keys — where {@link extractReadChains} reads the range whole.
|
|
215
|
+
* The one question it answers is which VALUES an expression reads, which a
|
|
216
|
+
* caller holding the data answers per range: a rule iterating a map's keys must
|
|
217
|
+
* not be taken for one reading its values.
|
|
218
|
+
*/
|
|
219
|
+
export function extractValueReadChains(node: CelNode): string[][] {
|
|
220
|
+
const chains: string[][] = [];
|
|
221
|
+
visitReads(node, chains, new Map(), true);
|
|
199
222
|
return chains;
|
|
200
223
|
}
|
|
201
224
|
|
|
@@ -223,14 +246,28 @@ function readChainOf(node: CelNode, bound: BoundRanges): string[] | null {
|
|
|
223
246
|
return null;
|
|
224
247
|
}
|
|
225
248
|
|
|
226
|
-
function visitReads(node: CelNode, chains: string[][], bound: BoundRanges): void {
|
|
249
|
+
function visitReads(node: CelNode, chains: string[][], bound: BoundRanges, valueReads: boolean): void {
|
|
227
250
|
const chain = readChainOf(node, bound);
|
|
228
251
|
if (chain !== null) {
|
|
229
252
|
// The variable itself, with no member read off it: the whole element.
|
|
230
|
-
|
|
253
|
+
if (chain[chain.length - 1] === EACH_SEGMENT) {
|
|
254
|
+
chains.push(valueReads ? [...chain, ELEMENT_SEGMENT] : chain.slice(0, -1));
|
|
255
|
+
} else {
|
|
256
|
+
chains.push(chain);
|
|
257
|
+
}
|
|
231
258
|
return;
|
|
232
259
|
}
|
|
233
260
|
|
|
261
|
+
if (valueReads && node.kind === "binary" && node.operator === "in") {
|
|
262
|
+
// `k in m` tests a key of a map and an element of a list.
|
|
263
|
+
const range = readChainOf(node.right, bound);
|
|
264
|
+
if (range !== null && range[range.length - 1] !== EACH_SEGMENT) {
|
|
265
|
+
chains.push([...range, EACH_SEGMENT, ELEMENT_SEGMENT]);
|
|
266
|
+
visitReads(node.left, chains, bound, valueReads);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
234
271
|
const presence = presenceOperand(node);
|
|
235
272
|
if (presence) {
|
|
236
273
|
const owner = readChainOf(presence, bound);
|
|
@@ -242,14 +279,14 @@ function visitReads(node: CelNode, chains: string[][], bound: BoundRanges): void
|
|
|
242
279
|
|
|
243
280
|
const moduleCall = moduleCallOf(node);
|
|
244
281
|
if (moduleCall) {
|
|
245
|
-
for (const arg of moduleCall.args) visitReads(arg, chains, bound);
|
|
282
|
+
for (const arg of moduleCall.args) visitReads(arg, chains, bound, valueReads);
|
|
246
283
|
return;
|
|
247
284
|
}
|
|
248
285
|
|
|
249
286
|
const bind = bindCall(node);
|
|
250
287
|
if (bind) {
|
|
251
|
-
visitReads(bind.init, chains, bound);
|
|
252
|
-
visitReads(bind.body, chains, new Map(bound).set(bind.name, null));
|
|
288
|
+
visitReads(bind.init, chains, bound, valueReads);
|
|
289
|
+
visitReads(bind.body, chains, new Map(bound).set(bind.name, null), valueReads);
|
|
253
290
|
return;
|
|
254
291
|
}
|
|
255
292
|
|
|
@@ -257,13 +294,13 @@ function visitReads(node: CelNode, chains: string[][], bound: BoundRanges): void
|
|
|
257
294
|
if (macro) {
|
|
258
295
|
const range = readChainOf(macro.receiver, bound);
|
|
259
296
|
if (range !== null) chains.push([...range, EACH_SEGMENT]);
|
|
260
|
-
else visitReads(macro.receiver, chains, bound);
|
|
297
|
+
else visitReads(macro.receiver, chains, bound, valueReads);
|
|
261
298
|
const inner = new Map(bound).set(macro.bound, range);
|
|
262
|
-
for (const arg of macro.scoped) visitReads(arg, chains, inner);
|
|
299
|
+
for (const arg of macro.scoped) visitReads(arg, chains, inner, valueReads);
|
|
263
300
|
return;
|
|
264
301
|
}
|
|
265
302
|
|
|
266
|
-
for (const child of childNodes(node)) visitReads(child, chains, bound);
|
|
303
|
+
for (const child of childNodes(node)) visitReads(child, chains, bound, valueReads);
|
|
267
304
|
}
|
|
268
305
|
|
|
269
306
|
/** What a presence test `has(<operand>.<member>)` asks the keys of. */
|
package/src/index.ts
CHANGED
|
@@ -25,9 +25,11 @@ export {
|
|
|
25
25
|
} from "./cel/interpolation-holes.js";
|
|
26
26
|
export {
|
|
27
27
|
EACH_SEGMENT,
|
|
28
|
+
ELEMENT_SEGMENT,
|
|
28
29
|
PRESENCE_SEGMENT,
|
|
29
30
|
extractAccessChains,
|
|
30
31
|
extractReadChains,
|
|
32
|
+
extractValueReadChains,
|
|
31
33
|
findNullableAccessIssues,
|
|
32
34
|
INDEX_SEGMENT,
|
|
33
35
|
schemaConjuncts,
|