@agentshouse/mdruntime 0.1.0-cec6690d5712e → 0.1.0-cedb03eaa48b6
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/AGENTS.md +277 -271
- package/README.md +8 -8
- package/dist/adapter.d.ts +85 -20
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/binary.d.ts +23 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +3 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +37 -14
- package/dist/change-set.d.ts +2 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +40 -13
- package/dist/change.d.ts +11 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +26 -1
- package/dist/chat/acts.d.ts +3 -4
- package/dist/chat/acts.d.ts.map +1 -1
- package/dist/chat/acts.js +10 -10
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/kit.d.ts +2 -1
- package/dist/chat/kit.d.ts.map +1 -1
- package/dist/chat/kit.js +3 -3
- package/dist/chat/list.d.ts +8 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +48 -8
- package/dist/chat/markdown.d.ts +2 -1
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +7 -6
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +2 -2
- package/dist/chat/messages.d.ts +1 -0
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +4 -0
- package/dist/chat/provider.d.ts +1 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +62 -79
- package/dist/chat/question.d.ts +1 -1
- package/dist/chat/question.d.ts.map +1 -1
- package/dist/chat/question.js +7 -18
- package/dist/chat/ready.d.ts +1 -0
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +4 -4
- package/dist/chat/style.js +5 -5
- package/dist/client.d.ts +22 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +23 -6
- package/dist/collection.d.ts +17 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +260 -19
- package/dist/connection.d.ts +39 -12
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1769 -385
- package/dist/conversation.d.ts +20 -7
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +474 -163
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +157 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/host.d.ts +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +98 -12
- package/dist/identity.d.ts +3 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +9 -0
- package/dist/index.d.ts +12 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/memory.d.ts +10 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +64 -17
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -1
- package/dist/observation.d.ts +7 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +29 -12
- package/dist/outcome.d.ts +17 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +10 -0
- package/dist/overlay.d.ts +15 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +99 -62
- package/dist/query.d.ts +58 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +36 -7
- package/dist/reach.d.ts +8 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +53 -6
- package/dist/react.d.ts +8 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/read-side.d.ts +16 -7
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +493 -102
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +27 -25
- package/dist/replica.d.ts +11 -4
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +106 -48
- package/dist/room-draft.d.ts +32 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +121 -3
- package/dist/rows.d.ts +8 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +12 -13
- package/dist/save.d.ts +29 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +358 -30
- package/dist/search.d.ts +49 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +192 -47
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +11 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +368 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +68 -21
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +463 -206
- package/dist/turn.d.ts +7 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +51 -0
- package/dist/windows.d.ts +26 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +93 -0
- package/dist/wire.d.ts +152 -30
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +52 -29
- package/package.json +12 -8
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
package/dist/reach.js
CHANGED
|
@@ -2,11 +2,12 @@ import { unheldView } from './conversation.js';
|
|
|
2
2
|
import { modelTypes, NO_MODEL } from './model.js';
|
|
3
3
|
import { applied, observing } from './observation.js';
|
|
4
4
|
import { runtimeError } from './failure.js';
|
|
5
|
-
import { failure, undeclared } from './outcome.js';
|
|
5
|
+
import { failure, undeclared, } from './outcome.js';
|
|
6
6
|
import { beneath } from './paths.js';
|
|
7
7
|
import { reconciled } from './read-side.js';
|
|
8
8
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
9
9
|
import { documentKey } from './rows.js';
|
|
10
|
+
import { undeclaredSearch } from './search.js';
|
|
10
11
|
const UNHELD_TYPES = { collection: modelTypes(NO_MODEL), typedSelection: null };
|
|
11
12
|
function unconversed(name) {
|
|
12
13
|
return () => Promise.resolve(undeclared(name));
|
|
@@ -24,6 +25,7 @@ const NO_CONVERSATION = {
|
|
|
24
25
|
};
|
|
25
26
|
const NO_CHAT_DRAFT = {
|
|
26
27
|
write: () => Promise.resolve(),
|
|
28
|
+
prepend: () => Promise.resolve(),
|
|
27
29
|
discard: () => Promise.resolve(),
|
|
28
30
|
};
|
|
29
31
|
export function holds(reach, room) {
|
|
@@ -52,6 +54,20 @@ function covers(reach, room, path) {
|
|
|
52
54
|
function conversing(reach) {
|
|
53
55
|
return reach === null || reach.conversations;
|
|
54
56
|
}
|
|
57
|
+
function refers(reach, scope) {
|
|
58
|
+
if (reach === null)
|
|
59
|
+
return true;
|
|
60
|
+
if (scope === null)
|
|
61
|
+
return false;
|
|
62
|
+
if (scope.kind === 'conversations')
|
|
63
|
+
return reach.conversations;
|
|
64
|
+
return scope.path === undefined
|
|
65
|
+
? wholly(reach, scope.locator)
|
|
66
|
+
: covers(reach, scope.locator, scope.path);
|
|
67
|
+
}
|
|
68
|
+
function unreachedReference(fileRef) {
|
|
69
|
+
return { kind: 'absent', code: 'binary-file-absent', fields: { fileRef }, retryable: false };
|
|
70
|
+
}
|
|
55
71
|
export function planReach(reach) {
|
|
56
72
|
return reach === null
|
|
57
73
|
? null
|
|
@@ -108,7 +124,7 @@ function savedWithin(reach, room, result) {
|
|
|
108
124
|
function statusWithin(reach, status) {
|
|
109
125
|
return {
|
|
110
126
|
...status,
|
|
111
|
-
attentionRequired: status.attentionRequired.filter((entry) => covers(reach, entry.room, entry.path)),
|
|
127
|
+
attentionRequired: status.attentionRequired.filter((entry) => 'refusal' in entry ? wholly(reach, entry.room) : covers(reach, entry.room, entry.path)),
|
|
112
128
|
};
|
|
113
129
|
}
|
|
114
130
|
function queueWithin(reach, room, entries) {
|
|
@@ -118,9 +134,10 @@ function queueWithin(reach, room, entries) {
|
|
|
118
134
|
function unreached(room) {
|
|
119
135
|
return runtimeError('room-not-held', `No Local Replica for ${room}`);
|
|
120
136
|
}
|
|
121
|
-
export function narrowed(runtime, given) {
|
|
137
|
+
export function narrowed(runtime, given, told) {
|
|
122
138
|
const { md, watch } = runtime;
|
|
123
139
|
let reach = given;
|
|
140
|
+
let port = told;
|
|
124
141
|
const open = new Set();
|
|
125
142
|
function following(begin) {
|
|
126
143
|
let stop = begin();
|
|
@@ -138,6 +155,9 @@ export function narrowed(runtime, given) {
|
|
|
138
155
|
if (topic === 'rooms') {
|
|
139
156
|
return following(() => watch(topic, input, (rooms) => deliver(roomsWithin(reach, rooms))));
|
|
140
157
|
}
|
|
158
|
+
if (topic === 'readiness') {
|
|
159
|
+
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
160
|
+
}
|
|
141
161
|
if (topic === 'sync-status') {
|
|
142
162
|
return following(() => watch(topic, input, (status) => deliver(statusWithin(reach, status))));
|
|
143
163
|
}
|
|
@@ -175,7 +195,7 @@ export function narrowed(runtime, given) {
|
|
|
175
195
|
if (next === null)
|
|
176
196
|
return;
|
|
177
197
|
held = next.keyed;
|
|
178
|
-
deliver(next.
|
|
198
|
+
deliver(next.message);
|
|
179
199
|
});
|
|
180
200
|
});
|
|
181
201
|
}
|
|
@@ -203,7 +223,9 @@ export function narrowed(runtime, given) {
|
|
|
203
223
|
...md,
|
|
204
224
|
rooms: () => roomsWithin(reach, md.rooms()),
|
|
205
225
|
query: ((input) => runtime.query(runtime.plan(input, reach))),
|
|
206
|
-
search: (input) =>
|
|
226
|
+
search: (input) => port.search === 'required'
|
|
227
|
+
? runtime.search(input, reach)
|
|
228
|
+
: Promise.resolve(undeclaredSearch()),
|
|
207
229
|
types(room) {
|
|
208
230
|
if (wholly(reach, room))
|
|
209
231
|
return md.types(room);
|
|
@@ -222,9 +244,28 @@ export function narrowed(runtime, given) {
|
|
|
222
244
|
}
|
|
223
245
|
return savedWithin(reach, room, await md.save(room, roomDrafts, writtenBy));
|
|
224
246
|
},
|
|
247
|
+
async saveParts(room, parts, writtenBy) {
|
|
248
|
+
if (!holds(reach, room))
|
|
249
|
+
throw unreached(room);
|
|
250
|
+
if (parts.some(({ path, parts: one }) => !covers(reach, room, path) || !moves(reach, room, readParts(one).move))) {
|
|
251
|
+
throw unreached(room);
|
|
252
|
+
}
|
|
253
|
+
return savedWithin(reach, room, await md.saveParts(room, parts, writtenBy));
|
|
254
|
+
},
|
|
225
255
|
history: (room, path, query) => covers(reach, room, path)
|
|
226
256
|
? md.history(room, path, query)
|
|
227
257
|
: Promise.resolve(failure({ kind: 'room-not-readable', locator: room })),
|
|
258
|
+
binaryFile: {
|
|
259
|
+
read: (room, path, revision) => covers(reach, room, path)
|
|
260
|
+
? md.binaryFile.read(room, path, revision)
|
|
261
|
+
: Promise.resolve(failure({ kind: 'room-not-readable', locator: room })),
|
|
262
|
+
link: (room, path, revision) => covers(reach, room, path)
|
|
263
|
+
? md.binaryFile.link(room, path, revision)
|
|
264
|
+
: Promise.resolve(failure({ kind: 'room-not-readable', locator: room })),
|
|
265
|
+
readReference: (reference) => refers(reach, runtime.referrerScope(reference.referrer))
|
|
266
|
+
? md.binaryFile.readReference(reference)
|
|
267
|
+
: Promise.resolve(unreachedReference(reference.fileRef)),
|
|
268
|
+
},
|
|
228
269
|
reached: (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
229
270
|
md.reached(room, roomVersion, path),
|
|
230
271
|
log: () => (reach === null ? md.log() : ''),
|
|
@@ -247,7 +288,7 @@ export function narrowed(runtime, given) {
|
|
|
247
288
|
list: () => conversation().list(),
|
|
248
289
|
read: (id, options) => conversation().read(id, options),
|
|
249
290
|
create: (input) => conversation().create(input),
|
|
250
|
-
send: (id) => conversation().send(id),
|
|
291
|
+
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
251
292
|
answer: (id, answer) => conversation().answer(id, answer),
|
|
252
293
|
interrupt: (id) => conversation().interrupt(id),
|
|
253
294
|
kill: (id) => conversation().kill(id),
|
|
@@ -256,6 +297,7 @@ export function narrowed(runtime, given) {
|
|
|
256
297
|
},
|
|
257
298
|
chatDraft: {
|
|
258
299
|
write: (id, draft, revision) => chatDraft().write(id, draft, revision),
|
|
300
|
+
prepend: (id, draft) => chatDraft().prepend(id, draft),
|
|
259
301
|
discard: (id) => chatDraft().discard(id),
|
|
260
302
|
},
|
|
261
303
|
observe: observing(within),
|
|
@@ -268,5 +310,10 @@ export function narrowed(runtime, given) {
|
|
|
268
310
|
for (const restart of [...open])
|
|
269
311
|
restart();
|
|
270
312
|
},
|
|
313
|
+
facts(next) {
|
|
314
|
+
port = next;
|
|
315
|
+
for (const restart of [...open])
|
|
316
|
+
restart();
|
|
317
|
+
},
|
|
271
318
|
};
|
|
272
319
|
}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { MdRuntimeClient } from './client.js';
|
|
2
|
-
import type { AppRoom, ConnectionRefusal, SaveResult } from './connection.js';
|
|
2
|
+
import type { AppRoom, ConnectionRefusal, SavedRoomDraft, SaveResult } from './connection.js';
|
|
3
3
|
import type { Member, ServiceMode } from './adapter.js';
|
|
4
4
|
import type { ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
5
5
|
import { type RuntimeError } from './failure.js';
|
|
6
6
|
import type { QueueEntry } from './outcome.js';
|
|
7
|
-
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
|
|
7
|
+
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
|
|
8
|
+
import type { Readiness } from './readiness.js';
|
|
8
9
|
import type { RoomDraft, RoomDraftParts } from './room-draft.js';
|
|
9
10
|
import type { SyncStatus } from './status.js';
|
|
10
11
|
type Client = MdRuntimeClient | null;
|
|
@@ -16,13 +17,14 @@ export type Observed<T> = {
|
|
|
16
17
|
};
|
|
17
18
|
export declare function useObserve(client: Client, topic: 'deployment-facts'): Observed<unknown>;
|
|
18
19
|
export declare function useObserve(client: Client, topic: 'rooms'): Observed<readonly AppRoom[]>;
|
|
20
|
+
export declare function useObserve(client: Client, topic: 'readiness'): Observed<Readiness>;
|
|
19
21
|
export declare function useObserve(client: Client, topic: 'connection-refusal'): Observed<ConnectionRefusal | null>;
|
|
20
22
|
export declare function useObserve(client: Client, topic: 'storage-loss'): Observed<string | null>;
|
|
21
23
|
export declare function useObserve(client: Client, topic: 'sync-status'): Observed<SyncStatus>;
|
|
22
24
|
export declare function useObserve(client: Client, topic: 'service-mode'): Observed<ServiceMode>;
|
|
23
25
|
export declare function useObserve(client: Client, topic: 'member'): Observed<Member | null>;
|
|
24
|
-
export declare function useObserve(client: Client, topic: 'query', query: DocumentQuery): Observed<DocumentResult>;
|
|
25
|
-
export declare function useObserve(client: Client, topic: 'query', query: GroupQuery): Observed<GroupResult>;
|
|
26
|
+
export declare function useObserve(client: Client, topic: 'query', query: DocumentQuery): Observed<DocumentResult | PendingResult>;
|
|
27
|
+
export declare function useObserve(client: Client, topic: 'query', query: GroupQuery): Observed<GroupResult | PendingResult>;
|
|
26
28
|
export declare function useObserve(client: Client, topic: 'queue', locator: string): Observed<readonly QueueEntry[]>;
|
|
27
29
|
export declare function useObserve(client: Client, topic: 'room-drafts'): Observed<readonly RoomDraft[]>;
|
|
28
30
|
export declare function useObserve(client: Client, topic: 'presentation'): Observed<unknown>;
|
|
@@ -33,9 +35,9 @@ export type Saving = {
|
|
|
33
35
|
readonly busy: boolean;
|
|
34
36
|
readonly outcome: SaveResult | null;
|
|
35
37
|
readonly failure: RuntimeError | null;
|
|
36
|
-
save(room: string,
|
|
38
|
+
save(room: string, parts: ReadonlyMap<string, RoomDraftParts>): Promise<SaveResult>;
|
|
39
|
+
saveWritten(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
37
40
|
};
|
|
38
|
-
export declare function saveRoomDrafts(client: MdRuntimeClient, room: string, roomDrafts: ReadonlyMap<string, RoomDraftParts>): Promise<SaveResult>;
|
|
39
41
|
export declare function useSave(client: MdRuntimeClient): Saving;
|
|
40
42
|
export {};
|
|
41
43
|
//# sourceMappingURL=react.d.ts.map
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzD,OAA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,GAAG,QAAQ,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC;AAsCpG,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACpF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACvF,CAAC;AAMF,wBAAgB,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA8BvD"}
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
-
import { failed
|
|
2
|
+
import { failed } from './failure.js';
|
|
3
3
|
const LOADING = { state: 'loading' };
|
|
4
4
|
export function useObserve(client, topic, ...input) {
|
|
5
5
|
const key = JSON.stringify([topic, ...input]);
|
|
@@ -33,24 +33,12 @@ export function useObserve(client, topic, ...input) {
|
|
|
33
33
|
return held !== null && held.client === client && held.key === key ? held.observed : LOADING;
|
|
34
34
|
}
|
|
35
35
|
const IDLE = { busy: false, outcome: null, failure: null };
|
|
36
|
-
export async function saveRoomDrafts(client, room, roomDrafts) {
|
|
37
|
-
const kept = [];
|
|
38
|
-
for (const [path, parts] of roomDrafts) {
|
|
39
|
-
const prior = await client.roomDraft.read(room, path);
|
|
40
|
-
const write = await client.roomDraft.write(room, path, prior?.revision ?? null, parts);
|
|
41
|
-
if (write.outcome !== 'written' || write.roomDraft === null) {
|
|
42
|
-
throw runtimeError(write.outcome === 'stale' ? write.code : 'room-draft-unwritten', `the Room Draft at ${path} was not written`);
|
|
43
|
-
}
|
|
44
|
-
kept.push({ path, revision: write.roomDraft.revision });
|
|
45
|
-
}
|
|
46
|
-
return client.save(room, kept);
|
|
47
|
-
}
|
|
48
36
|
export function useSave(client) {
|
|
49
37
|
const [state, setState] = useState(IDLE);
|
|
50
|
-
const
|
|
38
|
+
const settled = useCallback(async (saving) => {
|
|
51
39
|
setState({ busy: true, outcome: null, failure: null });
|
|
52
40
|
try {
|
|
53
|
-
const outcome = await
|
|
41
|
+
const outcome = await saving();
|
|
54
42
|
setState({ busy: false, outcome, failure: null });
|
|
55
43
|
return outcome;
|
|
56
44
|
}
|
|
@@ -59,6 +47,8 @@ export function useSave(client) {
|
|
|
59
47
|
setState({ busy: false, outcome: null, failure });
|
|
60
48
|
throw failure;
|
|
61
49
|
}
|
|
62
|
-
}, [
|
|
63
|
-
|
|
50
|
+
}, []);
|
|
51
|
+
const save = useCallback((room, parts) => settled(() => client.saveParts(room, [...parts].map(([path, one]) => ({ path, parts: one })))), [client, settled]);
|
|
52
|
+
const saveWritten = useCallback((room, roomDrafts) => settled(() => client.save(room, roomDrafts)), [client, settled]);
|
|
53
|
+
return { ...state, save, saveWritten };
|
|
64
54
|
}
|
package/dist/read-side.d.ts
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import type { ChangeSet } from './change-set.js';
|
|
2
|
-
import { type KeyedResult, type
|
|
3
|
-
import type { Plan,
|
|
2
|
+
import { type KeyedResult, type QueryMessage } from './observation.js';
|
|
3
|
+
import type { PendingResult, Plan, QueryCoverage, QueryRows } from './query.js';
|
|
4
|
+
import { type Later } from './turn.js';
|
|
4
5
|
import type { SearchedDocument } from './search.js';
|
|
6
|
+
export type Cover = {
|
|
7
|
+
coverage: QueryCoverage;
|
|
8
|
+
} | PendingResult;
|
|
5
9
|
export type ReadSide = {
|
|
6
|
-
apply(set: ChangeSet): void
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
apply(set: ChangeSet, next?: () => void): Later<void>;
|
|
11
|
+
recover(): void;
|
|
12
|
+
settled(): Promise<void>;
|
|
13
|
+
query<T>(plan: Plan, at: () => T): Promise<{
|
|
14
|
+
rows: QueryRows;
|
|
15
|
+
at: T;
|
|
16
|
+
}>;
|
|
17
|
+
watch(plan: Plan, identity: string, cover: () => Cover, deliver: (message: QueryMessage) => void): () => void;
|
|
18
|
+
room(room: string): readonly string[];
|
|
10
19
|
document(room: string, path: string): SearchedDocument | null;
|
|
11
20
|
close(): void;
|
|
12
21
|
};
|
|
13
22
|
export declare function reconciled(previous: KeyedResult, next: KeyedResult): {
|
|
14
23
|
keyed: KeyedResult;
|
|
15
|
-
|
|
24
|
+
message: QueryMessage;
|
|
16
25
|
} | null;
|
|
17
26
|
export declare function createReadSide(): ReadSide;
|
|
18
27
|
//# sourceMappingURL=read-side.d.ts.map
|
package/dist/read-side.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-side.d.ts","sourceRoot":"","sources":["../src/read-side.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-side.d.ts","sourceRoot":"","sources":["../src/read-side.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,YAAY,EAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAOV,aAAa,EACb,IAAI,EAEJ,aAAa,EAGb,SAAS,EAIV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAA8B,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkDpD,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,GAAG,aAAa,CAAC;AAwBhE,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,GAAG,EAAE,SAAS,E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