trilean 1.13.6 → 1.13.7

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.
Files changed (125) hide show
  1. package/dist/builtin-functions.cjs +1 -2
  2. package/dist/builtin-functions.d.cts +1 -3
  3. package/dist/builtin-functions.d.ts +1 -3
  4. package/dist/builtin-functions.js +1 -2
  5. package/dist/complex-division.cjs +1 -2
  6. package/dist/complex-division.d.cts +1 -3
  7. package/dist/complex-division.d.ts +1 -3
  8. package/dist/complex-division.js +1 -2
  9. package/dist/complex.cjs +1 -2
  10. package/dist/complex.d.cts +1 -3
  11. package/dist/complex.d.ts +1 -3
  12. package/dist/complex.js +1 -2
  13. package/dist/{computed-value-CbRF0Izc.d.cts → computed-value-CaFJ1YkU.d.ts} +0 -2
  14. package/dist/computed-value.cjs +1 -2
  15. package/dist/computed-value.d.cts +48 -2
  16. package/dist/computed-value.d.ts +1 -1
  17. package/dist/computed-value.js +1 -2
  18. package/dist/derived-aggregates.cjs +1 -2
  19. package/dist/derived-aggregates.d.cts +2 -4
  20. package/dist/derived-aggregates.d.ts +2 -4
  21. package/dist/derived-aggregates.js +1 -2
  22. package/dist/derived-connectives.cjs +1 -2
  23. package/dist/derived-connectives.d.cts +2 -4
  24. package/dist/derived-connectives.d.ts +2 -4
  25. package/dist/derived-connectives.js +1 -2
  26. package/dist/derived-patterns.cjs +1 -2
  27. package/dist/derived-patterns.d.cts +1 -3
  28. package/dist/derived-patterns.d.ts +1 -3
  29. package/dist/derived-patterns.js +1 -2
  30. package/dist/derived-values.cjs +1 -2
  31. package/dist/derived-values.d.cts +1 -3
  32. package/dist/derived-values.d.ts +1 -3
  33. package/dist/derived-values.js +1 -2
  34. package/dist/{dist-Dn-LI_AV.js → dist-ed78Tuwe.js} +2 -4
  35. package/dist/{dist-DO_3oafK.cjs → dist-ySX7cb5d.cjs} +2 -4
  36. package/dist/duration-order.cjs +1 -2
  37. package/dist/duration-order.d.cts +1 -3
  38. package/dist/duration-order.d.ts +1 -3
  39. package/dist/duration-order.js +1 -2
  40. package/dist/evaluate-document.cjs +4 -5
  41. package/dist/evaluate-document.d.cts +2 -4
  42. package/dist/evaluate-document.d.ts +2 -4
  43. package/dist/evaluate-document.js +4 -5
  44. package/dist/evaluation.cjs +1 -2
  45. package/dist/evaluation.d.cts +1 -3
  46. package/dist/evaluation.d.ts +1 -3
  47. package/dist/evaluation.js +1 -2
  48. package/dist/evaluator-budget.cjs +1 -2
  49. package/dist/evaluator-budget.d.cts +1 -3
  50. package/dist/evaluator-budget.d.ts +1 -3
  51. package/dist/evaluator-budget.js +1 -2
  52. package/dist/evaluator-collection.cjs +1 -2
  53. package/dist/evaluator-collection.d.cts +5 -7
  54. package/dist/evaluator-collection.d.ts +5 -7
  55. package/dist/evaluator-collection.js +1 -2
  56. package/dist/evaluator-compiled.cjs +3 -4
  57. package/dist/evaluator-compiled.d.cts +3 -5
  58. package/dist/evaluator-compiled.d.ts +3 -5
  59. package/dist/evaluator-compiled.js +3 -4
  60. package/dist/evaluator-effect.cjs +1 -2
  61. package/dist/evaluator-effect.d.cts +0 -2
  62. package/dist/evaluator-effect.d.ts +0 -2
  63. package/dist/evaluator-effect.js +1 -2
  64. package/dist/evaluator-factory.cjs +2 -3
  65. package/dist/evaluator-factory.d.cts +5 -7
  66. package/dist/evaluator-factory.d.ts +5 -7
  67. package/dist/evaluator-factory.js +2 -3
  68. package/dist/evaluator-indeterminacy-helpers.cjs +2 -3
  69. package/dist/evaluator-indeterminacy-helpers.d.cts +2 -4
  70. package/dist/evaluator-indeterminacy-helpers.d.ts +2 -4
  71. package/dist/evaluator-indeterminacy-helpers.js +2 -3
  72. package/dist/evaluator-literals.cjs +1 -2
  73. package/dist/evaluator-literals.d.cts +2 -4
  74. package/dist/evaluator-literals.d.ts +2 -4
  75. package/dist/evaluator-literals.js +1 -2
  76. package/dist/evaluator-operations.cjs +2 -3
  77. package/dist/evaluator-operations.d.cts +4 -6
  78. package/dist/evaluator-operations.d.ts +4 -6
  79. package/dist/evaluator-operations.js +2 -3
  80. package/dist/evaluator-test-helpers.cjs +2 -3
  81. package/dist/evaluator-test-helpers.d.cts +1 -3
  82. package/dist/evaluator-test-helpers.d.ts +1 -3
  83. package/dist/evaluator-test-helpers.js +2 -3
  84. package/dist/evaluator.cjs +2 -3
  85. package/dist/evaluator.d.cts +4 -6
  86. package/dist/evaluator.d.ts +4 -6
  87. package/dist/evaluator.js +2 -3
  88. package/dist/functions.cjs +1 -2
  89. package/dist/functions.d.cts +2 -4
  90. package/dist/functions.d.ts +2 -4
  91. package/dist/functions.js +1 -2
  92. package/dist/{index.CZzC1gGg-C3tq-f5f.cjs → index.CZzC1gGg-CQphWYWn.cjs} +23 -40
  93. package/dist/{index.CZzC1gGg-DVgiC1Nq.js → index.CZzC1gGg-D3-vRdPe.js} +14 -27
  94. package/dist/index.cjs +10 -10
  95. package/dist/index.d.cts +13 -13
  96. package/dist/index.d.ts +13 -13
  97. package/dist/index.js +10 -10
  98. package/dist/input-resolvers.cjs +1 -2
  99. package/dist/input-resolvers.d.cts +2 -4
  100. package/dist/input-resolvers.d.ts +2 -4
  101. package/dist/input-resolvers.js +1 -2
  102. package/dist/integer-power.cjs +1 -2
  103. package/dist/integer-power.d.cts +1 -3
  104. package/dist/integer-power.d.ts +1 -3
  105. package/dist/integer-power.js +1 -2
  106. package/dist/{json-value-B1Hjjjri.d.cts → json-value-ZLMaKP0n.d.ts} +0 -2
  107. package/dist/json-value.cjs +1 -2
  108. package/dist/json-value.d.cts +8 -2
  109. package/dist/json-value.d.ts +1 -1
  110. package/dist/json-value.js +1 -2
  111. package/dist/plain-record.cjs +1 -2
  112. package/dist/plain-record.d.cts +1 -3
  113. package/dist/plain-record.d.ts +1 -3
  114. package/dist/plain-record.js +1 -2
  115. package/dist/resolvers.d.cts +3 -5
  116. package/dist/resolvers.d.ts +3 -5
  117. package/dist/tree.cjs +1 -2
  118. package/dist/tree.d.cts +2 -4
  119. package/dist/tree.d.ts +2 -4
  120. package/dist/tree.js +1 -2
  121. package/dist-cli/trilean.mjs +24 -47
  122. package/package.json +3 -3
  123. package/schemas/trilean.schema.json +1 -1
  124. package/dist/computed-value-CbRF0Izc.d.ts +0 -51
  125. package/dist/json-value-B1Hjjjri.d.ts +0 -11
@@ -3,10 +3,9 @@ import { readFileSync } from "node:fs";
3
3
  import { parseArgs } from "node:util";
4
4
  import { z } from "zod";
5
5
  import { RegexParseError, compilePattern } from "trilean-regex";
6
- //#region package.json
7
- var version = "1.13.6";
8
- //#endregion
9
- //#region src/computed-value.ts
6
+ // package.json
7
+ var version = "1.13.7";
8
+ // src/computed-value.ts
10
9
  /** Dimension symbol -\> exponent, e.g. `{ m: 1, s: -1 }` for metres per second. A bare symbol like `"kg"` is shorthand for `{ kg: 1 }`. */
11
10
  const UnitSchema = z.record(z.string(), z.number());
12
11
  const DurationUnitSchema = z.enum([
@@ -118,8 +117,7 @@ function firstIndeterminate(...results) {
118
117
  }
119
118
  return first;
120
119
  }
121
- //#endregion
122
- //#region src/evaluator-budget.ts
120
+ // src/evaluator-budget.ts
123
121
  /** Default cap on the total number of predicate/expression nodes a single `evaluatePredicate`/`evaluateValue` call may visit -- see `createEvaluator`'s `maxNodes` option, threaded through to `createEvaluationBudget` below. Chosen generously above any realistic hand-authored business-rule, eligibility, or formula tree (see README.md's own consumer use cases), while still bounding an untrusted, adversarially-authored tree's total evaluation cost to a fixed, small amount of work regardless of how it is shaped. */
124
122
  const DEFAULT_MAX_EVALUATION_NODES = 1e4;
125
123
  /** Constructs a fresh `EvaluationBudget` for one top-level `evaluatePredicate`/`evaluateValue` call -- see `createEvaluator`'s `maxNodes`/`maxNestingDepth` options, which supply `maxNodes`/`maxNestingDepth` here. A fresh closure per call is what keeps `nodesVisited` from leaking between unrelated evaluations. */
@@ -132,8 +130,7 @@ function createEvaluationBudget(maxNodes, maxNestingDepth) {
132
130
  if (nestingDepth >= maxNestingDepth) return indeterminate("domain-error", `evaluation nesting depth exceeds the maximum of ${maxNestingDepth.toString()} (resource exhausted)`);
133
131
  } };
134
132
  }
135
- //#endregion
136
- //#region src/evaluator-effect.ts
133
+ // src/evaluator-effect.ts
137
134
  /**
138
135
  * Suspends until `value` is available. The driver resumes the task with exactly that value (awaited, in the async driver), and the generator's own "next" type is `T`, so the result is typed without an assertion.
139
136
  */
@@ -184,8 +181,7 @@ function runSync(task) {
184
181
  }
185
182
  return step.value;
186
183
  }
187
- //#endregion
188
- //#region src/evaluator-collection.ts
184
+ // src/evaluator-collection.ts
189
185
  /**
190
186
  * Collection resolution shared by the quantifiers (`some`/`every`) and by `fold` in evaluator.ts: resolves the opaque `collection` reference to its concrete candidate list via `resolvers.resolveCollection`, then evaluates each candidate's optional `filter` (via the injected `evaluatePredicate`, see `EvaluatePredicate`'s own doc comment) with that candidate as its own evaluation context and the accumulator reset to `undefined` -- see the README's "Evaluation context" and "Pre-filtering which items participate" sections. Deliberately stops short of deciding how an indeterminate filter combines with the rest of the surrounding node: `some`/`every` fold a filter-indeterminate item in as its own vote via the surrounding OR/AND absorption, while `fold` has no absorbing value at all and goes indeterminate outright on the same condition -- the two callers need genuinely different combination logic over these same per-item outcomes, so this helper only produces the outcomes and leaves combining them to the caller.
191
187
  */
@@ -213,8 +209,7 @@ function firstFilterIndeterminate(participating) {
213
209
  if (filterOutcome.status === "indeterminate") return filterOutcome.reason;
214
210
  }
215
211
  }
216
- //#endregion
217
- //#region src/complex-division.ts
212
+ // src/complex-division.ts
218
213
  /**
219
214
  * `value * 2 ** exponent`, applied in two halves because `2 ** exponent` is infinite beyond 1023 and a quotient can need a shift of about twice that. A power of two multiplies a double exactly while the result stays normal, so when the result can be non-zero and finite (a shift between about -1077 and 1024 for a scaled quotient of order one) each half is at most about 540 in magnitude, the first multiplication is exact, and the second rounds only where the result is subnormal. Outside that range the result overflows or is below the smallest subnormal: a non-zero value gives an infinity or zero, which is correct, and a zero value with a shift of 2047 or more gives NaN (zero times an infinite half), which the caller's finite check treats as it does an infinity.
220
215
  */
@@ -259,8 +254,7 @@ function divideComplexComponents(dividend, divisor) {
259
254
  im: scaleByPowerOfTwo((b * c - a * d) / denominator, shift)
260
255
  };
261
256
  }
262
- //#endregion
263
- //#region src/duration-order.ts
257
+ // src/duration-order.ts
264
258
  /** How many milliseconds one of each duration unit is. Every unit is a whole multiple of every finer one, which is what lets a value be divided down into a coarser unit by an exact integer. */
265
259
  const millisecondsPerDurationUnit = {
266
260
  ms: 1,
@@ -340,8 +334,7 @@ function compareDurations(left, right) {
340
334
  size: rightSize
341
335
  });
342
336
  }
343
- //#endregion
344
- //#region src/integer-power.ts
337
+ // src/integer-power.ts
345
338
  /**
346
339
  * `base` raised to a non-negative integer `exponent` by exponentiation by squaring: one squaring and at most one product per bit of the exponent, so the number of `multiply` calls grows with the logarithm of the exponent where repeated multiplication grows with the exponent itself (an exponent of 1e9 is a few dozen products rather than a billion). `identity` is the value of exponent zero and the start of the product; `multiply` must be associative, which squaring relies on. With a rounding `multiply` the grouping matters: squaring compounds a rounding error through each successive square, so its error grows in proportion to the exponent, and for large exponents the result is many times less accurate than a plain loop's, in exchange for work that does not grow with the exponent.
347
340
  *
@@ -358,8 +351,7 @@ function powerByRepeatedSquaring({ base, exponent, identity, multiply }) {
358
351
  }
359
352
  return result;
360
353
  }
361
- //#endregion
362
- //#region src/evaluator-operations.ts
354
+ // src/evaluator-operations.ts
363
355
  /** The indeterminate result for a resolver's report of absence: `not-yet-known` when the resolver said the value has not been supplied yet, `not-found` otherwise. The two share every propagation rule except `exists` (and so `coalesce`), which is why every resolver call site goes through this one function. */
364
356
  function absenceEvaluation(absence, notFoundMessage, notYetKnownMessage) {
365
357
  return absence.notYetKnown === true ? indeterminate("not-yet-known", notYetKnownMessage) : indeterminate("not-found", notFoundMessage);
@@ -780,8 +772,7 @@ function invokeRegisteredFunction(functions, fnName, args) {
780
772
  if ("wrongType" in outcome) return indeterminate("wrong-type", outcome.wrongType);
781
773
  return definite(outcome);
782
774
  }
783
- //#endregion
784
- //#region src/complex.ts
775
+ // src/complex.ts
785
776
  const complexFromPolar = (magnitude, phase, unit) => ({
786
777
  kind: "complex",
787
778
  re: magnitude * Math.cos(phase),
@@ -801,8 +792,7 @@ const complexPhase = (value) => ({
801
792
  kind: "number",
802
793
  value: Math.atan2(value.im + 0, value.re + 0)
803
794
  });
804
- //#endregion
805
- //#region src/evaluator-literals.ts
795
+ // src/evaluator-literals.ts
806
796
  /**
807
797
  * The `ComputedValue` a literal node denotes, as a new object on every call. Whichever authoring form a `complexLiteral` used (see the "Complex values" section of README.md), it is normalised here to the single rectangular `ComputedValue`, so nothing downstream (arithmetic, compare, memberOf, negate) ever sees a polar-authored value. Shared by the interpreter and the compiled path so a literal means one thing in both.
808
798
  */
@@ -841,8 +831,7 @@ function literalValue(node) {
841
831
  default: throw new Error("unreachable literal node kind");
842
832
  }
843
833
  }
844
- //#endregion
845
- //#region src/json-value.ts
834
+ // src/json-value.ts
846
835
  const JsonValueSchema = z.lazy(() => z.union([
847
836
  z.string(),
848
837
  z.number(),
@@ -851,8 +840,7 @@ const JsonValueSchema = z.lazy(() => z.union([
851
840
  z.array(JsonValueSchema),
852
841
  z.record(z.string(), JsonValueSchema)
853
842
  ]));
854
- //#endregion
855
- //#region src/tree.ts
843
+ // src/tree.ts
856
844
  const ComparisonOperatorSchema = z.enum([
857
845
  "gt",
858
846
  "gte",
@@ -1142,8 +1130,7 @@ const CoreExpressionNodeSchema = z.discriminatedUnion("kind", [
1142
1130
  TreeReferenceNodeSchema
1143
1131
  ]);
1144
1132
  const ExpressionNodeSchema = z.union([CoreExpressionNodeSchema, ComplexLiteralNodeSchema]);
1145
- //#endregion
1146
- //#region src/evaluator.ts
1133
+ // src/evaluator.ts
1147
1134
  /**
1148
1135
  * `evaluatePredicateInternal` and `evaluateValueInternal` below 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. `resolveParticipatingItems` (in `evaluator-collection.ts`) would share that same hazard if it imported `evaluatePredicateInternal` directly, since it calls back into it to evaluate each candidate's filter -- so it instead takes the evaluator as an injected `EvaluatePredicate` parameter (see that type's own doc comment), which is what lets it live in its own file with no circular dependency on this one. The pure, non-recursive value-combination logic (`combineAnd`/`compareValues`/`applyArithmetic` and their siblings) carries no such constraint either and lives in `evaluator-operations.ts`; the resource-limit infrastructure (`EvaluationBudget` and its constants), likewise self-contained, lives in `evaluator-budget.ts`.
1149
1136
  */
@@ -1360,8 +1347,7 @@ function* evaluateValueInternal(node, context, resolvers, accumulator, functions
1360
1347
  default: throw new Error("unreachable expression node kind");
1361
1348
  }
1362
1349
  }
1363
- //#endregion
1364
- //#region src/evaluator-compiled.ts
1350
+ // src/evaluator-compiled.ts
1365
1351
  /** Never charged: handed to the nodes of a tree compiled without budget counting, none of which reads it. */
1366
1352
  const UNLIMITED_BUDGET = { checkNode: () => void 0 };
1367
1353
  /** The `visitedTreeKeys` of a call that has not entered any `treeReference`; the interpreter copies it rather than mutating it, so one instance serves every call. */
@@ -1659,11 +1645,9 @@ function compilePredicateTree(node, functions, maxNodes, maxNestingDepth) {
1659
1645
  const countedRun = new NodeCompiler(functions, maxNestingDepth, true).predicate(node, 0);
1660
1646
  return (context, resolvers) => countedRun(context, resolvers, createEvaluationBudget(maxNodes, maxNestingDepth));
1661
1647
  }
1662
- //#endregion
1663
- //#region src/functions.ts
1648
+ // src/functions.ts
1664
1649
  const emptyFunctionRegistry = {};
1665
- //#endregion
1666
- //#region src/evaluator-factory.ts
1650
+ // src/evaluator-factory.ts
1667
1651
  /**
1668
1652
  * Builds a bound `{ evaluatePredicate, evaluateValue }` pair over a caller-supplied function registry for `call` nodes -- the registry is bound once, at construction time, unlike `resolvers`, which are supplied fresh to every call. `maxNodes` and `maxNestingDepth` configure that same pair's own `EvaluationBudget` (see its doc comment in evaluator-budget.ts), created fresh for every top-level `evaluatePredicate`/`evaluateValue` invocation so budgets never leak between unrelated calls. The bare module-level `evaluatePredicate`/`evaluateValue` exports below are `createEvaluator({})`'s output, so both caps default to `DEFAULT_MAX_EVALUATION_NODES`/`DEFAULT_MAX_NESTING_DEPTH` for every caller that does not explicitly configure them.
1669
1653
  */
@@ -1684,8 +1668,7 @@ function createSyncEvaluator({ functions = emptyFunctionRegistry, maxNodes = DEF
1684
1668
  };
1685
1669
  }
1686
1670
  const { evaluatePredicate, evaluateValue } = createEvaluator({});
1687
- //#endregion
1688
- //#region src/builtin-functions.ts
1671
+ // src/builtin-functions.ts
1689
1672
  const DECIMAL_BASE = 10;
1690
1673
  const BINARY_BASE = 2;
1691
1674
  /** Beyond this many decimal places a double either has no digit left to round (positive places) or rounds to zero (negative places): the decimal exponent range of a finite double, from the largest value's order of magnitude down to the smallest subnormal's. Clamping to it keeps the exponent written into a number string well formed whatever count a caller passes. */
@@ -1923,14 +1906,12 @@ const builtinFunctions = Object.freeze({
1923
1906
  });
1924
1907
  }
1925
1908
  });
1926
- //#endregion
1927
- //#region src/plain-record.ts
1909
+ // src/plain-record.ts
1928
1910
  /** Narrows `unknown` to a plain JSON-style object: not `null`, not an array. The guard parsed JSON is checked with before its fields are read, in place of an `as Record<string, unknown>` assertion. */
1929
1911
  function isPlainRecord(value) {
1930
1912
  return typeof value === "object" && value !== null && !Array.isArray(value);
1931
1913
  }
1932
- //#endregion
1933
- //#region src/input-resolvers.ts
1914
+ // src/input-resolvers.ts
1934
1915
  /** A plain JSON number, string or boolean is the unit-less value of that kind; anything else must already be a complete `ComputedValue` (the only way to supply units, durations, instants or complex values). Both routes end in `ComputedValueSchema`, so a number that is not finite (`1e999` parses to `Infinity`) is refused whichever way it was written, and a field the schema does not define is dropped rather than carried along. */
1935
1916
  function toComputedValue(raw) {
1936
1917
  const candidate = typeof raw === "number" ? {
@@ -2034,8 +2015,7 @@ function createInputResolvers(inputs, collections = /* @__PURE__ */ new Map()) {
2034
2015
  }
2035
2016
  };
2036
2017
  }
2037
- //#endregion
2038
- //#region src/evaluate-document.ts
2018
+ // src/evaluate-document.ts
2039
2019
  const predicateKinds = new Set(PredicateNodeSchema.options.map((option) => option.shape.kind.value));
2040
2020
  /** What a definite expression result that `ComputedValueSchema` refuses is reported as: the only way a result fails it is a non-finite number, which JSON would write as `null`. The evaluator's arithmetic and the built-in functions already keep one from forming, so this is the last check before a value leaves the document boundary, and it fails loudly rather than print a different value from the one computed. */
2041
2021
  const NOT_REPRESENTABLE = "(result): the value is not a finite number";
@@ -2119,8 +2099,7 @@ function evaluateDocument({ tree, inputs, as, maxNodes }) {
2119
2099
  evaluation
2120
2100
  };
2121
2101
  }
2122
- //#endregion
2123
- //#region cli/run.ts
2102
+ // cli/run.ts
2124
2103
  /** The command's wording for a root `treeReference` given without `--as`, in the same `path: message` form as the library's own issues. */
2125
2104
  const AMBIGUOUS_TREE_KIND = "(root): a treeReference is valid as a predicate and as an expression; pass --as predicate or --as expression";
2126
2105
  /** The path that stands for standard input. */
@@ -2261,8 +2240,7 @@ function parseCommandLine(args) {
2261
2240
  }
2262
2241
  });
2263
2242
  }
2264
- //#endregion
2265
- //#region cli/trilean.ts
2243
+ // cli/trilean.ts
2266
2244
  process.stdout.on("error", (error) => {
2267
2245
  if (error.code !== "EPIPE") throw error;
2268
2246
  });
@@ -2276,5 +2254,4 @@ process.exitCode = run(process.argv.slice(2), {
2276
2254
  },
2277
2255
  version
2278
2256
  });
2279
- //#endregion
2280
2257
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trilean",
3
3
  "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.",
4
- "version": "1.13.6",
4
+ "version": "1.13.7",
5
5
  "bin": {
6
6
  "trilean": "./dist-cli/trilean.mjs"
7
7
  },
@@ -9,7 +9,7 @@
9
9
  "url": "https://github.com/ExaDev/trilean/issues"
10
10
  },
11
11
  "dependencies": {
12
- "trilean-regex": "1.0.19",
12
+ "trilean-regex": "1.0.20",
13
13
  "zod": "^4.6.7"
14
14
  },
15
15
  "devDependencies": {
@@ -25,7 +25,7 @@
25
25
  "globals": "^17.13.0",
26
26
  "prettier": "^3.9.10",
27
27
  "publint": "^0.3.25",
28
- "tsdown": "^0.23.1",
28
+ "tsdown": "^0.23.7",
29
29
  "tsx": "^4.23.15",
30
30
  "turbo": "^2.11.10",
31
31
  "typescript": "^6.0.3",
@@ -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","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.13.6/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","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.13.7/schemas/trilean.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","oneOf":[{"$ref":"#/$defs/PredicateNode"},{"$ref":"#/$defs/ExpressionNode"}]}
@@ -1,51 +0,0 @@
1
- import { z } from "zod";
2
- //#region src/computed-value.d.ts
3
- /** Dimension symbol -\> exponent, e.g. `{ m: 1, s: -1 }` for metres per second. A bare symbol like `"kg"` is shorthand for `{ kg: 1 }`. */
4
- declare const UnitSchema: z.ZodRecord<z.ZodString, z.ZodNumber>;
5
- type Unit = z.infer<typeof UnitSchema>;
6
- declare const DurationUnitSchema: z.ZodEnum<{
7
- ms: "ms";
8
- s: "s";
9
- min: "min";
10
- h: "h";
11
- d: "d";
12
- }>;
13
- type DurationUnit = z.infer<typeof DurationUnitSchema>;
14
- declare const ComputedValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
15
- kind: z.ZodLiteral<"number">;
16
- value: z.ZodNumber;
17
- unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
18
- }, z.core.$strip>, z.ZodObject<{
19
- kind: z.ZodLiteral<"text">;
20
- value: z.ZodString;
21
- }, z.core.$strip>, z.ZodObject<{
22
- kind: z.ZodLiteral<"boolean">;
23
- value: z.ZodBoolean;
24
- }, z.core.$strip>, z.ZodObject<{
25
- kind: z.ZodLiteral<"instant">;
26
- value: z.ZodString;
27
- }, z.core.$strip>, z.ZodObject<{
28
- kind: z.ZodLiteral<"duration">;
29
- value: z.ZodNumber;
30
- unit: z.ZodEnum<{
31
- ms: "ms";
32
- s: "s";
33
- min: "min";
34
- h: "h";
35
- d: "d";
36
- }>;
37
- }, z.core.$strip>, z.ZodObject<{
38
- kind: z.ZodLiteral<"complex">;
39
- re: z.ZodNumber;
40
- im: z.ZodNumber;
41
- unit: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
42
- }, z.core.$strip>], "kind">;
43
- type ComputedValue = z.infer<typeof ComputedValueSchema>;
44
- /** An operand with no `unit` is dimensionless (an empty map) for comparison purposes. */
45
- declare function unitsEqual(a: Unit | undefined, b: Unit | undefined): boolean;
46
- /** Multiplying two unit-tagged numbers adds exponents per dimension. An operand with no `unit` is treated as dimensionless (an empty map). */
47
- declare function combineUnitsForMultiply(a: Unit | undefined, b: Unit | undefined): Unit;
48
- /** Dividing two unit-tagged numbers subtracts exponents per dimension. An operand with no `unit` is treated as dimensionless (an empty map). */
49
- declare function combineUnitsForDivide(a: Unit | undefined, b: Unit | undefined): Unit;
50
- //#endregion
51
- export { Unit as a, combineUnitsForMultiply as c, DurationUnitSchema as i, unitsEqual as l, ComputedValueSchema as n, UnitSchema as o, DurationUnit as r, combineUnitsForDivide as s, ComputedValue as t };
@@ -1,11 +0,0 @@
1
- import { z } from "zod";
2
- //#region src/json-value.d.ts
3
- /**
4
- * A JSON value with no further meaning imposed by this schema -- used for every opaque payload (reference keys, table identifiers, collection references, delegation payloads). "Opaque" means "uninterpreted by this package", not "untyped" -- every one of these must still be plain, serialisable JSON.
5
- */
6
- type JsonValue = string | number | boolean | null | JsonValue[] | {
7
- [key: string]: JsonValue;
8
- };
9
- declare const JsonValueSchema: z.ZodType<JsonValue>;
10
- //#endregion
11
- export { JsonValueSchema as n, JsonValue as t };