@agentshouse/mdruntime 0.1.0-cde2b99d2fcbc → 0.1.0-cdf06805b9658
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 +286 -292
- package/README.md +16 -14
- package/dist/adapter.d.ts +99 -36
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -4
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +27 -9
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +155 -64
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -63
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/client.d.ts +24 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +49 -9
- package/dist/collection.d.ts +7 -6
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +30 -77
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +721 -0
- package/dist/connection.d.ts +42 -15
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3397 -804
- package/dist/conversation.d.ts +30 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +549 -181
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +5 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +19 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +151 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -10
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -120
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +126 -16
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +123 -0
- package/dist/memory.d.ts +10 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +54 -26
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +11 -2
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +19 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +113 -12
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +38 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +26 -0
- package/dist/overlay.d.ts +3 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +100 -182
- package/dist/query.d.ts +60 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +48 -7
- package/dist/reach.d.ts +11 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +182 -62
- package/dist/react.d.ts +8 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/readiness.d.ts +64 -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 +100 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +198 -0
- package/dist/refresh.d.ts +16 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +113 -49
- package/dist/replica.d.ts +56 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +297 -162
- package/dist/room-draft.d.ts +17 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +65 -25
- package/dist/rows.d.ts +28 -37
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +113 -72
- package/dist/save.d.ts +50 -9
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +528 -166
- package/dist/search.d.ts +39 -28
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +37 -105
- 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 +16 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +431 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +118 -76
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +355 -444
- package/dist/stored.d.ts +145 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +567 -0
- package/dist/tables.d.ts +354 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +624 -0
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +164 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +55 -31
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +27 -23
- package/dist/chat/acts.d.ts +0 -34
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -60
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -20
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -59
- package/dist/chat/markdown.d.ts +0 -19
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -187
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -192
- package/dist/chat/messages.d.ts +0 -21
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -151
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -31
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -97
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -63
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -645
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -80
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -33
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -440
package/dist/query.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pointerFacts, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { referenceField } from './model.js';
|
|
3
3
|
import { normalize } from './paths.js';
|
|
4
|
+
import { decodedCursor } from './windows.js';
|
|
4
5
|
export class QueryError extends Error {
|
|
5
6
|
code;
|
|
6
7
|
retryable = false;
|
|
@@ -11,9 +12,18 @@ export class QueryError extends Error {
|
|
|
11
12
|
}
|
|
12
13
|
const RANGE = ['$gt', '$gte', '$lt', '$lte'];
|
|
13
14
|
const SINGLE = ['$eq', '$ne', '$in', '$nin', '$all', '$size', '$exists'];
|
|
14
|
-
const FILTER = ['rooms', 'types', 'where', 'pathPrefix', 'hop', 'backlinks'];
|
|
15
|
+
const FILTER = ['rooms', 'types', 'where', 'pathPrefix', 'folder', 'paths', 'hop', 'backlinks'];
|
|
15
16
|
const RELATED = ['types', 'where', 'pathPrefix', 'field'];
|
|
16
|
-
const PARTS = [
|
|
17
|
+
const PARTS = [
|
|
18
|
+
'fields',
|
|
19
|
+
'sections',
|
|
20
|
+
'preamble',
|
|
21
|
+
'markdown',
|
|
22
|
+
'backlinks',
|
|
23
|
+
'change',
|
|
24
|
+
'fileId',
|
|
25
|
+
'revision',
|
|
26
|
+
];
|
|
17
27
|
const ORDER = ['by', 'direction', 'nulls', 'stringSort', 'locale', 'localeOptions'];
|
|
18
28
|
const CALENDAR_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
19
29
|
const STRAY_ESCAPE = /~(?![01])/u;
|
|
@@ -60,6 +70,13 @@ function names(input, at) {
|
|
|
60
70
|
invalid(at, 'expects a list of names');
|
|
61
71
|
return [...new Set(listed)].sort();
|
|
62
72
|
}
|
|
73
|
+
function pathsOf(input) {
|
|
74
|
+
const listed = list(input, 'paths');
|
|
75
|
+
if (listed.some((item) => typeof item !== 'string' || item === '' || normalize(item) !== item)) {
|
|
76
|
+
invalid('paths', 'expects a list of Paths');
|
|
77
|
+
}
|
|
78
|
+
return [...new Set(listed)].sort();
|
|
79
|
+
}
|
|
63
80
|
function directory(input, at) {
|
|
64
81
|
if (typeof input !== 'string' || normalize(input) !== input) {
|
|
65
82
|
invalid(at, 'expects a normalized directory');
|
|
@@ -279,15 +296,16 @@ function backlinksOf(facts, rooms, input) {
|
|
|
279
296
|
return { types, where, pathPrefix, field };
|
|
280
297
|
}
|
|
281
298
|
function keyPlan(typed, input, at, path) {
|
|
282
|
-
if (input === 'room' || input === 'type' || (path && input === 'path'))
|
|
299
|
+
if (input === 'room' || input === 'type' || input === 'folder' || (path && input === 'path')) {
|
|
283
300
|
return { of: input };
|
|
301
|
+
}
|
|
284
302
|
if (plain(input) && Object.hasOwn(input, 'field') && Object.keys(input).length === 1) {
|
|
285
303
|
if (specs(typed, input.field, place(at, 'field')).some(several)) {
|
|
286
304
|
invalid(place(at, 'field'), 'a path that can hold several values');
|
|
287
305
|
}
|
|
288
306
|
return { of: 'field', field: input.field };
|
|
289
307
|
}
|
|
290
|
-
return invalid(at, path ? 'expects room, path, type or a field' : 'expects room, type or a field');
|
|
308
|
+
return invalid(at, path ? 'expects room, path, type, folder or a field' : 'expects room, type, folder or a field');
|
|
291
309
|
}
|
|
292
310
|
function direction(input, at) {
|
|
293
311
|
if (input === undefined)
|
|
@@ -349,7 +367,7 @@ function parts(typed, input, at, fields) {
|
|
|
349
367
|
});
|
|
350
368
|
return named;
|
|
351
369
|
}
|
|
352
|
-
function flag(input, at) {
|
|
370
|
+
export function flag(input, at) {
|
|
353
371
|
if (input === undefined)
|
|
354
372
|
return false;
|
|
355
373
|
if (input !== true)
|
|
@@ -377,6 +395,8 @@ function documentShape(typed, input) {
|
|
|
377
395
|
markdown: true,
|
|
378
396
|
backlinks: true,
|
|
379
397
|
change: true,
|
|
398
|
+
fileId: true,
|
|
399
|
+
revision: true,
|
|
380
400
|
orderBy,
|
|
381
401
|
};
|
|
382
402
|
}
|
|
@@ -391,6 +411,8 @@ function documentShape(typed, input) {
|
|
|
391
411
|
markdown: flag(select.markdown, 'select.markdown'),
|
|
392
412
|
backlinks: flag(select.backlinks, 'select.backlinks'),
|
|
393
413
|
change: flag(select.change, 'select.change'),
|
|
414
|
+
fileId: flag(select.fileId, 'select.fileId'),
|
|
415
|
+
revision: flag(select.revision, 'select.revision'),
|
|
394
416
|
orderBy,
|
|
395
417
|
};
|
|
396
418
|
}
|
|
@@ -421,20 +443,36 @@ export function planOf(input, facts, reach = null) {
|
|
|
421
443
|
invalid('select', 'a grouped query selects nothing');
|
|
422
444
|
if (!grouped && input.select === undefined)
|
|
423
445
|
invalid('select', 'a Document query must select');
|
|
424
|
-
known(input, [...FILTER, 'orderBy', 'limit', grouped ? 'groupBy' : 'select'], '');
|
|
446
|
+
known(input, [...FILTER, 'orderBy', 'limit', 'after', 'total', grouped ? 'groupBy' : 'select'], '');
|
|
425
447
|
const limit = limitOf(input.limit);
|
|
426
448
|
const rooms = input.rooms === undefined ? null : names(input.rooms, 'rooms');
|
|
427
449
|
const { typed, ...root } = scope(facts, rooms, input, '');
|
|
450
|
+
const shape = grouped ? groupShape(typed, input) : documentShape(typed, input);
|
|
428
451
|
return {
|
|
452
|
+
key: queryKey(input),
|
|
429
453
|
rooms,
|
|
430
454
|
reach,
|
|
455
|
+
locked: [],
|
|
431
456
|
root,
|
|
457
|
+
folder: input.folder === undefined ? null : directory(input.folder, 'folder'),
|
|
458
|
+
paths: input.paths === undefined ? null : pathsOf(input.paths),
|
|
432
459
|
hop: input.hop === undefined ? null : hopOf(facts, rooms, typed, input.hop),
|
|
433
460
|
backlinks: input.backlinks === undefined ? null : backlinksOf(facts, rooms, input.backlinks),
|
|
434
|
-
shape
|
|
461
|
+
shape,
|
|
435
462
|
limit,
|
|
463
|
+
after: continuationOf(input.after, shape.orderBy.length + 1),
|
|
464
|
+
total: flag(input.total, 'total'),
|
|
436
465
|
};
|
|
437
466
|
}
|
|
467
|
+
function continuationOf(input, arity) {
|
|
468
|
+
if (input === undefined)
|
|
469
|
+
return null;
|
|
470
|
+
const values = typeof input === 'string' ? decodedCursor(input) : null;
|
|
471
|
+
if (values === null || (values.length !== 0 && values.length !== arity)) {
|
|
472
|
+
invalid('after', 'expects the next an earlier result of this query returned');
|
|
473
|
+
}
|
|
474
|
+
return { text: input, values: values.length === 0 ? null : values };
|
|
475
|
+
}
|
|
438
476
|
export function limitOf(input) {
|
|
439
477
|
if (input === undefined)
|
|
440
478
|
return null;
|
|
@@ -449,6 +487,9 @@ export function filterOf(input, facts, reach = null) {
|
|
|
449
487
|
known(input, FILTER, '');
|
|
450
488
|
return planOf({ ...input, select: {} }, facts, reach);
|
|
451
489
|
}
|
|
490
|
+
export function queryKey(query) {
|
|
491
|
+
return canonical(query);
|
|
492
|
+
}
|
|
452
493
|
function canonical(value) {
|
|
453
494
|
if (Array.isArray(value))
|
|
454
495
|
return `[${value.map(canonical).join(',')}]`;
|
package/dist/reach.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { MdRuntime, RuntimeTopic } from './connection.js';
|
|
1
|
+
import type { MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
|
|
3
2
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
4
|
-
import type {
|
|
3
|
+
import type { Readiness } from './readiness.js';
|
|
4
|
+
import { type SearchResult } from './search.js';
|
|
5
5
|
export type ReachedDocument = {
|
|
6
6
|
readonly room: string;
|
|
7
7
|
readonly path: string;
|
|
@@ -19,13 +19,18 @@ export type RuntimeView = {
|
|
|
19
19
|
};
|
|
20
20
|
export type NarrowedView = RuntimeView & {
|
|
21
21
|
narrow(reach: PortReach | null): void;
|
|
22
|
+
facts(port: ReadinessPort): void;
|
|
22
23
|
};
|
|
23
24
|
export type Reachable = RuntimeView & {
|
|
24
25
|
plan(input: unknown, reach: PortReach | null): Plan;
|
|
25
26
|
query(plan: Plan): Promise<QueryResult>;
|
|
26
27
|
watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
|
|
27
|
-
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
28
|
-
|
|
28
|
+
search(input: unknown, reach: PortReach | null, locked: readonly string[]): Promise<SearchResult>;
|
|
29
|
+
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
|
|
30
|
+
locked(room: string): boolean;
|
|
31
|
+
lockedRooms(): readonly string[];
|
|
32
|
+
watchLocks(notify: () => void): () => void;
|
|
33
|
+
located(room: string, path: string, destination: string): ReachedDocument | null;
|
|
29
34
|
};
|
|
30
35
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
31
36
|
export declare function governs(reach: PortReach | null, room: {
|
|
@@ -38,5 +43,5 @@ export declare function governs(reach: PortReach | null, room: {
|
|
|
38
43
|
readonly selection: boolean;
|
|
39
44
|
};
|
|
40
45
|
export declare function planReach(reach: PortReach | null): PlanReach | null;
|
|
41
|
-
export declare function narrowed(runtime: Reachable, given: PortReach | null): NarrowedView;
|
|
46
|
+
export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;
|
|
42
47
|
//# sourceMappingURL=reach.d.ts.map
|
package/dist/reach.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,aAAa,EAEb,YAAY,EAEb,MAAM,iBAAiB,CAAC;AAwBzB,OAAO,KAAK,EAAiB,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGlE,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;IAC/C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAEjD,MAAM,MAAM,KAAK,GAAG,CAClB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,OAAO,EAAE,OAAO,KACb,MAAM,IAAI,CAAC;AAEhB,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAE1D,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GA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AE;QAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,GAC/F;IAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAU/D;AAcD,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CASnE;AAgGD,wBAAgB,QAAQ,CACtB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,IAAI,EAAE,aAAa,GAClB,YAAY,CA8Rd"}
|
package/dist/reach.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { unheldView } from './conversation.js';
|
|
2
2
|
import { modelTypes, NO_MODEL } from './model.js';
|
|
3
|
-
import {
|
|
3
|
+
import { changeOf, digestApplied, digestOf, observing, } from './observation.js';
|
|
4
4
|
import { runtimeError } from './failure.js';
|
|
5
|
-
import { failure, undeclared, } from './outcome.js';
|
|
5
|
+
import { failure, lockedRoom, ROOM_LOCKED, undeclared, UNREADABLE, } from './outcome.js';
|
|
6
6
|
import { beneath } from './paths.js';
|
|
7
|
-
import { reconciled } from './read-side.js';
|
|
8
7
|
import { moveTarget, readParts, staleWrite, } from './room-draft.js';
|
|
9
8
|
import { documentKey } from './rows.js';
|
|
9
|
+
import { undeclaredSearch } from './search.js';
|
|
10
10
|
const UNHELD_TYPES = { collection: modelTypes(NO_MODEL), typedSelection: null };
|
|
11
11
|
function unconversed(name) {
|
|
12
12
|
return () => Promise.resolve(undeclared(name));
|
|
@@ -16,6 +16,7 @@ const NO_CONVERSATION = {
|
|
|
16
16
|
read: (conversation) => Promise.resolve(unheldView(conversation)),
|
|
17
17
|
create: unconversed('conversation.create'),
|
|
18
18
|
send: unconversed('conversation.send'),
|
|
19
|
+
attach: unconversed('conversation.attach'),
|
|
19
20
|
answer: unconversed('conversation.answer'),
|
|
20
21
|
interrupt: unconversed('conversation.interrupt'),
|
|
21
22
|
kill: unconversed('conversation.kill'),
|
|
@@ -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,20 +54,6 @@ function covers(reach, room, path) {
|
|
|
52
54
|
function conversing(reach) {
|
|
53
55
|
return reach === null || reach.conversations;
|
|
54
56
|
}
|
|
55
|
-
function refers(reach, scope) {
|
|
56
|
-
if (reach === null)
|
|
57
|
-
return true;
|
|
58
|
-
if (scope === null)
|
|
59
|
-
return false;
|
|
60
|
-
if (scope.kind === 'conversations')
|
|
61
|
-
return reach.conversations;
|
|
62
|
-
return scope.path === undefined
|
|
63
|
-
? wholly(reach, scope.locator)
|
|
64
|
-
: covers(reach, scope.locator, scope.path);
|
|
65
|
-
}
|
|
66
|
-
function unreachedReference(fileRef) {
|
|
67
|
-
return { kind: 'absent', code: 'binary-file-absent', fields: { fileRef }, retryable: false };
|
|
68
|
-
}
|
|
69
57
|
export function planReach(reach) {
|
|
70
58
|
return reach === null
|
|
71
59
|
? null
|
|
@@ -89,7 +77,7 @@ function typesWithin(reach, room, types) {
|
|
|
89
77
|
};
|
|
90
78
|
}
|
|
91
79
|
function moves(reach, room, move) {
|
|
92
|
-
return move === undefined || covers(reach, room, moveTarget(move));
|
|
80
|
+
return move === undefined || covers(reach, move.room ?? room, moveTarget(move));
|
|
93
81
|
}
|
|
94
82
|
function draftWithin(reach, draft) {
|
|
95
83
|
return covers(reach, draft.room, draft.path) && moves(reach, draft.room, draft.parts.move);
|
|
@@ -122,76 +110,120 @@ function savedWithin(reach, room, result) {
|
|
|
122
110
|
function statusWithin(reach, status) {
|
|
123
111
|
return {
|
|
124
112
|
...status,
|
|
125
|
-
attentionRequired: status.attentionRequired.filter((entry) => covers(reach, entry.room, entry.path)),
|
|
113
|
+
attentionRequired: status.attentionRequired.filter((entry) => 'refusal' in entry ? wholly(reach, entry.room) : covers(reach, entry.room, entry.path)),
|
|
126
114
|
};
|
|
127
115
|
}
|
|
128
116
|
function queueWithin(reach, room, entries) {
|
|
129
|
-
return entries
|
|
130
|
-
(
|
|
117
|
+
return entries
|
|
118
|
+
.filter(({ batch }) => batch.changes.every((change) => covers(reach, room, change.path) &&
|
|
119
|
+
(change.kind !== 'move' || covers(reach, room, change.to))))
|
|
120
|
+
.map((entry) => {
|
|
121
|
+
const { between, ...batch } = entry.batch;
|
|
122
|
+
if (between === undefined)
|
|
123
|
+
return entry;
|
|
124
|
+
return wholly(reach, between.source.room) && wholly(reach, between.destination.room)
|
|
125
|
+
? entry
|
|
126
|
+
: { ...entry, batch };
|
|
127
|
+
});
|
|
131
128
|
}
|
|
132
129
|
function unreached(room) {
|
|
133
130
|
return runtimeError('room-not-held', `No Local Replica for ${room}`);
|
|
134
131
|
}
|
|
135
|
-
|
|
132
|
+
function lockedError(room) {
|
|
133
|
+
return runtimeError(ROOM_LOCKED, `${room} is locked until House confirms its access`, true);
|
|
134
|
+
}
|
|
135
|
+
function deviceUnreached() {
|
|
136
|
+
return runtimeError('device-unreached', 'Only the panel cleans up this device');
|
|
137
|
+
}
|
|
138
|
+
export function narrowed(runtime, given, told) {
|
|
136
139
|
const { md, watch } = runtime;
|
|
137
140
|
let reach = given;
|
|
141
|
+
let port = told;
|
|
138
142
|
const open = new Set();
|
|
139
|
-
function following(begin) {
|
|
143
|
+
function following(begin, locking = false) {
|
|
140
144
|
let stop = begin();
|
|
141
145
|
const restart = () => {
|
|
142
146
|
stop();
|
|
143
147
|
stop = begin();
|
|
144
148
|
};
|
|
145
149
|
open.add(restart);
|
|
150
|
+
const unwatch = locking ? runtime.watchLocks(restart) : () => { };
|
|
146
151
|
return () => {
|
|
147
152
|
open.delete(restart);
|
|
153
|
+
unwatch();
|
|
148
154
|
stop();
|
|
149
155
|
};
|
|
150
156
|
}
|
|
157
|
+
const unlocking = (rooms) => {
|
|
158
|
+
const locked = (rooms ?? []).filter((room) => runtime.locked(room));
|
|
159
|
+
return locked.length === 0
|
|
160
|
+
? null
|
|
161
|
+
: { pending: locked.map((room) => ({ room, awaits: 'unlock' })) };
|
|
162
|
+
};
|
|
163
|
+
const unlocked = (entries) => entries.filter((entry) => !runtime.locked(entry.room));
|
|
164
|
+
const intoLocked = (held) => held.some((move) => move?.room !== undefined && runtime.locked(move.room));
|
|
151
165
|
const within = (topic, input, deliver) => {
|
|
152
166
|
if (topic === 'rooms') {
|
|
153
167
|
return following(() => watch(topic, input, (rooms) => deliver(roomsWithin(reach, rooms))));
|
|
154
168
|
}
|
|
169
|
+
if (topic === 'readiness') {
|
|
170
|
+
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
171
|
+
}
|
|
155
172
|
if (topic === 'sync-status') {
|
|
156
|
-
return following(() => watch(topic, input, (status) =>
|
|
173
|
+
return following(() => watch(topic, input, (status) => {
|
|
174
|
+
const within = statusWithin(reach, status);
|
|
175
|
+
deliver({ ...within, attentionRequired: unlocked(within.attentionRequired) });
|
|
176
|
+
}), true);
|
|
157
177
|
}
|
|
158
178
|
if (topic === 'room-drafts') {
|
|
159
|
-
return following(() => watch(topic, input, (drafts) => deliver(draftsWithin(reach, drafts))));
|
|
179
|
+
return following(() => watch(topic, input, (drafts) => deliver(unlocked(draftsWithin(reach, drafts)))), true);
|
|
160
180
|
}
|
|
161
181
|
if (topic === 'queue') {
|
|
162
182
|
const room = input[0];
|
|
163
183
|
return following(() => {
|
|
164
|
-
if (!holds(reach, room)) {
|
|
184
|
+
if (!holds(reach, room) || runtime.locked(room)) {
|
|
165
185
|
deliver([]);
|
|
166
186
|
return () => { };
|
|
167
187
|
}
|
|
168
188
|
return watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)));
|
|
169
|
-
});
|
|
189
|
+
}, true);
|
|
170
190
|
}
|
|
171
191
|
if (topic === 'query') {
|
|
172
192
|
const plan = runtime.plan(input[0], reach);
|
|
173
193
|
let held = null;
|
|
174
194
|
return following(() => {
|
|
195
|
+
const locked = unlocking(plan.rooms);
|
|
196
|
+
if (locked !== null) {
|
|
197
|
+
const answer = { result: locked, keys: [] };
|
|
198
|
+
if (held === null || changeOf(held, answer) !== null)
|
|
199
|
+
deliver(answer);
|
|
200
|
+
held = digestOf(answer);
|
|
201
|
+
return () => { };
|
|
202
|
+
}
|
|
175
203
|
let first = true;
|
|
176
|
-
|
|
204
|
+
let open = true;
|
|
205
|
+
const heard = (message) => {
|
|
177
206
|
if (!first) {
|
|
178
|
-
held =
|
|
207
|
+
held = digestApplied(held, message);
|
|
179
208
|
deliver(message);
|
|
180
209
|
return;
|
|
181
210
|
}
|
|
182
211
|
first = false;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
deliver(next.change);
|
|
212
|
+
const change = held === null ? message : changeOf(held, message);
|
|
213
|
+
held = digestOf(message);
|
|
214
|
+
if (change !== null)
|
|
215
|
+
deliver(change);
|
|
216
|
+
};
|
|
217
|
+
const current = { ...plan, reach: planReach(reach), locked: runtime.lockedRooms() };
|
|
218
|
+
const stop = runtime.watchPlan(current, (message) => {
|
|
219
|
+
if (open)
|
|
220
|
+
heard(message);
|
|
193
221
|
});
|
|
194
|
-
|
|
222
|
+
return () => {
|
|
223
|
+
open = false;
|
|
224
|
+
stop();
|
|
225
|
+
};
|
|
226
|
+
}, true);
|
|
195
227
|
}
|
|
196
228
|
if (topic === 'conversation') {
|
|
197
229
|
return following(() => {
|
|
@@ -211,14 +243,32 @@ export function narrowed(runtime, given) {
|
|
|
211
243
|
}
|
|
212
244
|
return watch(topic, input, deliver);
|
|
213
245
|
};
|
|
246
|
+
const files = new Map();
|
|
247
|
+
let handed = 0;
|
|
248
|
+
const hand = async (reading) => {
|
|
249
|
+
const answer = await reading;
|
|
250
|
+
if (answer.kind !== 'binary')
|
|
251
|
+
return answer;
|
|
252
|
+
handed += 1;
|
|
253
|
+
const file = String(handed);
|
|
254
|
+
files.set(file, answer.file);
|
|
255
|
+
return { ...answer, file };
|
|
256
|
+
};
|
|
214
257
|
const conversation = () => (conversing(reach) ? md.conversation : NO_CONVERSATION);
|
|
215
258
|
const chatDraft = () => (conversing(reach) ? md.chatDraft : NO_CHAT_DRAFT);
|
|
216
259
|
const view = {
|
|
217
260
|
...md,
|
|
218
261
|
rooms: () => roomsWithin(reach, md.rooms()),
|
|
219
|
-
query: ((input) =>
|
|
220
|
-
|
|
262
|
+
query: ((input) => {
|
|
263
|
+
const plan = runtime.plan(input, reach);
|
|
264
|
+
return Promise.resolve(unlocking(plan.rooms) ?? runtime.query({ ...plan, locked: runtime.lockedRooms() }));
|
|
265
|
+
}),
|
|
266
|
+
search: (input) => port.search === 'required'
|
|
267
|
+
? runtime.search(input, reach, runtime.lockedRooms())
|
|
268
|
+
: Promise.resolve(undeclaredSearch()),
|
|
221
269
|
types(room) {
|
|
270
|
+
if (holds(reach, room) && runtime.locked(room))
|
|
271
|
+
throw lockedError(room);
|
|
222
272
|
if (wholly(reach, room))
|
|
223
273
|
return md.types(room);
|
|
224
274
|
if (!holds(reach, room))
|
|
@@ -229,39 +279,98 @@ export function narrowed(runtime, given) {
|
|
|
229
279
|
async save(room, roomDrafts, writtenBy) {
|
|
230
280
|
if (!holds(reach, room))
|
|
231
281
|
throw unreached(room);
|
|
232
|
-
|
|
233
|
-
|
|
282
|
+
if (runtime.locked(room))
|
|
283
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
284
|
+
const held = (await Promise.all(roomDrafts.map(({ path }) => md.roomDraft.read(room, path)))).map((draft) => draft?.parts.move);
|
|
285
|
+
const outside = roomDrafts.find(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]));
|
|
234
286
|
if (outside !== undefined) {
|
|
235
287
|
return { outcome: 'refused', code: 'stale', retryable: false, file: outside.path };
|
|
236
288
|
}
|
|
289
|
+
if (intoLocked(held))
|
|
290
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
237
291
|
return savedWithin(reach, room, await md.save(room, roomDrafts, writtenBy));
|
|
238
292
|
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
293
|
+
async saveParts(room, parts, writtenBy) {
|
|
294
|
+
if (!holds(reach, room))
|
|
295
|
+
throw unreached(room);
|
|
296
|
+
if (runtime.locked(room))
|
|
297
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
298
|
+
const held = parts.map(({ parts: one }) => readParts(one).move);
|
|
299
|
+
if (parts.some(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]))) {
|
|
300
|
+
throw unreached(room);
|
|
301
|
+
}
|
|
302
|
+
if (intoLocked(held))
|
|
303
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
304
|
+
return savedWithin(reach, room, await md.saveParts(room, parts, writtenBy));
|
|
305
|
+
},
|
|
306
|
+
resolve(room, path, destination) {
|
|
307
|
+
const at = runtime.located(room, path, destination);
|
|
308
|
+
return at !== null && !covers(reach, at.room, at.path)
|
|
309
|
+
? Promise.resolve(UNREADABLE)
|
|
310
|
+
: md.resolve(room, path, destination);
|
|
311
|
+
},
|
|
312
|
+
history: (room, path, query) => !covers(reach, room, path)
|
|
313
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
314
|
+
: runtime.locked(room)
|
|
315
|
+
? Promise.resolve(lockedRoom(room))
|
|
316
|
+
: md.history(room, path, query),
|
|
242
317
|
binaryFile: {
|
|
243
|
-
read: (room, path, revision) => covers(reach, room, path)
|
|
244
|
-
?
|
|
245
|
-
:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
318
|
+
read: (room, path, revision) => !covers(reach, room, path)
|
|
319
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
320
|
+
: runtime.locked(room)
|
|
321
|
+
? Promise.resolve(lockedRoom(room))
|
|
322
|
+
: hand(md.binaryFile.read(room, path, revision)),
|
|
323
|
+
link: (room, path, revision) => !covers(reach, room, path)
|
|
324
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
325
|
+
: runtime.locked(room)
|
|
326
|
+
? Promise.resolve(lockedRoom(room))
|
|
327
|
+
: md.binaryFile.link(room, path, revision),
|
|
328
|
+
async part(file, part) {
|
|
329
|
+
const key = files.get(file);
|
|
330
|
+
if (key === undefined)
|
|
331
|
+
return null;
|
|
332
|
+
const bytes = await md.binaryFile.part(key, part);
|
|
333
|
+
if (bytes === null)
|
|
334
|
+
files.delete(file);
|
|
335
|
+
return bytes;
|
|
336
|
+
},
|
|
249
337
|
},
|
|
250
|
-
reached: (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
251
|
-
|
|
338
|
+
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
339
|
+
!runtime.locked(room) &&
|
|
340
|
+
(await md.reached(room, roomVersion, path)),
|
|
252
341
|
log: () => (reach === null ? md.log() : ''),
|
|
342
|
+
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
253
343
|
roomDraft: {
|
|
254
|
-
list: () => md.roomDraft.list().then((drafts) => draftsWithin(reach, drafts)),
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
344
|
+
list: () => md.roomDraft.list().then((drafts) => unlocked(draftsWithin(reach, drafts))),
|
|
345
|
+
async read(room, path) {
|
|
346
|
+
if (!covers(reach, room, path))
|
|
347
|
+
return null;
|
|
348
|
+
if (runtime.locked(room))
|
|
349
|
+
throw lockedError(room);
|
|
350
|
+
return shownDraft(reach, await md.roomDraft.read(room, path));
|
|
351
|
+
},
|
|
352
|
+
write(room, path, revision, parts, next) {
|
|
353
|
+
try {
|
|
354
|
+
const move = readParts(parts).move;
|
|
355
|
+
if (!covers(reach, room, path) || !moves(reach, room, move))
|
|
356
|
+
throw unreached(room);
|
|
357
|
+
if (runtime.locked(room))
|
|
358
|
+
throw lockedError(room);
|
|
359
|
+
if (intoLocked([move]))
|
|
360
|
+
throw lockedError(move.room);
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
return Promise.reject(error);
|
|
259
364
|
}
|
|
260
|
-
return
|
|
365
|
+
return md.roomDraft
|
|
366
|
+
.write(room, path, revision, parts, next)
|
|
367
|
+
.then((written) => writeWithin(reach, written));
|
|
261
368
|
},
|
|
262
369
|
async discard(room, path, revision) {
|
|
263
370
|
if (!covers(reach, room, path))
|
|
264
371
|
return staleWrite(null);
|
|
372
|
+
if (runtime.locked(room))
|
|
373
|
+
throw lockedError(room);
|
|
265
374
|
return writeWithin(reach, await md.roomDraft.discard(room, path, revision));
|
|
266
375
|
},
|
|
267
376
|
},
|
|
@@ -269,7 +378,12 @@ export function narrowed(runtime, given) {
|
|
|
269
378
|
list: () => conversation().list(),
|
|
270
379
|
read: (id, options) => conversation().read(id, options),
|
|
271
380
|
create: (input) => conversation().create(input),
|
|
272
|
-
send: (id) => conversation().send(id),
|
|
381
|
+
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
382
|
+
attach: (room, file) => !wholly(reach, room)
|
|
383
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
384
|
+
: runtime.locked(room)
|
|
385
|
+
? Promise.resolve(lockedRoom(room))
|
|
386
|
+
: conversation().attach(room, file),
|
|
273
387
|
answer: (id, answer) => conversation().answer(id, answer),
|
|
274
388
|
interrupt: (id) => conversation().interrupt(id),
|
|
275
389
|
kill: (id) => conversation().kill(id),
|
|
@@ -278,6 +392,7 @@ export function narrowed(runtime, given) {
|
|
|
278
392
|
},
|
|
279
393
|
chatDraft: {
|
|
280
394
|
write: (id, draft, revision) => chatDraft().write(id, draft, revision),
|
|
395
|
+
prepend: (id, draft) => chatDraft().prepend(id, draft),
|
|
281
396
|
discard: (id) => chatDraft().discard(id),
|
|
282
397
|
},
|
|
283
398
|
observe: observing(within),
|
|
@@ -290,5 +405,10 @@ export function narrowed(runtime, given) {
|
|
|
290
405
|
for (const restart of [...open])
|
|
291
406
|
restart();
|
|
292
407
|
},
|
|
408
|
+
facts(next) {
|
|
409
|
+
port = next;
|
|
410
|
+
for (const restart of [...open])
|
|
411
|
+
restart();
|
|
412
|
+
},
|
|
293
413
|
};
|
|
294
414
|
}
|
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,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,WAAW,EACX,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,KAAK,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;AAErC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAClB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAUnD,wBAAgB,UAAU,CAAC,MAAM,EAAE,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