@telorun/cel 0.0.0-stage → 0.107.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 +146 -0
- package/dist/backend-runtime.d.ts.map +1 -0
- package/dist/backend-runtime.js +322 -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 +785 -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 +34 -0
- package/dist/cel-map-value.d.ts.map +1 -0
- package/dist/cel-map-value.js +74 -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 +159 -0
- package/dist/cel-value.d.ts.map +1 -0
- package/dist/cel-value.js +225 -0
- package/dist/check-diagnostic.d.ts +53 -0
- package/dist/check-diagnostic.d.ts.map +1 -0
- package/dist/check-diagnostic.js +66 -0
- package/dist/checker.d.ts +77 -0
- package/dist/checker.d.ts.map +1 -0
- package/dist/checker.js +721 -0
- package/dist/closure-backend.d.ts +21 -0
- package/dist/closure-backend.d.ts.map +1 -0
- package/dist/closure-backend.js +436 -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 +59 -0
- package/dist/duration-value.d.ts.map +1 -0
- package/dist/duration-value.js +135 -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 +283 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +459 -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 +78 -0
- package/dist/function-registry.d.ts.map +1 -0
- package/dist/function-registry.js +189 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -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 +132 -0
- package/dist/js-emitter.d.ts.map +1 -0
- package/dist/js-emitter.js +562 -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 +33 -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 +52 -0
- package/dist/member-read.d.ts.map +1 -0
- package/dist/member-read.js +125 -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 +33 -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 +56 -0
- package/dist/runtime-library.d.ts.map +1 -0
- package/dist/runtime-library.js +545 -0
- package/dist/serializer.d.ts +24 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +240 -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 +53 -0
- package/dist/timestamp-value.d.ts.map +1 -0
- package/dist/timestamp-value.js +223 -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 +26 -0
- package/dist/type-expression.d.ts.map +1 -0
- package/dist/type-expression.js +134 -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 +454 -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 +86 -0
- package/src/cel-program.ts +103 -0
- package/src/cel-type.ts +359 -0
- package/src/cel-value.ts +353 -0
- package/src/check-diagnostic.ts +102 -0
- package/src/checker.ts +932 -0
- package/src/closure-backend.ts +502 -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 +145 -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 +740 -0
- package/src/function-catalog.ts +140 -0
- package/src/function-registry.ts +229 -0
- package/src/index.ts +386 -0
- package/src/integer-arithmetic.ts +64 -0
- package/src/js-emitter.ts +713 -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 +191 -0
- package/src/macro-shape.ts +66 -0
- package/src/member-read.ts +126 -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 +34 -0
- package/src/root-references.ts +126 -0
- package/src/runtime-library.ts +615 -0
- package/src/serializer.ts +246 -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 +294 -0
- package/src/tree-equality.ts +130 -0
- package/src/type-expression.ts +160 -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,235 @@
|
|
|
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
|
+
|
|
63
|
+
{ "signature": "string.size(): int" },
|
|
64
|
+
{ "signature": "bytes.size(): int" },
|
|
65
|
+
{ "signature": "list<A>.size(): int" },
|
|
66
|
+
{ "signature": "map<K, V>.size(): int" },
|
|
67
|
+
{ "signature": "string.startsWith(string): bool" },
|
|
68
|
+
{ "signature": "string.endsWith(string): bool" },
|
|
69
|
+
{ "signature": "string.contains(string): bool" },
|
|
70
|
+
{ "signature": "string.matches(string): bool" },
|
|
71
|
+
{ "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" },
|
|
72
|
+
{ "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" },
|
|
73
|
+
{ "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" },
|
|
74
|
+
{ "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" },
|
|
75
|
+
{ "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" },
|
|
76
|
+
{ "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" },
|
|
77
|
+
{ "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" },
|
|
78
|
+
{ "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" },
|
|
79
|
+
{ "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" },
|
|
80
|
+
{ "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" },
|
|
81
|
+
{ "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" },
|
|
82
|
+
{ "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" },
|
|
83
|
+
{ "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" },
|
|
84
|
+
{ "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" },
|
|
85
|
+
{ "signature": "bytes.hex(): string", "spec": false, "reason": "no CEL library renders bytes as hexadecimal; kept for the manifests written against it" },
|
|
86
|
+
{ "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" },
|
|
87
|
+
{ "signature": "bytes.json(): dyn", "spec": false, "reason": "no CEL library parses JSON; kept for the manifests written against it", "deterministic": true },
|
|
88
|
+
{ "signature": "bytes.at(int): int", "spec": false, "reason": "no CEL library indexes bytes by a member call; kept for the manifests written against it" },
|
|
89
|
+
|
|
90
|
+
{ "signature": "google.protobuf.Timestamp.getDate(): int" },
|
|
91
|
+
{ "signature": "google.protobuf.Timestamp.getDate(string): int" },
|
|
92
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfMonth(): int" },
|
|
93
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfMonth(string): int" },
|
|
94
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfWeek(): int" },
|
|
95
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfWeek(string): int" },
|
|
96
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfYear(): int" },
|
|
97
|
+
{ "signature": "google.protobuf.Timestamp.getDayOfYear(string): int" },
|
|
98
|
+
{ "signature": "google.protobuf.Timestamp.getFullYear(): int" },
|
|
99
|
+
{ "signature": "google.protobuf.Timestamp.getFullYear(string): int" },
|
|
100
|
+
{ "signature": "google.protobuf.Timestamp.getHours(): int" },
|
|
101
|
+
{ "signature": "google.protobuf.Timestamp.getHours(string): int" },
|
|
102
|
+
{ "signature": "google.protobuf.Timestamp.getMilliseconds(): int" },
|
|
103
|
+
{ "signature": "google.protobuf.Timestamp.getMilliseconds(string): int" },
|
|
104
|
+
{ "signature": "google.protobuf.Timestamp.getMinutes(): int" },
|
|
105
|
+
{ "signature": "google.protobuf.Timestamp.getMinutes(string): int" },
|
|
106
|
+
{ "signature": "google.protobuf.Timestamp.getMonth(): int" },
|
|
107
|
+
{ "signature": "google.protobuf.Timestamp.getMonth(string): int" },
|
|
108
|
+
{ "signature": "google.protobuf.Timestamp.getSeconds(): int" },
|
|
109
|
+
{ "signature": "google.protobuf.Timestamp.getSeconds(string): int" },
|
|
110
|
+
{ "signature": "google.protobuf.Duration.getHours(): int" },
|
|
111
|
+
{ "signature": "google.protobuf.Duration.getMinutes(): int" },
|
|
112
|
+
{ "signature": "google.protobuf.Duration.getSeconds(): int" },
|
|
113
|
+
{ "signature": "google.protobuf.Duration.getMilliseconds(): int" }
|
|
114
|
+
],
|
|
115
|
+
"optionalTypeConstants": ["optional_type"],
|
|
116
|
+
"optionalTypeOperators": [
|
|
117
|
+
{ "operator": "==", "parameters": ["optional<A>", "optional<A>"], "returns": "bool" },
|
|
118
|
+
{ "operator": "!=", "parameters": ["optional<A>", "optional<A>"], "returns": "bool" }
|
|
119
|
+
],
|
|
120
|
+
"optionalTypeFunctions": [
|
|
121
|
+
{ "signature": "type(optional<A>): type" },
|
|
122
|
+
{ "signature": "optional<A>.hasValue(): bool" },
|
|
123
|
+
{ "signature": "optional<A>.value(): A" },
|
|
124
|
+
{ "signature": "optional<A>.or(optional<A>): optional<A>" },
|
|
125
|
+
{ "signature": "optional<A>.orValue(A): A" }
|
|
126
|
+
],
|
|
127
|
+
"operators": [
|
|
128
|
+
{ "operator": "!", "parameters": ["bool"], "returns": "bool" },
|
|
129
|
+
{ "operator": "-", "parameters": ["int"], "returns": "int" },
|
|
130
|
+
{ "operator": "-", "parameters": ["double"], "returns": "double" },
|
|
131
|
+
|
|
132
|
+
{ "operator": "+", "parameters": ["int", "int"], "returns": "int" },
|
|
133
|
+
{ "operator": "+", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
134
|
+
{ "operator": "+", "parameters": ["double", "double"], "returns": "double" },
|
|
135
|
+
{ "operator": "+", "parameters": ["string", "string"], "returns": "string" },
|
|
136
|
+
{ "operator": "+", "parameters": ["bytes", "bytes"], "returns": "bytes" },
|
|
137
|
+
{ "operator": "+", "parameters": ["list<A>", "list<A>"], "returns": "list<A>" },
|
|
138
|
+
{
|
|
139
|
+
"operator": "+",
|
|
140
|
+
"parameters": ["google.protobuf.Timestamp", "google.protobuf.Duration"],
|
|
141
|
+
"returns": "google.protobuf.Timestamp"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"operator": "+",
|
|
145
|
+
"parameters": ["google.protobuf.Duration", "google.protobuf.Timestamp"],
|
|
146
|
+
"returns": "google.protobuf.Timestamp"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"operator": "+",
|
|
150
|
+
"parameters": ["google.protobuf.Duration", "google.protobuf.Duration"],
|
|
151
|
+
"returns": "google.protobuf.Duration"
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
{ "operator": "-", "parameters": ["int", "int"], "returns": "int" },
|
|
155
|
+
{ "operator": "-", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
156
|
+
{ "operator": "-", "parameters": ["double", "double"], "returns": "double" },
|
|
157
|
+
{
|
|
158
|
+
"operator": "-",
|
|
159
|
+
"parameters": ["google.protobuf.Timestamp", "google.protobuf.Timestamp"],
|
|
160
|
+
"returns": "google.protobuf.Duration"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"operator": "-",
|
|
164
|
+
"parameters": ["google.protobuf.Timestamp", "google.protobuf.Duration"],
|
|
165
|
+
"returns": "google.protobuf.Timestamp"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"operator": "-",
|
|
169
|
+
"parameters": ["google.protobuf.Duration", "google.protobuf.Duration"],
|
|
170
|
+
"returns": "google.protobuf.Duration"
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
{ "operator": "*", "parameters": ["int", "int"], "returns": "int" },
|
|
174
|
+
{ "operator": "*", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
175
|
+
{ "operator": "*", "parameters": ["double", "double"], "returns": "double" },
|
|
176
|
+
{ "operator": "/", "parameters": ["int", "int"], "returns": "int" },
|
|
177
|
+
{ "operator": "/", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
178
|
+
{ "operator": "/", "parameters": ["double", "double"], "returns": "double" },
|
|
179
|
+
{ "operator": "%", "parameters": ["int", "int"], "returns": "int" },
|
|
180
|
+
{ "operator": "%", "parameters": ["uint", "uint"], "returns": "uint" },
|
|
181
|
+
|
|
182
|
+
{ "operator": "in", "parameters": ["A", "list<A>"], "returns": "bool" },
|
|
183
|
+
{ "operator": "in", "parameters": ["K", "map<K, V>"], "returns": "bool" }
|
|
184
|
+
],
|
|
185
|
+
"symmetricOperators": [
|
|
186
|
+
{
|
|
187
|
+
"operators": ["==", "!="],
|
|
188
|
+
"types": [
|
|
189
|
+
"int",
|
|
190
|
+
"uint",
|
|
191
|
+
"double",
|
|
192
|
+
"bool",
|
|
193
|
+
"string",
|
|
194
|
+
"bytes",
|
|
195
|
+
"null",
|
|
196
|
+
"type",
|
|
197
|
+
"list<A>",
|
|
198
|
+
"map<K, V>",
|
|
199
|
+
"google.protobuf.Timestamp",
|
|
200
|
+
"google.protobuf.Duration"
|
|
201
|
+
],
|
|
202
|
+
"returns": "bool",
|
|
203
|
+
"description": "Equality is declared per type: two values of unrelated types are not compared, and an optional is not compared at all."
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"operators": ["<", "<=", ">", ">="],
|
|
207
|
+
"types": [
|
|
208
|
+
"int",
|
|
209
|
+
"uint",
|
|
210
|
+
"double",
|
|
211
|
+
"bool",
|
|
212
|
+
"string",
|
|
213
|
+
"bytes",
|
|
214
|
+
"google.protobuf.Timestamp",
|
|
215
|
+
"google.protobuf.Duration"
|
|
216
|
+
],
|
|
217
|
+
"returns": "bool",
|
|
218
|
+
"description": "CEL orders every scalar type. A list and a map are comparable for equality alone."
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"crossNumericOperators": {
|
|
222
|
+
"operators": ["<", "<=", ">", ">="],
|
|
223
|
+
"pairs": [
|
|
224
|
+
["int", "uint"],
|
|
225
|
+
["int", "double"],
|
|
226
|
+
["uint", "int"],
|
|
227
|
+
["uint", "double"],
|
|
228
|
+
["double", "int"],
|
|
229
|
+
["double", "uint"]
|
|
230
|
+
],
|
|
231
|
+
"returns": "bool",
|
|
232
|
+
"spec": false,
|
|
233
|
+
"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."
|
|
234
|
+
}
|
|
235
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
|
|
15
|
+
import library from "./signatures/standard-library.json" with { type: "json" };
|
|
16
|
+
import type { CelType } from "./cel-type.js";
|
|
17
|
+
import { TYPE } from "./cel-type.js";
|
|
18
|
+
import type { FunctionRegistry } from "./function-registry.js";
|
|
19
|
+
import type { FunctionMetadata } from "./signature.js";
|
|
20
|
+
import { parseSignature } from "./signature.js";
|
|
21
|
+
import type { NominalResolver } from "./type-expression.js";
|
|
22
|
+
import { parseTypeExpression } from "./type-expression.js";
|
|
23
|
+
|
|
24
|
+
interface FunctionEntryData {
|
|
25
|
+
readonly signature: string;
|
|
26
|
+
/**
|
|
27
|
+
* `false` where CEL itself does not define the member. It is a **declaration**, not a
|
|
28
|
+
* note: the validator requires a `reason` beside it, so the library cannot grow a
|
|
29
|
+
* member that nobody said was outside the language.
|
|
30
|
+
*/
|
|
31
|
+
readonly spec?: boolean;
|
|
32
|
+
readonly reason?: string;
|
|
33
|
+
readonly deterministic?: boolean;
|
|
34
|
+
readonly description?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface OperatorEntryData {
|
|
38
|
+
readonly operator: string;
|
|
39
|
+
readonly parameters: readonly string[];
|
|
40
|
+
readonly returns: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface LibraryData {
|
|
44
|
+
readonly generation: number;
|
|
45
|
+
readonly typeConstants: readonly string[];
|
|
46
|
+
readonly constants: readonly { name: string; type: string; description?: string }[];
|
|
47
|
+
readonly functions: readonly FunctionEntryData[];
|
|
48
|
+
readonly optionalTypeConstants: readonly string[];
|
|
49
|
+
readonly optionalTypeOperators: readonly OperatorEntryData[];
|
|
50
|
+
readonly optionalTypeFunctions: readonly FunctionEntryData[];
|
|
51
|
+
readonly operators: readonly OperatorEntryData[];
|
|
52
|
+
readonly symmetricOperators: readonly {
|
|
53
|
+
readonly operators: readonly string[];
|
|
54
|
+
readonly types: readonly string[];
|
|
55
|
+
readonly returns: string;
|
|
56
|
+
}[];
|
|
57
|
+
readonly crossNumericOperators: {
|
|
58
|
+
readonly operators: readonly string[];
|
|
59
|
+
readonly pairs: readonly (readonly string[])[];
|
|
60
|
+
readonly returns: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const DATA = library as unknown as LibraryData;
|
|
65
|
+
|
|
66
|
+
export const STANDARD_LIBRARY_GENERATION = DATA.generation;
|
|
67
|
+
|
|
68
|
+
/** A constant the standard library declares: its name and the type it reads as. */
|
|
69
|
+
export interface StandardConstant {
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly type: CelType;
|
|
72
|
+
readonly description?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Every name the library declares as a constant: the type names (`int`, `list`, …),
|
|
77
|
+
* each of type `type`, and `google`, through which the well-known type names are read.
|
|
78
|
+
*/
|
|
79
|
+
export function standardConstants(optionalTypes: boolean): readonly StandardConstant[] {
|
|
80
|
+
const names = [...DATA.typeConstants, ...(optionalTypes ? DATA.optionalTypeConstants : [])];
|
|
81
|
+
const types = names.map((name) => ({ name, type: TYPE }));
|
|
82
|
+
const named = DATA.constants.map((entry) => ({
|
|
83
|
+
name: entry.name,
|
|
84
|
+
type: parseTypeExpression(entry.type),
|
|
85
|
+
...(entry.description === undefined ? {} : { description: entry.description }),
|
|
86
|
+
}));
|
|
87
|
+
return [...types, ...named];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The value `google` reads as: the two well-known type names, as type values. */
|
|
91
|
+
export function googleTypeNames(): ReadonlyMap<string, readonly string[]> {
|
|
92
|
+
return new Map([["protobuf", ["Duration", "Timestamp"]]]);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const metadataOf = (entry: FunctionEntryData): FunctionMetadata => ({
|
|
96
|
+
deterministic: entry.deterministic ?? true,
|
|
97
|
+
origin: "standard-library",
|
|
98
|
+
...(entry.description === undefined ? {} : { description: entry.description }),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Registers the library onto a registry. `optionalTypes` adds the optional-type
|
|
103
|
+
* members, which exist only where the option enables them.
|
|
104
|
+
*/
|
|
105
|
+
export function registerStandardLibrary(
|
|
106
|
+
registry: FunctionRegistry,
|
|
107
|
+
options: { optionalTypes: boolean; resolveNominal?: NominalResolver },
|
|
108
|
+
): void {
|
|
109
|
+
for (const entry of DATA.functions) {
|
|
110
|
+
registry.register(parseSignature(entry.signature, options.resolveNominal), metadataOf(entry));
|
|
111
|
+
}
|
|
112
|
+
if (options.optionalTypes) {
|
|
113
|
+
for (const entry of DATA.optionalTypeFunctions) {
|
|
114
|
+
registry.register(parseSignature(entry.signature, options.resolveNominal), metadataOf(entry));
|
|
115
|
+
}
|
|
116
|
+
for (const entry of DATA.optionalTypeOperators) registerOperatorData(registry, entry);
|
|
117
|
+
}
|
|
118
|
+
for (const entry of DATA.operators) registerOperatorData(registry, entry);
|
|
119
|
+
for (const group of DATA.symmetricOperators) {
|
|
120
|
+
for (const operator of group.operators) {
|
|
121
|
+
for (const type of group.types) {
|
|
122
|
+
registerOperatorData(registry, { operator, parameters: [type, type], returns: group.returns });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const cross = DATA.crossNumericOperators;
|
|
127
|
+
for (const operator of cross.operators) {
|
|
128
|
+
for (const [left, right] of cross.pairs) {
|
|
129
|
+
registerOperatorData(registry, { operator, parameters: [left!, right!], returns: cross.returns });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function registerOperatorData(registry: FunctionRegistry, entry: OperatorEntryData): void {
|
|
135
|
+
registry.register(
|
|
136
|
+
{
|
|
137
|
+
name: entry.operator,
|
|
138
|
+
form: "global",
|
|
139
|
+
parameters: entry.parameters.map((text) => parseTypeExpression(text)),
|
|
140
|
+
returns: parseTypeExpression(entry.returns),
|
|
141
|
+
},
|
|
142
|
+
{ deterministic: true, origin: "standard-library" },
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Every signature of the library as text, for a validator and for a docs listing. */
|
|
147
|
+
export function standardLibrarySignatures(): readonly string[] {
|
|
148
|
+
return [...DATA.functions, ...DATA.optionalTypeFunctions].map((entry) => entry.signature);
|
|
149
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
export type CelSyntaxCode =
|
|
13
|
+
/** A character that begins no CEL token. */
|
|
14
|
+
| "unexpected_character"
|
|
15
|
+
/** A token that cannot stand where it does. */
|
|
16
|
+
| "unexpected_token"
|
|
17
|
+
/** The source ended with an expression unfinished. */
|
|
18
|
+
| "unexpected_end"
|
|
19
|
+
/** A string or bytes literal that no quote closes. */
|
|
20
|
+
| "unterminated_string"
|
|
21
|
+
/** A reserved word written where an identifier must be. */
|
|
22
|
+
| "reserved_identifier"
|
|
23
|
+
/** A number literal that is not spelled as one. */
|
|
24
|
+
| "invalid_number"
|
|
25
|
+
/** An integer literal outside the int64 range. */
|
|
26
|
+
| "invalid_integer"
|
|
27
|
+
/** An unsigned integer literal outside the uint64 range. */
|
|
28
|
+
| "invalid_unsigned_integer"
|
|
29
|
+
/** An escape sequence no string or bytes literal admits. */
|
|
30
|
+
| "invalid_escape_sequence"
|
|
31
|
+
/** A `\\u`/`\\U` escape naming no Unicode code point. */
|
|
32
|
+
| "invalid_unicode_escape"
|
|
33
|
+
/** A `\\u` escape naming a surrogate not paired with its partner. */
|
|
34
|
+
| "invalid_unicode_surrogate"
|
|
35
|
+
/** A `\\x`/`\\X` escape with fewer than two hexadecimal digits. */
|
|
36
|
+
| "invalid_hex_escape"
|
|
37
|
+
/** A `\\nnn` escape with fewer than three octal digits. */
|
|
38
|
+
| "invalid_octal_escape"
|
|
39
|
+
/** A `\\nnn` escape naming a value above 255. */
|
|
40
|
+
| "octal_escape_out_of_range"
|
|
41
|
+
/** A `\\u`/`\\U` escape inside a bytes literal, which holds bytes and not text. */
|
|
42
|
+
| "bytes_unicode_escape"
|
|
43
|
+
/** One of the five input limits was reached. */
|
|
44
|
+
| "limit_exceeded";
|
|
45
|
+
|
|
46
|
+
export interface CelSyntaxDiagnostic {
|
|
47
|
+
readonly code: CelSyntaxCode;
|
|
48
|
+
readonly message: string;
|
|
49
|
+
readonly range: readonly [start: number, end: number];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Collects the first diagnostic and ignores every later one.
|
|
54
|
+
*
|
|
55
|
+
* Shared by the lexer and the parser so that "the first thing that could not be
|
|
56
|
+
* read" is one fact rather than two components' opinions of it.
|
|
57
|
+
*/
|
|
58
|
+
export class FirstSyntaxDiagnostic {
|
|
59
|
+
private held: CelSyntaxDiagnostic | undefined;
|
|
60
|
+
|
|
61
|
+
report(code: CelSyntaxCode, message: string, start: number, end: number): void {
|
|
62
|
+
this.held ??= { code, message, range: [start, end] };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get reported(): boolean {
|
|
66
|
+
return this.held !== undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
list(): readonly CelSyntaxDiagnostic[] {
|
|
70
|
+
return this.held ? [this.held] : [];
|
|
71
|
+
}
|
|
72
|
+
}
|