@agentshouse/mdruntime 0.1.0-c1e540acf5f9d → 0.1.0-c1ea23b9ca7c6
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 +14 -13
- package/dist/acceptance.js +1 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +24 -5
- package/dist/adapter.d.ts +74 -2
- package/dist/adapter.d.ts.map +1 -1
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/client.d.ts +10 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +14 -44
- package/dist/collection.d.ts +5 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +16 -8
- 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.map +1 -1
- package/dist/compile.js +2 -3
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +8 -4
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +7 -2
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +3 -0
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +8 -4
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +41 -22
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +30 -5
- 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 +1 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +3 -0
- package/dist/entry.d.ts +14 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +45 -16
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/host.d.ts +5 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +42 -13
- package/dist/house-query.d.ts +15 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +43 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/install.d.ts +8 -2
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +40 -33
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +37 -24
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +71 -30
- 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.map +1 -1
- package/dist/locks.js +4 -2
- package/dist/lost.js +1 -1
- package/dist/media.d.ts +18 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +114 -24
- package/dist/memory.d.ts +2 -0
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +41 -9
- package/dist/messages.d.ts +3 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +9 -3
- 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 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +3 -3
- package/dist/observation.d.ts +26 -10
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +200 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +18 -2
- package/dist/outcome.d.ts +10 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +17 -2
- package/dist/overlay.d.ts +1 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +3 -5
- package/dist/parts.d.ts +3 -1
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -7
- package/dist/preparation.d.ts +32 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +186 -78
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +62 -57
- package/dist/questions.d.ts +1 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +51 -21
- package/dist/reach.d.ts +14 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +102 -16
- package/dist/react.d.ts +5 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +15 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +10 -10
- package/dist/reads.d.ts +1 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +2 -2
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +2 -1
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +2 -2
- package/dist/room-draft.d.ts +28 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +230 -12
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +5 -2
- 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 +6 -6
- 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 +3 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +17 -86
- package/dist/saves.d.ts +2 -0
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +41 -14
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +3 -1
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +62 -38
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +1 -0
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +1 -0
- package/dist/source.d.ts +5 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +13 -2
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +13 -1
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +49 -20
- 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.d.ts +14 -9
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +12 -5
- package/dist/stored.d.ts +31 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +180 -44
- package/dist/surface.d.ts +10 -5
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +48 -15
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +46 -24
- package/dist/tables.d.ts +10 -49
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +60 -322
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +3 -9
- package/dist/wire.d.ts +22 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +11 -7
- package/package.json +3 -3
package/dist/save.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { apply, ARRAY_INDEX, ATTACHMENT, create,
|
|
2
|
-
import { immutable, leaving, queuedFile, departure, } from './change.js';
|
|
3
|
-
import { collectionOf, definitionsAt, documentsOf, governing, } from './collection.js';
|
|
1
|
+
import { apply, ARRAY_INDEX, ATTACHMENT, create, links, parse, pointerSegments, references, relative, relativize, retarget, roomReferences, serialize, target, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { immutable, isPart, leaving, queuedFile, departure, } from './change.js';
|
|
3
|
+
import { collectionOf, definitionsAt, documentsOf, governing, textType, typedText, } from './collection.js';
|
|
4
4
|
import { changeBatchIdentity, roomDraftRevision } from './identity.js';
|
|
5
5
|
import { composed, overlaying } from './overlay.js';
|
|
6
6
|
import { ancestors } from './paths.js';
|
|
7
7
|
import { entriesIn, sorting } from './shared.js';
|
|
8
|
-
import { changedParts, changesOf, moveTarget, withdrawnDrafts, } from './room-draft.js';
|
|
8
|
+
import { applyParts, changedParts, changesOf, moveTarget, partsBetween, withdrawnDrafts, } from './room-draft.js';
|
|
9
9
|
import { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
10
10
|
import { validatedCollection } from './validation.js';
|
|
11
11
|
function refuse(code, file, location, line) {
|
|
@@ -52,48 +52,6 @@ function repointed(document, definition, from, to, moves, settled) {
|
|
|
52
52
|
const next = applied.document;
|
|
53
53
|
return [...names].map((name) => ({ kind: 'field', path: from, name, value: next.fields[name] }));
|
|
54
54
|
}
|
|
55
|
-
function edited(document, changes, definition) {
|
|
56
|
-
const parts = new Map();
|
|
57
|
-
for (const change of changes) {
|
|
58
|
-
if (change.kind === 'field')
|
|
59
|
-
parts.set(`field ${change.name}`, {
|
|
60
|
-
kind: 'field',
|
|
61
|
-
name: change.name,
|
|
62
|
-
value: change.value,
|
|
63
|
-
prior: document.fields[change.name],
|
|
64
|
-
});
|
|
65
|
-
if (change.kind === 'preamble')
|
|
66
|
-
parts.set('preamble', { kind: 'preamble', value: change.value, prior: document.preamble });
|
|
67
|
-
if (change.kind === 'section')
|
|
68
|
-
parts.set(`section ${change.name}`, {
|
|
69
|
-
kind: 'section',
|
|
70
|
-
name: change.name,
|
|
71
|
-
value: change.value,
|
|
72
|
-
prior: document.sections[change.name] ?? '',
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (parts.size === 0)
|
|
76
|
-
return document;
|
|
77
|
-
const applied = apply(document, [...parts.values()], definition);
|
|
78
|
-
return applied.outcome === 'applied' ? applied.document : document;
|
|
79
|
-
}
|
|
80
|
-
function bodies(path, before, after) {
|
|
81
|
-
const changes = [];
|
|
82
|
-
for (const [name, value] of Object.entries(after.fields)) {
|
|
83
|
-
if (equalValue(before.fields[name], value))
|
|
84
|
-
continue;
|
|
85
|
-
changes.push({ kind: 'field', path, name, value });
|
|
86
|
-
}
|
|
87
|
-
if (after.preamble !== before.preamble) {
|
|
88
|
-
changes.push({ kind: 'preamble', path, value: after.preamble });
|
|
89
|
-
}
|
|
90
|
-
for (const [name, value] of Object.entries(after.sections)) {
|
|
91
|
-
if (before.sections[name] === value)
|
|
92
|
-
continue;
|
|
93
|
-
changes.push({ kind: 'section', path, name, value });
|
|
94
|
-
}
|
|
95
|
-
return changes;
|
|
96
|
-
}
|
|
97
55
|
function relinks(path, moved, before, moves, definition) {
|
|
98
56
|
const changes = [];
|
|
99
57
|
for (const link of links(before, path)) {
|
|
@@ -116,7 +74,7 @@ function relinks(path, moved, before, moves, definition) {
|
|
|
116
74
|
if (before.type === undefined) {
|
|
117
75
|
return { kind: 'changes', changes: [{ kind: 'replace', path, content: serialize(after) }] };
|
|
118
76
|
}
|
|
119
|
-
return { kind: 'changes', changes:
|
|
77
|
+
return { kind: 'changes', changes: partsBetween(path, before, after) };
|
|
120
78
|
}
|
|
121
79
|
function partKey(change) {
|
|
122
80
|
return change.kind === 'section' || change.kind === 'field'
|
|
@@ -168,9 +126,10 @@ function* rewrites(changes, visible) {
|
|
|
168
126
|
const repointing = repointed(document, definition, path, moved, moves, settled);
|
|
169
127
|
added.push(...repointing);
|
|
170
128
|
const own = parts.get(path) ?? [];
|
|
129
|
+
const edited = applyParts(document, own.map((index) => merged[index]), definition);
|
|
171
130
|
const relinked = moved === path && own.length === 0 && cannotLink(document.content, names)
|
|
172
131
|
? { kind: 'changes', changes: [] }
|
|
173
|
-
: relinks(path, moved, edited
|
|
132
|
+
: relinks(path, moved, edited.outcome === 'applied' ? edited.document : document, moves, definition);
|
|
174
133
|
if (relinked.kind === 'refused')
|
|
175
134
|
return relinked;
|
|
176
135
|
const keyed = new Map();
|
|
@@ -248,7 +207,7 @@ function rewritten(path, document, changes, definition) {
|
|
|
248
207
|
const after = applied.document;
|
|
249
208
|
if (document.type === undefined)
|
|
250
209
|
return [{ kind: 'replace', path, content: serialize(after) }];
|
|
251
|
-
return
|
|
210
|
+
return partsBetween(path, document, after);
|
|
252
211
|
}
|
|
253
212
|
function roomPathOf(handle, path) {
|
|
254
213
|
return `/rooms/${handle}/${path}`;
|
|
@@ -458,7 +417,7 @@ function* preconditionsOf(changes, visible, bases) {
|
|
|
458
417
|
};
|
|
459
418
|
for (const change of changes) {
|
|
460
419
|
yield ROW_WEIGHT;
|
|
461
|
-
if (change
|
|
420
|
+
if (isPart(change)) {
|
|
462
421
|
const based = bases.find((base) => sameTarget(base, change));
|
|
463
422
|
if (based !== undefined) {
|
|
464
423
|
add(based);
|
|
@@ -613,9 +572,6 @@ function relativeChange(change, input) {
|
|
|
613
572
|
function unqueueable(file) {
|
|
614
573
|
return refuse('unknown-revision', file);
|
|
615
574
|
}
|
|
616
|
-
function isPart(change) {
|
|
617
|
-
return change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble';
|
|
618
|
-
}
|
|
619
575
|
function touched(change) {
|
|
620
576
|
return change.kind === 'move' ? [change.path, change.to] : [change.path];
|
|
621
577
|
}
|
|
@@ -642,29 +598,7 @@ function unapplied(changes, visible, composition) {
|
|
|
642
598
|
function partsResult(content, path, changes, composition) {
|
|
643
599
|
const definitions = definitionsAt(composition, path);
|
|
644
600
|
const parsed = parse(content, path, definitions);
|
|
645
|
-
|
|
646
|
-
return null;
|
|
647
|
-
const document = parsed.document;
|
|
648
|
-
const parts = new Map();
|
|
649
|
-
for (const change of changes) {
|
|
650
|
-
if (change.kind === 'field')
|
|
651
|
-
parts.set(`field ${change.name}`, {
|
|
652
|
-
kind: 'field',
|
|
653
|
-
name: change.name,
|
|
654
|
-
value: change.value,
|
|
655
|
-
prior: document.fields[change.name],
|
|
656
|
-
});
|
|
657
|
-
else if (change.kind === 'section')
|
|
658
|
-
parts.set(`section ${change.name}`, {
|
|
659
|
-
kind: 'section',
|
|
660
|
-
name: change.name,
|
|
661
|
-
value: change.value,
|
|
662
|
-
prior: document.sections[change.name] ?? '',
|
|
663
|
-
});
|
|
664
|
-
else
|
|
665
|
-
parts.set('preamble', { kind: 'preamble', value: change.value, prior: document.preamble });
|
|
666
|
-
}
|
|
667
|
-
return apply(document, [...parts.values()], definitions(document.type));
|
|
601
|
+
return parsed.ok ? applyParts(parsed.document, changes, definitions(parsed.document.type)) : null;
|
|
668
602
|
}
|
|
669
603
|
function settledParts(changes, deferred, composition) {
|
|
670
604
|
for (const [held, parts] of deferred) {
|
|
@@ -883,11 +817,8 @@ function* limiting(queue, batch, limits, state) {
|
|
|
883
817
|
const limited = yield* exceeding(limits, batch.changes, rewritten.changes, yield* state(queue.slice(0, at + 1)));
|
|
884
818
|
return limited?.refusal ?? null;
|
|
885
819
|
}
|
|
886
|
-
function
|
|
887
|
-
|
|
888
|
-
return false;
|
|
889
|
-
const parsed = parse(content);
|
|
890
|
-
return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
|
|
820
|
+
function typedContent(content) {
|
|
821
|
+
return content !== undefined && typedText(parse(content));
|
|
891
822
|
}
|
|
892
823
|
function touchedLibrary(resulting, touched, composition) {
|
|
893
824
|
const entries = touched
|
|
@@ -907,9 +838,9 @@ function touchedLibrary(resulting, touched, composition) {
|
|
|
907
838
|
if (binaries.has(path))
|
|
908
839
|
known.set(path, { type: undefined, binary: true });
|
|
909
840
|
else if (content !== undefined && content !== null) {
|
|
910
|
-
const
|
|
911
|
-
if (
|
|
912
|
-
known.set(path, { type
|
|
841
|
+
const type = textType(parse(content, path, definitionsAt(composition, path)));
|
|
842
|
+
if (type !== undefined)
|
|
843
|
+
known.set(path, { type, binary: false });
|
|
913
844
|
await pace(content.length + ROW_WEIGHT);
|
|
914
845
|
}
|
|
915
846
|
}
|
|
@@ -927,7 +858,7 @@ async function judging(visible, resulting, composition, validate, removed, touch
|
|
|
927
858
|
for (const path of touched) {
|
|
928
859
|
const before = visible.documents[path];
|
|
929
860
|
const after = resulting.documents[path];
|
|
930
|
-
if (
|
|
861
|
+
if (typedContent(before) || typedContent(after))
|
|
931
862
|
typedPaths.push(path);
|
|
932
863
|
await pace((before?.length ?? 0) + (after?.length ?? 0) + ROW_WEIGHT);
|
|
933
864
|
}
|
|
@@ -1166,7 +1097,7 @@ function unreadable(saved, visible, composition) {
|
|
|
1166
1097
|
const path = saved.find(({ path: at, parts }) => (parts.fields !== undefined ||
|
|
1167
1098
|
parts.sections !== undefined ||
|
|
1168
1099
|
parts.preamble !== undefined) &&
|
|
1169
|
-
|
|
1100
|
+
typedContent(visible.documents[at]) &&
|
|
1170
1101
|
governing(composition, at).status === 'unavailable')?.path;
|
|
1171
1102
|
return path === undefined ? null : refuse('model-unavailable', path);
|
|
1172
1103
|
}
|
package/dist/saves.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
2
|
+
import type { ConversationFiles } from './conversation.js';
|
|
2
3
|
import { type AttachAnswer, type BinaryLinkAnswer, type HeldBinaryAnswer, type HeldShownAnswer } from './outcome.js';
|
|
3
4
|
import { type RoomDraftParts } from './room-draft.js';
|
|
4
5
|
import type { Runtime } from './runtime.js';
|
|
@@ -28,5 +29,6 @@ export type BinaryFileSurface = {
|
|
|
28
29
|
export declare function saveRoomDrafts(runtime: Runtime, locator: string, named: readonly SavedRoomDraft[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
29
30
|
export declare function saveParts(runtime: Runtime, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
30
31
|
export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
|
|
32
|
+
export declare function conversationFiles(runtime: Runtime): ConversationFiles;
|
|
31
33
|
export declare function binaryFileSurface(runtime: Runtime): BinaryFileSurface;
|
|
32
34
|
//# sourceMappingURL=saves.d.ts.map
|
package/dist/saves.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saves.d.ts","sourceRoot":"","sources":["../src/saves.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"saves.d.ts","sourceRoot":"","sources":["../src/saves.ts"],"names":[],"mappings":"AAUA,OAAO,EAA2B,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAKxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,OAAO,EASL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAGrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,cAAc,CAAC;AAatB,OAAO,EAQL,KAAK,cAAc,EAGpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAGL,KAAK,WAAW,EAGjB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAsB,KAAK,EAAoB,MAAM,YAAY,CAAC;AAK9E,MAAM,MAAM,UAAU,GAClB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,UA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ChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B,OAAO,CAAC,UAAU,CAAC,CAyBrB;AAgOD,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAK9F;AA+PD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAKrE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAQrE"}
|
package/dist/saves.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isImageType, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { binaryRecord } from './binary.js';
|
|
3
|
+
import { changeSet } from './change-set.js';
|
|
3
4
|
import { queuedFile } from './change.js';
|
|
4
|
-
import { available } from './collection.js';
|
|
5
|
+
import { available, textType } from './collection.js';
|
|
5
6
|
import { runtimeError } from './failure.js';
|
|
6
7
|
import { attachedFile } from './file.js';
|
|
8
|
+
import { roomDraftRevision } from './identity.js';
|
|
7
9
|
import { compositionFor } from './listing.js';
|
|
8
10
|
import { scoped } from './models.js';
|
|
9
|
-
import { absentBinary, attachAnswer, binaryAnswer, binaryLinkAnswer, failure, OFFLINE, UNCERTAIN, } from './outcome.js';
|
|
11
|
+
import { absentBinary, attachAnswer, binaryAnswer, binaryLinkAnswer, failure, linkedAnswer, OFFLINE, UNCERTAIN, } from './outcome.js';
|
|
10
12
|
import { sameBinary } from './overlay.js';
|
|
11
13
|
import { ancestors } from './paths.js';
|
|
12
14
|
import { connectionNow } from './preparation.js';
|
|
13
15
|
import { append, sliceAt, withdrawable } from './queue.js';
|
|
14
16
|
import { entryAt, replaying, slicing, } from './replica.js';
|
|
15
|
-
import { binaryBase, changesOf, held, heldFile, moveTarget, readSavedParts, } from './room-draft.js';
|
|
17
|
+
import { binaryBase, changesOf, held, heldFile, joinedOver, moveTarget, readSavedParts, } from './room-draft.js';
|
|
16
18
|
import { refuse } from './refusal.js';
|
|
17
19
|
import { visibleOf } from './room-drafts.js';
|
|
18
20
|
import { destination, planSave, } from './save.js';
|
|
@@ -43,9 +45,24 @@ export function saveRoomDrafts(runtime, locator, named, writtenBy) {
|
|
|
43
45
|
if (!saved.some((draft) => draft.path === path))
|
|
44
46
|
saved.push({ path, parts: record.parts });
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
const result = await loaded(runtime, locator, replica, saved, new Set(saved.map(({ path }) => path)), [], writtenBy);
|
|
49
|
+
if (result.outcome !== 'refused' || result.code !== 'changed-underneath')
|
|
50
|
+
return result;
|
|
51
|
+
return joinedUnderneath(runtime, locator, saved.map(({ path }) => drafts.get(path)), result);
|
|
47
52
|
});
|
|
48
53
|
}
|
|
54
|
+
async function joinedUnderneath({ store }, locator, records, refused) {
|
|
55
|
+
const visible = (await visibleOf(store, locator, records.map(({ path }) => path)));
|
|
56
|
+
const joined = records.flatMap((record) => {
|
|
57
|
+
const join = joinedOver(record.parts, record.marks, record.path, visible);
|
|
58
|
+
return join === null ? [] : [{ ...record, ...join, revision: roomDraftRevision() }];
|
|
59
|
+
});
|
|
60
|
+
if (joined.length === 0)
|
|
61
|
+
return refused;
|
|
62
|
+
await (await store.open()).commit({ rooms: [], writes: [{ locator, roomDrafts: joined }] });
|
|
63
|
+
await store.changed(changeSet(locator, { drafts: joined.map(({ path }) => path) }));
|
|
64
|
+
return refused;
|
|
65
|
+
}
|
|
49
66
|
export function saveParts(runtime, locator, named, writtenBy) {
|
|
50
67
|
const { store } = runtime;
|
|
51
68
|
return store.exclusive(async () => {
|
|
@@ -162,8 +179,7 @@ function lookupOf(local, key, view) {
|
|
|
162
179
|
function declaredOf(entry) {
|
|
163
180
|
if (entry.binary !== null)
|
|
164
181
|
return { type: undefined, binary: true };
|
|
165
|
-
|
|
166
|
-
return { type: read.ok ? (read.frontmatter.type ?? 'any') : undefined, binary: false };
|
|
182
|
+
return { type: textType(parse(entry.content ?? '')), binary: false };
|
|
167
183
|
}
|
|
168
184
|
function overriddenLookup(lookup, overrides) {
|
|
169
185
|
return async (paths) => {
|
|
@@ -250,7 +266,7 @@ async function transferBinary(runtime, request, transfer, answer) {
|
|
|
250
266
|
try {
|
|
251
267
|
const result = await transfer(authorization);
|
|
252
268
|
const settled = result;
|
|
253
|
-
if (presence.lostSince(request.locator, since))
|
|
269
|
+
if (request.locator !== null && presence.lostSince(request.locator, since))
|
|
254
270
|
return failure({ kind: 'room-not-readable', locator: request.locator });
|
|
255
271
|
if (settled.kind === 'scoped-refusal') {
|
|
256
272
|
const room = await store.record(settled.locator);
|
|
@@ -374,11 +390,11 @@ async function showBinaryPath(runtime, locator, path, revision) {
|
|
|
374
390
|
if (kept !== null)
|
|
375
391
|
return kept;
|
|
376
392
|
const mediaType = await heldMediaType(store, locator, path);
|
|
377
|
-
if (mediaType
|
|
393
|
+
if (mediaType !== undefined && isImageType(mediaType))
|
|
378
394
|
return fetchBinary(runtime, asked, name);
|
|
379
395
|
return linkOf(runtime, asked, revision === undefined ? mediaType : undefined);
|
|
380
396
|
}
|
|
381
|
-
async function
|
|
397
|
+
async function attachFile(runtime, locator, file, answer) {
|
|
382
398
|
const { store, socket } = runtime;
|
|
383
399
|
await socket.ready;
|
|
384
400
|
await socket.firstDiscovery;
|
|
@@ -388,16 +404,27 @@ async function attachBinary(runtime, locator, file) {
|
|
|
388
404
|
socket.session.now().refusal !== null)
|
|
389
405
|
return OFFLINE;
|
|
390
406
|
const request = await attachedFile(locator, file);
|
|
391
|
-
return transferBinary(runtime, { locator
|
|
407
|
+
return transferBinary(runtime, { locator }, async (held) => {
|
|
392
408
|
const result = await socket.attach(held, request);
|
|
393
|
-
if (result.kind === 'attached') {
|
|
409
|
+
if (result.kind === 'attached' && locator !== null) {
|
|
394
410
|
store.attached.hold(locator, result.path, {
|
|
395
411
|
revision: result.revision,
|
|
396
412
|
mediaType: request.mediaType,
|
|
397
413
|
});
|
|
398
414
|
}
|
|
399
415
|
return result;
|
|
400
|
-
},
|
|
416
|
+
}, answer);
|
|
417
|
+
}
|
|
418
|
+
async function keyedAttachment(runtime, link) {
|
|
419
|
+
await runtime.socket.ready;
|
|
420
|
+
const asked = { kind: 'key', link };
|
|
421
|
+
return transferBinary(runtime, { locator: null }, (authorization) => runtime.socket.link(authorization, asked), (result) => binaryLinkAnswer(result));
|
|
422
|
+
}
|
|
423
|
+
export function conversationFiles(runtime) {
|
|
424
|
+
return {
|
|
425
|
+
attach: (file) => attachFile(runtime, null, file, linkedAnswer),
|
|
426
|
+
attachment: (link) => keyedAttachment(runtime, link),
|
|
427
|
+
};
|
|
401
428
|
}
|
|
402
429
|
export function binaryFileSurface(runtime) {
|
|
403
430
|
return {
|
|
@@ -405,6 +432,6 @@ export function binaryFileSurface(runtime) {
|
|
|
405
432
|
read: (room, path, revision) => readBinaryPath(runtime, room, path, revision),
|
|
406
433
|
link: (room, path, revision) => linkBinaryPath(runtime, room, path, revision),
|
|
407
434
|
show: (room, path, revision) => showBinaryPath(runtime, room, path, revision),
|
|
408
|
-
attach: (room, file) =>
|
|
435
|
+
attach: (room, file) => attachFile(runtime, room, file, attachAnswer),
|
|
409
436
|
};
|
|
410
437
|
}
|
package/dist/seed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAwB,KAAK,WAAW,EAAqB,MAAM,kBAAkB,CAAC;AAC7F,OAAO,KAAK,EAAE,IAA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ACzB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,WAAW,GACjB,MAAM,IAAI,CA4BZ"}
|
package/dist/seed.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { queryKey } from '@agentshouse/mdmodel';
|
|
2
|
-
import { whole } from './observation.js';
|
|
2
|
+
import { pendingChange, whole } from './observation.js';
|
|
3
3
|
import { documentKey } from './rows.js';
|
|
4
4
|
const seedTopic = (key) => `seed\u0000${key}`;
|
|
5
5
|
function plain(value) {
|
|
@@ -130,7 +130,7 @@ export function watchSeeded(runtime, plan, deliver, watch) {
|
|
|
130
130
|
const watcher = store.watch(seedTopic(plan.key), shown);
|
|
131
131
|
const stop = watch((cover, held) => seedBehind(runtime, plan, cover, held), (message) => {
|
|
132
132
|
const answered = message;
|
|
133
|
-
pending = whole(answered)
|
|
133
|
+
pending = whole(answered) ? 'pending' in answered.result : pendingChange(answered);
|
|
134
134
|
if (pending && store.seeds.of(plan.key) !== undefined) {
|
|
135
135
|
shown();
|
|
136
136
|
return;
|
package/dist/shown.d.ts
CHANGED
|
@@ -10,16 +10,18 @@ export declare const REFUSAL_TOPIC = "connection-refusal";
|
|
|
10
10
|
export declare const STORAGE_LOSS_TOPIC = "storage-loss";
|
|
11
11
|
export declare const SERVICE_MODE_TOPIC = "service-mode";
|
|
12
12
|
export declare const MEMBER_TOPIC = "member";
|
|
13
|
+
export declare const TIME_ZONE_TOPIC = "time-zone";
|
|
13
14
|
export declare const AUTHORITY_TOPIC = "authority-changes";
|
|
14
15
|
export declare const LOCKS_TOPIC = "locks";
|
|
15
16
|
export declare const queueTopic: (locator: string) => string;
|
|
16
|
-
export declare function recoverReads({ liveQueries, figures }: Runtime): void;
|
|
17
|
+
export declare function recoverReads({ liveQueries, figures }: Runtime, locators?: readonly string[]): void;
|
|
17
18
|
export declare function emitRooms(runtime: Runtime, changed?: readonly string[]): Promise<void>;
|
|
18
19
|
export declare function emitKnownRooms(runtime: Runtime): void;
|
|
19
20
|
export declare function emitRefusal(runtime: Runtime): void;
|
|
20
21
|
export declare function storageLossNow({ store }: Runtime): string | null;
|
|
21
22
|
export declare function emitStorageLoss(runtime: Runtime): void;
|
|
22
23
|
export declare function emitMember({ store }: Runtime, member: Member | null): void;
|
|
24
|
+
export declare function emitTimeZone({ store }: Runtime, zone: string | null): void;
|
|
23
25
|
export declare function show(runtime: Runtime): Promise<void>;
|
|
24
26
|
export declare function moveTo(runtime: Runtime, next: Moving): Promise<void>;
|
|
25
27
|
export declare function statusShown(runtime: Runtime): Promise<void>;
|
package/dist/shown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shown.d.ts","sourceRoot":"","sources":["../src/shown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA6B,KAAK,aAAa,EAAmB,MAAM,aAAa,CAAC;AAiB7F,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,YAAY,gBAAgB,CAAC;AAE1C,eAAO,MAAM,aAAa,uBAAuB,CAAC;AAElD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAEnD,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,UAAU,YAAa,MAAM,WAA4B,CAAC;
|
|
1
|
+
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/dist/shown.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
2
|
import { conversationsChanged, conversationsLearned } from './conversation.js';
|
|
3
3
|
import { lossStated } from './durability.js';
|
|
4
|
-
import { listingNow,
|
|
4
|
+
import { listedEntries, listingNow, shownChange, shownRooms } from './listing.js';
|
|
5
5
|
import { emitPresentation, publishRoomDrafts } from './room-drafts.js';
|
|
6
6
|
import { same } from './status.js';
|
|
7
7
|
export const ROOMS_TOPIC = 'rooms';
|
|
@@ -10,11 +10,20 @@ export const REFUSAL_TOPIC = 'connection-refusal';
|
|
|
10
10
|
export const STORAGE_LOSS_TOPIC = 'storage-loss';
|
|
11
11
|
export const SERVICE_MODE_TOPIC = 'service-mode';
|
|
12
12
|
export const MEMBER_TOPIC = 'member';
|
|
13
|
+
export const TIME_ZONE_TOPIC = 'time-zone';
|
|
13
14
|
export const AUTHORITY_TOPIC = 'authority-changes';
|
|
14
15
|
export const LOCKS_TOPIC = 'locks';
|
|
15
16
|
export const queueTopic = (locator) => `queue\u0000${locator}`;
|
|
16
|
-
async function attended({ store, localSaves }) {
|
|
17
|
-
const held =
|
|
17
|
+
async function attended({ store, socket, localSaves }) {
|
|
18
|
+
const held = store.needed()
|
|
19
|
+
? await store.status()
|
|
20
|
+
: {
|
|
21
|
+
queued: [],
|
|
22
|
+
lastCompleted: socket.session.now().lastCompleted,
|
|
23
|
+
unsent: [],
|
|
24
|
+
resets: [],
|
|
25
|
+
returned: [],
|
|
26
|
+
};
|
|
18
27
|
const attentionRequired = held.returned.flatMap((record) => record.returned === null
|
|
19
28
|
? []
|
|
20
29
|
: [{ room: record.locator, path: record.path, returned: structuredClone(record.returned) }]);
|
|
@@ -42,15 +51,15 @@ async function attended({ store, localSaves }) {
|
|
|
42
51
|
};
|
|
43
52
|
}
|
|
44
53
|
async function queuedWork({ store, localSaves }) {
|
|
45
|
-
return !localSaves && (await store.queued()).length > 0;
|
|
54
|
+
return !localSaves && store.needed() && (await store.queued()).length > 0;
|
|
46
55
|
}
|
|
47
|
-
export function recoverReads({ liveQueries, figures }) {
|
|
48
|
-
liveQueries.recover();
|
|
56
|
+
export function recoverReads({ liveQueries, figures }, locators) {
|
|
57
|
+
liveQueries.recover(locators);
|
|
49
58
|
figures.recover();
|
|
50
59
|
}
|
|
51
60
|
export function emitRooms(runtime, changed) {
|
|
52
|
-
recoverReads(runtime);
|
|
53
|
-
runtime.store.readiness.queue();
|
|
61
|
+
recoverReads(runtime, changed);
|
|
62
|
+
runtime.store.readiness.queue(changed);
|
|
54
63
|
return changed === undefined
|
|
55
64
|
? publishRooms(runtime, 'all')
|
|
56
65
|
: publishRooms(runtime, 'changed', changed);
|
|
@@ -75,51 +84,58 @@ function roomsOwedWith(held, mode, touched) {
|
|
|
75
84
|
}
|
|
76
85
|
return held;
|
|
77
86
|
}
|
|
87
|
+
async function patchedRooms(runtime, owed) {
|
|
88
|
+
const { store } = runtime;
|
|
89
|
+
const touched = [...new Set([...owed.changed, ...owed.counted])];
|
|
90
|
+
const entries = await listedEntries(runtime, touched);
|
|
91
|
+
const shown = store.roomsShown.now();
|
|
92
|
+
if (entries === null || shown === null)
|
|
93
|
+
return false;
|
|
94
|
+
if (runtime.socket.closed())
|
|
95
|
+
return true;
|
|
96
|
+
const moved = entries.filter(({ locator, documents }) => owed.changed.has(locator) || shown.get(locator)?.documents !== documents);
|
|
97
|
+
const counted = moved.flatMap(({ locator }) => (owed.changed.has(locator) ? [] : [locator]));
|
|
98
|
+
if (counted.length > 0) {
|
|
99
|
+
recoverReads(runtime, counted);
|
|
100
|
+
store.readiness.queue(counted);
|
|
101
|
+
}
|
|
102
|
+
store.roomsShown.patch(moved);
|
|
103
|
+
if (moved.length === 0)
|
|
104
|
+
return true;
|
|
105
|
+
const change = shownChange(runtime, moved);
|
|
106
|
+
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
107
|
+
watcher.answer(change);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
78
110
|
async function deliverRooms(runtime, owed) {
|
|
79
111
|
const { store, socket } = runtime;
|
|
80
112
|
const waiting = () => store.watching(ROOMS_TOPIC, 'waiting');
|
|
81
113
|
if (socket.closed() || store.watching(ROOMS_TOPIC).length === 0)
|
|
82
114
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (
|
|
115
|
+
const touched = owed.changed.size > 0 || owed.counted.size > 0;
|
|
116
|
+
if (!owed.all && touched && waiting().length === 0 && (await patchedRooms(runtime, owed)))
|
|
117
|
+
return;
|
|
118
|
+
if (touched)
|
|
87
119
|
owed.all = true;
|
|
88
|
-
|
|
89
|
-
const held = await store.covering();
|
|
90
|
-
const { roomsShown } = store.device.now();
|
|
91
|
-
owed.all = [...owed.counted].some((locator) => held.rooms.has(locator) &&
|
|
92
|
-
roomsShown?.get(locator)?.documents !== held.rooms.get(locator).documents);
|
|
93
|
-
if (owed.all) {
|
|
94
|
-
recoverReads(runtime);
|
|
95
|
-
store.readiness.queue();
|
|
96
|
-
}
|
|
97
|
-
else if (waiting().length === 0)
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const listing = patched ?? (await listingNow(runtime));
|
|
120
|
+
const listing = await listingNow(runtime);
|
|
101
121
|
if (socket.closed())
|
|
102
122
|
return;
|
|
103
123
|
const { roomsListed, refusal, moving } = socket.session.now();
|
|
104
124
|
const joining = waiting().length > 0 &&
|
|
105
125
|
(roomsListed || listing.size > 0 || refusal !== null || moving.providerUnreachable);
|
|
106
|
-
if (!owed.all &&
|
|
126
|
+
if (!owed.all && !joining)
|
|
107
127
|
return;
|
|
108
128
|
const value = shownRooms(runtime, listing);
|
|
109
|
-
const
|
|
129
|
+
const shown = store.roomsShown.now();
|
|
110
130
|
const moved = owed.all ||
|
|
111
|
-
|
|
112
|
-
(roomsShown !== null &&
|
|
113
|
-
JSON.stringify(shownRooms(runtime, roomsShown)) !== JSON.stringify(value));
|
|
131
|
+
(shown !== null && JSON.stringify(shownRooms(runtime, shown)) !== JSON.stringify(value));
|
|
114
132
|
if (moved)
|
|
115
133
|
for (const watcher of store.watching(ROOMS_TOPIC, 'ready'))
|
|
116
134
|
watcher.answer(value);
|
|
117
135
|
if (joining)
|
|
118
136
|
for (const watcher of waiting())
|
|
119
137
|
watcher.answer(value);
|
|
120
|
-
store.
|
|
121
|
-
roomsShown: store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing,
|
|
122
|
-
});
|
|
138
|
+
store.roomsShown.show(store.watching(ROOMS_TOPIC, 'ready').length === 0 ? null : listing);
|
|
123
139
|
}
|
|
124
140
|
function publishRooms(runtime, mode, touched = []) {
|
|
125
141
|
if (runtime.socket.closed())
|
|
@@ -128,7 +144,7 @@ function publishRooms(runtime, mode, touched = []) {
|
|
|
128
144
|
}
|
|
129
145
|
export function emitRefusal(runtime) {
|
|
130
146
|
const { store, socket } = runtime;
|
|
131
|
-
store.readiness.queue();
|
|
147
|
+
store.readiness.queue([]);
|
|
132
148
|
store.tell(REFUSAL_TOPIC, socket.session.now().refusal);
|
|
133
149
|
emitKnownRooms(runtime);
|
|
134
150
|
}
|
|
@@ -137,12 +153,15 @@ export function storageLossNow({ store }) {
|
|
|
137
153
|
return lossStated(persistence, storageLoss);
|
|
138
154
|
}
|
|
139
155
|
export function emitStorageLoss(runtime) {
|
|
140
|
-
runtime.store.readiness.queue();
|
|
156
|
+
runtime.store.readiness.queue([]);
|
|
141
157
|
runtime.store.tell(STORAGE_LOSS_TOPIC, storageLossNow(runtime));
|
|
142
158
|
}
|
|
143
159
|
export function emitMember({ store }, member) {
|
|
144
160
|
store.tell(MEMBER_TOPIC, member);
|
|
145
161
|
}
|
|
162
|
+
export function emitTimeZone({ store }, zone) {
|
|
163
|
+
store.tell(TIME_ZONE_TOPIC, zone);
|
|
164
|
+
}
|
|
146
165
|
async function deliverStatus(runtime, owed) {
|
|
147
166
|
const { store, socket } = runtime;
|
|
148
167
|
const held = await attended(runtime);
|
|
@@ -171,7 +190,7 @@ export function show(runtime) {
|
|
|
171
190
|
const { store, socket } = runtime;
|
|
172
191
|
if (socket.closed())
|
|
173
192
|
return Promise.resolve();
|
|
174
|
-
store.readiness.queue();
|
|
193
|
+
store.readiness.queue([]);
|
|
175
194
|
emitKnownRooms(runtime);
|
|
176
195
|
const moved = { moving: socket.session.now().moving, current: conversationsCurrent(runtime) };
|
|
177
196
|
return store.owing(STATUS_TOPIC, (held) => {
|
|
@@ -255,6 +274,8 @@ export function publishChangeSet(runtime, set) {
|
|
|
255
274
|
}
|
|
256
275
|
export async function submissionDue(runtime, locators) {
|
|
257
276
|
const { store } = runtime;
|
|
277
|
+
if (!store.needed())
|
|
278
|
+
return;
|
|
258
279
|
const due = (await store.queued()).filter((locator) => locators === undefined || locators.includes(locator));
|
|
259
280
|
if (due.length === 0)
|
|
260
281
|
return;
|
|
@@ -262,7 +283,7 @@ export async function submissionDue(runtime, locators) {
|
|
|
262
283
|
}
|
|
263
284
|
export function roomUnreadable(runtime, locator) {
|
|
264
285
|
runtime.presence.refused(locator, null);
|
|
265
|
-
emitRooms(runtime);
|
|
286
|
+
emitRooms(runtime, [locator]);
|
|
266
287
|
}
|
|
267
288
|
export async function rest(runtime, progress, live = () => !runtime.socket.closed()) {
|
|
268
289
|
const { store, socket, presence } = runtime;
|
|
@@ -284,7 +305,10 @@ export async function rest(runtime, progress, live = () => !runtime.socket.close
|
|
|
284
305
|
if (synced && !session.now().recorded) {
|
|
285
306
|
const completedAt = new Date().toISOString();
|
|
286
307
|
try {
|
|
287
|
-
|
|
308
|
+
if (store.needed())
|
|
309
|
+
await (await store.open()).fact('lastCompleted', completedAt);
|
|
310
|
+
else
|
|
311
|
+
session.set({ lastCompleted: completedAt });
|
|
288
312
|
if (!live())
|
|
289
313
|
return;
|
|
290
314
|
session.set({ recorded: true });
|
package/dist/socket/session.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Authorization, ProviderRefusal, ServiceMode } from '../adapter.js';
|
|
1
|
+
import type { Authorization, Discovery, ProviderRefusal, QueriedRoom, ServiceMode } from '../adapter.js';
|
|
2
2
|
import { type Cell } from '../cell.js';
|
|
3
3
|
import type { Open } from '../open.js';
|
|
4
4
|
import type { CycleProgress, SyncStatus } from '../status.js';
|
|
@@ -23,6 +23,9 @@ export type Session = {
|
|
|
23
23
|
readonly discoveries: number;
|
|
24
24
|
readonly roomsNamed: boolean;
|
|
25
25
|
readonly roomsListed: boolean;
|
|
26
|
+
readonly queriesOnly: readonly QueriedRoom[];
|
|
27
|
+
readonly unstored: Discovery | null;
|
|
28
|
+
readonly lastCompleted: string | null;
|
|
26
29
|
readonly serviceMode: ServiceMode;
|
|
27
30
|
readonly haltedRefusal: boolean;
|
|
28
31
|
readonly openSignals: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/socket/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,4BAA4B,GAAG,uBAAuB,CAAC;AAEnF,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC,CAAC;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a,GAAG,IAAI,CAAC;CACzC,CAAC;AAEF,wBAAgB,aAAa,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,CAwBrF"}
|
package/dist/socket/session.js
CHANGED
package/dist/socket.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export type RuntimeSocket = Admission & Answers & {
|
|
|
31
31
|
readonly firstDiscovery: Promise<void>;
|
|
32
32
|
conversations(): Adapter['conversations'];
|
|
33
33
|
search(): Adapter['search'];
|
|
34
|
+
queryHouse(): Adapter['queryHouse'];
|
|
34
35
|
discover(authorized: Authorization): ReturnType<NonNullable<Adapter['discover']>> | undefined;
|
|
35
36
|
follows: Adapter['follows'];
|
|
36
37
|
mutate: Adapter['mutate'];
|