@agentshouse/mdruntime 0.1.0-ca2c50e56e0b8 → 0.1.0-ca366897a7e72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +31 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +39 -15
- package/dist/adapter.d.ts +98 -20
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- package/dist/{binary.d.ts → attachment.d.ts} +4 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/{binary.js → attachment.js} +2 -2
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +2 -2
- package/dist/client.d.ts +9 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +11 -11
- package/dist/collection.d.ts +1 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -1
- package/dist/compile.d.ts +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +71 -39
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +7 -2
- package/dist/conversation-live.d.ts +1 -0
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +2 -1
- package/dist/conversation-row.d.ts +16 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +17 -1
- package/dist/conversation.d.ts +13 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +45 -37
- package/dist/declaration.js +2 -2
- package/dist/download.d.ts +2 -2
- package/dist/download.d.ts.map +1 -1
- package/dist/download.js +2 -2
- package/dist/entry.d.ts +14 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +87 -26
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +12 -12
- package/dist/house-query.d.ts +8 -2
- package/dist/house-query.d.ts.map +1 -1
- package/dist/house-query.js +53 -5
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +2 -0
- package/dist/linked-file.d.ts +7 -0
- package/dist/linked-file.d.ts.map +1 -0
- package/dist/linked-file.js +16 -0
- package/dist/live.d.ts +14 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +29 -12
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +19 -6
- package/dist/memory.d.ts +2 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +13 -12
- package/dist/messages.d.ts +5 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +14 -3
- package/dist/model.d.ts +6 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +2 -0
- package/dist/outcome.d.ts +16 -16
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +5 -5
- package/dist/overlay.d.ts +19 -8
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +108 -37
- package/dist/parts.d.ts +1 -0
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +1 -1
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +56 -13
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/queue.d.ts +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +4 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +29 -13
- package/dist/react.d.ts +6 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +4 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +15 -4
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +3 -3
- package/dist/room-draft.d.ts +1 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +4 -4
- package/dist/room-drafts.js +2 -2
- package/dist/room-list.d.ts.map +1 -1
- package/dist/room-list.js +2 -0
- package/dist/rows.d.ts +9 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +19 -5
- package/dist/run-tables.d.ts +25 -0
- package/dist/run-tables.d.ts.map +1 -0
- package/dist/run-tables.js +98 -0
- package/dist/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +3 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +7 -7
- package/dist/saves.d.ts +5 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +54 -47
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shown.d.ts +1 -1
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +13 -12
- package/dist/socket.d.ts +3 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +7 -0
- package/dist/source.d.ts +37 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +63 -7
- package/dist/store/records.d.ts +12 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +10 -4
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/stored.d.ts +9 -2
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +33 -11
- package/dist/surface.d.ts +9 -3
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +5 -2
- package/dist/sync.js +1 -1
- package/dist/tables.d.ts +26 -2
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +24 -3
- package/dist/tallies.js +2 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +49 -3
- package/dist/wire.d.ts +7 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +7 -6
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,QAAQ,EAAE,QAAQ,EAAY,MAAM,cAAc,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAW,SAAS,EAAY,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;CAC3C,CAAC;AAaF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAGnD;AA6CD,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,aAAa,KAAK,IAAI,GAChD,MAAM,IAAI,CAcZ;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhE;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAMhE;AAED,wBAAsB,UAAU,CAC9B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
package/dist/runs.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { refusedForSpace } from './durability.js';
|
|
2
|
+
import { uncaught } from './failure.js';
|
|
3
|
+
export const RUNS_TOPIC = 'runs';
|
|
4
|
+
function sightOf(roomList, member) {
|
|
5
|
+
const rooms = roomList?.rooms ?? [];
|
|
6
|
+
return {
|
|
7
|
+
held: rooms.filter((room) => room.level !== 'search').map((room) => room.room_ref),
|
|
8
|
+
searched: rooms.filter((room) => room.level === 'search').map((room) => room.room_ref),
|
|
9
|
+
starter: member?.id ?? null,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function runsAsked(input) {
|
|
13
|
+
const asked = input;
|
|
14
|
+
return asked?.sent === true ? { sent: true } : { room: String(asked?.room) };
|
|
15
|
+
}
|
|
16
|
+
function entryOf({ room, name, document }) {
|
|
17
|
+
return { room, name, document };
|
|
18
|
+
}
|
|
19
|
+
function touches(asked, touched) {
|
|
20
|
+
return touched === null || 'sent' in asked || touched.includes(asked.room);
|
|
21
|
+
}
|
|
22
|
+
function touchedBy(event) {
|
|
23
|
+
if (event.kind === 'run')
|
|
24
|
+
return [event.run.room];
|
|
25
|
+
if (event.kind === 'removed')
|
|
26
|
+
return [event.room];
|
|
27
|
+
if (event.listing !== null)
|
|
28
|
+
return [event.listing];
|
|
29
|
+
return event.whole ? null : event.runs.map((run) => run.room);
|
|
30
|
+
}
|
|
31
|
+
function written(runtime, marks, touched) {
|
|
32
|
+
const { store, socket } = runtime;
|
|
33
|
+
if (marks !== null)
|
|
34
|
+
socket.runs()?.hold(marks);
|
|
35
|
+
store.tell(RUNS_TOPIC, touched);
|
|
36
|
+
}
|
|
37
|
+
function unwritten(error) {
|
|
38
|
+
if (!refusedForSpace(error))
|
|
39
|
+
uncaught(error);
|
|
40
|
+
}
|
|
41
|
+
function unheard(asked) {
|
|
42
|
+
return { pending: 'sent' in asked ? [] : [{ room: asked.room, awaits: 'acquisition' }] };
|
|
43
|
+
}
|
|
44
|
+
async function heldRuns(runtime, asked) {
|
|
45
|
+
const { store } = runtime;
|
|
46
|
+
const { roomList, member } = await (await store.open()).facts(['roomList', 'member']);
|
|
47
|
+
const held = roomList === null
|
|
48
|
+
? null
|
|
49
|
+
: await store.ask({ kind: 'run.held', asked, sight: sightOf(roomList, member) });
|
|
50
|
+
if (held === null)
|
|
51
|
+
return unheard(asked);
|
|
52
|
+
return {
|
|
53
|
+
current: held.filter((run) => run.current).map(entryOf),
|
|
54
|
+
history: held.map(entryOf),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function watchRuns(runtime, input, deliver) {
|
|
58
|
+
const { store } = runtime;
|
|
59
|
+
const asked = runsAsked(input);
|
|
60
|
+
const answer = () => store.publication(async () => {
|
|
61
|
+
if (!watcher.held())
|
|
62
|
+
return;
|
|
63
|
+
const runs = await heldRuns(runtime, asked);
|
|
64
|
+
if (watcher.held())
|
|
65
|
+
deliver(runs);
|
|
66
|
+
});
|
|
67
|
+
const watcher = store.watch(RUNS_TOPIC, (touched) => {
|
|
68
|
+
if (touches(asked, touched))
|
|
69
|
+
void answer();
|
|
70
|
+
});
|
|
71
|
+
void answer();
|
|
72
|
+
return watcher.stop;
|
|
73
|
+
}
|
|
74
|
+
export async function runsOpened(runtime) {
|
|
75
|
+
const { store, socket } = runtime;
|
|
76
|
+
socket.runs()?.hold(await store.ask({ kind: 'run.marks' }));
|
|
77
|
+
}
|
|
78
|
+
export function runHeard(runtime, event) {
|
|
79
|
+
const { store, socket } = runtime;
|
|
80
|
+
if (socket.closed())
|
|
81
|
+
return;
|
|
82
|
+
void store
|
|
83
|
+
.exclusive(() => store.ask({ kind: 'run.keep', event }))
|
|
84
|
+
.then((marks) => written(runtime, marks, touchedBy(event)), unwritten);
|
|
85
|
+
}
|
|
86
|
+
export async function runsListed(runtime, local, roomList) {
|
|
87
|
+
const { store } = runtime;
|
|
88
|
+
const { member } = await local.facts(['member']);
|
|
89
|
+
await store
|
|
90
|
+
.exclusive(() => store.ask({ kind: 'run.left', sight: sightOf(roomList, member) }))
|
|
91
|
+
.then((marks) => written(runtime, marks, null), unwritten);
|
|
92
|
+
}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -19,10 +19,12 @@ export type Runtime = {
|
|
|
19
19
|
readonly recovery: Recovery;
|
|
20
20
|
readonly retries: Retries;
|
|
21
21
|
readonly shell: RuntimeShell;
|
|
22
|
-
readonly
|
|
22
|
+
readonly savesLocally: (locator: string) => boolean;
|
|
23
23
|
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
24
24
|
readonly builtIn: ModelState;
|
|
25
25
|
readonly typedPaths: readonly TypedPath[];
|
|
26
|
+
readonly renamedActions: ReadonlyMap<string, string>;
|
|
27
|
+
readonly rewrittenInputs: ReadonlyMap<string, (input: unknown) => unknown>;
|
|
26
28
|
readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
|
|
27
29
|
readonly build: string;
|
|
28
30
|
readonly conversations: LiveConversations;
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { apply, ARRAY_INDEX, ATTACHMENT, create, links, parse, pointerSegments, references, relative, relativize, retarget, roomReferences, serialize, target, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { immutable, isPart, leaving, queuedFile, departure, } from './change.js';
|
|
3
|
-
import { collectionOf, definitionsAt, documentsOf, governing,
|
|
3
|
+
import { collectionOf, definitionsAt, documentsOf, governing, typeAt, UNTYPED, } 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';
|
|
@@ -817,8 +817,8 @@ function* limiting(queue, batch, limits, state) {
|
|
|
817
817
|
const limited = yield* exceeding(limits, batch.changes, rewritten.changes, yield* state(queue.slice(0, at + 1)));
|
|
818
818
|
return limited?.refusal ?? null;
|
|
819
819
|
}
|
|
820
|
-
function typedContent(content) {
|
|
821
|
-
return content !== undefined &&
|
|
820
|
+
function typedContent(composition, path, content) {
|
|
821
|
+
return (content !== undefined && (typeAt(composition, path, parse(content)) ?? UNTYPED) !== UNTYPED);
|
|
822
822
|
}
|
|
823
823
|
function touchedLibrary(resulting, touched, composition) {
|
|
824
824
|
const entries = touched
|
|
@@ -838,7 +838,7 @@ function touchedLibrary(resulting, touched, composition) {
|
|
|
838
838
|
if (binaries.has(path))
|
|
839
839
|
known.set(path, { type: undefined, binary: true });
|
|
840
840
|
else if (content !== undefined && content !== null) {
|
|
841
|
-
const type =
|
|
841
|
+
const type = typeAt(composition, path, parse(content, path, definitionsAt(composition, path)));
|
|
842
842
|
if (type !== undefined)
|
|
843
843
|
known.set(path, { type, binary: false });
|
|
844
844
|
await pace(content.length + ROW_WEIGHT);
|
|
@@ -858,7 +858,7 @@ async function judging(visible, resulting, composition, validate, removed, touch
|
|
|
858
858
|
for (const path of touched) {
|
|
859
859
|
const before = visible.documents[path];
|
|
860
860
|
const after = resulting.documents[path];
|
|
861
|
-
if (typedContent(before) || typedContent(after))
|
|
861
|
+
if (typedContent(composition, path, before) || typedContent(composition, path, after))
|
|
862
862
|
typedPaths.push(path);
|
|
863
863
|
await pace((before?.length ?? 0) + (after?.length ?? 0) + ROW_WEIGHT);
|
|
864
864
|
}
|
|
@@ -905,7 +905,7 @@ function roomReferencesIn(path, content, composition) {
|
|
|
905
905
|
const parsed = parse(content, path, definitions);
|
|
906
906
|
if (!parsed.ok)
|
|
907
907
|
return [];
|
|
908
|
-
return roomReferences(parsed.document, definitions(parsed.document.type));
|
|
908
|
+
return roomReferences(parsed.document, { path }, definitions(parsed.document.type));
|
|
909
909
|
}
|
|
910
910
|
function* admittedRooms(changes, visible, resulting, composition) {
|
|
911
911
|
const from = new Map();
|
|
@@ -1097,7 +1097,7 @@ function unreadable(saved, visible, composition) {
|
|
|
1097
1097
|
const path = saved.find(({ path: at, parts }) => (parts.fields !== undefined ||
|
|
1098
1098
|
parts.sections !== undefined ||
|
|
1099
1099
|
parts.preamble !== undefined) &&
|
|
1100
|
-
typedContent(visible.documents[at]) &&
|
|
1100
|
+
typedContent(composition, at, visible.documents[at]) &&
|
|
1101
1101
|
governing(composition, at).status === 'unavailable')?.path;
|
|
1102
1102
|
return path === undefined ? null : refuse('model-unavailable', path);
|
|
1103
1103
|
}
|
package/dist/saves.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
2
2
|
import type { ConversationFiles } from './conversation.js';
|
|
3
|
-
import { type AttachAnswer, type
|
|
3
|
+
import { type AttachAnswer, type AttachmentLinkAnswer, type HeldAttachmentAnswer, type HeldShownAnswer } from './outcome.js';
|
|
4
4
|
import { type RoomDraftParts } from './room-draft.js';
|
|
5
5
|
import type { Runtime } from './runtime.js';
|
|
6
6
|
import { type SaveRefusal } from './save.js';
|
|
@@ -19,9 +19,9 @@ export type SavedParts = {
|
|
|
19
19
|
readonly path: string;
|
|
20
20
|
readonly parts: RoomDraftParts;
|
|
21
21
|
};
|
|
22
|
-
export type
|
|
23
|
-
read(room: string, path: string, revision?: string): Promise<
|
|
24
|
-
link(room: string, path: string, revision?: string): Promise<
|
|
22
|
+
export type AttachmentSurface = {
|
|
23
|
+
read(room: string, path: string, revision?: string): Promise<HeldAttachmentAnswer>;
|
|
24
|
+
link(room: string, path: string, revision?: string): Promise<AttachmentLinkAnswer>;
|
|
25
25
|
show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
|
|
26
26
|
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
27
27
|
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
@@ -30,5 +30,5 @@ export declare function saveRoomDrafts(runtime: Runtime, locator: string, named:
|
|
|
30
30
|
export declare function saveParts(runtime: Runtime, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
31
31
|
export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
|
|
32
32
|
export declare function conversationFiles(runtime: Runtime): ConversationFiles;
|
|
33
|
-
export declare function
|
|
33
|
+
export declare function attachmentSurface(runtime: Runtime): AttachmentSurface;
|
|
34
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":"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,
|
|
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,EAA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C,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACxD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CAC9D,CAAC;AAYF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B,OAAO,CAAC,UAAU,CAAC,CAsCrB;AAuBD,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B,OAAO,CAAC,UAAU,CAAC,CAyBrB;AAwOD,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAK9F;AA+RD,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,20 +1,20 @@
|
|
|
1
1
|
import { isImageType, parse } from '@agentshouse/mdmodel';
|
|
2
|
-
import {
|
|
2
|
+
import { attachmentRecord } from './attachment.js';
|
|
3
3
|
import { changeSet } from './change-set.js';
|
|
4
4
|
import { queuedFile } from './change.js';
|
|
5
|
-
import { available,
|
|
5
|
+
import { available, definitionsAt, typeAt } from './collection.js';
|
|
6
6
|
import { runtimeError } from './failure.js';
|
|
7
7
|
import { attachedFile } from './file.js';
|
|
8
8
|
import { roomDraftRevision } from './identity.js';
|
|
9
9
|
import { compositionFor } from './listing.js';
|
|
10
10
|
import { scoped } from './models.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { absentAttachment, attachAnswer, attachmentAnswer, attachmentLinkAnswer, failure, linkedAnswer, OFFLINE, UNCERTAIN, } from './outcome.js';
|
|
12
|
+
import { sameAttachment } from './overlay.js';
|
|
13
13
|
import { ancestors } from './paths.js';
|
|
14
14
|
import { connectionNow } from './preparation.js';
|
|
15
15
|
import { append, sliceAt, withdrawable } from './queue.js';
|
|
16
16
|
import { entryAt, replaying, slicing, } from './replica.js';
|
|
17
|
-
import {
|
|
17
|
+
import { attachmentBase, changesOf, held, heldFile, joinedOver, moveTarget, readSavedParts, } from './room-draft.js';
|
|
18
18
|
import { refuse } from './refusal.js';
|
|
19
19
|
import { visibleOf } from './room-drafts.js';
|
|
20
20
|
import { destination, planSave, } from './save.js';
|
|
@@ -77,7 +77,7 @@ export function saveParts(runtime, locator, named, writtenBy) {
|
|
|
77
77
|
for (const { path, parts } of read) {
|
|
78
78
|
const file = parts.file === undefined
|
|
79
79
|
? undefined
|
|
80
|
-
: await heldFile(parts.file.blob, parts.file.base === undefined ?
|
|
80
|
+
: await heldFile(parts.file.blob, parts.file.base === undefined ? attachmentBase(visible, path) : parts.file.base);
|
|
81
81
|
if (parts.file !== undefined && file !== undefined) {
|
|
82
82
|
files.push({ key: file.localId, blob: parts.file.blob });
|
|
83
83
|
}
|
|
@@ -135,7 +135,8 @@ function targetsOf(saved) {
|
|
|
135
135
|
return saved.flatMap(({ parts }) => (parts.move === undefined ? [] : [moveTarget(parts.move)]));
|
|
136
136
|
}
|
|
137
137
|
async function loaded(runtime, locator, replica, saved, consumed, files, writtenBy) {
|
|
138
|
-
const { store
|
|
138
|
+
const { store } = runtime;
|
|
139
|
+
const localSaves = runtime.savesLocally(locator);
|
|
139
140
|
const into = destination(locator, saved);
|
|
140
141
|
const target = into === null ? undefined : await savedRoom(runtime, into);
|
|
141
142
|
const paths = saved.map(({ path }) => path);
|
|
@@ -154,12 +155,12 @@ async function loaded(runtime, locator, replica, saved, consumed, files, written
|
|
|
154
155
|
room.record.locator,
|
|
155
156
|
held,
|
|
156
157
|
])),
|
|
157
|
-
after: () => pendingShown(runtime),
|
|
158
|
+
after: () => pendingShown(runtime, locator),
|
|
158
159
|
});
|
|
159
160
|
}
|
|
160
161
|
function textDiffers(left, right) {
|
|
161
162
|
return ((left?.content ?? undefined) !== (right?.content ?? undefined) ||
|
|
162
|
-
!
|
|
163
|
+
!sameAttachment(left?.binary ?? undefined, right?.binary ?? undefined));
|
|
163
164
|
}
|
|
164
165
|
function textOf(entry) {
|
|
165
166
|
if (entry === null)
|
|
@@ -176,12 +177,16 @@ function lookupOf(local, key, view) {
|
|
|
176
177
|
]));
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
|
-
function declaredOf(entry) {
|
|
180
|
+
function declaredOf(composition, path, entry) {
|
|
180
181
|
if (entry.binary !== null)
|
|
181
182
|
return { type: undefined, binary: true };
|
|
182
|
-
|
|
183
|
+
const content = entry.content ?? '';
|
|
184
|
+
return {
|
|
185
|
+
type: typeAt(composition, path, parse(content, path, definitionsAt(composition, path))),
|
|
186
|
+
binary: false,
|
|
187
|
+
};
|
|
183
188
|
}
|
|
184
|
-
function overriddenLookup(lookup, overrides) {
|
|
189
|
+
function overriddenLookup(composition, lookup, overrides) {
|
|
185
190
|
return async (paths) => {
|
|
186
191
|
const known = new Map(await lookup(paths.filter((path) => !overrides.has(path))));
|
|
187
192
|
for (const path of paths) {
|
|
@@ -191,7 +196,7 @@ function overriddenLookup(lookup, overrides) {
|
|
|
191
196
|
if (entry === null)
|
|
192
197
|
known.delete(path);
|
|
193
198
|
else
|
|
194
|
-
known.set(path, declaredOf(entry));
|
|
199
|
+
known.set(path, declaredOf(composition, path, entry));
|
|
195
200
|
}
|
|
196
201
|
return known;
|
|
197
202
|
};
|
|
@@ -212,10 +217,12 @@ function validatorOf(runtime, record, confirmedLayer) {
|
|
|
212
217
|
if (textOf(was) !== textOf(now))
|
|
213
218
|
changes.push({ path, was: textOf(was), now: textOf(now) });
|
|
214
219
|
}
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
const composition = compositionFor(runtime, record);
|
|
221
|
+
return validatedNeighbourhood(changes, composition, {
|
|
222
|
+
lookup: overriddenLookup(composition, lookupOf(local, record.key, 'confirmed'), overrides),
|
|
217
223
|
texts: textsOf(local, record.key, 'confirmed'),
|
|
218
224
|
referrers: referrersOf(local, record.key, 'confirmed'),
|
|
225
|
+
holders: (sought) => local.holders(record.key, 'confirmed', sought),
|
|
219
226
|
});
|
|
220
227
|
};
|
|
221
228
|
}
|
|
@@ -245,7 +252,7 @@ export function batchFile(store, batch) {
|
|
|
245
252
|
return (await store.open()).file(localId, change?.kind === 'binary' ? change.mediaType : '');
|
|
246
253
|
};
|
|
247
254
|
}
|
|
248
|
-
async function
|
|
255
|
+
async function transferAttachment(runtime, request, transfer, answer) {
|
|
249
256
|
const { store, socket, presence } = runtime;
|
|
250
257
|
const { session } = socket;
|
|
251
258
|
if (socket.closed() || session.now().refusal !== null)
|
|
@@ -281,19 +288,19 @@ async function transferBinary(runtime, request, transfer, answer) {
|
|
|
281
288
|
return UNCERTAIN;
|
|
282
289
|
}
|
|
283
290
|
}
|
|
284
|
-
function
|
|
291
|
+
function fetchAttachment(runtime, request, name) {
|
|
285
292
|
const { store, socket } = runtime;
|
|
286
|
-
return
|
|
293
|
+
return transferAttachment(runtime, request, (authorization) => store.opened.fetch(name, () => socket.binary(authorization, request)), attachmentAnswer);
|
|
287
294
|
}
|
|
288
|
-
async function
|
|
295
|
+
async function readAttachment(runtime, request, name) {
|
|
289
296
|
if (runtime.socket.closed())
|
|
290
297
|
return UNCERTAIN;
|
|
291
298
|
const held = await runtime.store.opened.find(name);
|
|
292
299
|
if (held !== null)
|
|
293
300
|
return held;
|
|
294
|
-
return
|
|
301
|
+
return fetchAttachment(runtime, request, name);
|
|
295
302
|
}
|
|
296
|
-
async function
|
|
303
|
+
async function attachmentPath(store, locator, path, revision) {
|
|
297
304
|
if (revision !== undefined)
|
|
298
305
|
return { kind: 'path', locator, path, revision };
|
|
299
306
|
const replica = await store.replica(locator);
|
|
@@ -306,7 +313,7 @@ async function binaryPath(store, locator, path, revision) {
|
|
|
306
313
|
return null;
|
|
307
314
|
if (held.binary.state === 'pending')
|
|
308
315
|
return { kind: 'pending', localId: held.binary.localId };
|
|
309
|
-
const record =
|
|
316
|
+
const record = attachmentRecord(path, held.binary, held.revision ?? undefined);
|
|
310
317
|
if (record.state !== 'accepted')
|
|
311
318
|
return null;
|
|
312
319
|
const queued = replica.queue.flatMap((batch) => batch.changes);
|
|
@@ -334,17 +341,17 @@ async function binaryPath(store, locator, path, revision) {
|
|
|
334
341
|
revision: record.revision,
|
|
335
342
|
};
|
|
336
343
|
}
|
|
337
|
-
async function
|
|
344
|
+
async function askedAttachment({ store, socket }, locator, path, revision) {
|
|
338
345
|
await socket.ready;
|
|
339
346
|
const drafted = (await store.draft(locator, path))?.parts.file;
|
|
340
347
|
return drafted !== undefined && drafted.localId === revision
|
|
341
348
|
? { kind: 'pending', localId: revision }
|
|
342
|
-
:
|
|
349
|
+
: attachmentPath(store, locator, path, revision);
|
|
343
350
|
}
|
|
344
|
-
async function
|
|
351
|
+
async function pendingAttachment(store, locator, path, localId) {
|
|
345
352
|
const facts = await queuedFacts(store, locator, path, localId);
|
|
346
353
|
return facts === null
|
|
347
|
-
?
|
|
354
|
+
? absentAttachment(path)
|
|
348
355
|
: {
|
|
349
356
|
kind: 'binary',
|
|
350
357
|
file: localId,
|
|
@@ -352,13 +359,13 @@ async function pendingBinary(store, locator, path, localId) {
|
|
|
352
359
|
mediaType: facts.mediaType,
|
|
353
360
|
};
|
|
354
361
|
}
|
|
355
|
-
async function
|
|
356
|
-
const asked = await
|
|
362
|
+
async function readAttachmentPath(runtime, locator, path, revision) {
|
|
363
|
+
const asked = await askedAttachment(runtime, locator, path, revision);
|
|
357
364
|
if (asked === null)
|
|
358
|
-
return
|
|
365
|
+
return absentAttachment(path);
|
|
359
366
|
if (asked.kind === 'pending')
|
|
360
|
-
return
|
|
361
|
-
return
|
|
367
|
+
return pendingAttachment(runtime.store, locator, path, asked.localId);
|
|
368
|
+
return readAttachment(runtime, asked, { locator, path: asked.path, revision: asked.revision });
|
|
362
369
|
}
|
|
363
370
|
async function heldMediaType(store, locator, path) {
|
|
364
371
|
const replica = await store.record(locator);
|
|
@@ -366,20 +373,20 @@ async function heldMediaType(store, locator, path) {
|
|
|
366
373
|
return held === undefined ? store.attached.of(locator, path)?.mediaType : held.binary?.mediaType;
|
|
367
374
|
}
|
|
368
375
|
function linkOf(runtime, asked, held) {
|
|
369
|
-
return
|
|
376
|
+
return transferAttachment(runtime, asked, (authorization) => runtime.socket.link(authorization, asked), (result) => attachmentLinkAnswer(result, held));
|
|
370
377
|
}
|
|
371
|
-
async function
|
|
378
|
+
async function linkAttachmentPath(runtime, locator, path, revision) {
|
|
372
379
|
const { store, socket } = runtime;
|
|
373
380
|
await socket.ready;
|
|
374
|
-
const asked = await
|
|
381
|
+
const asked = await attachmentPath(store, locator, path, revision);
|
|
375
382
|
if (asked === null || asked.kind === 'pending')
|
|
376
|
-
return
|
|
383
|
+
return absentAttachment(path);
|
|
377
384
|
return linkOf(runtime, asked, revision === undefined ? await heldMediaType(store, locator, path) : undefined);
|
|
378
385
|
}
|
|
379
386
|
function shownImage(runtime, asked, name) {
|
|
380
387
|
const { store, socket } = runtime;
|
|
381
388
|
return new Promise((answer) => {
|
|
382
|
-
void
|
|
389
|
+
void transferAttachment(runtime, asked, (authorization) => store.opened.fetch(name, async () => {
|
|
383
390
|
const read = await socket.binary(authorization, asked);
|
|
384
391
|
const copies = read.kind === 'binary' ? (read.copies ?? []) : [];
|
|
385
392
|
if (read.kind === 'binary' && read.url !== undefined && copies.length > 0) {
|
|
@@ -392,16 +399,16 @@ function shownImage(runtime, asked, name) {
|
|
|
392
399
|
});
|
|
393
400
|
}
|
|
394
401
|
return read;
|
|
395
|
-
}),
|
|
402
|
+
}), attachmentAnswer).then(answer);
|
|
396
403
|
});
|
|
397
404
|
}
|
|
398
|
-
async function
|
|
405
|
+
async function showAttachmentPath(runtime, locator, path, revision) {
|
|
399
406
|
const { store } = runtime;
|
|
400
|
-
const asked = await
|
|
407
|
+
const asked = await askedAttachment(runtime, locator, path, revision);
|
|
401
408
|
if (asked === null)
|
|
402
|
-
return
|
|
409
|
+
return absentAttachment(path);
|
|
403
410
|
if (asked.kind === 'pending')
|
|
404
|
-
return
|
|
411
|
+
return pendingAttachment(store, locator, path, asked.localId);
|
|
405
412
|
if (runtime.socket.closed())
|
|
406
413
|
return UNCERTAIN;
|
|
407
414
|
const name = { locator, path: asked.path, revision: asked.revision };
|
|
@@ -424,7 +431,7 @@ async function attachFile(runtime, locator, file, answer) {
|
|
|
424
431
|
socket.session.now().refusal !== null)
|
|
425
432
|
return OFFLINE;
|
|
426
433
|
const request = await attachedFile(locator, file);
|
|
427
|
-
return
|
|
434
|
+
return transferAttachment(runtime, { locator }, async (held) => {
|
|
428
435
|
const result = await socket.attach(held, request);
|
|
429
436
|
if (result.kind === 'attached' && locator !== null) {
|
|
430
437
|
store.attached.hold(locator, result.path, {
|
|
@@ -438,7 +445,7 @@ async function attachFile(runtime, locator, file, answer) {
|
|
|
438
445
|
async function keyedAttachment(runtime, link) {
|
|
439
446
|
await runtime.socket.ready;
|
|
440
447
|
const asked = { kind: 'key', link };
|
|
441
|
-
return
|
|
448
|
+
return transferAttachment(runtime, { locator: null }, (authorization) => runtime.socket.link(authorization, asked), (result) => attachmentLinkAnswer(result));
|
|
442
449
|
}
|
|
443
450
|
export function conversationFiles(runtime) {
|
|
444
451
|
return {
|
|
@@ -446,12 +453,12 @@ export function conversationFiles(runtime) {
|
|
|
446
453
|
attachment: (link) => keyedAttachment(runtime, link),
|
|
447
454
|
};
|
|
448
455
|
}
|
|
449
|
-
export function
|
|
456
|
+
export function attachmentSurface(runtime) {
|
|
450
457
|
return {
|
|
451
458
|
part: runtime.store.part,
|
|
452
|
-
read: (room, path, revision) =>
|
|
453
|
-
link: (room, path, revision) =>
|
|
454
|
-
show: (room, path, revision) =>
|
|
459
|
+
read: (room, path, revision) => readAttachmentPath(runtime, room, path, revision),
|
|
460
|
+
link: (room, path, revision) => linkAttachmentPath(runtime, room, path, revision),
|
|
461
|
+
show: (room, path, revision) => showAttachmentPath(runtime, room, path, revision),
|
|
455
462
|
attach: (room, file) => attachFile(runtime, room, file, attachAnswer),
|
|
456
463
|
};
|
|
457
464
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../src/selector.ts"],"names":[],"mappings":"AAaA,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,GACtC,OAAO,CAET;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAOnF"}
|
package/dist/selector.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function rewrittenAt(value, members, rewrite) {
|
|
2
|
+
if (Array.isArray(value))
|
|
3
|
+
return value.map((one) => rewrittenAt(one, members, rewrite));
|
|
4
|
+
const [member, ...rest] = members;
|
|
5
|
+
if (member === undefined)
|
|
6
|
+
return rewrite(value);
|
|
7
|
+
if (value === null || typeof value !== 'object' || !Object.hasOwn(value, member))
|
|
8
|
+
return value;
|
|
9
|
+
const held = value;
|
|
10
|
+
return { ...held, [member]: rewrittenAt(held[member], rest, rewrite) };
|
|
11
|
+
}
|
|
12
|
+
export function selectorRewritten(value, selector, rewrite) {
|
|
13
|
+
return rewrittenAt(value, selector.split('.'), rewrite);
|
|
14
|
+
}
|
|
15
|
+
export function selectorValues(value, selector) {
|
|
16
|
+
const selected = [];
|
|
17
|
+
selectorRewritten(value, selector, (one) => {
|
|
18
|
+
selected.push(one);
|
|
19
|
+
return one;
|
|
20
|
+
});
|
|
21
|
+
return selected;
|
|
22
|
+
}
|
package/dist/shown.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare function show(runtime: Runtime): Promise<void>;
|
|
|
26
26
|
export declare function moveTo(runtime: Runtime, next: Moving): Promise<void>;
|
|
27
27
|
export declare function statusShown(runtime: Runtime): Promise<void>;
|
|
28
28
|
export declare function transferring({ socket }: Runtime): Moving;
|
|
29
|
-
export declare function pendingShown(runtime: Runtime): Promise<void>;
|
|
29
|
+
export declare function pendingShown(runtime: Runtime, locator: string): Promise<void>;
|
|
30
30
|
export declare function entriesOf(runtime: Runtime, locator: string): Promise<readonly QueueEntry[]>;
|
|
31
31
|
export declare function publishChangeSet(runtime: Runtime, set: ChangeSet): Promise<void>;
|
|
32
32
|
export declare function submissionDue(runtime: Runtime, locators?: readonly string[]): 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,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C,IAAI,CAAC,CAQjG;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAG/D;AAED,wBAAsB,IAAI,CACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,GAAG,IAAI,EAC9B,IAAI,GAAE,IAAqC,iBAkC5C"}
|
package/dist/shown.js
CHANGED
|
@@ -14,7 +14,7 @@ export const TIME_ZONE_TOPIC = 'time-zone';
|
|
|
14
14
|
export const AUTHORITY_TOPIC = 'authority-changes';
|
|
15
15
|
export const LOCKS_TOPIC = 'locks';
|
|
16
16
|
export const queueTopic = (locator) => `queue\u0000${locator}`;
|
|
17
|
-
async function attended({ store, socket,
|
|
17
|
+
async function attended({ store, socket, savesLocally }) {
|
|
18
18
|
const held = store.needed()
|
|
19
19
|
? await store.status()
|
|
20
20
|
: {
|
|
@@ -35,23 +35,22 @@ async function attended({ store, socket, localSaves }) {
|
|
|
35
35
|
return 0;
|
|
36
36
|
});
|
|
37
37
|
const changed = new Map();
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
for (const change of held.unsent)
|
|
39
|
+
if (!savesLocally(change.room))
|
|
40
40
|
changed.set(`${change.room}\u0000${change.path}`, change);
|
|
41
|
-
}
|
|
42
41
|
const unsent = [...changed]
|
|
43
42
|
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
|
|
44
43
|
.map(([, change]) => change);
|
|
45
44
|
return {
|
|
46
|
-
queued:
|
|
45
|
+
queued: held.queued.some((locator) => !savesLocally(locator)),
|
|
47
46
|
lastCompleted: held.lastCompleted,
|
|
48
47
|
attentionRequired,
|
|
49
48
|
unsent,
|
|
50
49
|
reset: held.resets.reduce((earliest, { reset }) => (earliest !== null && earliest <= reset ? earliest : reset), null),
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
|
-
async function queuedWork({ store,
|
|
54
|
-
return
|
|
52
|
+
async function queuedWork({ store, savesLocally }) {
|
|
53
|
+
return store.needed() && (await store.queued()).some((locator) => !savesLocally(locator));
|
|
55
54
|
}
|
|
56
55
|
export function recoverReads({ liveQueries, figures }, locators) {
|
|
57
56
|
liveQueries.recover(locators);
|
|
@@ -212,22 +211,24 @@ export function statusShown(runtime) {
|
|
|
212
211
|
export function transferring({ socket }) {
|
|
213
212
|
return { ...socket.session.now().moving, state: 'syncing', resting: false };
|
|
214
213
|
}
|
|
215
|
-
export function pendingShown(runtime) {
|
|
216
|
-
const { socket
|
|
214
|
+
export function pendingShown(runtime, locator) {
|
|
215
|
+
const { socket } = runtime;
|
|
216
|
+
const localSaves = runtime.savesLocally(locator);
|
|
217
217
|
if (!localSaves)
|
|
218
218
|
socket.session.set({ recorded: false });
|
|
219
219
|
const { moving } = socket.session.now();
|
|
220
220
|
return moveTo(runtime, localSaves ? moving : { ...moving, state: 'pending', resting: false });
|
|
221
221
|
}
|
|
222
|
-
function entryOf(
|
|
223
|
-
if (
|
|
222
|
+
function entryOf(local, states, batch) {
|
|
223
|
+
if (local)
|
|
224
224
|
return Object.freeze({ batch, state: 'local' });
|
|
225
225
|
const state = states.get(batch.id);
|
|
226
226
|
return Object.freeze({ batch, ...(state?.submission ?? { state: 'waiting' }) });
|
|
227
227
|
}
|
|
228
228
|
export async function entriesOf(runtime, locator) {
|
|
229
229
|
const { queue, states } = await runtime.store.work(locator);
|
|
230
|
-
|
|
230
|
+
const local = runtime.savesLocally(locator);
|
|
231
|
+
return queue.map((batch) => entryOf(local, states, batch));
|
|
231
232
|
}
|
|
232
233
|
function emitQueue(runtime, locator) {
|
|
233
234
|
const { store, socket } = runtime;
|