trilean 1.4.1 → 1.5.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/README.md +8 -1
- package/dist/evaluator.cjs +14 -1
- package/dist/evaluator.js +14 -1
- package/dist/tree.cjs +3 -1
- package/dist/tree.d.cts +6 -0
- package/dist/tree.d.ts +6 -0
- package/dist/tree.js +3 -1
- package/package.json +2 -1
- package/schemas/trilean.schema.json +1 -1
package/README.md
CHANGED
|
@@ -340,7 +340,7 @@ A `PredicateNode` evaluates to `Evaluation<boolean>` — true, false, or indeter
|
|
|
340
340
|
|
|
341
341
|
```ts
|
|
342
342
|
type ComparisonOperator = "gt" | "gte" | "lt" | "lte" | "eq" | "neq";
|
|
343
|
-
type TextComparisonOperator = "equals" | "notEquals" | "matches" | "notMatches";
|
|
343
|
+
type TextComparisonOperator = "equals" | "notEquals" | "matches" | "notMatches" | "portableMatches" | "portableNotMatches";
|
|
344
344
|
type MembershipOperator = "in" | "notIn";
|
|
345
345
|
|
|
346
346
|
type PredicateNode =
|
|
@@ -374,6 +374,13 @@ A relational-comparison leaf: compares two computed values using `gt`/`gte`/`lt`
|
|
|
374
374
|
|
|
375
375
|
A text-matching leaf, symmetric in the same way as `compare`: both `left` and `right` are `ExpressionNode`, and either may be a literal or an arbitrary formula. `equals`/`notEquals` are exact string equality; `matches`/`notMatches` interpret `right` as a pattern (an ECMAScript-style regular expression) tested against `left`'s text. Both operands must resolve to the `text` computed-value kind; anything else is `wrong-type`. A "small fixed category" value (e.g. a status label) is simply a `text` computed value from this leaf's point of view — no separate category kind exists.
|
|
376
376
|
|
|
377
|
+
**`portableMatches`/`portableNotMatches`** answer the same question as `matches`/`notMatches` but interpret `right` as a pattern in [`trilean-regex`](https://www.npmjs.com/package/trilean-regex)'s own grammar instead of ECMAScript's — a genuine regular language (no backreferences, no lookaround), matched by that package's Thompson-construction NFA simulation rather than the host's native `RegExp` engine. Two consequences follow from that restriction, and are the reason to reach for the portable pair instead of the plain one:
|
|
378
|
+
|
|
379
|
+
- **No catastrophic-backtracking risk.** An NFA simulation runs in time linear in the pattern's compiled state count and the input's length, regardless of the pattern's shape — there is no input a `portableMatches` pattern can be made to hang on the way a pathological ECMAScript pattern can hang `matches`.
|
|
380
|
+
- **Provable pushdown equivalence.** Because the grammar is a true regular language, [`trilean-sql`](https://www.npmjs.com/package/trilean-sql)'s dialect compilers can translate a `portableMatches`/`portableNotMatches` pattern into a database's own `LIKE`/`GLOB`/native-regex operators and prove the translation agrees with this package's own evaluator row for row — the same "compile and measure agreement against the reference matcher" discipline `trilean-sql` already applies to everything else it compiles. `matches`/`notMatches` carry no such guarantee: what a SQL engine's own native regex operator accepts is a different language from ECMAScript's, and `trilean-sql` refuses to push either operator down for exactly that reason (see `trilean-sql`'s README).
|
|
381
|
+
|
|
382
|
+
This is additive, not a redefinition: `matches`/`notMatches` keep their existing ECMAScript semantics unchanged, and nothing already written against them is affected. Reach for `portableMatches`/`portableNotMatches` specifically when a tree might be compiled to SQL (or when the backtracking-safety guarantee alone is worth the smaller grammar), and keep `matches`/`notMatches` for in-process-only trees that need ECMAScript's full expressiveness. An invalid `trilean-regex` pattern is `wrong-type`, exactly like an invalid ECMAScript pattern under `matches` — see `trilean-regex`'s own README for the grammar's precise definition and what it deliberately excludes.
|
|
383
|
+
|
|
377
384
|
### Pattern-matching builders
|
|
378
385
|
|
|
379
386
|
`matches` already covers arbitrary pattern matching, but writing the regular expression by hand is where the common, narrower cases go wrong: getting the escape-then-convert ordering backwards either stops wildcards working or silently reinterprets a literal asterisk in real data as one. Three builder functions compile a pattern string into an ordinary `textCompare` node instead — never a new node kind, never an evaluator branch, exactly the same composition-not-new-logic treatment [Derived connectives](#derived-connectives), [Derived aggregates](#derived-aggregates), and [Derived values](#derived-values) already give `xor`/`sum`/`coalesce`:
|
package/dist/evaluator.cjs
CHANGED
|
@@ -4,6 +4,7 @@ const require_computed_value = require("./computed-value.cjs");
|
|
|
4
4
|
const require_evaluation = require("./evaluation.cjs");
|
|
5
5
|
const require_functions = require("./functions.cjs");
|
|
6
6
|
const require_tree = require("./tree.cjs");
|
|
7
|
+
let trilean_regex = require("trilean-regex");
|
|
7
8
|
//#region src/evaluator.ts
|
|
8
9
|
/**
|
|
9
10
|
* `evaluatePredicateInternal` and `evaluateValueInternal` are co-located in this one file, rather than split across `predicate-evaluator.ts`/`value-evaluator.ts`, because they are mutually recursive: a predicate leaf (`compare`, `textCompare`, `memberOf`, `exists`) holds `ExpressionNode` operands, and an expression node (`conditional`'s `when`, a fold's `filter`) holds `PredicateNode` operands. Splitting them across modules would make each half import the other, and whichever module finished loading second would see the other's export as `undefined` at its own module-evaluation time -- a genuine circular-import TDZ hazard, not merely a style preference.
|
|
@@ -100,7 +101,7 @@ function compareValues(op, left, right) {
|
|
|
100
101
|
default: throw new Error("unreachable computed-value kind");
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
|
-
/** `textCompare`'s two operands must both resolve to the `text` computed-value kind -- any other kind, on either operand, is `wrong-type` (see the `textCompare` section of README.md). `equals`/`notEquals` are exact string equality; `matches`/`notMatches` interpret `right`'s text as an ECMAScript regular expression tested against `left`'s text. An invalid pattern is `wrong-type` rather than a thrown exception -- every data-quality problem stays inside the `Evaluation` result, per `Evaluation<T>`'s own doc comment in evaluation.ts. */
|
|
104
|
+
/** `textCompare`'s two operands must both resolve to the `text` computed-value kind -- any other kind, on either operand, is `wrong-type` (see the `textCompare` section of README.md). `equals`/`notEquals` are exact string equality; `matches`/`notMatches` interpret `right`'s text as an ECMAScript regular expression tested against `left`'s text; `portableMatches`/`portableNotMatches` interpret it as a pattern in `trilean-regex`'s own restricted grammar instead, matched by that package's finite-automaton reference matcher rather than the host's native `RegExp` engine -- see the `textCompare` section of README.md for when to reach for the portable pair instead of the plain one. An invalid pattern is `wrong-type` rather than a thrown exception either way -- every data-quality problem stays inside the `Evaluation` result, per `Evaluation<T>`'s own doc comment in evaluation.ts. */
|
|
104
105
|
function compareText(op, left, right) {
|
|
105
106
|
if (left.kind !== "text") return require_evaluation.indeterminate("wrong-type", `'textCompare' requires 'text' operands; the left operand is '${left.kind}'`);
|
|
106
107
|
if (right.kind !== "text") return require_evaluation.indeterminate("wrong-type", `'textCompare' requires 'text' operands; the right operand is '${right.kind}'`);
|
|
@@ -118,6 +119,18 @@ function compareText(op, left, right) {
|
|
|
118
119
|
const isMatch = pattern.test(left.value);
|
|
119
120
|
return require_evaluation.definite(op === "matches" ? isMatch : !isMatch);
|
|
120
121
|
}
|
|
122
|
+
case "portableMatches":
|
|
123
|
+
case "portableNotMatches": {
|
|
124
|
+
let compiled;
|
|
125
|
+
try {
|
|
126
|
+
compiled = (0, trilean_regex.compilePattern)(right.value);
|
|
127
|
+
} catch (error) {
|
|
128
|
+
const reason = error instanceof trilean_regex.RegexParseError ? error.message : String(error);
|
|
129
|
+
return require_evaluation.indeterminate("wrong-type", `'${right.value}' is not a valid trilean-regex pattern: ${reason}`);
|
|
130
|
+
}
|
|
131
|
+
const isMatch = compiled.test(left.value);
|
|
132
|
+
return require_evaluation.definite(op === "portableMatches" ? isMatch : !isMatch);
|
|
133
|
+
}
|
|
121
134
|
default: throw new Error("unreachable text comparison operator");
|
|
122
135
|
}
|
|
123
136
|
}
|
package/dist/evaluator.js
CHANGED
|
@@ -3,6 +3,7 @@ import { combineUnitsForDivide, combineUnitsForMultiply, unitsEqual } from "./co
|
|
|
3
3
|
import { definite, firstIndeterminate, indeterminate } from "./evaluation.js";
|
|
4
4
|
import { emptyFunctionRegistry } from "./functions.js";
|
|
5
5
|
import { ExpressionNodeSchema, PredicateNodeSchema } from "./tree.js";
|
|
6
|
+
import { RegexParseError, compilePattern } from "trilean-regex";
|
|
6
7
|
//#region src/evaluator.ts
|
|
7
8
|
/**
|
|
8
9
|
* `evaluatePredicateInternal` and `evaluateValueInternal` are co-located in this one file, rather than split across `predicate-evaluator.ts`/`value-evaluator.ts`, because they are mutually recursive: a predicate leaf (`compare`, `textCompare`, `memberOf`, `exists`) holds `ExpressionNode` operands, and an expression node (`conditional`'s `when`, a fold's `filter`) holds `PredicateNode` operands. Splitting them across modules would make each half import the other, and whichever module finished loading second would see the other's export as `undefined` at its own module-evaluation time -- a genuine circular-import TDZ hazard, not merely a style preference.
|
|
@@ -99,7 +100,7 @@ function compareValues(op, left, right) {
|
|
|
99
100
|
default: throw new Error("unreachable computed-value kind");
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
/** `textCompare`'s two operands must both resolve to the `text` computed-value kind -- any other kind, on either operand, is `wrong-type` (see the `textCompare` section of README.md). `equals`/`notEquals` are exact string equality; `matches`/`notMatches` interpret `right`'s text as an ECMAScript regular expression tested against `left`'s text. An invalid pattern is `wrong-type` rather than a thrown exception -- every data-quality problem stays inside the `Evaluation` result, per `Evaluation<T>`'s own doc comment in evaluation.ts. */
|
|
103
|
+
/** `textCompare`'s two operands must both resolve to the `text` computed-value kind -- any other kind, on either operand, is `wrong-type` (see the `textCompare` section of README.md). `equals`/`notEquals` are exact string equality; `matches`/`notMatches` interpret `right`'s text as an ECMAScript regular expression tested against `left`'s text; `portableMatches`/`portableNotMatches` interpret it as a pattern in `trilean-regex`'s own restricted grammar instead, matched by that package's finite-automaton reference matcher rather than the host's native `RegExp` engine -- see the `textCompare` section of README.md for when to reach for the portable pair instead of the plain one. An invalid pattern is `wrong-type` rather than a thrown exception either way -- every data-quality problem stays inside the `Evaluation` result, per `Evaluation<T>`'s own doc comment in evaluation.ts. */
|
|
103
104
|
function compareText(op, left, right) {
|
|
104
105
|
if (left.kind !== "text") return indeterminate("wrong-type", `'textCompare' requires 'text' operands; the left operand is '${left.kind}'`);
|
|
105
106
|
if (right.kind !== "text") return indeterminate("wrong-type", `'textCompare' requires 'text' operands; the right operand is '${right.kind}'`);
|
|
@@ -117,6 +118,18 @@ function compareText(op, left, right) {
|
|
|
117
118
|
const isMatch = pattern.test(left.value);
|
|
118
119
|
return definite(op === "matches" ? isMatch : !isMatch);
|
|
119
120
|
}
|
|
121
|
+
case "portableMatches":
|
|
122
|
+
case "portableNotMatches": {
|
|
123
|
+
let compiled;
|
|
124
|
+
try {
|
|
125
|
+
compiled = compilePattern(right.value);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
const reason = error instanceof RegexParseError ? error.message : String(error);
|
|
128
|
+
return indeterminate("wrong-type", `'${right.value}' is not a valid trilean-regex pattern: ${reason}`);
|
|
129
|
+
}
|
|
130
|
+
const isMatch = compiled.test(left.value);
|
|
131
|
+
return definite(op === "portableMatches" ? isMatch : !isMatch);
|
|
132
|
+
}
|
|
120
133
|
default: throw new Error("unreachable text comparison operator");
|
|
121
134
|
}
|
|
122
135
|
}
|
package/dist/tree.cjs
CHANGED
|
@@ -15,7 +15,9 @@ const TextComparisonOperatorSchema = zod.z.enum([
|
|
|
15
15
|
"equals",
|
|
16
16
|
"notEquals",
|
|
17
17
|
"matches",
|
|
18
|
-
"notMatches"
|
|
18
|
+
"notMatches",
|
|
19
|
+
"portableMatches",
|
|
20
|
+
"portableNotMatches"
|
|
19
21
|
]);
|
|
20
22
|
const MembershipOperatorSchema = zod.z.enum(["in", "notIn"]);
|
|
21
23
|
const ArithmeticOperatorSchema = zod.z.enum([
|
package/dist/tree.d.cts
CHANGED
|
@@ -15,6 +15,8 @@ declare const TextComparisonOperatorSchema: z.ZodEnum<{
|
|
|
15
15
|
notEquals: "notEquals";
|
|
16
16
|
matches: "matches";
|
|
17
17
|
notMatches: "notMatches";
|
|
18
|
+
portableMatches: "portableMatches";
|
|
19
|
+
portableNotMatches: "portableNotMatches";
|
|
18
20
|
}>;
|
|
19
21
|
type TextComparisonOperator = z.infer<typeof TextComparisonOperatorSchema>;
|
|
20
22
|
declare const MembershipOperatorSchema: z.ZodEnum<{
|
|
@@ -84,6 +86,8 @@ declare const TextCompareNodeSchema: z.ZodObject<{
|
|
|
84
86
|
notEquals: "notEquals";
|
|
85
87
|
matches: "matches";
|
|
86
88
|
notMatches: "notMatches";
|
|
89
|
+
portableMatches: "portableMatches";
|
|
90
|
+
portableNotMatches: "portableNotMatches";
|
|
87
91
|
}>;
|
|
88
92
|
left: typeof ExpressionNodeSchema;
|
|
89
93
|
right: typeof ExpressionNodeSchema;
|
|
@@ -160,6 +164,8 @@ declare const PredicateNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
160
164
|
notEquals: "notEquals";
|
|
161
165
|
matches: "matches";
|
|
162
166
|
notMatches: "notMatches";
|
|
167
|
+
portableMatches: "portableMatches";
|
|
168
|
+
portableNotMatches: "portableNotMatches";
|
|
163
169
|
}>;
|
|
164
170
|
left: typeof ExpressionNodeSchema;
|
|
165
171
|
right: typeof ExpressionNodeSchema;
|
package/dist/tree.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ declare const TextComparisonOperatorSchema: z.ZodEnum<{
|
|
|
15
15
|
notEquals: "notEquals";
|
|
16
16
|
matches: "matches";
|
|
17
17
|
notMatches: "notMatches";
|
|
18
|
+
portableMatches: "portableMatches";
|
|
19
|
+
portableNotMatches: "portableNotMatches";
|
|
18
20
|
}>;
|
|
19
21
|
type TextComparisonOperator = z.infer<typeof TextComparisonOperatorSchema>;
|
|
20
22
|
declare const MembershipOperatorSchema: z.ZodEnum<{
|
|
@@ -84,6 +86,8 @@ declare const TextCompareNodeSchema: z.ZodObject<{
|
|
|
84
86
|
notEquals: "notEquals";
|
|
85
87
|
matches: "matches";
|
|
86
88
|
notMatches: "notMatches";
|
|
89
|
+
portableMatches: "portableMatches";
|
|
90
|
+
portableNotMatches: "portableNotMatches";
|
|
87
91
|
}>;
|
|
88
92
|
left: typeof ExpressionNodeSchema;
|
|
89
93
|
right: typeof ExpressionNodeSchema;
|
|
@@ -160,6 +164,8 @@ declare const PredicateNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
160
164
|
notEquals: "notEquals";
|
|
161
165
|
matches: "matches";
|
|
162
166
|
notMatches: "notMatches";
|
|
167
|
+
portableMatches: "portableMatches";
|
|
168
|
+
portableNotMatches: "portableNotMatches";
|
|
163
169
|
}>;
|
|
164
170
|
left: typeof ExpressionNodeSchema;
|
|
165
171
|
right: typeof ExpressionNodeSchema;
|
package/dist/tree.js
CHANGED
|
@@ -14,7 +14,9 @@ const TextComparisonOperatorSchema = z.enum([
|
|
|
14
14
|
"equals",
|
|
15
15
|
"notEquals",
|
|
16
16
|
"matches",
|
|
17
|
-
"notMatches"
|
|
17
|
+
"notMatches",
|
|
18
|
+
"portableMatches",
|
|
19
|
+
"portableNotMatches"
|
|
18
20
|
]);
|
|
19
21
|
const MembershipOperatorSchema = z.enum(["in", "notIn"]);
|
|
20
22
|
const ArithmeticOperatorSchema = z.enum([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trilean",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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": {
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
|
+
"trilean-regex": "workspace:^",
|
|
52
53
|
"zod": "^4.5.4"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
@@ -1 +1 @@
|
|
|
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.
|
|
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","portableMatches","portableNotMatches"],"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.5.0/schemas/trilean.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","oneOf":[{"$ref":"#/$defs/PredicateNode"},{"$ref":"#/$defs/ExpressionNode"}]}
|