@agentshouse/mdruntime 0.1.0-cdf82f77fae68 → 0.1.0-ce15a88ae8478
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 +293 -292
- package/README.md +9 -8
- package/dist/adapter.d.ts +91 -23
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +4 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +13 -3
- package/dist/attempt.d.ts.map +1 -1
- package/dist/attempt.js +14 -1
- package/dist/bootstrap.d.ts +16 -8
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +102 -47
- 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/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/house.d.ts +25 -0
- package/dist/chat/house.d.ts.map +1 -0
- package/dist/chat/house.js +38 -0
- package/dist/chat/input.d.ts +3 -1
- package/dist/chat/input.d.ts.map +1 -1
- package/dist/chat/input.js +11 -18
- 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 +9 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +53 -9
- package/dist/chat/markdown.d.ts +3 -1
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +85 -26
- package/dist/chat/message.d.ts +1 -0
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +75 -13
- package/dist/chat/messages.d.ts +15 -1
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +82 -23
- package/dist/chat/name.d.ts +1 -0
- package/dist/chat/name.d.ts.map +1 -1
- package/dist/chat/name.js +1 -1
- package/dist/chat/opened.d.ts +1 -0
- package/dist/chat/opened.d.ts.map +1 -1
- package/dist/chat/opened.js +2 -0
- package/dist/chat/overlay.d.ts +1 -0
- package/dist/chat/overlay.d.ts.map +1 -1
- package/dist/chat/overlay.js +11 -5
- package/dist/chat/parts.d.ts +1 -0
- package/dist/chat/parts.d.ts.map +1 -1
- package/dist/chat/parts.js +3 -2
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -0
- package/dist/chat/provider.d.ts +9 -2
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +146 -156
- 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 +5 -1
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +9 -7
- package/dist/chat/room-file.d.ts +8 -0
- package/dist/chat/room-file.d.ts.map +1 -0
- package/dist/chat/room-file.js +72 -0
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.d.ts.map +1 -1
- package/dist/chat/style.js +9 -4
- package/dist/chat.d.ts +3 -2
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/client.d.ts +22 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +48 -8
- package/dist/collection.d.ts +7 -6
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +31 -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 +41 -13
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +3120 -702
- package/dist/conversation.d.ts +28 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +513 -178
- 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 +8 -1
- package/dist/durability.d.ts.map +1 -1
- 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 +14 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +102 -13
- 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 +9 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +55 -12
- 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 +10 -1
- 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 +39 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +29 -0
- package/dist/overlay.d.ts +3 -4
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +99 -181
- 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 -4
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +182 -51
- 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 +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 +198 -0
- package/dist/refresh.d.ts +12 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +74 -44
- package/dist/replica.d.ts +55 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +295 -149
- package/dist/room-draft.d.ts +16 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +32 -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 +108 -75
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +345 -450
- package/dist/stored.d.ts +138 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +544 -0
- package/dist/tables.d.ts +332 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +570 -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 +168 -32
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +56 -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 +20 -10
- 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,8 @@
|
|
|
1
1
|
import type { ReferrerScope } from './adapter.js';
|
|
2
|
-
import type { MdRuntime, RuntimeTopic } from './connection.js';
|
|
2
|
+
import type { MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
|
|
3
3
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Readiness } from './readiness.js';
|
|
5
|
+
import { type SearchResult } from './search.js';
|
|
5
6
|
export type ReachedDocument = {
|
|
6
7
|
readonly room: string;
|
|
7
8
|
readonly path: string;
|
|
@@ -19,13 +20,19 @@ export type RuntimeView = {
|
|
|
19
20
|
};
|
|
20
21
|
export type NarrowedView = RuntimeView & {
|
|
21
22
|
narrow(reach: PortReach | null): void;
|
|
23
|
+
facts(port: ReadinessPort): void;
|
|
22
24
|
};
|
|
23
25
|
export type Reachable = RuntimeView & {
|
|
24
26
|
plan(input: unknown, reach: PortReach | null): Plan;
|
|
25
27
|
query(plan: Plan): Promise<QueryResult>;
|
|
26
28
|
watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
|
|
27
|
-
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
29
|
+
search(input: unknown, reach: PortReach | null, locked: readonly string[]): Promise<SearchResult>;
|
|
30
|
+
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
|
|
28
31
|
referrerScope(referrer: unknown): ReferrerScope | null;
|
|
32
|
+
locked(room: string): boolean;
|
|
33
|
+
lockedRooms(): readonly string[];
|
|
34
|
+
watchLocks(notify: () => void): () => void;
|
|
35
|
+
located(room: string, path: string, destination: string): ReachedDocument | null;
|
|
29
36
|
};
|
|
30
37
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
31
38
|
export declare function governs(reach: PortReach | null, room: {
|
|
@@ -38,5 +45,5 @@ export declare function governs(reach: PortReach | null, room: {
|
|
|
38
45
|
readonly selection: boolean;
|
|
39
46
|
};
|
|
40
47
|
export declare function planReach(reach: PortReach | null): PlanReach | null;
|
|
41
|
-
export declare function narrowed(runtime: Reachable, given: PortReach | null): NarrowedView;
|
|
48
|
+
export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;
|
|
42
49
|
//# 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,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"reach.d.ts","sourceRoot":"","sources":["../src/reach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAEV,SAAS,EACT,aAAa,EAEb,YAAY,EAEb,MAAM,iBAAiB,CAAC;AAyBzB,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,W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AO,CACrB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,IAAI,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE;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;AAsBD,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,CAgSd"}
|
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 { absentReference, 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) {
|
|
@@ -57,15 +59,10 @@ function refers(reach, scope) {
|
|
|
57
59
|
return true;
|
|
58
60
|
if (scope === null)
|
|
59
61
|
return false;
|
|
60
|
-
if (scope.kind === 'conversations')
|
|
61
|
-
return reach.conversations;
|
|
62
62
|
return scope.path === undefined
|
|
63
63
|
? wholly(reach, scope.locator)
|
|
64
64
|
: covers(reach, scope.locator, scope.path);
|
|
65
65
|
}
|
|
66
|
-
function unreachedReference(fileRef) {
|
|
67
|
-
return { kind: 'absent', code: 'binary-file-absent', fields: { fileRef }, retryable: false };
|
|
68
|
-
}
|
|
69
66
|
export function planReach(reach) {
|
|
70
67
|
return reach === null
|
|
71
68
|
? null
|
|
@@ -89,7 +86,7 @@ function typesWithin(reach, room, types) {
|
|
|
89
86
|
};
|
|
90
87
|
}
|
|
91
88
|
function moves(reach, room, move) {
|
|
92
|
-
return move === undefined || covers(reach, room, moveTarget(move));
|
|
89
|
+
return move === undefined || covers(reach, move.room ?? room, moveTarget(move));
|
|
93
90
|
}
|
|
94
91
|
function draftWithin(reach, draft) {
|
|
95
92
|
return covers(reach, draft.room, draft.path) && moves(reach, draft.room, draft.parts.move);
|
|
@@ -122,76 +119,120 @@ function savedWithin(reach, room, result) {
|
|
|
122
119
|
function statusWithin(reach, status) {
|
|
123
120
|
return {
|
|
124
121
|
...status,
|
|
125
|
-
attentionRequired: status.attentionRequired.filter((entry) => covers(reach, entry.room, entry.path)),
|
|
122
|
+
attentionRequired: status.attentionRequired.filter((entry) => 'refusal' in entry ? wholly(reach, entry.room) : covers(reach, entry.room, entry.path)),
|
|
126
123
|
};
|
|
127
124
|
}
|
|
128
125
|
function queueWithin(reach, room, entries) {
|
|
129
|
-
return entries
|
|
130
|
-
(
|
|
126
|
+
return entries
|
|
127
|
+
.filter(({ batch }) => batch.changes.every((change) => covers(reach, room, change.path) &&
|
|
128
|
+
(change.kind !== 'move' || covers(reach, room, change.to))))
|
|
129
|
+
.map((entry) => {
|
|
130
|
+
const { between, ...batch } = entry.batch;
|
|
131
|
+
if (between === undefined)
|
|
132
|
+
return entry;
|
|
133
|
+
return wholly(reach, between.source.room) && wholly(reach, between.destination.room)
|
|
134
|
+
? entry
|
|
135
|
+
: { ...entry, batch };
|
|
136
|
+
});
|
|
131
137
|
}
|
|
132
138
|
function unreached(room) {
|
|
133
139
|
return runtimeError('room-not-held', `No Local Replica for ${room}`);
|
|
134
140
|
}
|
|
135
|
-
|
|
141
|
+
function lockedError(room) {
|
|
142
|
+
return runtimeError(ROOM_LOCKED, `${room} is locked until House confirms its access`, true);
|
|
143
|
+
}
|
|
144
|
+
function deviceUnreached() {
|
|
145
|
+
return runtimeError('device-unreached', 'Only the panel cleans up this device');
|
|
146
|
+
}
|
|
147
|
+
export function narrowed(runtime, given, told) {
|
|
136
148
|
const { md, watch } = runtime;
|
|
137
149
|
let reach = given;
|
|
150
|
+
let port = told;
|
|
138
151
|
const open = new Set();
|
|
139
|
-
function following(begin) {
|
|
152
|
+
function following(begin, locking = false) {
|
|
140
153
|
let stop = begin();
|
|
141
154
|
const restart = () => {
|
|
142
155
|
stop();
|
|
143
156
|
stop = begin();
|
|
144
157
|
};
|
|
145
158
|
open.add(restart);
|
|
159
|
+
const unwatch = locking ? runtime.watchLocks(restart) : () => { };
|
|
146
160
|
return () => {
|
|
147
161
|
open.delete(restart);
|
|
162
|
+
unwatch();
|
|
148
163
|
stop();
|
|
149
164
|
};
|
|
150
165
|
}
|
|
166
|
+
const unlocking = (rooms) => {
|
|
167
|
+
const locked = (rooms ?? []).filter((room) => runtime.locked(room));
|
|
168
|
+
return locked.length === 0
|
|
169
|
+
? null
|
|
170
|
+
: { pending: locked.map((room) => ({ room, awaits: 'unlock' })) };
|
|
171
|
+
};
|
|
172
|
+
const unlocked = (entries) => entries.filter((entry) => !runtime.locked(entry.room));
|
|
173
|
+
const intoLocked = (held) => held.some((move) => move?.room !== undefined && runtime.locked(move.room));
|
|
151
174
|
const within = (topic, input, deliver) => {
|
|
152
175
|
if (topic === 'rooms') {
|
|
153
176
|
return following(() => watch(topic, input, (rooms) => deliver(roomsWithin(reach, rooms))));
|
|
154
177
|
}
|
|
178
|
+
if (topic === 'readiness') {
|
|
179
|
+
return following(() => runtime.watchReadiness(port, reach, deliver));
|
|
180
|
+
}
|
|
155
181
|
if (topic === 'sync-status') {
|
|
156
|
-
return following(() => watch(topic, input, (status) =>
|
|
182
|
+
return following(() => watch(topic, input, (status) => {
|
|
183
|
+
const within = statusWithin(reach, status);
|
|
184
|
+
deliver({ ...within, attentionRequired: unlocked(within.attentionRequired) });
|
|
185
|
+
}), true);
|
|
157
186
|
}
|
|
158
187
|
if (topic === 'room-drafts') {
|
|
159
|
-
return following(() => watch(topic, input, (drafts) => deliver(draftsWithin(reach, drafts))));
|
|
188
|
+
return following(() => watch(topic, input, (drafts) => deliver(unlocked(draftsWithin(reach, drafts)))), true);
|
|
160
189
|
}
|
|
161
190
|
if (topic === 'queue') {
|
|
162
191
|
const room = input[0];
|
|
163
192
|
return following(() => {
|
|
164
|
-
if (!holds(reach, room)) {
|
|
193
|
+
if (!holds(reach, room) || runtime.locked(room)) {
|
|
165
194
|
deliver([]);
|
|
166
195
|
return () => { };
|
|
167
196
|
}
|
|
168
197
|
return watch(topic, input, (entries) => deliver(queueWithin(reach, room, entries)));
|
|
169
|
-
});
|
|
198
|
+
}, true);
|
|
170
199
|
}
|
|
171
200
|
if (topic === 'query') {
|
|
172
201
|
const plan = runtime.plan(input[0], reach);
|
|
173
202
|
let held = null;
|
|
174
203
|
return following(() => {
|
|
204
|
+
const locked = unlocking(plan.rooms);
|
|
205
|
+
if (locked !== null) {
|
|
206
|
+
const answer = { result: locked, keys: [] };
|
|
207
|
+
if (held === null || changeOf(held, answer) !== null)
|
|
208
|
+
deliver(answer);
|
|
209
|
+
held = digestOf(answer);
|
|
210
|
+
return () => { };
|
|
211
|
+
}
|
|
175
212
|
let first = true;
|
|
176
|
-
|
|
213
|
+
let open = true;
|
|
214
|
+
const heard = (message) => {
|
|
177
215
|
if (!first) {
|
|
178
|
-
held =
|
|
216
|
+
held = digestApplied(held, message);
|
|
179
217
|
deliver(message);
|
|
180
218
|
return;
|
|
181
219
|
}
|
|
182
220
|
first = false;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
deliver(next.change);
|
|
221
|
+
const change = held === null ? message : changeOf(held, message);
|
|
222
|
+
held = digestOf(message);
|
|
223
|
+
if (change !== null)
|
|
224
|
+
deliver(change);
|
|
225
|
+
};
|
|
226
|
+
const current = { ...plan, reach: planReach(reach), locked: runtime.lockedRooms() };
|
|
227
|
+
const stop = runtime.watchPlan(current, (message) => {
|
|
228
|
+
if (open)
|
|
229
|
+
heard(message);
|
|
193
230
|
});
|
|
194
|
-
|
|
231
|
+
return () => {
|
|
232
|
+
open = false;
|
|
233
|
+
stop();
|
|
234
|
+
};
|
|
235
|
+
}, true);
|
|
195
236
|
}
|
|
196
237
|
if (topic === 'conversation') {
|
|
197
238
|
return following(() => {
|
|
@@ -211,14 +252,32 @@ export function narrowed(runtime, given) {
|
|
|
211
252
|
}
|
|
212
253
|
return watch(topic, input, deliver);
|
|
213
254
|
};
|
|
255
|
+
const files = new Map();
|
|
256
|
+
let handed = 0;
|
|
257
|
+
const hand = async (reading) => {
|
|
258
|
+
const answer = await reading;
|
|
259
|
+
if (answer.kind !== 'binary')
|
|
260
|
+
return answer;
|
|
261
|
+
handed += 1;
|
|
262
|
+
const file = String(handed);
|
|
263
|
+
files.set(file, answer.file);
|
|
264
|
+
return { ...answer, file };
|
|
265
|
+
};
|
|
214
266
|
const conversation = () => (conversing(reach) ? md.conversation : NO_CONVERSATION);
|
|
215
267
|
const chatDraft = () => (conversing(reach) ? md.chatDraft : NO_CHAT_DRAFT);
|
|
216
268
|
const view = {
|
|
217
269
|
...md,
|
|
218
270
|
rooms: () => roomsWithin(reach, md.rooms()),
|
|
219
|
-
query: ((input) =>
|
|
220
|
-
|
|
271
|
+
query: ((input) => {
|
|
272
|
+
const plan = runtime.plan(input, reach);
|
|
273
|
+
return Promise.resolve(unlocking(plan.rooms) ?? runtime.query({ ...plan, locked: runtime.lockedRooms() }));
|
|
274
|
+
}),
|
|
275
|
+
search: (input) => port.search === 'required'
|
|
276
|
+
? runtime.search(input, reach, runtime.lockedRooms())
|
|
277
|
+
: Promise.resolve(undeclaredSearch()),
|
|
221
278
|
types(room) {
|
|
279
|
+
if (holds(reach, room) && runtime.locked(room))
|
|
280
|
+
throw lockedError(room);
|
|
222
281
|
if (wholly(reach, room))
|
|
223
282
|
return md.types(room);
|
|
224
283
|
if (!holds(reach, room))
|
|
@@ -229,39 +288,100 @@ export function narrowed(runtime, given) {
|
|
|
229
288
|
async save(room, roomDrafts, writtenBy) {
|
|
230
289
|
if (!holds(reach, room))
|
|
231
290
|
throw unreached(room);
|
|
232
|
-
|
|
233
|
-
|
|
291
|
+
if (runtime.locked(room))
|
|
292
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
293
|
+
const held = (await Promise.all(roomDrafts.map(({ path }) => md.roomDraft.read(room, path)))).map((draft) => draft?.parts.move);
|
|
294
|
+
const outside = roomDrafts.find(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]));
|
|
234
295
|
if (outside !== undefined) {
|
|
235
296
|
return { outcome: 'refused', code: 'stale', retryable: false, file: outside.path };
|
|
236
297
|
}
|
|
298
|
+
if (intoLocked(held))
|
|
299
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
237
300
|
return savedWithin(reach, room, await md.save(room, roomDrafts, writtenBy));
|
|
238
301
|
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
302
|
+
async saveParts(room, parts, writtenBy) {
|
|
303
|
+
if (!holds(reach, room))
|
|
304
|
+
throw unreached(room);
|
|
305
|
+
if (runtime.locked(room))
|
|
306
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
307
|
+
const held = parts.map(({ parts: one }) => readParts(one).move);
|
|
308
|
+
if (parts.some(({ path }, at) => !covers(reach, room, path) || !moves(reach, room, held[at]))) {
|
|
309
|
+
throw unreached(room);
|
|
310
|
+
}
|
|
311
|
+
if (intoLocked(held))
|
|
312
|
+
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
313
|
+
return savedWithin(reach, room, await md.saveParts(room, parts, writtenBy));
|
|
314
|
+
},
|
|
315
|
+
resolve(room, path, destination) {
|
|
316
|
+
const at = runtime.located(room, path, destination);
|
|
317
|
+
return at !== null && !covers(reach, at.room, at.path)
|
|
318
|
+
? Promise.resolve(UNREADABLE)
|
|
319
|
+
: md.resolve(room, path, destination);
|
|
320
|
+
},
|
|
321
|
+
history: (room, path, query) => !covers(reach, room, path)
|
|
322
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
323
|
+
: runtime.locked(room)
|
|
324
|
+
? Promise.resolve(lockedRoom(room))
|
|
325
|
+
: md.history(room, path, query),
|
|
242
326
|
binaryFile: {
|
|
243
|
-
read: (room, path, revision) => covers(reach, room, path)
|
|
244
|
-
?
|
|
245
|
-
:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
327
|
+
read: (room, path, revision) => !covers(reach, room, path)
|
|
328
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
329
|
+
: runtime.locked(room)
|
|
330
|
+
? Promise.resolve(lockedRoom(room))
|
|
331
|
+
: hand(md.binaryFile.read(room, path, revision)),
|
|
332
|
+
link: (room, path, revision) => !covers(reach, room, path)
|
|
333
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
334
|
+
: runtime.locked(room)
|
|
335
|
+
? Promise.resolve(lockedRoom(room))
|
|
336
|
+
: md.binaryFile.link(room, path, revision),
|
|
337
|
+
readReference(reference) {
|
|
338
|
+
const scope = runtime.referrerScope(reference.referrer);
|
|
339
|
+
if (!refers(reach, scope))
|
|
340
|
+
return Promise.resolve(absentReference(reference.fileRef));
|
|
341
|
+
if (scope !== null && runtime.locked(scope.locator)) {
|
|
342
|
+
return Promise.resolve(lockedRoom(scope.locator));
|
|
343
|
+
}
|
|
344
|
+
return hand(md.binaryFile.readReference(reference));
|
|
345
|
+
},
|
|
346
|
+
async part(file, part) {
|
|
347
|
+
const key = files.get(file);
|
|
348
|
+
if (key === undefined)
|
|
349
|
+
return null;
|
|
350
|
+
const bytes = await md.binaryFile.part(key, part);
|
|
351
|
+
if (bytes === null)
|
|
352
|
+
files.delete(file);
|
|
353
|
+
return bytes;
|
|
354
|
+
},
|
|
249
355
|
},
|
|
250
|
-
reached: (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
251
|
-
|
|
356
|
+
reached: async (room, roomVersion, path) => (path === undefined ? wholly(reach, room) : covers(reach, room, path)) &&
|
|
357
|
+
!runtime.locked(room) &&
|
|
358
|
+
(await md.reached(room, roomVersion, path)),
|
|
252
359
|
log: () => (reach === null ? md.log() : ''),
|
|
360
|
+
cleanUp: () => (reach === null ? md.cleanUp() : Promise.reject(deviceUnreached())),
|
|
253
361
|
roomDraft: {
|
|
254
|
-
list: () => md.roomDraft.list().then((drafts) => draftsWithin(reach, drafts)),
|
|
255
|
-
|
|
362
|
+
list: () => md.roomDraft.list().then((drafts) => unlocked(draftsWithin(reach, drafts))),
|
|
363
|
+
async read(room, path) {
|
|
364
|
+
if (!covers(reach, room, path))
|
|
365
|
+
return null;
|
|
366
|
+
if (runtime.locked(room))
|
|
367
|
+
throw lockedError(room);
|
|
368
|
+
return shownDraft(reach, await md.roomDraft.read(room, path));
|
|
369
|
+
},
|
|
256
370
|
async write(room, path, revision, parts) {
|
|
257
|
-
|
|
371
|
+
const move = readParts(parts).move;
|
|
372
|
+
if (!covers(reach, room, path) || !moves(reach, room, move))
|
|
258
373
|
throw unreached(room);
|
|
259
|
-
|
|
374
|
+
if (runtime.locked(room))
|
|
375
|
+
throw lockedError(room);
|
|
376
|
+
if (intoLocked([move]))
|
|
377
|
+
throw lockedError(move.room);
|
|
260
378
|
return writeWithin(reach, await md.roomDraft.write(room, path, revision, parts));
|
|
261
379
|
},
|
|
262
380
|
async discard(room, path, revision) {
|
|
263
381
|
if (!covers(reach, room, path))
|
|
264
382
|
return staleWrite(null);
|
|
383
|
+
if (runtime.locked(room))
|
|
384
|
+
throw lockedError(room);
|
|
265
385
|
return writeWithin(reach, await md.roomDraft.discard(room, path, revision));
|
|
266
386
|
},
|
|
267
387
|
},
|
|
@@ -269,7 +389,12 @@ export function narrowed(runtime, given) {
|
|
|
269
389
|
list: () => conversation().list(),
|
|
270
390
|
read: (id, options) => conversation().read(id, options),
|
|
271
391
|
create: (input) => conversation().create(input),
|
|
272
|
-
send: (id) => conversation().send(id),
|
|
392
|
+
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
393
|
+
attach: (room, file) => !wholly(reach, room)
|
|
394
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
395
|
+
: runtime.locked(room)
|
|
396
|
+
? Promise.resolve(lockedRoom(room))
|
|
397
|
+
: conversation().attach(room, file),
|
|
273
398
|
answer: (id, answer) => conversation().answer(id, answer),
|
|
274
399
|
interrupt: (id) => conversation().interrupt(id),
|
|
275
400
|
kill: (id) => conversation().kill(id),
|
|
@@ -278,6 +403,7 @@ export function narrowed(runtime, given) {
|
|
|
278
403
|
},
|
|
279
404
|
chatDraft: {
|
|
280
405
|
write: (id, draft, revision) => chatDraft().write(id, draft, revision),
|
|
406
|
+
prepend: (id, draft) => chatDraft().prepend(id, draft),
|
|
281
407
|
discard: (id) => chatDraft().discard(id),
|
|
282
408
|
},
|
|
283
409
|
observe: observing(within),
|
|
@@ -290,5 +416,10 @@ export function narrowed(runtime, given) {
|
|
|
290
416
|
for (const restart of [...open])
|
|
291
417
|
restart();
|
|
292
418
|
},
|
|
419
|
+
facts(next) {
|
|
420
|
+
port = next;
|
|
421
|
+
for (const restart of [...open])
|
|
422
|
+
restart();
|
|
423
|
+
},
|
|
293
424
|
};
|
|
294
425
|
}
|
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;I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