@telorun/templating 0.132.0 → 0.133.0-rc.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/interpolation-holes.d.ts +8 -6
- package/dist/cel/interpolation-holes.d.ts.map +1 -1
- package/dist/cel/interpolation-holes.js +11 -38
- package/dist/engines/interpolate.d.ts +1 -2
- package/dist/engines/interpolate.d.ts.map +1 -1
- package/dist/engines/interpolate.js +10 -10
- package/package.json +3 -3
- package/src/cel/interpolation-holes.ts +12 -36
- package/src/engines/interpolate.ts +9 -10
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.133.0-rc.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.133.0-rc.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.133.0-rc.0/kernel/README.md)
|
|
99
|
+
- [Telo SDK for module authors](https://github.com/telorun/telo/blob/v0.133.0-rc.0/sdk/README.md)
|
|
100
|
+
- [Modules](https://github.com/telorun/telo/blob/v0.133.0-rc.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.133.0-rc.0/LICENSE), the Sustainable Use License.
|
|
107
107
|
|
|
108
108
|
| MIT | Sustainable Use |
|
|
109
109
|
| --- | --- |
|
|
@@ -25,12 +25,14 @@ export type InterpolationShape = "none" | "lone-hole" | "interpolated" | "malfor
|
|
|
25
25
|
* Every `${{ expr }}` hole in `source` — the one hole grammar every tag with
|
|
26
26
|
* holes (`!interpolate`, `!sql`) and the untagged-interpolation migration read.
|
|
27
27
|
*
|
|
28
|
-
* A hole opens at `${{` and closes at the first `}}` that is outside a
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
28
|
+
* A hole opens at `${{` and closes at the first `}}` that is outside a quoted
|
|
29
|
+
* literal and outside any `{` the expression itself opened, so a map literal or a
|
|
30
|
+
* string holding braces is read whole. A quoted literal ends exactly where the
|
|
31
|
+
* language ends it: the hole reader has no rule of its own and asks the engine
|
|
32
|
+
* (`quotedLiteralEnd`), which reads string and bytes literals, their prefixes and
|
|
33
|
+
* triple-quoted forms, and backtick-quoted member names. A comment is not read, so
|
|
34
|
+
* `//` is hole text and a quote after it opens a literal. Outside a hole nothing is
|
|
35
|
+
* special but `${{`; a literal `${{` is written as a hole yielding it (`${{ '${{' }}`).
|
|
34
36
|
*
|
|
35
37
|
* A hole that never closes is a reading failure at its opening offset, never a
|
|
36
38
|
* guess at where it meant to end.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation-holes.d.ts","sourceRoot":"","sources":["../../src/cel/interpolation-holes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interpolation-holes.d.ts","sourceRoot":"","sources":["../../src/cel/interpolation-holes.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E;;YAEY;AACZ,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,WAAW,GAAG,cAAc,GAAG,WAAW,CAAC;AAIrF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAwBlE;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAWrE;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAS9F"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { quotedLiteralEnd } from "@telorun/cel";
|
|
1
2
|
const OPEN = "${{";
|
|
2
3
|
/**
|
|
3
4
|
* Every `${{ expr }}` hole in `source` — the one hole grammar every tag with
|
|
4
5
|
* holes (`!interpolate`, `!sql`) and the untagged-interpolation migration read.
|
|
5
6
|
*
|
|
6
|
-
* A hole opens at `${{` and closes at the first `}}` that is outside a
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* A hole opens at `${{` and closes at the first `}}` that is outside a quoted
|
|
8
|
+
* literal and outside any `{` the expression itself opened, so a map literal or a
|
|
9
|
+
* string holding braces is read whole. A quoted literal ends exactly where the
|
|
10
|
+
* language ends it: the hole reader has no rule of its own and asks the engine
|
|
11
|
+
* (`quotedLiteralEnd`), which reads string and bytes literals, their prefixes and
|
|
12
|
+
* triple-quoted forms, and backtick-quoted member names. A comment is not read, so
|
|
13
|
+
* `//` is hole text and a quote after it opens a literal. Outside a hole nothing is
|
|
14
|
+
* special but `${{`; a literal `${{` is written as a hole yielding it (`${{ '${{' }}`).
|
|
12
15
|
*
|
|
13
16
|
* A hole that never closes is a reading failure at its opening offset, never a
|
|
14
17
|
* guess at where it meant to end.
|
|
@@ -71,8 +74,8 @@ function closingOffset(source, from) {
|
|
|
71
74
|
let i = from;
|
|
72
75
|
while (i < source.length) {
|
|
73
76
|
const c = source[i];
|
|
74
|
-
if (c === "'" || c === '"') {
|
|
75
|
-
const after =
|
|
77
|
+
if (c === "'" || c === '"' || c === "`") {
|
|
78
|
+
const after = quotedLiteralEnd(source, i);
|
|
76
79
|
if (after === undefined)
|
|
77
80
|
return undefined;
|
|
78
81
|
i = after;
|
|
@@ -89,33 +92,3 @@ function closingOffset(source, from) {
|
|
|
89
92
|
}
|
|
90
93
|
return undefined;
|
|
91
94
|
}
|
|
92
|
-
/** Offset just past the string literal whose opening quote is at `quoteAt`. */
|
|
93
|
-
function skipString(source, quoteAt) {
|
|
94
|
-
const quote = source[quoteAt];
|
|
95
|
-
const raw = /[rR]/.test(literalPrefix(source, quoteAt));
|
|
96
|
-
const triple = source.startsWith(quote.repeat(3), quoteAt);
|
|
97
|
-
const delimiter = triple ? quote.repeat(3) : quote;
|
|
98
|
-
let i = quoteAt + delimiter.length;
|
|
99
|
-
while (i < source.length) {
|
|
100
|
-
if (!raw && source[i] === "\\") {
|
|
101
|
-
i += 2;
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (!triple && source[i] === "\n")
|
|
105
|
-
return undefined;
|
|
106
|
-
if (source.startsWith(delimiter, i))
|
|
107
|
-
return i + delimiter.length;
|
|
108
|
-
i++;
|
|
109
|
-
}
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
/** The `r`/`b` prefix letters written immediately before a quote, when they are
|
|
113
|
-
* a prefix rather than the tail of an identifier. */
|
|
114
|
-
function literalPrefix(source, quoteAt) {
|
|
115
|
-
let i = quoteAt;
|
|
116
|
-
while (i > 0 && quoteAt - i < 2 && /[rRbB]/.test(source[i - 1]))
|
|
117
|
-
i--;
|
|
118
|
-
if (i > 0 && /[A-Za-z0-9_]/.test(source[i - 1]))
|
|
119
|
-
return "";
|
|
120
|
-
return source.slice(i, quoteAt);
|
|
121
|
-
}
|
|
@@ -6,8 +6,7 @@ import type { TemplatingEngine } from "../engine.js";
|
|
|
6
6
|
* `string()` overloads (RFC 3339 for a timestamp, `5400s` for a duration, UTF-8
|
|
7
7
|
* for bytes), never the host language's conversion, so any CEL engine renders
|
|
8
8
|
* the same text. A hole whose type has no `string()` overload is refused
|
|
9
|
-
* statically, and a `dyn` hole
|
|
10
|
-
* at runtime with the hole it came from.
|
|
9
|
+
* statically, and a `dyn` hole whose value `string()` refuses (null, a list, a map, an optional, a type) is refused at runtime with the hole it came from.
|
|
11
10
|
*/
|
|
12
11
|
export declare const interpolateEngine: TemplatingEngine;
|
|
13
12
|
//# sourceMappingURL=interpolate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAyC/B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CelEvaluationError,
|
|
1
|
+
import { CelEvaluationError, celTypeNameOf, typeValueName } from "@telorun/cel";
|
|
2
2
|
import { nullableValueChain } from "../cel/analyze.js";
|
|
3
3
|
import { literalFragments } from "../cel/interpolation-holes.js";
|
|
4
4
|
import { celVerdictError } from "../cel/verdict-codes.js";
|
|
@@ -11,8 +11,7 @@ const INTERPOLATE_ENGINE = "interpolate";
|
|
|
11
11
|
* `string()` overloads (RFC 3339 for a timestamp, `5400s` for a duration, UTF-8
|
|
12
12
|
* for bytes), never the host language's conversion, so any CEL engine renders
|
|
13
13
|
* the same text. A hole whose type has no `string()` overload is refused
|
|
14
|
-
* statically, and a `dyn` hole
|
|
15
|
-
* at runtime with the hole it came from.
|
|
14
|
+
* statically, and a `dyn` hole whose value `string()` refuses (null, a list, a map, an optional, a type) is refused at runtime with the hole it came from.
|
|
16
15
|
*/
|
|
17
16
|
export const interpolateEngine = {
|
|
18
17
|
name: INTERPOLATE_ENGINE,
|
|
@@ -116,15 +115,16 @@ function stringConversion(env) {
|
|
|
116
115
|
CONVERSIONS.set(env, conversion);
|
|
117
116
|
return conversion;
|
|
118
117
|
}
|
|
118
|
+
/** The value in CEL's terms, as `type()` names it; no host class name reaches the message. */
|
|
119
119
|
function runtimeTypeOf(value) {
|
|
120
|
-
|
|
120
|
+
const name = celTypeNameOf(value);
|
|
121
|
+
if (name === undefined)
|
|
122
|
+
return "a value outside the CEL value domain";
|
|
123
|
+
if (name === "null_type")
|
|
121
124
|
return "null";
|
|
122
|
-
if (
|
|
125
|
+
if (name === "list")
|
|
123
126
|
return "a list";
|
|
124
|
-
|
|
125
|
-
// prototype: a branded value is a plain object, so a prototype test named an optional, a
|
|
126
|
-
// type and every host named type "a map".
|
|
127
|
-
if (isCelMap(value) || isCelRecord(value))
|
|
127
|
+
if (name === "map")
|
|
128
128
|
return "a map";
|
|
129
|
-
return `a value of type ${
|
|
129
|
+
return `a value of type ${typeValueName(name)}`;
|
|
130
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/templating",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.133.0-rc.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.133.0-rc.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.133.0-rc.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@telorun/sdk": "*"
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { quotedLiteralEnd } from "@telorun/cel";
|
|
2
|
+
|
|
1
3
|
/** One `${{ expr }}` hole in a scalar. Offsets index the scalar's source. */
|
|
2
4
|
export interface InterpolationHole {
|
|
3
5
|
/** Offset of the opening `${{`. */
|
|
@@ -25,12 +27,14 @@ const OPEN = "${{";
|
|
|
25
27
|
* Every `${{ expr }}` hole in `source` — the one hole grammar every tag with
|
|
26
28
|
* holes (`!interpolate`, `!sql`) and the untagged-interpolation migration read.
|
|
27
29
|
*
|
|
28
|
-
* A hole opens at `${{` and closes at the first `}}` that is outside a
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* A hole opens at `${{` and closes at the first `}}` that is outside a quoted
|
|
31
|
+
* literal and outside any `{` the expression itself opened, so a map literal or a
|
|
32
|
+
* string holding braces is read whole. A quoted literal ends exactly where the
|
|
33
|
+
* language ends it: the hole reader has no rule of its own and asks the engine
|
|
34
|
+
* (`quotedLiteralEnd`), which reads string and bytes literals, their prefixes and
|
|
35
|
+
* triple-quoted forms, and backtick-quoted member names. A comment is not read, so
|
|
36
|
+
* `//` is hole text and a quote after it opens a literal. Outside a hole nothing is
|
|
37
|
+
* special but `${{`; a literal `${{` is written as a hole yielding it (`${{ '${{' }}`).
|
|
34
38
|
*
|
|
35
39
|
* A hole that never closes is a reading failure at its opening offset, never a
|
|
36
40
|
* guess at where it meant to end.
|
|
@@ -93,8 +97,8 @@ function closingOffset(source: string, from: number): number | undefined {
|
|
|
93
97
|
let i = from;
|
|
94
98
|
while (i < source.length) {
|
|
95
99
|
const c = source[i]!;
|
|
96
|
-
if (c === "'" || c === '"') {
|
|
97
|
-
const after =
|
|
100
|
+
if (c === "'" || c === '"' || c === "`") {
|
|
101
|
+
const after = quotedLiteralEnd(source, i);
|
|
98
102
|
if (after === undefined) return undefined;
|
|
99
103
|
i = after;
|
|
100
104
|
continue;
|
|
@@ -108,31 +112,3 @@ function closingOffset(source: string, from: number): number | undefined {
|
|
|
108
112
|
}
|
|
109
113
|
return undefined;
|
|
110
114
|
}
|
|
111
|
-
|
|
112
|
-
/** Offset just past the string literal whose opening quote is at `quoteAt`. */
|
|
113
|
-
function skipString(source: string, quoteAt: number): number | undefined {
|
|
114
|
-
const quote = source[quoteAt]!;
|
|
115
|
-
const raw = /[rR]/.test(literalPrefix(source, quoteAt));
|
|
116
|
-
const triple = source.startsWith(quote.repeat(3), quoteAt);
|
|
117
|
-
const delimiter = triple ? quote.repeat(3) : quote;
|
|
118
|
-
let i = quoteAt + delimiter.length;
|
|
119
|
-
while (i < source.length) {
|
|
120
|
-
if (!raw && source[i] === "\\") {
|
|
121
|
-
i += 2;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (!triple && source[i] === "\n") return undefined;
|
|
125
|
-
if (source.startsWith(delimiter, i)) return i + delimiter.length;
|
|
126
|
-
i++;
|
|
127
|
-
}
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** The `r`/`b` prefix letters written immediately before a quote, when they are
|
|
132
|
-
* a prefix rather than the tail of an identifier. */
|
|
133
|
-
function literalPrefix(source: string, quoteAt: number): string {
|
|
134
|
-
let i = quoteAt;
|
|
135
|
-
while (i > 0 && quoteAt - i < 2 && /[rRbB]/.test(source[i - 1]!)) i--;
|
|
136
|
-
if (i > 0 && /[A-Za-z0-9_]/.test(source[i - 1]!)) return "";
|
|
137
|
-
return source.slice(i, quoteAt);
|
|
138
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CelEnvironment, CelEvaluationError,
|
|
1
|
+
import { CelEnvironment, CelEvaluationError, celTypeNameOf, typeValueName, 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";
|
|
@@ -21,8 +21,7 @@ const INTERPOLATE_ENGINE = "interpolate";
|
|
|
21
21
|
* `string()` overloads (RFC 3339 for a timestamp, `5400s` for a duration, UTF-8
|
|
22
22
|
* for bytes), never the host language's conversion, so any CEL engine renders
|
|
23
23
|
* the same text. A hole whose type has no `string()` overload is refused
|
|
24
|
-
* statically, and a `dyn` hole
|
|
25
|
-
* at runtime with the hole it came from.
|
|
24
|
+
* statically, and a `dyn` hole whose value `string()` refuses (null, a list, a map, an optional, a type) is refused at runtime with the hole it came from.
|
|
26
25
|
*/
|
|
27
26
|
export const interpolateEngine: TemplatingEngine = {
|
|
28
27
|
name: INTERPOLATE_ENGINE,
|
|
@@ -143,12 +142,12 @@ function stringConversion(env: CelEnvironment): Conversion {
|
|
|
143
142
|
return conversion;
|
|
144
143
|
}
|
|
145
144
|
|
|
145
|
+
/** The value in CEL's terms, as `type()` names it; no host class name reaches the message. */
|
|
146
146
|
function runtimeTypeOf(value: unknown): string {
|
|
147
|
-
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return `a value of type ${(value as object).constructor?.name ?? typeof value}`;
|
|
147
|
+
const name = celTypeNameOf(value);
|
|
148
|
+
if (name === undefined) return "a value outside the CEL value domain";
|
|
149
|
+
if (name === "null_type") return "null";
|
|
150
|
+
if (name === "list") return "a list";
|
|
151
|
+
if (name === "map") return "a map";
|
|
152
|
+
return `a value of type ${typeValueName(name)}`;
|
|
154
153
|
}
|