@agentshouse/mdruntime 0.1.0-ce41fec66d91b → 0.1.0-ce5b3c1e6ea87
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 +2 -2
- package/dist/acceptance.d.ts +6 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +389 -0
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +251 -0
- package/dist/adapter.d.ts +44 -25
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -56
- package/dist/bootstrap.d.ts +8 -4
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +209 -78
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/chat-types.d.ts +5 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +13 -0
- package/dist/client.d.ts +20 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -0
- package/dist/collection.d.ts +2 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/compile.d.ts +6 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +231 -300
- package/dist/connection.d.ts +5 -141
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +101 -5058
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +136 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +248 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +53 -0
- package/dist/conversation.d.ts +34 -38
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +856 -850
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/durability.d.ts +15 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +17 -7
- package/dist/figures.d.ts +48 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +4 -5
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +23 -22
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +23 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +560 -0
- package/dist/job.d.ts +33 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +54 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +268 -0
- package/dist/listing.d.ts +53 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +175 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +62 -20
- package/dist/locks.d.ts +9 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +61 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +61 -0
- package/dist/memory.d.ts +5 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +47 -8
- package/dist/messages.d.ts +27 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +97 -19
- package/dist/model.d.ts +2 -9
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -9
- package/dist/models.d.ts +14 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +193 -0
- package/dist/observation.d.ts +2 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +7 -2
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +57 -0
- package/dist/outcome.d.ts +4 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -0
- package/dist/parts.d.ts +59 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +118 -0
- package/dist/preparation.d.ts +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +226 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +272 -0
- package/dist/query.d.ts +13 -208
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +34 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +122 -0
- package/dist/reach.d.ts +14 -12
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +167 -114
- package/dist/react.d.ts +10 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +0 -2
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +37 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +171 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +9 -1
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +7 -0
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +56 -0
- package/dist/replica.d.ts +8 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +52 -16
- package/dist/room-draft.d.ts +4 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +65 -52
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +216 -0
- package/dist/rows.d.ts +14 -21
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +48 -184
- package/dist/runtime.d.ts +43 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +3 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +16 -11
- package/dist/saves.d.ts +70 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +1006 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -0
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +9 -5
- package/dist/shown.d.ts +31 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +295 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +20 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +77 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/rooms.d.ts +43 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +90 -0
- package/dist/socket/session.d.ts +39 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +70 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +175 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +81 -0
- package/dist/status.d.ts +0 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/fences.d.ts +16 -0
- package/dist/store/fences.d.ts.map +1 -0
- package/dist/store/fences.js +26 -0
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/readiness.d.ts +10 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +52 -0
- package/dist/store/records.d.ts +212 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +408 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +43 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +57 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +107 -145
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +143 -366
- package/dist/stored.d.ts +58 -32
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +264 -187
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +223 -0
- package/dist/sync.d.ts +20 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +532 -0
- package/dist/tables.d.ts +117 -27
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +211 -49
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +7 -4
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +17 -1
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +7 -0
- package/package.json +2 -2
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -370
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../src/reads.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE/D,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAExC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,IAAI,IAAI,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACxD,MAAM,IAAI,OAAO,CAAC;IAClB,SAAS,IAAI,OAAO,CAAC;IACrB,MAAM,IAAI,OAAO,CAAC;IAClB,IAAI,IAAI,OAAO,CAAC;IAChB,MAAM,IAAI,IAAI,CAAC;CAChB,CAAC;AAeF,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMhG;AAED,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,EAC9B,MAAM,EAAE,MAAM,GACb,IAAI,CAMN;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGvF;AAMD,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAsJpE"}
|
package/dist/reads.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { refusedForSpace } from './durability.js';
|
|
2
|
+
import { answeredResult, UNCERTAIN } from './outcome.js';
|
|
3
|
+
export const READ_TABLES = [
|
|
4
|
+
'CREATE TABLE read_answers (name TEXT NOT NULL, input TEXT NOT NULL, build TEXT NOT NULL, answer TEXT NOT NULL, PRIMARY KEY (name, input)) WITHOUT ROWID',
|
|
5
|
+
];
|
|
6
|
+
export function storedRead(connection, { name, input, build }) {
|
|
7
|
+
const [held] = connection.rows('SELECT answer FROM read_answers WHERE name = ? AND input = ? AND build = ?', [name, input, build]);
|
|
8
|
+
return held === undefined ? null : String(held.answer);
|
|
9
|
+
}
|
|
10
|
+
export function keptRead(connection, { name, input, build }, answer) {
|
|
11
|
+
connection.run('INSERT OR REPLACE INTO read_answers (name, input, build, answer) VALUES (?, ?, ?, ?)', [name, input, build, answer]);
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
export function readsOfOtherBuildsForgotten(connection, build) {
|
|
15
|
+
connection.run('DELETE FROM read_answers WHERE build <> ?', [build]);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
function answered(result) {
|
|
19
|
+
return result.kind === 'action' && answeredResult(result.result);
|
|
20
|
+
}
|
|
21
|
+
export function readAnswers(options) {
|
|
22
|
+
const { database, build, recovery } = options;
|
|
23
|
+
const unkept = new Set(options.unkept);
|
|
24
|
+
const leading = new Set(options.leading);
|
|
25
|
+
const reads = new Map();
|
|
26
|
+
function leads(read) {
|
|
27
|
+
return leading.has(read.at.name);
|
|
28
|
+
}
|
|
29
|
+
function show(read, shown) {
|
|
30
|
+
read.shown = shown;
|
|
31
|
+
for (const deliver of read.observers)
|
|
32
|
+
deliver(shown);
|
|
33
|
+
}
|
|
34
|
+
async function kept(read, answer) {
|
|
35
|
+
if (!read.shown.kept || options.full())
|
|
36
|
+
return;
|
|
37
|
+
await database.ask({ kind: 'read.keep', ...read.at, answer }).catch((error) => {
|
|
38
|
+
if (refusedForSpace(error))
|
|
39
|
+
options.filled();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async function asked(read, led) {
|
|
43
|
+
if (!options.online()) {
|
|
44
|
+
read.owed = true;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const result = await options.call(read.at.name, read.asked).catch(() => UNCERTAIN);
|
|
48
|
+
if (options.closed())
|
|
49
|
+
return;
|
|
50
|
+
read.owed = !answered(result);
|
|
51
|
+
if (read.owed) {
|
|
52
|
+
show(read, { ...read.shown, failure: result });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const answer = result.result;
|
|
56
|
+
const text = JSON.stringify(answer);
|
|
57
|
+
if (text === read.text && read.shown.failure === null)
|
|
58
|
+
return;
|
|
59
|
+
read.text = text;
|
|
60
|
+
await kept(read, text);
|
|
61
|
+
await led;
|
|
62
|
+
if (!options.closed())
|
|
63
|
+
show(read, { ...read.shown, answer, failure: null });
|
|
64
|
+
}
|
|
65
|
+
function lost(read) {
|
|
66
|
+
return read.owed && read.shown.failure?.kind === 'transport-uncertainty' && options.streaming();
|
|
67
|
+
}
|
|
68
|
+
function retrying(read) {
|
|
69
|
+
return `${read.key} again`;
|
|
70
|
+
}
|
|
71
|
+
function askedLater(read) {
|
|
72
|
+
void recovery.attempt(retrying(read), async () => {
|
|
73
|
+
if (options.closed() || read.observers.size === 0 || !lost(read))
|
|
74
|
+
return 'done';
|
|
75
|
+
await attempted(read);
|
|
76
|
+
return lost(read) ? 'again' : 'done';
|
|
77
|
+
}, { again: true });
|
|
78
|
+
}
|
|
79
|
+
function forgotten(read) {
|
|
80
|
+
read.text = null;
|
|
81
|
+
read.shown = { ...read.shown, answer: null, failure: null };
|
|
82
|
+
}
|
|
83
|
+
function attempted(read, led) {
|
|
84
|
+
read.asking = true;
|
|
85
|
+
return recovery
|
|
86
|
+
.attempt(read.key, async () => {
|
|
87
|
+
await asked(read, led);
|
|
88
|
+
return 'done';
|
|
89
|
+
})
|
|
90
|
+
.finally(() => {
|
|
91
|
+
const unanswered = read.joined && read.owed;
|
|
92
|
+
read.asking = false;
|
|
93
|
+
read.joined = false;
|
|
94
|
+
if (unanswered)
|
|
95
|
+
void ask(read);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function ask(read, led) {
|
|
99
|
+
return attempted(read, led).finally(() => {
|
|
100
|
+
if (lost(read))
|
|
101
|
+
askedLater(read);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function opened(name, input, key) {
|
|
105
|
+
const held = !unkept.has(name);
|
|
106
|
+
const read = {
|
|
107
|
+
key,
|
|
108
|
+
at: { name, input: JSON.stringify(input ?? null), build },
|
|
109
|
+
asked: input,
|
|
110
|
+
observers: new Set(),
|
|
111
|
+
stored: Promise.resolve(),
|
|
112
|
+
text: null,
|
|
113
|
+
shown: { answer: null, failure: null, kept: held },
|
|
114
|
+
owed: false,
|
|
115
|
+
asking: false,
|
|
116
|
+
joined: false,
|
|
117
|
+
};
|
|
118
|
+
if (held) {
|
|
119
|
+
read.stored = database.ask({ kind: 'read.stored', ...read.at }).then((text) => {
|
|
120
|
+
if (text === null || read.text !== null)
|
|
121
|
+
return;
|
|
122
|
+
read.text = text;
|
|
123
|
+
read.shown = { ...read.shown, answer: JSON.parse(text) };
|
|
124
|
+
}, () => { });
|
|
125
|
+
}
|
|
126
|
+
reads.set(key, read);
|
|
127
|
+
return read;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
watch(name, input, deliver) {
|
|
131
|
+
const key = JSON.stringify([name, input ?? null]);
|
|
132
|
+
const read = reads.get(key) ?? opened(name, input, key);
|
|
133
|
+
read.observers.add(deliver);
|
|
134
|
+
void read.stored.then(() => {
|
|
135
|
+
if (!read.observers.has(deliver))
|
|
136
|
+
return;
|
|
137
|
+
if (!read.shown.kept)
|
|
138
|
+
forgotten(read);
|
|
139
|
+
deliver(read.shown);
|
|
140
|
+
if (read.asking)
|
|
141
|
+
read.joined = true;
|
|
142
|
+
else
|
|
143
|
+
void ask(read);
|
|
144
|
+
});
|
|
145
|
+
return () => {
|
|
146
|
+
read.observers.delete(deliver);
|
|
147
|
+
if (read.observers.size === 0 && reads.get(key) === read)
|
|
148
|
+
reads.delete(key);
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
again() {
|
|
152
|
+
const all = [...reads.values()];
|
|
153
|
+
const led = Promise.all(all.filter(leads).map((read) => ask(read)));
|
|
154
|
+
for (const read of all)
|
|
155
|
+
if (!leads(read))
|
|
156
|
+
void ask(read, led);
|
|
157
|
+
},
|
|
158
|
+
reopened() {
|
|
159
|
+
for (const read of reads.values()) {
|
|
160
|
+
recovery.cancel(retrying(read));
|
|
161
|
+
if (read.text === null) {
|
|
162
|
+
if (read.owed)
|
|
163
|
+
void ask(read);
|
|
164
|
+
}
|
|
165
|
+
else if (read.shown.failure?.kind === 'transport-uncertainty') {
|
|
166
|
+
show(read, { ...read.shown, failure: null });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
package/dist/recovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAElE,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,CAAC,MAAM,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AC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACnC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB,CAAC;AAsBF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,SAAW,EAAE,KAAK,SAAS,GAAG,MAAM,CAGpF;AAED,wBAAsB,aAAa,CAAC,CAAC,EACnC,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACrB,MAAM,EAAE,WAAW,EACnB,QAAQ,GAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAoB,GAC5C,OAAO,CAAC,CAAC,CAAC,CAsBZ;AA8KD,wBAAgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAStE"}
|
package/dist/recovery.js
CHANGED
|
@@ -106,7 +106,15 @@ function owner(backoff, inFlight, release = () => { }) {
|
|
|
106
106
|
}
|
|
107
107
|
intent.tries += 1;
|
|
108
108
|
if (intent.tries >= backoff.attempts) {
|
|
109
|
-
|
|
109
|
+
if (again === null) {
|
|
110
|
+
finish(key, intent, false);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
intent.tries = 0;
|
|
114
|
+
if (again === 'now')
|
|
115
|
+
launch(key, intent);
|
|
116
|
+
else
|
|
117
|
+
wait(key, intent, again, true);
|
|
110
118
|
return;
|
|
111
119
|
}
|
|
112
120
|
if (result === 'again') {
|
package/dist/refresh.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type Refreshing = {
|
|
|
20
20
|
later(paths: readonly string[], roomVersion: string): Promise<ReadonlySet<string>>;
|
|
21
21
|
stage(page: RefreshedPage): Promise<boolean>;
|
|
22
22
|
};
|
|
23
|
-
type PageContent = Pick<RefreshPage, 'documents' | 'revisions' | 'fileIds' | 'changes' | 'binaryFiles'>;
|
|
23
|
+
type PageContent = Pick<RefreshPage, 'documents' | 'facts' | 'revisions' | 'fileIds' | 'created' | 'changes' | 'binaryFiles'>;
|
|
24
24
|
export declare function pageEntries(page: PageContent, removals: readonly string[], roomVersion: string, prior: (paths: readonly string[]) => Promise<ReadonlyMap<string, HeldEntry>>): Promise<StoredEntry[]>;
|
|
25
25
|
export declare function advancement(refresh: Refresher, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean, staging: Refreshing): Promise<Advancement>;
|
|
26
26
|
export {};
|
package/dist/refresh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAG9D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GAC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KxB;AAgDD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,SAAS,EAClB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,EACzB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
|
package/dist/refresh.js
CHANGED
|
@@ -45,9 +45,11 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
45
45
|
entries.push({
|
|
46
46
|
path,
|
|
47
47
|
content: page.documents[path],
|
|
48
|
+
facts: page.facts[path] ?? null,
|
|
48
49
|
binary: null,
|
|
49
50
|
revision: page.revisions[path] ?? prior.get(path)?.revision ?? null,
|
|
50
51
|
fileId: page.fileIds?.[path] ?? null,
|
|
52
|
+
created: page.created?.[path] ?? null,
|
|
51
53
|
change: page.changes[path] ?? null,
|
|
52
54
|
written: roomVersion,
|
|
53
55
|
});
|
|
@@ -57,9 +59,11 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
57
59
|
entries.push({
|
|
58
60
|
path,
|
|
59
61
|
content: null,
|
|
62
|
+
facts: null,
|
|
60
63
|
binary: { state: 'accepted', ...page.binaryFiles[path] },
|
|
61
64
|
revision: page.revisions[path] ?? prior.get(path)?.revision ?? null,
|
|
62
65
|
fileId: page.fileIds?.[path] ?? null,
|
|
66
|
+
created: page.created?.[path] ?? null,
|
|
63
67
|
change: page.changes[path] ?? null,
|
|
64
68
|
written: null,
|
|
65
69
|
});
|
|
@@ -74,6 +78,7 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
74
78
|
...kept,
|
|
75
79
|
revision: page.revisions[path] ?? held.revision,
|
|
76
80
|
fileId: page.fileIds?.[path] ?? held.fileId,
|
|
81
|
+
created: page.created?.[path] ?? held.created,
|
|
77
82
|
change: page.changes[path] ?? held.change,
|
|
78
83
|
});
|
|
79
84
|
}
|
|
@@ -94,8 +99,10 @@ function unwritten(page, kept) {
|
|
|
94
99
|
return {
|
|
95
100
|
...page,
|
|
96
101
|
documents: without(page.documents, kept),
|
|
102
|
+
facts: without(page.facts, kept),
|
|
97
103
|
revisions: without(page.revisions, kept),
|
|
98
104
|
...(page.fileIds === undefined ? {} : { fileIds: without(page.fileIds, kept) }),
|
|
105
|
+
...(page.created === undefined ? {} : { created: without(page.created, kept) }),
|
|
99
106
|
changes: without(page.changes, kept),
|
|
100
107
|
binaryFiles: without(page.binaryFiles, kept),
|
|
101
108
|
removals: page.removals.filter((path) => !kept.has(path)),
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
+
import type { Runtime } from './runtime.js';
|
|
3
|
+
import type { RefusalReason } from './socket.js';
|
|
4
|
+
export declare function refuse(runtime: Runtime, reason: RefusalReason, provider?: ProviderRefusal | null): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,wBAAsB,MAAM,CAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,aAAa,EACrB,QAAQ,GAAE,eAAe,GAAG,IAAW,iBAmDxC"}
|
package/dist/refusal.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
|
+
import { composedOf } from './collection.js';
|
|
3
|
+
import { listedLocators } from './listing.js';
|
|
4
|
+
import { prepare } from './preparation.js';
|
|
5
|
+
import { storedRecord } from './replica.js';
|
|
6
|
+
import { emitRefusal } from './shown.js';
|
|
7
|
+
export async function refuse(runtime, reason, provider = null) {
|
|
8
|
+
const { store, socket, journal } = runtime;
|
|
9
|
+
socket.session.set({ paused: true });
|
|
10
|
+
socket.abortReads();
|
|
11
|
+
try {
|
|
12
|
+
if (reason === 'revoked-authorization') {
|
|
13
|
+
await store.exclusive(async () => {
|
|
14
|
+
const revoked = { status: 'unavailable', reason: 'revoked' };
|
|
15
|
+
let held = new Map();
|
|
16
|
+
try {
|
|
17
|
+
const local = await store.open();
|
|
18
|
+
held = await store.rooms();
|
|
19
|
+
await local.commit({
|
|
20
|
+
rooms: [...held.values()].map(({ record: kept }) => {
|
|
21
|
+
const record = { ...kept, model: revoked };
|
|
22
|
+
return {
|
|
23
|
+
locator: record.locator,
|
|
24
|
+
key: record.key,
|
|
25
|
+
record: storedRecord(record),
|
|
26
|
+
composed: composedOf(store.composed(record)),
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
journal.record('model revocation persistence failed');
|
|
33
|
+
}
|
|
34
|
+
const listedNow = listedLocators(runtime, held);
|
|
35
|
+
for (const locator of listedNow) {
|
|
36
|
+
if (!held.has(locator))
|
|
37
|
+
socket.rooms.stand(locator, { unheldModel: revoked });
|
|
38
|
+
}
|
|
39
|
+
store.changed(mergeChangeSets(listedNow.map((locator) => changeSet(locator, { documents: null, room: true }))));
|
|
40
|
+
prepare(runtime);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
socket.session.set({
|
|
46
|
+
refusal: {
|
|
47
|
+
code: reason,
|
|
48
|
+
retryable: false,
|
|
49
|
+
reauthorizationOffered: reason === 'revoked-authorization',
|
|
50
|
+
refusal: provider,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
journal.record(`connection refused ${reason}`);
|
|
54
|
+
emitRefusal(runtime);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/dist/replica.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type TypedPath } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { BootstrapInventory, SavedFacts, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
|
|
2
3
|
import { type ChangeBatch, type Precondition } from './change.js';
|
|
3
4
|
import { type Collection, type Composition } from './collection.js';
|
|
4
5
|
import { type ModelState } from './model.js';
|
|
@@ -22,23 +23,22 @@ export type HeldReplica = {
|
|
|
22
23
|
readonly record: ReplicaRecord;
|
|
23
24
|
readonly queue: readonly ChangeBatch[];
|
|
24
25
|
readonly overlaid: ReadonlySet<string>;
|
|
25
|
-
readonly count: number;
|
|
26
|
-
readonly confirmed: number;
|
|
27
|
-
readonly indexed: boolean;
|
|
28
26
|
};
|
|
29
27
|
export type VisibleLayer = Layer & {
|
|
30
28
|
readonly collection: Collection;
|
|
31
29
|
};
|
|
32
30
|
export type Slice = Layer & {
|
|
33
31
|
readonly written: Readonly<Record<string, string>>;
|
|
32
|
+
readonly facts: Readonly<Record<string, SavedFacts>>;
|
|
34
33
|
readonly held: ReadonlySet<string>;
|
|
35
34
|
};
|
|
36
|
-
export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState): Composition;
|
|
35
|
+
export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
|
|
37
36
|
export declare function storedRecord(record: ReplicaRecord): string;
|
|
38
37
|
export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
|
|
38
|
+
export type LayerEntry = Omit<StoredEntry, 'facts'>;
|
|
39
39
|
export declare function entryAt(layer: Layer & {
|
|
40
40
|
readonly written?: Readonly<Record<string, string>>;
|
|
41
|
-
}, path: string):
|
|
41
|
+
}, path: string): LayerEntry | null;
|
|
42
42
|
export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
|
|
43
43
|
export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
|
|
44
44
|
export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
|
|
@@ -47,7 +47,7 @@ export type Replayed = {
|
|
|
47
47
|
readonly touched: ReadonlySet<string>;
|
|
48
48
|
};
|
|
49
49
|
export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
|
|
50
|
-
export declare function overlayOf(visible:
|
|
50
|
+
export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
|
|
51
51
|
export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
|
|
52
52
|
export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
|
|
53
53
|
export type Standing = {
|
|
@@ -63,6 +63,6 @@ export type Returned = {
|
|
|
63
63
|
readonly removed: readonly string[];
|
|
64
64
|
};
|
|
65
65
|
export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
|
|
66
|
-
export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string): Generator<number, Returned, void>;
|
|
66
|
+
export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string, composition: Composition): Generator<number, Returned, void>;
|
|
67
67
|
export {};
|
|
68
68
|
//# sourceMappingURL=replica.d.ts.map
|
package/dist/replica.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM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E,OAAO,EACd,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,GACvB,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CA4BnC;AAED,KAAK,QAAQ,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,GAAG,EAAE,SAAS,WAAW,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF,wBAAgB,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAiBrF;AAED,wBAAiB,SAAS,CACxB,SAAS,EAAE,KAAK,EAChB,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,GACvB,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CA6FnC"}
|
package/dist/replica.js
CHANGED
|
@@ -3,14 +3,17 @@ import { immutable, landing } from './change.js';
|
|
|
3
3
|
import { collectionOf } from './collection.js';
|
|
4
4
|
import { storedModel } from './model.js';
|
|
5
5
|
import { acceptedBinaries, overlaying } from './overlay.js';
|
|
6
|
+
import { writtenFacts } from './rows.js';
|
|
6
7
|
import { effectiveIn, rewriting } from './save.js';
|
|
8
|
+
import { guarding } from './shared.js';
|
|
7
9
|
import { ROW_WEIGHT } from './turn.js';
|
|
8
|
-
export function compositionOf(record, builtIn) {
|
|
10
|
+
export function compositionOf(record, builtIn, typedPaths) {
|
|
9
11
|
return {
|
|
10
12
|
model: record.model,
|
|
11
13
|
selection: record.typedSelection === null
|
|
12
14
|
? null
|
|
13
15
|
: { roots: record.typedSelection.roots, model: builtIn },
|
|
16
|
+
typedPaths,
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
19
|
export function storedRecord(record) {
|
|
@@ -35,7 +38,7 @@ function strict(values, held) {
|
|
|
35
38
|
throw new UnreadPath(property);
|
|
36
39
|
}
|
|
37
40
|
};
|
|
38
|
-
return
|
|
41
|
+
return guarding(values, {
|
|
39
42
|
get(target, property, receiver) {
|
|
40
43
|
guard(property);
|
|
41
44
|
return Reflect.get(target, property, receiver);
|
|
@@ -58,9 +61,13 @@ export function* slicing(entries, paths) {
|
|
|
58
61
|
const binaries = {};
|
|
59
62
|
const revisions = {};
|
|
60
63
|
const fileIds = {};
|
|
64
|
+
const created = {};
|
|
61
65
|
const changes = {};
|
|
62
66
|
const written = {};
|
|
67
|
+
const facts = {};
|
|
63
68
|
for (const entry of entries) {
|
|
69
|
+
if (entry.facts !== null)
|
|
70
|
+
facts[entry.path] = entry.facts;
|
|
64
71
|
if (entry.binary !== null)
|
|
65
72
|
binaries[entry.path] = entry.binary;
|
|
66
73
|
else if (entry.content !== null)
|
|
@@ -69,6 +76,8 @@ export function* slicing(entries, paths) {
|
|
|
69
76
|
revisions[entry.path] = entry.revision;
|
|
70
77
|
if (entry.fileId !== null)
|
|
71
78
|
fileIds[entry.path] = entry.fileId;
|
|
79
|
+
if (entry.created !== null)
|
|
80
|
+
created[entry.path] = entry.created;
|
|
72
81
|
if (entry.change !== null)
|
|
73
82
|
changes[entry.path] = entry.change;
|
|
74
83
|
if (entry.written !== null)
|
|
@@ -80,8 +89,10 @@ export function* slicing(entries, paths) {
|
|
|
80
89
|
binaries: strict(binaries, held),
|
|
81
90
|
revisions: strict(revisions, held),
|
|
82
91
|
fileIds: strict(fileIds, held),
|
|
92
|
+
created: strict(created, held),
|
|
83
93
|
changes: strict(changes, held),
|
|
84
94
|
written: strict(written, held),
|
|
95
|
+
facts: strict(facts, held),
|
|
85
96
|
held,
|
|
86
97
|
};
|
|
87
98
|
}
|
|
@@ -96,6 +107,7 @@ export function entryAt(layer, path) {
|
|
|
96
107
|
binary: binary ?? null,
|
|
97
108
|
revision: layer.revisions[path] ?? null,
|
|
98
109
|
fileId: layer.fileIds[path] ?? null,
|
|
110
|
+
created: layer.created[path] ?? null,
|
|
99
111
|
change: layer.changes[path] ?? null,
|
|
100
112
|
written: layer.written?.[path] ?? null,
|
|
101
113
|
};
|
|
@@ -104,8 +116,9 @@ export function* slicingWith(slice, set, removed) {
|
|
|
104
116
|
const entries = new Map();
|
|
105
117
|
for (const path of slice.held) {
|
|
106
118
|
const entry = entryAt(slice, path);
|
|
107
|
-
if (entry !== null)
|
|
108
|
-
entries.set(path, { ...entry, type: null });
|
|
119
|
+
if (entry !== null) {
|
|
120
|
+
entries.set(path, { ...entry, type: null, facts: slice.facts[path] ?? null });
|
|
121
|
+
}
|
|
109
122
|
yield ROW_WEIGHT;
|
|
110
123
|
}
|
|
111
124
|
for (const path of removed)
|
|
@@ -169,8 +182,9 @@ export function* replaying(confirmed, queue, locator, composition) {
|
|
|
169
182
|
export function* overlayOf(visible, touched) {
|
|
170
183
|
const rows = [];
|
|
171
184
|
for (const path of touched) {
|
|
172
|
-
yield ROW_WEIGHT;
|
|
173
185
|
const entry = entryAt(visible, path);
|
|
186
|
+
yield ROW_WEIGHT + (entry?.content?.length ?? 0);
|
|
187
|
+
const text = entry?.binary === null ? entry.content : null;
|
|
174
188
|
rows.push(entry === null
|
|
175
189
|
? {
|
|
176
190
|
path,
|
|
@@ -179,10 +193,17 @@ export function* overlayOf(visible, touched) {
|
|
|
179
193
|
binary: null,
|
|
180
194
|
revision: null,
|
|
181
195
|
fileId: null,
|
|
196
|
+
created: null,
|
|
182
197
|
change: null,
|
|
183
198
|
written: null,
|
|
199
|
+
facts: null,
|
|
184
200
|
}
|
|
185
|
-
: {
|
|
201
|
+
: {
|
|
202
|
+
...entry,
|
|
203
|
+
written: null,
|
|
204
|
+
present: true,
|
|
205
|
+
facts: text === null ? null : writtenFacts(path, text, visible.collection.composition),
|
|
206
|
+
});
|
|
186
207
|
}
|
|
187
208
|
return rows;
|
|
188
209
|
}
|
|
@@ -347,17 +368,20 @@ export function returnedPaths(submitted, accepted) {
|
|
|
347
368
|
}
|
|
348
369
|
return paths;
|
|
349
370
|
}
|
|
350
|
-
export function* returning(confirmed, submitted, accepted, writtenAt) {
|
|
371
|
+
export function* returning(confirmed, submitted, accepted, writtenAt, composition) {
|
|
351
372
|
const documents = new Map();
|
|
352
373
|
const binaries = new Map();
|
|
353
374
|
const revisions = new Map();
|
|
354
375
|
const fileIds = new Map();
|
|
376
|
+
const created = new Map();
|
|
355
377
|
const changes = new Map();
|
|
356
378
|
const written = new Map();
|
|
379
|
+
const facts = new Map();
|
|
357
380
|
const read = (changed, held, path) => (changed.has(path) ? changed.get(path) : held[path]);
|
|
358
381
|
for (const [path, content] of Object.entries(accepted.documents)) {
|
|
359
|
-
yield ROW_WEIGHT;
|
|
382
|
+
yield ROW_WEIGHT + content.length;
|
|
360
383
|
documents.set(path, content);
|
|
384
|
+
facts.set(path, writtenFacts(path, content, composition));
|
|
361
385
|
fileIds.set(path, undefined);
|
|
362
386
|
written.set(path, writtenAt);
|
|
363
387
|
}
|
|
@@ -380,48 +404,60 @@ export function* returning(confirmed, submitted, accepted, writtenAt) {
|
|
|
380
404
|
written.set(path, undefined);
|
|
381
405
|
}
|
|
382
406
|
for (const change of submitted.changes) {
|
|
383
|
-
if (change.kind === 'arrival'
|
|
384
|
-
if (accepted.revisions[change.path]
|
|
407
|
+
if (change.kind === 'arrival') {
|
|
408
|
+
if (accepted.revisions[change.path] === undefined)
|
|
409
|
+
continue;
|
|
410
|
+
created.set(change.path, change.created);
|
|
411
|
+
if ('binary' in change)
|
|
385
412
|
binaries.set(change.path, { state: 'accepted', ...change.binary });
|
|
386
|
-
}
|
|
387
413
|
continue;
|
|
388
414
|
}
|
|
389
|
-
if (change.kind !== 'move')
|
|
415
|
+
if (change.kind !== 'move' || accepted.revisions[change.to] === undefined)
|
|
390
416
|
continue;
|
|
417
|
+
created.set(change.to, read(created, confirmed.created, change.path));
|
|
418
|
+
created.set(change.path, undefined);
|
|
391
419
|
const moved = read(binaries, confirmed.binaries, change.path);
|
|
392
|
-
if (moved === undefined
|
|
420
|
+
if (moved === undefined)
|
|
393
421
|
continue;
|
|
394
422
|
binaries.set(change.to, moved);
|
|
395
423
|
binaries.set(change.path, undefined);
|
|
396
424
|
}
|
|
397
425
|
for (const [path, binary] of acceptedBinaries(accepted.binaryFiles ?? {}))
|
|
398
426
|
binaries.set(path, binary);
|
|
399
|
-
for (const path of accepted.removals)
|
|
427
|
+
for (const path of accepted.removals) {
|
|
400
428
|
binaries.set(path, undefined);
|
|
429
|
+
created.set(path, undefined);
|
|
430
|
+
}
|
|
401
431
|
const paths = new Set([
|
|
402
432
|
...documents.keys(),
|
|
403
433
|
...binaries.keys(),
|
|
404
434
|
...revisions.keys(),
|
|
405
435
|
...fileIds.keys(),
|
|
436
|
+
...created.keys(),
|
|
406
437
|
...changes.keys(),
|
|
407
438
|
...written.keys(),
|
|
408
439
|
]);
|
|
409
440
|
const set = [];
|
|
410
441
|
const removed = [];
|
|
411
442
|
for (const path of paths) {
|
|
412
|
-
yield ROW_WEIGHT;
|
|
413
443
|
const content = read(documents, confirmed.documents, path);
|
|
414
444
|
const binary = read(binaries, confirmed.binaries, path);
|
|
445
|
+
yield ROW_WEIGHT;
|
|
415
446
|
if (content === undefined && binary === undefined) {
|
|
416
447
|
removed.push(path);
|
|
417
448
|
continue;
|
|
418
449
|
}
|
|
450
|
+
const text = binary === undefined ? (content ?? null) : null;
|
|
451
|
+
const fresh = confirmed.documents[path] === undefined && confirmed.binaries[path] === undefined;
|
|
419
452
|
set.push({
|
|
420
453
|
path,
|
|
421
|
-
content:
|
|
454
|
+
content: text,
|
|
455
|
+
facts: text === null ? null : (read(facts, confirmed.facts, path) ?? null),
|
|
422
456
|
binary: binary ?? null,
|
|
423
457
|
revision: read(revisions, confirmed.revisions, path) ?? null,
|
|
424
458
|
fileId: read(fileIds, confirmed.fileIds, path) ?? null,
|
|
459
|
+
created: read(created, confirmed.created, path) ??
|
|
460
|
+
(fresh ? (read(changes, confirmed.changes, path)?.time ?? null) : null),
|
|
425
461
|
change: read(changes, confirmed.changes, path) ?? null,
|
|
426
462
|
written: read(written, confirmed.written, path) ?? null,
|
|
427
463
|
});
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -90,9 +90,9 @@ type ChangedUnderneath = {
|
|
|
90
90
|
readonly file?: string | null;
|
|
91
91
|
};
|
|
92
92
|
export type ReturnReason = ProviderRefusal & {
|
|
93
|
-
readonly kind: Open<'conflicted' | 'rejected' | '
|
|
93
|
+
readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
|
|
94
94
|
};
|
|
95
|
-
export declare function returnedBy(kind: '
|
|
95
|
+
export declare function returnedBy(kind: 'withdrawn'): ReturnReason;
|
|
96
96
|
export type RoomDraft = {
|
|
97
97
|
readonly room: string;
|
|
98
98
|
readonly path: string;
|
|
@@ -127,13 +127,14 @@ export type SavedDraft = {
|
|
|
127
127
|
readonly path: string;
|
|
128
128
|
readonly parts: HeldParts;
|
|
129
129
|
};
|
|
130
|
-
export declare function readParts(value: unknown): RoomDraftParts;
|
|
130
|
+
export declare function readParts(value: unknown, path: string): RoomDraftParts;
|
|
131
131
|
export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
|
|
132
132
|
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
|
|
133
133
|
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
134
134
|
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
135
135
|
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
136
136
|
export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
|
|
137
|
+
export declare function lineEnded(text: string): string;
|
|
137
138
|
export type TextParts = {
|
|
138
139
|
readonly fields?: Readonly<Record<string, {
|
|
139
140
|
readonly value: unknown;
|