@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,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An environment: what names, functions and types an expression is read against.
|
|
3
|
+
*
|
|
4
|
+
* **Everything is registered the same way, including the standard library.** There is
|
|
5
|
+
* no privileged door: a host can replace `duration(string)` with its own, or remove a
|
|
6
|
+
* standard function so a call to it is refused, because the library came in through the
|
|
7
|
+
* same `registerFunction` a host uses. An engine with a built-in library behind a
|
|
8
|
+
* private registration is an engine whose library cannot be changed — which is the
|
|
9
|
+
* concrete thing this package exists to fix.
|
|
10
|
+
*
|
|
11
|
+
* `clone()` inherits everything and then diverges: registering or removing on the clone
|
|
12
|
+
* leaves the parent as it was. That is what lets one base environment be built once and
|
|
13
|
+
* specialised per site.
|
|
14
|
+
*
|
|
15
|
+
* **Two seams, and only two, let a host's vocabulary in**: `registerType`, for a named
|
|
16
|
+
* type over a base with its own operators and members, and `resolveSchemaType`, asked at
|
|
17
|
+
* every node of a JSON Schema before the structural rules. Nothing in this package knows
|
|
18
|
+
* any host's type names.
|
|
19
|
+
*/
|
|
20
|
+
import type { CelActivation } from "./activation.js";
|
|
21
|
+
import type { CelExpression } from "./cel-expression.js";
|
|
22
|
+
import type { CelProgram, EvaluateOptions } from "./cel-program.js";
|
|
23
|
+
import type { EmittedModule, EmittedModuleStore, EmittedRuntime, StoredEmittedModule } from "./emitted-module.js";
|
|
24
|
+
import type { CelValue } from "./cel-value.js";
|
|
25
|
+
import type { CelType } from "./cel-type.js";
|
|
26
|
+
import type { CheckResult } from "./checker.js";
|
|
27
|
+
import type { FieldDeclaration, JsonSchemaNode, RecursiveSchemaReference, SchemaTypeResolver, UnjudgedSchemaNode } from "./json-schema-type.js";
|
|
28
|
+
import type { NominalTypeDefinition } from "./nominal-type.js";
|
|
29
|
+
import type { CelParseLimits } from "./parse-limits.js";
|
|
30
|
+
import type { CelSignature, FunctionMetadata } from "./signature.js";
|
|
31
|
+
export interface CelEnvironmentOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Whether a name nothing declares reads as `dyn` instead of being reported.
|
|
34
|
+
*
|
|
35
|
+
* The default is CEL's own answer — report it. A host that types only part of what an
|
|
36
|
+
* expression may read turns it on, and a host that declares everything legal at a site
|
|
37
|
+
* leaves it off so a misspelled name is caught.
|
|
38
|
+
*/
|
|
39
|
+
readonly unlistedVariablesAreDyn?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a list or map literal must hold one type. The default is off, which is
|
|
42
|
+
* CEL's: a heterogeneous literal is a `list<dyn>`, not a mistake.
|
|
43
|
+
*/
|
|
44
|
+
readonly homogeneousAggregateLiterals?: boolean;
|
|
45
|
+
/** Whether `.?`, `[?]` and the `optional` members exist. Off by default, as in CEL. */
|
|
46
|
+
readonly enableOptionalTypes?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Asked at every schema node, with the document the node belongs to, before its
|
|
49
|
+
* structure is read. It answers a registered type name with its arguments, or the
|
|
50
|
+
* document to read in place of the node — which is how a reference leaving the document
|
|
51
|
+
* is resolved, the host owning what a reference outside this document is based on.
|
|
52
|
+
*/
|
|
53
|
+
readonly resolveSchemaType?: SchemaTypeResolver;
|
|
54
|
+
readonly limits?: Partial<CelParseLimits>;
|
|
55
|
+
/** Whether the standard library is registered. On by default. */
|
|
56
|
+
readonly standardLibrary?: boolean;
|
|
57
|
+
/** How many compiled expressions this environment keeps. */
|
|
58
|
+
readonly compiledCacheCapacity?: number;
|
|
59
|
+
}
|
|
60
|
+
export type TypeDeclaration = string | CelType | {
|
|
61
|
+
readonly fields: Readonly<Record<string, FieldDeclaration>>;
|
|
62
|
+
} | {
|
|
63
|
+
readonly schema: JsonSchemaNode;
|
|
64
|
+
/**
|
|
65
|
+
* The document the schema belongs to — what a `#/…` reference inside it resolves
|
|
66
|
+
* against. Absent where the schema **is** the document, which is the common case.
|
|
67
|
+
*/
|
|
68
|
+
readonly document?: JsonSchemaNode;
|
|
69
|
+
};
|
|
70
|
+
export interface VariableDefinition {
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly type: CelType;
|
|
73
|
+
readonly typeName: string;
|
|
74
|
+
readonly description?: string;
|
|
75
|
+
readonly constant: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface FunctionDefinition {
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly signature: string;
|
|
80
|
+
/** How the call is written: the receiver type, or null for a global call. */
|
|
81
|
+
readonly receiverType: string | null;
|
|
82
|
+
readonly parameters: readonly string[];
|
|
83
|
+
readonly returns: string;
|
|
84
|
+
readonly deterministic: boolean;
|
|
85
|
+
readonly hostBacked: boolean;
|
|
86
|
+
readonly throws?: readonly string[];
|
|
87
|
+
readonly description?: string;
|
|
88
|
+
readonly origin?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface TypeDefinitionListing {
|
|
91
|
+
readonly name: string;
|
|
92
|
+
readonly base: string;
|
|
93
|
+
readonly parameters: readonly string[];
|
|
94
|
+
readonly description?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface NamespaceListing {
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly functions: readonly string[];
|
|
99
|
+
/** Whether names beyond the listed ones are reachable; see {@link NamespaceOptions.open}. */
|
|
100
|
+
readonly open: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface Definitions {
|
|
103
|
+
readonly variables: readonly VariableDefinition[];
|
|
104
|
+
readonly functions: readonly FunctionDefinition[];
|
|
105
|
+
readonly types: readonly TypeDefinitionListing[];
|
|
106
|
+
readonly namespaces: readonly NamespaceListing[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* What converting one registration's schema could not judge.
|
|
110
|
+
*
|
|
111
|
+
* A schema node this engine has no rule for is reported rather than refused: the schema
|
|
112
|
+
* is usually a third party's data, so throwing at registration would turn someone else's
|
|
113
|
+
* schema into a crash, and typing it `dyn` quietly is the hole the report exists to close.
|
|
114
|
+
* The consumer that knows where the schema was written is the one that can anchor a
|
|
115
|
+
* diagnostic at it.
|
|
116
|
+
*/
|
|
117
|
+
export interface SchemaRegistrationReport {
|
|
118
|
+
/** The name registered under. */
|
|
119
|
+
readonly name: string;
|
|
120
|
+
readonly unjudged: readonly UnjudgedSchemaNode[];
|
|
121
|
+
/** Every reference re-entered on the descent: a recursive schema, deliberately `dyn`. */
|
|
122
|
+
readonly recursive: readonly RecursiveSchemaReference[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A namespaced function a host declares, in one of two forms.
|
|
126
|
+
*
|
|
127
|
+
* **`signature`** declares it whole, in global form (`total(double, int): double`), and this
|
|
128
|
+
* engine judges the call's arity and its argument types against it.
|
|
129
|
+
*
|
|
130
|
+
* **`name` + `returns`** declares the function's identity and its RESULT and **withholds the
|
|
131
|
+
* parameter list**, so arity and arguments are judged by nobody here. A host whose own
|
|
132
|
+
* signature grammar is richer than CEL's — an optional trailing parameter, a declared JSON
|
|
133
|
+
* Schema per parameter — judges them itself and strictly better. The two forms are exclusive
|
|
134
|
+
* by construction rather than by a flag: a declaration that carried parameters and asked for
|
|
135
|
+
* them to be ignored would hold a list nothing reads, which no reader can tell from a list
|
|
136
|
+
* that is simply wrong.
|
|
137
|
+
*
|
|
138
|
+
* **A type name this environment registers nothing under is accepted and reads `dyn`**, and
|
|
139
|
+
* every call to such a function carries a ranged `CEL_TYPE_ERROR` naming it. A declaration
|
|
140
|
+
* is a host's own data — a module function's declared result out of a manifest — so a typo
|
|
141
|
+
* in one is the host disagreeing with its own registry, which is reported where there is a
|
|
142
|
+
* range rather than thrown where there is none. A type registered AFTER a declaration naming
|
|
143
|
+
* it does not change that declaration: a declaration resolves its types once, when it is
|
|
144
|
+
* made.
|
|
145
|
+
*/
|
|
146
|
+
export type NamespaceFunctionDeclaration = ({
|
|
147
|
+
readonly signature: string;
|
|
148
|
+
readonly name?: never;
|
|
149
|
+
readonly returns?: never;
|
|
150
|
+
} | {
|
|
151
|
+
readonly name: string;
|
|
152
|
+
readonly returns: string | CelType;
|
|
153
|
+
readonly signature?: never;
|
|
154
|
+
}) & {
|
|
155
|
+
readonly deterministic?: boolean;
|
|
156
|
+
readonly hostBacked?: boolean;
|
|
157
|
+
readonly throws?: readonly string[];
|
|
158
|
+
};
|
|
159
|
+
/** What a host says about a namespace as a whole. */
|
|
160
|
+
export interface NamespaceOptions {
|
|
161
|
+
/**
|
|
162
|
+
* Whether names beyond the declared ones are reachable through it. **Open** means a name
|
|
163
|
+
* this namespace did not declare types `dyn` and is reported by nobody: the host resolves
|
|
164
|
+
* it against vocabulary this engine does not hold — an export gate, a capability, a
|
|
165
|
+
* re-export chain — and words that verdict itself. Closed (the default) makes such a name
|
|
166
|
+
* `FUNCTION_UNRESOLVED`.
|
|
167
|
+
*/
|
|
168
|
+
readonly open?: boolean;
|
|
169
|
+
}
|
|
170
|
+
/** How many compiled expressions an environment keeps when nothing says otherwise. */
|
|
171
|
+
export declare const DEFAULT_COMPILED_CACHE_CAPACITY = 256;
|
|
172
|
+
export declare class CelEnvironment {
|
|
173
|
+
private readonly registry;
|
|
174
|
+
private readonly variables;
|
|
175
|
+
private readonly types;
|
|
176
|
+
private readonly namespaceFunctions;
|
|
177
|
+
/** Namespaces that declare only part of what they reach; see {@link NamespaceOptions.open}. */
|
|
178
|
+
private readonly openNamespaces;
|
|
179
|
+
private readonly constants;
|
|
180
|
+
/** Bounded: a source text is a key an author's input decides. */
|
|
181
|
+
private readonly compiled;
|
|
182
|
+
readonly options: Required<Pick<CelEnvironmentOptions, "unlistedVariablesAreDyn" | "homogeneousAggregateLiterals" | "enableOptionalTypes">> & CelEnvironmentOptions;
|
|
183
|
+
constructor(options?: CelEnvironmentOptions, inherited?: CelEnvironment);
|
|
184
|
+
/** A new environment inheriting everything, which may then diverge. */
|
|
185
|
+
clone(options?: CelEnvironmentOptions): CelEnvironment;
|
|
186
|
+
/**
|
|
187
|
+
* Registers a function, **replacing** any registration answering the same call.
|
|
188
|
+
*
|
|
189
|
+
* Every registration forgets what this environment compiled: a program holds the
|
|
190
|
+
* overloads its call sites resolved to, so serving a cached one after the library
|
|
191
|
+
* changed would run the function that was replaced — the precise failure the
|
|
192
|
+
* replaceable library exists to avoid.
|
|
193
|
+
*/
|
|
194
|
+
registerFunction(signature: string | CelSignature, metadata?: FunctionMetadata): this;
|
|
195
|
+
/** Removes the one registration answering that call. Answers whether it was there. */
|
|
196
|
+
removeFunction(signature: string | CelSignature): boolean;
|
|
197
|
+
/** Removes every registration of a name, so a call to it is unknown. */
|
|
198
|
+
removeFunctionsNamed(name: string): number;
|
|
199
|
+
/** Registers an operator over the types given, replacing one over the same types. */
|
|
200
|
+
registerOperator(operator: string, parameters: readonly string[], returns: string, metadata?: FunctionMetadata): this;
|
|
201
|
+
registerVariable(name: string, declaration: TypeDeclaration, metadata?: {
|
|
202
|
+
readonly description?: string;
|
|
203
|
+
}): this;
|
|
204
|
+
/** A name whose value never changes; it reads exactly as a variable does. */
|
|
205
|
+
registerConstant(name: string, declaration: TypeDeclaration, metadata?: {
|
|
206
|
+
readonly description?: string;
|
|
207
|
+
}): this;
|
|
208
|
+
hasVariable(name: string): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Every schema-typed registration whose schema this engine could not judge whole, with
|
|
211
|
+
* each node by JSON Pointer. Empty is every node judged, which is the normal answer.
|
|
212
|
+
*/
|
|
213
|
+
schemaReports(): readonly SchemaRegistrationReport[];
|
|
214
|
+
/** Registers a named type, with every operator, conversion and member it declares. */
|
|
215
|
+
registerType(definition: NominalTypeDefinition): this;
|
|
216
|
+
/**
|
|
217
|
+
* Registers a namespace and the functions it declares. A namespace is a name that
|
|
218
|
+
* denotes a module rather than a value, which is what turns `Alias.fn(x)` into a
|
|
219
|
+
* qualified call rather than a method on something.
|
|
220
|
+
*/
|
|
221
|
+
registerNamespace(name: string, functions?: readonly (string | NamespaceFunctionDeclaration)[], options?: NamespaceOptions): this;
|
|
222
|
+
/** Every namespace registered, in canonical order. */
|
|
223
|
+
namespaces(): readonly string[];
|
|
224
|
+
/** Reads an expression against this environment's namespaces. */
|
|
225
|
+
parse(source: string): CelExpression;
|
|
226
|
+
/**
|
|
227
|
+
* Checks an expression. A tree resolved under a different namespace set is **refused**
|
|
228
|
+
* rather than checked: its qualified calls are not the ones this environment would
|
|
229
|
+
* have found, so every answer about it would be about a different expression.
|
|
230
|
+
*/
|
|
231
|
+
check(source: string | CelExpression): CheckResult;
|
|
232
|
+
/**
|
|
233
|
+
* Compiles an expression into a program. Nothing is type-checked here — the checker
|
|
234
|
+
* decides every verdict, and a consumer that wants one asks for it — so compiling
|
|
235
|
+
* refuses only what cannot be compiled at all: a source that did not read whole.
|
|
236
|
+
*
|
|
237
|
+
* A compile from text is memoized in a bounded cache; a tree handed over directly is
|
|
238
|
+
* compiled each time, because a tree has no identity to key on.
|
|
239
|
+
*/
|
|
240
|
+
compile(source: string | CelExpression): CelProgram;
|
|
241
|
+
/** Compiles and runs an expression against an activation. */
|
|
242
|
+
evaluate(source: string | CelExpression, activation?: CelActivation, options?: EvaluateOptions): CelValue;
|
|
243
|
+
/**
|
|
244
|
+
* The JavaScript module for a set of expressions, emitted now: its text, its key and its
|
|
245
|
+
* integrity header. The same expressions in the same order against the same environment
|
|
246
|
+
* emit byte-identically, so a host may compare two emissions instead of trusting one.
|
|
247
|
+
*
|
|
248
|
+
* The host stores and loads the text; this package touches no filesystem and exports no
|
|
249
|
+
* loader. `emitterRuntime()` is what the loaded module's factory takes, and
|
|
250
|
+
* `programsFromEmittedModule` verifies its header before anything runs.
|
|
251
|
+
*/
|
|
252
|
+
emit(sources: readonly string[]): EmittedModule;
|
|
253
|
+
/**
|
|
254
|
+
* The module for a set of expressions, read from the store where it holds a copy whose
|
|
255
|
+
* header matches and emitted and written where it does not — so a corrupted, stale or
|
|
256
|
+
* foreign stored copy causes a recompile rather than a run.
|
|
257
|
+
*/
|
|
258
|
+
emittedModule(sources: readonly string[], store: EmittedModuleStore): StoredEmittedModule;
|
|
259
|
+
/** The runtime support library an emitted module's factory is handed. */
|
|
260
|
+
emitterRuntime(): EmittedRuntime;
|
|
261
|
+
/**
|
|
262
|
+
* This environment's digest: the order-independent hash of its resolved listing, which
|
|
263
|
+
* the key and the header are both over. A host that caches by key never needs it; a host
|
|
264
|
+
* explaining a recompile does.
|
|
265
|
+
*/
|
|
266
|
+
digest(): string;
|
|
267
|
+
private expressionsOf;
|
|
268
|
+
/** What the backends need of this environment, built one way for both of them. */
|
|
269
|
+
private target;
|
|
270
|
+
/**
|
|
271
|
+
* An expression a backend may compile: read whole, and resolved under this
|
|
272
|
+
* environment's own namespaces. Nothing is type-checked — the checker decides every
|
|
273
|
+
* verdict and a consumer that wants one asks for it.
|
|
274
|
+
*/
|
|
275
|
+
private readyExpression;
|
|
276
|
+
private compileExpressionNow;
|
|
277
|
+
/**
|
|
278
|
+
* Whether a value of this type can be converted to text by the environment's own
|
|
279
|
+
* `string()`. A consumer that renders a value into text asks this before it tries;
|
|
280
|
+
* `dyn` passes, because only the runtime knows what it holds.
|
|
281
|
+
*/
|
|
282
|
+
convertsToString(type: CelType): boolean;
|
|
283
|
+
/** Every registration, for a listing a host prints or compares. */
|
|
284
|
+
definitions(): Definitions;
|
|
285
|
+
private readonly nominalResolver;
|
|
286
|
+
private readType;
|
|
287
|
+
private signatureOf;
|
|
288
|
+
/** The type a declaration names: a type expression, a field map, or a schema. */
|
|
289
|
+
private typeOf;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,KAAK,EAEV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAC;AAGnE,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,qBAAqB,EAAkB,MAAM,mBAAmB,CAAC;AAO/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;A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