trilean 1.1.0 → 1.2.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/dist/tree.d.cts CHANGED
@@ -200,6 +200,11 @@ declare const TextLiteralNodeSchema: z.ZodObject<{
200
200
  value: z.ZodString;
201
201
  }, z.core.$strip>;
202
202
  type TextLiteralNode = z.infer<typeof TextLiteralNodeSchema>;
203
+ declare const BooleanLiteralNodeSchema: z.ZodObject<{
204
+ kind: z.ZodLiteral<"booleanLiteral">;
205
+ value: z.ZodBoolean;
206
+ }, z.core.$strip>;
207
+ type BooleanLiteralNode = z.infer<typeof BooleanLiteralNodeSchema>;
203
208
  declare const InstantLiteralNodeSchema: z.ZodObject<{
204
209
  kind: z.ZodLiteral<"instantLiteral">;
205
210
  value: z.ZodString;
@@ -217,6 +222,38 @@ declare const DurationLiteralNodeSchema: z.ZodObject<{
217
222
  }>;
218
223
  }, z.core.$strip>;
219
224
  type DurationLiteralNode = z.infer<typeof DurationLiteralNodeSchema>;
225
+ /**
226
+ * The wire-format literal accepts either of the two authoring forms real-world complex data arrives in, discriminated structurally rather than by a `form` tag: rectangular (`re`/`im`), matching the `complex` computed-value kind's own single canonical representation exactly (see the "Complex values" section of README.md), or polar (`magnitude`/`phase`, in radians), for the domains that reason that way natively and would otherwise have to hand-compute the conversion before ever constructing the tree. `strictObject` on both members is what makes the two forms mutually exclusive on the wire -- a plain `object` would silently strip an unrecognised field rather than reject a payload that mixes both.
227
+ *
228
+ * The evaluator normalises whichever form was authored into the single rectangular `ComputedValue` immediately on evaluation (see the `complexLiteral` case in evaluator.ts), so nothing downstream of that -- arithmetic, `compare`, `memberOf`, `negate` -- ever sees a polar value; they keep consuming the one canonical `complex` shape unchanged.
229
+ */
230
+ declare const ComplexRectangularLiteralNodeSchema: z.ZodObject<{
231
+ kind: z.ZodLiteral<"complexLiteral">;
232
+ re: z.ZodNumber;
233
+ im: z.ZodNumber;
234
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
235
+ }, z.core.$strict>;
236
+ type ComplexRectangularLiteralNode = z.infer<typeof ComplexRectangularLiteralNodeSchema>;
237
+ declare const ComplexPolarLiteralNodeSchema: z.ZodObject<{
238
+ kind: z.ZodLiteral<"complexLiteral">;
239
+ magnitude: z.ZodNumber;
240
+ phase: z.ZodNumber;
241
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
242
+ }, z.core.$strict>;
243
+ type ComplexPolarLiteralNode = z.infer<typeof ComplexPolarLiteralNodeSchema>;
244
+ /** Both literal forms share the one literal `kind: "complexLiteral"` value, which is exactly why this is a plain `z.union` rather than a `z.discriminatedUnion` -- `z.discriminatedUnion` requires a unique discriminant literal per member and throws ("Duplicate discriminator value") the moment two members share one. `ExpressionNodeSchema` below folds this plain union in alongside its own discriminated union of every other kind, rather than trying to host it as a normal member. */
245
+ declare const ComplexLiteralNodeSchema: z.ZodUnion<readonly [z.ZodObject<{
246
+ kind: z.ZodLiteral<"complexLiteral">;
247
+ re: z.ZodNumber;
248
+ im: z.ZodNumber;
249
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
250
+ }, z.core.$strict>, z.ZodObject<{
251
+ kind: z.ZodLiteral<"complexLiteral">;
252
+ magnitude: z.ZodNumber;
253
+ phase: z.ZodNumber;
254
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
255
+ }, z.core.$strict>]>;
256
+ type ComplexLiteralNode = z.infer<typeof ComplexLiteralNodeSchema>;
220
257
  declare const ReferenceNodeSchema: z.ZodObject<{
221
258
  kind: z.ZodLiteral<"reference">;
222
259
  key: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
@@ -308,13 +345,16 @@ declare const DelegateNodeSchema: z.ZodObject<{
308
345
  payload: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
309
346
  }, z.core.$strip>;
310
347
  type DelegateNode = z.infer<typeof DelegateNodeSchema>;
311
- declare const ExpressionNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
348
+ declare const ExpressionNodeSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
312
349
  kind: z.ZodLiteral<"numberLiteral">;
313
350
  value: z.ZodNumber;
314
351
  unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
315
352
  }, z.core.$strip>, z.ZodObject<{
316
353
  kind: z.ZodLiteral<"textLiteral">;
317
354
  value: z.ZodString;
355
+ }, z.core.$strip>, z.ZodObject<{
356
+ kind: z.ZodLiteral<"booleanLiteral">;
357
+ value: z.ZodBoolean;
318
358
  }, z.core.$strip>, z.ZodObject<{
319
359
  kind: z.ZodLiteral<"instantLiteral">;
320
360
  value: z.ZodString;
@@ -387,7 +427,17 @@ declare const ExpressionNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
387
427
  }, z.core.$strip>, z.ZodObject<{
388
428
  kind: z.ZodLiteral<"treeReference">;
389
429
  key: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
390
- }, z.core.$strip>], "kind">;
430
+ }, z.core.$strip>], "kind">, z.ZodUnion<readonly [z.ZodObject<{
431
+ kind: z.ZodLiteral<"complexLiteral">;
432
+ re: z.ZodNumber;
433
+ im: z.ZodNumber;
434
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
435
+ }, z.core.$strict>, z.ZodObject<{
436
+ kind: z.ZodLiteral<"complexLiteral">;
437
+ magnitude: z.ZodNumber;
438
+ phase: z.ZodNumber;
439
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
440
+ }, z.core.$strict>]>]>;
391
441
  type ExpressionNode = z.infer<typeof ExpressionNodeSchema>;
392
442
  //#endregion
393
- 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, HitPolicy, HitPolicySchema, 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, TreeReferenceNode, TreeReferenceNodeSchema };
443
+ export { AccumulatorNode, AccumulatorNodeSchema, AllOfNode, AllOfNodeSchema, AndNode, AndNodeSchema, AnyOfNode, AnyOfNodeSchema, ArithmeticNode, ArithmeticNodeSchema, ArithmeticOperator, ArithmeticOperatorSchema, BooleanLiteralNode, BooleanLiteralNodeSchema, CallNode, CallNodeSchema, CompareNode, CompareNodeSchema, ComparisonOperator, ComparisonOperatorSchema, ComplexLiteralNode, ComplexLiteralNodeSchema, ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, ConditionalCase, ConditionalCaseSchema, ConditionalNode, ConditionalNodeSchema, DelegateNode, DelegateNodeSchema, DurationLiteralNode, DurationLiteralNodeSchema, EveryNode, EveryNodeSchema, ExistsNode, ExistsNodeSchema, ExpressionNode, ExpressionNodeSchema, FoldCombiner, FoldCombinerSchema, FoldNode, FoldNodeSchema, HitPolicy, HitPolicySchema, 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, TreeReferenceNode, TreeReferenceNodeSchema };
package/dist/tree.d.ts CHANGED
@@ -200,6 +200,11 @@ declare const TextLiteralNodeSchema: z.ZodObject<{
200
200
  value: z.ZodString;
201
201
  }, z.core.$strip>;
202
202
  type TextLiteralNode = z.infer<typeof TextLiteralNodeSchema>;
203
+ declare const BooleanLiteralNodeSchema: z.ZodObject<{
204
+ kind: z.ZodLiteral<"booleanLiteral">;
205
+ value: z.ZodBoolean;
206
+ }, z.core.$strip>;
207
+ type BooleanLiteralNode = z.infer<typeof BooleanLiteralNodeSchema>;
203
208
  declare const InstantLiteralNodeSchema: z.ZodObject<{
204
209
  kind: z.ZodLiteral<"instantLiteral">;
205
210
  value: z.ZodString;
@@ -217,6 +222,38 @@ declare const DurationLiteralNodeSchema: z.ZodObject<{
217
222
  }>;
218
223
  }, z.core.$strip>;
219
224
  type DurationLiteralNode = z.infer<typeof DurationLiteralNodeSchema>;
225
+ /**
226
+ * The wire-format literal accepts either of the two authoring forms real-world complex data arrives in, discriminated structurally rather than by a `form` tag: rectangular (`re`/`im`), matching the `complex` computed-value kind's own single canonical representation exactly (see the "Complex values" section of README.md), or polar (`magnitude`/`phase`, in radians), for the domains that reason that way natively and would otherwise have to hand-compute the conversion before ever constructing the tree. `strictObject` on both members is what makes the two forms mutually exclusive on the wire -- a plain `object` would silently strip an unrecognised field rather than reject a payload that mixes both.
227
+ *
228
+ * The evaluator normalises whichever form was authored into the single rectangular `ComputedValue` immediately on evaluation (see the `complexLiteral` case in evaluator.ts), so nothing downstream of that -- arithmetic, `compare`, `memberOf`, `negate` -- ever sees a polar value; they keep consuming the one canonical `complex` shape unchanged.
229
+ */
230
+ declare const ComplexRectangularLiteralNodeSchema: z.ZodObject<{
231
+ kind: z.ZodLiteral<"complexLiteral">;
232
+ re: z.ZodNumber;
233
+ im: z.ZodNumber;
234
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
235
+ }, z.core.$strict>;
236
+ type ComplexRectangularLiteralNode = z.infer<typeof ComplexRectangularLiteralNodeSchema>;
237
+ declare const ComplexPolarLiteralNodeSchema: z.ZodObject<{
238
+ kind: z.ZodLiteral<"complexLiteral">;
239
+ magnitude: z.ZodNumber;
240
+ phase: z.ZodNumber;
241
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
242
+ }, z.core.$strict>;
243
+ type ComplexPolarLiteralNode = z.infer<typeof ComplexPolarLiteralNodeSchema>;
244
+ /** Both literal forms share the one literal `kind: "complexLiteral"` value, which is exactly why this is a plain `z.union` rather than a `z.discriminatedUnion` -- `z.discriminatedUnion` requires a unique discriminant literal per member and throws ("Duplicate discriminator value") the moment two members share one. `ExpressionNodeSchema` below folds this plain union in alongside its own discriminated union of every other kind, rather than trying to host it as a normal member. */
245
+ declare const ComplexLiteralNodeSchema: z.ZodUnion<readonly [z.ZodObject<{
246
+ kind: z.ZodLiteral<"complexLiteral">;
247
+ re: z.ZodNumber;
248
+ im: z.ZodNumber;
249
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
250
+ }, z.core.$strict>, z.ZodObject<{
251
+ kind: z.ZodLiteral<"complexLiteral">;
252
+ magnitude: z.ZodNumber;
253
+ phase: z.ZodNumber;
254
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
255
+ }, z.core.$strict>]>;
256
+ type ComplexLiteralNode = z.infer<typeof ComplexLiteralNodeSchema>;
220
257
  declare const ReferenceNodeSchema: z.ZodObject<{
221
258
  kind: z.ZodLiteral<"reference">;
222
259
  key: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
@@ -308,13 +345,16 @@ declare const DelegateNodeSchema: z.ZodObject<{
308
345
  payload: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
309
346
  }, z.core.$strip>;
310
347
  type DelegateNode = z.infer<typeof DelegateNodeSchema>;
311
- declare const ExpressionNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
348
+ declare const ExpressionNodeSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
312
349
  kind: z.ZodLiteral<"numberLiteral">;
313
350
  value: z.ZodNumber;
314
351
  unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
315
352
  }, z.core.$strip>, z.ZodObject<{
316
353
  kind: z.ZodLiteral<"textLiteral">;
317
354
  value: z.ZodString;
355
+ }, z.core.$strip>, z.ZodObject<{
356
+ kind: z.ZodLiteral<"booleanLiteral">;
357
+ value: z.ZodBoolean;
318
358
  }, z.core.$strip>, z.ZodObject<{
319
359
  kind: z.ZodLiteral<"instantLiteral">;
320
360
  value: z.ZodString;
@@ -387,7 +427,17 @@ declare const ExpressionNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
387
427
  }, z.core.$strip>, z.ZodObject<{
388
428
  kind: z.ZodLiteral<"treeReference">;
389
429
  key: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
390
- }, z.core.$strip>], "kind">;
430
+ }, z.core.$strip>], "kind">, z.ZodUnion<readonly [z.ZodObject<{
431
+ kind: z.ZodLiteral<"complexLiteral">;
432
+ re: z.ZodNumber;
433
+ im: z.ZodNumber;
434
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
435
+ }, z.core.$strict>, z.ZodObject<{
436
+ kind: z.ZodLiteral<"complexLiteral">;
437
+ magnitude: z.ZodNumber;
438
+ phase: z.ZodNumber;
439
+ unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
440
+ }, z.core.$strict>]>]>;
391
441
  type ExpressionNode = z.infer<typeof ExpressionNodeSchema>;
392
442
  //#endregion
393
- 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, HitPolicy, HitPolicySchema, 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, TreeReferenceNode, TreeReferenceNodeSchema };
443
+ export { AccumulatorNode, AccumulatorNodeSchema, AllOfNode, AllOfNodeSchema, AndNode, AndNodeSchema, AnyOfNode, AnyOfNodeSchema, ArithmeticNode, ArithmeticNodeSchema, ArithmeticOperator, ArithmeticOperatorSchema, BooleanLiteralNode, BooleanLiteralNodeSchema, CallNode, CallNodeSchema, CompareNode, CompareNodeSchema, ComparisonOperator, ComparisonOperatorSchema, ComplexLiteralNode, ComplexLiteralNodeSchema, ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, ConditionalCase, ConditionalCaseSchema, ConditionalNode, ConditionalNodeSchema, DelegateNode, DelegateNodeSchema, DurationLiteralNode, DurationLiteralNodeSchema, EveryNode, EveryNodeSchema, ExistsNode, ExistsNodeSchema, ExpressionNode, ExpressionNodeSchema, FoldCombiner, FoldCombinerSchema, FoldNode, FoldNodeSchema, HitPolicy, HitPolicySchema, 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, TreeReferenceNode, TreeReferenceNodeSchema };
package/dist/tree.js CHANGED
@@ -146,6 +146,10 @@ const TextLiteralNodeSchema = z.object({
146
146
  kind: z.literal("textLiteral"),
147
147
  value: z.string()
148
148
  });
149
+ const BooleanLiteralNodeSchema = z.object({
150
+ kind: z.literal("booleanLiteral"),
151
+ value: z.boolean()
152
+ });
149
153
  const InstantLiteralNodeSchema = z.object({
150
154
  kind: z.literal("instantLiteral"),
151
155
  /** ISO-8601 timestamp. */
@@ -156,6 +160,25 @@ const DurationLiteralNodeSchema = z.object({
156
160
  value: z.number(),
157
161
  unit: DurationUnitSchema
158
162
  });
163
+ /**
164
+ * The wire-format literal accepts either of the two authoring forms real-world complex data arrives in, discriminated structurally rather than by a `form` tag: rectangular (`re`/`im`), matching the `complex` computed-value kind's own single canonical representation exactly (see the "Complex values" section of README.md), or polar (`magnitude`/`phase`, in radians), for the domains that reason that way natively and would otherwise have to hand-compute the conversion before ever constructing the tree. `strictObject` on both members is what makes the two forms mutually exclusive on the wire -- a plain `object` would silently strip an unrecognised field rather than reject a payload that mixes both.
165
+ *
166
+ * The evaluator normalises whichever form was authored into the single rectangular `ComputedValue` immediately on evaluation (see the `complexLiteral` case in evaluator.ts), so nothing downstream of that -- arithmetic, `compare`, `memberOf`, `negate` -- ever sees a polar value; they keep consuming the one canonical `complex` shape unchanged.
167
+ */
168
+ const ComplexRectangularLiteralNodeSchema = z.strictObject({
169
+ kind: z.literal("complexLiteral"),
170
+ re: z.number(),
171
+ im: z.number(),
172
+ unit: UnitSchema.optional()
173
+ });
174
+ const ComplexPolarLiteralNodeSchema = z.strictObject({
175
+ kind: z.literal("complexLiteral"),
176
+ magnitude: z.number(),
177
+ phase: z.number(),
178
+ unit: UnitSchema.optional()
179
+ });
180
+ /** Both literal forms share the one literal `kind: "complexLiteral"` value, which is exactly why this is a plain `z.union` rather than a `z.discriminatedUnion` -- `z.discriminatedUnion` requires a unique discriminant literal per member and throws ("Duplicate discriminator value") the moment two members share one. `ExpressionNodeSchema` below folds this plain union in alongside its own discriminated union of every other kind, rather than trying to host it as a normal member. */
181
+ const ComplexLiteralNodeSchema = z.union([ComplexRectangularLiteralNodeSchema, ComplexPolarLiteralNodeSchema]);
159
182
  const ReferenceNodeSchema = z.object({
160
183
  kind: z.literal("reference"),
161
184
  key: JsonValueSchema,
@@ -247,9 +270,11 @@ const DelegateNodeSchema = z.object({
247
270
  system: z.string(),
248
271
  payload: JsonValueSchema
249
272
  });
250
- const ExpressionNodeSchema = z.discriminatedUnion("kind", [
273
+ /** Every expression node kind except `complexLiteral`, which cannot be a member of this same discriminated union alongside its own two forms (see `ComplexLiteralNodeSchema` above) -- folded back in below via a plain `z.union` rather than `z.discriminatedUnion`. */
274
+ const CoreExpressionNodeSchema = z.discriminatedUnion("kind", [
251
275
  NumberLiteralNodeSchema,
252
276
  TextLiteralNodeSchema,
277
+ BooleanLiteralNodeSchema,
253
278
  InstantLiteralNodeSchema,
254
279
  DurationLiteralNodeSchema,
255
280
  ReferenceNodeSchema,
@@ -263,5 +288,6 @@ const ExpressionNodeSchema = z.discriminatedUnion("kind", [
263
288
  DelegateNodeSchema,
264
289
  TreeReferenceNodeSchema
265
290
  ]);
291
+ const ExpressionNodeSchema = z.union([CoreExpressionNodeSchema, ComplexLiteralNodeSchema]);
266
292
  //#endregion
267
- export { AccumulatorNodeSchema, AllOfNodeSchema, AndNodeSchema, AnyOfNodeSchema, ArithmeticNodeSchema, ArithmeticOperatorSchema, CallNodeSchema, CompareNodeSchema, ComparisonOperatorSchema, ConditionalCaseSchema, ConditionalNodeSchema, DelegateNodeSchema, DurationLiteralNodeSchema, EveryNodeSchema, ExistsNodeSchema, ExpressionNodeSchema, FoldCombinerSchema, FoldNodeSchema, HitPolicySchema, InstantLiteralNodeSchema, LookupNodeSchema, MemberOfNodeSchema, MembershipOperatorSchema, NegateNodeSchema, NotNodeSchema, NumberLiteralNodeSchema, OrNodeSchema, PredicateNodeSchema, ReferenceNodeSchema, SomeNodeSchema, TextCompareNodeSchema, TextComparisonOperatorSchema, TextLiteralNodeSchema, TreeReferenceNodeSchema };
293
+ export { AccumulatorNodeSchema, AllOfNodeSchema, AndNodeSchema, AnyOfNodeSchema, ArithmeticNodeSchema, ArithmeticOperatorSchema, BooleanLiteralNodeSchema, CallNodeSchema, CompareNodeSchema, ComparisonOperatorSchema, ComplexLiteralNodeSchema, ComplexPolarLiteralNodeSchema, ComplexRectangularLiteralNodeSchema, ConditionalCaseSchema, ConditionalNodeSchema, DelegateNodeSchema, DurationLiteralNodeSchema, EveryNodeSchema, ExistsNodeSchema, ExpressionNodeSchema, FoldCombinerSchema, FoldNodeSchema, HitPolicySchema, InstantLiteralNodeSchema, LookupNodeSchema, MemberOfNodeSchema, MembershipOperatorSchema, NegateNodeSchema, NotNodeSchema, NumberLiteralNodeSchema, OrNodeSchema, PredicateNodeSchema, ReferenceNodeSchema, SomeNodeSchema, TextCompareNodeSchema, TextComparisonOperatorSchema, TextLiteralNodeSchema, TreeReferenceNodeSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trilean",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Three-valued predicate and expression evaluation trees, stored as JSON and evaluated against injected resolvers, for domain logic — business rules, eligibility checks, formulas, search filters, and more — that needs to be data instead of code.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1 +1 @@
1
- {"$defs":{"ExpressionNode":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"const":"numberLiteral","type":"string"},"unit":{"additionalProperties":{"type":"number"},"propertyNames":{"type":"string"},"type":"object"},"value":{"type":"number"}},"required":["kind","value"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"textLiteral","type":"string"},"value":{"type":"string"}},"required":["kind","value"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"instantLiteral","type":"string"},"value":{"type":"string"}},"required":["kind","value"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"durationLiteral","type":"string"},"unit":{"enum":["ms","s","min","h","d"],"type":"string"},"value":{"type":"number"}},"required":["kind","value","unit"],"type":"object"},{"additionalProperties":false,"properties":{"key":{"$ref":"#/$defs/schema0"},"kind":{"const":"reference","type":"string"},"unit":{"additionalProperties":{"type":"number"},"propertyNames":{"type":"string"},"type":"object"}},"required":["kind","key"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"arithmetic","type":"string"},"left":{"$ref":"#/$defs/ExpressionNode"},"op":{"enum":["add","subtract","multiply","divide","power","modulo"],"type":"string"},"right":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","op","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"negate","type":"string"},"operand":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","operand"],"type":"object"},{"additionalProperties":false,"properties":{"args":{"items":{"$ref":"#/$defs/ExpressionNode"},"type":"array"},"fn":{"type":"string"},"kind":{"const":"call","type":"string"}},"required":["kind","fn","args"],"type":"object"},{"additionalProperties":false,"properties":{"keys":{"items":{"$ref":"#/$defs/ExpressionNode"},"type":"array"},"kind":{"const":"lookup","type":"string"},"table":{"$ref":"#/$defs/schema0"}},"required":["kind","table","keys"],"type":"object"},{"additionalProperties":false,"properties":{"cases":{"items":{"additionalProperties":false,"properties":{"then":{"$ref":"#/$defs/ExpressionNode"},"when":{"$ref":"#/$defs/PredicateNode"}},"required":["when","then"],"type":"object"},"type":"array"},"fallback":{"$ref":"#/$defs/ExpressionNode"},"hitPolicy":{"enum":["first","unique"],"type":"string"},"kind":{"const":"conditional","type":"string"}},"required":["kind","cases","fallback"],"type":"object"},{"additionalProperties":false,"properties":{"collection":{"$ref":"#/$defs/schema0"},"combiner":{"oneOf":[{"additionalProperties":false,"properties":{"item":{"$ref":"#/$defs/ExpressionNode"},"mode":{"const":"max","type":"string"}},"required":["mode","item"],"type":"object"},{"additionalProperties":false,"properties":{"item":{"$ref":"#/$defs/ExpressionNode"},"mode":{"const":"min","type":"string"}},"required":["mode","item"],"type":"object"},{"additionalProperties":false,"properties":{"combine":{"$ref":"#/$defs/ExpressionNode"},"initial":{"$ref":"#/$defs/ExpressionNode"},"mode":{"const":"reduce","type":"string"}},"required":["mode","initial","combine"],"type":"object"}]},"filter":{"$ref":"#/$defs/PredicateNode"},"kind":{"const":"fold","type":"string"}},"required":["kind","collection","combiner"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"accumulator","type":"string"}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"delegate","type":"string"},"payload":{"$ref":"#/$defs/schema0"},"system":{"type":"string"}},"required":["kind","system","payload"],"type":"object"},{"additionalProperties":false,"properties":{"key":{"$ref":"#/$defs/schema0"},"kind":{"const":"treeReference","type":"string"}},"required":["kind","key"],"type":"object"}]},"PredicateNode":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"const":"not","type":"string"},"operand":{"$ref":"#/$defs/PredicateNode"}},"required":["kind","operand"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"and","type":"string"},"left":{"$ref":"#/$defs/PredicateNode"},"right":{"$ref":"#/$defs/PredicateNode"}},"required":["kind","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"or","type":"string"},"left":{"$ref":"#/$defs/PredicateNode"},"right":{"$ref":"#/$defs/PredicateNode"}},"required":["kind","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"allOf","type":"string"},"operands":{"items":{"$ref":"#/$defs/PredicateNode"},"type":"array"}},"required":["kind","operands"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"anyOf","type":"string"},"operands":{"items":{"$ref":"#/$defs/PredicateNode"},"type":"array"}},"required":["kind","operands"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"compare","type":"string"},"left":{"$ref":"#/$defs/ExpressionNode"},"op":{"enum":["gt","gte","lt","lte","eq","neq"],"type":"string"},"right":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","op","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"textCompare","type":"string"},"left":{"$ref":"#/$defs/ExpressionNode"},"op":{"enum":["equals","notEquals","matches","notMatches"],"type":"string"},"right":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","op","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"candidates":{"items":{"$ref":"#/$defs/ExpressionNode"},"type":"array"},"kind":{"const":"memberOf","type":"string"},"op":{"enum":["in","notIn"],"type":"string"},"operand":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","op","operand","candidates"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"exists","type":"string"},"operand":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","operand"],"type":"object"},{"additionalProperties":false,"properties":{"collection":{"$ref":"#/$defs/schema0"},"filter":{"$ref":"#/$defs/PredicateNode"},"item":{"$ref":"#/$defs/PredicateNode"},"kind":{"const":"some","type":"string"}},"required":["kind","collection","item"],"type":"object"},{"additionalProperties":false,"properties":{"collection":{"$ref":"#/$defs/schema0"},"filter":{"$ref":"#/$defs/PredicateNode"},"item":{"$ref":"#/$defs/PredicateNode"},"kind":{"const":"every","type":"string"}},"required":["kind","collection","item"],"type":"object"},{"additionalProperties":false,"properties":{"key":{"$ref":"#/$defs/schema0"},"kind":{"const":"treeReference","type":"string"}},"required":["kind","key"],"type":"object"}]},"schema0":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"null"},{"items":{"$ref":"#/$defs/schema0"},"type":"array"},{"additionalProperties":{"$ref":"#/$defs/schema0"},"propertyNames":{"type":"string"},"type":"object"}]}},"$id":"https://cdn.jsdelivr.net/npm/trilean@1.1.0/schemas/trilean.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","oneOf":[{"$ref":"#/$defs/PredicateNode"},{"$ref":"#/$defs/ExpressionNode"}]}
1
+ {"$defs":{"ExpressionNode":{"anyOf":[{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"const":"numberLiteral","type":"string"},"unit":{"additionalProperties":{"type":"number"},"propertyNames":{"type":"string"},"type":"object"},"value":{"type":"number"}},"required":["kind","value"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"textLiteral","type":"string"},"value":{"type":"string"}},"required":["kind","value"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"booleanLiteral","type":"string"},"value":{"type":"boolean"}},"required":["kind","value"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"instantLiteral","type":"string"},"value":{"type":"string"}},"required":["kind","value"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"durationLiteral","type":"string"},"unit":{"enum":["ms","s","min","h","d"],"type":"string"},"value":{"type":"number"}},"required":["kind","value","unit"],"type":"object"},{"additionalProperties":false,"properties":{"key":{"$ref":"#/$defs/schema0"},"kind":{"const":"reference","type":"string"},"unit":{"additionalProperties":{"type":"number"},"propertyNames":{"type":"string"},"type":"object"}},"required":["kind","key"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"arithmetic","type":"string"},"left":{"$ref":"#/$defs/ExpressionNode"},"op":{"enum":["add","subtract","multiply","divide","power","modulo"],"type":"string"},"right":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","op","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"negate","type":"string"},"operand":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","operand"],"type":"object"},{"additionalProperties":false,"properties":{"args":{"items":{"$ref":"#/$defs/ExpressionNode"},"type":"array"},"fn":{"type":"string"},"kind":{"const":"call","type":"string"}},"required":["kind","fn","args"],"type":"object"},{"additionalProperties":false,"properties":{"keys":{"items":{"$ref":"#/$defs/ExpressionNode"},"type":"array"},"kind":{"const":"lookup","type":"string"},"table":{"$ref":"#/$defs/schema0"}},"required":["kind","table","keys"],"type":"object"},{"additionalProperties":false,"properties":{"cases":{"items":{"additionalProperties":false,"properties":{"then":{"$ref":"#/$defs/ExpressionNode"},"when":{"$ref":"#/$defs/PredicateNode"}},"required":["when","then"],"type":"object"},"type":"array"},"fallback":{"$ref":"#/$defs/ExpressionNode"},"hitPolicy":{"enum":["first","unique"],"type":"string"},"kind":{"const":"conditional","type":"string"}},"required":["kind","cases","fallback"],"type":"object"},{"additionalProperties":false,"properties":{"collection":{"$ref":"#/$defs/schema0"},"combiner":{"oneOf":[{"additionalProperties":false,"properties":{"item":{"$ref":"#/$defs/ExpressionNode"},"mode":{"const":"max","type":"string"}},"required":["mode","item"],"type":"object"},{"additionalProperties":false,"properties":{"item":{"$ref":"#/$defs/ExpressionNode"},"mode":{"const":"min","type":"string"}},"required":["mode","item"],"type":"object"},{"additionalProperties":false,"properties":{"combine":{"$ref":"#/$defs/ExpressionNode"},"initial":{"$ref":"#/$defs/ExpressionNode"},"mode":{"const":"reduce","type":"string"}},"required":["mode","initial","combine"],"type":"object"}]},"filter":{"$ref":"#/$defs/PredicateNode"},"kind":{"const":"fold","type":"string"}},"required":["kind","collection","combiner"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"accumulator","type":"string"}},"required":["kind"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"delegate","type":"string"},"payload":{"$ref":"#/$defs/schema0"},"system":{"type":"string"}},"required":["kind","system","payload"],"type":"object"},{"additionalProperties":false,"properties":{"key":{"$ref":"#/$defs/schema0"},"kind":{"const":"treeReference","type":"string"}},"required":["kind","key"],"type":"object"}]},{"anyOf":[{"additionalProperties":false,"properties":{"im":{"type":"number"},"kind":{"const":"complexLiteral","type":"string"},"re":{"type":"number"},"unit":{"additionalProperties":{"type":"number"},"propertyNames":{"type":"string"},"type":"object"}},"required":["kind","re","im"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"complexLiteral","type":"string"},"magnitude":{"type":"number"},"phase":{"type":"number"},"unit":{"additionalProperties":{"type":"number"},"propertyNames":{"type":"string"},"type":"object"}},"required":["kind","magnitude","phase"],"type":"object"}]}]},"PredicateNode":{"oneOf":[{"additionalProperties":false,"properties":{"kind":{"const":"not","type":"string"},"operand":{"$ref":"#/$defs/PredicateNode"}},"required":["kind","operand"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"and","type":"string"},"left":{"$ref":"#/$defs/PredicateNode"},"right":{"$ref":"#/$defs/PredicateNode"}},"required":["kind","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"or","type":"string"},"left":{"$ref":"#/$defs/PredicateNode"},"right":{"$ref":"#/$defs/PredicateNode"}},"required":["kind","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"allOf","type":"string"},"operands":{"items":{"$ref":"#/$defs/PredicateNode"},"type":"array"}},"required":["kind","operands"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"anyOf","type":"string"},"operands":{"items":{"$ref":"#/$defs/PredicateNode"},"type":"array"}},"required":["kind","operands"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"compare","type":"string"},"left":{"$ref":"#/$defs/ExpressionNode"},"op":{"enum":["gt","gte","lt","lte","eq","neq"],"type":"string"},"right":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","op","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"textCompare","type":"string"},"left":{"$ref":"#/$defs/ExpressionNode"},"op":{"enum":["equals","notEquals","matches","notMatches"],"type":"string"},"right":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","op","left","right"],"type":"object"},{"additionalProperties":false,"properties":{"candidates":{"items":{"$ref":"#/$defs/ExpressionNode"},"type":"array"},"kind":{"const":"memberOf","type":"string"},"op":{"enum":["in","notIn"],"type":"string"},"operand":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","op","operand","candidates"],"type":"object"},{"additionalProperties":false,"properties":{"kind":{"const":"exists","type":"string"},"operand":{"$ref":"#/$defs/ExpressionNode"}},"required":["kind","operand"],"type":"object"},{"additionalProperties":false,"properties":{"collection":{"$ref":"#/$defs/schema0"},"filter":{"$ref":"#/$defs/PredicateNode"},"item":{"$ref":"#/$defs/PredicateNode"},"kind":{"const":"some","type":"string"}},"required":["kind","collection","item"],"type":"object"},{"additionalProperties":false,"properties":{"collection":{"$ref":"#/$defs/schema0"},"filter":{"$ref":"#/$defs/PredicateNode"},"item":{"$ref":"#/$defs/PredicateNode"},"kind":{"const":"every","type":"string"}},"required":["kind","collection","item"],"type":"object"},{"additionalProperties":false,"properties":{"key":{"$ref":"#/$defs/schema0"},"kind":{"const":"treeReference","type":"string"}},"required":["kind","key"],"type":"object"}]},"schema0":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"null"},{"items":{"$ref":"#/$defs/schema0"},"type":"array"},{"additionalProperties":{"$ref":"#/$defs/schema0"},"propertyNames":{"type":"string"},"type":"object"}]}},"$id":"https://cdn.jsdelivr.net/npm/trilean@1.2.0/schemas/trilean.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","oneOf":[{"$ref":"#/$defs/PredicateNode"},{"$ref":"#/$defs/ExpressionNode"}]}