@agentshouse/mdruntime 0.1.0-c835af48a82d3 → 0.1.0-c83bc1fac9b35
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 +21 -19
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +299 -0
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +321 -0
- package/dist/adapter.d.ts +115 -57
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +0 -5
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +2 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -2
- package/dist/client.d.ts +26 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +45 -58
- package/dist/collection.d.ts +26 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +28 -10
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +31 -25
- package/dist/connection.d.ts +5 -149
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +112 -5364
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +152 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +261 -0
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +22 -3
- package/dist/conversation.d.ts +57 -45
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +977 -1031
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +12 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +14 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +5 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +23 -12
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +8 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- 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 +24 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +87 -20
- package/dist/house-query.d.ts +21 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +41 -0
- package/dist/index.d.ts +30 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -6
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +290 -0
- package/dist/listing.d.ts +60 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +168 -0
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +74 -33
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +34 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +19 -2
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +105 -27
- package/dist/memory.d.ts +9 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +94 -32
- package/dist/messages.d.ts +12 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +35 -39
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +4 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -5
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +217 -85
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +69 -0
- package/dist/outcome.d.ts +16 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +32 -2
- package/dist/overlay.d.ts +6 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +37 -24
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +5 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +28 -110
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +45 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +335 -0
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +287 -0
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +3 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +4 -6
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +15 -5
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +164 -33
- package/dist/react.d.ts +18 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +16 -5
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +10 -10
- package/dist/reads.d.ts +6 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +61 -11
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +5 -13
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +17 -18
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +31 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +273 -66
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +220 -0
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +9 -10
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +35 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +326 -225
- package/dist/saves.d.ts +34 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +437 -0
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +35 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +326 -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 +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -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/session.d.ts +41 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +26 -0
- package/dist/socket.d.ts +68 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +165 -0
- package/dist/source.d.ts +5 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +18 -6
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +40 -0
- package/dist/store/readiness.d.ts +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +227 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +468 -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/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -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 +119 -204
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +170 -394
- package/dist/stored.d.ts +26 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +101 -36
- package/dist/surface.d.ts +94 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +255 -0
- package/dist/sync.d.ts +21 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +557 -0
- package/dist/tables.d.ts +28 -59
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +106 -331
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +4 -10
- package/dist/wire.d.ts +68 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +26 -9
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/store.js
CHANGED
|
@@ -1,408 +1,184 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
lost: false,
|
|
35
|
-
}),
|
|
36
|
-
files: [...batchFiles(batch), ...draftFiles(drafts)],
|
|
37
|
-
...batchFacts(batch),
|
|
38
|
-
};
|
|
39
|
-
}),
|
|
40
|
-
}),
|
|
41
|
-
...(founded === undefined
|
|
42
|
-
? {}
|
|
43
|
-
: {
|
|
44
|
-
founded: founded.map((batch) => ({
|
|
45
|
-
id: batch.id,
|
|
46
|
-
batch: JSON.stringify(batch),
|
|
47
|
-
files: batchFiles(batch),
|
|
48
|
-
...batchFacts(batch),
|
|
49
|
-
})),
|
|
50
|
-
}),
|
|
51
|
-
...(roomDrafts === undefined ? {} : { roomDrafts: roomDrafts.map(roomDraftRow) }),
|
|
52
|
-
...(consumedRoomDrafts === undefined ? {} : { consumedRoomDrafts }),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function marked(value) {
|
|
56
|
-
return typeof value === 'object' && value !== null && FILE in value;
|
|
57
|
-
}
|
|
58
|
-
function keyed(keys, value) {
|
|
59
|
-
const stored = [];
|
|
60
|
-
const files = [];
|
|
61
|
-
const record = JSON.stringify(value, (_name, held) => {
|
|
62
|
-
if (!(held instanceof Blob))
|
|
63
|
-
return held;
|
|
64
|
-
let key = keys.get(held);
|
|
65
|
-
if (key === undefined) {
|
|
66
|
-
key = binaryLocalId();
|
|
67
|
-
keys.set(held, key);
|
|
68
|
-
}
|
|
69
|
-
stored.push({ key, blob: held });
|
|
70
|
-
files.push(key);
|
|
71
|
-
return { [FILE]: key, type: held.type };
|
|
1
|
+
import { schemaTypes } from './attached-model.js';
|
|
2
|
+
import { createCell } from './cell.js';
|
|
3
|
+
import { openedFiles } from './opened.js';
|
|
4
|
+
import { compositionOf } from './replica.js';
|
|
5
|
+
import { STARTING } from './status.js';
|
|
6
|
+
import { createInstalls, NO_INSTALL } from './store/installs.js';
|
|
7
|
+
import { openRuntimeStore, } from './store/records.js';
|
|
8
|
+
import { createReadinessQueue } from './store/readiness.js';
|
|
9
|
+
import { createRoomHeld } from './store/room-held.js';
|
|
10
|
+
import { createRoomsShown } from './store/rooms-shown.js';
|
|
11
|
+
import { createSpace } from './store/space.js';
|
|
12
|
+
import { createWatchers } from './store/watchers.js';
|
|
13
|
+
import { createWrites } from './store/writes.js';
|
|
14
|
+
const OPENING = 'store';
|
|
15
|
+
export function createStore(options) {
|
|
16
|
+
const writes = createWrites();
|
|
17
|
+
const watchers = createWatchers(options.unpublished);
|
|
18
|
+
const { lost } = options;
|
|
19
|
+
const installs = createInstalls();
|
|
20
|
+
const seeds = new Map();
|
|
21
|
+
const conflicted = createRoomHeld();
|
|
22
|
+
const attached = createRoomHeld();
|
|
23
|
+
const typesHeld = new Map();
|
|
24
|
+
const device = createCell({
|
|
25
|
+
persistence: options.persistence,
|
|
26
|
+
storageLoss: null,
|
|
27
|
+
completedWhenOpened: false,
|
|
28
|
+
preparing: false,
|
|
29
|
+
sweeping: false,
|
|
30
|
+
unpreparedDemand: new Set(),
|
|
31
|
+
unpreparable: new Set(),
|
|
32
|
+
establishing: new Set(),
|
|
33
|
+
status: STARTING,
|
|
72
34
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
function roomOf(row) {
|
|
88
|
-
return {
|
|
89
|
-
record: { ...JSON.parse(row.record), key: row.key },
|
|
90
|
-
indexed: row.indexed,
|
|
91
|
-
documents: row.documents,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function json(value, fallback) {
|
|
95
|
-
return value === undefined ? fallback : JSON.parse(value);
|
|
96
|
-
}
|
|
97
|
-
export function openRuntimeStore(authored) {
|
|
98
|
-
const keys = new WeakMap();
|
|
99
|
-
const read = async (key, type) => {
|
|
100
|
-
const blob = await authored.ask({ kind: 'authored.file', key, type });
|
|
101
|
-
keys.set(blob, key);
|
|
102
|
-
return blob;
|
|
103
|
-
};
|
|
104
|
-
const restored = async (records) => Promise.all(records.map(async (record) => (await filed(JSON.parse(record), read))));
|
|
105
|
-
const amend = async (locator, id, amendment) => {
|
|
106
|
-
await authored.ask({
|
|
107
|
-
kind: 'authored.amend',
|
|
108
|
-
locator,
|
|
109
|
-
id,
|
|
110
|
-
amendment: JSON.stringify(amendment),
|
|
35
|
+
const space = createSpace(options.database, options.spaceFreed);
|
|
36
|
+
const readiness = createReadinessQueue(options.deliverReadiness, options.unpublished);
|
|
37
|
+
let opening;
|
|
38
|
+
let needed = false;
|
|
39
|
+
function open() {
|
|
40
|
+
needed = true;
|
|
41
|
+
opening ??= options.opening(openRuntimeStore(options.database)).then((opened) => {
|
|
42
|
+
options.retries.succeeded('database', OPENING);
|
|
43
|
+
return opened;
|
|
44
|
+
}, (error) => {
|
|
45
|
+
opening = undefined;
|
|
46
|
+
options.retries.failed('database', OPENING, error);
|
|
47
|
+
throw error;
|
|
111
48
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
49
|
+
return opening;
|
|
50
|
+
}
|
|
51
|
+
function prepareAgain(locator) {
|
|
52
|
+
const { unpreparable } = device.now();
|
|
53
|
+
device.set({
|
|
54
|
+
unpreparable: locator === undefined
|
|
55
|
+
? new Set()
|
|
56
|
+
: new Set([...unpreparable].filter((held) => held !== locator)),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function typed(locator, persisted) {
|
|
60
|
+
if (persisted.status === 'unavailable')
|
|
61
|
+
return persisted;
|
|
62
|
+
const schema = persisted.snapshot.schema;
|
|
63
|
+
const held = typesHeld.get(locator);
|
|
64
|
+
if (held !== undefined && held.schema === schema)
|
|
65
|
+
return { ...persisted, types: held.types };
|
|
66
|
+
const types = schemaTypes(schema, options.roomTypes);
|
|
67
|
+
typesHeld.set(locator, { schema, types });
|
|
68
|
+
return { ...persisted, types };
|
|
69
|
+
}
|
|
70
|
+
function recordOf(stored) {
|
|
71
|
+
return { ...stored, model: typed(stored.locator, stored.model) };
|
|
72
|
+
}
|
|
73
|
+
async function rooms(locators) {
|
|
74
|
+
const held = await (await open()).rooms(locators);
|
|
75
|
+
return new Map(held
|
|
76
|
+
.filter(({ record }) => !lost(record.locator))
|
|
77
|
+
.map(({ record, indexed, documents }) => [
|
|
78
|
+
record.locator,
|
|
79
|
+
{ record: recordOf(record), indexed, documents },
|
|
80
|
+
]));
|
|
81
|
+
}
|
|
82
|
+
async function work(locator) {
|
|
83
|
+
if (lost(locator))
|
|
84
|
+
return { replica: undefined, queue: [], states: new Map() };
|
|
85
|
+
const { room, queue } = await (await open()).room(locator);
|
|
86
|
+
const batches = queue.map(({ batch }) => batch);
|
|
87
|
+
const states = new Map(queue.map(({ batch, state }) => [batch.id, state]));
|
|
88
|
+
return {
|
|
89
|
+
replica: room === null
|
|
90
|
+
? undefined
|
|
91
|
+
: { record: recordOf(room.record), queue: batches, states, overlaid: room.overlaid },
|
|
92
|
+
queue: batches,
|
|
93
|
+
states,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function drafts(locator, paths) {
|
|
97
|
+
const held = await (await open()).roomDrafts(locator, paths);
|
|
98
|
+
return held.filter((record) => !lost(record.locator));
|
|
99
|
+
}
|
|
116
100
|
return {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
101
|
+
device,
|
|
102
|
+
roomsShown: createRoomsShown(),
|
|
103
|
+
space,
|
|
104
|
+
readiness,
|
|
105
|
+
ask: options.database.ask,
|
|
106
|
+
changed: options.changed,
|
|
107
|
+
open,
|
|
108
|
+
needed: () => needed,
|
|
109
|
+
durably: (work) => writes.exclusive(async () => {
|
|
110
|
+
const local = await open();
|
|
111
|
+
return work(local);
|
|
112
|
+
}),
|
|
113
|
+
exclusive: writes.exclusive,
|
|
114
|
+
gathered: writes.gathered,
|
|
115
|
+
written: writes.written,
|
|
116
|
+
startingWrite: writes.startingWrite,
|
|
117
|
+
finishingWrite: writes.finishingWrite,
|
|
118
|
+
ahead: writes.ahead,
|
|
119
|
+
rederive: writes.rederive,
|
|
120
|
+
refreshPage: writes.refreshPage,
|
|
121
|
+
stageBytes: writes.stageBytes,
|
|
122
|
+
deriveBytes: writes.deriveBytes,
|
|
123
|
+
rooms,
|
|
124
|
+
record: async (locator) => (await rooms([locator])).get(locator)?.record,
|
|
125
|
+
work,
|
|
126
|
+
replica: async (locator) => (await work(locator)).replica,
|
|
134
127
|
async covering() {
|
|
135
|
-
const
|
|
128
|
+
const held = await (await open()).covering();
|
|
129
|
+
if (!options.losing())
|
|
130
|
+
return held;
|
|
136
131
|
return {
|
|
137
|
-
rooms: new Map(rooms.
|
|
138
|
-
|
|
132
|
+
rooms: new Map([...held.rooms].filter(([locator]) => !lost(locator))),
|
|
133
|
+
locking: new Set([...held.locking].filter((locator) => !lost(locator))),
|
|
134
|
+
queues: new Map([...held.queues].filter(([locator]) => !lost(locator))),
|
|
139
135
|
};
|
|
140
136
|
},
|
|
141
|
-
offline(locator) {
|
|
142
|
-
return authored.ask({ kind: 'replica.offline', locator });
|
|
143
|
-
},
|
|
144
|
-
async held() {
|
|
145
|
-
const { held, staged } = await authored.ask({ kind: 'replica.held' });
|
|
146
|
-
return { held: new Set(held), staged: new Set(staged) };
|
|
147
|
-
},
|
|
148
137
|
async status() {
|
|
149
|
-
const
|
|
150
|
-
kind: 'authored.status',
|
|
151
|
-
});
|
|
152
|
-
return {
|
|
153
|
-
queued,
|
|
154
|
-
lastCompleted: json(lastCompleted ?? undefined, null),
|
|
155
|
-
unsent: changes.map(({ locator, path }) => ({ room: locator, path })),
|
|
156
|
-
resets,
|
|
157
|
-
returned: returned.map((record) => JSON.parse(record)),
|
|
158
|
-
};
|
|
159
|
-
},
|
|
160
|
-
async batch(locator, id) {
|
|
161
|
-
const held = await authored.ask({ kind: 'authored.batch', locator, id });
|
|
162
|
-
return held === null ? null : JSON.parse(held);
|
|
163
|
-
},
|
|
164
|
-
order(locator) {
|
|
165
|
-
return authored.ask({ kind: 'authored.order', locator });
|
|
166
|
-
},
|
|
167
|
-
queued() {
|
|
168
|
-
return authored.ask({ kind: 'authored.queued' });
|
|
169
|
-
},
|
|
170
|
-
async moving() {
|
|
171
|
-
const { queues, pending } = await authored.ask({ kind: 'authored.moving' });
|
|
138
|
+
const held = await (await open()).status();
|
|
172
139
|
return {
|
|
173
|
-
queued:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
})),
|
|
140
|
+
queued: held.queued.filter((locator) => !lost(locator)),
|
|
141
|
+
lastCompleted: held.lastCompleted,
|
|
142
|
+
unsent: held.unsent.filter(({ room }) => !lost(room)),
|
|
143
|
+
resets: held.resets.filter(({ locator }) => !lost(locator)),
|
|
144
|
+
returned: held.returned.filter(({ locator }) => !lost(locator)),
|
|
179
145
|
};
|
|
180
146
|
},
|
|
181
|
-
async
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
referrers(key, view, targets) {
|
|
217
|
-
return authored.ask({ kind: 'replica.referrers', key, view, targets });
|
|
218
|
-
},
|
|
219
|
-
folders(key, view, paths) {
|
|
220
|
-
return authored.ask({ kind: 'replica.folders', key, view, paths });
|
|
221
|
-
},
|
|
222
|
-
typedWithin(key, view, roots, within) {
|
|
223
|
-
return authored.ask({ kind: 'replica.typedWithin', key, view, roots, within });
|
|
224
|
-
},
|
|
225
|
-
stage(record, composition, page) {
|
|
226
|
-
return authored.ask({
|
|
227
|
-
kind: 'replica.stage',
|
|
228
|
-
locator: record.locator,
|
|
229
|
-
transfer: record.transfer,
|
|
230
|
-
key: record.key,
|
|
231
|
-
fingerprint: composedOf(composition).fingerprint,
|
|
232
|
-
entries: page.entries,
|
|
233
|
-
folders: page.folders,
|
|
234
|
-
part: page.part ?? null,
|
|
235
|
-
});
|
|
236
|
-
},
|
|
237
|
-
resume(record, composition, parts, published) {
|
|
238
|
-
return authored.ask({
|
|
239
|
-
kind: 'replica.resume',
|
|
240
|
-
locator: record.locator,
|
|
241
|
-
transfer: record.transfer,
|
|
242
|
-
fingerprint: composedOf(composition).fingerprint,
|
|
243
|
-
parts,
|
|
244
|
-
published,
|
|
245
|
-
});
|
|
246
|
-
},
|
|
247
|
-
async refresh(key, composition, page) {
|
|
248
|
-
await authored.ask({
|
|
249
|
-
kind: 'replica.refresh',
|
|
250
|
-
key,
|
|
251
|
-
composed: composedOf(composition),
|
|
252
|
-
entries: page.entries,
|
|
253
|
-
removals: page.removals,
|
|
254
|
-
folders: page.folders,
|
|
255
|
-
folderRemovals: page.folderRemovals,
|
|
256
|
-
});
|
|
257
|
-
},
|
|
258
|
-
async unrefresh(key) {
|
|
259
|
-
await authored.ask({ kind: 'replica.unrefresh', key });
|
|
260
|
-
},
|
|
261
|
-
commit({ rooms, writes = [], files = [], whole = false }) {
|
|
262
|
-
for (const room of rooms)
|
|
263
|
-
change(room.key);
|
|
264
|
-
return authored.ask({
|
|
265
|
-
kind: 'replica.commit',
|
|
266
|
-
...(writes.length === 0 && files.length === 0
|
|
267
|
-
? {}
|
|
268
|
-
: { authored: { writes: writes.map(authoredRows), files, whole } }),
|
|
269
|
-
rooms,
|
|
270
|
-
});
|
|
271
|
-
},
|
|
272
|
-
async fence(locators) {
|
|
273
|
-
await authored.ask({ kind: 'replica.fence', locators });
|
|
274
|
-
},
|
|
275
|
-
async erase(locator, limit) {
|
|
276
|
-
return (await authored.ask({ kind: 'replica.erase', locator, limit })).remaining;
|
|
277
|
-
},
|
|
278
|
-
async abandon(locator) {
|
|
279
|
-
await authored.ask({ kind: 'replica.abandon', locator });
|
|
280
|
-
},
|
|
281
|
-
async unfence(locators) {
|
|
282
|
-
return new Set(await authored.ask({ kind: 'replica.unfence', locators }));
|
|
283
|
-
},
|
|
284
|
-
async release(key) {
|
|
285
|
-
await authored.ask({ kind: 'replica.release', key });
|
|
286
|
-
},
|
|
287
|
-
async rederive(key, composition, bytes, ms, floor) {
|
|
288
|
-
change(key);
|
|
289
|
-
return authored.ask({
|
|
290
|
-
kind: 'replica.rederive',
|
|
291
|
-
key,
|
|
292
|
-
composed: composedOf(composition),
|
|
293
|
-
bytes,
|
|
294
|
-
ms,
|
|
295
|
-
floor,
|
|
296
|
-
});
|
|
297
|
-
},
|
|
298
|
-
async fact(name, value) {
|
|
299
|
-
await authored.ask({ kind: 'replica.fact', name, value: JSON.stringify(value) });
|
|
300
|
-
},
|
|
301
|
-
submit(locator, id, submission, lost) {
|
|
302
|
-
return amend(locator, id, { submission, lost });
|
|
303
|
-
},
|
|
304
|
-
keepUpload(locator, id, upload) {
|
|
305
|
-
return amend(locator, id, { upload });
|
|
306
|
-
},
|
|
307
|
-
async roomDrafts(locator, paths) {
|
|
308
|
-
const held = await authored.ask({
|
|
309
|
-
kind: 'authored.roomDrafts',
|
|
310
|
-
locator: locator ?? null,
|
|
311
|
-
paths: paths ?? null,
|
|
312
|
-
});
|
|
313
|
-
return held.map((record) => JSON.parse(record));
|
|
314
|
-
},
|
|
315
|
-
async present(record) {
|
|
316
|
-
await authored.ask({
|
|
317
|
-
kind: 'replica.present',
|
|
318
|
-
app: record.app,
|
|
319
|
-
value: JSON.stringify(record.value ?? null),
|
|
320
|
-
});
|
|
321
|
-
},
|
|
322
|
-
conversations(conversations) {
|
|
323
|
-
return authored.ask({ kind: 'conversation.held', conversations: conversations ?? null });
|
|
324
|
-
},
|
|
325
|
-
async keepMessages(write) {
|
|
326
|
-
await authored.ask({ kind: 'conversation.keep', ...write });
|
|
327
|
-
},
|
|
328
|
-
messageWindow(conversation, limit, before, phrase = null) {
|
|
329
|
-
return authored.ask({ kind: 'conversation.window', conversation, limit, before, phrase });
|
|
330
|
-
},
|
|
331
|
-
messageCount(conversation, phrase = null) {
|
|
332
|
-
return authored.ask({ kind: 'conversation.count', conversation, phrase });
|
|
333
|
-
},
|
|
334
|
-
turnArrived(conversation, turn) {
|
|
335
|
-
return authored.ask({ kind: 'conversation.turn', conversation, turn });
|
|
336
|
-
},
|
|
337
|
-
conversationRows(conversations) {
|
|
338
|
-
return authored.ask({ kind: 'conversation.rows', conversations });
|
|
339
|
-
},
|
|
340
|
-
jobMarkers(conversation) {
|
|
341
|
-
return authored.ask({ kind: 'conversation.jobs', conversation });
|
|
342
|
-
},
|
|
343
|
-
async dropConversations(conversations) {
|
|
344
|
-
await authored.ask({ kind: 'conversation.drop', conversations });
|
|
345
|
-
},
|
|
346
|
-
async chatDrafts() {
|
|
347
|
-
const records = await authored.ask({ kind: 'authored.chatDrafts' });
|
|
348
|
-
return records.map((record) => JSON.parse(record));
|
|
349
|
-
},
|
|
350
|
-
async chatDraft(conversation) {
|
|
351
|
-
const record = await authored.ask({ kind: 'authored.chatDraft.read', conversation });
|
|
352
|
-
return record === null ? null : JSON.parse(record);
|
|
353
|
-
},
|
|
354
|
-
async keepChatDrafts(records) {
|
|
355
|
-
await authored.ask({
|
|
356
|
-
kind: 'authored.chatDraft',
|
|
357
|
-
kept: records.map((record) => ({
|
|
358
|
-
conversation: record.conversation,
|
|
359
|
-
record: JSON.stringify(record),
|
|
360
|
-
})),
|
|
361
|
-
dropped: [],
|
|
362
|
-
});
|
|
363
|
-
},
|
|
364
|
-
async dropChatDraft(conversation) {
|
|
365
|
-
await authored.ask({ kind: 'authored.chatDraft', kept: [], dropped: [conversation] });
|
|
366
|
-
},
|
|
367
|
-
async calls() {
|
|
368
|
-
return restored(await authored.ask({ kind: 'authored.calls' }));
|
|
369
|
-
},
|
|
370
|
-
async keepCall(record) {
|
|
371
|
-
const { stored, ...kept } = keyed(keys, record);
|
|
372
|
-
await authored.ask({
|
|
373
|
-
kind: 'authored.call',
|
|
374
|
-
operation: record.operation,
|
|
375
|
-
kept,
|
|
376
|
-
files: stored,
|
|
377
|
-
});
|
|
378
|
-
},
|
|
379
|
-
async dropCall(operation) {
|
|
380
|
-
await authored.ask({ kind: 'authored.call', operation, kept: null, files: [] });
|
|
381
|
-
},
|
|
382
|
-
async keepRoomDraft(record, files) {
|
|
383
|
-
const { path, ...kept } = roomDraftRow(record);
|
|
384
|
-
await authored.ask({
|
|
385
|
-
kind: 'authored.roomDraft',
|
|
386
|
-
locator: record.locator,
|
|
387
|
-
path,
|
|
388
|
-
kept,
|
|
389
|
-
files,
|
|
390
|
-
});
|
|
391
|
-
},
|
|
392
|
-
async discardRoomDraft(locator, path) {
|
|
393
|
-
await authored.ask({ kind: 'authored.roomDraft', locator, path, kept: null, files: [] });
|
|
394
|
-
},
|
|
395
|
-
fences() {
|
|
396
|
-
return authored.ask({ kind: 'authored.fences' });
|
|
397
|
-
},
|
|
398
|
-
generation() {
|
|
399
|
-
return fact('generation');
|
|
400
|
-
},
|
|
401
|
-
async rememberGeneration(value) {
|
|
402
|
-
await authored.ask({ kind: 'authored.remember', name: 'generation', value });
|
|
403
|
-
},
|
|
404
|
-
file(key, type) {
|
|
405
|
-
return authored.ask({ kind: 'authored.file', key, type });
|
|
147
|
+
queued: async () => (await (await open()).queued()).filter((locator) => !lost(locator)),
|
|
148
|
+
drafts,
|
|
149
|
+
draft: async (locator, path) => (await drafts(locator, [path]))[0],
|
|
150
|
+
composed: ({ model, declaration }) => compositionOf(model, declaration.typedSelection, options.builtIn, options.typedPaths),
|
|
151
|
+
publication: watchers.publication,
|
|
152
|
+
owing: watchers.owing,
|
|
153
|
+
watch: watchers.watch,
|
|
154
|
+
watching: watchers.watching,
|
|
155
|
+
tell: watchers.tell,
|
|
156
|
+
installs,
|
|
157
|
+
seeds: {
|
|
158
|
+
of: (key) => seeds.get(key),
|
|
159
|
+
keep(key, seed) {
|
|
160
|
+
seeds.set(key, seed);
|
|
161
|
+
},
|
|
162
|
+
drop(key) {
|
|
163
|
+
seeds.delete(key);
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
conflicted,
|
|
167
|
+
attached,
|
|
168
|
+
opened: openedFiles(options.database, lost),
|
|
169
|
+
prepareAgain,
|
|
170
|
+
part: (file, part) => options.database.ask({ kind: 'file.part', key: file, part }),
|
|
171
|
+
forget(locator) {
|
|
172
|
+
typesHeld.delete(locator);
|
|
173
|
+
conflicted.forget(locator);
|
|
174
|
+
attached.forget(locator);
|
|
175
|
+
installs.change(locator, ({ installing }) => ({ ...NO_INSTALL, installing }));
|
|
176
|
+
prepareAgain(locator);
|
|
177
|
+
},
|
|
178
|
+
close() {
|
|
179
|
+
space.stop();
|
|
180
|
+
readiness.close();
|
|
181
|
+
watchers.close();
|
|
406
182
|
},
|
|
407
183
|
};
|
|
408
184
|
}
|
package/dist/stored.d.ts
CHANGED
|
@@ -47,17 +47,28 @@ export type HeldRoomWork = {
|
|
|
47
47
|
readonly state: string;
|
|
48
48
|
}[];
|
|
49
49
|
};
|
|
50
|
-
export type
|
|
51
|
-
readonly
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
export type CoverLog = {
|
|
51
|
+
readonly token: string;
|
|
52
|
+
readonly at: number;
|
|
53
|
+
};
|
|
54
|
+
export type CoveredRow = {
|
|
55
|
+
readonly locator: string;
|
|
56
|
+
readonly handle: string;
|
|
57
|
+
readonly key: number;
|
|
58
|
+
readonly transfer: string;
|
|
59
|
+
readonly roomVersion: string;
|
|
60
|
+
readonly indexed: boolean;
|
|
61
|
+
readonly documents: number;
|
|
62
|
+
readonly bytes: number;
|
|
63
|
+
readonly offline: string;
|
|
64
|
+
};
|
|
65
|
+
export type CoveredRooms = {
|
|
66
|
+
readonly log: CoverLog;
|
|
67
|
+
readonly whole: boolean;
|
|
68
|
+
readonly rooms: readonly CoveredRow[];
|
|
69
|
+
readonly removed: readonly string[];
|
|
70
|
+
};
|
|
71
|
+
export type Covering = CoveredRooms & {
|
|
61
72
|
readonly queues: readonly {
|
|
62
73
|
readonly locator: string;
|
|
63
74
|
readonly ids: readonly string[];
|
|
@@ -139,18 +150,19 @@ export declare function rederive(connection: Connection, key: number, composed:
|
|
|
139
150
|
export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
|
|
140
151
|
export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
|
|
141
152
|
export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
|
|
142
|
-
export declare function folders(connection: Connection, key: number,
|
|
153
|
+
export declare function folders(connection: Connection, key: number, list: readonly string[]): string[];
|
|
143
154
|
export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
|
|
144
155
|
export declare function opened(connection: Connection): ReplicaOpened;
|
|
145
156
|
export declare function heldRooms(connection: Connection, locators: readonly string[] | null): readonly HeldRoomRow[];
|
|
146
157
|
export declare function heldRoom(connection: Connection, locator: string): HeldRoomRow | null;
|
|
147
158
|
export declare function overlaid(connection: Connection, key: number): readonly string[];
|
|
148
|
-
export declare function covering(connection: Connection):
|
|
159
|
+
export declare function covering(connection: Connection, since: CoverLog | null): CoveredRooms;
|
|
149
160
|
export declare function offlineMode(connection: Connection, locator: string): string | null;
|
|
150
161
|
export declare function stagedLocators(connection: Connection): readonly string[];
|
|
151
162
|
export declare function heldLocators(connection: Connection): readonly string[];
|
|
152
163
|
export declare function demoted(connection: Connection): null;
|
|
153
|
-
export declare function facts(connection: Connection): Readonly<Record<string, string>>;
|
|
164
|
+
export declare function facts(connection: Connection, names: readonly string[] | null): Readonly<Record<string, string>>;
|
|
154
165
|
export declare function presentation(connection: Connection, app: string): string | null;
|
|
166
|
+
export declare function tablesOf(statements: readonly string[]): readonly string[];
|
|
155
167
|
export declare function ended(connection: Connection): void;
|
|
156
168
|
//# sourceMappingURL=stored.d.ts.map
|