@agentshouse/mdruntime 0.1.0-c0ffc146f48dd → 0.1.0-c112fd663ab59
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 +10 -10
- package/dist/acceptance.d.ts +6 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +385 -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 +45 -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 +210 -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/change.js +4 -2
- 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 +22 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -2
- 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 +240 -315
- package/dist/connection.d.ts +5 -142
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +103 -5071
- 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 +861 -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/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +1 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/figures.d.ts +49 -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 +25 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +556 -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 +270 -0
- package/dist/listing.d.ts +53 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +176 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +63 -21
- package/dist/locks.d.ts +9 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +62 -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/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +3 -3
- package/dist/memory.d.ts +5 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +50 -10
- package/dist/messages.d.ts +27 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +103 -31
- 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 +197 -0
- package/dist/observation.d.ts +2 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +14 -14
- package/dist/opened.js +3 -3
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +60 -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 +60 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +126 -0
- 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 +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +233 -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 -209
- 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 +13 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +10 -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 -3
- 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 +174 -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 +57 -0
- package/dist/replica.d.ts +9 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +53 -17
- package/dist/room-draft.d.ts +3 -4
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +7 -7
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -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 +5 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +34 -21
- package/dist/saves.d.ts +70 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +1005 -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 -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 +31 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +290 -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 +44 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +90 -0
- package/dist/socket/session.d.ts +38 -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 +82 -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 +431 -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 +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 +107 -145
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +143 -366
- package/dist/stored.d.ts +59 -33
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +278 -189
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +224 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +532 -0
- package/dist/tables.d.ts +120 -29
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +216 -54
- 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 +16 -1
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +6 -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
package/dist/store.js
CHANGED
|
@@ -1,375 +1,152 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}),
|
|
35
|
-
}),
|
|
36
|
-
...(founded === undefined
|
|
37
|
-
? {}
|
|
38
|
-
: {
|
|
39
|
-
founded: founded.map((batch) => ({
|
|
40
|
-
id: batch.id,
|
|
41
|
-
batch: JSON.stringify(batch),
|
|
42
|
-
files: batchFiles(batch),
|
|
43
|
-
})),
|
|
44
|
-
}),
|
|
45
|
-
...(roomDrafts === undefined ? {} : { roomDrafts: roomDrafts.map(roomDraftRow) }),
|
|
46
|
-
...(consumedRoomDrafts === undefined ? {} : { consumedRoomDrafts }),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function marked(value) {
|
|
50
|
-
return typeof value === 'object' && value !== null && FILE in value;
|
|
51
|
-
}
|
|
52
|
-
function keyed(keys, value) {
|
|
53
|
-
const stored = [];
|
|
54
|
-
const files = [];
|
|
55
|
-
const record = JSON.stringify(value, (_name, held) => {
|
|
56
|
-
if (!(held instanceof Blob))
|
|
57
|
-
return held;
|
|
58
|
-
let key = keys.get(held);
|
|
59
|
-
if (key === undefined) {
|
|
60
|
-
key = binaryLocalId();
|
|
61
|
-
keys.set(held, key);
|
|
62
|
-
}
|
|
63
|
-
stored.push({ key, blob: held });
|
|
64
|
-
files.push(key);
|
|
65
|
-
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 { createFences } from './store/fences.js';
|
|
7
|
+
import { createInstalls } from './store/installs.js';
|
|
8
|
+
import { openRuntimeStore, } from './store/records.js';
|
|
9
|
+
import { createReadinessQueue } from './store/readiness.js';
|
|
10
|
+
import { createRoomHeld } from './store/room-held.js';
|
|
11
|
+
import { createSpace } from './store/space.js';
|
|
12
|
+
import { createWatchers } from './store/watchers.js';
|
|
13
|
+
import { createWrites } from './store/writes.js';
|
|
14
|
+
export { NO_INSTALL } from './store/installs.js';
|
|
15
|
+
export function createStore(options) {
|
|
16
|
+
const writes = createWrites();
|
|
17
|
+
const watchers = createWatchers(options.unpublished);
|
|
18
|
+
const fences = createFences();
|
|
19
|
+
const installs = createInstalls();
|
|
20
|
+
const seeds = new Map();
|
|
21
|
+
const landed = createRoomHeld();
|
|
22
|
+
const attached = createRoomHeld();
|
|
23
|
+
const typesHeld = new Map();
|
|
24
|
+
const device = createCell({
|
|
25
|
+
persistence: options.persistence,
|
|
26
|
+
storageLoss: null,
|
|
27
|
+
heldWhenOpened: false,
|
|
28
|
+
preparing: false,
|
|
29
|
+
sweeping: false,
|
|
30
|
+
unpreparedDemand: new Set(),
|
|
31
|
+
establishing: new Set(),
|
|
32
|
+
status: STARTING,
|
|
33
|
+
roomsShown: null,
|
|
66
34
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (typeof value !== 'object' || value === null)
|
|
75
|
-
return value;
|
|
76
|
-
const restored = {};
|
|
77
|
-
for (const [name, item] of Object.entries(value))
|
|
78
|
-
restored[name] = await filed(item, read);
|
|
79
|
-
return restored;
|
|
80
|
-
}
|
|
81
|
-
function json(value, fallback) {
|
|
82
|
-
return value === undefined ? fallback : JSON.parse(value);
|
|
83
|
-
}
|
|
84
|
-
export function openRuntimeStore(fenced, authored) {
|
|
85
|
-
const keys = new WeakMap();
|
|
86
|
-
const read = async (key, type) => {
|
|
87
|
-
const blob = await authored.ask({ kind: 'authored.file', key, type });
|
|
88
|
-
keys.set(blob, key);
|
|
89
|
-
return blob;
|
|
90
|
-
};
|
|
91
|
-
const restored = async (records) => Promise.all(records.map(async (record) => (await filed(JSON.parse(record), read))));
|
|
92
|
-
const amend = async (locator, id, amendment) => {
|
|
93
|
-
if (fenced(locator))
|
|
94
|
-
return;
|
|
95
|
-
await authored.ask({
|
|
96
|
-
kind: 'authored.amend',
|
|
97
|
-
locator,
|
|
98
|
-
id,
|
|
99
|
-
amendment: JSON.stringify(amendment),
|
|
35
|
+
const space = createSpace(options.database, options.spaceFreed);
|
|
36
|
+
const readiness = createReadinessQueue(options.deliverReadiness, options.unpublished);
|
|
37
|
+
let opening;
|
|
38
|
+
function open() {
|
|
39
|
+
opening ??= options.opening(openRuntimeStore(options.database)).catch((error) => {
|
|
40
|
+
opening = undefined;
|
|
41
|
+
throw error;
|
|
100
42
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
43
|
+
return opening;
|
|
44
|
+
}
|
|
45
|
+
function typed(locator, persisted) {
|
|
46
|
+
if (persisted.status === 'unavailable')
|
|
47
|
+
return persisted;
|
|
48
|
+
const schema = persisted.snapshot.schema;
|
|
49
|
+
const held = typesHeld.get(locator);
|
|
50
|
+
if (held !== undefined && held.schema === schema)
|
|
51
|
+
return { ...persisted, types: held.types };
|
|
52
|
+
const types = schemaTypes(schema, options.roomTypes);
|
|
53
|
+
typesHeld.set(locator, { schema, types });
|
|
54
|
+
return { ...persisted, types };
|
|
55
|
+
}
|
|
56
|
+
function recordOf(stored) {
|
|
57
|
+
return { ...stored, model: typed(stored.locator, stored.model) };
|
|
58
|
+
}
|
|
59
|
+
async function rooms(locators) {
|
|
60
|
+
const held = await (await open()).rooms(locators);
|
|
61
|
+
return new Map(held
|
|
62
|
+
.filter(({ record }) => !fences.has(record.locator))
|
|
63
|
+
.map(({ record, indexed, documents }) => [
|
|
64
|
+
record.locator,
|
|
65
|
+
{ record: recordOf(record), indexed, documents },
|
|
66
|
+
]));
|
|
67
|
+
}
|
|
68
|
+
async function work(locator) {
|
|
69
|
+
if (fences.has(locator))
|
|
70
|
+
return { replica: undefined, queue: [], states: new Map() };
|
|
71
|
+
const { room, queue } = await (await open()).room(locator);
|
|
72
|
+
const batches = queue.map(({ batch }) => batch);
|
|
73
|
+
const states = new Map(queue.map(({ batch, state }) => [batch.id, state]));
|
|
74
|
+
return {
|
|
75
|
+
replica: room === null
|
|
76
|
+
? undefined
|
|
77
|
+
: { record: recordOf(room.record), queue: batches, states, overlaid: room.overlaid },
|
|
78
|
+
queue: batches,
|
|
79
|
+
states,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
async function drafts(locator, paths) {
|
|
83
|
+
const held = await (await open()).roomDrafts(locator, paths);
|
|
84
|
+
return held.filter((record) => !fences.has(record.locator));
|
|
85
|
+
}
|
|
113
86
|
return {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
87
|
+
device,
|
|
88
|
+
space,
|
|
89
|
+
readiness,
|
|
90
|
+
ask: options.database.ask,
|
|
91
|
+
changed: options.changed,
|
|
92
|
+
open,
|
|
93
|
+
durably: (work) => writes.exclusive(async () => {
|
|
94
|
+
const local = await open();
|
|
95
|
+
return work(local);
|
|
96
|
+
}),
|
|
97
|
+
exclusive: writes.exclusive,
|
|
98
|
+
gathered: writes.gathered,
|
|
99
|
+
written: writes.written,
|
|
100
|
+
startingWrite: writes.startingWrite,
|
|
101
|
+
finishingWrite: writes.finishingWrite,
|
|
102
|
+
ahead: writes.ahead,
|
|
103
|
+
rederive: writes.rederive,
|
|
104
|
+
refreshPage: writes.refreshPage,
|
|
105
|
+
stageBytes: writes.stageBytes,
|
|
106
|
+
deriveBytes: writes.deriveBytes,
|
|
107
|
+
rooms,
|
|
108
|
+
record: async (locator) => (await rooms([locator])).get(locator)?.record,
|
|
109
|
+
work,
|
|
110
|
+
replica: async (locator) => (await work(locator)).replica,
|
|
111
|
+
async covering() {
|
|
112
|
+
const held = await (await open()).covering();
|
|
123
113
|
return {
|
|
124
|
-
rooms: new Map(held.rooms
|
|
125
|
-
|
|
126
|
-
.map(({ locator, key, record }) => [
|
|
127
|
-
locator,
|
|
128
|
-
{ ...JSON.parse(record), key },
|
|
129
|
-
])),
|
|
130
|
-
unindexed,
|
|
131
|
-
overlaid,
|
|
132
|
-
erasing: held.erasing.length > 0,
|
|
133
|
-
orphans: held.orphans,
|
|
134
|
-
lastCompleted: json(held.facts.lastCompleted, null),
|
|
135
|
-
providerLimits: json(held.facts.providerLimits, []),
|
|
136
|
-
capabilities: json(held.facts.capabilities, []),
|
|
137
|
-
member: json(held.facts.member, null),
|
|
138
|
-
targets: json(held.facts.targets, {}),
|
|
139
|
-
presentation: held.presentation.map(({ app, value }) => ({
|
|
140
|
-
app,
|
|
141
|
-
value: JSON.parse(value),
|
|
142
|
-
})),
|
|
143
|
-
conversationList: json(held.facts.conversationList, null),
|
|
144
|
-
conversationCursor: json(held.facts.conversationCursor, null),
|
|
114
|
+
rooms: new Map([...held.rooms].filter(([locator]) => !fences.has(locator))),
|
|
115
|
+
queues: new Map([...held.queues].filter(([locator]) => !fences.has(locator))),
|
|
145
116
|
};
|
|
146
117
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return null;
|
|
180
|
-
return authored.ask({
|
|
181
|
-
kind: 'replica.stage',
|
|
182
|
-
locator: record.locator,
|
|
183
|
-
transfer: record.transfer,
|
|
184
|
-
key: record.key,
|
|
185
|
-
fingerprint: composedOf(composition).fingerprint,
|
|
186
|
-
entries: page.entries,
|
|
187
|
-
folders: page.folders,
|
|
188
|
-
});
|
|
189
|
-
},
|
|
190
|
-
async refresh(key, composition, page) {
|
|
191
|
-
await authored.ask({
|
|
192
|
-
kind: 'replica.refresh',
|
|
193
|
-
key,
|
|
194
|
-
composed: composedOf(composition),
|
|
195
|
-
entries: page.entries,
|
|
196
|
-
removals: page.removals,
|
|
197
|
-
folders: page.folders,
|
|
198
|
-
folderRemovals: page.folderRemovals,
|
|
199
|
-
});
|
|
200
|
-
},
|
|
201
|
-
async unrefresh(key) {
|
|
202
|
-
await authored.ask({ kind: 'replica.unrefresh', key });
|
|
203
|
-
},
|
|
204
|
-
async commit({ rooms, writes = [], files = [], whole = false, discards = [] }) {
|
|
205
|
-
const kept = whole ? writes : writes.filter(({ locator }) => !fenced(locator));
|
|
206
|
-
const refused = whole ? kept.find(({ locator }) => fenced(locator)) : undefined;
|
|
207
|
-
if (refused !== undefined) {
|
|
208
|
-
return { fenced: refused.locator, counts: {}, changed: {}, indexed: {} };
|
|
209
|
-
}
|
|
210
|
-
for (const room of rooms)
|
|
211
|
-
change(room.key);
|
|
212
|
-
const committed = await authored.ask({
|
|
213
|
-
kind: 'replica.commit',
|
|
214
|
-
...(kept.length === 0 && files.length === 0 && discards.length === 0
|
|
215
|
-
? {}
|
|
216
|
-
: { authored: { writes: rows(kept), files, whole, discards } }),
|
|
217
|
-
rooms: rooms.filter(({ locator }) => !fenced(locator)),
|
|
218
|
-
});
|
|
219
|
-
if (committed.fenced === null || !whole)
|
|
220
|
-
noted(kept);
|
|
221
|
-
for (const locator of discards)
|
|
222
|
-
queued.delete(locator);
|
|
223
|
-
return committed;
|
|
224
|
-
},
|
|
225
|
-
async fence(locators) {
|
|
226
|
-
await authored.ask({ kind: 'replica.fence', locators });
|
|
227
|
-
for (const locator of locators)
|
|
228
|
-
queued.delete(locator);
|
|
229
|
-
},
|
|
230
|
-
async erase(locator, limit) {
|
|
231
|
-
return (await authored.ask({ kind: 'replica.erase', locator, limit })).remaining;
|
|
232
|
-
},
|
|
233
|
-
async abandon(locator) {
|
|
234
|
-
if (fenced(locator))
|
|
235
|
-
return;
|
|
236
|
-
await authored.ask({ kind: 'replica.abandon', locator });
|
|
237
|
-
},
|
|
238
|
-
async release(key) {
|
|
239
|
-
await authored.ask({ kind: 'replica.release', key });
|
|
240
|
-
},
|
|
241
|
-
async rederive(key, composition, bytes, ms, floor) {
|
|
242
|
-
change(key);
|
|
243
|
-
return authored.ask({
|
|
244
|
-
kind: 'replica.rederive',
|
|
245
|
-
key,
|
|
246
|
-
composed: composedOf(composition),
|
|
247
|
-
bytes,
|
|
248
|
-
ms,
|
|
249
|
-
floor,
|
|
250
|
-
});
|
|
251
|
-
},
|
|
252
|
-
async fact(name, value) {
|
|
253
|
-
await authored.ask({ kind: 'replica.fact', name, value: JSON.stringify(value) });
|
|
254
|
-
},
|
|
255
|
-
async queues() {
|
|
256
|
-
const { queues, pending } = await authored.ask({ kind: 'authored.queues' });
|
|
257
|
-
queued.clear();
|
|
258
|
-
for (const queue of queues)
|
|
259
|
-
queued.set(queue.locator, new Set(queue.ids));
|
|
260
|
-
const byId = new Map(pending.map((record) => [`${record.locator}\0${record.id}`, record]));
|
|
261
|
-
return queues
|
|
262
|
-
.filter((queue) => !fenced(queue.locator))
|
|
263
|
-
.map((queue) => ({
|
|
264
|
-
locator: queue.locator,
|
|
265
|
-
pending: queue.ids.map((id) => {
|
|
266
|
-
const record = byId.get(`${queue.locator}\0${id}`);
|
|
267
|
-
if (record === undefined)
|
|
268
|
-
throw new Error(`Missing Pending Change ${queue.locator}/${id}`);
|
|
269
|
-
return {
|
|
270
|
-
batch: JSON.parse(record.batch),
|
|
271
|
-
state: JSON.parse(record.state),
|
|
272
|
-
};
|
|
273
|
-
}),
|
|
274
|
-
}));
|
|
275
|
-
},
|
|
276
|
-
submit(locator, id, submission, lost) {
|
|
277
|
-
return amend(locator, id, { submission, lost });
|
|
278
|
-
},
|
|
279
|
-
keepUpload(locator, id, upload) {
|
|
280
|
-
return amend(locator, id, { upload });
|
|
281
|
-
},
|
|
282
|
-
async roomDrafts() {
|
|
283
|
-
const held = await authored.ask({ kind: 'authored.roomDrafts' });
|
|
284
|
-
return held
|
|
285
|
-
.map((record) => JSON.parse(record))
|
|
286
|
-
.filter((record) => !fenced(record.locator));
|
|
287
|
-
},
|
|
288
|
-
async present(record) {
|
|
289
|
-
await authored.ask({
|
|
290
|
-
kind: 'replica.present',
|
|
291
|
-
app: record.app,
|
|
292
|
-
value: JSON.stringify(record.value ?? null),
|
|
293
|
-
});
|
|
294
|
-
},
|
|
295
|
-
conversations() {
|
|
296
|
-
return authored.ask({ kind: 'conversation.held' });
|
|
297
|
-
},
|
|
298
|
-
async keepMessages(write) {
|
|
299
|
-
await authored.ask({ kind: 'conversation.keep', ...write });
|
|
300
|
-
},
|
|
301
|
-
messageWindow(conversation, limit, before) {
|
|
302
|
-
return authored.ask({ kind: 'conversation.window', conversation, limit, before });
|
|
303
|
-
},
|
|
304
|
-
messageCount(conversation) {
|
|
305
|
-
return authored.ask({ kind: 'conversation.count', conversation });
|
|
306
|
-
},
|
|
307
|
-
turnArrived(conversation, turn) {
|
|
308
|
-
return authored.ask({ kind: 'conversation.turn', conversation, turn });
|
|
309
|
-
},
|
|
310
|
-
async dropConversations(conversations) {
|
|
311
|
-
await authored.ask({ kind: 'conversation.drop', conversations });
|
|
312
|
-
},
|
|
313
|
-
async chatDrafts() {
|
|
314
|
-
const records = await authored.ask({ kind: 'authored.chatDrafts' });
|
|
315
|
-
return records.map((record) => JSON.parse(record));
|
|
316
|
-
},
|
|
317
|
-
async keepChatDrafts(records) {
|
|
318
|
-
await authored.ask({
|
|
319
|
-
kind: 'authored.chatDraft',
|
|
320
|
-
kept: records.map((record) => ({
|
|
321
|
-
conversation: record.conversation,
|
|
322
|
-
record: JSON.stringify(record),
|
|
323
|
-
})),
|
|
324
|
-
dropped: [],
|
|
325
|
-
});
|
|
326
|
-
},
|
|
327
|
-
async dropChatDraft(conversation) {
|
|
328
|
-
await authored.ask({ kind: 'authored.chatDraft', kept: [], dropped: [conversation] });
|
|
329
|
-
},
|
|
330
|
-
async calls() {
|
|
331
|
-
return restored(await authored.ask({ kind: 'authored.calls' }));
|
|
332
|
-
},
|
|
333
|
-
async keepCall(record) {
|
|
334
|
-
const { stored, ...kept } = keyed(keys, record);
|
|
335
|
-
await authored.ask({
|
|
336
|
-
kind: 'authored.call',
|
|
337
|
-
operation: record.operation,
|
|
338
|
-
kept,
|
|
339
|
-
files: stored,
|
|
340
|
-
});
|
|
341
|
-
},
|
|
342
|
-
async dropCall(operation) {
|
|
343
|
-
await authored.ask({ kind: 'authored.call', operation, kept: null, files: [] });
|
|
344
|
-
},
|
|
345
|
-
async keepRoomDraft(record, files) {
|
|
346
|
-
if (fenced(record.locator))
|
|
347
|
-
return;
|
|
348
|
-
const { path, ...kept } = roomDraftRow(record);
|
|
349
|
-
await authored.ask({
|
|
350
|
-
kind: 'authored.roomDraft',
|
|
351
|
-
locator: record.locator,
|
|
352
|
-
path,
|
|
353
|
-
kept,
|
|
354
|
-
files,
|
|
355
|
-
});
|
|
356
|
-
},
|
|
357
|
-
async discardRoomDraft(locator, path) {
|
|
358
|
-
if (fenced(locator))
|
|
359
|
-
return;
|
|
360
|
-
await authored.ask({ kind: 'authored.roomDraft', locator, path, kept: null, files: [] });
|
|
361
|
-
},
|
|
362
|
-
fences() {
|
|
363
|
-
return authored.ask({ kind: 'authored.fences' });
|
|
364
|
-
},
|
|
365
|
-
generation() {
|
|
366
|
-
return fact('generation');
|
|
367
|
-
},
|
|
368
|
-
async rememberGeneration(value) {
|
|
369
|
-
await authored.ask({ kind: 'authored.remember', name: 'generation', value });
|
|
370
|
-
},
|
|
371
|
-
file(key, type) {
|
|
372
|
-
return authored.ask({ kind: 'authored.file', key, type });
|
|
118
|
+
drafts,
|
|
119
|
+
draft: async (locator, path) => (await drafts(locator, [path]))[0],
|
|
120
|
+
composed: (record) => compositionOf(record, options.builtIn, options.typedPaths),
|
|
121
|
+
publication: watchers.publication,
|
|
122
|
+
owing: watchers.owing,
|
|
123
|
+
watch: watchers.watch,
|
|
124
|
+
watching: watchers.watching,
|
|
125
|
+
tell: watchers.tell,
|
|
126
|
+
fences,
|
|
127
|
+
installs,
|
|
128
|
+
seeds: {
|
|
129
|
+
of: (key) => seeds.get(key),
|
|
130
|
+
keep(key, seed) {
|
|
131
|
+
seeds.set(key, seed);
|
|
132
|
+
},
|
|
133
|
+
drop(key) {
|
|
134
|
+
seeds.delete(key);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
landed,
|
|
138
|
+
attached,
|
|
139
|
+
opened: openedFiles(options.database, fences.has),
|
|
140
|
+
part: (file, part) => options.database.ask({ kind: 'file.part', key: file, part }),
|
|
141
|
+
forget(locator) {
|
|
142
|
+
typesHeld.delete(locator);
|
|
143
|
+
landed.forget(locator);
|
|
144
|
+
attached.forget(locator);
|
|
145
|
+
},
|
|
146
|
+
close() {
|
|
147
|
+
space.stop();
|
|
148
|
+
readiness.close();
|
|
149
|
+
watchers.close();
|
|
373
150
|
},
|
|
374
151
|
};
|
|
375
152
|
}
|
package/dist/stored.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HeadChange } from './adapter.js';
|
|
1
|
+
import type { SavedFacts, HeadChange } from './adapter.js';
|
|
2
2
|
import { type Composed, type Composition } from './collection.js';
|
|
3
3
|
import type { HeldBinary } from './overlay.js';
|
|
4
4
|
import type { Connection } from './tables.js';
|
|
@@ -10,8 +10,10 @@ export type StoredEntry = {
|
|
|
10
10
|
readonly binary: HeldBinary | null;
|
|
11
11
|
readonly revision: string | null;
|
|
12
12
|
readonly fileId: string | null;
|
|
13
|
+
readonly created: string | null;
|
|
13
14
|
readonly change: HeadChange | null;
|
|
14
15
|
readonly written: string | null;
|
|
16
|
+
readonly facts: SavedFacts | null;
|
|
15
17
|
};
|
|
16
18
|
export type OverlayEntry = StoredEntry & {
|
|
17
19
|
readonly present: boolean;
|
|
@@ -27,35 +29,46 @@ export type TypedEntry = {
|
|
|
27
29
|
export type Referrer = {
|
|
28
30
|
readonly path: string;
|
|
29
31
|
readonly target: string;
|
|
30
|
-
readonly kind: string;
|
|
31
32
|
};
|
|
32
|
-
export type
|
|
33
|
-
readonly key: number;
|
|
33
|
+
export type HeldRoomRow = {
|
|
34
34
|
readonly locator: string;
|
|
35
|
-
readonly
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
35
|
+
readonly key: number;
|
|
36
|
+
readonly record: string;
|
|
37
|
+
readonly indexed: boolean;
|
|
38
|
+
readonly documents: number;
|
|
38
39
|
};
|
|
39
|
-
export type
|
|
40
|
+
export type HeldRoomWork = {
|
|
41
|
+
readonly room: (HeldRoomRow & {
|
|
42
|
+
readonly overlaid: readonly string[];
|
|
43
|
+
}) | null;
|
|
44
|
+
readonly queue: readonly {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly batch: string;
|
|
47
|
+
readonly state: string;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
50
|
+
export type Covering = {
|
|
40
51
|
readonly rooms: readonly {
|
|
41
52
|
readonly locator: string;
|
|
42
53
|
readonly key: number;
|
|
43
|
-
readonly
|
|
54
|
+
readonly transfer: string;
|
|
55
|
+
readonly roomVersion: string;
|
|
56
|
+
readonly indexed: boolean;
|
|
57
|
+
readonly documents: number;
|
|
58
|
+
readonly bytes: number;
|
|
59
|
+
readonly offline: string;
|
|
44
60
|
}[];
|
|
45
|
-
readonly
|
|
46
|
-
readonly facts: Readonly<Record<string, string>>;
|
|
47
|
-
readonly presentation: readonly {
|
|
48
|
-
readonly app: string;
|
|
49
|
-
readonly value: string;
|
|
50
|
-
}[];
|
|
51
|
-
readonly overlaid: readonly {
|
|
52
|
-
readonly key: number;
|
|
53
|
-
readonly path: string;
|
|
54
|
-
}[];
|
|
55
|
-
readonly erasing: readonly {
|
|
56
|
-
readonly key: number;
|
|
61
|
+
readonly queues: readonly {
|
|
57
62
|
readonly locator: string;
|
|
63
|
+
readonly ids: readonly string[];
|
|
58
64
|
}[];
|
|
65
|
+
};
|
|
66
|
+
export type HeldLocators = {
|
|
67
|
+
readonly held: readonly string[];
|
|
68
|
+
readonly staged: readonly string[];
|
|
69
|
+
};
|
|
70
|
+
export type ReplicaOpened = {
|
|
71
|
+
readonly erasing: boolean;
|
|
59
72
|
readonly orphans: readonly number[];
|
|
60
73
|
};
|
|
61
74
|
export type RoomCommit = {
|
|
@@ -78,14 +91,9 @@ export type RoomCommit = {
|
|
|
78
91
|
};
|
|
79
92
|
};
|
|
80
93
|
export type Committed = {
|
|
81
|
-
readonly counts: Readonly<Record<string, number>>;
|
|
82
94
|
readonly changed: Readonly<Record<string, readonly string[] | null>>;
|
|
83
95
|
readonly indexed: Readonly<Record<string, boolean>>;
|
|
84
96
|
};
|
|
85
|
-
export type CountedRoom = {
|
|
86
|
-
readonly key: number;
|
|
87
|
-
readonly roots: readonly string[];
|
|
88
|
-
};
|
|
89
97
|
export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
|
|
90
98
|
export declare function stage(connection: Connection, request: {
|
|
91
99
|
readonly locator: string;
|
|
@@ -94,7 +102,20 @@ export declare function stage(connection: Connection, request: {
|
|
|
94
102
|
readonly fingerprint: string;
|
|
95
103
|
readonly entries: readonly StoredEntry[];
|
|
96
104
|
readonly folders: readonly string[];
|
|
105
|
+
readonly part: string | null;
|
|
97
106
|
}): number;
|
|
107
|
+
export type Resumed = {
|
|
108
|
+
readonly key: number | null;
|
|
109
|
+
readonly transfer: string;
|
|
110
|
+
readonly staged: readonly string[];
|
|
111
|
+
};
|
|
112
|
+
export declare function resume(connection: Connection, request: {
|
|
113
|
+
readonly locator: string;
|
|
114
|
+
readonly transfer: string;
|
|
115
|
+
readonly fingerprint: string;
|
|
116
|
+
readonly parts: readonly string[];
|
|
117
|
+
readonly published: number | null;
|
|
118
|
+
}): Resumed;
|
|
98
119
|
export declare function refreshing(connection: Connection, request: {
|
|
99
120
|
readonly key: number;
|
|
100
121
|
readonly composed: Composed;
|
|
@@ -104,7 +125,6 @@ export declare function refreshing(connection: Connection, request: {
|
|
|
104
125
|
readonly folderRemovals: readonly string[];
|
|
105
126
|
}): null;
|
|
106
127
|
export declare function unrefresh(connection: Connection, key: number): null;
|
|
107
|
-
export declare function counts(connection: Connection, rooms: readonly CountedRoom[]): number[];
|
|
108
128
|
export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
|
|
109
129
|
export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
|
|
110
130
|
export declare function abandon(connection: Connection, locator: string): null;
|
|
@@ -118,13 +138,19 @@ export declare function rederive(connection: Connection, key: number, composed:
|
|
|
118
138
|
};
|
|
119
139
|
export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
|
|
120
140
|
export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
|
|
121
|
-
export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]
|
|
122
|
-
export declare function
|
|
123
|
-
readonly path: string;
|
|
124
|
-
readonly revision: string;
|
|
125
|
-
}[];
|
|
126
|
-
export declare function folders(connection: Connection, key: number, view: View, list: readonly string[]): string[];
|
|
141
|
+
export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
|
|
142
|
+
export declare function folders(connection: Connection, key: number, list: readonly string[]): string[];
|
|
127
143
|
export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
|
|
128
144
|
export declare function opened(connection: Connection): ReplicaOpened;
|
|
145
|
+
export declare function heldRooms(connection: Connection, locators: readonly string[] | null): readonly HeldRoomRow[];
|
|
146
|
+
export declare function heldRoom(connection: Connection, locator: string): HeldRoomRow | null;
|
|
147
|
+
export declare function overlaid(connection: Connection, key: number): readonly string[];
|
|
148
|
+
export declare function covering(connection: Connection): Covering['rooms'];
|
|
149
|
+
export declare function offlineMode(connection: Connection, locator: string): string | null;
|
|
150
|
+
export declare function stagedLocators(connection: Connection): readonly string[];
|
|
151
|
+
export declare function heldLocators(connection: Connection): readonly string[];
|
|
152
|
+
export declare function demoted(connection: Connection): null;
|
|
153
|
+
export declare function facts(connection: Connection): Readonly<Record<string, string>>;
|
|
154
|
+
export declare function presentation(connection: Connection, app: string): string | null;
|
|
129
155
|
export declare function ended(connection: Connection): void;
|
|
130
156
|
//# sourceMappingURL=stored.d.ts.map
|