trilean 0.0.0 → 1.0.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 +21 -0
- package/README.md +634 -0
- package/dist/computed-value.cjs +71 -0
- package/dist/computed-value.d.cts +43 -0
- package/dist/computed-value.d.ts +43 -0
- package/dist/computed-value.js +65 -0
- package/dist/derived-aggregates.cjs +74 -0
- package/dist/derived-aggregates.d.cts +12 -0
- package/dist/derived-aggregates.d.ts +12 -0
- package/dist/derived-aggregates.js +70 -0
- package/dist/derived-connectives.cjs +40 -0
- package/dist/derived-connectives.d.cts +17 -0
- package/dist/derived-connectives.d.ts +17 -0
- package/dist/derived-connectives.js +31 -0
- package/dist/evaluation.cjs +39 -0
- package/dist/evaluation.d.cts +29 -0
- package/dist/evaluation.d.ts +29 -0
- package/dist/evaluation.js +35 -0
- package/dist/evaluator.cjs +482 -0
- package/dist/evaluator.d.cts +18 -0
- package/dist/evaluator.d.ts +18 -0
- package/dist/evaluator.js +479 -0
- package/dist/functions.cjs +5 -0
- package/dist/functions.d.cts +11 -0
- package/dist/functions.d.ts +11 -0
- package/dist/functions.js +4 -0
- package/dist/index.cjs +69 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +9 -0
- package/dist/json-value-B1Hjjjri.d.cts +11 -0
- package/dist/json-value-B1Hjjjri.d.ts +11 -0
- package/dist/json-value.cjs +13 -0
- package/dist/json-value.d.cts +2 -0
- package/dist/json-value.d.ts +2 -0
- package/dist/json-value.js +12 -0
- package/dist/resolvers.cjs +0 -0
- package/dist/resolvers.d.cts +28 -0
- package/dist/resolvers.d.ts +28 -0
- package/dist/resolvers.js +0 -0
- package/dist/tree.cjs +289 -0
- package/dist/tree.d.cts +368 -0
- package/dist/tree.d.ts +368 -0
- package/dist/tree.js +257 -0
- package/package.json +114 -2
- package/schemas/trilean.schema.json +1 -0
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { t as JsonValue } from "./json-value-B1Hjjjri.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/tree.d.ts
|
|
4
|
+
declare const ComparisonOperatorSchema: z.ZodEnum<{
|
|
5
|
+
gt: "gt";
|
|
6
|
+
gte: "gte";
|
|
7
|
+
lt: "lt";
|
|
8
|
+
lte: "lte";
|
|
9
|
+
eq: "eq";
|
|
10
|
+
neq: "neq";
|
|
11
|
+
}>;
|
|
12
|
+
type ComparisonOperator = z.infer<typeof ComparisonOperatorSchema>;
|
|
13
|
+
declare const TextComparisonOperatorSchema: z.ZodEnum<{
|
|
14
|
+
equals: "equals";
|
|
15
|
+
notEquals: "notEquals";
|
|
16
|
+
matches: "matches";
|
|
17
|
+
notMatches: "notMatches";
|
|
18
|
+
}>;
|
|
19
|
+
type TextComparisonOperator = z.infer<typeof TextComparisonOperatorSchema>;
|
|
20
|
+
declare const MembershipOperatorSchema: z.ZodEnum<{
|
|
21
|
+
in: "in";
|
|
22
|
+
notIn: "notIn";
|
|
23
|
+
}>;
|
|
24
|
+
type MembershipOperator = z.infer<typeof MembershipOperatorSchema>;
|
|
25
|
+
declare const ArithmeticOperatorSchema: z.ZodEnum<{
|
|
26
|
+
add: "add";
|
|
27
|
+
subtract: "subtract";
|
|
28
|
+
multiply: "multiply";
|
|
29
|
+
divide: "divide";
|
|
30
|
+
power: "power";
|
|
31
|
+
modulo: "modulo";
|
|
32
|
+
}>;
|
|
33
|
+
type ArithmeticOperator = z.infer<typeof ArithmeticOperatorSchema>;
|
|
34
|
+
declare const NotNodeSchema: z.ZodObject<{
|
|
35
|
+
kind: z.ZodLiteral<"not">;
|
|
36
|
+
operand: typeof PredicateNodeSchema;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
type NotNode = z.infer<typeof NotNodeSchema>;
|
|
39
|
+
declare const AndNodeSchema: z.ZodObject<{
|
|
40
|
+
kind: z.ZodLiteral<"and">;
|
|
41
|
+
left: typeof PredicateNodeSchema;
|
|
42
|
+
right: typeof PredicateNodeSchema;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
type AndNode = z.infer<typeof AndNodeSchema>;
|
|
45
|
+
declare const OrNodeSchema: z.ZodObject<{
|
|
46
|
+
kind: z.ZodLiteral<"or">;
|
|
47
|
+
left: typeof PredicateNodeSchema;
|
|
48
|
+
right: typeof PredicateNodeSchema;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
type OrNode = z.infer<typeof OrNodeSchema>;
|
|
51
|
+
declare const AllOfNodeSchema: z.ZodObject<{
|
|
52
|
+
kind: z.ZodLiteral<"allOf">;
|
|
53
|
+
operands: z.ZodArray<typeof PredicateNodeSchema>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
type AllOfNode = z.infer<typeof AllOfNodeSchema>;
|
|
56
|
+
declare const AnyOfNodeSchema: z.ZodObject<{
|
|
57
|
+
kind: z.ZodLiteral<"anyOf">;
|
|
58
|
+
operands: z.ZodArray<typeof PredicateNodeSchema>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
type AnyOfNode = z.infer<typeof AnyOfNodeSchema>;
|
|
61
|
+
declare const CompareNodeSchema: z.ZodObject<{
|
|
62
|
+
kind: z.ZodLiteral<"compare">;
|
|
63
|
+
op: z.ZodEnum<{
|
|
64
|
+
gt: "gt";
|
|
65
|
+
gte: "gte";
|
|
66
|
+
lt: "lt";
|
|
67
|
+
lte: "lte";
|
|
68
|
+
eq: "eq";
|
|
69
|
+
neq: "neq";
|
|
70
|
+
}>;
|
|
71
|
+
left: typeof ExpressionNodeSchema;
|
|
72
|
+
right: typeof ExpressionNodeSchema;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
type CompareNode = z.infer<typeof CompareNodeSchema>;
|
|
75
|
+
declare const TextCompareNodeSchema: z.ZodObject<{
|
|
76
|
+
kind: z.ZodLiteral<"textCompare">;
|
|
77
|
+
op: z.ZodEnum<{
|
|
78
|
+
equals: "equals";
|
|
79
|
+
notEquals: "notEquals";
|
|
80
|
+
matches: "matches";
|
|
81
|
+
notMatches: "notMatches";
|
|
82
|
+
}>;
|
|
83
|
+
left: typeof ExpressionNodeSchema;
|
|
84
|
+
right: typeof ExpressionNodeSchema;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
type TextCompareNode = z.infer<typeof TextCompareNodeSchema>;
|
|
87
|
+
declare const MemberOfNodeSchema: z.ZodObject<{
|
|
88
|
+
kind: z.ZodLiteral<"memberOf">;
|
|
89
|
+
op: z.ZodEnum<{
|
|
90
|
+
in: "in";
|
|
91
|
+
notIn: "notIn";
|
|
92
|
+
}>;
|
|
93
|
+
operand: typeof ExpressionNodeSchema;
|
|
94
|
+
candidates: z.ZodArray<typeof ExpressionNodeSchema>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
type MemberOfNode = z.infer<typeof MemberOfNodeSchema>;
|
|
97
|
+
declare const ExistsNodeSchema: z.ZodObject<{
|
|
98
|
+
kind: z.ZodLiteral<"exists">;
|
|
99
|
+
operand: typeof ExpressionNodeSchema;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
type ExistsNode = z.infer<typeof ExistsNodeSchema>;
|
|
102
|
+
declare const SomeNodeSchema: z.ZodObject<{
|
|
103
|
+
kind: z.ZodLiteral<"some">;
|
|
104
|
+
collection: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
105
|
+
item: typeof PredicateNodeSchema;
|
|
106
|
+
filter: z.ZodOptional<typeof PredicateNodeSchema>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
type SomeNode = z.infer<typeof SomeNodeSchema>;
|
|
109
|
+
declare const EveryNodeSchema: z.ZodObject<{
|
|
110
|
+
kind: z.ZodLiteral<"every">;
|
|
111
|
+
collection: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
112
|
+
item: typeof PredicateNodeSchema;
|
|
113
|
+
filter: z.ZodOptional<typeof PredicateNodeSchema>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
type EveryNode = z.infer<typeof EveryNodeSchema>;
|
|
116
|
+
declare const PredicateNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
117
|
+
kind: z.ZodLiteral<"not">;
|
|
118
|
+
operand: typeof PredicateNodeSchema;
|
|
119
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
120
|
+
kind: z.ZodLiteral<"and">;
|
|
121
|
+
left: typeof PredicateNodeSchema;
|
|
122
|
+
right: typeof PredicateNodeSchema;
|
|
123
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
124
|
+
kind: z.ZodLiteral<"or">;
|
|
125
|
+
left: typeof PredicateNodeSchema;
|
|
126
|
+
right: typeof PredicateNodeSchema;
|
|
127
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
128
|
+
kind: z.ZodLiteral<"allOf">;
|
|
129
|
+
operands: z.ZodArray<typeof PredicateNodeSchema>;
|
|
130
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
131
|
+
kind: z.ZodLiteral<"anyOf">;
|
|
132
|
+
operands: z.ZodArray<typeof PredicateNodeSchema>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
kind: z.ZodLiteral<"compare">;
|
|
135
|
+
op: z.ZodEnum<{
|
|
136
|
+
gt: "gt";
|
|
137
|
+
gte: "gte";
|
|
138
|
+
lt: "lt";
|
|
139
|
+
lte: "lte";
|
|
140
|
+
eq: "eq";
|
|
141
|
+
neq: "neq";
|
|
142
|
+
}>;
|
|
143
|
+
left: typeof ExpressionNodeSchema;
|
|
144
|
+
right: typeof ExpressionNodeSchema;
|
|
145
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
146
|
+
kind: z.ZodLiteral<"textCompare">;
|
|
147
|
+
op: z.ZodEnum<{
|
|
148
|
+
equals: "equals";
|
|
149
|
+
notEquals: "notEquals";
|
|
150
|
+
matches: "matches";
|
|
151
|
+
notMatches: "notMatches";
|
|
152
|
+
}>;
|
|
153
|
+
left: typeof ExpressionNodeSchema;
|
|
154
|
+
right: typeof ExpressionNodeSchema;
|
|
155
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
156
|
+
kind: z.ZodLiteral<"memberOf">;
|
|
157
|
+
op: z.ZodEnum<{
|
|
158
|
+
in: "in";
|
|
159
|
+
notIn: "notIn";
|
|
160
|
+
}>;
|
|
161
|
+
operand: typeof ExpressionNodeSchema;
|
|
162
|
+
candidates: z.ZodArray<typeof ExpressionNodeSchema>;
|
|
163
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
164
|
+
kind: z.ZodLiteral<"exists">;
|
|
165
|
+
operand: typeof ExpressionNodeSchema;
|
|
166
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
167
|
+
kind: z.ZodLiteral<"some">;
|
|
168
|
+
collection: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
169
|
+
item: typeof PredicateNodeSchema;
|
|
170
|
+
filter: z.ZodOptional<typeof PredicateNodeSchema>;
|
|
171
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
172
|
+
kind: z.ZodLiteral<"every">;
|
|
173
|
+
collection: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
174
|
+
item: typeof PredicateNodeSchema;
|
|
175
|
+
filter: z.ZodOptional<typeof PredicateNodeSchema>;
|
|
176
|
+
}, z.core.$strip>], "kind">;
|
|
177
|
+
type PredicateNode = z.infer<typeof PredicateNodeSchema>;
|
|
178
|
+
declare const NumberLiteralNodeSchema: z.ZodObject<{
|
|
179
|
+
kind: z.ZodLiteral<"numberLiteral">;
|
|
180
|
+
value: z.ZodNumber;
|
|
181
|
+
unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
182
|
+
}, z.core.$strip>;
|
|
183
|
+
type NumberLiteralNode = z.infer<typeof NumberLiteralNodeSchema>;
|
|
184
|
+
declare const TextLiteralNodeSchema: z.ZodObject<{
|
|
185
|
+
kind: z.ZodLiteral<"textLiteral">;
|
|
186
|
+
value: z.ZodString;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
type TextLiteralNode = z.infer<typeof TextLiteralNodeSchema>;
|
|
189
|
+
declare const InstantLiteralNodeSchema: z.ZodObject<{
|
|
190
|
+
kind: z.ZodLiteral<"instantLiteral">;
|
|
191
|
+
value: z.ZodString;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
type InstantLiteralNode = z.infer<typeof InstantLiteralNodeSchema>;
|
|
194
|
+
declare const DurationLiteralNodeSchema: z.ZodObject<{
|
|
195
|
+
kind: z.ZodLiteral<"durationLiteral">;
|
|
196
|
+
value: z.ZodNumber;
|
|
197
|
+
unit: z.ZodEnum<{
|
|
198
|
+
ms: "ms";
|
|
199
|
+
s: "s";
|
|
200
|
+
min: "min";
|
|
201
|
+
h: "h";
|
|
202
|
+
d: "d";
|
|
203
|
+
}>;
|
|
204
|
+
}, z.core.$strip>;
|
|
205
|
+
type DurationLiteralNode = z.infer<typeof DurationLiteralNodeSchema>;
|
|
206
|
+
declare const ReferenceNodeSchema: z.ZodObject<{
|
|
207
|
+
kind: z.ZodLiteral<"reference">;
|
|
208
|
+
key: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
209
|
+
unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
210
|
+
}, z.core.$strip>;
|
|
211
|
+
type ReferenceNode = z.infer<typeof ReferenceNodeSchema>;
|
|
212
|
+
declare const ArithmeticNodeSchema: z.ZodObject<{
|
|
213
|
+
kind: z.ZodLiteral<"arithmetic">;
|
|
214
|
+
op: z.ZodEnum<{
|
|
215
|
+
add: "add";
|
|
216
|
+
subtract: "subtract";
|
|
217
|
+
multiply: "multiply";
|
|
218
|
+
divide: "divide";
|
|
219
|
+
power: "power";
|
|
220
|
+
modulo: "modulo";
|
|
221
|
+
}>;
|
|
222
|
+
left: typeof ExpressionNodeSchema;
|
|
223
|
+
right: typeof ExpressionNodeSchema;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
type ArithmeticNode = z.infer<typeof ArithmeticNodeSchema>;
|
|
226
|
+
declare const NegateNodeSchema: z.ZodObject<{
|
|
227
|
+
kind: z.ZodLiteral<"negate">;
|
|
228
|
+
operand: typeof ExpressionNodeSchema;
|
|
229
|
+
}, z.core.$strip>;
|
|
230
|
+
type NegateNode = z.infer<typeof NegateNodeSchema>;
|
|
231
|
+
declare const CallNodeSchema: z.ZodObject<{
|
|
232
|
+
kind: z.ZodLiteral<"call">;
|
|
233
|
+
fn: z.ZodString;
|
|
234
|
+
args: z.ZodArray<typeof ExpressionNodeSchema>;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
type CallNode = z.infer<typeof CallNodeSchema>;
|
|
237
|
+
declare const LookupNodeSchema: z.ZodObject<{
|
|
238
|
+
kind: z.ZodLiteral<"lookup">;
|
|
239
|
+
table: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
240
|
+
keys: z.ZodArray<typeof ExpressionNodeSchema>;
|
|
241
|
+
}, z.core.$strip>;
|
|
242
|
+
type LookupNode = z.infer<typeof LookupNodeSchema>;
|
|
243
|
+
declare const ConditionalCaseSchema: z.ZodObject<{
|
|
244
|
+
when: typeof PredicateNodeSchema;
|
|
245
|
+
then: typeof ExpressionNodeSchema;
|
|
246
|
+
}, z.core.$strip>;
|
|
247
|
+
type ConditionalCase = z.infer<typeof ConditionalCaseSchema>;
|
|
248
|
+
declare const ConditionalNodeSchema: z.ZodObject<{
|
|
249
|
+
kind: z.ZodLiteral<"conditional">;
|
|
250
|
+
cases: z.ZodArray<typeof ConditionalCaseSchema>;
|
|
251
|
+
fallback: typeof ExpressionNodeSchema;
|
|
252
|
+
}, z.core.$strip>;
|
|
253
|
+
type ConditionalNode = z.infer<typeof ConditionalNodeSchema>;
|
|
254
|
+
declare const FoldCombinerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
255
|
+
mode: z.ZodLiteral<"max">;
|
|
256
|
+
item: typeof ExpressionNodeSchema;
|
|
257
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
258
|
+
mode: z.ZodLiteral<"min">;
|
|
259
|
+
item: typeof ExpressionNodeSchema;
|
|
260
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
261
|
+
mode: z.ZodLiteral<"reduce">;
|
|
262
|
+
initial: typeof ExpressionNodeSchema;
|
|
263
|
+
combine: typeof ExpressionNodeSchema;
|
|
264
|
+
}, z.core.$strip>], "mode">;
|
|
265
|
+
type FoldCombiner = z.infer<typeof FoldCombinerSchema>;
|
|
266
|
+
declare const FoldNodeSchema: z.ZodObject<{
|
|
267
|
+
kind: z.ZodLiteral<"fold">;
|
|
268
|
+
collection: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
269
|
+
filter: z.ZodOptional<typeof PredicateNodeSchema>;
|
|
270
|
+
combiner: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
271
|
+
mode: z.ZodLiteral<"max">;
|
|
272
|
+
item: typeof ExpressionNodeSchema;
|
|
273
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
274
|
+
mode: z.ZodLiteral<"min">;
|
|
275
|
+
item: typeof ExpressionNodeSchema;
|
|
276
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
277
|
+
mode: z.ZodLiteral<"reduce">;
|
|
278
|
+
initial: typeof ExpressionNodeSchema;
|
|
279
|
+
combine: typeof ExpressionNodeSchema;
|
|
280
|
+
}, z.core.$strip>], "mode">;
|
|
281
|
+
}, z.core.$strip>;
|
|
282
|
+
type FoldNode = z.infer<typeof FoldNodeSchema>;
|
|
283
|
+
declare const AccumulatorNodeSchema: z.ZodObject<{
|
|
284
|
+
kind: z.ZodLiteral<"accumulator">;
|
|
285
|
+
}, z.core.$strip>;
|
|
286
|
+
type AccumulatorNode = z.infer<typeof AccumulatorNodeSchema>;
|
|
287
|
+
declare const DelegateNodeSchema: z.ZodObject<{
|
|
288
|
+
kind: z.ZodLiteral<"delegate">;
|
|
289
|
+
system: z.ZodString;
|
|
290
|
+
payload: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
291
|
+
}, z.core.$strip>;
|
|
292
|
+
type DelegateNode = z.infer<typeof DelegateNodeSchema>;
|
|
293
|
+
declare const ExpressionNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
294
|
+
kind: z.ZodLiteral<"numberLiteral">;
|
|
295
|
+
value: z.ZodNumber;
|
|
296
|
+
unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
297
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
298
|
+
kind: z.ZodLiteral<"textLiteral">;
|
|
299
|
+
value: z.ZodString;
|
|
300
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
301
|
+
kind: z.ZodLiteral<"instantLiteral">;
|
|
302
|
+
value: z.ZodString;
|
|
303
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
304
|
+
kind: z.ZodLiteral<"durationLiteral">;
|
|
305
|
+
value: z.ZodNumber;
|
|
306
|
+
unit: z.ZodEnum<{
|
|
307
|
+
ms: "ms";
|
|
308
|
+
s: "s";
|
|
309
|
+
min: "min";
|
|
310
|
+
h: "h";
|
|
311
|
+
d: "d";
|
|
312
|
+
}>;
|
|
313
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
314
|
+
kind: z.ZodLiteral<"reference">;
|
|
315
|
+
key: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
316
|
+
unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
317
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
318
|
+
kind: z.ZodLiteral<"arithmetic">;
|
|
319
|
+
op: z.ZodEnum<{
|
|
320
|
+
add: "add";
|
|
321
|
+
subtract: "subtract";
|
|
322
|
+
multiply: "multiply";
|
|
323
|
+
divide: "divide";
|
|
324
|
+
power: "power";
|
|
325
|
+
modulo: "modulo";
|
|
326
|
+
}>;
|
|
327
|
+
left: typeof ExpressionNodeSchema;
|
|
328
|
+
right: typeof ExpressionNodeSchema;
|
|
329
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
330
|
+
kind: z.ZodLiteral<"negate">;
|
|
331
|
+
operand: typeof ExpressionNodeSchema;
|
|
332
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
333
|
+
kind: z.ZodLiteral<"call">;
|
|
334
|
+
fn: z.ZodString;
|
|
335
|
+
args: z.ZodArray<typeof ExpressionNodeSchema>;
|
|
336
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
337
|
+
kind: z.ZodLiteral<"lookup">;
|
|
338
|
+
table: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
339
|
+
keys: z.ZodArray<typeof ExpressionNodeSchema>;
|
|
340
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
341
|
+
kind: z.ZodLiteral<"conditional">;
|
|
342
|
+
cases: z.ZodArray<typeof ConditionalCaseSchema>;
|
|
343
|
+
fallback: typeof ExpressionNodeSchema;
|
|
344
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
345
|
+
kind: z.ZodLiteral<"fold">;
|
|
346
|
+
collection: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
347
|
+
filter: z.ZodOptional<typeof PredicateNodeSchema>;
|
|
348
|
+
combiner: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
349
|
+
mode: z.ZodLiteral<"max">;
|
|
350
|
+
item: typeof ExpressionNodeSchema;
|
|
351
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
352
|
+
mode: z.ZodLiteral<"min">;
|
|
353
|
+
item: typeof ExpressionNodeSchema;
|
|
354
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
355
|
+
mode: z.ZodLiteral<"reduce">;
|
|
356
|
+
initial: typeof ExpressionNodeSchema;
|
|
357
|
+
combine: typeof ExpressionNodeSchema;
|
|
358
|
+
}, z.core.$strip>], "mode">;
|
|
359
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
360
|
+
kind: z.ZodLiteral<"accumulator">;
|
|
361
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
362
|
+
kind: z.ZodLiteral<"delegate">;
|
|
363
|
+
system: z.ZodString;
|
|
364
|
+
payload: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
365
|
+
}, z.core.$strip>], "kind">;
|
|
366
|
+
type ExpressionNode = z.infer<typeof ExpressionNodeSchema>;
|
|
367
|
+
//#endregion
|
|
368
|
+
export { AccumulatorNode, AccumulatorNodeSchema, AllOfNode, AllOfNodeSchema, AndNode, AndNodeSchema, AnyOfNode, AnyOfNodeSchema, ArithmeticNode, ArithmeticNodeSchema, ArithmeticOperator, ArithmeticOperatorSchema, CallNode, CallNodeSchema, CompareNode, CompareNodeSchema, ComparisonOperator, ComparisonOperatorSchema, ConditionalCase, ConditionalCaseSchema, ConditionalNode, ConditionalNodeSchema, DelegateNode, DelegateNodeSchema, DurationLiteralNode, DurationLiteralNodeSchema, EveryNode, EveryNodeSchema, ExistsNode, ExistsNodeSchema, ExpressionNode, ExpressionNodeSchema, FoldCombiner, FoldCombinerSchema, FoldNode, FoldNodeSchema, InstantLiteralNode, InstantLiteralNodeSchema, LookupNode, LookupNodeSchema, MemberOfNode, MemberOfNodeSchema, MembershipOperator, MembershipOperatorSchema, NegateNode, NegateNodeSchema, NotNode, NotNodeSchema, NumberLiteralNode, NumberLiteralNodeSchema, OrNode, OrNodeSchema, PredicateNode, PredicateNodeSchema, ReferenceNode, ReferenceNodeSchema, SomeNode, SomeNodeSchema, TextCompareNode, TextCompareNodeSchema, TextComparisonOperator, TextComparisonOperatorSchema, TextLiteralNode, TextLiteralNodeSchema };
|
package/dist/tree.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { DurationUnitSchema, UnitSchema } from "./computed-value.js";
|
|
2
|
+
import { JsonValueSchema } from "./json-value.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/tree.ts
|
|
5
|
+
const ComparisonOperatorSchema = z.enum([
|
|
6
|
+
"gt",
|
|
7
|
+
"gte",
|
|
8
|
+
"lt",
|
|
9
|
+
"lte",
|
|
10
|
+
"eq",
|
|
11
|
+
"neq"
|
|
12
|
+
]);
|
|
13
|
+
const TextComparisonOperatorSchema = z.enum([
|
|
14
|
+
"equals",
|
|
15
|
+
"notEquals",
|
|
16
|
+
"matches",
|
|
17
|
+
"notMatches"
|
|
18
|
+
]);
|
|
19
|
+
const MembershipOperatorSchema = z.enum(["in", "notIn"]);
|
|
20
|
+
const ArithmeticOperatorSchema = z.enum([
|
|
21
|
+
"add",
|
|
22
|
+
"subtract",
|
|
23
|
+
"multiply",
|
|
24
|
+
"divide",
|
|
25
|
+
"power",
|
|
26
|
+
"modulo"
|
|
27
|
+
]);
|
|
28
|
+
const NotNodeSchema = z.object({
|
|
29
|
+
kind: z.literal("not"),
|
|
30
|
+
get operand() {
|
|
31
|
+
return PredicateNodeSchema;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const AndNodeSchema = z.object({
|
|
35
|
+
kind: z.literal("and"),
|
|
36
|
+
get left() {
|
|
37
|
+
return PredicateNodeSchema;
|
|
38
|
+
},
|
|
39
|
+
get right() {
|
|
40
|
+
return PredicateNodeSchema;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const OrNodeSchema = z.object({
|
|
44
|
+
kind: z.literal("or"),
|
|
45
|
+
get left() {
|
|
46
|
+
return PredicateNodeSchema;
|
|
47
|
+
},
|
|
48
|
+
get right() {
|
|
49
|
+
return PredicateNodeSchema;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const AllOfNodeSchema = z.object({
|
|
53
|
+
kind: z.literal("allOf"),
|
|
54
|
+
get operands() {
|
|
55
|
+
return z.array(PredicateNodeSchema);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const AnyOfNodeSchema = z.object({
|
|
59
|
+
kind: z.literal("anyOf"),
|
|
60
|
+
get operands() {
|
|
61
|
+
return z.array(PredicateNodeSchema);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const CompareNodeSchema = z.object({
|
|
65
|
+
kind: z.literal("compare"),
|
|
66
|
+
op: ComparisonOperatorSchema,
|
|
67
|
+
get left() {
|
|
68
|
+
return ExpressionNodeSchema;
|
|
69
|
+
},
|
|
70
|
+
get right() {
|
|
71
|
+
return ExpressionNodeSchema;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const TextCompareNodeSchema = z.object({
|
|
75
|
+
kind: z.literal("textCompare"),
|
|
76
|
+
op: TextComparisonOperatorSchema,
|
|
77
|
+
get left() {
|
|
78
|
+
return ExpressionNodeSchema;
|
|
79
|
+
},
|
|
80
|
+
get right() {
|
|
81
|
+
return ExpressionNodeSchema;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const MemberOfNodeSchema = z.object({
|
|
85
|
+
kind: z.literal("memberOf"),
|
|
86
|
+
op: MembershipOperatorSchema,
|
|
87
|
+
get operand() {
|
|
88
|
+
return ExpressionNodeSchema;
|
|
89
|
+
},
|
|
90
|
+
get candidates() {
|
|
91
|
+
return z.array(ExpressionNodeSchema);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const ExistsNodeSchema = z.object({
|
|
95
|
+
kind: z.literal("exists"),
|
|
96
|
+
get operand() {
|
|
97
|
+
return ExpressionNodeSchema;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const SomeNodeSchema = z.object({
|
|
101
|
+
kind: z.literal("some"),
|
|
102
|
+
collection: JsonValueSchema,
|
|
103
|
+
get item() {
|
|
104
|
+
return PredicateNodeSchema;
|
|
105
|
+
},
|
|
106
|
+
get filter() {
|
|
107
|
+
return PredicateNodeSchema.optional();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const EveryNodeSchema = z.object({
|
|
111
|
+
kind: z.literal("every"),
|
|
112
|
+
collection: JsonValueSchema,
|
|
113
|
+
get item() {
|
|
114
|
+
return PredicateNodeSchema;
|
|
115
|
+
},
|
|
116
|
+
get filter() {
|
|
117
|
+
return PredicateNodeSchema.optional();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const PredicateNodeSchema = z.discriminatedUnion("kind", [
|
|
121
|
+
NotNodeSchema,
|
|
122
|
+
AndNodeSchema,
|
|
123
|
+
OrNodeSchema,
|
|
124
|
+
AllOfNodeSchema,
|
|
125
|
+
AnyOfNodeSchema,
|
|
126
|
+
CompareNodeSchema,
|
|
127
|
+
TextCompareNodeSchema,
|
|
128
|
+
MemberOfNodeSchema,
|
|
129
|
+
ExistsNodeSchema,
|
|
130
|
+
SomeNodeSchema,
|
|
131
|
+
EveryNodeSchema
|
|
132
|
+
]);
|
|
133
|
+
const NumberLiteralNodeSchema = z.object({
|
|
134
|
+
kind: z.literal("numberLiteral"),
|
|
135
|
+
value: z.number(),
|
|
136
|
+
unit: UnitSchema.optional()
|
|
137
|
+
});
|
|
138
|
+
const TextLiteralNodeSchema = z.object({
|
|
139
|
+
kind: z.literal("textLiteral"),
|
|
140
|
+
value: z.string()
|
|
141
|
+
});
|
|
142
|
+
const InstantLiteralNodeSchema = z.object({
|
|
143
|
+
kind: z.literal("instantLiteral"),
|
|
144
|
+
/** ISO-8601 timestamp. */
|
|
145
|
+
value: z.string()
|
|
146
|
+
});
|
|
147
|
+
const DurationLiteralNodeSchema = z.object({
|
|
148
|
+
kind: z.literal("durationLiteral"),
|
|
149
|
+
value: z.number(),
|
|
150
|
+
unit: DurationUnitSchema
|
|
151
|
+
});
|
|
152
|
+
const ReferenceNodeSchema = z.object({
|
|
153
|
+
kind: z.literal("reference"),
|
|
154
|
+
key: JsonValueSchema,
|
|
155
|
+
unit: UnitSchema.optional()
|
|
156
|
+
});
|
|
157
|
+
const ArithmeticNodeSchema = z.object({
|
|
158
|
+
kind: z.literal("arithmetic"),
|
|
159
|
+
op: ArithmeticOperatorSchema,
|
|
160
|
+
get left() {
|
|
161
|
+
return ExpressionNodeSchema;
|
|
162
|
+
},
|
|
163
|
+
get right() {
|
|
164
|
+
return ExpressionNodeSchema;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
const NegateNodeSchema = z.object({
|
|
168
|
+
kind: z.literal("negate"),
|
|
169
|
+
get operand() {
|
|
170
|
+
return ExpressionNodeSchema;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
const CallNodeSchema = z.object({
|
|
174
|
+
kind: z.literal("call"),
|
|
175
|
+
fn: z.string(),
|
|
176
|
+
get args() {
|
|
177
|
+
return z.array(ExpressionNodeSchema);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
const LookupNodeSchema = z.object({
|
|
181
|
+
kind: z.literal("lookup"),
|
|
182
|
+
table: JsonValueSchema,
|
|
183
|
+
get keys() {
|
|
184
|
+
return z.array(ExpressionNodeSchema);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const ConditionalCaseSchema = z.object({
|
|
188
|
+
get when() {
|
|
189
|
+
return PredicateNodeSchema;
|
|
190
|
+
},
|
|
191
|
+
get then() {
|
|
192
|
+
return ExpressionNodeSchema;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const ConditionalNodeSchema = z.object({
|
|
196
|
+
kind: z.literal("conditional"),
|
|
197
|
+
get cases() {
|
|
198
|
+
return z.array(ConditionalCaseSchema);
|
|
199
|
+
},
|
|
200
|
+
get fallback() {
|
|
201
|
+
return ExpressionNodeSchema;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
const FoldCombinerSchema = z.discriminatedUnion("mode", [
|
|
205
|
+
z.object({
|
|
206
|
+
mode: z.literal("max"),
|
|
207
|
+
get item() {
|
|
208
|
+
return ExpressionNodeSchema;
|
|
209
|
+
}
|
|
210
|
+
}),
|
|
211
|
+
z.object({
|
|
212
|
+
mode: z.literal("min"),
|
|
213
|
+
get item() {
|
|
214
|
+
return ExpressionNodeSchema;
|
|
215
|
+
}
|
|
216
|
+
}),
|
|
217
|
+
z.object({
|
|
218
|
+
mode: z.literal("reduce"),
|
|
219
|
+
get initial() {
|
|
220
|
+
return ExpressionNodeSchema;
|
|
221
|
+
},
|
|
222
|
+
get combine() {
|
|
223
|
+
return ExpressionNodeSchema;
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
]);
|
|
227
|
+
const FoldNodeSchema = z.object({
|
|
228
|
+
kind: z.literal("fold"),
|
|
229
|
+
collection: JsonValueSchema,
|
|
230
|
+
get filter() {
|
|
231
|
+
return PredicateNodeSchema.optional();
|
|
232
|
+
},
|
|
233
|
+
combiner: FoldCombinerSchema
|
|
234
|
+
});
|
|
235
|
+
const AccumulatorNodeSchema = z.object({ kind: z.literal("accumulator") });
|
|
236
|
+
const DelegateNodeSchema = z.object({
|
|
237
|
+
kind: z.literal("delegate"),
|
|
238
|
+
system: z.string(),
|
|
239
|
+
payload: JsonValueSchema
|
|
240
|
+
});
|
|
241
|
+
const ExpressionNodeSchema = z.discriminatedUnion("kind", [
|
|
242
|
+
NumberLiteralNodeSchema,
|
|
243
|
+
TextLiteralNodeSchema,
|
|
244
|
+
InstantLiteralNodeSchema,
|
|
245
|
+
DurationLiteralNodeSchema,
|
|
246
|
+
ReferenceNodeSchema,
|
|
247
|
+
ArithmeticNodeSchema,
|
|
248
|
+
NegateNodeSchema,
|
|
249
|
+
CallNodeSchema,
|
|
250
|
+
LookupNodeSchema,
|
|
251
|
+
ConditionalNodeSchema,
|
|
252
|
+
FoldNodeSchema,
|
|
253
|
+
AccumulatorNodeSchema,
|
|
254
|
+
DelegateNodeSchema
|
|
255
|
+
]);
|
|
256
|
+
//#endregion
|
|
257
|
+
export { AccumulatorNodeSchema, AllOfNodeSchema, AndNodeSchema, AnyOfNodeSchema, ArithmeticNodeSchema, ArithmeticOperatorSchema, CallNodeSchema, CompareNodeSchema, ComparisonOperatorSchema, ConditionalCaseSchema, ConditionalNodeSchema, DelegateNodeSchema, DurationLiteralNodeSchema, EveryNodeSchema, ExistsNodeSchema, ExpressionNodeSchema, FoldCombinerSchema, FoldNodeSchema, InstantLiteralNodeSchema, LookupNodeSchema, MemberOfNodeSchema, MembershipOperatorSchema, NegateNodeSchema, NotNodeSchema, NumberLiteralNodeSchema, OrNodeSchema, PredicateNodeSchema, ReferenceNodeSchema, SomeNodeSchema, TextCompareNodeSchema, TextComparisonOperatorSchema, TextLiteralNodeSchema };
|