@telorun/cel 0.0.0-stage → 0.108.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/LICENSE +17 -0
- package/README.md +281 -2
- package/dist/activation.d.ts +27 -0
- package/dist/activation.d.ts.map +1 -0
- package/dist/activation.js +24 -0
- package/dist/backend-runtime.d.ts +184 -0
- package/dist/backend-runtime.d.ts.map +1 -0
- package/dist/backend-runtime.js +425 -0
- package/dist/bounded-cache.d.ts +21 -0
- package/dist/bounded-cache.d.ts.map +1 -0
- package/dist/bounded-cache.js +42 -0
- package/dist/catalog-runtime.d.ts +59 -0
- package/dist/catalog-runtime.d.ts.map +1 -0
- package/dist/catalog-runtime.js +786 -0
- package/dist/cel-expression.d.ts +32 -0
- package/dist/cel-expression.d.ts.map +1 -0
- package/dist/cel-expression.js +29 -0
- package/dist/cel-map-value.d.ts +47 -0
- package/dist/cel-map-value.d.ts.map +1 -0
- package/dist/cel-map-value.js +85 -0
- package/dist/cel-program.d.ts +44 -0
- package/dist/cel-program.d.ts.map +1 -0
- package/dist/cel-program.js +72 -0
- package/dist/cel-type.d.ts +131 -0
- package/dist/cel-type.d.ts.map +1 -0
- package/dist/cel-type.js +293 -0
- package/dist/cel-value.d.ts +166 -0
- package/dist/cel-value.d.ts.map +1 -0
- package/dist/cel-value.js +225 -0
- package/dist/check-diagnostic.d.ts +54 -0
- package/dist/check-diagnostic.d.ts.map +1 -0
- package/dist/check-diagnostic.js +66 -0
- package/dist/checker.d.ts +86 -0
- package/dist/checker.d.ts.map +1 -0
- package/dist/checker.js +806 -0
- package/dist/closure-backend.d.ts +21 -0
- package/dist/closure-backend.d.ts.map +1 -0
- package/dist/closure-backend.js +487 -0
- package/dist/comprehension-bindings.d.ts +33 -0
- package/dist/comprehension-bindings.d.ts.map +1 -0
- package/dist/comprehension-bindings.js +50 -0
- package/dist/comprehension-runtime.d.ts +44 -0
- package/dist/comprehension-runtime.d.ts.map +1 -0
- package/dist/comprehension-runtime.js +137 -0
- package/dist/declared-chain.d.ts +35 -0
- package/dist/declared-chain.d.ts.map +1 -0
- package/dist/declared-chain.js +36 -0
- package/dist/duration-value.d.ts +70 -0
- package/dist/duration-value.d.ts.map +1 -0
- package/dist/duration-value.js +149 -0
- package/dist/emitted-module.d.ts +207 -0
- package/dist/emitted-module.d.ts.map +1 -0
- package/dist/emitted-module.js +359 -0
- package/dist/engine-version.d.ts +3 -0
- package/dist/engine-version.d.ts.map +1 -0
- package/dist/engine-version.js +8 -0
- package/dist/environment-digest.d.ts +44 -0
- package/dist/environment-digest.d.ts.map +1 -0
- package/dist/environment-digest.js +98 -0
- package/dist/environment.d.ts +291 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +474 -0
- package/dist/function-catalog.d.ts +66 -0
- package/dist/function-catalog.d.ts.map +1 -0
- package/dist/function-catalog.js +77 -0
- package/dist/function-registry.d.ts +118 -0
- package/dist/function-registry.d.ts.map +1 -0
- package/dist/function-registry.js +292 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/integer-arithmetic.d.ts +27 -0
- package/dist/integer-arithmetic.d.ts.map +1 -0
- package/dist/integer-arithmetic.js +58 -0
- package/dist/js-emitter.d.ts +133 -0
- package/dist/js-emitter.d.ts.map +1 -0
- package/dist/js-emitter.js +568 -0
- package/dist/json-schema-type.d.ts +182 -0
- package/dist/json-schema-type.d.ts.map +1 -0
- package/dist/json-schema-type.js +487 -0
- package/dist/json-text-scan.d.ts +28 -0
- package/dist/json-text-scan.d.ts.map +1 -0
- package/dist/json-text-scan.js +159 -0
- package/dist/lexer.d.ts +103 -0
- package/dist/lexer.d.ts.map +1 -0
- package/dist/lexer.js +458 -0
- package/dist/macro-check.d.ts +41 -0
- package/dist/macro-check.d.ts.map +1 -0
- package/dist/macro-check.js +162 -0
- package/dist/macro-shape.d.ts +24 -0
- package/dist/macro-shape.d.ts.map +1 -0
- package/dist/macro-shape.js +55 -0
- package/dist/member-read.d.ts +89 -0
- package/dist/member-read.d.ts.map +1 -0
- package/dist/member-read.js +166 -0
- package/dist/namespace-resolution.d.ts +35 -0
- package/dist/namespace-resolution.d.ts.map +1 -0
- package/dist/namespace-resolution.js +160 -0
- package/dist/nominal-type.d.ts +63 -0
- package/dist/nominal-type.d.ts.map +1 -0
- package/dist/nominal-type.js +98 -0
- package/dist/nullable-access.d.ts +38 -0
- package/dist/nullable-access.d.ts.map +1 -0
- package/dist/nullable-access.js +93 -0
- package/dist/parse-limits.d.ts +26 -0
- package/dist/parse-limits.d.ts.map +1 -0
- package/dist/parse-limits.js +21 -0
- package/dist/parser.d.ts +48 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +503 -0
- package/dist/qualified-calls.d.ts +22 -0
- package/dist/qualified-calls.d.ts.map +1 -0
- package/dist/qualified-calls.js +27 -0
- package/dist/regular-expression.d.ts +48 -0
- package/dist/regular-expression.d.ts.map +1 -0
- package/dist/regular-expression.js +77 -0
- package/dist/reserved-words.d.ts +52 -0
- package/dist/reserved-words.d.ts.map +1 -0
- package/dist/reserved-words.js +77 -0
- package/dist/resolved-call.d.ts +46 -0
- package/dist/resolved-call.d.ts.map +1 -0
- package/dist/resolved-call.js +15 -0
- package/dist/root-references.d.ts +23 -0
- package/dist/root-references.d.ts.map +1 -0
- package/dist/root-references.js +120 -0
- package/dist/runtime-library.d.ts +67 -0
- package/dist/runtime-library.d.ts.map +1 -0
- package/dist/runtime-library.js +554 -0
- package/dist/serializer.d.ts +24 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +256 -0
- package/dist/sha256.d.ts +20 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +103 -0
- package/dist/signature.d.ts +72 -0
- package/dist/signature.d.ts.map +1 -0
- package/dist/signature.js +61 -0
- package/dist/signatures/function-catalog.json +788 -0
- package/dist/signatures/standard-library.json +229 -0
- package/dist/standard-library.d.ts +41 -0
- package/dist/standard-library.d.ts.map +1 -0
- package/dist/standard-library.js +85 -0
- package/dist/syntax-diagnostic.d.ts +61 -0
- package/dist/syntax-diagnostic.d.ts.map +1 -0
- package/dist/syntax-diagnostic.js +28 -0
- package/dist/syntax-tree.d.ts +160 -0
- package/dist/syntax-tree.d.ts.map +1 -0
- package/dist/syntax-tree.js +58 -0
- package/dist/timestamp-value.d.ts +62 -0
- package/dist/timestamp-value.d.ts.map +1 -0
- package/dist/timestamp-value.js +238 -0
- package/dist/tree-equality.d.ts +15 -0
- package/dist/tree-equality.d.ts.map +1 -0
- package/dist/tree-equality.js +105 -0
- package/dist/type-expression.d.ts +42 -0
- package/dist/type-expression.d.ts.map +1 -0
- package/dist/type-expression.js +154 -0
- package/dist/value-equality.d.ts +38 -0
- package/dist/value-equality.d.ts.map +1 -0
- package/dist/value-equality.js +196 -0
- package/dist/value-text.d.ts +25 -0
- package/dist/value-text.d.ts.map +1 -0
- package/dist/value-text.js +44 -0
- package/dist/zoned-calendar.d.ts +61 -0
- package/dist/zoned-calendar.d.ts.map +1 -0
- package/dist/zoned-calendar.js +143 -0
- package/package.json +56 -3
- package/src/activation.ts +32 -0
- package/src/backend-runtime.ts +604 -0
- package/src/bounded-cache.ts +45 -0
- package/src/catalog-runtime.ts +921 -0
- package/src/cel-expression.ts +53 -0
- package/src/cel-map-value.ts +97 -0
- package/src/cel-program.ts +103 -0
- package/src/cel-type.ts +359 -0
- package/src/cel-value.ts +361 -0
- package/src/check-diagnostic.ts +104 -0
- package/src/checker.ts +1045 -0
- package/src/closure-backend.ts +547 -0
- package/src/comprehension-bindings.ts +66 -0
- package/src/comprehension-runtime.ts +157 -0
- package/src/declared-chain.ts +45 -0
- package/src/duration-value.ts +160 -0
- package/src/emitted-module.ts +494 -0
- package/src/engine-version.ts +9 -0
- package/src/environment-digest.ts +111 -0
- package/src/environment.ts +761 -0
- package/src/function-catalog.ts +140 -0
- package/src/function-registry.ts +341 -0
- package/src/index.ts +407 -0
- package/src/integer-arithmetic.ts +64 -0
- package/src/js-emitter.ts +721 -0
- package/src/json-schema-type.ts +664 -0
- package/src/json-text-scan.ts +163 -0
- package/src/lexer.ts +562 -0
- package/src/macro-check.ts +197 -0
- package/src/macro-shape.ts +66 -0
- package/src/member-read.ts +167 -0
- package/src/namespace-resolution.ts +167 -0
- package/src/nominal-type.ts +149 -0
- package/src/nullable-access.ts +95 -0
- package/src/parse-limits.ts +36 -0
- package/src/parser.ts +554 -0
- package/src/qualified-calls.ts +39 -0
- package/src/regular-expression.ts +101 -0
- package/src/reserved-words.ts +94 -0
- package/src/resolved-call.ts +47 -0
- package/src/root-references.ts +126 -0
- package/src/runtime-library.ts +639 -0
- package/src/serializer.ts +262 -0
- package/src/sha256.ts +112 -0
- package/src/signature.ts +127 -0
- package/src/signatures/function-catalog.json +788 -0
- package/src/signatures/standard-library.json +235 -0
- package/src/standard-library.ts +149 -0
- package/src/syntax-diagnostic.ts +72 -0
- package/src/syntax-tree.ts +229 -0
- package/src/timestamp-value.ts +310 -0
- package/src/tree-equality.ts +130 -0
- package/src/type-expression.ts +182 -0
- package/src/value-equality.ts +201 -0
- package/src/value-text.ts +45 -0
- package/src/zoned-calendar.ts +178 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generation": 1,
|
|
3
|
+
"description": "CEL's own standard library, as declarations. No implementation, no host vocabulary.",
|
|
4
|
+
"typeConstants": ["bool", "bytes", "double", "int", "list", "map", "null_type", "string", "type", "uint"],
|
|
5
|
+
"constants": [
|
|
6
|
+
{
|
|
7
|
+
"name": "google",
|
|
8
|
+
"type": "map<string, map<string, type>>",
|
|
9
|
+
"description": "The well-known type names, so that type(x) == google.protobuf.Timestamp can be written."
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"functions": [
|
|
13
|
+
{ "signature": "bool(bool): bool" },
|
|
14
|
+
{ "signature": "bool(string): bool" },
|
|
15
|
+
{ "signature": "bytes(bytes): bytes" },
|
|
16
|
+
{ "signature": "bytes(string): bytes" },
|
|
17
|
+
{ "signature": "double(double): double" },
|
|
18
|
+
{ "signature": "double(int): double" },
|
|
19
|
+
{ "signature": "double(uint): double" },
|
|
20
|
+
{ "signature": "double(string): double" },
|
|
21
|
+
{ "signature": "duration(string): google.protobuf.Duration" },
|
|
22
|
+
{ "signature": "duration(google.protobuf.Duration): google.protobuf.Duration" },
|
|
23
|
+
{ "signature": "dyn(A): dyn" },
|
|
24
|
+
{ "signature": "int(int): int" },
|
|
25
|
+
{ "signature": "int(uint): int" },
|
|
26
|
+
{ "signature": "int(double): int" },
|
|
27
|
+
{ "signature": "int(string): int" },
|
|
28
|
+
{ "signature": "int(google.protobuf.Timestamp): int" },
|
|
29
|
+
{ "signature": "int(google.protobuf.Duration): int" },
|
|
30
|
+
{ "signature": "matches(string, string): bool" },
|
|
31
|
+
{ "signature": "size(string): int" },
|
|
32
|
+
{ "signature": "size(bytes): int" },
|
|
33
|
+
{ "signature": "size(list<A>): int" },
|
|
34
|
+
{ "signature": "size(map<K, V>): int" },
|
|
35
|
+
{ "signature": "string(string): string" },
|
|
36
|
+
{ "signature": "string(bool): string" },
|
|
37
|
+
{ "signature": "string(int): string" },
|
|
38
|
+
{ "signature": "string(uint): string" },
|
|
39
|
+
{ "signature": "string(double): string" },
|
|
40
|
+
{ "signature": "string(bytes): string" },
|
|
41
|
+
{ "signature": "string(google.protobuf.Timestamp): string" },
|
|
42
|
+
{ "signature": "string(google.protobuf.Duration): string" },
|
|
43
|
+
{ "signature": "timestamp(string): google.protobuf.Timestamp" },
|
|
44
|
+
{ "signature": "timestamp(int): google.protobuf.Timestamp" },
|
|
45
|
+
{ "signature": "timestamp(google.protobuf.Timestamp): google.protobuf.Timestamp" },
|
|
46
|
+
{ "signature": "type(int): type" },
|
|
47
|
+
{ "signature": "type(uint): type" },
|
|
48
|
+
{ "signature": "type(double): type" },
|
|
49
|
+
{ "signature": "type(bool): type" },
|
|
50
|
+
{ "signature": "type(string): type" },
|
|
51
|
+
{ "signature": "type(bytes): type" },
|
|
52
|
+
{ "signature": "type(null): type" },
|
|
53
|
+
{ "signature": "type(type): type" },
|
|
54
|
+
{ "signature": "type(list<A>): type" },
|
|
55
|
+
{ "signature": "type(map<K, V>): type" },
|
|
56
|
+
{ "signature": "type(google.protobuf.Timestamp): type" },
|
|
57
|
+
{ "signature": "type(google.protobuf.Duration): type" },
|
|
58
|
+
{ "signature": "uint(uint): uint" },
|
|
59
|
+
{ "signature": "uint(int): uint" },
|
|
60
|
+
{ "signature": "uint(double): uint" },
|
|
61
|
+
{ "signature": "uint(string): uint" },
|
|
62
|
+
{ "signature": "string.size(): int" },
|
|
63
|
+
{ "signature": "bytes.size(): int" },
|
|
64
|
+
{ "signature": "list<A>.size(): int" },
|
|
65
|
+
{ "signature": "map<K, V>.size(): int" },
|
|
66
|
+
{ "signature": "string.startsWith(string): bool" },
|
|
67
|
+
{ "signature": "string.endsWith(string): bool" },
|
|
68
|
+
{ "signature": "string.contains(string): bool" },
|
|
69
|
+
{ "signature": "string.matches(string): bool" },
|
|
70
|
+
{ "signature": "string.lowerAscii(): string", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: despite its name it lowercases every letter the host language's own casing lowercases, not the ASCII letters alone, so 'TacoC\u00c6t'.lowerAscii() answers 'tacoc\u00e6t' where the extension answers 'tacoc\u00c6t'. Kept, with that behaviour, for the manifests already written against it" },
|
|
71
|
+
{ "signature": "string.upperAscii(): string", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: despite its name it uppercases every letter the host language's own casing uppercases, not the ASCII letters alone. Kept, with that behaviour, for the manifests already written against it" },
|
|
72
|
+
{ "signature": "string.trim(): string", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: the characters it trims are the host language's own whitespace set, which is not the extension's (U+0085 is trimmed by one and not the other). Kept for the manifests already written against it" },
|
|
73
|
+
{ "signature": "string.indexOf(string): int", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: indices are UTF-16 CODE UNITS, not code points, so a string holding a character outside the basic plane is indexed differently than the extension indexes it \u2014 a port that read this member as the extension's would index by rune and silently change the answer of every manifest that cuts a string. Kept for the manifests already written against it" },
|
|
74
|
+
{ "signature": "string.indexOf(string, int): int", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: indices are UTF-16 CODE UNITS, not code points, so a string holding a character outside the basic plane is indexed differently than the extension indexes it \u2014 a port that read this member as the extension's would index by rune and silently change the answer of every manifest that cuts a string, and the index it takes is one too. Kept for the manifests already written against it" },
|
|
75
|
+
{ "signature": "string.lastIndexOf(string): int", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: indices are UTF-16 CODE UNITS, not code points, so a string holding a character outside the basic plane is indexed differently than the extension indexes it \u2014 a port that read this member as the extension's would index by rune and silently change the answer of every manifest that cuts a string. Kept for the manifests already written against it" },
|
|
76
|
+
{ "signature": "string.lastIndexOf(string, int): int", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: indices are UTF-16 CODE UNITS, not code points, so a string holding a character outside the basic plane is indexed differently than the extension indexes it \u2014 a port that read this member as the extension's would index by rune and silently change the answer of every manifest that cuts a string, and the index it takes is one too. Kept for the manifests already written against it" },
|
|
77
|
+
{ "signature": "string.substring(int): string", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: indices are UTF-16 CODE UNITS, not code points, so a string holding a character outside the basic plane is indexed differently than the extension indexes it \u2014 a port that read this member as the extension's would index by rune and silently change the answer of every manifest that cuts a string. Kept for the manifests already written against it \u2014 and because an index may fall between the halves of a surrogate pair, this member can build a string holding a lone surrogate, which is outside the CEL value domain and which the conformance encoding refuses by contract" },
|
|
78
|
+
{ "signature": "string.substring(int, int): string", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: indices are UTF-16 CODE UNITS, not code points, so a string holding a character outside the basic plane is indexed differently than the extension indexes it \u2014 a port that read this member as the extension's would index by rune and silently change the answer of every manifest that cuts a string. Kept for the manifests already written against it \u2014 and because an index may fall between the halves of a surrogate pair, this member can build a string holding a lone surrogate, which is outside the CEL value domain and which the conformance encoding refuses by contract" },
|
|
79
|
+
{ "signature": "string.split(string): list<string>", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it: an empty separator splits into UTF-16 code units rather than code points, so a character outside the basic plane comes apart. Kept for the manifests already written against it" },
|
|
80
|
+
{ "signature": "string.split(string, int): list<string>", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member differs from it as the one-argument form does, and a negative limit takes every part, zero takes none and a positive one keeps the remainder in the last. Kept for the manifests already written against it" },
|
|
81
|
+
{ "signature": "list<string>.join(): string", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member computes what that equivalent computes, which is exactly why it is declared here: CEL defines no join, so a port must not take this one for CEL's. Kept for the manifests already written against it" },
|
|
82
|
+
{ "signature": "list<string>.join(string): string", "spec": false, "reason": "cel-spec's standard definitions over strings are size, startsWith, endsWith, matches, contains and concatenation, and nothing else; the strings extension has an equivalent, which Telo does not ship. This member computes what that equivalent computes; CEL defines no join, so a port must not take this one for CEL's. Kept for the manifests already written against it" },
|
|
83
|
+
{ "signature": "bytes.string(): string", "spec": false, "reason": "CEL converts bytes to text as string(bytes); this member form is the engine being replaced's own, kept for the manifests written against it" },
|
|
84
|
+
{ "signature": "bytes.hex(): string", "spec": false, "reason": "no CEL library renders bytes as hexadecimal; kept for the manifests written against it" },
|
|
85
|
+
{ "signature": "bytes.base64(): string", "spec": false, "reason": "CEL encodes base64 through its encoders extension, which this engine does not carry; kept for the manifests written against it" },
|
|
86
|
+
{ "signature": "bytes.json(): dyn", "spec": false, "reason": "no CEL library parses JSON; kept for the manifests written against it", "deterministic": true },
|
|
87
|
+
{ "signature": "bytes.at(int): int", "spec": false, "reason": "no CEL library indexes bytes by a member call; kept for the manifests written against it" },
|
|
88
|
+
{ "signature": "google.protobuf.Timestamp.getDate(): int" },
|
|
89
|
+
{ "signature": "google.protobuf.Timestamp.getDate(string): int" },
|
|
90
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfMonth(): int" },
|
|
91
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfMonth(string): int" },
|
|
92
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfWeek(): int" },
|
|
93
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfWeek(string): int" },
|
|
94
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfYear(): int" },
|
|
95
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfYear(string): int" },
|
|
96
|
+
{ "signature": "google.protobuf.Timestamp.getFullYear(): int" },
|
|
97
|
+
{ "signature": "google.protobuf.Timestamp.getFullYear(string): int" },
|
|
98
|
+
{ "signature": "google.protobuf.Timestamp.getHours(): int" },
|
|
99
|
+
{ "signature": "google.protobuf.Timestamp.getHours(string): int" },
|
|
100
|
+
{ "signature": "google.protobuf.Timestamp.getMilliseconds(): int" },
|
|
101
|
+
{ "signature": "google.protobuf.Timestamp.getMilliseconds(string): int" },
|
|
102
|
+
{ "signature": "google.protobuf.Timestamp.getMinutes(): int" },
|
|
103
|
+
{ "signature": "google.protobuf.Timestamp.getMinutes(string): int" },
|
|
104
|
+
{ "signature": "google.protobuf.Timestamp.getMonth(): int" },
|
|
105
|
+
{ "signature": "google.protobuf.Timestamp.getMonth(string): int" },
|
|
106
|
+
{ "signature": "google.protobuf.Timestamp.getSeconds(): int" },
|
|
107
|
+
{ "signature": "google.protobuf.Timestamp.getSeconds(string): int" },
|
|
108
|
+
{ "signature": "google.protobuf.Duration.getHours(): int" },
|
|
109
|
+
{ "signature": "google.protobuf.Duration.getMinutes(): int" },
|
|
110
|
+
{ "signature": "google.protobuf.Duration.getSeconds(): int" },
|
|
111
|
+
{ "signature": "google.protobuf.Duration.getMilliseconds(): int" }
|
|
112
|
+
],
|
|
113
|
+
"optionalTypeConstants": ["optional_type"],
|
|
114
|
+
"optionalTypeOperators": [
|
|
115
|
+
{ "operator": "==", "parameters": ["optional<A>", "optional<A>"], "returns": "bool" },
|
|
116
|
+
{ "operator": "!=", "parameters": ["optional<A>", "optional<A>"], "returns": "bool" }
|
|
117
|
+
],
|
|
118
|
+
"optionalTypeFunctions": [
|
|
119
|
+
{ "signature": "type(optional<A>): type" },
|
|
120
|
+
{ "signature": "optional<A>.hasValue(): bool" },
|
|
121
|
+
{ "signature": "optional<A>.value(): A" },
|
|
122
|
+
{ "signature": "optional<A>.or(optional<A>): optional<A>" },
|
|
123
|
+
{ "signature": "optional<A>.orValue(A): A" }
|
|
124
|
+
],
|
|
125
|
+
"operators": [
|
|
126
|
+
{ "operator": "!", "parameters": ["bool"], "returns": "bool" },
|
|
127
|
+
{ "operator": "-", "parameters": ["int"], "returns": "int" },
|
|
128
|
+
{ "operator": "-", "parameters": ["double"], "returns": "double" },
|
|
129
|
+
{ "operator": "+", "parameters": ["int", "int"], "returns": "int" },
|
|
130
|
+
{ "operator": "+", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
131
|
+
{ "operator": "+", "parameters": ["double", "double"], "returns": "double" },
|
|
132
|
+
{ "operator": "+", "parameters": ["string", "string"], "returns": "string" },
|
|
133
|
+
{ "operator": "+", "parameters": ["bytes", "bytes"], "returns": "bytes" },
|
|
134
|
+
{ "operator": "+", "parameters": ["list<A>", "list<A>"], "returns": "list<A>" },
|
|
135
|
+
{
|
|
136
|
+
"operator": "+",
|
|
137
|
+
"parameters": ["google.protobuf.Timestamp", "google.protobuf.Duration"],
|
|
138
|
+
"returns": "google.protobuf.Timestamp"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"operator": "+",
|
|
142
|
+
"parameters": ["google.protobuf.Duration", "google.protobuf.Timestamp"],
|
|
143
|
+
"returns": "google.protobuf.Timestamp"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"operator": "+",
|
|
147
|
+
"parameters": ["google.protobuf.Duration", "google.protobuf.Duration"],
|
|
148
|
+
"returns": "google.protobuf.Duration"
|
|
149
|
+
},
|
|
150
|
+
{ "operator": "-", "parameters": ["int", "int"], "returns": "int" },
|
|
151
|
+
{ "operator": "-", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
152
|
+
{ "operator": "-", "parameters": ["double", "double"], "returns": "double" },
|
|
153
|
+
{
|
|
154
|
+
"operator": "-",
|
|
155
|
+
"parameters": ["google.protobuf.Timestamp", "google.protobuf.Timestamp"],
|
|
156
|
+
"returns": "google.protobuf.Duration"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"operator": "-",
|
|
160
|
+
"parameters": ["google.protobuf.Timestamp", "google.protobuf.Duration"],
|
|
161
|
+
"returns": "google.protobuf.Timestamp"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"operator": "-",
|
|
165
|
+
"parameters": ["google.protobuf.Duration", "google.protobuf.Duration"],
|
|
166
|
+
"returns": "google.protobuf.Duration"
|
|
167
|
+
},
|
|
168
|
+
{ "operator": "*", "parameters": ["int", "int"], "returns": "int" },
|
|
169
|
+
{ "operator": "*", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
170
|
+
{ "operator": "*", "parameters": ["double", "double"], "returns": "double" },
|
|
171
|
+
{ "operator": "/", "parameters": ["int", "int"], "returns": "int" },
|
|
172
|
+
{ "operator": "/", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
173
|
+
{ "operator": "/", "parameters": ["double", "double"], "returns": "double" },
|
|
174
|
+
{ "operator": "%", "parameters": ["int", "int"], "returns": "int" },
|
|
175
|
+
{ "operator": "%", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
176
|
+
{ "operator": "in", "parameters": ["A", "list<A>"], "returns": "bool" },
|
|
177
|
+
{ "operator": "in", "parameters": ["K", "map<K, V>"], "returns": "bool" }
|
|
178
|
+
],
|
|
179
|
+
"symmetricOperators": [
|
|
180
|
+
{
|
|
181
|
+
"operators": ["==", "!="],
|
|
182
|
+
"types": [
|
|
183
|
+
"int",
|
|
184
|
+
"uint",
|
|
185
|
+
"double",
|
|
186
|
+
"bool",
|
|
187
|
+
"string",
|
|
188
|
+
"bytes",
|
|
189
|
+
"null",
|
|
190
|
+
"type",
|
|
191
|
+
"list<A>",
|
|
192
|
+
"map<K, V>",
|
|
193
|
+
"google.protobuf.Timestamp",
|
|
194
|
+
"google.protobuf.Duration"
|
|
195
|
+
],
|
|
196
|
+
"returns": "bool",
|
|
197
|
+
"description": "Equality is declared per type: two values of unrelated types are not compared, and an optional is not compared at all."
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"operators": ["<", "<=", ">", ">="],
|
|
201
|
+
"types": [
|
|
202
|
+
"int",
|
|
203
|
+
"uint",
|
|
204
|
+
"double",
|
|
205
|
+
"bool",
|
|
206
|
+
"string",
|
|
207
|
+
"bytes",
|
|
208
|
+
"google.protobuf.Timestamp",
|
|
209
|
+
"google.protobuf.Duration"
|
|
210
|
+
],
|
|
211
|
+
"returns": "bool",
|
|
212
|
+
"description": "CEL orders every scalar type. A list and a map are comparable for equality alone."
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"crossNumericOperators": {
|
|
216
|
+
"operators": ["<", "<=", ">", ">="],
|
|
217
|
+
"pairs": [
|
|
218
|
+
["int", "uint"],
|
|
219
|
+
["int", "double"],
|
|
220
|
+
["uint", "int"],
|
|
221
|
+
["uint", "double"],
|
|
222
|
+
["double", "int"],
|
|
223
|
+
["double", "uint"]
|
|
224
|
+
],
|
|
225
|
+
"returns": "bool",
|
|
226
|
+
"spec": false,
|
|
227
|
+
"reason": "CEL's checker is strict about the numeric types — its own suite writes dyn(1) < 2u precisely because of that — so ordering across them is an extension of what the language accepts at check time, kept because manifests rely on it. It never computes across them, and equality across them stays refused."
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading CEL's standard library into an environment.
|
|
3
|
+
*
|
|
4
|
+
* The library is **data** (`signatures/standard-library.json`) read through the same
|
|
5
|
+
* registration surface a host uses, with no privileged path of any kind. That is what
|
|
6
|
+
* makes a standard signature replaceable and removable, which is the capability the
|
|
7
|
+
* package exists for: an engine whose library registers itself through a private door
|
|
8
|
+
* cannot have one of its signatures overridden, and an override is how a host gives
|
|
9
|
+
* `duration(string)` a type of its own.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here is an implementation — the library's declarations and its behaviour are
|
|
12
|
+
* separate concerns, and a checker needs only the first.
|
|
13
|
+
*/
|
|
14
|
+
import type { CelType } from "./cel-type.js";
|
|
15
|
+
import type { FunctionRegistry } from "./function-registry.js";
|
|
16
|
+
import type { NominalResolver } from "./type-expression.js";
|
|
17
|
+
export declare const STANDARD_LIBRARY_GENERATION: number;
|
|
18
|
+
/** A constant the standard library declares: its name and the type it reads as. */
|
|
19
|
+
export interface StandardConstant {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly type: CelType;
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every name the library declares as a constant: the type names (`int`, `list`, …),
|
|
26
|
+
* each of type `type`, and `google`, through which the well-known type names are read.
|
|
27
|
+
*/
|
|
28
|
+
export declare function standardConstants(optionalTypes: boolean): readonly StandardConstant[];
|
|
29
|
+
/** The value `google` reads as: the two well-known type names, as type values. */
|
|
30
|
+
export declare function googleTypeNames(): ReadonlyMap<string, readonly string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Registers the library onto a registry. `optionalTypes` adds the optional-type
|
|
33
|
+
* members, which exist only where the option enables them.
|
|
34
|
+
*/
|
|
35
|
+
export declare function registerStandardLibrary(registry: FunctionRegistry, options: {
|
|
36
|
+
optionalTypes: boolean;
|
|
37
|
+
resolveNominal?: NominalResolver;
|
|
38
|
+
}): void;
|
|
39
|
+
/** Every signature of the library as text, for a validator and for a docs listing. */
|
|
40
|
+
export declare function standardLibrarySignatures(): readonly string[];
|
|
41
|
+
//# sourceMappingURL=standard-library.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-library.d.ts","sourceRoot":"","sources":["../src/standard-library.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA6C5D,eAAO,MAAM,2BAA2B,QAAkB,CAAC;AAE3D,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,OAAO,GAAG,SAAS,gBAAgB,EAAE,CASrF;AAED,kFAAkF;AAClF,wBAAgB,eAAe,IAAI,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAExE;AAQD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE;IAAE,aAAa,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,eAAe,CAAA;CAAE,GACpE,IAAI,CAwBN;AAcD,sFAAsF;AACtF,wBAAgB,yBAAyB,IAAI,SAAS,MAAM,EAAE,CAE7D"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading CEL's standard library into an environment.
|
|
3
|
+
*
|
|
4
|
+
* The library is **data** (`signatures/standard-library.json`) read through the same
|
|
5
|
+
* registration surface a host uses, with no privileged path of any kind. That is what
|
|
6
|
+
* makes a standard signature replaceable and removable, which is the capability the
|
|
7
|
+
* package exists for: an engine whose library registers itself through a private door
|
|
8
|
+
* cannot have one of its signatures overridden, and an override is how a host gives
|
|
9
|
+
* `duration(string)` a type of its own.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here is an implementation — the library's declarations and its behaviour are
|
|
12
|
+
* separate concerns, and a checker needs only the first.
|
|
13
|
+
*/
|
|
14
|
+
import library from "./signatures/standard-library.json" with { type: "json" };
|
|
15
|
+
import { TYPE } from "./cel-type.js";
|
|
16
|
+
import { parseSignature } from "./signature.js";
|
|
17
|
+
import { parseTypeExpression } from "./type-expression.js";
|
|
18
|
+
const DATA = library;
|
|
19
|
+
export const STANDARD_LIBRARY_GENERATION = DATA.generation;
|
|
20
|
+
/**
|
|
21
|
+
* Every name the library declares as a constant: the type names (`int`, `list`, …),
|
|
22
|
+
* each of type `type`, and `google`, through which the well-known type names are read.
|
|
23
|
+
*/
|
|
24
|
+
export function standardConstants(optionalTypes) {
|
|
25
|
+
const names = [...DATA.typeConstants, ...(optionalTypes ? DATA.optionalTypeConstants : [])];
|
|
26
|
+
const types = names.map((name) => ({ name, type: TYPE }));
|
|
27
|
+
const named = DATA.constants.map((entry) => ({
|
|
28
|
+
name: entry.name,
|
|
29
|
+
type: parseTypeExpression(entry.type),
|
|
30
|
+
...(entry.description === undefined ? {} : { description: entry.description }),
|
|
31
|
+
}));
|
|
32
|
+
return [...types, ...named];
|
|
33
|
+
}
|
|
34
|
+
/** The value `google` reads as: the two well-known type names, as type values. */
|
|
35
|
+
export function googleTypeNames() {
|
|
36
|
+
return new Map([["protobuf", ["Duration", "Timestamp"]]]);
|
|
37
|
+
}
|
|
38
|
+
const metadataOf = (entry) => ({
|
|
39
|
+
deterministic: entry.deterministic ?? true,
|
|
40
|
+
origin: "standard-library",
|
|
41
|
+
...(entry.description === undefined ? {} : { description: entry.description }),
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Registers the library onto a registry. `optionalTypes` adds the optional-type
|
|
45
|
+
* members, which exist only where the option enables them.
|
|
46
|
+
*/
|
|
47
|
+
export function registerStandardLibrary(registry, options) {
|
|
48
|
+
for (const entry of DATA.functions) {
|
|
49
|
+
registry.register(parseSignature(entry.signature, options.resolveNominal), metadataOf(entry));
|
|
50
|
+
}
|
|
51
|
+
if (options.optionalTypes) {
|
|
52
|
+
for (const entry of DATA.optionalTypeFunctions) {
|
|
53
|
+
registry.register(parseSignature(entry.signature, options.resolveNominal), metadataOf(entry));
|
|
54
|
+
}
|
|
55
|
+
for (const entry of DATA.optionalTypeOperators)
|
|
56
|
+
registerOperatorData(registry, entry);
|
|
57
|
+
}
|
|
58
|
+
for (const entry of DATA.operators)
|
|
59
|
+
registerOperatorData(registry, entry);
|
|
60
|
+
for (const group of DATA.symmetricOperators) {
|
|
61
|
+
for (const operator of group.operators) {
|
|
62
|
+
for (const type of group.types) {
|
|
63
|
+
registerOperatorData(registry, { operator, parameters: [type, type], returns: group.returns });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const cross = DATA.crossNumericOperators;
|
|
68
|
+
for (const operator of cross.operators) {
|
|
69
|
+
for (const [left, right] of cross.pairs) {
|
|
70
|
+
registerOperatorData(registry, { operator, parameters: [left, right], returns: cross.returns });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function registerOperatorData(registry, entry) {
|
|
75
|
+
registry.register({
|
|
76
|
+
name: entry.operator,
|
|
77
|
+
form: "global",
|
|
78
|
+
parameters: entry.parameters.map((text) => parseTypeExpression(text)),
|
|
79
|
+
returns: parseTypeExpression(entry.returns),
|
|
80
|
+
}, { deterministic: true, origin: "standard-library" });
|
|
81
|
+
}
|
|
82
|
+
/** Every signature of the library as text, for a validator and for a docs listing. */
|
|
83
|
+
export function standardLibrarySignatures() {
|
|
84
|
+
return [...DATA.functions, ...DATA.optionalTypeFunctions].map((entry) => entry.signature);
|
|
85
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the front end says when it cannot read the source.
|
|
3
|
+
*
|
|
4
|
+
* A syntax diagnostic is DATA, never a thrown error and never a sentence a
|
|
5
|
+
* consumer re-derives: it carries a code from the closed set below, the range of
|
|
6
|
+
* the offending text, and a message for a reader. Parsing reports **at most one**
|
|
7
|
+
* — the first thing it could not read — because the text after it is no longer
|
|
8
|
+
* trustworthy and a cascade of guesses is what makes a half-typed expression
|
|
9
|
+
* unusable in an editor. Everything the parser could read is still in the tree.
|
|
10
|
+
*/
|
|
11
|
+
export type CelSyntaxCode =
|
|
12
|
+
/** A character that begins no CEL token. */
|
|
13
|
+
"unexpected_character"
|
|
14
|
+
/** A token that cannot stand where it does. */
|
|
15
|
+
| "unexpected_token"
|
|
16
|
+
/** The source ended with an expression unfinished. */
|
|
17
|
+
| "unexpected_end"
|
|
18
|
+
/** A string or bytes literal that no quote closes. */
|
|
19
|
+
| "unterminated_string"
|
|
20
|
+
/** A reserved word written where an identifier must be. */
|
|
21
|
+
| "reserved_identifier"
|
|
22
|
+
/** A number literal that is not spelled as one. */
|
|
23
|
+
| "invalid_number"
|
|
24
|
+
/** An integer literal outside the int64 range. */
|
|
25
|
+
| "invalid_integer"
|
|
26
|
+
/** An unsigned integer literal outside the uint64 range. */
|
|
27
|
+
| "invalid_unsigned_integer"
|
|
28
|
+
/** An escape sequence no string or bytes literal admits. */
|
|
29
|
+
| "invalid_escape_sequence"
|
|
30
|
+
/** A `\\u`/`\\U` escape naming no Unicode code point. */
|
|
31
|
+
| "invalid_unicode_escape"
|
|
32
|
+
/** A `\\u` escape naming a surrogate not paired with its partner. */
|
|
33
|
+
| "invalid_unicode_surrogate"
|
|
34
|
+
/** A `\\x`/`\\X` escape with fewer than two hexadecimal digits. */
|
|
35
|
+
| "invalid_hex_escape"
|
|
36
|
+
/** A `\\nnn` escape with fewer than three octal digits. */
|
|
37
|
+
| "invalid_octal_escape"
|
|
38
|
+
/** A `\\nnn` escape naming a value above 255. */
|
|
39
|
+
| "octal_escape_out_of_range"
|
|
40
|
+
/** A `\\u`/`\\U` escape inside a bytes literal, which holds bytes and not text. */
|
|
41
|
+
| "bytes_unicode_escape"
|
|
42
|
+
/** One of the five input limits was reached. */
|
|
43
|
+
| "limit_exceeded";
|
|
44
|
+
export interface CelSyntaxDiagnostic {
|
|
45
|
+
readonly code: CelSyntaxCode;
|
|
46
|
+
readonly message: string;
|
|
47
|
+
readonly range: readonly [start: number, end: number];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Collects the first diagnostic and ignores every later one.
|
|
51
|
+
*
|
|
52
|
+
* Shared by the lexer and the parser so that "the first thing that could not be
|
|
53
|
+
* read" is one fact rather than two components' opinions of it.
|
|
54
|
+
*/
|
|
55
|
+
export declare class FirstSyntaxDiagnostic {
|
|
56
|
+
private held;
|
|
57
|
+
report(code: CelSyntaxCode, message: string, start: number, end: number): void;
|
|
58
|
+
get reported(): boolean;
|
|
59
|
+
list(): readonly CelSyntaxDiagnostic[];
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=syntax-diagnostic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax-diagnostic.d.ts","sourceRoot":"","sources":["../src/syntax-diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,aAAa;AACvB,4CAA4C;AAC1C,sBAAsB;AACxB,+CAA+C;GAC7C,kBAAkB;AACpB,sDAAsD;GACpD,gBAAgB;AAClB,sDAAsD;GACpD,qBAAqB;AACvB,2DAA2D;GACzD,qBAAqB;AACvB,mDAAmD;GACjD,gBAAgB;AAClB,kDAAkD;GAChD,iBAAiB;AACnB,4DAA4D;GAC1D,0BAA0B;AAC5B,4DAA4D;GAC1D,yBAAyB;AAC3B,yDAAyD;GACvD,wBAAwB;AAC1B,qEAAqE;GACnE,2BAA2B;AAC7B,mEAAmE;GACjE,oBAAoB;AACtB,2DAA2D;GACzD,sBAAsB;AACxB,iDAAiD;GAC/C,2BAA2B;AAC7B,mFAAmF;GACjF,sBAAsB;AACxB,gDAAgD;GAC9C,gBAAgB,CAAC;AAErB,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;;GAKG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,IAAI,CAAkC;IAE9C,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAI9E,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,IAAI,SAAS,mBAAmB,EAAE;CAGvC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the front end says when it cannot read the source.
|
|
3
|
+
*
|
|
4
|
+
* A syntax diagnostic is DATA, never a thrown error and never a sentence a
|
|
5
|
+
* consumer re-derives: it carries a code from the closed set below, the range of
|
|
6
|
+
* the offending text, and a message for a reader. Parsing reports **at most one**
|
|
7
|
+
* — the first thing it could not read — because the text after it is no longer
|
|
8
|
+
* trustworthy and a cascade of guesses is what makes a half-typed expression
|
|
9
|
+
* unusable in an editor. Everything the parser could read is still in the tree.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Collects the first diagnostic and ignores every later one.
|
|
13
|
+
*
|
|
14
|
+
* Shared by the lexer and the parser so that "the first thing that could not be
|
|
15
|
+
* read" is one fact rather than two components' opinions of it.
|
|
16
|
+
*/
|
|
17
|
+
export class FirstSyntaxDiagnostic {
|
|
18
|
+
held;
|
|
19
|
+
report(code, message, start, end) {
|
|
20
|
+
this.held ??= { code, message, range: [start, end] };
|
|
21
|
+
}
|
|
22
|
+
get reported() {
|
|
23
|
+
return this.held !== undefined;
|
|
24
|
+
}
|
|
25
|
+
list() {
|
|
26
|
+
return this.held ? [this.held] : [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical CEL syntax tree.
|
|
3
|
+
*
|
|
4
|
+
* Every node carries `range`, the half-open `[start, end)` span of UTF-16 code
|
|
5
|
+
* units it covers in the source it was parsed from, so a diagnostic, a hover or a
|
|
6
|
+
* rename can point at the text the author wrote. A tree built by hand carries
|
|
7
|
+
* ranges too — the serializer and the queries read them, and a node with none
|
|
8
|
+
* would make either answer silently wrong.
|
|
9
|
+
*
|
|
10
|
+
* Literals hold their decoded value in a tagged form rather than as a bare
|
|
11
|
+
* JavaScript value: CEL's `int` and `uint` are both arbitrary-magnitude integers,
|
|
12
|
+
* `1` and `1u` are different expressions, and a backend must be able to tell them
|
|
13
|
+
* apart without consulting a runtime value class.
|
|
14
|
+
*
|
|
15
|
+
* `qcall` is the one node the parser never produces — see `namespace-resolution.ts`.
|
|
16
|
+
*/
|
|
17
|
+
/** Half-open span of UTF-16 code units: `[start, end)`. */
|
|
18
|
+
export type SourceRange = readonly [start: number, end: number];
|
|
19
|
+
export type CelLiteral = {
|
|
20
|
+
readonly type: "int";
|
|
21
|
+
readonly value: bigint;
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: "uint";
|
|
24
|
+
readonly value: bigint;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: "double";
|
|
27
|
+
readonly value: number;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
readonly value: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "bytes";
|
|
33
|
+
readonly value: Uint8Array;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "bool";
|
|
36
|
+
readonly value: boolean;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "null";
|
|
39
|
+
};
|
|
40
|
+
export type CelUnaryOperator = "!" | "-";
|
|
41
|
+
export type CelBinaryOperator = "||" | "&&" | "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "+" | "-" | "*" | "/" | "%";
|
|
42
|
+
interface Ranged {
|
|
43
|
+
readonly range: SourceRange;
|
|
44
|
+
}
|
|
45
|
+
export interface CelLiteralNode extends Ranged {
|
|
46
|
+
readonly kind: "literal";
|
|
47
|
+
readonly literal: CelLiteral;
|
|
48
|
+
}
|
|
49
|
+
export interface CelIdentNode extends Ranged {
|
|
50
|
+
readonly kind: "ident";
|
|
51
|
+
readonly name: string;
|
|
52
|
+
/**
|
|
53
|
+
* `.y` — the name is resolved against the environment's own declarations, never
|
|
54
|
+
* against a name something inside the expression bound. It is the only spelling for
|
|
55
|
+
* the outer `request` where a comprehension variable is also called `request`.
|
|
56
|
+
*/
|
|
57
|
+
readonly absolute: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* One element of a list literal. `optional` marks `[?x]`: the element holds an
|
|
61
|
+
* `optional<T>` and contributes a `T`, and an absent one leaves no element behind.
|
|
62
|
+
*/
|
|
63
|
+
export interface CelListElement {
|
|
64
|
+
readonly value: CelNode;
|
|
65
|
+
readonly optional: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface CelListNode extends Ranged {
|
|
68
|
+
readonly kind: "list";
|
|
69
|
+
readonly elements: readonly CelListElement[];
|
|
70
|
+
}
|
|
71
|
+
/** One entry of a map literal. `optional` marks `{?k: v}`, as for a list element. */
|
|
72
|
+
export interface CelMapEntry {
|
|
73
|
+
readonly key: CelNode;
|
|
74
|
+
readonly value: CelNode;
|
|
75
|
+
readonly optional: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface CelMapNode extends Ranged {
|
|
78
|
+
readonly kind: "map";
|
|
79
|
+
readonly entries: readonly CelMapEntry[];
|
|
80
|
+
}
|
|
81
|
+
/** `operand.field`, `operand.?field` when `optional`, `` operand.`field` `` when `quoted`. */
|
|
82
|
+
export interface CelSelectNode extends Ranged {
|
|
83
|
+
readonly kind: "select";
|
|
84
|
+
readonly operand: CelNode;
|
|
85
|
+
/** The member's name, decoded: the text between the backticks for a quoted one. */
|
|
86
|
+
readonly field: string;
|
|
87
|
+
readonly fieldRange: SourceRange;
|
|
88
|
+
readonly optional: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Written between backticks, which is how a member whose name is not spelled as an
|
|
91
|
+
* identifier is read — `content-type`, `foo.txt`, `/api/v1`. It changes nothing about
|
|
92
|
+
* what is read: the name is looked up exactly as a plain member's is.
|
|
93
|
+
*/
|
|
94
|
+
readonly quoted: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** `operand[index]`, and `operand[?index]` when `optional`. */
|
|
97
|
+
export interface CelIndexNode extends Ranged {
|
|
98
|
+
readonly kind: "index";
|
|
99
|
+
readonly operand: CelNode;
|
|
100
|
+
readonly index: CelNode;
|
|
101
|
+
readonly optional: boolean;
|
|
102
|
+
}
|
|
103
|
+
/** `name(args)`. */
|
|
104
|
+
export interface CelCallNode extends Ranged {
|
|
105
|
+
readonly kind: "call";
|
|
106
|
+
readonly name: string;
|
|
107
|
+
readonly nameRange: SourceRange;
|
|
108
|
+
readonly args: readonly CelNode[];
|
|
109
|
+
}
|
|
110
|
+
/** `receiver.name(args)`, including every macro call — nothing expands one here. */
|
|
111
|
+
export interface CelReceiverCallNode extends Ranged {
|
|
112
|
+
readonly kind: "receiverCall";
|
|
113
|
+
readonly receiver: CelNode;
|
|
114
|
+
readonly name: string;
|
|
115
|
+
readonly nameRange: SourceRange;
|
|
116
|
+
readonly args: readonly CelNode[];
|
|
117
|
+
}
|
|
118
|
+
/** `namespace.name(args)`, where `namespace` names a module rather than a value. */
|
|
119
|
+
export interface CelQualifiedCallNode extends Ranged {
|
|
120
|
+
readonly kind: "qcall";
|
|
121
|
+
readonly namespace: string;
|
|
122
|
+
readonly namespaceRange: SourceRange;
|
|
123
|
+
readonly name: string;
|
|
124
|
+
readonly nameRange: SourceRange;
|
|
125
|
+
readonly args: readonly CelNode[];
|
|
126
|
+
}
|
|
127
|
+
export interface CelUnaryNode extends Ranged {
|
|
128
|
+
readonly kind: "unary";
|
|
129
|
+
readonly operator: CelUnaryOperator;
|
|
130
|
+
readonly operand: CelNode;
|
|
131
|
+
}
|
|
132
|
+
export interface CelBinaryNode extends Ranged {
|
|
133
|
+
readonly kind: "binary";
|
|
134
|
+
readonly operator: CelBinaryOperator;
|
|
135
|
+
readonly left: CelNode;
|
|
136
|
+
readonly right: CelNode;
|
|
137
|
+
}
|
|
138
|
+
export interface CelConditionalNode extends Ranged {
|
|
139
|
+
readonly kind: "conditional";
|
|
140
|
+
readonly condition: CelNode;
|
|
141
|
+
readonly whenTrue: CelNode;
|
|
142
|
+
readonly whenFalse: CelNode;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The hole error recovery leaves where an expression was expected and none could
|
|
146
|
+
* be read. It stands for text the parser could not make sense of, so the tree
|
|
147
|
+
* around it stays usable; it is never serializable and never evaluable.
|
|
148
|
+
*/
|
|
149
|
+
export interface CelUnparsedNode extends Ranged {
|
|
150
|
+
readonly kind: "unparsed";
|
|
151
|
+
}
|
|
152
|
+
export type CelNode = CelLiteralNode | CelIdentNode | CelListNode | CelMapNode | CelSelectNode | CelIndexNode | CelCallNode | CelReceiverCallNode | CelQualifiedCallNode | CelUnaryNode | CelBinaryNode | CelConditionalNode | CelUnparsedNode;
|
|
153
|
+
/** Every child node, in source order. The single reader of a node's shape for traversal. */
|
|
154
|
+
export declare function childNodes(node: CelNode): readonly CelNode[];
|
|
155
|
+
/** Depth-first pre-order walk over the whole tree. */
|
|
156
|
+
export declare function walkTree(root: CelNode): Generator<CelNode>;
|
|
157
|
+
/** Whether any node of the tree is an unparsed hole. */
|
|
158
|
+
export declare function hasUnparsed(root: CelNode): boolean;
|
|
159
|
+
export {};
|
|
160
|
+
//# sourceMappingURL=syntax-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax-tree.d.ts","sourceRoot":"","sources":["../src/syntax-tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAEhE,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC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