fig-tree-evaluator 2.23.2 → 3.0.0-preview.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +214 -148
- package/build/authoring/index.d.ts +80 -0
- package/build/authoring/index.js +1 -0
- package/build/chunks/engine.js +1 -0
- package/build/chunks/shared.js +1 -0
- package/build/editor-hints/index.d.ts +35 -0
- package/build/editor-hints/index.js +1 -0
- package/build/format/index.d.ts +104 -0
- package/build/format/index.js +1 -0
- package/build/index.d.ts +915 -237
- package/build/index.js +1 -0
- package/build/migrate/index.d.ts +55 -0
- package/build/migrate/index.js +1 -0
- package/package.json +107 -50
- package/CHANGELOG.md +0 -134
- package/build/index.cjs.js +0 -1
- package/build/index.esm.js +0 -1
package/build/index.d.ts
CHANGED
|
@@ -1,279 +1,957 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
maxSize?: number;
|
|
10
|
-
maxTime?: number;
|
|
11
|
-
}
|
|
12
|
-
interface Store {
|
|
13
|
-
[key: string]: {
|
|
14
|
-
result: EvaluatorOutput;
|
|
15
|
-
timestamp: number;
|
|
16
|
-
};
|
|
1
|
+
declare const version = "3.0.0-preview.10";
|
|
2
|
+
|
|
3
|
+
interface HttpRequest {
|
|
4
|
+
url: string;
|
|
5
|
+
method: 'get' | 'post';
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
signal: AbortSignal;
|
|
17
9
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
10
|
+
interface HttpClient {
|
|
11
|
+
request(req: HttpRequest): Promise<unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface SqlRequest {
|
|
14
|
+
text: string;
|
|
15
|
+
values?: unknown[] | Record<string, unknown>;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
interface SqlConnection {
|
|
19
|
+
query(req: SqlRequest): Promise<Record<string, unknown>[]>;
|
|
20
|
+
}
|
|
21
|
+
interface CacheStore {
|
|
22
|
+
get(key: string): unknown | Promise<unknown>;
|
|
23
|
+
set(key: string, value: unknown): void;
|
|
24
|
+
delete(key: string): void;
|
|
25
|
+
clear(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const ErrorCodes: {
|
|
29
|
+
readonly typeCheck: "type-check";
|
|
30
|
+
readonly operatorFailure: "operator-failure";
|
|
31
|
+
readonly requestTimeout: "request-timeout";
|
|
32
|
+
readonly httpStatus: "http-status";
|
|
33
|
+
readonly invalidResponse: "invalid-response";
|
|
34
|
+
readonly graphQLErrors: "graphql-errors";
|
|
35
|
+
readonly sqlError: "sql-error";
|
|
36
|
+
readonly requestFailure: "request-failure";
|
|
37
|
+
readonly nonFiniteResult: "non-finite-result";
|
|
38
|
+
readonly escapedHandle: "escaped-handle";
|
|
39
|
+
readonly emptyAggregate: "empty-aggregate";
|
|
40
|
+
readonly missingDataPath: "missing-data-path";
|
|
41
|
+
readonly missingRequired: "missing-required";
|
|
42
|
+
readonly timeout: "timeout";
|
|
43
|
+
readonly aborted: "aborted";
|
|
44
|
+
readonly malformedNode: "malformed-node";
|
|
45
|
+
readonly unknownOperator: "unknown-operator";
|
|
46
|
+
readonly unknownFragment: "unknown-fragment";
|
|
47
|
+
readonly unknownNodeKey: "unknown-node-key";
|
|
48
|
+
readonly unrecognizedIdentifier: "unrecognized-identifier";
|
|
49
|
+
readonly positionalArity: "positional-arity";
|
|
50
|
+
readonly invalidVars: "invalid-vars";
|
|
51
|
+
readonly invalidReference: "invalid-reference";
|
|
52
|
+
readonly invalidAs: "invalid-as";
|
|
53
|
+
readonly unresolvedVar: "unresolved-var";
|
|
54
|
+
readonly unresolvedParam: "unresolved-param";
|
|
55
|
+
readonly unresolvedBinding: "unresolved-binding";
|
|
56
|
+
readonly bareVars: "bare-vars";
|
|
57
|
+
readonly varCycle: "var-cycle";
|
|
58
|
+
readonly depthCeiling: "depth-ceiling";
|
|
59
|
+
readonly maxDepthExceeded: "max-depth";
|
|
60
|
+
readonly maxNodesExceeded: "max-nodes";
|
|
61
|
+
readonly returnsMismatch: "returns-mismatch";
|
|
62
|
+
readonly operatorValidate: "operator-validate";
|
|
63
|
+
readonly uselessModifier: "useless-modifier";
|
|
64
|
+
readonly unreferencedVar: "unreferenced-var";
|
|
65
|
+
readonly shadowedVar: "shadowed-var";
|
|
66
|
+
readonly deadBinding: "dead-binding";
|
|
67
|
+
readonly fallbackMismatch: "fallback-mismatch";
|
|
68
|
+
readonly unboundToken: "unbound-token";
|
|
69
|
+
readonly unusedSubstitution: "unused-substitution";
|
|
70
|
+
readonly inertReferenceToken: "inert-reference-token";
|
|
71
|
+
readonly invalidDefinition: "invalid-definition";
|
|
72
|
+
readonly invalidName: "invalid-name";
|
|
73
|
+
readonly reservedName: "reserved-name";
|
|
74
|
+
readonly invalidNullPolicy: "invalid-null-policy";
|
|
75
|
+
readonly duplicateOperator: "duplicate-operator";
|
|
76
|
+
readonly fragmentCycle: "fragment-cycle";
|
|
77
|
+
readonly invalidOptions: "invalid-options";
|
|
54
78
|
};
|
|
79
|
+
type KnownErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
80
|
+
type FigTreeErrorCode = KnownErrorCode | (string & {});
|
|
81
|
+
type KnownFallbackErrorCode = (typeof ErrorCodes)['typeCheck' | 'operatorFailure' | 'requestTimeout' | 'httpStatus' | 'invalidResponse' | 'graphQLErrors' | 'sqlError' | 'requestFailure' | 'nonFiniteResult' | 'escapedHandle' | 'emptyAggregate' | 'missingDataPath' | 'missingRequired' | 'timeout'];
|
|
82
|
+
type FallbackErrorCode = KnownFallbackErrorCode | (string & {});
|
|
55
83
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
84
|
+
type Severity = 'error' | 'warning';
|
|
85
|
+
interface Issue {
|
|
86
|
+
severity: Severity;
|
|
87
|
+
code: FigTreeErrorCode;
|
|
88
|
+
message: string;
|
|
89
|
+
path: (string | number)[];
|
|
90
|
+
operator?: string;
|
|
91
|
+
fragment?: string;
|
|
92
|
+
parameter?: string;
|
|
93
|
+
suggestion?: string;
|
|
60
94
|
}
|
|
61
|
-
interface
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
95
|
+
interface ValidationResult {
|
|
96
|
+
valid: boolean;
|
|
97
|
+
issues: Issue[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare const LAZY_HANDLE: unique symbol;
|
|
101
|
+
interface LazyValue<T = unknown> {
|
|
102
|
+
readonly [LAZY_HANDLE]: true;
|
|
103
|
+
evaluate(): Promise<T>;
|
|
104
|
+
}
|
|
105
|
+
interface Settlement {
|
|
106
|
+
index: number;
|
|
107
|
+
ok: boolean;
|
|
108
|
+
value?: unknown;
|
|
109
|
+
error?: unknown;
|
|
110
|
+
}
|
|
111
|
+
type SettlementStream = AsyncIterable<Settlement> & {
|
|
112
|
+
readonly [LAZY_HANDLE]: true;
|
|
113
|
+
length: number;
|
|
114
|
+
};
|
|
115
|
+
interface PerElement<T = unknown> {
|
|
116
|
+
readonly [LAZY_HANDLE]: true;
|
|
117
|
+
evaluate(index: number): Promise<T>;
|
|
118
|
+
settle(): SettlementStream;
|
|
119
|
+
}
|
|
120
|
+
type TraceEvent = {
|
|
121
|
+
type: string;
|
|
122
|
+
[key: string]: unknown;
|
|
123
|
+
};
|
|
124
|
+
interface OperatorContext {
|
|
125
|
+
signal: AbortSignal;
|
|
126
|
+
options: Readonly<EvaluationOptions>;
|
|
127
|
+
cache: {
|
|
128
|
+
memo<T>(key: unknown, fn: () => Promise<T>): Promise<T>;
|
|
129
|
+
};
|
|
130
|
+
trace: {
|
|
131
|
+
note(event: TraceEvent): void;
|
|
65
132
|
};
|
|
66
|
-
data?: Record<string, unknown>;
|
|
67
|
-
headers?: Record<string, unknown>;
|
|
68
|
-
method?: 'get' | 'post';
|
|
69
133
|
}
|
|
70
134
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
135
|
+
type TraceStatus = 'value' | 'failed' | 'fallback' | 'cancelled' | 'skipped';
|
|
136
|
+
type TraceKind = 'operator' | 'fragment' | 'reference' | 'literal' | 'skeleton';
|
|
137
|
+
interface TraceNode {
|
|
138
|
+
path: (string | number)[];
|
|
139
|
+
source?: {
|
|
140
|
+
fragment: string;
|
|
75
141
|
};
|
|
76
|
-
|
|
142
|
+
kind: TraceKind;
|
|
143
|
+
operator?: string;
|
|
144
|
+
ref?: string;
|
|
145
|
+
var?: string;
|
|
146
|
+
status: TraceStatus;
|
|
147
|
+
value?: unknown;
|
|
148
|
+
error?: FigTreeError;
|
|
149
|
+
events?: TraceEvent[];
|
|
150
|
+
children?: TraceNode[];
|
|
151
|
+
elapsed?: number;
|
|
152
|
+
warnings?: Issue[];
|
|
153
|
+
}
|
|
154
|
+
interface CacheTraceEvent {
|
|
155
|
+
type: 'cache';
|
|
156
|
+
hit: boolean;
|
|
157
|
+
}
|
|
158
|
+
interface RequestTraceEvent {
|
|
159
|
+
type: 'request';
|
|
160
|
+
method: string;
|
|
161
|
+
url: string;
|
|
162
|
+
headers: string[];
|
|
77
163
|
}
|
|
164
|
+
interface QueryTraceEvent {
|
|
165
|
+
type: 'query';
|
|
166
|
+
text: string;
|
|
167
|
+
}
|
|
168
|
+
interface RenderTraceEvent {
|
|
169
|
+
type: 'render';
|
|
170
|
+
token: string;
|
|
171
|
+
rendered: 'literal' | 'placeholder' | 'empty' | 'gap-closed';
|
|
172
|
+
}
|
|
173
|
+
interface KeyOverwriteTraceEvent {
|
|
174
|
+
type: 'key-overwrite';
|
|
175
|
+
key: string;
|
|
176
|
+
}
|
|
177
|
+
interface ShieldedFallbackTraceEvent {
|
|
178
|
+
type: 'shielded-fallback';
|
|
179
|
+
}
|
|
180
|
+
type KnownTraceEvent = CacheTraceEvent | RequestTraceEvent | QueryTraceEvent | RenderTraceEvent | KeyOverwriteTraceEvent | ShieldedFallbackTraceEvent;
|
|
78
181
|
|
|
79
|
-
|
|
182
|
+
interface FallbackError {
|
|
183
|
+
code: FallbackErrorCode;
|
|
184
|
+
message: string;
|
|
185
|
+
path: (string | number)[];
|
|
186
|
+
operator?: string;
|
|
187
|
+
fragment?: string;
|
|
188
|
+
fragmentPath?: (string | number)[];
|
|
189
|
+
errorData?: Record<string, unknown>;
|
|
190
|
+
}
|
|
191
|
+
interface FigTreeErrorInit {
|
|
192
|
+
code: FigTreeErrorCode;
|
|
193
|
+
message: string;
|
|
194
|
+
path: (string | number)[];
|
|
195
|
+
operator?: string;
|
|
196
|
+
fragment?: string;
|
|
197
|
+
fragmentPath?: (string | number)[];
|
|
198
|
+
errorData?: Record<string, unknown>;
|
|
199
|
+
related?: FigTreeError[];
|
|
200
|
+
cause?: unknown;
|
|
201
|
+
issues?: Issue[];
|
|
202
|
+
trace?: TraceNode;
|
|
203
|
+
}
|
|
204
|
+
declare class FigTreeError extends Error {
|
|
205
|
+
code: FigTreeErrorCode;
|
|
206
|
+
path: (string | number)[];
|
|
207
|
+
operator?: string;
|
|
208
|
+
fragment?: string;
|
|
209
|
+
fragmentPath?: (string | number)[];
|
|
210
|
+
errorData?: Record<string, unknown>;
|
|
211
|
+
related?: FigTreeError[];
|
|
212
|
+
cause?: unknown;
|
|
213
|
+
issues?: Issue[];
|
|
214
|
+
trace?: TraceNode;
|
|
215
|
+
constructor(init: FigTreeErrorInit);
|
|
216
|
+
prettyPrint(): string;
|
|
217
|
+
}
|
|
218
|
+
declare const isFigTreeError: (input: unknown) => input is FigTreeError;
|
|
80
219
|
|
|
81
|
-
|
|
82
|
-
type
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
type
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
functions?: Record<string, UnknownFunction | FunctionDefinition>;
|
|
91
|
-
fragments?: Fragments;
|
|
92
|
-
httpClient?: HttpClient;
|
|
93
|
-
graphQLConnection?: GraphQLConnection;
|
|
94
|
-
sqlConnection?: SQLConnection;
|
|
95
|
-
baseEndpoint?: string;
|
|
96
|
-
headers?: {
|
|
97
|
-
[key: string]: string;
|
|
98
|
-
};
|
|
99
|
-
returnErrorAsString?: boolean;
|
|
100
|
-
nullEqualsUndefined?: boolean;
|
|
101
|
-
caseInsensitive?: boolean;
|
|
102
|
-
allowJSONStringInput?: boolean;
|
|
103
|
-
noShorthand?: boolean;
|
|
104
|
-
skipRuntimeTypeCheck?: boolean;
|
|
105
|
-
evaluateFullObject?: boolean;
|
|
106
|
-
excludeOperators?: OperatorAlias[];
|
|
107
|
-
useCache?: boolean;
|
|
108
|
-
maxCacheSize?: number;
|
|
109
|
-
maxCacheTime?: number;
|
|
110
|
-
supportDeprecatedValueNodes?: boolean;
|
|
111
|
-
}
|
|
112
|
-
interface FigTreeConfig {
|
|
113
|
-
options: FigTreeOptions;
|
|
114
|
-
operators: OperatorReference;
|
|
115
|
-
operatorAliases: OperatorAliases;
|
|
116
|
-
typeChecker: (...args: TypeCheckInput[] | [TypeCheckInput[]]) => void;
|
|
117
|
-
resolvedAliasNodes: {
|
|
118
|
-
[key: string]: EvaluatorOutput;
|
|
119
|
-
};
|
|
120
|
-
cache: FigTreeCache;
|
|
121
|
-
httpClient?: HttpClient;
|
|
122
|
-
graphQLClient?: HttpClient;
|
|
123
|
-
}
|
|
124
|
-
type OutputType = 'string' | 'number' | 'boolean' | 'bool' | 'array';
|
|
125
|
-
interface OperatorNode {
|
|
126
|
-
operator: OperatorAlias;
|
|
127
|
-
outputType?: OutputType;
|
|
128
|
-
children?: EvaluatorNode[];
|
|
129
|
-
fallback?: EvaluatorNode;
|
|
130
|
-
useCache?: boolean;
|
|
131
|
-
[key: string]: EvaluatorNode;
|
|
220
|
+
type BasicType = 'any' | 'string' | 'number' | 'boolean' | 'array' | 'object' | 'null' | 'integer';
|
|
221
|
+
type LiteralType = {
|
|
222
|
+
literal: readonly (string | number | boolean)[];
|
|
223
|
+
};
|
|
224
|
+
type ExpectedType = BasicType | LiteralType | readonly BasicType[];
|
|
225
|
+
interface Constraints {
|
|
226
|
+
length?: number;
|
|
227
|
+
homogeneous?: readonly BasicType[];
|
|
228
|
+
elementShape?: Record<string, TypeDeclaration>;
|
|
132
229
|
}
|
|
133
|
-
interface
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
230
|
+
interface TypeDeclaration {
|
|
231
|
+
type?: ExpectedType;
|
|
232
|
+
required?: boolean;
|
|
233
|
+
constraints?: Constraints;
|
|
137
234
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
235
|
+
type TypeCheckResult = {
|
|
236
|
+
ok: true;
|
|
237
|
+
} | {
|
|
238
|
+
ok: false;
|
|
239
|
+
expected: string;
|
|
240
|
+
actual: string;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
declare const validateHelpers: Readonly<{
|
|
244
|
+
parsePath: (path: string) => PathSegment[];
|
|
245
|
+
resolvePath: (source: unknown, path: string | PathSegment[]) => ResolveResult;
|
|
246
|
+
checkType: (value: unknown, expected: ExpectedType) => TypeCheckResult;
|
|
247
|
+
checkConstraints: (value: unknown, constraints: Constraints) => TypeCheckResult;
|
|
248
|
+
describeType: (value: unknown) => string;
|
|
249
|
+
renderText: (value: unknown) => string;
|
|
250
|
+
isTruthy: (value: unknown) => boolean;
|
|
251
|
+
}>;
|
|
252
|
+
type ValidateHelpers = typeof validateHelpers;
|
|
253
|
+
|
|
254
|
+
interface FallbackCoverage {
|
|
255
|
+
uncovered: CoverageFinding[];
|
|
256
|
+
covered: CoveredFinding[];
|
|
143
257
|
}
|
|
144
|
-
interface
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
258
|
+
interface CoverageFinding {
|
|
259
|
+
path: (string | number)[];
|
|
260
|
+
code: FigTreeErrorCode;
|
|
261
|
+
message: string;
|
|
262
|
+
certainty: 'may' | 'always';
|
|
263
|
+
operator?: string;
|
|
264
|
+
parameter?: string;
|
|
265
|
+
fragment?: string;
|
|
266
|
+
fragmentPath?: (string | number)[];
|
|
267
|
+
}
|
|
268
|
+
interface CoveredFinding extends CoverageFinding {
|
|
269
|
+
coveredBy: (string | number)[];
|
|
270
|
+
coveredByFragmentPath?: (string | number)[];
|
|
271
|
+
givesNull?: true;
|
|
272
|
+
}
|
|
273
|
+
interface FallbackCoverageOptions {
|
|
274
|
+
strictNumbers?: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface OperatorAnalysis {
|
|
277
|
+
failures?: FailureRule[];
|
|
278
|
+
external?: true;
|
|
279
|
+
output?: DeclaredOutput;
|
|
280
|
+
}
|
|
281
|
+
interface FailureRule {
|
|
282
|
+
code: FallbackErrorCode;
|
|
283
|
+
parameter?: string;
|
|
284
|
+
when?: Record<string, FailureTest>;
|
|
285
|
+
options?: Record<string, unknown>;
|
|
286
|
+
may?: true;
|
|
287
|
+
overflow?: true;
|
|
288
|
+
}
|
|
289
|
+
type FailureTest = string | number | boolean | null | {
|
|
290
|
+
type: ExpectedType;
|
|
291
|
+
} | {
|
|
292
|
+
below: number;
|
|
293
|
+
} | {
|
|
294
|
+
empty: true;
|
|
295
|
+
} | {
|
|
296
|
+
supplied: boolean;
|
|
297
|
+
} | {
|
|
298
|
+
invalid: true;
|
|
299
|
+
} | {
|
|
300
|
+
some: FailureTest;
|
|
301
|
+
} | {
|
|
302
|
+
not: FailureTest;
|
|
162
303
|
};
|
|
163
|
-
type
|
|
164
|
-
type
|
|
165
|
-
|
|
166
|
-
|
|
304
|
+
type DeclaredOutput = ExpectedType | {
|
|
305
|
+
type: 'number' | 'integer';
|
|
306
|
+
min?: number;
|
|
307
|
+
max?: number;
|
|
308
|
+
} | {
|
|
309
|
+
type: 'string' | 'array';
|
|
310
|
+
minLength?: number;
|
|
311
|
+
} | {
|
|
312
|
+
param: string;
|
|
313
|
+
} | {
|
|
314
|
+
elementOf: string;
|
|
315
|
+
} | {
|
|
316
|
+
kindOf: string;
|
|
317
|
+
} | {
|
|
318
|
+
arrayOf: DeclaredOutput;
|
|
319
|
+
minLength?: number;
|
|
320
|
+
} | {
|
|
321
|
+
oneOf: DeclaredOutput[];
|
|
322
|
+
} | {
|
|
323
|
+
typeNamedBy: string;
|
|
324
|
+
} | {
|
|
325
|
+
byParam: string;
|
|
326
|
+
cases: Record<string, DeclaredOutput>;
|
|
327
|
+
otherwise?: DeclaredOutput;
|
|
328
|
+
} | {
|
|
329
|
+
firstNonNull: string;
|
|
330
|
+
} | {
|
|
331
|
+
sum: string;
|
|
332
|
+
} | {
|
|
333
|
+
product: string;
|
|
334
|
+
} | {
|
|
335
|
+
difference: [string, string];
|
|
336
|
+
} | {
|
|
337
|
+
abs: string;
|
|
338
|
+
} | {
|
|
339
|
+
min: string;
|
|
340
|
+
} | {
|
|
341
|
+
max: string;
|
|
167
342
|
};
|
|
168
|
-
|
|
343
|
+
|
|
344
|
+
type TypeOf<T> = T extends 'string' ? string : T extends 'number' | 'integer' ? number : T extends 'boolean' ? boolean : T extends 'array' ? unknown[] : T extends 'object' ? Record<string, unknown> : T extends 'null' ? null : T extends 'any' ? unknown : T extends {
|
|
345
|
+
literal: readonly (infer M)[];
|
|
346
|
+
} ? M : T extends readonly (infer B)[] ? TypeOf<B> : unknown;
|
|
347
|
+
type DeclaredType<P> = P extends {
|
|
348
|
+
type: infer T;
|
|
349
|
+
} ? T : 'any';
|
|
350
|
+
type KeepsNull<P> = P extends {
|
|
351
|
+
nullPolicy: 'value';
|
|
352
|
+
} ? true : P extends {
|
|
353
|
+
nullPolicy: NullPolicyValue;
|
|
354
|
+
} ? false : P extends {
|
|
355
|
+
nullPolicy: (...args: any) => any;
|
|
356
|
+
} ? true : false;
|
|
357
|
+
type Delivered<P> = KeepsNull<P> extends true ? TypeOf<DeclaredType<P>> : Exclude<TypeOf<DeclaredType<P>>, null>;
|
|
358
|
+
type Truthy<P> = P extends {
|
|
359
|
+
type: 'array';
|
|
360
|
+
} ? boolean[] : P extends {
|
|
361
|
+
type: 'object';
|
|
362
|
+
} ? Record<string, boolean> : boolean;
|
|
363
|
+
type ParamValue<P> = P extends {
|
|
364
|
+
evaluation: 'structural';
|
|
365
|
+
} ? TypeOf<DeclaredType<P>> : P extends {
|
|
366
|
+
evaluation: 'race';
|
|
367
|
+
} ? SettlementStream : P extends {
|
|
368
|
+
evaluation: 'lazyElements';
|
|
369
|
+
} ? LazyValue[] : P extends {
|
|
370
|
+
evaluation: 'lazyEntries';
|
|
371
|
+
} ? Record<string, LazyValue> : P extends {
|
|
372
|
+
evaluation: 'perElement';
|
|
373
|
+
} ? PerElement<P extends {
|
|
374
|
+
truthiness: true;
|
|
375
|
+
} ? boolean : Delivered<P>> : P extends {
|
|
376
|
+
evaluation: 'lazy';
|
|
377
|
+
} ? LazyValue<Delivered<P>> : P extends {
|
|
378
|
+
truthiness: true;
|
|
379
|
+
} ? Truthy<P> : Delivered<P>;
|
|
380
|
+
type IsHolder<P> = P extends {
|
|
381
|
+
replacesNullAt: readonly string[];
|
|
382
|
+
} ? true : false;
|
|
383
|
+
type IsOptional<P> = P extends {
|
|
384
|
+
default: unknown;
|
|
385
|
+
} ? false : P extends {
|
|
386
|
+
required: false;
|
|
387
|
+
} ? true : false;
|
|
388
|
+
type BodyKeys<D> = {
|
|
389
|
+
[K in keyof D]: IsHolder<D[K]> extends true ? never : K;
|
|
390
|
+
}[keyof D];
|
|
391
|
+
type OptionalKeys<D> = {
|
|
392
|
+
[K in BodyKeys<D>]: IsOptional<D[K]> extends true ? K : never;
|
|
393
|
+
}[BodyKeys<D>];
|
|
394
|
+
type RequiredKeys<D> = Exclude<BodyKeys<D>, OptionalKeys<D>>;
|
|
395
|
+
type Simplify<T> = {
|
|
396
|
+
[K in keyof T]: T[K];
|
|
397
|
+
} & {};
|
|
398
|
+
type ResolvedParams<D extends ParameterDeclarations = ParameterDeclarations> = Simplify<{
|
|
399
|
+
[K in RequiredKeys<D>]: ParamValue<D[K]>;
|
|
400
|
+
} & {
|
|
401
|
+
[K in OptionalKeys<D>]?: ParamValue<D[K]>;
|
|
402
|
+
}>;
|
|
403
|
+
|
|
404
|
+
type EvaluationMode = 'eager' | 'race' | 'lazy' | 'lazyElements' | 'lazyEntries' | 'perElement' | 'structural';
|
|
405
|
+
declare const OPERATOR_CATEGORIES: readonly ["logic", "comparison", "math", "string", "array", "data", "io", "other"];
|
|
406
|
+
type OperatorCategory = (typeof OPERATOR_CATEGORIES)[number];
|
|
407
|
+
type NullPolicyValue = 'propagate' | 'value';
|
|
408
|
+
type ConditionalNullPolicy = (selectorValue: any) => NullPolicyValue;
|
|
409
|
+
type NullPolicy = NullPolicyValue | ConditionalNullPolicy;
|
|
410
|
+
interface CompiledNullPolicy {
|
|
411
|
+
selector: string;
|
|
412
|
+
table: {
|
|
413
|
+
value: string | number | boolean;
|
|
414
|
+
policy: NullPolicyValue;
|
|
415
|
+
}[];
|
|
416
|
+
}
|
|
417
|
+
declare const EvaluationData: unique symbol;
|
|
418
|
+
type OperatorEvaluate = (params: Record<string, unknown>, context: OperatorContext) => unknown;
|
|
419
|
+
interface ValidateFinding {
|
|
420
|
+
severity: Severity;
|
|
421
|
+
message: string;
|
|
422
|
+
parameter?: string;
|
|
423
|
+
}
|
|
424
|
+
type OperatorValidate = (literalParams: Record<string, unknown>, helpers: ValidateHelpers) => ValidateFinding[];
|
|
425
|
+
interface ParameterDeclaration extends TypeDeclaration {
|
|
426
|
+
default?: unknown;
|
|
427
|
+
description?: string;
|
|
428
|
+
metadata?: Record<string, unknown>;
|
|
429
|
+
evaluation?: EvaluationMode;
|
|
430
|
+
over?: string;
|
|
431
|
+
truthiness?: boolean;
|
|
432
|
+
nullPolicy?: NullPolicy;
|
|
433
|
+
elementNullPolicy?: NullPolicyValue;
|
|
434
|
+
replacesNullAt?: readonly string[];
|
|
435
|
+
}
|
|
436
|
+
type ParameterDeclarations = Record<string, ParameterDeclaration>;
|
|
437
|
+
interface OperatorDefinition<P extends ParameterDeclarations = ParameterDeclarations> {
|
|
169
438
|
name: string;
|
|
439
|
+
alias?: string;
|
|
440
|
+
category: OperatorCategory;
|
|
170
441
|
description: string;
|
|
171
|
-
|
|
172
|
-
|
|
442
|
+
metadata?: Record<string, unknown>;
|
|
443
|
+
parameters: P;
|
|
444
|
+
positionalParams?: readonly string[];
|
|
445
|
+
timeoutParam?: string;
|
|
446
|
+
cache?: true;
|
|
447
|
+
validate?: OperatorValidate;
|
|
448
|
+
analysis?: OperatorAnalysis;
|
|
449
|
+
evaluate: (params: ResolvedParams<P>, context: OperatorContext) => unknown;
|
|
450
|
+
returns?: ExpectedType;
|
|
451
|
+
}
|
|
452
|
+
declare const VALIDATED_OPERATOR: unique symbol;
|
|
453
|
+
interface ValidatedParameter {
|
|
173
454
|
type: ExpectedType;
|
|
455
|
+
required: boolean;
|
|
174
456
|
default?: unknown;
|
|
457
|
+
description?: string;
|
|
458
|
+
metadata?: Record<string, unknown>;
|
|
459
|
+
evaluation: EvaluationMode;
|
|
460
|
+
truthiness: boolean;
|
|
461
|
+
nullPolicy: NullPolicyValue | CompiledNullPolicy;
|
|
462
|
+
elementNullPolicy?: NullPolicyValue;
|
|
463
|
+
constraints?: Constraints;
|
|
464
|
+
over?: string;
|
|
465
|
+
replacesNullAt?: string[];
|
|
175
466
|
}
|
|
176
|
-
interface
|
|
467
|
+
interface ValidatedOperatorDefinition {
|
|
468
|
+
readonly [VALIDATED_OPERATOR]: true;
|
|
177
469
|
name: string;
|
|
178
|
-
|
|
179
|
-
|
|
470
|
+
alias?: string;
|
|
471
|
+
category: OperatorCategory;
|
|
472
|
+
description: string;
|
|
473
|
+
metadata?: Record<string, unknown>;
|
|
474
|
+
parameters: Record<string, ValidatedParameter>;
|
|
475
|
+
positionalParams?: string[];
|
|
476
|
+
restParam: string | null;
|
|
477
|
+
resolution: ResolutionPlan;
|
|
478
|
+
deliversLazily: boolean;
|
|
479
|
+
timeoutParam: string | null;
|
|
480
|
+
cache: boolean;
|
|
481
|
+
fingerprint: string;
|
|
482
|
+
validate?: OperatorValidate;
|
|
483
|
+
analysis?: OperatorAnalysis;
|
|
484
|
+
evaluate: OperatorEvaluate;
|
|
485
|
+
returns: ExpectedType;
|
|
486
|
+
}
|
|
487
|
+
type DeclarationEntry = readonly [name: string, declared: ValidatedParameter];
|
|
488
|
+
interface ResolutionPlan {
|
|
489
|
+
readonly entries: readonly DeclarationEntry[];
|
|
490
|
+
readonly whole: readonly DeclarationEntry[];
|
|
491
|
+
readonly perElement: readonly DeclarationEntry[];
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
declare const isTruthy: (value: unknown) => boolean;
|
|
495
|
+
|
|
496
|
+
declare const compareValues: (a: number | string, b: number | string) => -1 | 0 | 1;
|
|
497
|
+
|
|
498
|
+
declare const ARRAY = "<array>";
|
|
499
|
+
declare const OBJECT = "<object>";
|
|
500
|
+
declare const renderText: (value: unknown) => string;
|
|
501
|
+
|
|
502
|
+
declare const WILDCARD: unique symbol;
|
|
503
|
+
type Wildcard = typeof WILDCARD;
|
|
504
|
+
type PathSegment = string | number | Wildcard;
|
|
505
|
+
interface ResolveResult {
|
|
506
|
+
found: boolean;
|
|
507
|
+
value: unknown;
|
|
508
|
+
}
|
|
509
|
+
declare const parsePath: (path: string) => PathSegment[];
|
|
510
|
+
declare const resolvePath: (source: unknown, path: string | PathSegment[]) => ResolveResult;
|
|
511
|
+
|
|
512
|
+
declare const deepEqual: (foo: any, bar: any) => boolean;
|
|
513
|
+
|
|
514
|
+
declare const NAMESPACE_TOKENS: {
|
|
515
|
+
readonly data: "data";
|
|
516
|
+
readonly d: "data";
|
|
517
|
+
readonly vars: "vars";
|
|
518
|
+
readonly v: "vars";
|
|
519
|
+
readonly params: "params";
|
|
520
|
+
readonly p: "params";
|
|
521
|
+
readonly element: "element";
|
|
522
|
+
readonly e: "element";
|
|
523
|
+
readonly index: "index";
|
|
524
|
+
readonly i: "index";
|
|
525
|
+
readonly error: "error";
|
|
526
|
+
readonly err: "error";
|
|
527
|
+
};
|
|
528
|
+
type ReferenceNamespace = (typeof NAMESPACE_TOKENS)[keyof typeof NAMESPACE_TOKENS];
|
|
529
|
+
type ReferenceRecognition = {
|
|
530
|
+
kind: 'reference';
|
|
531
|
+
namespace: ReferenceNamespace;
|
|
532
|
+
segments: PathSegment[];
|
|
533
|
+
drill: string;
|
|
534
|
+
binding?: string;
|
|
535
|
+
} | {
|
|
536
|
+
kind: 'invalid';
|
|
537
|
+
namespace: ReferenceNamespace;
|
|
538
|
+
reason: string;
|
|
539
|
+
code?: string;
|
|
540
|
+
} | {
|
|
541
|
+
kind: 'unrecognized';
|
|
542
|
+
} | {
|
|
543
|
+
kind: 'plain';
|
|
544
|
+
};
|
|
545
|
+
interface ReferenceScope {
|
|
546
|
+
bindings?: readonly string[];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
type ObjectClass = {
|
|
550
|
+
kind: 'operator';
|
|
551
|
+
} | {
|
|
552
|
+
kind: 'fragment';
|
|
553
|
+
} | {
|
|
554
|
+
kind: 'shorthand';
|
|
555
|
+
key: string;
|
|
556
|
+
} | {
|
|
557
|
+
kind: 'plain';
|
|
558
|
+
} | {
|
|
559
|
+
kind: 'malformed';
|
|
560
|
+
message: string;
|
|
561
|
+
};
|
|
562
|
+
interface PositionalShape {
|
|
563
|
+
positionalParams?: readonly string[];
|
|
564
|
+
restParam: string | null;
|
|
565
|
+
}
|
|
566
|
+
interface PositionalLayout {
|
|
567
|
+
bound: number;
|
|
568
|
+
restAt: number | null;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
interface FragmentParameterDeclaration extends TypeDeclaration {
|
|
572
|
+
default?: unknown;
|
|
573
|
+
description?: string;
|
|
574
|
+
metadata?: Record<string, unknown>;
|
|
575
|
+
}
|
|
576
|
+
interface FragmentDefinition {
|
|
577
|
+
expression: unknown;
|
|
578
|
+
parameters?: Record<string, FragmentParameterDeclaration>;
|
|
180
579
|
description?: string;
|
|
580
|
+
metadata?: Record<string, unknown>;
|
|
581
|
+
}
|
|
582
|
+
interface FragmentParameter {
|
|
583
|
+
type: ExpectedType;
|
|
584
|
+
required: boolean;
|
|
181
585
|
default?: unknown;
|
|
586
|
+
description?: string;
|
|
587
|
+
metadata?: Record<string, unknown>;
|
|
588
|
+
constraints?: Constraints;
|
|
182
589
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
590
|
+
|
|
591
|
+
type EvaluationOptions = Omit<FigTreeOptions, 'operators' | 'fragments'>;
|
|
592
|
+
type CallOptions = Pick<FigTreeOptions, 'data' | 'signal' | 'timeout' | 'trace'>;
|
|
593
|
+
type OnlyCallOptions<CallOpts> = CallOpts & {
|
|
594
|
+
[Key in Exclude<keyof CallOpts, keyof CallOptions>]: never;
|
|
595
|
+
};
|
|
596
|
+
interface FigTreeOptions {
|
|
597
|
+
data?: Record<string, unknown>;
|
|
598
|
+
fragments?: Record<string, FragmentDefinition>;
|
|
599
|
+
operators?: (ValidatedOperatorDefinition | ValidatedOperatorDefinition[])[];
|
|
600
|
+
operatorDefaults?: {
|
|
601
|
+
[operator: string]: {
|
|
602
|
+
noCache?: true;
|
|
603
|
+
fallback?: unknown;
|
|
604
|
+
[param: string]: unknown;
|
|
605
|
+
};
|
|
606
|
+
};
|
|
607
|
+
http?: {
|
|
608
|
+
baseEndpoint?: string;
|
|
609
|
+
headers?: Record<string, string>;
|
|
610
|
+
};
|
|
611
|
+
graphQL?: {
|
|
612
|
+
endpoint?: string;
|
|
613
|
+
headers?: Record<string, string>;
|
|
614
|
+
};
|
|
615
|
+
strictDataPaths?: boolean;
|
|
616
|
+
maxDepth?: number;
|
|
617
|
+
maxNodes?: number;
|
|
618
|
+
timeout?: number;
|
|
619
|
+
signal?: AbortSignal;
|
|
620
|
+
cache?: {
|
|
621
|
+
store?: CacheStore;
|
|
622
|
+
maxSize?: number;
|
|
623
|
+
maxTime?: number;
|
|
624
|
+
};
|
|
625
|
+
trace?: boolean;
|
|
187
626
|
}
|
|
188
|
-
type
|
|
189
|
-
|
|
190
|
-
parseChildren: ParseChildrenMethod;
|
|
627
|
+
type OptionsUpdate = {
|
|
628
|
+
[Key in keyof FigTreeOptions]?: (Key extends MergedBlock ? Removable<NonNullable<FigTreeOptions[Key]>> : FigTreeOptions[Key]) | null;
|
|
191
629
|
};
|
|
192
|
-
type
|
|
193
|
-
|
|
630
|
+
type MergedBlock = 'fragments' | 'operatorDefaults' | 'http' | 'graphQL' | 'cache';
|
|
631
|
+
type Removable<Block> = {
|
|
632
|
+
[Key in keyof Block]?: Block[Key] | null;
|
|
194
633
|
};
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
evaluate(expression: EvaluatorNode, options?: FigTreeOptions): Promise<EvaluatorOutput>;
|
|
210
|
-
isFigTreeExpression(expression: EvaluatorNode): boolean;
|
|
211
|
-
getOptions(): FigTreeOptions;
|
|
212
|
-
updateOptions(options: FigTreeOptions): void;
|
|
213
|
-
getCache: () => Store;
|
|
214
|
-
setCache: (cache: Store) => Store;
|
|
215
|
-
getOperators(): readonly OperatorMetadata[];
|
|
216
|
-
getFragments(): readonly FragmentMetadata[];
|
|
217
|
-
getCustomFunctions(): readonly CustomFunctionMetadata[];
|
|
218
|
-
getConfig(): {
|
|
219
|
-
options: FigTreeOptions;
|
|
220
|
-
operators: OperatorReference;
|
|
221
|
-
operatorAliases: OperatorAliases;
|
|
222
|
-
typeChecker: (...args: TypeCheckInput[] | [TypeCheckInput[]]) => void;
|
|
223
|
-
resolvedAliasNodes: {};
|
|
224
|
-
cache: FigTreeCache;
|
|
225
|
-
graphQLClient: HttpClient | undefined;
|
|
226
|
-
httpClient: HttpClient | undefined;
|
|
634
|
+
interface EvaluationResult {
|
|
635
|
+
result: unknown;
|
|
636
|
+
trace: TraceNode;
|
|
637
|
+
}
|
|
638
|
+
type NoOptions = Record<never, never>;
|
|
639
|
+
type Merge<Instance, Call> = Omit<Instance, keyof Call> & Call;
|
|
640
|
+
type ResultShape<O> = O extends {
|
|
641
|
+
trace: true;
|
|
642
|
+
} ? EvaluationResult : unknown;
|
|
643
|
+
|
|
644
|
+
interface Dependencies {
|
|
645
|
+
data: {
|
|
646
|
+
paths: string[];
|
|
647
|
+
dynamic: boolean;
|
|
227
648
|
};
|
|
228
|
-
|
|
649
|
+
operators: string[];
|
|
650
|
+
fragments: string[];
|
|
651
|
+
}
|
|
652
|
+
interface ParameterInfo extends ValidatedParameter {
|
|
653
|
+
hostDefault?: unknown;
|
|
654
|
+
}
|
|
655
|
+
interface OperatorInfo extends Omit<ValidatedOperatorDefinition, typeof VALIDATED_OPERATOR | 'evaluate' | 'validate' | 'deliversLazily' | 'resolution' | 'fingerprint' | 'parameters'> {
|
|
656
|
+
parameters: Record<string, ParameterInfo>;
|
|
657
|
+
hasValidate: boolean;
|
|
658
|
+
hostNoCache?: true;
|
|
659
|
+
hostFallback?: unknown;
|
|
660
|
+
}
|
|
661
|
+
interface FragmentInfo {
|
|
662
|
+
name: string;
|
|
663
|
+
description?: string;
|
|
664
|
+
metadata?: Record<string, unknown>;
|
|
665
|
+
parameters: Record<string, FragmentParameter>;
|
|
666
|
+
returns: ExpectedType;
|
|
667
|
+
warnings: Issue[];
|
|
668
|
+
dependencies: Dependencies;
|
|
669
|
+
caches: boolean;
|
|
229
670
|
}
|
|
230
|
-
declare const evaluateExpression: (expression: EvaluatorNode, options?: FigTreeOptions) => Promise<EvaluatorOutput>;
|
|
231
671
|
|
|
232
|
-
declare class
|
|
233
|
-
|
|
672
|
+
declare class FigTree<InstanceOpts extends FigTreeOptions = NoOptions> {
|
|
673
|
+
private state;
|
|
674
|
+
private readonly results;
|
|
675
|
+
readonly version = "3.0.0-preview.10";
|
|
676
|
+
constructor(options?: InstanceOpts);
|
|
677
|
+
updateOptions(options?: OptionsUpdate): void;
|
|
678
|
+
clearCache(): void;
|
|
679
|
+
getOptions(): EvaluationOptions;
|
|
680
|
+
getOperators(): OperatorInfo[];
|
|
681
|
+
getFragments(): FragmentInfo[];
|
|
682
|
+
validate(expression: unknown, options?: CallOptions): ValidationResult;
|
|
683
|
+
getDependencies(expression: unknown): Dependencies;
|
|
684
|
+
isEvaluable(expression: unknown): boolean;
|
|
685
|
+
evaluate<CallOpts extends CallOptions = NoOptions>(expression: unknown, options?: OnlyCallOptions<CallOpts>): Promise<ResultShape<Merge<InstanceOpts, CallOpts>>>;
|
|
686
|
+
compile(expression: unknown): CompiledExpression<InstanceOpts>;
|
|
687
|
+
}
|
|
688
|
+
declare class CompiledExpression<InstanceOpts extends FigTreeOptions = NoOptions> {
|
|
689
|
+
#private;
|
|
690
|
+
private constructor();
|
|
691
|
+
get expression(): unknown;
|
|
692
|
+
get issues(): readonly Issue[];
|
|
693
|
+
get hasErrors(): boolean;
|
|
694
|
+
evaluate<CallOpts extends CallOptions = NoOptions>(options?: OnlyCallOptions<CallOpts>): Promise<ResultShape<Merge<InstanceOpts, CallOpts>>>;
|
|
695
|
+
getDependencies(): Dependencies;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
declare function defineOperator(definition: ValidatedOperatorDefinition): ValidatedOperatorDefinition;
|
|
699
|
+
declare function defineOperator<const P extends ParameterDeclarations>(definition: OperatorDefinition<P>): ValidatedOperatorDefinition;
|
|
700
|
+
|
|
701
|
+
declare const coreOperators: ValidatedOperatorDefinition[];
|
|
702
|
+
|
|
703
|
+
interface OperatorFailureInit {
|
|
704
|
+
code?: FallbackErrorCode;
|
|
234
705
|
errorData?: Record<string, unknown>;
|
|
235
|
-
expression?: EvaluatorNode;
|
|
236
|
-
prettyPrint: string;
|
|
237
|
-
constructor(error: Error & {
|
|
238
|
-
errorData?: Record<string, unknown>;
|
|
239
|
-
}, operator?: Operator, name?: string, expression?: EvaluatorNode);
|
|
240
706
|
}
|
|
241
|
-
declare
|
|
707
|
+
declare class OperatorFailure extends Error {
|
|
708
|
+
code?: FallbackErrorCode;
|
|
709
|
+
errorData?: Record<string, unknown>;
|
|
710
|
+
constructor(message: string, init?: OperatorFailureInit);
|
|
711
|
+
}
|
|
712
|
+
declare const isOperatorFailure: (input: unknown) => input is OperatorFailure;
|
|
242
713
|
|
|
243
|
-
declare const
|
|
244
|
-
|
|
245
|
-
};
|
|
246
|
-
declare const SQLite: (db: Database) => {
|
|
247
|
-
query: ({ query, values }: QueryInput) => Promise<any[]>;
|
|
248
|
-
};
|
|
714
|
+
declare const httpOperators: (client?: HttpClient) => ValidatedOperatorDefinition[];
|
|
715
|
+
declare const sqlOperators: (connection: SqlConnection) => ValidatedOperatorDefinition[];
|
|
249
716
|
|
|
250
|
-
type
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
717
|
+
type FetchLike = (input: string, init?: {
|
|
718
|
+
method?: string;
|
|
719
|
+
headers?: Record<string, string>;
|
|
720
|
+
body?: string;
|
|
721
|
+
signal?: AbortSignal;
|
|
722
|
+
}) => Promise<FetchResponseLike>;
|
|
723
|
+
interface FetchResponseLike {
|
|
724
|
+
ok: boolean;
|
|
725
|
+
status: number;
|
|
726
|
+
statusText: string;
|
|
727
|
+
url: string;
|
|
728
|
+
text(): Promise<string>;
|
|
729
|
+
}
|
|
730
|
+
interface AxiosLike {
|
|
731
|
+
(config: {
|
|
732
|
+
url: string;
|
|
733
|
+
method: 'get' | 'post';
|
|
734
|
+
headers?: Record<string, string>;
|
|
735
|
+
data?: unknown;
|
|
736
|
+
signal?: AbortSignal;
|
|
737
|
+
}): Promise<{
|
|
738
|
+
data: unknown;
|
|
739
|
+
status: number;
|
|
740
|
+
statusText: string;
|
|
741
|
+
}>;
|
|
742
|
+
isAxiosError(payload: unknown): payload is AxiosErrorLike;
|
|
743
|
+
}
|
|
744
|
+
interface AxiosErrorLike {
|
|
745
|
+
message: string;
|
|
746
|
+
config?: {
|
|
747
|
+
url?: string;
|
|
748
|
+
};
|
|
749
|
+
response?: {
|
|
750
|
+
status: number;
|
|
751
|
+
statusText: string;
|
|
752
|
+
data: unknown;
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
declare class FetchClient implements HttpClient {
|
|
756
|
+
private readonly supplied?;
|
|
757
|
+
constructor(fetchImpl?: FetchLike);
|
|
758
|
+
request: (req: HttpRequest) => Promise<unknown>;
|
|
759
|
+
}
|
|
760
|
+
declare class AxiosClient implements HttpClient {
|
|
761
|
+
private readonly axios;
|
|
762
|
+
constructor(axios: AxiosLike);
|
|
763
|
+
request: (req: HttpRequest) => Promise<unknown>;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
interface PgClientLike {
|
|
767
|
+
query(config: {
|
|
768
|
+
text: string;
|
|
769
|
+
values?: unknown[];
|
|
770
|
+
}): Promise<{
|
|
771
|
+
rows: Record<string, unknown>[];
|
|
772
|
+
}>;
|
|
773
|
+
}
|
|
774
|
+
interface SqliteDatabaseLike {
|
|
775
|
+
all(sql: string, params?: unknown[] | Record<string, unknown>): Promise<Record<string, unknown>[]>;
|
|
776
|
+
}
|
|
777
|
+
declare class PostgresConnection implements SqlConnection {
|
|
778
|
+
private readonly client;
|
|
779
|
+
constructor(client: PgClientLike);
|
|
780
|
+
query: (req: SqlRequest) => Promise<Record<string, unknown>[]>;
|
|
781
|
+
}
|
|
782
|
+
declare class SQLiteConnection implements SqlConnection {
|
|
783
|
+
private readonly db;
|
|
784
|
+
constructor(db: SqliteDatabaseLike);
|
|
785
|
+
query: (req: SqlRequest) => Promise<Record<string, unknown>[]>;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
interface HttpFailureInfo {
|
|
789
|
+
status: number;
|
|
790
|
+
statusText: string;
|
|
791
|
+
url: string;
|
|
792
|
+
response: unknown;
|
|
793
|
+
}
|
|
794
|
+
declare const httpFailure: (info: HttpFailureInfo) => OperatorFailure;
|
|
795
|
+
declare const sqlFailure: (driver: string, error: unknown) => OperatorFailure;
|
|
796
|
+
|
|
797
|
+
type Json = null | boolean | number | string | Json[] | {
|
|
798
|
+
[key: string]: Json;
|
|
260
799
|
};
|
|
800
|
+
type Path = (string | number)[];
|
|
261
801
|
|
|
262
|
-
|
|
802
|
+
type NodeMap = Record<string, InspectNode>;
|
|
803
|
+
type InspectNode = {
|
|
804
|
+
order: number;
|
|
805
|
+
path: Path;
|
|
806
|
+
} & ({
|
|
807
|
+
kind: 'constant';
|
|
808
|
+
value: Json;
|
|
809
|
+
} | {
|
|
810
|
+
kind: 'reference';
|
|
811
|
+
reference: string;
|
|
812
|
+
authored: string;
|
|
813
|
+
binding?: string;
|
|
814
|
+
} | {
|
|
815
|
+
kind: 'operator';
|
|
816
|
+
vars?: NodeMap;
|
|
817
|
+
operator: string;
|
|
818
|
+
params: NodeMap;
|
|
819
|
+
fallback?: InspectNode;
|
|
820
|
+
timeoutFallback?: Json;
|
|
821
|
+
noCache?: true;
|
|
822
|
+
hostDefaults?: string[];
|
|
823
|
+
} | {
|
|
824
|
+
kind: 'fragmentCall';
|
|
825
|
+
vars?: NodeMap;
|
|
826
|
+
fragment: string;
|
|
827
|
+
resolved: boolean;
|
|
828
|
+
argumentsMode: 'static' | 'dynamic';
|
|
829
|
+
parameters?: NodeMap | InspectNode;
|
|
830
|
+
fallback?: InspectNode;
|
|
831
|
+
timeoutFallback?: Json;
|
|
832
|
+
noCache?: true;
|
|
833
|
+
} | {
|
|
834
|
+
kind: 'skeleton';
|
|
835
|
+
vars?: NodeMap;
|
|
836
|
+
shape: Json;
|
|
837
|
+
holes: {
|
|
838
|
+
at: Path;
|
|
839
|
+
node: InspectNode;
|
|
840
|
+
}[];
|
|
841
|
+
} | {
|
|
842
|
+
kind: 'elements';
|
|
843
|
+
elements: InspectNode[];
|
|
844
|
+
} | {
|
|
845
|
+
kind: 'entries';
|
|
846
|
+
vars?: NodeMap;
|
|
847
|
+
entries: NodeMap;
|
|
848
|
+
} | {
|
|
849
|
+
kind: 'invalid';
|
|
850
|
+
raw: Json;
|
|
851
|
+
});
|
|
263
852
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
853
|
+
type InspectIssue = Issue & {
|
|
854
|
+
order?: number;
|
|
855
|
+
};
|
|
856
|
+
interface InspectDependencies {
|
|
857
|
+
dataPaths: string[];
|
|
858
|
+
dynamic: boolean;
|
|
859
|
+
operators: string[];
|
|
860
|
+
fragments: string[];
|
|
861
|
+
}
|
|
862
|
+
interface InspectReport {
|
|
863
|
+
version: string;
|
|
864
|
+
expression: Json;
|
|
865
|
+
options: Record<string, Json>;
|
|
866
|
+
canonicalForm: InspectNode;
|
|
867
|
+
issues: InspectIssue[];
|
|
868
|
+
timeoutShielded: boolean;
|
|
869
|
+
nodeCount: number;
|
|
870
|
+
maxDepth: number;
|
|
871
|
+
dependencies: InspectDependencies;
|
|
872
|
+
own: {
|
|
873
|
+
nodeCount: number;
|
|
874
|
+
maxDepth: number;
|
|
875
|
+
dependencies: InspectDependencies;
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
declare const inspect: <InstanceOpts extends FigTreeOptions>(compiled: CompiledExpression<InstanceOpts>, options?: CallOptions) => InspectReport;
|
|
271
879
|
|
|
272
|
-
|
|
273
|
-
|
|
880
|
+
interface OperatorHints {
|
|
881
|
+
displayName: string;
|
|
882
|
+
docUrl: string;
|
|
883
|
+
backgroundColor: string;
|
|
884
|
+
textColor: string;
|
|
885
|
+
seeds?: {
|
|
886
|
+
[parameter: string]: unknown;
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
type FragmentHints = Omit<OperatorHints, 'docUrl'> & {
|
|
890
|
+
docUrl?: string;
|
|
891
|
+
};
|
|
892
|
+
interface CategoryHints {
|
|
893
|
+
displayName: string;
|
|
894
|
+
order: number;
|
|
895
|
+
backgroundColor: string;
|
|
896
|
+
textColor: string;
|
|
897
|
+
}
|
|
898
|
+
type OperatorHintMap = {
|
|
899
|
+
[operator: string]: OperatorHints;
|
|
900
|
+
};
|
|
901
|
+
type CategoryHintMap = {
|
|
902
|
+
[category in OperatorCategory]: CategoryHints;
|
|
903
|
+
};
|
|
904
|
+
type TypeSeeds = {
|
|
905
|
+
[type in BasicType]: unknown;
|
|
906
|
+
};
|
|
274
907
|
|
|
275
|
-
|
|
908
|
+
interface MigrationIssue {
|
|
909
|
+
code: 'split-trailing-empty' | 'remainder-sign' | 'template-numbering' | 'named-token-source' | 'response-collapse' | 'computed-delimiter' | 'computed-branches' | 'graphql-relative-url' | 'output-type' | 'missing-data-fallback' | 'unprefixed-parameter' | 'cache-opt-in' | 'instance-case-insensitive' | 'values-cut' | 'fallback-converted' | 'malformed-entry' | 'unreachable-branches' | 'overridden-value' | 'discarded-expression' | 'fragment-shorthand-payload' | 'shadowed-argument' | 'unknown-argument' | 'name-renamed' | 'unknown-parameter-type' | 'default-outside-type' | 'unused-output-type' | 'deciding-value' | 'drilled-substitution-token' | 'number-mapping' | 'template-escape' | 'computed-dollar-template' | 'custom-function-call' | 'computed-function-name' | 'computed-arguments' | 'body-override' | 'computed-fragment-name' | 'replaced-output-type' | 'computed-children' | 'unknown-operator' | 'unconvertible-input';
|
|
910
|
+
tag: 'non-convertible' | 'intentional-semantic-change' | 'lossy-default';
|
|
911
|
+
path: (string | number)[];
|
|
912
|
+
message: string;
|
|
913
|
+
}
|
|
914
|
+
interface MigrationResult {
|
|
915
|
+
expression: unknown;
|
|
916
|
+
issues: MigrationIssue[];
|
|
917
|
+
}
|
|
918
|
+
interface FragmentMigrationResult {
|
|
919
|
+
fragments: Record<string, FragmentDefinition>;
|
|
920
|
+
issues: MigrationIssue[];
|
|
921
|
+
}
|
|
922
|
+
interface V2Options {
|
|
923
|
+
fragments?: Record<string, unknown>;
|
|
924
|
+
functions?: readonly string[] | Record<string, unknown>;
|
|
925
|
+
evaluateFullObject?: boolean;
|
|
926
|
+
noShorthand?: boolean;
|
|
927
|
+
caseInsensitive?: boolean;
|
|
928
|
+
useCache?: boolean;
|
|
929
|
+
}
|
|
276
930
|
|
|
277
|
-
|
|
931
|
+
interface Registry {
|
|
932
|
+
getOperators(): readonly {
|
|
933
|
+
name: string;
|
|
934
|
+
alias?: string;
|
|
935
|
+
positionalParams?: readonly string[];
|
|
936
|
+
restParam: string | null;
|
|
937
|
+
}[];
|
|
938
|
+
getFragments(): readonly {
|
|
939
|
+
name: string;
|
|
940
|
+
}[];
|
|
941
|
+
}
|
|
942
|
+
type Spelling = 'preserve' | 'canonical' | 'alias';
|
|
943
|
+
interface NameOptions {
|
|
944
|
+
referenceNames?: Spelling;
|
|
945
|
+
}
|
|
946
|
+
interface CanonicalOptions extends NameOptions {
|
|
947
|
+
operatorNames?: Spelling;
|
|
948
|
+
referencesAsGet?: boolean;
|
|
949
|
+
}
|
|
950
|
+
interface ShorthandOptions extends NameOptions {
|
|
951
|
+
operatorNames?: Spelling;
|
|
952
|
+
arguments?: 'positional' | 'named';
|
|
953
|
+
getAsReference?: boolean;
|
|
954
|
+
}
|
|
278
955
|
|
|
279
|
-
export {
|
|
956
|
+
export { ARRAY, AxiosClient, CompiledExpression, ErrorCodes, EvaluationData, FetchClient, FigTree, FigTreeError, OBJECT, OPERATOR_CATEGORIES, OperatorFailure, PostgresConnection, SQLiteConnection, WILDCARD, compareValues, coreOperators, deepEqual, defineOperator, httpFailure, httpOperators, inspect, isFigTreeError, isOperatorFailure, isTruthy, parsePath, renderText, resolvePath, sqlFailure, sqlOperators, version };
|
|
957
|
+
export type { AxiosErrorLike, AxiosLike, BasicType, CacheStore, CacheTraceEvent, CallOptions, CanonicalOptions, CategoryHintMap, CategoryHints, CompiledNullPolicy, ConditionalNullPolicy, Constraints, CoverageFinding, CoveredFinding, DeclaredOutput, Dependencies, EvaluationMode, EvaluationOptions, EvaluationResult, ExpectedType, FailureRule, FailureTest, FallbackCoverage, FallbackCoverageOptions, FallbackError, FallbackErrorCode, FetchLike, FetchResponseLike, FigTreeErrorCode, FigTreeErrorInit, FigTreeOptions, FragmentDefinition, FragmentHints, FragmentInfo, FragmentMigrationResult, FragmentParameter, FragmentParameterDeclaration, HttpClient, HttpFailureInfo, HttpRequest, InspectDependencies, InspectIssue, InspectNode, InspectReport, Issue, KeyOverwriteTraceEvent, KnownTraceEvent, LazyValue, LiteralType, Merge, MigrationIssue, MigrationResult, NameOptions, NoOptions, NullPolicy, NullPolicyValue, ObjectClass, OnlyCallOptions, OperatorAnalysis, OperatorCategory, OperatorContext, OperatorDefinition, OperatorEvaluate, OperatorFailureInit, OperatorHintMap, OperatorHints, OperatorInfo, OperatorValidate, OptionsUpdate, ParamValue, ParameterDeclaration, ParameterDeclarations, ParameterInfo, PathSegment, PerElement, PgClientLike, PositionalLayout, PositionalShape, QueryTraceEvent, ReferenceNamespace, ReferenceRecognition, ReferenceScope, Registry, RenderTraceEvent, RequestTraceEvent, ResolveResult, ResolvedParams, ResultShape, Settlement, SettlementStream, Severity, ShieldedFallbackTraceEvent, ShorthandOptions, Spelling, SqlConnection, SqlRequest, SqliteDatabaseLike, TraceEvent, TraceKind, TraceNode, TraceStatus, TypeCheckResult, TypeDeclaration, TypeOf, TypeSeeds, V2Options, ValidateFinding, ValidateHelpers, ValidatedOperatorDefinition, ValidatedParameter, ValidationResult, Wildcard };
|