trilean 1.13.12 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/evaluator-operations.js +24 -4
  3. package/dist-cli/trilean.mjs +25 -5
  4. package/package.json +10 -20
  5. package/schemas/trilean.schema.json +1 -1
  6. package/dist/builtin-functions.cjs +0 -242
  7. package/dist/builtin-functions.d.cts +0 -13
  8. package/dist/complex-division.cjs +0 -47
  9. package/dist/complex-division.d.cts +0 -23
  10. package/dist/complex.cjs +0 -35
  11. package/dist/complex.d.cts +0 -23
  12. package/dist/computed-value.cjs +0 -80
  13. package/dist/computed-value.d.cts +0 -48
  14. package/dist/derived-aggregates.cjs +0 -73
  15. package/dist/derived-aggregates.d.cts +0 -9
  16. package/dist/derived-connectives.cjs +0 -39
  17. package/dist/derived-connectives.d.cts +0 -14
  18. package/dist/derived-patterns.cjs +0 -93
  19. package/dist/derived-patterns.d.cts +0 -4
  20. package/dist/derived-values.cjs +0 -23
  21. package/dist/derived-values.d.cts +0 -7
  22. package/dist/dist-ed78Tuwe.js +0 -1612
  23. package/dist/dist-ySX7cb5d.cjs +0 -1612
  24. package/dist/duration-order.cjs +0 -83
  25. package/dist/duration-order.d.cts +0 -21
  26. package/dist/evaluate-document.cjs +0 -92
  27. package/dist/evaluate-document.d.cts +0 -42
  28. package/dist/evaluation.cjs +0 -47
  29. package/dist/evaluation.d.cts +0 -29
  30. package/dist/evaluator-budget.cjs +0 -37
  31. package/dist/evaluator-budget.d.cts +0 -22
  32. package/dist/evaluator-collection.cjs +0 -33
  33. package/dist/evaluator-collection.d.cts +0 -21
  34. package/dist/evaluator-compiled.cjs +0 -310
  35. package/dist/evaluator-compiled.d.cts +0 -18
  36. package/dist/evaluator-effect.cjs +0 -57
  37. package/dist/evaluator-effect.d.cts +0 -40
  38. package/dist/evaluator-factory.cjs +0 -31
  39. package/dist/evaluator-factory.d.cts +0 -34
  40. package/dist/evaluator-literals.cjs +0 -42
  41. package/dist/evaluator-literals.d.cts +0 -8
  42. package/dist/evaluator-operations.cjs +0 -440
  43. package/dist/evaluator-operations.d.cts +0 -27
  44. package/dist/evaluator-test-helpers.cjs +0 -15030
  45. package/dist/evaluator-test-helpers.d.cts +0 -10
  46. package/dist/evaluator-test-helpers.d.ts +0 -10
  47. package/dist/evaluator-test-helpers.js +0 -14902
  48. package/dist/evaluator.cjs +0 -228
  49. package/dist/evaluator.d.cts +0 -12
  50. package/dist/functions.cjs +0 -4
  51. package/dist/functions.d.cts +0 -12
  52. package/dist/index.cjs +0 -97
  53. package/dist/index.d.cts +0 -18
  54. package/dist/input-resolvers.cjs +0 -109
  55. package/dist/input-resolvers.d.cts +0 -22
  56. package/dist/integer-power.cjs +0 -19
  57. package/dist/integer-power.d.cts +0 -11
  58. package/dist/json-value.cjs +0 -12
  59. package/dist/json-value.d.cts +0 -8
  60. package/dist/plain-record.cjs +0 -7
  61. package/dist/plain-record.d.cts +0 -2
  62. package/dist/resolvers.cjs +0 -0
  63. package/dist/resolvers.d.cts +0 -54
  64. package/dist/tree.cjs +0 -332
  65. package/dist/tree.d.cts +0 -446
@@ -1,228 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_evaluation = require("./evaluation.cjs");
3
- const require_evaluator_budget = require("./evaluator-budget.cjs");
4
- const require_evaluator_collection = require("./evaluator-collection.cjs");
5
- const require_evaluator_operations = require("./evaluator-operations.cjs");
6
- const require_evaluator_literals = require("./evaluator-literals.cjs");
7
- const require_evaluator_effect = require("./evaluator-effect.cjs");
8
- const require_tree = require("./tree.cjs");
9
- // src/evaluator.ts
10
- /**
11
- * `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`.
12
- */
13
- function* evaluatePredicateInternal(node, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth) {
14
- const budgetExceeded = budget.checkNode(nestingDepth);
15
- if (budgetExceeded !== void 0) return budgetExceeded;
16
- switch (node.kind) {
17
- case "not": {
18
- const operand = yield* evaluatePredicateInternal(node.operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
19
- if (operand.status === "indeterminate") return operand;
20
- return require_evaluation.definite(!operand.value);
21
- }
22
- case "and": {
23
- const [left, right] = yield* require_evaluator_effect.all([evaluatePredicateInternal(node.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluatePredicateInternal(node.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
24
- return require_evaluator_operations.combineAnd(left, right);
25
- }
26
- case "or": {
27
- const [left, right] = yield* require_evaluator_effect.all([evaluatePredicateInternal(node.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluatePredicateInternal(node.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
28
- return require_evaluator_operations.combineOr(left, right);
29
- }
30
- case "allOf": return (yield* require_evaluator_effect.all(node.operands.map((operand) => evaluatePredicateInternal(operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)))).reduce(require_evaluator_operations.combineAnd, require_evaluation.definite(true));
31
- case "anyOf": return (yield* require_evaluator_effect.all(node.operands.map((operand) => evaluatePredicateInternal(operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)))).reduce(require_evaluator_operations.combineOr, require_evaluation.definite(false));
32
- case "compare": {
33
- const [left, right] = yield* require_evaluator_effect.all([evaluateValueInternal(node.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluateValueInternal(node.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
34
- if (left.status === "indeterminate") return left;
35
- if (right.status === "indeterminate") return right;
36
- return require_evaluator_operations.compareValues(node.op, left.value, right.value);
37
- }
38
- case "textCompare": {
39
- const [left, right] = yield* require_evaluator_effect.all([evaluateValueInternal(node.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluateValueInternal(node.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
40
- if (left.status === "indeterminate") return left;
41
- if (right.status === "indeterminate") return right;
42
- return require_evaluator_operations.compareText(node.op, left.value, right.value);
43
- }
44
- case "memberOf": {
45
- const operandResult = yield* evaluateValueInternal(node.operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
46
- if (operandResult.status === "indeterminate") return operandResult;
47
- const candidateOutcomes = yield* require_evaluator_effect.all(node.candidates.map(function* (candidate) {
48
- const candidateResult = yield* evaluateValueInternal(candidate, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
49
- if (candidateResult.status === "indeterminate") return candidateResult;
50
- return require_evaluator_operations.computeMembershipMatch(operandResult.value, candidateResult.value);
51
- }));
52
- for (const outcome of candidateOutcomes) if (outcome.status === "definite" && outcome.value) return require_evaluation.definite(node.op === "in");
53
- const reason = require_evaluation.firstIndeterminate(...candidateOutcomes);
54
- if (reason !== void 0) return {
55
- status: "indeterminate",
56
- reason
57
- };
58
- return require_evaluation.definite(node.op === "notIn");
59
- }
60
- case "exists": {
61
- const operandResult = yield* evaluateValueInternal(node.operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
62
- if (operandResult.status === "indeterminate") {
63
- if (operandResult.reason.code === "not-yet-known" || require_evaluator_budget.isResourceExhaustion(operandResult.reason)) return operandResult;
64
- if (operandResult.reason.code === "not-found") return require_evaluation.definite(false);
65
- }
66
- return require_evaluation.definite(true);
67
- }
68
- case "some":
69
- case "every": {
70
- const participating = yield* require_evaluator_collection.resolveParticipatingItems(evaluatePredicateInternal, node.collection, node.filter, context, resolvers, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
71
- const votes = (yield* require_evaluator_effect.all(participating.map(function* ({ item, filterOutcome }) {
72
- if (filterOutcome === "exclude") return void 0;
73
- if (filterOutcome !== "include") return filterOutcome;
74
- return yield* evaluatePredicateInternal(node.item, item, resolvers, void 0, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
75
- }))).filter((vote) => vote !== void 0);
76
- const combine = node.kind === "some" ? require_evaluator_operations.combineOr : require_evaluator_operations.combineAnd;
77
- const identity = node.kind === "some" ? require_evaluation.definite(false) : require_evaluation.definite(true);
78
- return votes.reduce(combine, identity);
79
- }
80
- case "treeReference": {
81
- if (resolvers.resolveTree === void 0) return require_evaluation.indeterminate("wrong-type", "no tree resolver registered for treeReference nodes");
82
- const keyString = JSON.stringify(node.key);
83
- if (visitedTreeKeys.has(keyString)) return require_evaluation.indeterminate("domain-error", "circular treeReference detected");
84
- if (treeReferenceDepth >= 100) return require_evaluator_budget.resourceExhausted(`treeReference chain exceeds the maximum depth of ${100 .toString()}`);
85
- const resolution = yield* require_evaluator_effect.wait(resolvers.resolveTree(node.key, context));
86
- if (!resolution.found) return require_evaluator_operations.absenceEvaluation(resolution, "treeReference key did not resolve to a tree", "the tree for the treeReference key is not yet known");
87
- const parsed = require_tree.PredicateNodeSchema.safeParse(resolution.node);
88
- if (!parsed.success) return require_evaluation.indeterminate("wrong-type", "the referenced tree is not a valid PredicateNode");
89
- return yield* evaluatePredicateInternal(parsed.data, context, resolvers, accumulator, functions, /* @__PURE__ */ new Set([...visitedTreeKeys, keyString]), treeReferenceDepth + 1, budget, nestingDepth + 1);
90
- }
91
- default: throw new Error("unreachable predicate node kind");
92
- }
93
- }
94
- function* evaluateValueInternal(node, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth) {
95
- const budgetExceeded = budget.checkNode(nestingDepth);
96
- if (budgetExceeded !== void 0) return budgetExceeded;
97
- switch (node.kind) {
98
- case "reference": {
99
- const resolution = yield* require_evaluator_effect.wait(resolvers.resolveValue(node.key, context));
100
- if (!resolution.found) return require_evaluator_operations.absenceEvaluation(resolution, `no value found for reference key ${JSON.stringify(node.key)}`, `the value for reference key ${JSON.stringify(node.key)} is not yet known`);
101
- const unitError = require_evaluator_operations.checkReferenceUnit(node.unit, resolution.value);
102
- if (unitError !== void 0) return unitError;
103
- return require_evaluation.definite(resolution.value);
104
- }
105
- case "accumulator":
106
- if (accumulator === void 0) return require_evaluation.indeterminate("wrong-type", "accumulator used outside a reduce fold's combine expression");
107
- return require_evaluation.definite(accumulator);
108
- case "call": {
109
- const argResults = yield* require_evaluator_effect.all(node.args.map((arg) => evaluateValueInternal(arg, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)));
110
- const args = [];
111
- for (const result of argResults) {
112
- if (result.status === "indeterminate") return result;
113
- args.push(result.value);
114
- }
115
- return require_evaluator_operations.invokeRegisteredFunction(functions, node.fn, args);
116
- }
117
- case "numberLiteral":
118
- case "textLiteral":
119
- case "booleanLiteral":
120
- case "instantLiteral":
121
- case "durationLiteral":
122
- case "complexLiteral": return require_evaluation.definite(require_evaluator_literals.literalValue(node));
123
- case "arithmetic": {
124
- const [left, right] = yield* require_evaluator_effect.all([evaluateValueInternal(node.left, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1), evaluateValueInternal(node.right, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)]);
125
- if (left.status === "indeterminate") return left;
126
- if (right.status === "indeterminate") return right;
127
- return require_evaluator_operations.applyArithmetic(node.op, left.value, right.value);
128
- }
129
- case "negate": {
130
- const operand = yield* evaluateValueInternal(node.operand, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
131
- if (operand.status === "indeterminate") return operand;
132
- return require_evaluator_operations.applyNegate(operand.value);
133
- }
134
- case "lookup": {
135
- const keyResults = yield* require_evaluator_effect.all(node.keys.map((key) => evaluateValueInternal(key, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)));
136
- const keyValues = [];
137
- for (const result of keyResults) {
138
- if (result.status === "indeterminate") return result;
139
- keyValues.push(result.value);
140
- }
141
- const resolution = yield* require_evaluator_effect.wait(resolvers.resolveLookup(node.table, keyValues, context));
142
- if (!resolution.found) return require_evaluator_operations.absenceEvaluation(resolution, `no match found in lookup table ${JSON.stringify(node.table)}`, `the match in lookup table ${JSON.stringify(node.table)} is not yet known`);
143
- return require_evaluation.definite(resolution.value);
144
- }
145
- case "conditional": {
146
- if ((node.hitPolicy ?? "first") === "first") {
147
- for (const { when, then } of node.cases) {
148
- const whenResult = yield* evaluatePredicateInternal(when, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
149
- if (whenResult.status === "indeterminate") return whenResult;
150
- if (whenResult.value) return yield* evaluateValueInternal(then, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
151
- }
152
- return yield* evaluateValueInternal(node.fallback, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
153
- }
154
- const evaluatedCases = yield* require_evaluator_effect.all(node.cases.map(function* ({ when, then }) {
155
- return {
156
- then,
157
- whenResult: yield* evaluatePredicateInternal(when, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1)
158
- };
159
- }));
160
- const matches = evaluatedCases.filter(({ whenResult }) => whenResult.status === "definite" && whenResult.value);
161
- if (matches.length >= 2) return require_evaluation.indeterminate("domain-error", "more than one case matched under the 'unique' hit policy");
162
- const reason = require_evaluation.firstIndeterminate(...evaluatedCases.map(({ whenResult }) => whenResult));
163
- if (reason !== void 0) return {
164
- status: "indeterminate",
165
- reason
166
- };
167
- const [match] = matches;
168
- if (match === void 0) return yield* evaluateValueInternal(node.fallback, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
169
- return yield* evaluateValueInternal(match.then, context, resolvers, accumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
170
- }
171
- case "fold": {
172
- const participating = yield* require_evaluator_collection.resolveParticipatingItems(evaluatePredicateInternal, node.collection, node.filter, context, resolvers, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
173
- const filterIndeterminateReason = require_evaluator_collection.firstFilterIndeterminate(participating);
174
- if (filterIndeterminateReason !== void 0) return {
175
- status: "indeterminate",
176
- reason: filterIndeterminateReason
177
- };
178
- const includedItems = participating.filter(({ filterOutcome }) => filterOutcome === "include").map(({ item }) => item);
179
- if (node.combiner.mode === "reduce") {
180
- const initialResult = yield* evaluateValueInternal(node.combiner.initial, context, resolvers, void 0, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
181
- if (initialResult.status === "indeterminate") return initialResult;
182
- let runningAccumulator = initialResult.value;
183
- for (const item of includedItems) {
184
- const stepResult = yield* evaluateValueInternal(node.combiner.combine, item, resolvers, runningAccumulator, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
185
- if (stepResult.status === "indeterminate") return stepResult;
186
- runningAccumulator = stepResult.value;
187
- }
188
- return require_evaluation.definite(runningAccumulator);
189
- }
190
- if (includedItems.length === 0) return require_evaluation.indeterminate("domain-error", `'${node.combiner.mode}' has no participating items to seed a running result from`);
191
- const dominatesOp = node.combiner.mode === "max" ? "gt" : "lt";
192
- let runningExtremum;
193
- for (const item of includedItems) {
194
- const itemResult = yield* evaluateValueInternal(node.combiner.item, item, resolvers, void 0, functions, visitedTreeKeys, treeReferenceDepth, budget, nestingDepth + 1);
195
- if (itemResult.status === "indeterminate") return itemResult;
196
- if (runningExtremum === void 0) {
197
- runningExtremum = itemResult.value;
198
- continue;
199
- }
200
- const comparison = require_evaluator_operations.compareValues(dominatesOp, itemResult.value, runningExtremum);
201
- if (comparison.status === "indeterminate") return comparison;
202
- if (comparison.value) runningExtremum = itemResult.value;
203
- }
204
- if (runningExtremum === void 0) throw new Error("unreachable: max/min over a non-empty participating list produced no running result");
205
- return require_evaluation.definite(runningExtremum);
206
- }
207
- case "delegate": {
208
- if (resolvers.resolveDelegate === void 0) return require_evaluation.indeterminate("wrong-type", `no delegate handler registered for external system '${node.system}'`);
209
- const resolution = yield* require_evaluator_effect.wait(resolvers.resolveDelegate(node.system, node.payload, context));
210
- if (!resolution.found) return require_evaluator_operations.absenceEvaluation(resolution, `delegate handler for external system '${node.system}' reported no value`, `the value from the delegate handler for external system '${node.system}' is not yet known`);
211
- return require_evaluation.definite(resolution.value);
212
- }
213
- case "treeReference": {
214
- if (resolvers.resolveTree === void 0) return require_evaluation.indeterminate("wrong-type", "no tree resolver registered for treeReference nodes");
215
- const keyString = JSON.stringify(node.key);
216
- if (visitedTreeKeys.has(keyString)) return require_evaluation.indeterminate("domain-error", "circular treeReference detected");
217
- if (treeReferenceDepth >= 100) return require_evaluator_budget.resourceExhausted(`treeReference chain exceeds the maximum depth of ${100 .toString()}`);
218
- const resolution = yield* require_evaluator_effect.wait(resolvers.resolveTree(node.key, context));
219
- if (!resolution.found) return require_evaluator_operations.absenceEvaluation(resolution, "treeReference key did not resolve to a tree", "the tree for the treeReference key is not yet known");
220
- const parsed = require_tree.ExpressionNodeSchema.safeParse(resolution.node);
221
- if (!parsed.success) return require_evaluation.indeterminate("wrong-type", "the referenced tree is not a valid ExpressionNode");
222
- return yield* evaluateValueInternal(parsed.data, context, resolvers, accumulator, functions, /* @__PURE__ */ new Set([...visitedTreeKeys, keyString]), treeReferenceDepth + 1, budget, nestingDepth + 1);
223
- }
224
- default: throw new Error("unreachable expression node kind");
225
- }
226
- }
227
- exports.evaluatePredicateInternal = evaluatePredicateInternal;
228
- exports.evaluateValueInternal = evaluateValueInternal;
@@ -1,12 +0,0 @@
1
- import { ComputedValue } from "./computed-value.cjs";
2
- import { Evaluation } from "./evaluation.cjs";
3
- import { EvaluationBudget } from "./evaluator-budget.cjs";
4
- import { FunctionRegistry } from "./functions.cjs";
5
- import { Task } from "./evaluator-effect.cjs";
6
- import { EvaluationContext, EvaluatorResolvers } from "./resolvers.cjs";
7
- import { ExpressionNode, PredicateNode } from "./tree.cjs";
8
- /**
9
- * `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`.
10
- */
11
- export declare function evaluatePredicateInternal(node: PredicateNode, context: EvaluationContext, resolvers: Readonly<EvaluatorResolvers>, accumulator: ComputedValue | undefined, functions: Readonly<FunctionRegistry>, visitedTreeKeys: ReadonlySet<string>, treeReferenceDepth: number, budget: Readonly<EvaluationBudget>, nestingDepth: number): Task<Evaluation<boolean>>;
12
- export declare function evaluateValueInternal(node: ExpressionNode, context: EvaluationContext, resolvers: Readonly<EvaluatorResolvers>, accumulator: ComputedValue | undefined, functions: Readonly<FunctionRegistry>, visitedTreeKeys: ReadonlySet<string>, treeReferenceDepth: number, budget: Readonly<EvaluationBudget>, nestingDepth: number): Task<Evaluation<ComputedValue>>;
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- // src/functions.ts
3
- const emptyFunctionRegistry = {};
4
- exports.emptyFunctionRegistry = emptyFunctionRegistry;
@@ -1,12 +0,0 @@
1
- import { ComputedValue } from "./computed-value.cjs";
2
- /** What a registered function returns instead of a value when it cannot produce one: a `domainError` for an argument of the right kind outside the function's domain (`squareRoot` of a negative number), or a `wrongType` for an argument the function cannot accept at all (the wrong kind, or units that do not match). They surface as `domain-error` and `wrong-type` respectively, the same split every other node kind draws. */
3
- export type FunctionFailure = {
4
- domainError: string;
5
- } | {
6
- wrongType: string;
7
- };
8
- /**
9
- * Named functions available to a `call` expression node, supplied once at evaluator construction time (see `createEvaluator` in evaluator-factory.ts) rather than per evaluation call. A function reports a failure by returning a `FunctionFailure` rather than throwing, which keeps `call` inside the same three-outcome model as every other node kind.
10
- */
11
- export type FunctionRegistry = Record<string, (args: readonly ComputedValue[]) => ComputedValue | FunctionFailure>;
12
- export declare const emptyFunctionRegistry: FunctionRegistry;
package/dist/index.cjs DELETED
@@ -1,97 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_json_value = require("./json-value.cjs");
3
- const require_evaluation = require("./evaluation.cjs");
4
- const require_computed_value = require("./computed-value.cjs");
5
- const require_functions = require("./functions.cjs");
6
- const require_builtin_functions = require("./builtin-functions.cjs");
7
- const require_input_resolvers = require("./input-resolvers.cjs");
8
- const require_evaluate_document = require("./evaluate-document.cjs");
9
- const require_evaluator_factory = require("./evaluator-factory.cjs");
10
- const require_evaluator_budget = require("./evaluator-budget.cjs");
11
- const require_derived_connectives = require("./derived-connectives.cjs");
12
- const require_derived_aggregates = require("./derived-aggregates.cjs");
13
- const require_derived_values = require("./derived-values.cjs");
14
- const require_derived_patterns = require("./derived-patterns.cjs");
15
- const require_complex = require("./complex.cjs");
16
- const require_tree = require("./tree.cjs");
17
- exports.AccumulatorNodeSchema = require_tree.AccumulatorNodeSchema;
18
- exports.AllOfNodeSchema = require_tree.AllOfNodeSchema;
19
- exports.AndNodeSchema = require_tree.AndNodeSchema;
20
- exports.AnyOfNodeSchema = require_tree.AnyOfNodeSchema;
21
- exports.ArithmeticNodeSchema = require_tree.ArithmeticNodeSchema;
22
- exports.ArithmeticOperatorSchema = require_tree.ArithmeticOperatorSchema;
23
- exports.BooleanLiteralNodeSchema = require_tree.BooleanLiteralNodeSchema;
24
- exports.CallNodeSchema = require_tree.CallNodeSchema;
25
- exports.CompareNodeSchema = require_tree.CompareNodeSchema;
26
- exports.ComparisonOperatorSchema = require_tree.ComparisonOperatorSchema;
27
- exports.ComplexLiteralNodeSchema = require_tree.ComplexLiteralNodeSchema;
28
- exports.ComplexPolarLiteralNodeSchema = require_tree.ComplexPolarLiteralNodeSchema;
29
- exports.ComplexRectangularLiteralNodeSchema = require_tree.ComplexRectangularLiteralNodeSchema;
30
- exports.ComputedValueSchema = require_computed_value.ComputedValueSchema;
31
- exports.ConditionalCaseSchema = require_tree.ConditionalCaseSchema;
32
- exports.ConditionalNodeSchema = require_tree.ConditionalNodeSchema;
33
- exports.DEFAULT_MAX_EVALUATION_NODES = require_evaluator_budget.DEFAULT_MAX_EVALUATION_NODES;
34
- exports.DEFAULT_MAX_NESTING_DEPTH = require_evaluator_budget.DEFAULT_MAX_NESTING_DEPTH;
35
- exports.DelegateNodeSchema = require_tree.DelegateNodeSchema;
36
- exports.DurationLiteralNodeSchema = require_tree.DurationLiteralNodeSchema;
37
- exports.DurationUnitSchema = require_computed_value.DurationUnitSchema;
38
- exports.EveryNodeSchema = require_tree.EveryNodeSchema;
39
- exports.ExistsNodeSchema = require_tree.ExistsNodeSchema;
40
- exports.ExpressionNodeSchema = require_tree.ExpressionNodeSchema;
41
- exports.FoldCombinerSchema = require_tree.FoldCombinerSchema;
42
- exports.FoldNodeSchema = require_tree.FoldNodeSchema;
43
- exports.HitPolicySchema = require_tree.HitPolicySchema;
44
- exports.IndeterminateReasonSchema = require_evaluation.IndeterminateReasonSchema;
45
- exports.InstantLiteralNodeSchema = require_tree.InstantLiteralNodeSchema;
46
- exports.JsonValueSchema = require_json_value.JsonValueSchema;
47
- exports.LookupNodeSchema = require_tree.LookupNodeSchema;
48
- exports.MemberOfNodeSchema = require_tree.MemberOfNodeSchema;
49
- exports.MembershipOperatorSchema = require_tree.MembershipOperatorSchema;
50
- exports.NegateNodeSchema = require_tree.NegateNodeSchema;
51
- exports.NotNodeSchema = require_tree.NotNodeSchema;
52
- exports.NumberLiteralNodeSchema = require_tree.NumberLiteralNodeSchema;
53
- exports.OrNodeSchema = require_tree.OrNodeSchema;
54
- exports.PredicateNodeSchema = require_tree.PredicateNodeSchema;
55
- exports.ReferenceNodeSchema = require_tree.ReferenceNodeSchema;
56
- exports.SomeNodeSchema = require_tree.SomeNodeSchema;
57
- exports.TextCompareNodeSchema = require_tree.TextCompareNodeSchema;
58
- exports.TextComparisonOperatorSchema = require_tree.TextComparisonOperatorSchema;
59
- exports.TextLiteralNodeSchema = require_tree.TextLiteralNodeSchema;
60
- exports.TreeReferenceNodeSchema = require_tree.TreeReferenceNodeSchema;
61
- exports.UnitSchema = require_computed_value.UnitSchema;
62
- exports.and = require_derived_connectives.and;
63
- exports.average = require_derived_aggregates.average;
64
- exports.builtinFunctions = require_builtin_functions.builtinFunctions;
65
- exports.coalesce = require_derived_values.coalesce;
66
- exports.combineUnitsForDivide = require_computed_value.combineUnitsForDivide;
67
- exports.combineUnitsForMultiply = require_computed_value.combineUnitsForMultiply;
68
- exports.complexFromPolar = require_complex.complexFromPolar;
69
- exports.complexLiteralFromPolar = require_complex.complexLiteralFromPolar;
70
- exports.complexMagnitude = require_complex.complexMagnitude;
71
- exports.complexPhase = require_complex.complexPhase;
72
- exports.count = require_derived_aggregates.count;
73
- exports.createEvaluator = require_evaluator_factory.createEvaluator;
74
- exports.createInputResolvers = require_input_resolvers.createInputResolvers;
75
- exports.createSyncEvaluator = require_evaluator_factory.createSyncEvaluator;
76
- exports.definite = require_evaluation.definite;
77
- exports.emptyFunctionRegistry = require_functions.emptyFunctionRegistry;
78
- exports.evaluateDocument = require_evaluate_document.evaluateDocument;
79
- exports.evaluatePredicate = require_evaluator_factory.evaluatePredicate;
80
- exports.evaluateValue = require_evaluator_factory.evaluateValue;
81
- exports.firstIndeterminate = require_evaluation.firstIndeterminate;
82
- exports.hierarchicalGlobPattern = require_derived_patterns.hierarchicalGlobPattern;
83
- exports.iff = require_derived_connectives.iff;
84
- exports.implies = require_derived_connectives.implies;
85
- exports.indeterminate = require_evaluation.indeterminate;
86
- exports.nand = require_derived_connectives.nand;
87
- exports.none = require_derived_connectives.none;
88
- exports.nor = require_derived_connectives.nor;
89
- exports.not = require_derived_connectives.not;
90
- exports.or = require_derived_connectives.or;
91
- exports.parseInputs = require_input_resolvers.parseInputs;
92
- exports.prefixPattern = require_derived_patterns.prefixPattern;
93
- exports.presenceOf = require_derived_aggregates.presenceOf;
94
- exports.sum = require_derived_aggregates.sum;
95
- exports.unitsEqual = require_computed_value.unitsEqual;
96
- exports.wildcardPattern = require_derived_patterns.wildcardPattern;
97
- exports.xor = require_derived_connectives.xor;
package/dist/index.d.cts DELETED
@@ -1,18 +0,0 @@
1
- import { JsonValue, JsonValueSchema } from "./json-value.cjs";
2
- import { Evaluation, IndeterminateReason, IndeterminateReasonSchema, definite, firstIndeterminate, indeterminate } from "./evaluation.cjs";
3
- import { ComputedValue, ComputedValueSchema, DurationUnit, DurationUnitSchema, Unit, UnitSchema, combineUnitsForDivide, combineUnitsForMultiply, unitsEqual } from "./computed-value.cjs";
4
- import { Absence, EvaluationContext, Resolution, Resolvers, SyncResolvers, TreeResolution } from "./resolvers.cjs";
5
- import { FunctionFailure, FunctionRegistry, emptyFunctionRegistry } from "./functions.cjs";
6
- import { builtinFunctions } from "./builtin-functions.cjs";
7
- import { InputItem, InputsParseResult, createInputResolvers, parseInputs } from "./input-resolvers.cjs";
8
- import { DocumentEvaluation, EvaluateDocumentOptions, TreeKind, evaluateDocument } from "./evaluate-document.cjs";
9
- import { EvaluatorOptions, createEvaluator, createSyncEvaluator, evaluatePredicate, evaluateValue } from "./evaluator-factory.cjs";
10
- import { CompiledPredicate } from "./evaluator-compiled.cjs";
11
- import { DEFAULT_MAX_EVALUATION_NODES, DEFAULT_MAX_NESTING_DEPTH } from "./evaluator-budget.cjs";
12
- import { and, iff, implies, nand, none, nor, not, or, xor } from "./derived-connectives.cjs";
13
- import { average, count, presenceOf, sum } from "./derived-aggregates.cjs";
14
- import { coalesce } from "./derived-values.cjs";
15
- import { hierarchicalGlobPattern, prefixPattern, wildcardPattern } from "./derived-patterns.cjs";
16
- import { complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase } from "./complex.cjs";
17
- import { 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 } from "./tree.cjs";
18
- export { type Absence, type AccumulatorNode, AccumulatorNodeSchema, type AllOfNode, AllOfNodeSchema, type AndNode, AndNodeSchema, type AnyOfNode, AnyOfNodeSchema, type ArithmeticNode, ArithmeticNodeSchema, type ArithmeticOperator, ArithmeticOperatorSchema, type BooleanLiteralNode, BooleanLiteralNodeSchema, type CallNode, CallNodeSchema, type CompareNode, CompareNodeSchema, type ComparisonOperator, ComparisonOperatorSchema, type CompiledPredicate, type ComplexLiteralNode, ComplexLiteralNodeSchema, type ComplexPolarLiteralNode, ComplexPolarLiteralNodeSchema, type ComplexRectangularLiteralNode, ComplexRectangularLiteralNodeSchema, type ComputedValue, ComputedValueSchema, type ConditionalCase, ConditionalCaseSchema, type ConditionalNode, ConditionalNodeSchema, DEFAULT_MAX_EVALUATION_NODES, DEFAULT_MAX_NESTING_DEPTH, type DelegateNode, DelegateNodeSchema, type DocumentEvaluation, type DurationLiteralNode, DurationLiteralNodeSchema, type DurationUnit, DurationUnitSchema, type EvaluateDocumentOptions, type Evaluation, type EvaluationContext, type EvaluatorOptions, type EveryNode, EveryNodeSchema, type ExistsNode, ExistsNodeSchema, type ExpressionNode, ExpressionNodeSchema, type FoldCombiner, FoldCombinerSchema, type FoldNode, FoldNodeSchema, type FunctionFailure, type FunctionRegistry, type HitPolicy, HitPolicySchema, type IndeterminateReason, IndeterminateReasonSchema, type InputItem, type InputsParseResult, type InstantLiteralNode, InstantLiteralNodeSchema, type JsonValue, JsonValueSchema, type LookupNode, LookupNodeSchema, type MemberOfNode, MemberOfNodeSchema, type MembershipOperator, MembershipOperatorSchema, type NegateNode, NegateNodeSchema, type NotNode, NotNodeSchema, type NumberLiteralNode, NumberLiteralNodeSchema, type OrNode, OrNodeSchema, type PredicateNode, PredicateNodeSchema, type ReferenceNode, ReferenceNodeSchema, type Resolution, type Resolvers, type SomeNode, SomeNodeSchema, type SyncResolvers, type TextCompareNode, TextCompareNodeSchema, type TextComparisonOperator, TextComparisonOperatorSchema, type TextLiteralNode, TextLiteralNodeSchema, type TreeKind, type TreeReferenceNode, TreeReferenceNodeSchema, type TreeResolution, type Unit, UnitSchema, and, average, builtinFunctions, coalesce, combineUnitsForDivide, combineUnitsForMultiply, complexFromPolar, complexLiteralFromPolar, complexMagnitude, complexPhase, count, createEvaluator, createInputResolvers, createSyncEvaluator, definite, emptyFunctionRegistry, evaluateDocument, evaluatePredicate, evaluateValue, firstIndeterminate, hierarchicalGlobPattern, iff, implies, indeterminate, nand, none, nor, not, or, parseInputs, prefixPattern, presenceOf, sum, unitsEqual, wildcardPattern, xor };
@@ -1,109 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_computed_value = require("./computed-value.cjs");
3
- const require_plain_record = require("./plain-record.cjs");
4
- // src/input-resolvers.ts
5
- /** 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. */
6
- function toComputedValue(raw) {
7
- const candidate = typeof raw === "number" ? {
8
- kind: "number",
9
- value: raw
10
- } : typeof raw === "string" ? {
11
- kind: "text",
12
- value: raw
13
- } : typeof raw === "boolean" ? {
14
- kind: "boolean",
15
- value: raw
16
- } : raw;
17
- const parsed = require_computed_value.ComputedValueSchema.safeParse(candidate);
18
- return parsed.success ? parsed.data : void 0;
19
- }
20
- const NOT_A_VALUE = "expected a finite number, text, boolean or a complete computed value";
21
- /**
22
- * The evaluation context while a `fold`, `some` or `every` is evaluating one item. `resolveCollection` wraps each element in one of these, and `resolveValue` reads names from an item only when its context is one, so scope follows what the resolver itself handed out and not the identity or shape of anything else. The class is not exported, so no value passed as a context can be mistaken for an item. The guarantee is about this resolver's own `resolveCollection`: a list served by it is scoped, and the supported way to give it lists is the `collections` argument of `createInputResolvers`. An embedder that composes resolvers, spreading these and overriding `resolveCollection` to serve its own items while keeping this `resolveValue`, serves items that are not wrappers, and a fold over them reads names from the top-level inputs; scoping those items is the embedder's responsibility.
23
- */
24
- var ScopedItem = class {
25
- values;
26
- constructor(values) {
27
- this.values = values;
28
- }
29
- };
30
- /** Validates one element of a list input: a plain object whose every entry is a value, each by the same rules as a top-level input. */
31
- function parseItem(label, raw) {
32
- if (!require_plain_record.isPlainRecord(raw)) return {
33
- item: void 0,
34
- issues: [`${label}: expected an object of named values`]
35
- };
36
- const item = /* @__PURE__ */ new Map();
37
- const issues = [];
38
- for (const [name, value] of Object.entries(raw)) {
39
- const computed = toComputedValue(value);
40
- if (computed === void 0) issues.push(`${label}.${name}: ${NOT_A_VALUE}`);
41
- else item.set(name, computed);
42
- }
43
- if (issues.length > 0) return {
44
- item: void 0,
45
- issues
46
- };
47
- return {
48
- item,
49
- issues
50
- };
51
- }
52
- /**
53
- * Validates a plain object of inputs and splits it into named values and lists of items. An entry that is an array is a list: every element must be an object of named values (see `toComputedValue` for the accepted shapes of each value), and the list is what a `fold`, `some` or `every` resolves its `collection` to. Any other entry is one named value. Every entry is checked up front, so a malformed input is reported as one by name and position rather than surfacing later as a `not-found` reference.
54
- */
55
- function parseInputs(raw) {
56
- if (!require_plain_record.isPlainRecord(raw)) return {
57
- ok: false,
58
- issues: ["inputs must be a JSON object of named values"]
59
- };
60
- const inputs = /* @__PURE__ */ new Map();
61
- const collections = /* @__PURE__ */ new Map();
62
- const issues = [];
63
- for (const [name, value] of Object.entries(raw)) {
64
- if (Array.isArray(value)) {
65
- const items = [];
66
- value.forEach((element, index) => {
67
- const parsedItem = parseItem(`inputs.${name}[${String(index)}]`, element);
68
- issues.push(...parsedItem.issues);
69
- if (parsedItem.item !== void 0) items.push(parsedItem.item);
70
- });
71
- collections.set(name, items);
72
- continue;
73
- }
74
- const computed = toComputedValue(value);
75
- if (computed === void 0) issues.push(`inputs.${name}: ${NOT_A_VALUE}`);
76
- else inputs.set(name, computed);
77
- }
78
- return issues.length === 0 ? {
79
- ok: true,
80
- inputs,
81
- collections
82
- } : {
83
- ok: false,
84
- issues
85
- };
86
- }
87
- /**
88
- * Synchronous resolvers over named inputs and lists of items. A `reference` whose key is a string resolves to the value of that name: against the top-level inputs outside a `fold`, `some` or `every`, and against the current item alone inside one, since descending into a collection replaces the evaluation context with the item (an item does not see the top-level inputs, so a value an item needs is written into the item). Every other key, and every `lookup`, is `not-found`. `resolveCollection` returns the items the inputs hold under the collection's name, each wrapped so that only the wrapper this module created is read as an item (a list built by the embedder works the same as a parsed one), and throws for a collection the inputs do not hold: an empty list would silently change what a `fold`, `some` or `every` means, and a missing list is a mistake in the tree or the inputs, not an empty collection. `delegate` and `treeReference` nodes are left unresolved, so they are `wrong-type` like any node whose optional resolver is absent.
89
- */
90
- function createInputResolvers(inputs, collections = /* @__PURE__ */ new Map()) {
91
- return {
92
- resolveValue: (key, context) => {
93
- const scope = context instanceof ScopedItem ? context.values : inputs;
94
- const value = typeof key === "string" ? scope.get(key) : void 0;
95
- return value === void 0 ? { found: false } : {
96
- found: true,
97
- value
98
- };
99
- },
100
- resolveLookup: () => ({ found: false }),
101
- resolveCollection: (collection) => {
102
- const items = typeof collection === "string" ? collections.get(collection) : void 0;
103
- if (items === void 0) throw new Error(`collection ${JSON.stringify(collection)} cannot be resolved: the inputs hold no list of items under that name`);
104
- return items.map((values) => new ScopedItem(values));
105
- }
106
- };
107
- }
108
- exports.createInputResolvers = createInputResolvers;
109
- exports.parseInputs = parseInputs;
@@ -1,22 +0,0 @@
1
- import { ComputedValue } from "./computed-value.cjs";
2
- import { SyncResolvers } from "./resolvers.cjs";
3
- /** One element of a list input: the named values a `reference` resolves against while a `fold`, `some` or `every` is evaluating that element. */
4
- export type InputItem = ReadonlyMap<string, ComputedValue>;
5
- export type InputsParseResult = {
6
- ok: true;
7
- /** The named values: every entry that is not an array. */
8
- inputs: ReadonlyMap<string, ComputedValue>;
9
- /** The lists of items: every entry that is an array, which a `fold`, `some` or `every` names as its `collection`. */
10
- collections: ReadonlyMap<string, readonly InputItem[]>;
11
- } | {
12
- ok: false;
13
- issues: readonly string[];
14
- };
15
- /**
16
- * Validates a plain object of inputs and splits it into named values and lists of items. An entry that is an array is a list: every element must be an object of named values (see `toComputedValue` for the accepted shapes of each value), and the list is what a `fold`, `some` or `every` resolves its `collection` to. Any other entry is one named value. Every entry is checked up front, so a malformed input is reported as one by name and position rather than surfacing later as a `not-found` reference.
17
- */
18
- export declare function parseInputs(raw: unknown): InputsParseResult;
19
- /**
20
- * Synchronous resolvers over named inputs and lists of items. A `reference` whose key is a string resolves to the value of that name: against the top-level inputs outside a `fold`, `some` or `every`, and against the current item alone inside one, since descending into a collection replaces the evaluation context with the item (an item does not see the top-level inputs, so a value an item needs is written into the item). Every other key, and every `lookup`, is `not-found`. `resolveCollection` returns the items the inputs hold under the collection's name, each wrapped so that only the wrapper this module created is read as an item (a list built by the embedder works the same as a parsed one), and throws for a collection the inputs do not hold: an empty list would silently change what a `fold`, `some` or `every` means, and a missing list is a mistake in the tree or the inputs, not an empty collection. `delegate` and `treeReference` nodes are left unresolved, so they are `wrong-type` like any node whose optional resolver is absent.
21
- */
22
- export declare function createInputResolvers(inputs: ReadonlyMap<string, ComputedValue>, collections?: ReadonlyMap<string, readonly InputItem[]>): SyncResolvers;
@@ -1,19 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- // src/integer-power.ts
3
- /**
4
- * `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.
5
- *
6
- * The exponent is halved with `Math.floor(remaining / 2)` and tested for oddness with `% 2`, both exact for any finite double, including those past the largest safe integer, whose low bits are all zero. The last squaring is skipped, so no unused product is formed and a base too large to square is not squared once more than the result needs.
7
- */
8
- function powerByRepeatedSquaring({ base, exponent, identity, multiply }) {
9
- let result = identity;
10
- let factor = base;
11
- let remaining = exponent;
12
- while (remaining > 0) {
13
- if (remaining % 2 === 1) result = multiply(result, factor);
14
- remaining = Math.floor(remaining / 2);
15
- if (remaining > 0) factor = multiply(factor, factor);
16
- }
17
- return result;
18
- }
19
- exports.powerByRepeatedSquaring = powerByRepeatedSquaring;
@@ -1,11 +0,0 @@
1
- /**
2
- * `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.
3
- *
4
- * The exponent is halved with `Math.floor(remaining / 2)` and tested for oddness with `% 2`, both exact for any finite double, including those past the largest safe integer, whose low bits are all zero. The last squaring is skipped, so no unused product is formed and a base too large to square is not squared once more than the result needs.
5
- */
6
- export declare function powerByRepeatedSquaring<T>({ base, exponent, identity, multiply }: {
7
- base: T;
8
- exponent: number;
9
- identity: T;
10
- multiply: (left: T, right: T) => T;
11
- }): T;
@@ -1,12 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let zod = require("zod");
3
- // src/json-value.ts
4
- const JsonValueSchema = zod.z.lazy(() => zod.z.union([
5
- zod.z.string(),
6
- zod.z.number(),
7
- zod.z.boolean(),
8
- zod.z.null(),
9
- zod.z.array(JsonValueSchema),
10
- zod.z.record(zod.z.string(), JsonValueSchema)
11
- ]));
12
- exports.JsonValueSchema = JsonValueSchema;
@@ -1,8 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * 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.
4
- */
5
- export type JsonValue = string | number | boolean | null | JsonValue[] | {
6
- [key: string]: JsonValue;
7
- };
8
- export declare const JsonValueSchema: z.ZodType<JsonValue>;
@@ -1,7 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- // src/plain-record.ts
3
- /** 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. */
4
- function isPlainRecord(value) {
5
- return typeof value === "object" && value !== null && !Array.isArray(value);
6
- }
7
- exports.isPlainRecord = isPlainRecord;
@@ -1,2 +0,0 @@
1
- /** 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. */
2
- export declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
File without changes