fig-tree-evaluator 3.0.0-preview.10 → 3.0.0-preview.12

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.
@@ -0,0 +1,502 @@
1
+ declare const ErrorCodes: {
2
+ readonly typeCheck: "type-check";
3
+ readonly operatorFailure: "operator-failure";
4
+ readonly requestTimeout: "request-timeout";
5
+ readonly httpStatus: "http-status";
6
+ readonly invalidResponse: "invalid-response";
7
+ readonly graphQLErrors: "graphql-errors";
8
+ readonly sqlError: "sql-error";
9
+ readonly requestFailure: "request-failure";
10
+ readonly nonFiniteResult: "non-finite-result";
11
+ readonly escapedHandle: "escaped-handle";
12
+ readonly emptyAggregate: "empty-aggregate";
13
+ readonly missingDataPath: "missing-data-path";
14
+ readonly missingRequired: "missing-required";
15
+ readonly timeout: "timeout";
16
+ readonly aborted: "aborted";
17
+ readonly malformedNode: "malformed-node";
18
+ readonly unknownOperator: "unknown-operator";
19
+ readonly unknownFragment: "unknown-fragment";
20
+ readonly unknownNodeKey: "unknown-node-key";
21
+ readonly unrecognizedIdentifier: "unrecognized-identifier";
22
+ readonly positionalArity: "positional-arity";
23
+ readonly invalidVars: "invalid-vars";
24
+ readonly invalidReference: "invalid-reference";
25
+ readonly invalidAs: "invalid-as";
26
+ readonly unresolvedVar: "unresolved-var";
27
+ readonly unresolvedParam: "unresolved-param";
28
+ readonly unresolvedBinding: "unresolved-binding";
29
+ readonly bareVars: "bare-vars";
30
+ readonly varCycle: "var-cycle";
31
+ readonly depthCeiling: "depth-ceiling";
32
+ readonly maxDepthExceeded: "max-depth";
33
+ readonly maxNodesExceeded: "max-nodes";
34
+ readonly returnsMismatch: "returns-mismatch";
35
+ readonly operatorValidate: "operator-validate";
36
+ readonly uselessModifier: "useless-modifier";
37
+ readonly unreferencedVar: "unreferenced-var";
38
+ readonly shadowedVar: "shadowed-var";
39
+ readonly deadBinding: "dead-binding";
40
+ readonly fallbackMismatch: "fallback-mismatch";
41
+ readonly unboundToken: "unbound-token";
42
+ readonly unusedSubstitution: "unused-substitution";
43
+ readonly inertReferenceToken: "inert-reference-token";
44
+ readonly invalidDefinition: "invalid-definition";
45
+ readonly invalidName: "invalid-name";
46
+ readonly reservedName: "reserved-name";
47
+ readonly invalidNullPolicy: "invalid-null-policy";
48
+ readonly duplicateOperator: "duplicate-operator";
49
+ readonly fragmentCycle: "fragment-cycle";
50
+ readonly invalidOptions: "invalid-options";
51
+ };
52
+ type KnownErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
53
+ type FigTreeErrorCode = KnownErrorCode | (string & {});
54
+ type KnownFallbackErrorCode = (typeof ErrorCodes)['typeCheck' | 'operatorFailure' | 'requestTimeout' | 'httpStatus' | 'invalidResponse' | 'graphQLErrors' | 'sqlError' | 'requestFailure' | 'nonFiniteResult' | 'escapedHandle' | 'emptyAggregate' | 'missingDataPath' | 'missingRequired' | 'timeout'];
55
+ type FallbackErrorCode = KnownFallbackErrorCode | (string & {});
56
+
57
+ interface CacheStore {
58
+ get(key: string): unknown | Promise<unknown>;
59
+ set(key: string, value: unknown): void;
60
+ delete(key: string): void;
61
+ clear(): void;
62
+ }
63
+
64
+ type BasicType = 'any' | 'string' | 'number' | 'boolean' | 'array' | 'object' | 'null' | 'integer';
65
+ type LiteralType = {
66
+ literal: readonly (string | number | boolean)[];
67
+ };
68
+ type ExpectedType = BasicType | LiteralType | readonly BasicType[];
69
+ interface Constraints {
70
+ length?: number;
71
+ homogeneous?: readonly BasicType[];
72
+ elementShape?: Record<string, TypeDeclaration>;
73
+ }
74
+ interface TypeDeclaration {
75
+ type?: ExpectedType;
76
+ required?: boolean;
77
+ constraints?: Constraints;
78
+ }
79
+ type TypeCheckResult = {
80
+ ok: true;
81
+ } | {
82
+ ok: false;
83
+ expected: string;
84
+ actual: string;
85
+ };
86
+
87
+ declare const WILDCARD: unique symbol;
88
+ type Wildcard = typeof WILDCARD;
89
+ type PathSegment = string | number | Wildcard;
90
+ interface ResolveResult {
91
+ found: boolean;
92
+ value: unknown;
93
+ }
94
+
95
+ interface Dependencies {
96
+ data: {
97
+ paths: string[];
98
+ dynamic: boolean;
99
+ };
100
+ operators: string[];
101
+ fragments: string[];
102
+ }
103
+ interface ParameterInfo extends ValidatedParameter {
104
+ hostDefault?: unknown;
105
+ }
106
+ interface OperatorInfo extends Omit<ValidatedOperatorDefinition, typeof VALIDATED_OPERATOR | 'evaluate' | 'validate' | 'deliversLazily' | 'resolution' | 'fingerprint' | 'parameters'> {
107
+ parameters: Record<string, ParameterInfo>;
108
+ hasValidate: boolean;
109
+ hostNoCache?: true;
110
+ hostFallback?: unknown;
111
+ }
112
+ interface FragmentInfo {
113
+ name: string;
114
+ description?: string;
115
+ metadata?: Record<string, unknown>;
116
+ parameters: Record<string, FragmentParameter>;
117
+ returns: ExpectedType;
118
+ warnings: Issue[];
119
+ dependencies: Dependencies;
120
+ caches: boolean;
121
+ }
122
+
123
+ declare class FigTree<InstanceOpts extends FigTreeOptions = NoOptions> {
124
+ private state;
125
+ private readonly results;
126
+ readonly version = "3.0.0-preview.12";
127
+ constructor(options?: InstanceOpts);
128
+ updateOptions(options?: OptionsUpdate): void;
129
+ clearCache(): void;
130
+ getOptions(): EvaluationOptions;
131
+ getOperators(): OperatorInfo[];
132
+ getFragments(): FragmentInfo[];
133
+ validate(expression: unknown, options?: CallOptions): ValidationResult;
134
+ getDependencies(expression: unknown): Dependencies;
135
+ isEvaluable(expression: unknown): boolean;
136
+ evaluate<CallOpts extends CallOptions = NoOptions>(expression: unknown, options?: OnlyCallOptions<CallOpts>): Promise<ResultShape<Merge<InstanceOpts, CallOpts>>>;
137
+ compile(expression: unknown): CompiledExpression<InstanceOpts>;
138
+ }
139
+ declare class CompiledExpression<InstanceOpts extends FigTreeOptions = NoOptions> {
140
+ #private;
141
+ private constructor();
142
+ get expression(): unknown;
143
+ get issues(): readonly Issue[];
144
+ get hasErrors(): boolean;
145
+ evaluate<CallOpts extends CallOptions = NoOptions>(options?: OnlyCallOptions<CallOpts>): Promise<ResultShape<Merge<InstanceOpts, CallOpts>>>;
146
+ getDependencies(): Dependencies;
147
+ }
148
+
149
+ interface OperatorAnalysis {
150
+ failures?: FailureRule[];
151
+ external?: true;
152
+ output?: DeclaredOutput;
153
+ }
154
+ interface FailureRule {
155
+ code: FallbackErrorCode;
156
+ parameter?: string;
157
+ when?: Record<string, FailureTest>;
158
+ options?: Record<string, unknown>;
159
+ may?: true;
160
+ overflow?: true;
161
+ }
162
+ type FailureTest = string | number | boolean | null | {
163
+ type: ExpectedType;
164
+ } | {
165
+ below: number;
166
+ } | {
167
+ empty: true;
168
+ } | {
169
+ supplied: boolean;
170
+ } | {
171
+ invalid: true;
172
+ } | {
173
+ some: FailureTest;
174
+ } | {
175
+ not: FailureTest;
176
+ };
177
+ type DeclaredOutput = ExpectedType | {
178
+ type: 'number' | 'integer';
179
+ min?: number;
180
+ max?: number;
181
+ } | {
182
+ type: 'string' | 'array';
183
+ minLength?: number;
184
+ } | {
185
+ param: string;
186
+ } | {
187
+ elementOf: string;
188
+ } | {
189
+ kindOf: string;
190
+ } | {
191
+ arrayOf: DeclaredOutput;
192
+ minLength?: number;
193
+ } | {
194
+ oneOf: DeclaredOutput[];
195
+ } | {
196
+ typeNamedBy: string;
197
+ } | {
198
+ byParam: string;
199
+ cases: Record<string, DeclaredOutput>;
200
+ otherwise?: DeclaredOutput;
201
+ } | {
202
+ firstNonNull: string;
203
+ } | {
204
+ sum: string;
205
+ } | {
206
+ product: string;
207
+ } | {
208
+ difference: [string, string];
209
+ } | {
210
+ abs: string;
211
+ } | {
212
+ min: string;
213
+ } | {
214
+ max: string;
215
+ };
216
+
217
+ declare const validateHelpers: Readonly<{
218
+ parsePath: (path: string) => PathSegment[];
219
+ resolvePath: (source: unknown, path: string | PathSegment[]) => ResolveResult;
220
+ checkType: (value: unknown, expected: ExpectedType) => TypeCheckResult;
221
+ checkConstraints: (value: unknown, constraints: Constraints) => TypeCheckResult;
222
+ describeType: (value: unknown) => string;
223
+ renderText: (value: unknown) => string;
224
+ isTruthy: (value: unknown) => boolean;
225
+ }>;
226
+ type ValidateHelpers = typeof validateHelpers;
227
+
228
+ type EvaluationMode = 'eager' | 'race' | 'lazy' | 'lazyElements' | 'lazyEntries' | 'perElement' | 'structural';
229
+ declare const OPERATOR_CATEGORIES: readonly ["logic", "comparison", "math", "string", "array", "data", "io", "other"];
230
+ type OperatorCategory = (typeof OPERATOR_CATEGORIES)[number];
231
+ type NullPolicyValue = 'propagate' | 'value';
232
+ interface CompiledNullPolicy {
233
+ selector: string;
234
+ table: {
235
+ value: string | number | boolean;
236
+ policy: NullPolicyValue;
237
+ }[];
238
+ }
239
+ type OperatorEvaluate = (params: Record<string, unknown>, context: OperatorContext) => unknown;
240
+ interface ValidateFinding {
241
+ severity: Severity;
242
+ message: string;
243
+ parameter?: string;
244
+ }
245
+ type OperatorValidate = (literalParams: Record<string, unknown>, helpers: ValidateHelpers) => ValidateFinding[];
246
+ declare const VALIDATED_OPERATOR: unique symbol;
247
+ interface ValidatedParameter {
248
+ type: ExpectedType;
249
+ required: boolean;
250
+ default?: unknown;
251
+ metadata?: Record<string, unknown>;
252
+ evaluation: EvaluationMode;
253
+ truthiness: boolean;
254
+ nullPolicy: NullPolicyValue | CompiledNullPolicy;
255
+ elementNullPolicy?: NullPolicyValue;
256
+ constraints?: Constraints;
257
+ over?: string;
258
+ replacesNullAt?: string[];
259
+ }
260
+ interface ValidatedOperatorDefinition {
261
+ readonly [VALIDATED_OPERATOR]: true;
262
+ name: string;
263
+ alias?: string;
264
+ category: OperatorCategory;
265
+ metadata?: Record<string, unknown>;
266
+ parameters: Record<string, ValidatedParameter>;
267
+ positionalParams?: string[];
268
+ restParam: string | null;
269
+ resolution: ResolutionPlan;
270
+ deliversLazily: boolean;
271
+ timeoutParam: string | null;
272
+ cache: boolean;
273
+ fingerprint: string;
274
+ validate?: OperatorValidate;
275
+ analysis?: OperatorAnalysis;
276
+ evaluate: OperatorEvaluate;
277
+ returns: ExpectedType;
278
+ }
279
+ type DeclarationEntry = readonly [name: string, declared: ValidatedParameter];
280
+ interface ResolutionPlan {
281
+ readonly entries: readonly DeclarationEntry[];
282
+ readonly whole: readonly DeclarationEntry[];
283
+ readonly perElement: readonly DeclarationEntry[];
284
+ }
285
+
286
+ type EvaluationOptions = Omit<FigTreeOptions, 'operators' | 'fragments'>;
287
+ type CallOptions = Pick<FigTreeOptions, 'data' | 'signal' | 'timeout' | 'trace'>;
288
+ type OnlyCallOptions<CallOpts> = CallOpts & {
289
+ [Key in Exclude<keyof CallOpts, keyof CallOptions>]: never;
290
+ };
291
+ interface FigTreeOptions {
292
+ data?: Record<string, unknown>;
293
+ fragments?: Record<string, FragmentDefinition>;
294
+ operators?: (ValidatedOperatorDefinition | ValidatedOperatorDefinition[])[];
295
+ operatorDefaults?: {
296
+ [operator: string]: {
297
+ noCache?: true;
298
+ fallback?: unknown;
299
+ [param: string]: unknown;
300
+ };
301
+ };
302
+ http?: {
303
+ baseEndpoint?: string;
304
+ headers?: Record<string, string>;
305
+ };
306
+ graphQL?: {
307
+ endpoint?: string;
308
+ headers?: Record<string, string>;
309
+ };
310
+ strictDataPaths?: boolean;
311
+ maxDepth?: number;
312
+ maxNodes?: number;
313
+ timeout?: number;
314
+ signal?: AbortSignal;
315
+ cache?: {
316
+ store?: CacheStore;
317
+ maxSize?: number;
318
+ maxTime?: number;
319
+ };
320
+ trace?: boolean;
321
+ }
322
+ type OptionsUpdate = {
323
+ [Key in keyof FigTreeOptions]?: (Key extends MergedBlock ? Removable<NonNullable<FigTreeOptions[Key]>> : FigTreeOptions[Key]) | null;
324
+ };
325
+ type MergedBlock = 'fragments' | 'operatorDefaults' | 'http' | 'graphQL' | 'cache';
326
+ type Removable<Block> = {
327
+ [Key in keyof Block]?: Block[Key] | null;
328
+ };
329
+ interface EvaluationResult {
330
+ result: unknown;
331
+ trace: TraceNode;
332
+ }
333
+ type NoOptions = Record<never, never>;
334
+ type Merge<Instance, Call> = Omit<Instance, keyof Call> & Call;
335
+ type ResultShape<O> = O extends {
336
+ trace: true;
337
+ } ? EvaluationResult : unknown;
338
+
339
+ type TraceEvent = {
340
+ type: string;
341
+ [key: string]: unknown;
342
+ };
343
+ interface OperatorContext {
344
+ signal: AbortSignal;
345
+ options: Readonly<EvaluationOptions>;
346
+ cache: {
347
+ memo<T>(key: unknown, fn: () => Promise<T>): Promise<T>;
348
+ };
349
+ trace: {
350
+ note(event: TraceEvent): void;
351
+ };
352
+ }
353
+
354
+ type TraceStatus = 'value' | 'failed' | 'fallback' | 'cancelled' | 'skipped';
355
+ type TraceKind = 'operator' | 'fragment' | 'reference' | 'literal' | 'skeleton';
356
+ interface TraceNode {
357
+ path: (string | number)[];
358
+ source?: {
359
+ fragment: string;
360
+ };
361
+ kind: TraceKind;
362
+ operator?: string;
363
+ ref?: string;
364
+ var?: string;
365
+ status: TraceStatus;
366
+ value?: unknown;
367
+ error?: FigTreeError;
368
+ events?: TraceEvent[];
369
+ children?: TraceNode[];
370
+ elapsed?: number;
371
+ warnings?: Issue[];
372
+ }
373
+
374
+ interface FigTreeErrorInit {
375
+ code: FigTreeErrorCode;
376
+ message: string;
377
+ path: (string | number)[];
378
+ operator?: string;
379
+ fragment?: string;
380
+ fragmentPath?: (string | number)[];
381
+ errorData?: Record<string, unknown>;
382
+ related?: FigTreeError[];
383
+ cause?: unknown;
384
+ issues?: Issue[];
385
+ trace?: TraceNode;
386
+ }
387
+ declare class FigTreeError extends Error {
388
+ code: FigTreeErrorCode;
389
+ path: (string | number)[];
390
+ operator?: string;
391
+ fragment?: string;
392
+ fragmentPath?: (string | number)[];
393
+ errorData?: Record<string, unknown>;
394
+ related?: FigTreeError[];
395
+ cause?: unknown;
396
+ issues?: Issue[];
397
+ trace?: TraceNode;
398
+ constructor(init: FigTreeErrorInit);
399
+ prettyPrint(): string;
400
+ }
401
+
402
+ type Severity = 'error' | 'warning';
403
+ interface Issue {
404
+ severity: Severity;
405
+ code: FigTreeErrorCode;
406
+ message: string;
407
+ path: (string | number)[];
408
+ operator?: string;
409
+ fragment?: string;
410
+ parameter?: string;
411
+ suggestion?: string;
412
+ }
413
+ interface ValidationResult {
414
+ valid: boolean;
415
+ issues: Issue[];
416
+ }
417
+
418
+ interface FragmentParameterDeclaration extends TypeDeclaration {
419
+ default?: unknown;
420
+ description?: string;
421
+ metadata?: Record<string, unknown>;
422
+ }
423
+ interface FragmentDefinition {
424
+ expression: unknown;
425
+ parameters?: Record<string, FragmentParameterDeclaration>;
426
+ description?: string;
427
+ metadata?: Record<string, unknown>;
428
+ }
429
+ interface FragmentParameter {
430
+ type: ExpectedType;
431
+ required: boolean;
432
+ default?: unknown;
433
+ description?: string;
434
+ metadata?: Record<string, unknown>;
435
+ constraints?: Constraints;
436
+ }
437
+
438
+ interface OperatorListing {
439
+ displayName?: string;
440
+ description?: string;
441
+ parameterDescriptions?: {
442
+ [parameter: string]: string;
443
+ };
444
+ docUrl?: string;
445
+ backgroundColor?: string;
446
+ textColor?: string;
447
+ seeds?: {
448
+ [parameter: string]: unknown;
449
+ };
450
+ }
451
+ interface CategoryListing {
452
+ displayName: string;
453
+ order: number;
454
+ backgroundColor: string;
455
+ textColor: string;
456
+ }
457
+ type OperatorListingMap = {
458
+ [operator: string]: OperatorListing;
459
+ };
460
+ type CategoryListingMap = {
461
+ [category in OperatorCategory]: CategoryListing;
462
+ };
463
+ type TypeSeeds = {
464
+ [type in BasicType]: unknown;
465
+ };
466
+ interface CatalogCategory extends CategoryListing {
467
+ name: OperatorCategory;
468
+ }
469
+ interface CatalogParameter extends ParameterInfo {
470
+ description?: string;
471
+ seed: unknown;
472
+ }
473
+ interface CatalogOperator extends Omit<OperatorInfo, 'parameters'> {
474
+ displayName: string;
475
+ description?: string;
476
+ docUrl?: string;
477
+ backgroundColor: string;
478
+ textColor: string;
479
+ parameters: Record<string, CatalogParameter>;
480
+ }
481
+ interface CatalogFragmentParameter extends FragmentParameter {
482
+ seed: unknown;
483
+ }
484
+ interface CatalogFragment extends Omit<FragmentInfo, 'parameters'> {
485
+ displayName: string;
486
+ docUrl?: string;
487
+ backgroundColor?: string;
488
+ textColor?: string;
489
+ parameters: Record<string, CatalogFragmentParameter>;
490
+ }
491
+ interface Catalog {
492
+ categories: CatalogCategory[];
493
+ operators: CatalogOperator[];
494
+ fragments: CatalogFragment[];
495
+ }
496
+
497
+ declare const categoryListings: CategoryListingMap;
498
+ declare const typeSeeds: TypeSeeds;
499
+ declare const operatorListings: OperatorListingMap;
500
+ declare const getCatalog: (fig: Pick<FigTree, "getOperators" | "getFragments">, ...listings: OperatorListingMap[]) => Catalog;
501
+
502
+ export { categoryListings, getCatalog, operatorListings, typeSeeds };
@@ -0,0 +1 @@
1
+ const e={logic:{displayName:"Logic & control",order:0,backgroundColor:"#632fbc",textColor:"#ffffff"},comparison:{displayName:"Comparison",order:1,backgroundColor:"#247f7c",textColor:"#ffffff"},math:{displayName:"Arithmetic & math",order:2,backgroundColor:"#2b8237",textColor:"#ffffff"},string:{displayName:"Strings",order:3,backgroundColor:"#a1660c",textColor:"#ffffff"},array:{displayName:"Arrays & iteration",order:4,backgroundColor:"#236ac7",textColor:"#ffffff"},data:{displayName:"Data & objects",order:5,backgroundColor:"#b93171",textColor:"#ffffff"},io:{displayName:"I/O",order:6,backgroundColor:"#6e7a24",textColor:"#ffffff"},other:{displayName:"Other",order:7,backgroundColor:"#606e8a",textColor:"#ffffff"}},a={any:"Replace me",string:"Replace me",number:1,integer:1,boolean:!0,array:[],object:{},null:null},r="https://github.com/CarlosNZ/fig-tree-evaluator",t={and:{displayName:"Logical AND",description:"True when every value is truthy — operands run in parallel",docUrl:r,backgroundColor:"#d6d0f0",textColor:"#26183f",seeds:{values:[!0,!0]},parameterDescriptions:{values:"Operands, judged by FigTree truthiness; null is falsy"}},or:{displayName:"Logical OR",description:"True when any value is truthy — operands run in parallel",docUrl:r,backgroundColor:"#cabfeb",textColor:"#26183f",seeds:{values:[!0,!1]},parameterDescriptions:{values:"Operands, judged by FigTree truthiness; null is falsy"}},not:{displayName:"Logical NOT (!)",description:"Negate the truthiness of a value",docUrl:r,backgroundColor:"#c0aee5",textColor:"#26183f",seeds:{value:!0},parameterDescriptions:{value:"Judged by FigTree truthiness; null is falsy, so not(null) is true"}},if:{displayName:"Conditional (?)",description:"Choose between two branches — only the chosen branch evaluates",docUrl:r,backgroundColor:"#ddd0f0",textColor:"#26183f",seeds:{condition:!0,then:"The condition is true",else:"The condition is false"},parameterDescriptions:{condition:"Judged by FigTree truthiness; null is falsy",then:"The value when the condition holds",else:"The value when it does not; omitted means null"}},match:{displayName:"Match",description:"Dispatch on a value — only the matching branch evaluates",docUrl:r,backgroundColor:"#d4bfeb",textColor:"#26183f",seeds:{value:"matchMe",branches:{matchMe:"YES",nonMatch:"NO"},default:"No match"},parameterDescriptions:{value:"Matched against branch keys by its canonical string form",branches:"A literal map of branches, or an expression computing one",default:"The branch taken when none matches; absent means failure"}},firstOf:{displayName:"First non-null",description:"The first candidate that is not null (SQL COALESCE) — later candidates never evaluate",docUrl:r,backgroundColor:"#ccaee5",textColor:"#26183f",seeds:{values:[null,"The first non-null value"]},parameterDescriptions:{values:"Candidates, tried in order; only null is skipped"}},equal:{displayName:"Equal (=)",description:"Are all the values equal? Deep, structural, key-order-insensitive; a cross-type comparison is false",docUrl:r,backgroundColor:"#d2efe9",textColor:"#183f3e",seeds:{values:["These are equal","These are equal"]},parameterDescriptions:{values:"The values compared; null is comparable (null equals null)",caseInsensitive:"Fold string operands to one case before comparing (shallow)"}},notEqual:{displayName:"Not equal (!=)",description:'Are the values NOT all equal? The exact negation of equal (never "all distinct")',docUrl:r,backgroundColor:"#c1e9e3",textColor:"#183f3e",seeds:{values:["These items","don't match"]},parameterDescriptions:{values:"The values compared; null is comparable (null equals null)",caseInsensitive:"Fold string operands to one case before comparing (shallow)"}},greaterThan:{displayName:"Greater than (>)",description:"Is the first value strictly greater than the second?",docUrl:r,backgroundColor:"#b0e3e0",textColor:"#183f3e",seeds:{values:[10,9]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},greaterThanOrEqual:{displayName:"Greater than or equal (>=)",description:"Is the first value greater than or equal to the second?",docUrl:r,backgroundColor:"#d2efef",textColor:"#183f3e",seeds:{values:[10,10]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},lessThan:{displayName:"Less than (<)",description:"Is the first value strictly less than the second?",docUrl:r,backgroundColor:"#c1e6e9",textColor:"#183f3e",seeds:{values:[9,10]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},lessThanOrEqual:{displayName:"Less than or equal (<=)",description:"Is the first value less than or equal to the second?",docUrl:r,backgroundColor:"#b0dbe3",textColor:"#183f3e",seeds:{values:[9,9]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},plus:{displayName:"Plus (+)",description:"Add numbers, concatenate strings or arrays, or shallow-merge objects — all operands must share one type",docUrl:r,backgroundColor:"#d7edd4",textColor:"#193e1e",seeds:{values:[1,2,3]},parameterDescriptions:{values:"The operands; homogeneous: all numbers, strings, arrays or objects",expect:"Pin the mode: every operand must be this type, and an empty input yields its identity",nullValueDefault:"Replaces any null operand before the addition"}},subtract:{displayName:"Subtract (-)",description:"Subtract one number from another",docUrl:r,backgroundColor:"#bfe4bc",textColor:"#193e1e",seeds:{value:10,minus:5},parameterDescriptions:{value:"The main operand",minus:"The amount subtracted from value"}},multiply:{displayName:"Multiply (*)",description:"Multiply numbers together — an empty input is 1, the empty product",docUrl:r,backgroundColor:"#b4e0b3",textColor:"#193e1e",seeds:{values:[5,5]},parameterDescriptions:{values:"The factors",nullValueDefault:"Replaces any null factor before multiplying"}},divide:{displayName:"Divide (/)",description:"Divide one number by another — true division; zero divisors fail",docUrl:r,backgroundColor:"#cceacd",textColor:"#193e1e",seeds:{value:100,by:10},parameterDescriptions:{value:"The main operand",by:"The divisor"}},modulo:{displayName:"Modulo",description:"The floored remainder: the result takes the sign of mod, so modulo(-7, 3) is 2",docUrl:r,backgroundColor:"#c3e7c6",textColor:"#193e1e",seeds:{value:10,mod:3},parameterDescriptions:{value:"The main operand",mod:"The modulus"}},power:{displayName:"Power (^)",description:"Raise a base to an exponent — overflow and complex results fail",docUrl:r,backgroundColor:"#acddb1",textColor:"#193e1e",seeds:{base:2,exponent:3},parameterDescriptions:{base:"The number to raise",exponent:"The power to raise it to"}},round:{displayName:"Round",description:"Round to a number of decimal places — ties go half away from zero; negative decimals round to tens, hundreds, …",docUrl:r,backgroundColor:"#d4edd8",textColor:"#193e1e",seeds:{value:3.14159,decimals:2},parameterDescriptions:{value:"The number to round",decimals:"Decimal places to keep; negative values round to powers of ten"}},floor:{displayName:"Round down",description:"Round down toward negative infinity",docUrl:r,backgroundColor:"#bce4c4",textColor:"#193e1e",seeds:{value:2.7},parameterDescriptions:{value:"The number to round down"}},ceil:{displayName:"Round up",description:"Round up toward positive infinity",docUrl:r,backgroundColor:"#b3e0be",textColor:"#193e1e",seeds:{value:2.3},parameterDescriptions:{value:"The number to round up"}},abs:{displayName:"Absolute value",description:"The absolute value",docUrl:r,backgroundColor:"#ccead5",textColor:"#193e1e",seeds:{value:-5},parameterDescriptions:{value:"The number"}},min:{displayName:"Minimum",description:"The smallest of the values — numbers numerically, strings in codepoint order",docUrl:r,backgroundColor:"#c3e7cf",textColor:"#193e1e",seeds:{values:[3,1,2]},parameterDescriptions:{values:"The candidates: all numbers, or all strings (codepoint order)",nullValueDefault:"Replaces any null candidate before comparing"}},max:{displayName:"Maximum",description:"The largest of the values — numbers numerically, strings in codepoint order",docUrl:r,backgroundColor:"#acddbf",textColor:"#193e1e",seeds:{values:[3,1,2]},parameterDescriptions:{values:"The candidates: all numbers, or all strings (codepoint order)",nullValueDefault:"Replaces any null candidate before comparing"}},buildString:{displayName:"String builder",description:"Render a template, filling its tokens — the result is always a string",docUrl:r,backgroundColor:"#f8d9c9",textColor:"#3f2f18",seeds:{template:"Hello {{$data.name}}"},parameterDescriptions:{template:"The text, with %N or {{name}} tokens; in a literal template, {{$data.x}} is that reference",substitutions:"An array pairs with %N tokens, an object with {{name}} tokens; the mode dispatches on which arrives",trim:"Trim whitespace from each rendered value, never from the template text",closeGaps:"A value that renders empty also takes one run of adjacent template whitespace",nullValueDefault:'Rendered in place of a null value, instead of ""'}},split:{displayName:"Split text",description:"Divide a string on a delimiter into an array of pieces — empty pieces are kept; an empty delimiter splits into code points",docUrl:r,backgroundColor:"#f5cbab",textColor:"#3f2f18",seeds:{value:"Alpha, Bravo, Charlie",delimiter:",",trim:!1},parameterDescriptions:{value:"The string to divide",delimiter:'Split on each occurrence; "" splits into code points',trim:"Trim whitespace from each piece"}},join:{displayName:"Join text",description:"Render array elements to text and concatenate them with a delimiter",docUrl:r,backgroundColor:"#f3cba0",textColor:"#3f2f18",seeds:{values:["Alpha","Bravo","Charlie"],delimiter:", "},parameterDescriptions:{values:'Elements of any type, rendered by the stringification table; a null renders "" and still occupies its slot',delimiter:"Placed between each adjacent pair — shares its contract with split",nullValueDefault:'Rendered in place of a null element, instead of ""'}},lower:{displayName:"Lower case",description:"Lowercase a string — Unicode default case mapping, locale-independent",docUrl:r,backgroundColor:"#f7e1bf",textColor:"#3f2f18",seeds:{value:"Hello World"},parameterDescriptions:{value:"The string to lowercase"}},upper:{displayName:"Upper case",description:"Uppercase a string — Unicode default case mapping, locale-independent",docUrl:r,backgroundColor:"#f6e1b4",textColor:"#3f2f18",seeds:{value:"Hello World"},parameterDescriptions:{value:"The string to uppercase"}},trim:{displayName:"Trim whitespace",description:"Strip whitespace (the JS trim set) from both ends of a string",docUrl:r,backgroundColor:"#f2dd97",textColor:"#3f2f18",seeds:{value:" Hello World "},parameterDescriptions:{value:"The string to trim"}},regex:{displayName:"Regular expression",description:"Test, extract or match a string against a regular expression",docUrl:r,backgroundColor:"#f8f1c9",textColor:"#3f2f18",seeds:{value:"test-this",pattern:"^[a-z]{4}-[a-z]{4}$",flags:"i"},parameterDescriptions:{value:"The subject string",pattern:"The regular expression source",flags:"The admitted subset: i, m, s, u",mode:"test gives a boolean, extract the first matching substring, match every one of them",noMatchDefault:"The extract answer when nothing matches — a matched empty string still passes through"}},length:{displayName:"Length",description:"An array's element count, or a string's Unicode code-point count",docUrl:r,backgroundColor:"#cde5f3",textColor:"#18293f",seeds:{value:[1,2,3,4,5]},parameterDescriptions:{value:"The array or string measured"}},map:{displayName:"Map each",description:"Transform every element of an array",docUrl:r,backgroundColor:"#bbd7ef",textColor:"#18293f",seeds:{input:[1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"Evaluated per element, with $element and $index bound"}},filter:{displayName:"Filter",description:"Keep the elements of an array whose predicate is truthy",docUrl:r,backgroundColor:"#a8c7eb",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},find:{displayName:"Find first",description:"The first element of an array whose predicate is truthy",docUrl:r,backgroundColor:"#cddcf3",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy",noMatchDefault:"The answer when nothing matches; a found null passes through unchanged"}},some:{displayName:"Any match",description:"True when any element satisfies the predicate",docUrl:r,backgroundColor:"#bbccef",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},every:{displayName:"All match",description:"True when every element satisfies the predicate",docUrl:r,backgroundColor:"#a8b9eb",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},get:{displayName:"Get data",description:"Read a path out of the evaluation data, or out of a supplied object — the dynamic face of a $data reference",docUrl:r,backgroundColor:"#f0d1e5",textColor:"#3f182a",seeds:{path:"path.to.value",from:{path:{to:{value:"Found it"}}},default:"Not found"},parameterDescriptions:{path:"Dot and bracket segments, quoted keys and the [*] projection — or an array of segments, taken verbatim",from:"The source the path reads: a value, or a bare namespace ($data, $vars, $params, $element) whose var or parameter name opens the path — replace, never merge; a null source misses every path",default:"The answer when the path is missing — a stored null passes through unchanged (firstOf replaces one); supplying it also opts out of strictDataPaths"}},buildObject:{displayName:"Build object",description:"Assemble an object from computed key/value entries — for keys known only at runtime",docUrl:r,backgroundColor:"#eac0cc",textColor:"#3f182a",seeds:{entries:[{key:"firstKey",value:"firstValue"},{key:"secondKey",value:"secondValue"}]},parameterDescriptions:{entries:'Objects with a "key" and a "value"; a null value keeps its key'}},convert:{displayName:"Convert type",description:"Convert a value to a number, string, boolean or array — strict: a failed conversion is an error, never a guess",docUrl:r,backgroundColor:"#dddfe3",textColor:"#272a30",seeds:{value:"42"},parameterDescriptions:{value:"The value to convert; null propagates except for boolean, where it is false",to:"The target type"}},http:{displayName:"HTTP request",description:"One HTTP request — GET or POST — returning the parsed JSON response",docUrl:r,backgroundColor:"#eeedd2",textColor:"#3a3f18",seeds:{url:"https://restcountries.com/v3.1/name/zealand",returnPath:"[0].name.common",timeout:5e3},parameterDescriptions:{url:"A full http(s) URL is used verbatim; anything else — including an empty string — joins http.baseEndpoint",method:"Lowercase; the mutating verbs are deliberately absent — an expression is a read",query:"Query-string pairs; a null value omits its pair, a composite one is an error",body:"The JSON payload; a whole-null body means NO body, while nulls inside one are JSON nulls",headers:"Merged over the http.headers option per key; a null value removes an inherited pair",returnPath:"Dot/bracket path or segments array applied to the response; a miss is null",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},graphQL:{displayName:"GraphQL query",description:"One GraphQL query — a POST of { query, variables } — returning the data field",docUrl:r,backgroundColor:"#e3e8c2",textColor:"#3a3f18",seeds:{query:'query getCountries {\n countries(filter: { continent: { eq: "OC" } }) {\n name\n }\n}',url:"https://countries.trevorblades.com/",returnPath:"countries[0].name",timeout:5e3},parameterDescriptions:{query:"The GraphQL document — the protocol’s own word, as sql.query is",variables:"Query variables; a null value is CARRIED as JSON null, a nullable argument being meaningful GraphQL",url:"Per-node endpoint override; unset means the graphQL.endpoint option",headers:"Merged over http.headers then graphQL.headers; a null value removes a pair",returnPath:"Dot/bracket path or segments array applied to the response; a miss is null",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},sql:{displayName:"SQL query",description:"One SQL query against the registered connection. Expressions are READS — give the connection a read-only role and run mutations host-side",docUrl:r,backgroundColor:"#d2e2b1",textColor:"#3a3f18",seeds:{query:"SELECT contact_name FROM customers LIMIT 5",timeout:5e3},parameterDescriptions:{query:"SQL text with the driver’s own placeholders — FigTree never parses SQL",values:"Bind values — positional as an array, named as an object; a null binds SQL NULL",shape:"rows: every row object; firstRow: the first; column: one column’s values; firstValue: one scalar",noRowDefault:"The answer when firstRow / firstValue find no row — never for rows / column, never on failure",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},literal:{displayName:"Literal",docUrl:r,backgroundColor:"#d5dae4",textColor:"#272a30",seeds:{value:"No content inside a literal node is evaluated"}}},o=(e,a)=>void 0!==e&&Object.hasOwn(e,a)?e[a]:void 0,s=e=>void 0!==e.backgroundColor&&void 0!==e.textColor?{backgroundColor:e.backgroundColor,textColor:e.textColor}:void 0,n=(e,r,t)=>void 0!==e.seeds&&Object.hasOwn(e.seeds,r)?e.seeds[r]:"string"==typeof t?a[t]:"literal"in t?t.literal[0]:a[t.find(e=>"null"!==e)??"null"],l=(e,a)=>{for(const[r,t]of Object.entries(a??{}))void 0!==t&&(e[r]=t)},i=(a,...r)=>({categories:Object.entries(e).map(([e,a])=>({name:e,...a})).sort((e,a)=>e.order-a.order),operators:a.getOperators().map(({name:a,parameters:i,...d})=>{const c=(e=>{const a={seeds:{},parameterDescriptions:{}};for(const n of[t,...r]){const r=o(n,e);if(void 0!==r){for(const e of["displayName","description","docUrl"]){const t=r[e];void 0!==t&&(a[e]=t)}Object.assign(a,s(r)),l(a.seeds,r.seeds),l(a.parameterDescriptions,r.parameterDescriptions)}}return a})(a),u={name:a,displayName:c.displayName??a,...d,...s(c)??s(e[d.category]),parameters:{}};void 0!==c.description&&(u.description=c.description),void 0!==c.docUrl&&(u.docUrl=c.docUrl);for(const[e,a]of Object.entries(i)){const r={...a,seed:n(c,e,a.type)},t=o(c.parameterDescriptions,e);void 0!==t&&(r.description=t),u.parameters[e]=r}return u}),fragments:a.getFragments().map(({name:e,parameters:a,...r})=>{const t=r.metadata??{},o={name:e,displayName:t.displayName??e,...r,...s(t),parameters:{}};void 0!==t.docUrl&&(o.docUrl=t.docUrl);for(const[e,r]of Object.entries(a))o.parameters[e]={...r,seed:n(t,e,r.type)};return o})});export{e as categoryListings,i as getCatalog,t as operatorListings,a as typeSeeds};