@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,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which functions an environment has, and which one a call resolves to.
|
|
3
|
+
*
|
|
4
|
+
* **Nothing here is privileged.** The standard library registers through exactly this
|
|
5
|
+
* surface, so a host can replace one of its signatures or remove it — the capability
|
|
6
|
+
* the whole package exists for. Registration is last-wins by dispatch key
|
|
7
|
+
* (`signature.ts`), removal is by the same key, and both are per environment: a
|
|
8
|
+
* clone inherits and may then diverge without touching its parent.
|
|
9
|
+
*
|
|
10
|
+
* **Resolution answers WHY it failed**, never just "no". A call on a name nothing
|
|
11
|
+
* registers, a call written in the wrong form, and a call whose arguments no overload
|
|
12
|
+
* takes are three different mistakes with three different repairs, and the engine
|
|
13
|
+
* being replaced reported one sentence for all three — which is why a separate
|
|
14
|
+
* classifier had to re-derive the cause after the fact. The checker decides it here,
|
|
15
|
+
* once, with the candidates it considered.
|
|
16
|
+
*/
|
|
17
|
+
import type { CelType } from "./cel-type.js";
|
|
18
|
+
import type { CallForm, CelSignature, FunctionMetadata } from "./signature.js";
|
|
19
|
+
export interface RegisteredFunction {
|
|
20
|
+
readonly signature: CelSignature;
|
|
21
|
+
readonly metadata: FunctionMetadata;
|
|
22
|
+
}
|
|
23
|
+
export type ResolutionFailure =
|
|
24
|
+
/** No function of that name is registered, in any form. */
|
|
25
|
+
{
|
|
26
|
+
readonly reason: "unknown";
|
|
27
|
+
readonly candidates: readonly RegisteredFunction[];
|
|
28
|
+
}
|
|
29
|
+
/** The name is registered, but only in the other call form. */
|
|
30
|
+
| {
|
|
31
|
+
readonly reason: "wrong-form";
|
|
32
|
+
readonly candidates: readonly RegisteredFunction[];
|
|
33
|
+
}
|
|
34
|
+
/** The name and form are registered; no overload takes these arguments. */
|
|
35
|
+
| {
|
|
36
|
+
readonly reason: "no-overload";
|
|
37
|
+
readonly candidates: readonly RegisteredFunction[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* How many names a refused call may name as candidates.
|
|
41
|
+
*
|
|
42
|
+
* It is **declared** rather than left to a message's taste, because the conformance
|
|
43
|
+
* vectors pin that message byte for byte: a bound and an order a second engine cannot
|
|
44
|
+
* reproduce would be a row no port can pass. The order is edit distance then name, both
|
|
45
|
+
* over the name exactly as it was written.
|
|
46
|
+
*/
|
|
47
|
+
export declare const UNKNOWN_FUNCTION_CANDIDATES = 5;
|
|
48
|
+
export interface Resolution {
|
|
49
|
+
readonly resolved: RegisteredFunction;
|
|
50
|
+
/** The return type with every type parameter substituted by what this call bound. */
|
|
51
|
+
readonly returns: CelType;
|
|
52
|
+
}
|
|
53
|
+
export declare class FunctionRegistry {
|
|
54
|
+
private readonly byName;
|
|
55
|
+
constructor(inherited?: FunctionRegistry);
|
|
56
|
+
/** Registers a function, replacing any registration answering the same call. */
|
|
57
|
+
register(signature: CelSignature, metadata?: FunctionMetadata): void;
|
|
58
|
+
/** Removes the one registration answering that call. Answers whether it was there. */
|
|
59
|
+
remove(signature: CelSignature): boolean;
|
|
60
|
+
/** Removes every registration of a name. Answers how many went. */
|
|
61
|
+
removeName(name: string): number;
|
|
62
|
+
has(name: string): boolean;
|
|
63
|
+
/** Every registration, in name order then registration order. */
|
|
64
|
+
list(): readonly RegisteredFunction[];
|
|
65
|
+
named(name: string): readonly RegisteredFunction[];
|
|
66
|
+
/**
|
|
67
|
+
* The names this environment registers that would accept a call of that form and
|
|
68
|
+
* arity, nearest first — what a call on a name nothing registers is offered instead.
|
|
69
|
+
*
|
|
70
|
+
* **Form and arity are a filter rather than a ranking**, because a nearer name a call
|
|
71
|
+
* cannot be written on is not a repair: `'a'.size()` is not helped by `size`. A name
|
|
72
|
+
* that is not a name is filtered for the same reason — the operators register under
|
|
73
|
+
* their own symbols (`!`, `-`, `+`), and `no(1)` offered `!` and `-` as its two
|
|
74
|
+
* nearest spellings, neither of which can be written as a call at all. Among what
|
|
75
|
+
* passes the filter the order is edit distance then name, and the list is cut at
|
|
76
|
+
* {@link UNKNOWN_FUNCTION_CANDIDATES} — a declared bound and a declared order, so the
|
|
77
|
+
* message is the same text on every engine. Distance is counted over the name as
|
|
78
|
+
* written, with no case folding: a port reproduces one rule and not a host language's
|
|
79
|
+
* notion of lower case.
|
|
80
|
+
*/
|
|
81
|
+
candidateNames(wanted: string, form: CallForm, arity: number): readonly string[];
|
|
82
|
+
/**
|
|
83
|
+
* The function a call resolves to. `receiver` is the type the call is written on,
|
|
84
|
+
* absent for a global call.
|
|
85
|
+
*/
|
|
86
|
+
resolve(name: string, form: CallForm, args: readonly CelType[], receiver?: CelType): Resolution | ResolutionFailure;
|
|
87
|
+
/**
|
|
88
|
+
* The loose pass: a `dyn` argument makes a candidate viable, and **where several become
|
|
89
|
+
* viable and they do not agree on a return type, the call answers `dyn`.**
|
|
90
|
+
*
|
|
91
|
+
* Taking the first one instead is a concrete type nothing established. `dyn('a') +
|
|
92
|
+
* dyn('b')` answered `int` — the first `+` overload — so a host that declares nothing
|
|
93
|
+
* about a name had `a + b` typed `int`, and a consumer comparing that against a declared
|
|
94
|
+
* `string` slot refused a manifest that runs correctly. The honest answer is the one the
|
|
95
|
+
* engine's own design already states: overloads are resolved per call site on the VALUES'
|
|
96
|
+
* own types, so a `dyn` operand is exactly the case where the static answer is unknown.
|
|
97
|
+
*
|
|
98
|
+
* The candidate is still carried for the caller that wants one (a listing, a flag), and a
|
|
99
|
+
* single viable overload still answers its own return type — `dyn` only where they differ.
|
|
100
|
+
*/
|
|
101
|
+
private matchLoosely;
|
|
102
|
+
private match;
|
|
103
|
+
/**
|
|
104
|
+
* Whether an argument fits a parameter, binding type parameters as it goes.
|
|
105
|
+
*
|
|
106
|
+
* **A type parameter is bound by the first argument that mentions it**, and a later
|
|
107
|
+
* argument does not refine it: `[] + [3, 4]` is `list<T>`, because the empty list
|
|
108
|
+
* fixed the element type as "unknown" and the second argument cannot retroactively
|
|
109
|
+
* decide what the first one held.
|
|
110
|
+
*/
|
|
111
|
+
private fits;
|
|
112
|
+
}
|
|
113
|
+
/** The type with every bound parameter replaced; an unbound one stays as it is. */
|
|
114
|
+
export declare function substitute(type: CelType, bindings: ReadonlyMap<string, CelType>): CelType;
|
|
115
|
+
/** How a resolution failure names what it looked at, for a message a human reads. */
|
|
116
|
+
export declare function describeCandidates(candidates: readonly RegisteredFunction[]): string;
|
|
117
|
+
export declare function describeArguments(args: readonly CelType[]): string;
|
|
118
|
+
//# sourceMappingURL=function-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-registry.d.ts","sourceRoot":"","sources":["../src/function-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,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BAAkB,EAAE;IAIlD;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE;IAiBhF;;;OAGG;IACH,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,SAAS,OAAO,EAAE,EACxB,QAAQ,CAAC,EAAE,OAAO,GACjB,UAAU,GAAG,iBAAiB;IAiBjC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,KAAK;IAiBb;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI;CA8Cb;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAwBzF;AA6BD,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,kBAAkB,EAAE,GAAG,MAAM,CAEpF;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAElE"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which functions an environment has, and which one a call resolves to.
|
|
3
|
+
*
|
|
4
|
+
* **Nothing here is privileged.** The standard library registers through exactly this
|
|
5
|
+
* surface, so a host can replace one of its signatures or remove it — the capability
|
|
6
|
+
* the whole package exists for. Registration is last-wins by dispatch key
|
|
7
|
+
* (`signature.ts`), removal is by the same key, and both are per environment: a
|
|
8
|
+
* clone inherits and may then diverge without touching its parent.
|
|
9
|
+
*
|
|
10
|
+
* **Resolution answers WHY it failed**, never just "no". A call on a name nothing
|
|
11
|
+
* registers, a call written in the wrong form, and a call whose arguments no overload
|
|
12
|
+
* takes are three different mistakes with three different repairs, and the engine
|
|
13
|
+
* being replaced reported one sentence for all three — which is why a separate
|
|
14
|
+
* classifier had to re-derive the cause after the fact. The checker decides it here,
|
|
15
|
+
* once, with the candidates it considered.
|
|
16
|
+
*/
|
|
17
|
+
import { CelEngineError } from "./check-diagnostic.js";
|
|
18
|
+
import { assignable, DYN, formatType, isDyn, typesEqual } from "./cel-type.js";
|
|
19
|
+
import { formatSignature, signatureKey } from "./signature.js";
|
|
20
|
+
import { CALL_SITE_DIRECT_ARITY } from "./runtime-library.js";
|
|
21
|
+
import { isIdentifierSpelling, isReservedWord } from "./reserved-words.js";
|
|
22
|
+
/**
|
|
23
|
+
* How many names a refused call may name as candidates.
|
|
24
|
+
*
|
|
25
|
+
* It is **declared** rather than left to a message's taste, because the conformance
|
|
26
|
+
* vectors pin that message byte for byte: a bound and an order a second engine cannot
|
|
27
|
+
* reproduce would be a row no port can pass. The order is edit distance then name, both
|
|
28
|
+
* over the name exactly as it was written.
|
|
29
|
+
*/
|
|
30
|
+
export const UNKNOWN_FUNCTION_CANDIDATES = 5;
|
|
31
|
+
export class FunctionRegistry {
|
|
32
|
+
byName;
|
|
33
|
+
constructor(inherited) {
|
|
34
|
+
this.byName = new Map();
|
|
35
|
+
if (inherited) {
|
|
36
|
+
for (const [name, entries] of inherited.byName)
|
|
37
|
+
this.byName.set(name, [...entries]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** Registers a function, replacing any registration answering the same call. */
|
|
41
|
+
register(signature, metadata = {}) {
|
|
42
|
+
// An implementation receives its arguments positionally, up to the bound, so a wider
|
|
43
|
+
// signature is refused HERE rather than resolved and then called with its tail dropped.
|
|
44
|
+
// A declared bound nothing enforces is the silent wrong answer it exists to prevent.
|
|
45
|
+
const arity = signature.parameters.length + (signature.form === "receiver" ? 1 : 0);
|
|
46
|
+
if (arity > CALL_SITE_DIRECT_ARITY) {
|
|
47
|
+
throw new CelEngineError("signature_too_wide", `${formatSignature(signature)} takes ${arity} values and an implementation receives at most ${CALL_SITE_DIRECT_ARITY}`);
|
|
48
|
+
}
|
|
49
|
+
const entries = this.byName.get(signature.name) ?? [];
|
|
50
|
+
const key = signatureKey(signature);
|
|
51
|
+
const at = entries.findIndex((entry) => signatureKey(entry.signature) === key);
|
|
52
|
+
const entry = { signature, metadata };
|
|
53
|
+
if (at === -1)
|
|
54
|
+
entries.push(entry);
|
|
55
|
+
else
|
|
56
|
+
entries[at] = entry;
|
|
57
|
+
this.byName.set(signature.name, entries);
|
|
58
|
+
}
|
|
59
|
+
/** Removes the one registration answering that call. Answers whether it was there. */
|
|
60
|
+
remove(signature) {
|
|
61
|
+
const entries = this.byName.get(signature.name);
|
|
62
|
+
if (!entries)
|
|
63
|
+
return false;
|
|
64
|
+
const key = signatureKey(signature);
|
|
65
|
+
const at = entries.findIndex((entry) => signatureKey(entry.signature) === key);
|
|
66
|
+
if (at === -1)
|
|
67
|
+
return false;
|
|
68
|
+
entries.splice(at, 1);
|
|
69
|
+
if (entries.length === 0)
|
|
70
|
+
this.byName.delete(signature.name);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
/** Removes every registration of a name. Answers how many went. */
|
|
74
|
+
removeName(name) {
|
|
75
|
+
const entries = this.byName.get(name);
|
|
76
|
+
if (!entries)
|
|
77
|
+
return 0;
|
|
78
|
+
this.byName.delete(name);
|
|
79
|
+
return entries.length;
|
|
80
|
+
}
|
|
81
|
+
has(name) {
|
|
82
|
+
return this.byName.has(name);
|
|
83
|
+
}
|
|
84
|
+
/** Every registration, in name order then registration order. */
|
|
85
|
+
list() {
|
|
86
|
+
return [...this.byName.keys()].sort().flatMap((name) => this.byName.get(name));
|
|
87
|
+
}
|
|
88
|
+
named(name) {
|
|
89
|
+
return this.byName.get(name) ?? [];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The names this environment registers that would accept a call of that form and
|
|
93
|
+
* arity, nearest first — what a call on a name nothing registers is offered instead.
|
|
94
|
+
*
|
|
95
|
+
* **Form and arity are a filter rather than a ranking**, because a nearer name a call
|
|
96
|
+
* cannot be written on is not a repair: `'a'.size()` is not helped by `size`. A name
|
|
97
|
+
* that is not a name is filtered for the same reason — the operators register under
|
|
98
|
+
* their own symbols (`!`, `-`, `+`), and `no(1)` offered `!` and `-` as its two
|
|
99
|
+
* nearest spellings, neither of which can be written as a call at all. Among what
|
|
100
|
+
* passes the filter the order is edit distance then name, and the list is cut at
|
|
101
|
+
* {@link UNKNOWN_FUNCTION_CANDIDATES} — a declared bound and a declared order, so the
|
|
102
|
+
* message is the same text on every engine. Distance is counted over the name as
|
|
103
|
+
* written, with no case folding: a port reproduces one rule and not a host language's
|
|
104
|
+
* notion of lower case.
|
|
105
|
+
*/
|
|
106
|
+
candidateNames(wanted, form, arity) {
|
|
107
|
+
const matching = [];
|
|
108
|
+
for (const [name, entries] of this.byName) {
|
|
109
|
+
if (name === wanted)
|
|
110
|
+
continue;
|
|
111
|
+
if (!isIdentifierSpelling(name) || isReservedWord(name))
|
|
112
|
+
continue;
|
|
113
|
+
const accepts = entries.some((entry) => entry.signature.form === form && entry.signature.parameters.length === arity);
|
|
114
|
+
if (accepts)
|
|
115
|
+
matching.push(name);
|
|
116
|
+
}
|
|
117
|
+
return matching
|
|
118
|
+
.map((name) => ({ name, distance: editDistance(wanted, name) }))
|
|
119
|
+
.sort((left, right) => left.distance - right.distance || compareNames(left.name, right.name))
|
|
120
|
+
.slice(0, UNKNOWN_FUNCTION_CANDIDATES)
|
|
121
|
+
.map((candidate) => candidate.name);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The function a call resolves to. `receiver` is the type the call is written on,
|
|
125
|
+
* absent for a global call.
|
|
126
|
+
*/
|
|
127
|
+
resolve(name, form, args, receiver) {
|
|
128
|
+
const all = this.byName.get(name);
|
|
129
|
+
if (!all || all.length === 0)
|
|
130
|
+
return { reason: "unknown", candidates: [] };
|
|
131
|
+
const inForm = all.filter((entry) => entry.signature.form === form);
|
|
132
|
+
if (inForm.length === 0)
|
|
133
|
+
return { reason: "wrong-form", candidates: all };
|
|
134
|
+
const arity = inForm.filter((entry) => entry.signature.parameters.length === args.length);
|
|
135
|
+
const viable = arity.length === 0 ? inForm : arity;
|
|
136
|
+
// Exact first, then a candidate `dyn` makes viable, which is what keeps an
|
|
137
|
+
// unlisted variable from turning one mistake into two.
|
|
138
|
+
const exact = this.match(viable, args, receiver, false);
|
|
139
|
+
if (exact)
|
|
140
|
+
return exact;
|
|
141
|
+
const loose = this.matchLoosely(viable, args, receiver);
|
|
142
|
+
if (loose)
|
|
143
|
+
return loose;
|
|
144
|
+
return { reason: "no-overload", candidates: inForm };
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The loose pass: a `dyn` argument makes a candidate viable, and **where several become
|
|
148
|
+
* viable and they do not agree on a return type, the call answers `dyn`.**
|
|
149
|
+
*
|
|
150
|
+
* Taking the first one instead is a concrete type nothing established. `dyn('a') +
|
|
151
|
+
* dyn('b')` answered `int` — the first `+` overload — so a host that declares nothing
|
|
152
|
+
* about a name had `a + b` typed `int`, and a consumer comparing that against a declared
|
|
153
|
+
* `string` slot refused a manifest that runs correctly. The honest answer is the one the
|
|
154
|
+
* engine's own design already states: overloads are resolved per call site on the VALUES'
|
|
155
|
+
* own types, so a `dyn` operand is exactly the case where the static answer is unknown.
|
|
156
|
+
*
|
|
157
|
+
* The candidate is still carried for the caller that wants one (a listing, a flag), and a
|
|
158
|
+
* single viable overload still answers its own return type — `dyn` only where they differ.
|
|
159
|
+
*/
|
|
160
|
+
matchLoosely(candidates, args, receiver) {
|
|
161
|
+
const viable = [];
|
|
162
|
+
for (const candidate of candidates) {
|
|
163
|
+
const held = this.match([candidate], args, receiver, true);
|
|
164
|
+
if (held)
|
|
165
|
+
viable.push(held);
|
|
166
|
+
}
|
|
167
|
+
const first = viable[0];
|
|
168
|
+
if (!first)
|
|
169
|
+
return undefined;
|
|
170
|
+
const agree = viable.every((held) => typesEqual(held.returns, first.returns));
|
|
171
|
+
return agree ? first : { resolved: first.resolved, returns: DYN };
|
|
172
|
+
}
|
|
173
|
+
match(candidates, args, receiver, allowDyn) {
|
|
174
|
+
for (const candidate of candidates) {
|
|
175
|
+
const { signature } = candidate;
|
|
176
|
+
if (signature.parameters.length !== args.length)
|
|
177
|
+
continue;
|
|
178
|
+
const bindings = new Map();
|
|
179
|
+
if (signature.receiver && !this.fits(receiver ?? DYN, signature.receiver, bindings, allowDyn))
|
|
180
|
+
continue;
|
|
181
|
+
if (!signature.parameters.every((want, at) => this.fits(args[at], want, bindings, allowDyn)))
|
|
182
|
+
continue;
|
|
183
|
+
return { resolved: candidate, returns: substitute(signature.returns, bindings) };
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Whether an argument fits a parameter, binding type parameters as it goes.
|
|
189
|
+
*
|
|
190
|
+
* **A type parameter is bound by the first argument that mentions it**, and a later
|
|
191
|
+
* argument does not refine it: `[] + [3, 4]` is `list<T>`, because the empty list
|
|
192
|
+
* fixed the element type as "unknown" and the second argument cannot retroactively
|
|
193
|
+
* decide what the first one held.
|
|
194
|
+
*/
|
|
195
|
+
fits(argument, parameter, bindings, allowDyn) {
|
|
196
|
+
if (parameter.kind === "parameter") {
|
|
197
|
+
const bound = bindings.get(parameter.name);
|
|
198
|
+
if (!bound) {
|
|
199
|
+
bindings.set(parameter.name, argument);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
// A binding that holds an unresolved parameter holds no information, so a later
|
|
203
|
+
// concrete argument refines it: `optional.none().orValue(42)` is an int.
|
|
204
|
+
if (bound.kind === "parameter" && argument.kind !== "parameter") {
|
|
205
|
+
bindings.set(parameter.name, argument);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
if (bound.kind === "parameter" || argument.kind === "parameter")
|
|
209
|
+
return true;
|
|
210
|
+
return assignable(argument, bound) || (allowDyn && (isDyn(argument) || isDyn(bound)));
|
|
211
|
+
}
|
|
212
|
+
if (parameter.kind === "list" && argument.kind === "list") {
|
|
213
|
+
return this.fits(argument.element, parameter.element, bindings, allowDyn);
|
|
214
|
+
}
|
|
215
|
+
if (parameter.kind === "map" && argument.kind === "map") {
|
|
216
|
+
return (this.fits(argument.key, parameter.key, bindings, allowDyn) &&
|
|
217
|
+
this.fits(argument.value, parameter.value, bindings, allowDyn));
|
|
218
|
+
}
|
|
219
|
+
if (parameter.kind === "optional" && argument.kind === "optional") {
|
|
220
|
+
return this.fits(argument.value, parameter.value, bindings, allowDyn);
|
|
221
|
+
}
|
|
222
|
+
if (parameter.kind === "nominal" &&
|
|
223
|
+
argument.kind === "nominal" &&
|
|
224
|
+
parameter.name === argument.name &&
|
|
225
|
+
parameter.args.length === argument.args.length) {
|
|
226
|
+
// A named type's arguments are invariant, so they fit one for one — which is also
|
|
227
|
+
// where a signature written over `Self` binds its own type parameters.
|
|
228
|
+
return parameter.args.every((want, at) => this.fits(argument.args[at], want, bindings, allowDyn));
|
|
229
|
+
}
|
|
230
|
+
if (isDyn(argument))
|
|
231
|
+
return allowDyn || isDyn(parameter);
|
|
232
|
+
return assignable(argument, parameter);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/** The type with every bound parameter replaced; an unbound one stays as it is. */
|
|
236
|
+
export function substitute(type, bindings) {
|
|
237
|
+
switch (type.kind) {
|
|
238
|
+
case "parameter":
|
|
239
|
+
return bindings.get(type.name) ?? type;
|
|
240
|
+
case "list": {
|
|
241
|
+
const element = substitute(type.element, bindings);
|
|
242
|
+
return element === type.element ? type : { kind: "list", element };
|
|
243
|
+
}
|
|
244
|
+
case "map": {
|
|
245
|
+
const key = substitute(type.key, bindings);
|
|
246
|
+
const value = substitute(type.value, bindings);
|
|
247
|
+
return key === type.key && value === type.value ? type : { kind: "map", key, value };
|
|
248
|
+
}
|
|
249
|
+
case "optional": {
|
|
250
|
+
const value = substitute(type.value, bindings);
|
|
251
|
+
return value === type.value ? type : { kind: "optional", value };
|
|
252
|
+
}
|
|
253
|
+
case "nominal": {
|
|
254
|
+
const args = type.args.map((argument) => substitute(argument, bindings));
|
|
255
|
+
return args.every((argument, at) => argument === type.args[at]) ? type : { ...type, args };
|
|
256
|
+
}
|
|
257
|
+
default:
|
|
258
|
+
return type;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/** Code-unit order, so a port orders two names without a locale. */
|
|
262
|
+
function compareNames(left, right) {
|
|
263
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Levenshtein distance in UTF-16 code units — one insertion, deletion or substitution
|
|
267
|
+
* each costing one, which is the whole rule a port needs to reproduce.
|
|
268
|
+
*
|
|
269
|
+
* Code units rather than code points for the same reason every range in this package is
|
|
270
|
+
* in them: it is the one unit both ends of the engine already count in, and a name is
|
|
271
|
+
* compared against a name rather than cut.
|
|
272
|
+
*/
|
|
273
|
+
function editDistance(from, to) {
|
|
274
|
+
let previous = Array.from({ length: to.length + 1 }, (ignored, at) => at);
|
|
275
|
+
for (let left = 1; left <= from.length; left += 1) {
|
|
276
|
+
const row = new Array(to.length + 1);
|
|
277
|
+
row[0] = left;
|
|
278
|
+
for (let right = 1; right <= to.length; right += 1) {
|
|
279
|
+
const substitution = previous[right - 1] + (from[left - 1] === to[right - 1] ? 0 : 1);
|
|
280
|
+
row[right] = Math.min(substitution, previous[right] + 1, row[right - 1] + 1);
|
|
281
|
+
}
|
|
282
|
+
previous = row;
|
|
283
|
+
}
|
|
284
|
+
return previous[to.length];
|
|
285
|
+
}
|
|
286
|
+
/** How a resolution failure names what it looked at, for a message a human reads. */
|
|
287
|
+
export function describeCandidates(candidates) {
|
|
288
|
+
return candidates.map((candidate) => formatSignature(candidate.signature)).join(", ");
|
|
289
|
+
}
|
|
290
|
+
export function describeArguments(args) {
|
|
291
|
+
return args.map((type) => formatType(type)).join(", ");
|
|
292
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@telorun/cel` — the CEL language.
|
|
3
|
+
*
|
|
4
|
+
* This entry is the front end: reading an expression, the canonical tree it reads
|
|
5
|
+
* into, writing a tree back as source, and the two questions a consumer asks of a
|
|
6
|
+
* tree (what it reads, and which namespaced functions it calls). It reaches no
|
|
7
|
+
* runtime of its own and no host facility — nothing here touches a filesystem, a
|
|
8
|
+
* clock or a network, so it runs unchanged in a browser.
|
|
9
|
+
*
|
|
10
|
+
* It owns CEL and nothing above it: no host's type vocabulary, no host's function
|
|
11
|
+
* catalog. Those are registered onto the engine by whoever embeds it.
|
|
12
|
+
*/
|
|
13
|
+
export { parseExpression, resolvedUnder } from "./cel-expression.js";
|
|
14
|
+
export type { CelExpression, ParseExpressionOptions } from "./cel-expression.js";
|
|
15
|
+
export { MAX_INT, MAX_UINT, MIN_INT } from "./lexer.js";
|
|
16
|
+
export { CelNamespaceError, namespaceSetsEqual, normalizeNamespaces, RESERVED_NAMESPACES, resolveNamespaces, } from "./namespace-resolution.js";
|
|
17
|
+
export { DEFAULT_PARSE_LIMITS, resolveParseLimits } from "./parse-limits.js";
|
|
18
|
+
export type { CelParseLimits } from "./parse-limits.js";
|
|
19
|
+
export { parseSyntax } from "./parser.js";
|
|
20
|
+
export type { ParseOptions, ParseResult } from "./parser.js";
|
|
21
|
+
export { qualifiedCalls } from "./qualified-calls.js";
|
|
22
|
+
export type { QualifiedCall } from "./qualified-calls.js";
|
|
23
|
+
export { isIdentifierSpelling, isReservedWord, LITERAL_WORDS, OPERATOR_WORDS, RESERVED_WORDS, } from "./reserved-words.js";
|
|
24
|
+
export { rootReferences } from "./root-references.js";
|
|
25
|
+
export { splitDeclaredChain } from "./declared-chain.js";
|
|
26
|
+
export type { DeclaredChain } from "./declared-chain.js";
|
|
27
|
+
export { CelSerializeError, serializeTree } from "./serializer.js";
|
|
28
|
+
export type { CelSyntaxCode, CelSyntaxDiagnostic } from "./syntax-diagnostic.js";
|
|
29
|
+
export { childNodes, hasUnparsed, walkTree } from "./syntax-tree.js";
|
|
30
|
+
export type { CelBinaryNode, CelBinaryOperator, CelCallNode, CelConditionalNode, CelIdentNode, CelIndexNode, CelListNode, CelLiteral, CelLiteralNode, CelMapEntry, CelMapNode, CelNode, CelQualifiedCallNode, CelReceiverCallNode, CelSelectNode, CelUnaryNode, CelUnaryOperator, CelUnparsedNode, SourceRange, } from "./syntax-tree.js";
|
|
31
|
+
export { treesEqual } from "./tree-equality.js";
|
|
32
|
+
export { admitsNull, assignable, BOOL, BYTES, DOUBLE, DURATION, DYN, formatType, INT, isDyn, isNumeric, listOf, mapOf, NULL, optionalOf, parameterOf, STRING, TIMESTAMP, TYPE, typesEqual, UINT, unify, unionOf, WELL_KNOWN_TYPE_NAMES, withoutNull, withoutParameters, } from "./cel-type.js";
|
|
33
|
+
export type { CelType, DynType, ListType, MapType, NominalType, OptionalType, ParameterType, PrimitiveName, PrimitiveType, RecordType, UnionType, } from "./cel-type.js";
|
|
34
|
+
export { CEL_CHECK_CODES, CelEngineError } from "./check-diagnostic.js";
|
|
35
|
+
export type { CelCheckCode, CelCheckDiagnostic, CelDiagnosticFix, CelEngineErrorCode, } from "./check-diagnostic.js";
|
|
36
|
+
export type { CheckResult, NamespaceFunction } from "./checker.js";
|
|
37
|
+
export { CelEnvironment, DEFAULT_COMPILED_CACHE_CAPACITY } from "./environment.js";
|
|
38
|
+
export type { CelEnvironmentOptions, Definitions, FunctionDefinition, NamespaceFunctionDeclaration, NamespaceListing, NamespaceOptions, SchemaRegistrationReport, TypeDeclaration, TypeDefinitionListing, VariableDefinition, } from "./environment.js";
|
|
39
|
+
export { FunctionRegistry, UNKNOWN_FUNCTION_CANDIDATES } from "./function-registry.js";
|
|
40
|
+
export type { RegisteredFunction, Resolution, ResolutionFailure } from "./function-registry.js";
|
|
41
|
+
export { fieldMapType, schemaType, TYPE_CONSTRAINING_KEYWORDS, TYPE_KEYWORDS_READ, UNJUDGED_REASONS, } from "./json-schema-type.js";
|
|
42
|
+
export type { FieldDeclaration, JsonSchemaDocument, JsonSchemaNode, NamedTypeLookup, RecursiveSchemaReference, SchemaConversion, SchemaTypeAnswer, SchemaTypeResolver, SchemaTypeResult, UnjudgedReason, UnjudgedSchemaNode, } from "./json-schema-type.js";
|
|
43
|
+
export { CelTypeRegistrationError } from "./nominal-type.js";
|
|
44
|
+
export type { NominalOperatorDeclaration, NominalTypeDefinition, RegisteredType, } from "./nominal-type.js";
|
|
45
|
+
export type { ResolvedCall } from "./resolved-call.js";
|
|
46
|
+
export { formatSignature, parseSignature, signatureKey } from "./signature.js";
|
|
47
|
+
export type { CallForm, CelSignature, FunctionMetadata, LiteralArgumentCheck, } from "./signature.js";
|
|
48
|
+
export { googleTypeNames, registerStandardLibrary, standardConstants, STANDARD_LIBRARY_GENERATION, standardLibrarySignatures, } from "./standard-library.js";
|
|
49
|
+
export type { StandardConstant } from "./standard-library.js";
|
|
50
|
+
export { catalogCategories, catalogSignatures, FUNCTION_CATALOG_GENERATION, functionCatalog, registerFunctionCatalog, } from "./function-catalog.js";
|
|
51
|
+
export type { CatalogFunction, RegisterCatalogOptions } from "./function-catalog.js";
|
|
52
|
+
export { catalogGuardedNames, catalogImplementation, catalogImplementedKeys, catalogLiteralCheck, } from "./catalog-runtime.js";
|
|
53
|
+
export type { CatalogImplementation, CelCatalogHandlers } from "./catalog-runtime.js";
|
|
54
|
+
export { scanJsonPrefix } from "./json-text-scan.js";
|
|
55
|
+
export type { JsonRefusal } from "./json-text-scan.js";
|
|
56
|
+
export { civilTimeIn, dateTextIn, daysInMonth, instantOfCivilTime, isoTextIn, knownTimeZone, } from "./zoned-calendar.js";
|
|
57
|
+
export type { CivilTime } from "./zoned-calendar.js";
|
|
58
|
+
export { CelTypeExpressionError, CelUnknownTypeNameError, parseTypeExpression, } from "./type-expression.js";
|
|
59
|
+
export type { NominalResolver } from "./type-expression.js";
|
|
60
|
+
export type { CelActivation } from "./activation.js";
|
|
61
|
+
export { BoundedCache } from "./bounded-cache.js";
|
|
62
|
+
export { celMapFromEntries, celMapKeys } from "./cel-map-value.js";
|
|
63
|
+
export { CelEvaluationError, programOfStep } from "./cel-program.js";
|
|
64
|
+
export type { CelProgram, EvaluateOptions } from "./cel-program.js";
|
|
65
|
+
export { ENGINE_VERSION } from "./engine-version.js";
|
|
66
|
+
export { EMITTER_FORMAT_GENERATION, emittedModuleIdentity, emittedModuleKey, emittedModuleRefusal, programsFromEmittedModule, readEmittedHeader, } from "./emitted-module.js";
|
|
67
|
+
export type { EmittedFactory, EmittedHeader, EmittedIdentity, EmittedModule, EmittedModuleStore, EmittedRuntime, StoredEmittedModule, } from "./emitted-module.js";
|
|
68
|
+
export { environmentDigest } from "./environment-digest.js";
|
|
69
|
+
export type { DigestedEnvironment } from "./environment-digest.js";
|
|
70
|
+
/** The whole contract between an emitted module and the runtime it is handed. */
|
|
71
|
+
export { RUNTIME_BINDINGS } from "./js-emitter.js";
|
|
72
|
+
export type { RuntimeBinding } from "./js-emitter.js";
|
|
73
|
+
export { CEL_EVALUATION_CODES, CEL_VALUE_KEYS, CEL_VALUE_TYPE, celError, celNone, celSome, celTypeNameOf, celTypeValue, celUint, isCelBytes, isCelDuration, isCelError, isCelMap, isCelOptional, isCelRecord, isCelTimestamp, isCelTypeValue, isCelUint, literalValue, } from "./cel-value.js";
|
|
74
|
+
export type { CelDuration, CelError, CelEvaluationCode, CelHostValue, CelMap, CelMapKey, CelMapValueEntry, CelOptional, CelRecord, CelTimestamp, CelTypeValue, CelUint, CelValue, CelValueKey, } from "./cel-value.js";
|
|
75
|
+
export { compileTree } from "./closure-backend.js";
|
|
76
|
+
export type { CompiledTree } from "./closure-backend.js";
|
|
77
|
+
export { CALL_SITE_CACHE_CAPACITY, CelCompileError } from "./backend-runtime.js";
|
|
78
|
+
export type { CelStep, CompileTarget, EvaluationFrame, NamespaceDispatch, NamespaceImplementation, } from "./backend-runtime.js";
|
|
79
|
+
export { celAll, celExists, celExistsOne, celFilter, celMapComprehension, } from "./comprehension-runtime.js";
|
|
80
|
+
export type { ComprehensionBody } from "./comprehension-runtime.js";
|
|
81
|
+
export { celDurationFromNanos, durationField, durationNanos, durationNanosFromText, durationOutOfRange, formatDuration, MAX_DURATION_NANOS, MIN_DURATION_NANOS, parseDuration, } from "./duration-value.js";
|
|
82
|
+
export { celHas, celIterable, celLookup, celRead, lookupAbsence, lookupError, MISSING, OUT_OF_RANGE, UNSUPPORTED_CONTAINER, UNSUPPORTED_KEY, } from "./member-read.js";
|
|
83
|
+
export type { Lookup } from "./member-read.js";
|
|
84
|
+
export { celMatches, PATTERN_CACHE_CAPACITY, RE2_FLAG_LETTERS, RE2_PATTERN_ERROR_KINDS, re2Pattern, } from "./regular-expression.js";
|
|
85
|
+
export type { RE2Compiled, RE2PatternRefusal } from "./regular-expression.js";
|
|
86
|
+
export { base64Text, celTypeValueOf, implementationOf, jsonAsCelValue, implementedKeys, optionalOfNonZero, standardConstantValues, typeValueName, } from "./runtime-library.js";
|
|
87
|
+
export type { CelCallContext, CelImplementation } from "./runtime-library.js";
|
|
88
|
+
export { CALL_SITE_DIRECT_ARITY } from "./runtime-library.js";
|
|
89
|
+
export { celTimestamp, celTimestampFromMillis, formatTimestamp, MAX_TIMESTAMP_SECONDS, MIN_TIMESTAMP_SECONDS, parseTimestamp, timestampField, timestampNanos, zonedFields, } from "./timestamp-value.js";
|
|
90
|
+
export { celCompare, celEqual } from "./value-equality.js";
|
|
91
|
+
export { bytesToText, doubleText, textToBytes } from "./value-text.js";
|
|
92
|
+
export { BINDING_FORMS, namespaceMacroBinding, receiverMacroBinding, type ComprehensionBinding, } from "./comprehension-bindings.js";
|
|
93
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,qBAA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;AAE9E,OAAO,EACL,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,oBAAoB,GAC1B,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@telorun/cel` — the CEL language.
|
|
3
|
+
*
|
|
4
|
+
* This entry is the front end: reading an expression, the canonical tree it reads
|
|
5
|
+
* into, writing a tree back as source, and the two questions a consumer asks of a
|
|
6
|
+
* tree (what it reads, and which namespaced functions it calls). It reaches no
|
|
7
|
+
* runtime of its own and no host facility — nothing here touches a filesystem, a
|
|
8
|
+
* clock or a network, so it runs unchanged in a browser.
|
|
9
|
+
*
|
|
10
|
+
* It owns CEL and nothing above it: no host's type vocabulary, no host's function
|
|
11
|
+
* catalog. Those are registered onto the engine by whoever embeds it.
|
|
12
|
+
*/
|
|
13
|
+
export { parseExpression, resolvedUnder } from "./cel-expression.js";
|
|
14
|
+
export { MAX_INT, MAX_UINT, MIN_INT } from "./lexer.js";
|
|
15
|
+
export { CelNamespaceError, namespaceSetsEqual, normalizeNamespaces, RESERVED_NAMESPACES, resolveNamespaces, } from "./namespace-resolution.js";
|
|
16
|
+
export { DEFAULT_PARSE_LIMITS, resolveParseLimits } from "./parse-limits.js";
|
|
17
|
+
export { parseSyntax } from "./parser.js";
|
|
18
|
+
export { qualifiedCalls } from "./qualified-calls.js";
|
|
19
|
+
export { isIdentifierSpelling, isReservedWord, LITERAL_WORDS, OPERATOR_WORDS, RESERVED_WORDS, } from "./reserved-words.js";
|
|
20
|
+
export { rootReferences } from "./root-references.js";
|
|
21
|
+
export { splitDeclaredChain } from "./declared-chain.js";
|
|
22
|
+
export { CelSerializeError, serializeTree } from "./serializer.js";
|
|
23
|
+
export { childNodes, hasUnparsed, walkTree } from "./syntax-tree.js";
|
|
24
|
+
export { treesEqual } from "./tree-equality.js";
|
|
25
|
+
// --- the type system, the registry and the checker -------------------------
|
|
26
|
+
export { admitsNull, assignable, BOOL, BYTES, DOUBLE, DURATION, DYN, formatType, INT, isDyn, isNumeric, listOf, mapOf, NULL, optionalOf, parameterOf, STRING, TIMESTAMP, TYPE, typesEqual, UINT, unify, unionOf, WELL_KNOWN_TYPE_NAMES, withoutNull, withoutParameters, } from "./cel-type.js";
|
|
27
|
+
export { CEL_CHECK_CODES, CelEngineError } from "./check-diagnostic.js";
|
|
28
|
+
export { CelEnvironment, DEFAULT_COMPILED_CACHE_CAPACITY } from "./environment.js";
|
|
29
|
+
export { FunctionRegistry, UNKNOWN_FUNCTION_CANDIDATES } from "./function-registry.js";
|
|
30
|
+
export { fieldMapType, schemaType, TYPE_CONSTRAINING_KEYWORDS, TYPE_KEYWORDS_READ, UNJUDGED_REASONS, } from "./json-schema-type.js";
|
|
31
|
+
export { CelTypeRegistrationError } from "./nominal-type.js";
|
|
32
|
+
export { formatSignature, parseSignature, signatureKey } from "./signature.js";
|
|
33
|
+
export { googleTypeNames, registerStandardLibrary, standardConstants, STANDARD_LIBRARY_GENERATION, standardLibrarySignatures, } from "./standard-library.js";
|
|
34
|
+
// --- the function catalog: the dialect, registered as a host registers one ------
|
|
35
|
+
export { catalogCategories, catalogSignatures, FUNCTION_CATALOG_GENERATION, functionCatalog, registerFunctionCatalog, } from "./function-catalog.js";
|
|
36
|
+
export { catalogGuardedNames, catalogImplementation, catalogImplementedKeys, catalogLiteralCheck, } from "./catalog-runtime.js";
|
|
37
|
+
export { scanJsonPrefix } from "./json-text-scan.js";
|
|
38
|
+
export { civilTimeIn, dateTextIn, daysInMonth, instantOfCivilTime, isoTextIn, knownTimeZone, } from "./zoned-calendar.js";
|
|
39
|
+
export { CelTypeExpressionError, CelUnknownTypeNameError, parseTypeExpression, } from "./type-expression.js";
|
|
40
|
+
export { BoundedCache } from "./bounded-cache.js";
|
|
41
|
+
// `mapKeyIdentity` is deliberately NOT exported: what identifies an entry is the entries
|
|
42
|
+
// map's own business, and publishing the rule is what let a consumer grow a second copy of
|
|
43
|
+
// it. A host reads a map through the member-read seam and walks `entries` for the pairs.
|
|
44
|
+
export { celMapFromEntries, celMapKeys } from "./cel-map-value.js";
|
|
45
|
+
export { CelEvaluationError, programOfStep } from "./cel-program.js";
|
|
46
|
+
// --- the emitter: JavaScript source, its key, and the one store seam --------
|
|
47
|
+
export { ENGINE_VERSION } from "./engine-version.js";
|
|
48
|
+
export { EMITTER_FORMAT_GENERATION, emittedModuleIdentity, emittedModuleKey, emittedModuleRefusal, programsFromEmittedModule, readEmittedHeader, } from "./emitted-module.js";
|
|
49
|
+
export { environmentDigest } from "./environment-digest.js";
|
|
50
|
+
/** The whole contract between an emitted module and the runtime it is handed. */
|
|
51
|
+
export { RUNTIME_BINDINGS } from "./js-emitter.js";
|
|
52
|
+
export { CEL_EVALUATION_CODES, CEL_VALUE_KEYS, CEL_VALUE_TYPE, celError, celNone, celSome, celTypeNameOf, celTypeValue, celUint, isCelBytes, isCelDuration, isCelError, isCelMap, isCelOptional, isCelRecord, isCelTimestamp, isCelTypeValue, isCelUint, literalValue, } from "./cel-value.js";
|
|
53
|
+
export { compileTree } from "./closure-backend.js";
|
|
54
|
+
export { CALL_SITE_CACHE_CAPACITY, CelCompileError } from "./backend-runtime.js";
|
|
55
|
+
export { celAll, celExists, celExistsOne, celFilter, celMapComprehension, } from "./comprehension-runtime.js";
|
|
56
|
+
export { celDurationFromNanos, durationField, durationNanos, durationNanosFromText, durationOutOfRange, formatDuration, MAX_DURATION_NANOS, MIN_DURATION_NANOS, parseDuration, } from "./duration-value.js";
|
|
57
|
+
export { celHas, celIterable, celLookup, celRead, lookupAbsence, lookupError, MISSING, OUT_OF_RANGE, UNSUPPORTED_CONTAINER, UNSUPPORTED_KEY, } from "./member-read.js";
|
|
58
|
+
export { celMatches, PATTERN_CACHE_CAPACITY, RE2_FLAG_LETTERS, RE2_PATTERN_ERROR_KINDS, re2Pattern, } from "./regular-expression.js";
|
|
59
|
+
export { base64Text, celTypeValueOf, implementationOf, jsonAsCelValue, implementedKeys, optionalOfNonZero, standardConstantValues, typeValueName, } from "./runtime-library.js";
|
|
60
|
+
// The bound a host writing an implementation is held to, and what the refusal names.
|
|
61
|
+
export { CALL_SITE_DIRECT_ARITY } from "./runtime-library.js";
|
|
62
|
+
export { celTimestamp, celTimestampFromMillis, formatTimestamp, MAX_TIMESTAMP_SECONDS, MIN_TIMESTAMP_SECONDS, parseTimestamp, timestampField, timestampNanos, zonedFields, } from "./timestamp-value.js";
|
|
63
|
+
export { celCompare, celEqual } from "./value-equality.js";
|
|
64
|
+
export { bytesToText, doubleText, textToBytes } from "./value-text.js";
|
|
65
|
+
export { BINDING_FORMS, namespaceMacroBinding, receiverMacroBinding, } from "./comprehension-bindings.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integer arithmetic: 64-bit, checked, and **never wrapped**.
|
|
3
|
+
*
|
|
4
|
+
* CEL's `int` is a signed 64-bit integer and its `uint` an unsigned one. A result
|
|
5
|
+
* outside the range is an error, not a wrap: an engine that wraps answers a value no
|
|
6
|
+
* other engine answers, and a manifest that silently computes `-9223372036854775808`
|
|
7
|
+
* from a sum of positives is worse than one that fails. The vectors pin this as the
|
|
8
|
+
* domain-keeping answer where the engine being replaced returns a number beyond int64.
|
|
9
|
+
*
|
|
10
|
+
* Division truncates toward zero and the modulo takes the dividend's sign, which is
|
|
11
|
+
* what `BigInt` already does; division and modulo by zero are errors of their own, so a
|
|
12
|
+
* reader of the code knows which one happened.
|
|
13
|
+
*/
|
|
14
|
+
import { type CelError, type CelUint } from "./cel-value.js";
|
|
15
|
+
import type { SourceRange } from "./syntax-tree.js";
|
|
16
|
+
/** An int result, or the overflow it is outside the range. */
|
|
17
|
+
export declare function intResult(value: bigint, range?: SourceRange): bigint | CelError;
|
|
18
|
+
/** A uint result, or the overflow it is outside the range. */
|
|
19
|
+
export declare function uintResult(value: bigint, range?: SourceRange): CelUint | CelError;
|
|
20
|
+
export declare function intDivide(left: bigint, right: bigint, range?: SourceRange): bigint | CelError;
|
|
21
|
+
export declare function intModulo(left: bigint, right: bigint, range?: SourceRange): bigint | CelError;
|
|
22
|
+
export declare function uintDivide(left: bigint, right: bigint, range?: SourceRange): CelUint | CelError;
|
|
23
|
+
export declare function uintModulo(left: bigint, right: bigint, range?: SourceRange): CelUint | CelError;
|
|
24
|
+
/** Whether a magnitude fits a uint64 — used by the conversions. */
|
|
25
|
+
export declare function fitsUint(value: bigint): boolean;
|
|
26
|
+
export declare function fitsInt(value: bigint): boolean;
|
|
27
|
+
//# sourceMappingURL=integer-arithmetic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integer-arithmetic.d.ts","sourceRoot":"","sources":["../src/integer-arithmetic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAqB,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpD,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAA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