@toiroakr/chisel 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +354 -21
- package/dist/absence.d.ts +28 -0
- package/dist/absence.js +266 -0
- package/dist/absence.js.map +1 -0
- package/dist/behavior.d.ts +26 -19
- package/dist/behavior.js +193 -203
- package/dist/behavior.js.map +1 -1
- package/dist/beside.d.ts +5 -0
- package/dist/beside.js +10 -0
- package/dist/beside.js.map +1 -1
- package/dist/border.d.ts +7 -8
- package/dist/border.js +88 -36
- package/dist/border.js.map +1 -1
- package/dist/bounds.d.ts +1 -0
- package/dist/bounds.js +27 -0
- package/dist/bounds.js.map +1 -0
- package/dist/changes.d.ts +23 -0
- package/dist/changes.js +355 -0
- package/dist/changes.js.map +1 -0
- package/dist/checks.d.ts +1 -0
- package/dist/checks.js +295 -0
- package/dist/checks.js.map +1 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +351 -14
- package/dist/cli.js.map +1 -1
- package/dist/codec.js +16 -7
- package/dist/codec.js.map +1 -1
- package/dist/codegen.js +6 -8
- package/dist/codegen.js.map +1 -1
- package/dist/composition.d.ts +3 -3
- package/dist/composition.js +9 -8
- package/dist/composition.js.map +1 -1
- package/dist/conformance.d.ts +24 -0
- package/dist/conformance.js +44 -0
- package/dist/conformance.js.map +1 -0
- package/dist/data.d.ts +3 -2
- package/dist/data.js +7 -3
- package/dist/data.js.map +1 -1
- package/dist/decimal-js.d.ts +2 -0
- package/dist/decimal-js.js +5 -0
- package/dist/decimal-js.js.map +1 -0
- package/dist/decimal.d.ts +2 -0
- package/dist/decimal.js +3 -0
- package/dist/decimal.js.map +1 -0
- package/dist/dependency.d.ts +9 -6
- package/dist/dependency.js +23 -17
- package/dist/dependency.js.map +1 -1
- package/dist/domain.d.ts +6 -2
- package/dist/domain.js +65 -25
- package/dist/domain.js.map +1 -1
- package/dist/ensures.js +3 -3
- package/dist/ensures.js.map +1 -1
- package/dist/equal.d.ts +1 -0
- package/dist/equal.js +135 -0
- package/dist/equal.js.map +1 -0
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/exact.d.ts +13 -1
- package/dist/exact.js +52 -3
- package/dist/exact.js.map +1 -1
- package/dist/feasibility.d.ts +5 -3
- package/dist/feasibility.js +309 -53
- package/dist/feasibility.js.map +1 -1
- package/dist/guard-borders.d.ts +14 -5
- package/dist/guard-borders.js +229 -190
- package/dist/guard-borders.js.map +1 -1
- package/dist/guard-scope.d.ts +65 -0
- package/dist/guard-scope.js +384 -0
- package/dist/guard-scope.js.map +1 -0
- package/dist/hooks.d.ts +22 -0
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +30 -8
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/dist/interleave.d.ts +31 -0
- package/dist/interleave.js +202 -0
- package/dist/interleave.js.map +1 -0
- package/dist/interval.d.ts +8 -0
- package/dist/interval.js +213 -23
- package/dist/interval.js.map +1 -1
- package/dist/isolated.d.ts +7 -1
- package/dist/isolated.js +53 -5
- package/dist/isolated.js.map +1 -1
- package/dist/kinds/decimal.d.ts +1 -0
- package/dist/kinds/decimal.js +16 -0
- package/dist/kinds/decimal.js.map +1 -0
- package/dist/kinds/rational.d.ts +1 -0
- package/dist/kinds/rational.js +13 -0
- package/dist/kinds/rational.js.map +1 -0
- package/dist/kinds/temporal.d.ts +1 -0
- package/dist/kinds/temporal.js +15 -0
- package/dist/kinds/temporal.js.map +1 -0
- package/dist/lean/behavior.d.ts +29 -0
- package/dist/lean/behavior.js +76 -0
- package/dist/lean/behavior.js.map +1 -0
- package/dist/lean/given.d.ts +10 -0
- package/dist/lean/given.js +15 -0
- package/dist/lean/given.js.map +1 -0
- package/dist/lean/index.d.ts +11 -0
- package/dist/lean/index.js +8 -0
- package/dist/lean/index.js.map +1 -0
- package/dist/lean/model.d.ts +20 -0
- package/dist/lean/model.js +133 -0
- package/dist/lean/model.js.map +1 -0
- package/dist/lean/protocol.d.ts +14 -0
- package/dist/lean/protocol.js +34 -0
- package/dist/lean/protocol.js.map +1 -0
- package/dist/lean/rule.d.ts +54 -0
- package/dist/lean/rule.js +149 -0
- package/dist/lean/rule.js.map +1 -0
- package/dist/lean/schema.d.ts +46 -0
- package/dist/lean/schema.js +155 -0
- package/dist/lean/schema.js.map +1 -0
- package/dist/machine-check.d.ts +73 -0
- package/dist/machine-check.js +215 -0
- package/dist/machine-check.js.map +1 -0
- package/dist/machine.d.ts +122 -0
- package/dist/machine.js +271 -0
- package/dist/machine.js.map +1 -0
- package/dist/model.d.ts +110 -11
- package/dist/model.js +724 -80
- package/dist/model.js.map +1 -1
- package/dist/off-grid.d.ts +4 -0
- package/dist/off-grid.js +92 -0
- package/dist/off-grid.js.map +1 -0
- package/dist/outcomes.d.ts +15 -0
- package/dist/outcomes.js +120 -0
- package/dist/outcomes.js.map +1 -0
- package/dist/pairs.js +14 -5
- package/dist/pairs.js.map +1 -1
- package/dist/partition.d.ts +1 -0
- package/dist/partition.js +101 -19
- package/dist/partition.js.map +1 -1
- package/dist/placeholders.d.ts +3 -0
- package/dist/placeholders.js +44 -0
- package/dist/placeholders.js.map +1 -0
- package/dist/proof.d.ts +6 -0
- package/dist/proof.js +282 -56
- package/dist/proof.js.map +1 -1
- package/dist/protocol.d.ts +22 -0
- package/dist/protocol.js +12 -0
- package/dist/protocol.js.map +1 -0
- package/dist/relations.d.ts +30 -0
- package/dist/relations.js +235 -0
- package/dist/relations.js.map +1 -0
- package/dist/replay.d.ts +45 -0
- package/dist/replay.js +157 -0
- package/dist/replay.js.map +1 -0
- package/dist/rewrites.d.ts +41 -0
- package/dist/rewrites.js +180 -0
- package/dist/rewrites.js.map +1 -0
- package/dist/rule.d.ts +74 -11
- package/dist/rule.js +429 -22
- package/dist/rule.js.map +1 -1
- package/dist/runtime.d.ts +12 -0
- package/dist/runtime.js +8 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schema.d.ts +44 -28
- package/dist/schema.js +50 -113
- package/dist/schema.js.map +1 -1
- package/dist/specification.d.ts +23 -3
- package/dist/specification.js +1001 -96
- package/dist/specification.js.map +1 -1
- package/dist/stops.d.ts +20 -0
- package/dist/stops.js +221 -0
- package/dist/stops.js.map +1 -0
- package/dist/temporal-global.d.ts +4 -0
- package/dist/temporal-global.js +11 -0
- package/dist/temporal-global.js.map +1 -0
- package/dist/temporal.d.ts +22 -0
- package/dist/temporal.js +113 -0
- package/dist/temporal.js.map +1 -0
- package/dist/tla-validate.d.ts +31 -0
- package/dist/tla-validate.js +151 -0
- package/dist/tla-validate.js.map +1 -0
- package/dist/tla.d.ts +61 -0
- package/dist/tla.js +722 -0
- package/dist/tla.js.map +1 -0
- package/dist/verification.d.ts +9 -0
- package/dist/verification.js +7 -0
- package/dist/verification.js.map +1 -0
- package/dist/ways.d.ts +11 -5
- package/dist/ways.js +51 -45
- package/dist/ways.js.map +1 -1
- package/dist/world.d.ts +98 -0
- package/dist/world.js +463 -0
- package/dist/world.js.map +1 -0
- package/package.json +49 -10
- package/schema/report.schema.json +169 -1
package/dist/rewrites.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { SpecificationError, performSync } from "./behavior.js";
|
|
2
|
+
import { childrenOf, iterationsOf, nodeOf, withWalk } from "./model.js";
|
|
3
|
+
import { describeTerm, isTerm, localLabel, pathsRead, termData } from "./rule.js";
|
|
4
|
+
import { schemaAtPath } from "./schema.js";
|
|
5
|
+
import { integralBounds } from "./domain.js";
|
|
6
|
+
import { isEvaluationLimit } from "./exact.js";
|
|
7
|
+
// The folds an implementation's models write, each once however many cases
|
|
8
|
+
// its decision decides, leaving out a fold that reads nothing a run is handed:
|
|
9
|
+
// it answers one value on every run, and so does either rewrite of it.
|
|
10
|
+
export function foldsOf(implementation) {
|
|
11
|
+
if (implementation === undefined || implementation.pipeline !== undefined || implementation.external !== undefined)
|
|
12
|
+
return [];
|
|
13
|
+
const decisions = new Map();
|
|
14
|
+
for (const [tag, decision] of Object.entries(implementation.cases ?? {})) {
|
|
15
|
+
if (decision?.kind !== "rules")
|
|
16
|
+
continue;
|
|
17
|
+
const tags = decisions.get(decision) ?? [];
|
|
18
|
+
tags.push(tag);
|
|
19
|
+
decisions.set(decision, tags);
|
|
20
|
+
}
|
|
21
|
+
const folds = [];
|
|
22
|
+
for (const [decision, tags] of decisions) {
|
|
23
|
+
const rules = decision;
|
|
24
|
+
const written = rules.runs ?? rules.expression;
|
|
25
|
+
if (written === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
for (const node of new Set(iterationsOf(written))) {
|
|
28
|
+
if (node.kind !== "fold")
|
|
29
|
+
continue;
|
|
30
|
+
const fold = node;
|
|
31
|
+
if (!readsRun(fold))
|
|
32
|
+
continue;
|
|
33
|
+
const values = fold.values;
|
|
34
|
+
const label = isTerm(values) ? `fold over ${termLabel(values)}` : "fold";
|
|
35
|
+
const position = isTerm(values) ? termData(values) : undefined;
|
|
36
|
+
const over = position?.kind === "position" && position.measure === "value" && !position.path[0].startsWith("#") ? position.path : undefined;
|
|
37
|
+
// A list written with one element or none, or an input list every case
|
|
38
|
+
// the fold walks holds to one element at most, takes no second step.
|
|
39
|
+
const written = Array.isArray(values) && nodeOf(values) === undefined && values.length <= 1;
|
|
40
|
+
const bounded = over !== undefined && tags.every(tag => {
|
|
41
|
+
const list = schemaAtPath(implementation.behavior.input.variants[tag], over);
|
|
42
|
+
const upper = list === undefined ? undefined : integralBounds(list, "length").upper;
|
|
43
|
+
return upper !== undefined && upper <= 1;
|
|
44
|
+
});
|
|
45
|
+
const single = written || bounded;
|
|
46
|
+
folds.push({ decision: rules, tags, node, label, ...(over === undefined ? {} : { over }), ...(single ? { single: true } : {}) });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return folds;
|
|
50
|
+
}
|
|
51
|
+
function termLabel(term) {
|
|
52
|
+
const data = termData(term);
|
|
53
|
+
if (data.kind === "position" && data.path[0]?.startsWith("#local:"))
|
|
54
|
+
return [localLabel(data.path[0]), ...data.path.slice(1)].join(".");
|
|
55
|
+
return describeTerm(term);
|
|
56
|
+
}
|
|
57
|
+
function readsRun(fold) {
|
|
58
|
+
const own = new Set([fold.name, fold.accumulator]);
|
|
59
|
+
const seen = new Set();
|
|
60
|
+
let reads = false;
|
|
61
|
+
// The whole input, read by the empty path, is a read of what a run is handed.
|
|
62
|
+
const rooted = (path) => {
|
|
63
|
+
if (path[0] === undefined || !own.has(path[0]))
|
|
64
|
+
reads = true;
|
|
65
|
+
};
|
|
66
|
+
const walk = (value) => {
|
|
67
|
+
if (reads || value === null || typeof value !== "object" || seen.has(value))
|
|
68
|
+
return;
|
|
69
|
+
seen.add(value);
|
|
70
|
+
if (isTerm(value)) {
|
|
71
|
+
const data = termData(value);
|
|
72
|
+
if (data.kind === "position")
|
|
73
|
+
rooted(data.path);
|
|
74
|
+
else
|
|
75
|
+
for (const part of data.parts)
|
|
76
|
+
rooted(part.path);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const node = nodeOf(value);
|
|
80
|
+
// A name a node inside the fold binds is read from within, not from what a run is handed; each is declared once.
|
|
81
|
+
if (node?.kind === "bind" || node?.kind === "map" || node?.kind === "fold")
|
|
82
|
+
own.add(node.name);
|
|
83
|
+
if (node?.kind === "fold")
|
|
84
|
+
own.add(node.accumulator);
|
|
85
|
+
if (node?.kind === "choose")
|
|
86
|
+
for (const path of pathsRead(node.condition))
|
|
87
|
+
rooted(path);
|
|
88
|
+
if (node?.kind === "call")
|
|
89
|
+
reads = true;
|
|
90
|
+
for (const child of childrenOf(value))
|
|
91
|
+
walk(child);
|
|
92
|
+
};
|
|
93
|
+
for (const part of [fold.values, fold.initial, fold.body])
|
|
94
|
+
walk(part);
|
|
95
|
+
return reads;
|
|
96
|
+
}
|
|
97
|
+
export function runWalk(implementation, given, deps, rewrite) {
|
|
98
|
+
const elements = new Map();
|
|
99
|
+
const observe = (node, count) => {
|
|
100
|
+
const counts = elements.get(node) ?? [];
|
|
101
|
+
counts.push(count);
|
|
102
|
+
elements.set(node, counts);
|
|
103
|
+
};
|
|
104
|
+
try {
|
|
105
|
+
const actual = withWalk(rewrite, observe, () => performSync(implementation, given, deps));
|
|
106
|
+
return { actual, elements };
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (error instanceof SpecificationError && error.message.includes("answered a promise"))
|
|
110
|
+
return { pending: true, elements };
|
|
111
|
+
return { error, elements };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export const walks = ["after one step", "from the seed"];
|
|
115
|
+
export function tookSecond(run, node) {
|
|
116
|
+
return (run.elements.get(node) ?? []).some(count => count >= 2);
|
|
117
|
+
}
|
|
118
|
+
// Whether a rewrite of a fold changes how a run on `given` comes out:
|
|
119
|
+
// `answers` says whether what the rewritten run answered is the answer.
|
|
120
|
+
export function tells(implementation, fold, walk, given, deps, answers) {
|
|
121
|
+
const rewritten = runWalk(implementation, given, deps, { node: fold.node, walk });
|
|
122
|
+
// A rewritten run cut short by a limit of evaluation says nothing of how it
|
|
123
|
+
// would have come out.
|
|
124
|
+
if (rewritten.pending || isEvaluationLimit(rewritten.error))
|
|
125
|
+
return "pending";
|
|
126
|
+
return rewritten.error !== undefined || !answers(rewritten.actual);
|
|
127
|
+
}
|
|
128
|
+
export function walksOf(implementation, rows, answers, tagOfGiven) {
|
|
129
|
+
if (implementation === undefined)
|
|
130
|
+
return [];
|
|
131
|
+
const coverage = [];
|
|
132
|
+
for (const fold of foldsOf(implementation)) {
|
|
133
|
+
const ofCase = rows.filter(row => fold.tags.includes(tagOfGiven(row.given) ?? ""));
|
|
134
|
+
const plain = ofCase.map(row => ({ row, run: runWalk(implementation, row.given, row.deps) }));
|
|
135
|
+
const entered = plain.filter(({ run }) => run.elements.has(fold.node));
|
|
136
|
+
const second = plain.filter(({ run }) => tookSecond(run, fold.node));
|
|
137
|
+
// A run that could not be made synchronously might still reach the fold,
|
|
138
|
+
// again if it has been entered already, and take a second element there.
|
|
139
|
+
const pendingPlain = plain.some(({ run }) => run.pending);
|
|
140
|
+
for (const walk of walks) {
|
|
141
|
+
const base = { decision: fold.decision.id, walk: fold.label, rewrite: walk };
|
|
142
|
+
if (fold.single) {
|
|
143
|
+
coverage.push({ ...base, status: "no row owed", reason: "リストが要素を一つしか持たない" });
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
let told;
|
|
147
|
+
let pending = pendingPlain;
|
|
148
|
+
for (const { row } of second) {
|
|
149
|
+
const outcome = tells(implementation, fold, walk, row.given, row.deps, actual => answers(row.expected, actual));
|
|
150
|
+
if (outcome === "pending")
|
|
151
|
+
pending = true;
|
|
152
|
+
else if (outcome) {
|
|
153
|
+
told = row.name;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (told !== undefined)
|
|
158
|
+
coverage.push({ ...base, status: "told", row: told });
|
|
159
|
+
else if (pending)
|
|
160
|
+
coverage.push({ ...base, status: "undecided", reason: "同期に実行できない行がある" });
|
|
161
|
+
else
|
|
162
|
+
coverage.push({
|
|
163
|
+
...base,
|
|
164
|
+
status: "not told",
|
|
165
|
+
reason: entered.length === 0
|
|
166
|
+
? "答えのある行がfoldに入らない"
|
|
167
|
+
: second.length === 0
|
|
168
|
+
? "二つ目の要素まで歩く答えのある行がない"
|
|
169
|
+
: "二つ以上の要素を歩く行も、書き換えで答えが変わらない",
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return coverage;
|
|
174
|
+
}
|
|
175
|
+
// A short sentence a report writes for a rewrite no row tells apart.
|
|
176
|
+
export function describeWalk(item) {
|
|
177
|
+
const rewrite = item.rewrite === "after one step" ? "最初の要素で止めても" : "各段階に前の答えの代わりに初期値を渡しても";
|
|
178
|
+
return `${item.decision}: ${item.walk}を${rewrite}答えの変わる行がない`;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=rewrites.js.map
|
|
@@ -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O,KAAK,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,uBAAuB,CAAC;IAC3F,OAAO,GAAG,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,IAAI,OAAO,YAAY,CAAC;AAC/D,CAAC"}
|
package/dist/rule.d.ts
CHANGED
|
@@ -2,17 +2,26 @@ import { Rational } from "./exact.js";
|
|
|
2
2
|
import type { Decimal } from "decimal.js";
|
|
3
3
|
import type { Temporal as TemporalTypes } from "temporal-spec";
|
|
4
4
|
import type { Execution, Guard } from "./behavior.js";
|
|
5
|
-
type Moment = TemporalTypes.Instant | TemporalTypes.PlainDate | TemporalTypes.PlainTime | TemporalTypes.PlainDateTime;
|
|
5
|
+
type Moment = Date | TemporalTypes.Instant | TemporalTypes.PlainDate | TemporalTypes.PlainTime | TemporalTypes.PlainDateTime;
|
|
6
6
|
export type Comparable = number | bigint | Rational | string | Moment | Decimal;
|
|
7
|
+
export declare const MAX_DATE_TIME = 8640000000000000;
|
|
7
8
|
declare const TERM: unique symbol;
|
|
9
|
+
export type Transform = "trim" | "lowercase" | "uppercase";
|
|
10
|
+
type Reading = "value" | "length";
|
|
11
|
+
export type Measure = Reading | `${string}:${Reading}`;
|
|
12
|
+
export declare function measureOf(transforms: readonly Transform[], reading: Reading): Measure;
|
|
13
|
+
export declare function partsOfMeasure(measure: Measure): {
|
|
14
|
+
readonly transforms: readonly Transform[];
|
|
15
|
+
readonly reading: Reading;
|
|
16
|
+
};
|
|
8
17
|
export interface PositionTermData {
|
|
9
18
|
readonly kind: "position";
|
|
10
19
|
readonly path: readonly string[];
|
|
11
|
-
readonly measure:
|
|
20
|
+
readonly measure: Measure;
|
|
12
21
|
}
|
|
13
22
|
export interface LinearPart {
|
|
14
23
|
readonly path: readonly string[];
|
|
15
|
-
readonly measure:
|
|
24
|
+
readonly measure: Measure;
|
|
16
25
|
readonly coefficient: number;
|
|
17
26
|
}
|
|
18
27
|
export interface LinearTermData {
|
|
@@ -53,19 +62,35 @@ interface Equatable<T> {
|
|
|
53
62
|
interface Measured {
|
|
54
63
|
$length(): TermOf<number>;
|
|
55
64
|
}
|
|
65
|
+
interface Transformable {
|
|
66
|
+
$trim(): TermOf<string>;
|
|
67
|
+
$lowercase(): TermOf<string>;
|
|
68
|
+
$uppercase(): TermOf<string>;
|
|
69
|
+
}
|
|
56
70
|
interface Quantified<E> {
|
|
57
71
|
$all(each: (element: TermOf<E>) => Rule): Rule & Condition;
|
|
58
72
|
$any(each: (element: TermOf<E>) => Rule): Rule & Condition;
|
|
73
|
+
$includes(value: Operand<E>): Rule & Condition;
|
|
74
|
+
}
|
|
75
|
+
interface Related {
|
|
76
|
+
$startsWith(other: Operand<string>): Rule & Condition;
|
|
77
|
+
$endsWith(other: Operand<string>): Rule & Condition;
|
|
78
|
+
$contains(other: Operand<string>): Rule & Condition;
|
|
79
|
+
}
|
|
80
|
+
interface Keyed {
|
|
81
|
+
$hasKey(key: Operand<string>): Rule & Condition;
|
|
59
82
|
}
|
|
60
|
-
type TermOperator = "$lt" | "$lte" | "$gt" | "$gte" | "$eq" | "$ne" | "$length" | "$all" | "$any" | "$plus" | "$minus";
|
|
83
|
+
type TermOperator = "$lt" | "$lte" | "$gt" | "$gte" | "$eq" | "$ne" | "$length" | "$trim" | "$lowercase" | "$uppercase" | "$all" | "$any" | "$includes" | "$startsWith" | "$endsWith" | "$contains" | "$hasKey" | "$plus" | "$minus";
|
|
84
|
+
type KeysOfCases<T> = T extends unknown ? keyof T : never;
|
|
85
|
+
type FieldOfCases<T, K extends PropertyKey> = T extends unknown ? (K extends keyof T ? T[K] : never) : never;
|
|
61
86
|
type Fields<T> = {
|
|
62
|
-
readonly [K in Exclude<
|
|
87
|
+
readonly [K in Exclude<KeysOfCases<T> & string, TermOperator>]-?: TermOf<Exclude<FieldOfCases<T, K>, undefined>>;
|
|
63
88
|
};
|
|
64
89
|
export type TermOf<T> = Term<T> & (0 extends 1 & T ? {
|
|
65
90
|
readonly [key: string]: any;
|
|
66
|
-
} : [T] extends [boolean] ? Equatable<T> : [T] extends [number | Decimal] ? Ordered<T> & Arithmetic<T> : [T] extends [bigint | Rational] ? Ordered<T> : [T] extends [Moment] ? Ordered<T> : [T] extends [string] ? Ordered<T> & Measured : [T] extends [readonly (infer E)[]] ? Measured & Quantified<E> : [T] extends [object] ? string extends keyof T ? unknown extends T[string & keyof T] ? {
|
|
91
|
+
} : [T] extends [boolean] ? Equatable<T> : [T] extends [number | Decimal] ? Ordered<T> & Arithmetic<T> : [T] extends [bigint | Rational] ? Ordered<T> : [T] extends [Moment] ? Ordered<T> : [T] extends [string] ? Ordered<T> & Measured & Transformable & Related : [T] extends [readonly (infer E)[]] ? Measured & Quantified<E> : [T] extends [object] ? string extends keyof T ? unknown extends T[string & keyof T] ? {
|
|
67
92
|
readonly [key: string]: any;
|
|
68
|
-
} : Measured & {
|
|
93
|
+
} : Measured & Keyed & {
|
|
69
94
|
readonly [key: string]: TermOf<Exclude<T[string & keyof T], undefined>>;
|
|
70
95
|
} : Fields<T> : unknown);
|
|
71
96
|
export type InvariantRule<T> = {
|
|
@@ -90,6 +115,13 @@ export interface AnyRule {
|
|
|
90
115
|
readonly element: string;
|
|
91
116
|
readonly each: Rule;
|
|
92
117
|
}
|
|
118
|
+
export type Relation = "startsWith" | "endsWith" | "contains" | "hasKey" | "includes";
|
|
119
|
+
export interface RelationRule {
|
|
120
|
+
readonly kind: "relation";
|
|
121
|
+
readonly relation: Relation;
|
|
122
|
+
readonly subject: Term<unknown>;
|
|
123
|
+
readonly other: Operand<unknown>;
|
|
124
|
+
}
|
|
93
125
|
export interface AndRule {
|
|
94
126
|
readonly kind: "and";
|
|
95
127
|
readonly rules: readonly Rule[];
|
|
@@ -102,10 +134,10 @@ export interface NotRule {
|
|
|
102
134
|
readonly kind: "not";
|
|
103
135
|
readonly rule: Rule;
|
|
104
136
|
}
|
|
105
|
-
export type Rule = (CompareRule | AllRule | AnyRule | AndRule | OrRule | NotRule) & {
|
|
137
|
+
export type Rule = (CompareRule | AllRule | AnyRule | RelationRule | AndRule | OrRule | NotRule) & {
|
|
106
138
|
readonly name?: string;
|
|
107
139
|
};
|
|
108
|
-
export type Distinction = CompareRule | AllRule | AnyRule;
|
|
140
|
+
export type Distinction = CompareRule | AllRule | AnyRule | RelationRule;
|
|
109
141
|
export declare function conjuncts(rule: Rule): readonly Rule[];
|
|
110
142
|
export declare const DEPS = "#deps";
|
|
111
143
|
export declare function depsTerm<T>(): TermOf<T>;
|
|
@@ -114,6 +146,7 @@ export declare function withLocal(scope: unknown, name: string, value: unknown):
|
|
|
114
146
|
export declare function withDeps(input: unknown, deps: unknown): unknown;
|
|
115
147
|
export declare function rootTerm<T>(key: string): TermOf<T>;
|
|
116
148
|
export declare function termPaths(rule: Rule): readonly (readonly string[])[];
|
|
149
|
+
export declare function pathsRead(rule: Rule): readonly (readonly string[])[];
|
|
117
150
|
export declare function rootsRead(rule: Rule): ReadonlySet<string | undefined>;
|
|
118
151
|
export declare function selfTerm<T>(): TermOf<T>;
|
|
119
152
|
export declare function isTerm(value: unknown): value is Term<unknown>;
|
|
@@ -124,6 +157,9 @@ export declare function stepInto(rule: Rule, key: string): Rule | undefined;
|
|
|
124
157
|
export type ComparisonObserver = (rule: CompareRule, scope: unknown) => void;
|
|
125
158
|
export type DistinctionObserver = (distinction: Distinction, outcome: boolean) => void;
|
|
126
159
|
export declare function holds(rule: Rule, value: unknown, observe?: ComparisonObserver, decide?: DistinctionObserver): boolean;
|
|
160
|
+
export declare function relates(rule: RelationRule, value: unknown): boolean;
|
|
161
|
+
export declare function sameElement(left: unknown, right: unknown): boolean;
|
|
162
|
+
export declare function relationHolds(relation: Relation, subject: unknown, other: unknown): boolean;
|
|
127
163
|
export declare function satisfy(rule: Rule, value: unknown, stepAt?: StepAt): unknown;
|
|
128
164
|
export type ElementLabels = Readonly<Record<string, string>>;
|
|
129
165
|
export declare function describeRule(rule: Rule, path?: string, elements?: ElementLabels): string;
|
|
@@ -132,15 +168,42 @@ export type StepAt = (path: readonly string[]) => Step | {
|
|
|
132
168
|
readonly among: readonly unknown[];
|
|
133
169
|
} | undefined;
|
|
134
170
|
export declare function isDecimal(value: unknown): value is Decimal;
|
|
171
|
+
export declare function copyOf<V>(value: V): V;
|
|
135
172
|
export declare function decimalUnits(value: Decimal, scale: number, rounding: "floor" | "ceil"): bigint;
|
|
136
173
|
export declare function decimalOfUnits(like: Decimal, units: bigint, scale: number): Decimal;
|
|
137
174
|
export declare function decimalStep(scale: number): Step;
|
|
138
175
|
export declare function sizeOf(value: unknown): number;
|
|
139
176
|
export declare function resize(current: unknown, size: number, empty?: () => unknown): unknown;
|
|
140
|
-
export declare function
|
|
177
|
+
export declare function counts(measure: Measure): boolean;
|
|
178
|
+
export declare function transformed(value: unknown, transforms: readonly Transform[]): unknown;
|
|
179
|
+
export declare function leftAsItReads(value: unknown, transforms: readonly Transform[]): value is string;
|
|
180
|
+
export declare function measureLabel(location: string, measure: Measure): string;
|
|
181
|
+
export declare function measured(value: unknown, measure: Measure): unknown;
|
|
182
|
+
export declare function rewrite(current: unknown, measure: Measure, target: unknown, empty?: () => unknown): unknown;
|
|
183
|
+
export declare function positionTerm(path: readonly string[], measure: Measure): Term<unknown>;
|
|
141
184
|
export declare function differenceOf(rule: CompareRule): LinearTermData;
|
|
142
185
|
export declare function positionData(term: Term<unknown>): PositionTermData | undefined;
|
|
143
186
|
export declare function positionOf(term: Term<unknown>): PositionTermData;
|
|
144
187
|
export declare function readOperand(operand: unknown, value: unknown): unknown;
|
|
145
|
-
export declare function
|
|
188
|
+
export declare function localLabel(name: string): string;
|
|
189
|
+
export declare function describeLiteral(value: unknown): string;
|
|
190
|
+
export declare function describeTerm(term: Term<unknown>, path?: string, elements?: ElementLabels): string;
|
|
191
|
+
export declare function rebaseTerm(term: Term<unknown>, move: (path: readonly string[]) => readonly string[]): Term<unknown>;
|
|
192
|
+
export declare function rebaseRule(rule: Rule, move: (path: readonly string[]) => readonly string[]): Rule;
|
|
193
|
+
export declare function linearCombination(items: readonly {
|
|
194
|
+
readonly operand: unknown;
|
|
195
|
+
readonly coefficient: number;
|
|
196
|
+
}[]): unknown;
|
|
197
|
+
export interface Replacement {
|
|
198
|
+
readonly with: unknown;
|
|
199
|
+
readonly over?: number;
|
|
200
|
+
}
|
|
201
|
+
export declare function substitutedOperand(value: unknown, replace: (path: readonly string[]) => Replacement | undefined): Replacement | undefined;
|
|
202
|
+
export declare function substitutedRule(rule: Rule, replace: (path: readonly string[]) => Replacement | undefined): Rule | undefined;
|
|
203
|
+
export declare function normalize(rule: Rule): {
|
|
204
|
+
operator: Operator;
|
|
205
|
+
bound: unknown;
|
|
206
|
+
measure: Measure;
|
|
207
|
+
} | undefined;
|
|
208
|
+
export declare function constantsOf(rules: readonly Rule[]): unknown[];
|
|
146
209
|
export {};
|