@graview/core 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/archived-seen.d.ts.map +1 -1
- package/dist/archived-seen.js +6 -3
- package/dist/archived-seen.js.map +1 -1
- package/dist/arrangement.d.ts +9 -1
- package/dist/arrangement.d.ts.map +1 -1
- package/dist/arrangement.js +28 -2
- package/dist/arrangement.js.map +1 -1
- package/dist/arranging.d.ts.map +1 -1
- package/dist/arranging.js +12 -6
- package/dist/arranging.js.map +1 -1
- package/dist/binding-served.d.ts +3 -1
- package/dist/binding-served.d.ts.map +1 -1
- package/dist/binding-served.js +12 -2
- package/dist/binding-served.js.map +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +37 -36
- package/dist/catalog.js.map +1 -1
- package/dist/check.d.ts +1 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +2 -0
- package/dist/check.js.map +1 -1
- package/dist/cli/check/field-sight.d.ts.map +1 -1
- package/dist/cli/check/field-sight.js +2 -1
- package/dist/cli/check/field-sight.js.map +1 -1
- package/dist/cli/check/index.d.ts +1 -0
- package/dist/cli/check/index.d.ts.map +1 -1
- package/dist/cli/check/index.js +1 -0
- package/dist/cli/check/index.js.map +1 -1
- package/dist/cli/check/touched.d.ts +8 -0
- package/dist/cli/check/touched.d.ts.map +1 -0
- package/dist/cli/check/touched.js +35 -0
- package/dist/cli/check/touched.js.map +1 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +2 -1
- package/dist/cli/check.js.map +1 -1
- package/dist/document/blocks.d.ts.map +1 -1
- package/dist/document/blocks.js +11 -3
- package/dist/document/blocks.js.map +1 -1
- package/dist/document/compile.d.ts.map +1 -1
- package/dist/document/compile.js +81 -3
- package/dist/document/compile.js.map +1 -1
- package/dist/document/compiled.d.ts.map +1 -1
- package/dist/document/compiled.js +50 -28
- package/dist/document/compiled.js.map +1 -1
- package/dist/document/computed.d.ts.map +1 -1
- package/dist/document/computed.js +2 -1
- package/dist/document/computed.js.map +1 -1
- package/dist/document/edit.d.ts.map +1 -1
- package/dist/document/edit.js +2 -1
- package/dist/document/edit.js.map +1 -1
- package/dist/document/expr/evaluate.d.ts +14 -0
- package/dist/document/expr/evaluate.d.ts.map +1 -1
- package/dist/document/expr/evaluate.js +8 -1
- package/dist/document/expr/evaluate.js.map +1 -1
- package/dist/document/graview-template.d.ts.map +1 -1
- package/dist/document/graview-template.js +2 -1
- package/dist/document/graview-template.js.map +1 -1
- package/dist/document/migrate.d.ts.map +1 -1
- package/dist/document/migrate.js +6 -0
- package/dist/document/migrate.js.map +1 -1
- package/dist/document/rules.d.ts +2 -0
- package/dist/document/rules.d.ts.map +1 -1
- package/dist/document/rules.js +27 -14
- package/dist/document/rules.js.map +1 -1
- package/dist/document/template.d.ts +2 -0
- package/dist/document/template.d.ts.map +1 -1
- package/dist/document/template.js +12 -1
- package/dist/document/template.js.map +1 -1
- package/dist/document/views.d.ts.map +1 -1
- package/dist/document/views.js +2 -1
- package/dist/document/views.js.map +1 -1
- package/dist/document.schema.json +2 -2
- package/dist/graph/diff.d.ts.map +1 -1
- package/dist/graph/diff.js +4 -0
- package/dist/graph/diff.js.map +1 -1
- package/dist/graph/graph.d.ts +71 -0
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +167 -4
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/touched.d.ts +152 -0
- package/dist/graph/touched.d.ts.map +1 -0
- package/dist/graph/touched.js +263 -0
- package/dist/graph/touched.js.map +1 -0
- package/dist/graph/tracked.d.ts +2 -0
- package/dist/graph/tracked.d.ts.map +1 -1
- package/dist/graph/tracked.js +4 -0
- package/dist/graph/tracked.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/integrity.d.ts.map +1 -1
- package/dist/integrity.js +3 -1
- package/dist/integrity.js.map +1 -1
- package/dist/job-findings.d.ts.map +1 -1
- package/dist/job-findings.js +3 -2
- package/dist/job-findings.js.map +1 -1
- package/dist/jobs.d.ts +0 -15
- package/dist/jobs.d.ts.map +1 -1
- package/dist/jobs.js +24 -2
- package/dist/jobs.js.map +1 -1
- package/dist/kind-list.d.ts.map +1 -1
- package/dist/kind-list.js +2 -1
- package/dist/kind-list.js.map +1 -1
- package/dist/lines.d.ts +0 -11
- package/dist/lines.d.ts.map +1 -1
- package/dist/lines.js +16 -1
- package/dist/lines.js.map +1 -1
- package/dist/linked.d.ts.map +1 -1
- package/dist/linked.js +3 -1
- package/dist/linked.js.map +1 -1
- package/dist/ops/log.d.ts +9 -0
- package/dist/ops/log.d.ts.map +1 -1
- package/dist/ops/log.js +10 -8
- package/dist/ops/log.js.map +1 -1
- package/dist/ops/types.d.ts +7 -0
- package/dist/ops/types.d.ts.map +1 -1
- package/dist/ops/withheld.d.ts +4 -0
- package/dist/ops/withheld.d.ts.map +1 -1
- package/dist/ops/withheld.js +16 -1
- package/dist/ops/withheld.js.map +1 -1
- package/dist/past.d.ts.map +1 -1
- package/dist/past.js +7 -14
- package/dist/past.js.map +1 -1
- package/dist/schema/reading.d.ts.map +1 -1
- package/dist/schema/reading.js +4 -0
- package/dist/schema/reading.js.map +1 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +7 -1
- package/dist/schema/schema.js.map +1 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +6 -3
- package/dist/search.js.map +1 -1
- package/dist/seen.d.ts +27 -3
- package/dist/seen.d.ts.map +1 -1
- package/dist/seen.js +151 -25
- package/dist/seen.js.map +1 -1
- package/dist/served-touches.d.ts +24 -0
- package/dist/served-touches.d.ts.map +1 -0
- package/dist/served-touches.js +61 -0
- package/dist/served-touches.js.map +1 -0
- package/dist/store.d.ts +3 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +56 -12
- package/dist/store.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
package/dist/store.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { judgedOnTouches } from "./graph/touched.js";
|
|
2
|
+
import { everBound, hidesFrom, readingOf, seatLens, seenBy, seesEveryRecord, seesId, toldTouches } from "./seen.js";
|
|
3
|
+
import { offersTouches, servedTold, TOLD_TO, UNSEATED } from "./served-touches.js";
|
|
2
4
|
import { isoToday } from "./days.js";
|
|
3
5
|
import { Graph, GraphError, MissingRecordError } from "./graph/graph.js";
|
|
4
6
|
import { resolveModules } from "./modules.js";
|
|
5
7
|
import { diffSnapshots, diffTouched, EMPTY_DIFF, isEmptyDiff } from "./graph/diff.js";
|
|
6
8
|
import { normalize, writesOf } from "./graph/primitives.js";
|
|
9
|
+
import { keptMaking, untouched } from "./graph/touched.js";
|
|
7
10
|
import { keepLinked, keepsLinked } from "./keep-linked.js";
|
|
8
11
|
import { bareOp, inverseOf } from "./ops/inverse.js";
|
|
9
12
|
import { LabelIndex, refusalFor } from "./labels.js";
|
|
@@ -57,6 +60,10 @@ export const PREVIEW_BATCH = "preview";
|
|
|
57
60
|
const given = (key, value) => (value === undefined ? {} : { [key]: value });
|
|
58
61
|
/** A call's arguments written out the same however their keys were ordered: what says two calls ask the same. */
|
|
59
62
|
const canonicalArgs = (value) => JSON.stringify(value, (_, one) => (one && typeof one === "object" && !Array.isArray(one) ? Object.fromEntries(Object.keys(one).sort().map((key) => [key, one[key]])) : one)) ?? "";
|
|
63
|
+
/** A record an act adds, without what it said of when it was made and touched: the op that lands it says that (`touched.ts`). */
|
|
64
|
+
const madeBare = (primitive) => (primitive.op === "add-node" ? { ...primitive, node: untouched(primitive.node) } : primitive);
|
|
65
|
+
/** What a host hands as an op, without what it says of when a record was made or touched, an add's or a removal's: the framework's own ops say that. */
|
|
66
|
+
const hostBare = (primitive) => (primitive.op === "add-node" || primitive.op === "remove-node" ? { ...primitive, node: untouched(primitive.node) } : primitive);
|
|
60
67
|
const HUMAN = { kind: "human" };
|
|
61
68
|
/** The host itself, which sees what it keeps: the principal a question is asked as when no seat is named. */
|
|
62
69
|
const SYSTEM = { kind: "system" };
|
|
@@ -325,7 +332,7 @@ export class Store {
|
|
|
325
332
|
this.publishing = options.publishing;
|
|
326
333
|
this.tidying = options.tidying;
|
|
327
334
|
this.votes = options.votes;
|
|
328
|
-
this.by = options.principal ??
|
|
335
|
+
this.by = options.principal ?? UNSEATED;
|
|
329
336
|
this.intelligence = options.intelligence ?? [];
|
|
330
337
|
for (const provider of options.intelligence ?? []) {
|
|
331
338
|
if (provider.may)
|
|
@@ -384,11 +391,17 @@ export class Store {
|
|
|
384
391
|
this.graph = options.snapshot
|
|
385
392
|
? Graph.from(options.schema, options.snapshot, validate)
|
|
386
393
|
: this.log.fold(options.schema, { ...validate, ...(last ? { from: last } : {}) });
|
|
394
|
+
// A graph stored before records kept when they were touched says so from the ops its log still holds, and no more (`touched.ts`).
|
|
395
|
+
if (options.snapshot)
|
|
396
|
+
this.graph.touchFrom(this.log.all());
|
|
387
397
|
}
|
|
388
398
|
else {
|
|
389
399
|
this.log = OperationLog.from([], options.epochs ?? (options.snapshot ? [{ seq: options.horizon ?? 0, base: options.snapshot }] : []), horizon);
|
|
390
400
|
this.graph = Graph.from(options.schema, options.snapshot ?? { nodes: [], edges: [] }, validate);
|
|
391
401
|
}
|
|
402
|
+
// Whom each seat was ever bound to, so who touched a record is said as the person by whatever reads the graph (`personSaidFor`).
|
|
403
|
+
this.graph.everBound = () => everBound(this);
|
|
404
|
+
this.graph.servedTold = () => servedTold(this);
|
|
392
405
|
/*
|
|
393
406
|
* A HYDRATED STORE COUNTS ON FROM WHERE THE LOG LEFT OFF.
|
|
394
407
|
*
|
|
@@ -503,6 +516,10 @@ export class Store {
|
|
|
503
516
|
this.projected = { projection, length: all.length, last, said };
|
|
504
517
|
return projection;
|
|
505
518
|
}
|
|
519
|
+
/** Whether a seat this store was given is told a record's four (`toldTouches`), the judgment `offersTouches` asks of it without importing it. */
|
|
520
|
+
[TOLD_TO](by) {
|
|
521
|
+
return toldTouches(this, by);
|
|
522
|
+
}
|
|
506
523
|
/**
|
|
507
524
|
* TURN MODULES OFF OR ON, AS AN OP (FR-12).
|
|
508
525
|
*
|
|
@@ -1412,7 +1429,9 @@ export class Store {
|
|
|
1412
1429
|
* judges them over another reading of this graph: a seat's (FR-55).
|
|
1413
1430
|
*/
|
|
1414
1431
|
violations(context, over = this.graph) {
|
|
1415
|
-
|
|
1432
|
+
const judged = evaluate(over, this.allInvariants(), this.judging(context)).map((violation) => this.asking(violation));
|
|
1433
|
+
// A store whose seat is told none of a record's four (a page's, as its server said) reports no rule its judgment read them for: it was judged on blanks.
|
|
1434
|
+
return offersTouches(this) ? judged : judged.filter((violation) => !judgedOnTouches(violation));
|
|
1416
1435
|
}
|
|
1417
1436
|
/*
|
|
1418
1437
|
* A REPAIR SAYS WHAT IT STILL ASKS FOR (the twelfth walk). A rule written
|
|
@@ -1508,6 +1527,7 @@ export class Store {
|
|
|
1508
1527
|
if (made) {
|
|
1509
1528
|
twin.graph.applyPrimitives(made.primitives);
|
|
1510
1529
|
twin.log.append(made);
|
|
1530
|
+
twin.graph.touch(made);
|
|
1511
1531
|
}
|
|
1512
1532
|
this.personMade = { key, twin };
|
|
1513
1533
|
return twin;
|
|
@@ -1865,6 +1885,7 @@ export class Store {
|
|
|
1865
1885
|
if (person) {
|
|
1866
1886
|
this.graph.applyPrimitives(person.primitives);
|
|
1867
1887
|
this.log.append(person);
|
|
1888
|
+
this.graph.touch(person);
|
|
1868
1889
|
ops.push(person);
|
|
1869
1890
|
allPrimitives.push(...person.primitives);
|
|
1870
1891
|
writes.add(person.writes[0]);
|
|
@@ -1933,7 +1954,8 @@ export class Store {
|
|
|
1933
1954
|
* to one of those goes back to its source — in this op, so one undo
|
|
1934
1955
|
* takes both back. Applied to the graph as they are worked out.
|
|
1935
1956
|
*/
|
|
1936
|
-
|
|
1957
|
+
// A record an act adds is made by this op, whatever it said of its making (`touched.ts`).
|
|
1958
|
+
const made = this.asSplices(compiled.primitives, options.base).map(normalize).map(madeBare);
|
|
1937
1959
|
this.graph.applyPrimitives(made);
|
|
1938
1960
|
const following = keepsLinked(this.schema) ? keepLinked(this.schema, this.graph, made, { mayWriteBack: this.writesBack(as) }).map(normalize) : [];
|
|
1939
1961
|
madeIds[at] = compiled.primitives.find((primitive) => primitive.op === "add-node")?.node.id;
|
|
@@ -1968,6 +1990,8 @@ export class Store {
|
|
|
1968
1990
|
...given("lineage", lined),
|
|
1969
1991
|
};
|
|
1970
1992
|
this.log.append(op);
|
|
1993
|
+
// Every record it wrote says when, and who (`touched.ts`).
|
|
1994
|
+
this.graph.touch(op);
|
|
1971
1995
|
ops.push(op);
|
|
1972
1996
|
allPrimitives.push(...op.primitives);
|
|
1973
1997
|
for (const id of op.reads)
|
|
@@ -2039,7 +2063,8 @@ export class Store {
|
|
|
2039
2063
|
receive(ops, options = {}) {
|
|
2040
2064
|
this.stillNow();
|
|
2041
2065
|
const known = new Set(this.log.all().map((op) => op.id));
|
|
2042
|
-
|
|
2066
|
+
// Each record an op adds kept without what its payload said of its making: the op that lands it here says that (`keptMaking`).
|
|
2067
|
+
const fresh = ops.filter((op) => !known.has(op.id)).map(keptMaking);
|
|
2043
2068
|
if (fresh.length === 0)
|
|
2044
2069
|
return [];
|
|
2045
2070
|
const before = this.graph.snapshot();
|
|
@@ -2073,6 +2098,8 @@ export class Store {
|
|
|
2073
2098
|
for (const [index, op] of fresh.entries()) {
|
|
2074
2099
|
const here = bareOp({ ...op, seq: seq + index });
|
|
2075
2100
|
this.log.append(here);
|
|
2101
|
+
// Stamped as it was made, applied here before or not: a client's own stamp gives way to the server's.
|
|
2102
|
+
this.graph.touch(here);
|
|
2076
2103
|
landed.push(here);
|
|
2077
2104
|
}
|
|
2078
2105
|
this.countPast(landed);
|
|
@@ -2104,7 +2131,8 @@ export class Store {
|
|
|
2104
2131
|
const taken = new Set(this.log.all().map((op) => op.id));
|
|
2105
2132
|
let batch;
|
|
2106
2133
|
const built = ops.map((made, index) => {
|
|
2107
|
-
|
|
2134
|
+
// A host says nothing of when a record was made, an undo it makes included: only the framework's own undo puts one back as it was (`touched.ts`).
|
|
2135
|
+
const primitives = made.primitives.map(normalize).map(hostBare);
|
|
2108
2136
|
const op = {
|
|
2109
2137
|
id: made.id ?? this.nextId(),
|
|
2110
2138
|
seq: this.log.length + index,
|
|
@@ -2138,8 +2166,10 @@ export class Store {
|
|
|
2138
2166
|
throw new ReceiveError(op, error);
|
|
2139
2167
|
}
|
|
2140
2168
|
}
|
|
2141
|
-
for (const op of built)
|
|
2169
|
+
for (const op of built) {
|
|
2142
2170
|
this.log.append(op);
|
|
2171
|
+
this.graph.touch(op);
|
|
2172
|
+
}
|
|
2143
2173
|
// An id or batch the host named is the log's now: the next one minted counts past it (FR-204).
|
|
2144
2174
|
this.countPast(built);
|
|
2145
2175
|
for (const op of built)
|
|
@@ -2165,7 +2195,7 @@ export class Store {
|
|
|
2165
2195
|
const rollback = this.graph.snapshot();
|
|
2166
2196
|
const intent = options.intent ?? "Apply a change";
|
|
2167
2197
|
const lineage = this.heldLineage(lineageOf(options.lineage), author);
|
|
2168
|
-
const handed = this.asSplices(primitives, options.base).map(normalize);
|
|
2198
|
+
const handed = keptMaking({ primitives: this.asSplices(primitives, options.base).map(normalize) }).primitives;
|
|
2169
2199
|
// What follows it (Roadmap f-keep-linked), worked out on the graph as it lands: the host's change keeps derived records in step too.
|
|
2170
2200
|
this.graph.applyPrimitives(handed);
|
|
2171
2201
|
let recorded = handed;
|
|
@@ -2194,6 +2224,7 @@ export class Store {
|
|
|
2194
2224
|
...given("lineage", lineage),
|
|
2195
2225
|
};
|
|
2196
2226
|
this.log.append(op);
|
|
2227
|
+
this.graph.touch(op);
|
|
2197
2228
|
ops.push(op);
|
|
2198
2229
|
tellTheWatchOfAnAuthor(author.id);
|
|
2199
2230
|
}
|
|
@@ -2341,6 +2372,8 @@ export class Store {
|
|
|
2341
2372
|
};
|
|
2342
2373
|
this.graph.applyPrimitives(op.primitives, { restoring: putsBack(target) });
|
|
2343
2374
|
this.log.append(op);
|
|
2375
|
+
// An undo touches what it puts back: now, by whoever took it back.
|
|
2376
|
+
this.graph.touch(op);
|
|
2344
2377
|
ops.push(op);
|
|
2345
2378
|
}
|
|
2346
2379
|
const diff = diffTouched(rollback, this.graph.snapshot(), ops.flatMap((op) => [...op.primitives]));
|
|
@@ -2770,14 +2803,22 @@ export class Store {
|
|
|
2770
2803
|
try {
|
|
2771
2804
|
// 1. Back to the confirmed prefix, putting back exactly what each op took.
|
|
2772
2805
|
// In place: what a pending op took out goes back where it stood, or this copy and the server's disagree on order.
|
|
2773
|
-
|
|
2806
|
+
// Each taken back with its touch (`touched.ts`): what a record said before it, where the graph remembers; the rest by the log.
|
|
2807
|
+
const forgotten = new Set();
|
|
2808
|
+
for (const op of [...tail].reverse()) {
|
|
2774
2809
|
this.graph.applyPrimitives(inverseOf(op), { restoring: true, inPlace: true });
|
|
2810
|
+
for (const id of this.graph.untouch(op))
|
|
2811
|
+
forgotten.add(id);
|
|
2812
|
+
}
|
|
2775
2813
|
this.log.truncate(cut);
|
|
2814
|
+
if (forgotten.size > 0)
|
|
2815
|
+
this.graph.retouch(forgotten, this.log.all());
|
|
2776
2816
|
// 2. What the server says, in its order.
|
|
2777
2817
|
const known = new Set(this.log.all().map((op) => op.id));
|
|
2778
|
-
for (const
|
|
2779
|
-
if (known.has(
|
|
2818
|
+
for (const handed of change.confirmed) {
|
|
2819
|
+
if (known.has(handed.id))
|
|
2780
2820
|
continue;
|
|
2821
|
+
const op = keptMaking(handed);
|
|
2781
2822
|
try {
|
|
2782
2823
|
this.graph.applyPrimitives(op.primitives, { restoring: op.undoes !== undefined });
|
|
2783
2824
|
}
|
|
@@ -2786,6 +2827,7 @@ export class Store {
|
|
|
2786
2827
|
}
|
|
2787
2828
|
const here = bareOp({ ...op, seq: this.log.length });
|
|
2788
2829
|
this.log.append(here);
|
|
2830
|
+
this.graph.touch(here);
|
|
2789
2831
|
known.add(op.id);
|
|
2790
2832
|
landed.push(here);
|
|
2791
2833
|
}
|
|
@@ -3028,7 +3070,7 @@ export class Store {
|
|
|
3028
3070
|
epochAt(seq) {
|
|
3029
3071
|
const ops = this.log.all();
|
|
3030
3072
|
// What the store keeps of who made what and what was removed is written here, from the log, never carried over from an epoch.
|
|
3031
|
-
const { creators: _creators, removed: _removed, writers: _writers, published: _published, declines: _declines, ...checkpoint } = this.log.checkpointAt(this.schema, seq, { validate: this.validate });
|
|
3073
|
+
const { creators: _creators, removed: _removed, writers: _writers, published: _published, declines: _declines, bound: _bound, ...checkpoint } = this.log.checkpointAt(this.schema, seq, { validate: this.validate });
|
|
3032
3074
|
/*
|
|
3033
3075
|
* Who made each record behind it, so a store opened on it still knows (an `own` sight reads the log for it);
|
|
3034
3076
|
* what each record removed behind it was, so a field naming one is still judged as naming it; and who wrote
|
|
@@ -3050,6 +3092,8 @@ export class Store {
|
|
|
3050
3092
|
return {
|
|
3051
3093
|
...checkpoint,
|
|
3052
3094
|
...(kept(creators) && { creators }),
|
|
3095
|
+
// Whom each seat was bound to, ended bindings too: who made or touched a record is still said as the person (`touchesRebound`).
|
|
3096
|
+
...(this.schema.definitions.some((definition) => definition.people === true) && kept(Object.fromEntries(everBound(this))) && { bound: Object.fromEntries(everBound(this)) }),
|
|
3053
3097
|
...(removed && { removed }),
|
|
3054
3098
|
...(kept(writers) && { writers }),
|
|
3055
3099
|
...(kept(declines) && { declines }),
|