@agentshouse/mdruntime 0.1.0-cf08ada271a7f → 0.1.0-cf08df9b663d8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -19
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +57 -38
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +173 -83
- package/dist/adapter.d.ts +210 -30
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -7
- package/dist/{binary.d.ts → attachment.d.ts} +8 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +2 -4
- package/dist/client.d.ts +29 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +49 -64
- package/dist/collection.d.ts +6 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -9
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +4 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +88 -44
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +32 -17
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +26 -11
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +24 -11
- package/dist/conversation-row.d.ts +23 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +37 -8
- package/dist/conversation.d.ts +45 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +337 -203
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +46 -48
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +26 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +126 -36
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -1
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/holdings.d.ts.map +1 -1
- package/dist/holdings.js +5 -3
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +94 -30
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +27 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -9
- package/dist/install.d.ts +10 -5
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +49 -55
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +74 -51
- package/dist/linked-file.d.ts +7 -0
- package/dist/linked-file.d.ts.map +1 -0
- package/dist/linked-file.js +13 -0
- package/dist/listing.d.ts +27 -20
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +68 -69
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +94 -36
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -38
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +8 -20
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +181 -34
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +99 -37
- package/dist/messages.d.ts +21 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +48 -16
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +10 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +18 -35
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +6 -6
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +4 -4
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +22 -10
- package/dist/outcome.d.ts +33 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +36 -6
- package/dist/overlay.d.ts +21 -7
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +112 -39
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +5 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -15
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +207 -96
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +137 -79
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- package/dist/queue.d.ts +2 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +76 -49
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +196 -37
- package/dist/react.d.ts +17 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +23 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +18 -10
- package/dist/reads.d.ts +5 -3
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +26 -14
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +31 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +262 -36
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +12 -7
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +47 -0
- package/dist/rows.d.ts +11 -3
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +25 -11
- package/dist/run-tables.d.ts +25 -0
- package/dist/run-tables.d.ts.map +1 -0
- package/dist/run-tables.js +98 -0
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +11 -5
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +120 -135
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +116 -65
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -4
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shown.d.ts +8 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +95 -67
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +9 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +17 -16
- package/dist/source.d.ts +42 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +76 -9
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +31 -7
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +70 -24
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +24 -14
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +49 -17
- package/dist/stored.d.ts +41 -16
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +215 -57
- package/dist/surface.d.ts +20 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +66 -32
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +109 -82
- package/dist/tables.d.ts +40 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +109 -326
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +3 -4
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +50 -10
- package/dist/wire.d.ts +68 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +28 -11
- package/package.json +4 -4
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
- package/dist/job.d.ts +0 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -41
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/declaration.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { equalValue } from '@agentshouse/mdmodel';
|
|
2
|
-
import {
|
|
2
|
+
import { documentAt, covered, normalize } from './paths.js';
|
|
3
3
|
export function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }) {
|
|
4
4
|
return declaration;
|
|
5
5
|
}
|
|
@@ -8,10 +8,10 @@ export function sameDeclaration(left, right) {
|
|
|
8
8
|
}
|
|
9
9
|
export function writeRule({ operations, providerOwnedPaths, authoredPaths, }, pathRule, local) {
|
|
10
10
|
return (path, needs) => {
|
|
11
|
-
const normalized = normalize(path);
|
|
11
|
+
const normalized = normalize(path.normalize('NFC'));
|
|
12
12
|
if (normalized === null || normalized === '')
|
|
13
13
|
return { code: 'room-root', path };
|
|
14
|
-
if (covered(providerOwnedPaths, normalized) || !
|
|
14
|
+
if (covered(providerOwnedPaths, normalized) || !documentAt(authoredPaths, normalized)) {
|
|
15
15
|
return { code: 'provider-owned-path', path: normalized };
|
|
16
16
|
}
|
|
17
17
|
if (!pathRule(normalized))
|
package/dist/discovery.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { CycleProgress } from './status.js';
|
|
|
5
5
|
import type { RuntimeStore } from './store.js';
|
|
6
6
|
export declare function malformed(listed: readonly DiscoveredRoom[]): string | null;
|
|
7
7
|
export declare function applyDiscovery(runtime: Runtime, found: readonly DiscoveredRoom[], started: number, left?: readonly string[]): Promise<readonly DiscoveredRoom[]>;
|
|
8
|
+
export declare const DISCOVERY = "discovery";
|
|
8
9
|
export declare function signIn(runtime: Runtime, local: RuntimeStore, signedIn: Member | null): Promise<void>;
|
|
9
|
-
export declare function
|
|
10
|
+
export declare function zoned(runtime: Runtime, local: RuntimeStore, zone: string | null): Promise<void>;
|
|
11
|
+
export declare function discoverRooms(runtime: Runtime, progress: CycleProgress, live: Live, found: Discovery | null): Promise<readonly DiscoveredRoom[] | null>;
|
|
10
12
|
//# sourceMappingURL=discovery.d.ts.map
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,IAAI,CAsB1E;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAgDpC;AAUD,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,iBAI1F;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,iBAIrF;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,OAAO,CAAC,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,CA2E3C"}
|
package/dist/discovery.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { validRoot } from './collection.js';
|
|
2
|
-
import {
|
|
3
|
-
import { admitted, list, listHeld } from './listing.js';
|
|
4
|
-
import { confirmLocks, lockedRooms, relocked } from './locks.js';
|
|
2
|
+
import { lockedRooms, relocked } from './locks.js';
|
|
5
3
|
import { loseRooms } from './lost.js';
|
|
6
4
|
import { cachedModels } from './models.js';
|
|
7
5
|
import { beneath } from './paths.js';
|
|
8
6
|
import { refuse } from './refusal.js';
|
|
9
|
-
import { emitMember, emitRefusal, emitRooms, moveTo, transferring } from './shown.js';
|
|
7
|
+
import { emitMember, emitRefusal, emitRooms, emitTimeZone, moveTo, transferring } from './shown.js';
|
|
10
8
|
function within(root, path) {
|
|
11
9
|
return root === '' || beneath(root, path);
|
|
12
10
|
}
|
|
@@ -38,61 +36,40 @@ export function malformed(listed) {
|
|
|
38
36
|
return null;
|
|
39
37
|
}
|
|
40
38
|
export async function applyDiscovery(runtime, found, started, left) {
|
|
41
|
-
const { store, socket } = runtime;
|
|
42
|
-
|
|
39
|
+
const { store, socket, presence } = runtime;
|
|
40
|
+
if (found.length === 0 && !store.needed()) {
|
|
41
|
+
const listed = presence.list([], { whole: left === undefined, live: socket.isOpen() });
|
|
42
|
+
socket.session.set({ roomsListed: true });
|
|
43
|
+
emitRooms(runtime);
|
|
44
|
+
return listed;
|
|
45
|
+
}
|
|
43
46
|
const lockedBefore = await lockedRooms(runtime);
|
|
44
47
|
const local = await store.open();
|
|
45
|
-
const
|
|
48
|
+
const fenced = new Set(await local.fences());
|
|
46
49
|
const relisting = found
|
|
47
50
|
.map(({ locator }) => locator)
|
|
48
|
-
.filter((locator) =>
|
|
49
|
-
|
|
50
|
-
return stillFenced.has(locator) && (fence === undefined || fence.at < started);
|
|
51
|
-
});
|
|
52
|
-
const relisted = relisting.length === 0
|
|
51
|
+
.filter((locator) => fenced.has(locator) && presence.liftable(locator, started));
|
|
52
|
+
const unfenced = relisting.length === 0
|
|
53
53
|
? new Set()
|
|
54
54
|
: await store.durably((held) => held.unfence(relisting));
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
continue;
|
|
59
|
-
if (relisted.has(locator) || (!stillFenced.has(locator) && !fence.written)) {
|
|
60
|
-
store.fences.lift(locator);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
55
|
+
const clear = found.filter(({ locator }) => !fenced.has(locator) || unfenced.has(locator));
|
|
56
|
+
for (const { locator } of clear)
|
|
57
|
+
presence.lift(locator, started, unfenced.has(locator));
|
|
63
58
|
const kept = await local.held();
|
|
64
59
|
await loseRooms(runtime, found
|
|
65
60
|
.filter((room) => room.replica.admission !== 'admitted' &&
|
|
66
61
|
(kept.held.has(room.locator) || store.installs.of(room.locator).transfer !== null))
|
|
67
62
|
.map((room) => room.locator));
|
|
68
|
-
const listed = found.filter(({ locator }) => !store.fences.has(locator) && (!stillFenced.has(locator) || relisted.has(locator)));
|
|
69
|
-
const listedLocatorsNow = new Set(listed.map((room) => room.locator));
|
|
70
|
-
for (const locator of listedLocatorsNow)
|
|
71
|
-
rooms.stand(locator, { refusal: null });
|
|
72
|
-
if (left === undefined)
|
|
73
|
-
rooms.undiscoverAll();
|
|
74
|
-
for (const room of listed)
|
|
75
|
-
rooms.discover(room);
|
|
76
63
|
const named = new Set(found.map((room) => room.locator));
|
|
77
64
|
await loseRooms(runtime, left ??
|
|
78
65
|
[
|
|
79
66
|
...new Set([
|
|
80
|
-
...rooms
|
|
67
|
+
...presence.rooms().map(({ locator }) => locator),
|
|
81
68
|
...kept.held,
|
|
82
69
|
...store.installs.transferring(),
|
|
83
70
|
]),
|
|
84
71
|
].filter((locator) => !named.has(locator)));
|
|
85
|
-
const
|
|
86
|
-
for (const room of listed) {
|
|
87
|
-
const record = held.get(room.locator)?.record;
|
|
88
|
-
if (record !== undefined && record.declaration.replica.selection !== room.replica.selection) {
|
|
89
|
-
listHeld(runtime, room.locator);
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
const declaration = declared(room);
|
|
93
|
-
list(runtime, room.locator, declaration, admitted(runtime, room.locator, declaration));
|
|
94
|
-
}
|
|
95
|
-
confirmLocks(runtime, listed);
|
|
72
|
+
const listed = presence.list(clear, { whole: left === undefined, live: socket.isOpen() });
|
|
96
73
|
socket.session.set({ roomsListed: true });
|
|
97
74
|
emitRooms(runtime);
|
|
98
75
|
await relocked(runtime, lockedBefore);
|
|
@@ -102,18 +79,25 @@ async function asked({ socket }, authorized) {
|
|
|
102
79
|
try {
|
|
103
80
|
return (await socket.discover(authorized)) ?? { kind: 'transport-uncertainty' };
|
|
104
81
|
}
|
|
105
|
-
catch {
|
|
106
|
-
return { kind: 'transport-uncertainty' };
|
|
82
|
+
catch (failure) {
|
|
83
|
+
return { kind: 'transport-uncertainty', failure };
|
|
107
84
|
}
|
|
108
85
|
}
|
|
86
|
+
export const DISCOVERY = 'discovery';
|
|
109
87
|
export async function signIn(runtime, local, signedIn) {
|
|
110
88
|
if (JSON.stringify(signedIn) === JSON.stringify((await local.facts()).member))
|
|
111
89
|
return;
|
|
112
90
|
await local.fact('member', signedIn);
|
|
113
91
|
emitMember(runtime, signedIn);
|
|
114
92
|
}
|
|
115
|
-
export async function
|
|
116
|
-
|
|
93
|
+
export async function zoned(runtime, local, zone) {
|
|
94
|
+
if (zone === (await local.facts()).timeZone)
|
|
95
|
+
return;
|
|
96
|
+
await local.fact('timeZone', zone);
|
|
97
|
+
emitTimeZone(runtime, zone);
|
|
98
|
+
}
|
|
99
|
+
export async function discoverRooms(runtime, progress, live, found) {
|
|
100
|
+
const { store, socket } = runtime;
|
|
117
101
|
const { session } = socket;
|
|
118
102
|
const { closed, authorization } = session.now();
|
|
119
103
|
if (closed || authorization === undefined) {
|
|
@@ -131,16 +115,19 @@ export async function discoverRooms(runtime, local, progress, live, found) {
|
|
|
131
115
|
socket.notifyReady();
|
|
132
116
|
return null;
|
|
133
117
|
}
|
|
134
|
-
|
|
118
|
+
if (result.kind === 'transport-uncertainty')
|
|
119
|
+
runtime.retries.uncertain('connection', DISCOVERY, result);
|
|
120
|
+
if (result.kind === 'discovery')
|
|
121
|
+
runtime.retries.succeeded('connection', DISCOVERY);
|
|
135
122
|
if (result.kind === 'transport-uncertainty') {
|
|
136
|
-
|
|
123
|
+
if (store.needed())
|
|
124
|
+
await cachedModels(runtime, await store.open());
|
|
137
125
|
progress.reachable = false;
|
|
138
126
|
progress.complete = false;
|
|
139
127
|
socket.notifyReady();
|
|
140
128
|
return null;
|
|
141
129
|
}
|
|
142
130
|
if (result.kind === 'contract-unavailable') {
|
|
143
|
-
journal.record(`connection contract unavailable ${result.code}`);
|
|
144
131
|
await refuse(runtime, 'missing-required-guarantee', {
|
|
145
132
|
code: result.code,
|
|
146
133
|
fields: result.fields,
|
|
@@ -156,7 +143,6 @@ export async function discoverRooms(runtime, local, progress, live, found) {
|
|
|
156
143
|
}
|
|
157
144
|
const invalid = malformed(result.rooms);
|
|
158
145
|
if (invalid !== null) {
|
|
159
|
-
journal.record(invalid);
|
|
160
146
|
await refuse(runtime, 'missing-required-guarantee');
|
|
161
147
|
socket.notifyReady();
|
|
162
148
|
return null;
|
|
@@ -165,13 +151,25 @@ export async function discoverRooms(runtime, local, progress, live, found) {
|
|
|
165
151
|
session.set({ refusal: null });
|
|
166
152
|
emitRefusal(runtime);
|
|
167
153
|
}
|
|
154
|
+
const queriesOnly = result.queriesOnly ?? [];
|
|
155
|
+
if (!store.needed() && result.rooms.length === 0) {
|
|
156
|
+
session.set({ queriesOnly, unstored: result });
|
|
157
|
+
socket.notifyReady();
|
|
158
|
+
return applyDiscovery(runtime, result.rooms, started);
|
|
159
|
+
}
|
|
160
|
+
const local = await store.open();
|
|
168
161
|
const held = await local.facts();
|
|
169
162
|
if (JSON.stringify(result.providerLimits) !== JSON.stringify(held.providerLimits) ||
|
|
170
163
|
JSON.stringify(result.capabilities) !== JSON.stringify(held.capabilities)) {
|
|
171
164
|
await local.fact('providerLimits', result.providerLimits);
|
|
172
165
|
await local.fact('capabilities', result.capabilities);
|
|
173
166
|
}
|
|
167
|
+
if (JSON.stringify(queriesOnly) !== JSON.stringify(held.queriesOnly)) {
|
|
168
|
+
await local.fact('queriesOnly', queriesOnly);
|
|
169
|
+
}
|
|
170
|
+
session.set({ queriesOnly, unstored: null });
|
|
174
171
|
socket.notifyReady();
|
|
175
172
|
await signIn(runtime, local, result.member ?? null);
|
|
173
|
+
await zoned(runtime, local, result.timeZone ?? null);
|
|
176
174
|
return applyDiscovery(runtime, result.rooms, started);
|
|
177
175
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './client.js';
|
|
2
|
+
import type { AttachmentLinkAnswer, DownloadAnswer } from './outcome.js';
|
|
3
|
+
export declare function handedCopy(copy: Blob, name: string): DownloadAnswer;
|
|
4
|
+
export declare function handedLink(path: string, link: () => Promise<AttachmentLinkAnswer>): Promise<DownloadAnswer>;
|
|
5
|
+
export declare function downloadAttachment(client: MdRuntimeClient, link: string): Promise<DownloadAnswer>;
|
|
6
|
+
//# sourceMappingURL=download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAuBzE,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAKnE;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAEjG"}
|
package/dist/download.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { linkedFile } from './linked-file.js';
|
|
2
|
+
// A browser reads a download's address only after the click that hands it returns, so a copy's address is released a minute later.
|
|
3
|
+
const HANDED_COPY_MS = 60_000;
|
|
4
|
+
const PAGE = /\.html?$/iu;
|
|
5
|
+
const STARTED = { kind: 'started' };
|
|
6
|
+
const BLOCKED = {
|
|
7
|
+
kind: 'blocked',
|
|
8
|
+
code: 'popup-blocked',
|
|
9
|
+
fields: {},
|
|
10
|
+
retryable: true,
|
|
11
|
+
};
|
|
12
|
+
function handed(url, name) {
|
|
13
|
+
const anchor = document.createElement('a');
|
|
14
|
+
anchor.href = url;
|
|
15
|
+
anchor.download = name;
|
|
16
|
+
anchor.click();
|
|
17
|
+
}
|
|
18
|
+
export function handedCopy(copy, name) {
|
|
19
|
+
const url = URL.createObjectURL(copy);
|
|
20
|
+
handed(url, name);
|
|
21
|
+
setTimeout(() => URL.revokeObjectURL(url), HANDED_COPY_MS);
|
|
22
|
+
return STARTED;
|
|
23
|
+
}
|
|
24
|
+
export async function handedLink(path, link) {
|
|
25
|
+
const tab = PAGE.test(path) ? globalThis.open('', '_blank') : null;
|
|
26
|
+
const linked = await link();
|
|
27
|
+
if (linked.kind === 'link' && PAGE.test(linked.name)) {
|
|
28
|
+
const away = tab ?? globalThis.open('', '_blank');
|
|
29
|
+
if (away === null)
|
|
30
|
+
return BLOCKED;
|
|
31
|
+
away.location.replace(linked.url);
|
|
32
|
+
return STARTED;
|
|
33
|
+
}
|
|
34
|
+
tab?.close();
|
|
35
|
+
if (linked.kind !== 'link')
|
|
36
|
+
return linked;
|
|
37
|
+
handed(linked.url, linked.name);
|
|
38
|
+
return STARTED;
|
|
39
|
+
}
|
|
40
|
+
export function downloadAttachment(client, link) {
|
|
41
|
+
return handedLink(linkedFile(link)?.path ?? link, () => client.conversation.attachment(link));
|
|
42
|
+
}
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
+
import type { RetriedFailure, Step } from './retried.js';
|
|
2
3
|
export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
|
|
3
4
|
export type UnsentWork = {
|
|
4
5
|
readonly kind: UnsentKind;
|
|
5
6
|
readonly count: number;
|
|
6
7
|
};
|
|
8
|
+
export declare function leftToSend(unsent: readonly UnsentWork[]): boolean;
|
|
7
9
|
export type AppCode = {
|
|
8
10
|
readonly running: number;
|
|
9
11
|
readonly older: number;
|
|
@@ -18,10 +20,13 @@ export type RuntimeShell = {
|
|
|
18
20
|
keepGeneration(value: string): void | Promise<void>;
|
|
19
21
|
dropGeneration(): void | Promise<void>;
|
|
20
22
|
cleanUp?(): Promise<number>;
|
|
21
|
-
measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
|
|
23
|
+
measure?(measured: (app: string | null, code: AppCode | null) => void): Promise<HeldCode>;
|
|
22
24
|
reset(): Promise<void>;
|
|
25
|
+
retried?(failure: RetriedFailure): void;
|
|
26
|
+
succeeded?(step: Step): void;
|
|
23
27
|
};
|
|
24
28
|
export declare function refusedForSpace(error: unknown): boolean;
|
|
25
29
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
30
|
+
export declare function lossStated(persistence: Persistence, loss: string | null): string | null;
|
|
26
31
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
27
32
|
//# sourceMappingURL=durability.d.ts.map
|
package/dist/durability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzD,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;AAEjF,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAEjE;AAED,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3F,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,cAAc,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1F,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IACxC,SAAS,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAG/F;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAEvF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGrF"}
|
package/dist/durability.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
const STORAGE_LOSS_CODE = 'storage-loss';
|
|
2
|
+
const VISIT_LOSS_CODE = 'visit';
|
|
3
|
+
export function leftToSend(unsent) {
|
|
4
|
+
return unsent.some(({ kind }) => kind === 'pending-change' || kind === 'call');
|
|
5
|
+
}
|
|
2
6
|
export function refusedForSpace(error) {
|
|
3
7
|
return (typeof error === 'object' &&
|
|
4
8
|
error !== null &&
|
|
@@ -9,6 +13,9 @@ export function detectStorageLoss(stored, reported) {
|
|
|
9
13
|
return null;
|
|
10
14
|
return STORAGE_LOSS_CODE;
|
|
11
15
|
}
|
|
16
|
+
export function lossStated(persistence, loss) {
|
|
17
|
+
return persistence === 'memory' ? VISIT_LOSS_CODE : loss;
|
|
18
|
+
}
|
|
12
19
|
export function nextGeneration(stored, reported) {
|
|
13
20
|
if (stored !== null && (reported === null || reported === stored))
|
|
14
21
|
return stored;
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,20 +1,45 @@
|
|
|
1
1
|
import { type VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Attachment, HeadChange } from './adapter.js';
|
|
3
|
+
import type { ChangeBatch } from './change.js';
|
|
4
|
+
import { type Written } from './overlay.js';
|
|
2
5
|
import { type QueryRows } from './query.js';
|
|
6
|
+
import { type ValuedEntry } from './stored.js';
|
|
3
7
|
import type { Connection } from './tables.js';
|
|
4
8
|
export { QueryError } from '@agentshouse/mdmodel';
|
|
9
|
+
export { documentKey, pathOfKey } from './rows.js';
|
|
10
|
+
export type { ValuedEntry } from './stored.js';
|
|
11
|
+
export type EntryArea = {
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly open: readonly string[];
|
|
14
|
+
};
|
|
5
15
|
export type EntryRoom = {
|
|
6
16
|
locator: string;
|
|
17
|
+
handle?: string;
|
|
18
|
+
readable?: readonly string[];
|
|
19
|
+
areas?: readonly EntryArea[];
|
|
7
20
|
schema: string | null;
|
|
8
21
|
documents: Readonly<Record<string, string>>;
|
|
9
22
|
revisions?: Readonly<Record<string, string>>;
|
|
23
|
+
fileIds?: Readonly<Record<string, string>>;
|
|
24
|
+
created?: Readonly<Record<string, string>>;
|
|
25
|
+
changes?: Readonly<Record<string, HeadChange>>;
|
|
26
|
+
attachments?: Readonly<Record<string, Attachment>>;
|
|
10
27
|
};
|
|
11
28
|
export type EntryArguments = Readonly<Record<string, string>>;
|
|
12
29
|
export type EntryParameterKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
13
30
|
export declare function boundQuery(template: unknown, args: EntryArguments): unknown;
|
|
14
31
|
export declare function entryParameters(template: unknown): readonly string[];
|
|
32
|
+
export declare function localQueryRefusal(template: unknown): string | null;
|
|
15
33
|
export declare function entryRefusal(template: unknown): string | null;
|
|
16
34
|
export type EntryScope = {
|
|
17
35
|
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
|
|
18
36
|
};
|
|
19
|
-
export
|
|
37
|
+
export type CountedRoom = {
|
|
38
|
+
locator: string;
|
|
39
|
+
schema: string | null;
|
|
40
|
+
documents: readonly ValuedEntry[];
|
|
41
|
+
};
|
|
42
|
+
export declare function writtenIn(room: EntryRoom, roomTypes: VerifiedModel, batch: ChangeBatch): Written;
|
|
43
|
+
export declare function entryScope(rooms: readonly EntryRoom[], roomTypes: VerifiedModel, connection: Connection, followed?: readonly EntryRoom[]): EntryScope;
|
|
44
|
+
export declare function countScope(room: CountedRoom, roomTypes: VerifiedModel, connection: Connection): EntryScope;
|
|
20
45
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"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"}
|
package/dist/entry.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { invalid, plain, QueryError, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { attachedModel } from './attached-model.js';
|
|
3
|
+
import { writtenDocuments } from './overlay.js';
|
|
3
4
|
import { answerQuery } from './compile.js';
|
|
4
5
|
import { planWithin } from './query.js';
|
|
5
|
-
import { writtenFacts } from './rows.js';
|
|
6
|
-
import { entered, REPLICA_TABLES } from './stored.js';
|
|
6
|
+
import { documentKey, writtenFacts } from './rows.js';
|
|
7
|
+
import { entered, enteredValues, REPLICA_TABLES, } from './stored.js';
|
|
7
8
|
export { QueryError } from '@agentshouse/mdmodel';
|
|
9
|
+
export { documentKey, pathOfKey } from './rows.js';
|
|
8
10
|
const PARAMETER = '$param';
|
|
9
11
|
const KIND = 'as';
|
|
10
12
|
const INTEGER = /^-?(?:0|[1-9][0-9]*)$/u;
|
|
@@ -70,6 +72,12 @@ export function entryParameters(template) {
|
|
|
70
72
|
return [];
|
|
71
73
|
}
|
|
72
74
|
const SAMPLED = {
|
|
75
|
+
rooms: 'entry',
|
|
76
|
+
folder: 'entry',
|
|
77
|
+
outside: 'entry',
|
|
78
|
+
paths: 'entry',
|
|
79
|
+
fileIds: 'entry',
|
|
80
|
+
text: 'entry',
|
|
73
81
|
direction: 'asc',
|
|
74
82
|
nulls: 'last',
|
|
75
83
|
stringSort: 'lexical',
|
|
@@ -100,15 +108,16 @@ function sampled(template, key) {
|
|
|
100
108
|
}
|
|
101
109
|
return template;
|
|
102
110
|
}
|
|
103
|
-
function entryPlan(query, facts) {
|
|
104
|
-
const plan = planWithin(query, facts);
|
|
111
|
+
function entryPlan(query, facts, reach = null) {
|
|
112
|
+
const plan = planWithin(query, facts, reach);
|
|
105
113
|
if (plan.fileIds !== null)
|
|
106
114
|
invalid('fileIds', 'an entry Room holds no file IDs');
|
|
107
115
|
return plan;
|
|
108
116
|
}
|
|
109
|
-
|
|
117
|
+
const UNHELD = { listed: false, rooms: [] };
|
|
118
|
+
function refusalOf(plan) {
|
|
110
119
|
try {
|
|
111
|
-
|
|
120
|
+
plan();
|
|
112
121
|
return null;
|
|
113
122
|
}
|
|
114
123
|
catch (error) {
|
|
@@ -117,45 +126,126 @@ export function entryRefusal(template) {
|
|
|
117
126
|
throw error;
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
|
-
export function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
export function localQueryRefusal(template) {
|
|
130
|
+
return refusalOf(() => planWithin(sampled(template, ''), UNHELD));
|
|
131
|
+
}
|
|
132
|
+
export function entryRefusal(template) {
|
|
133
|
+
return refusalOf(() => entryPlan(sampled(template, ''), UNHELD));
|
|
134
|
+
}
|
|
135
|
+
function composedRoom(room, roomTypes) {
|
|
136
|
+
const model = attachedModel({
|
|
137
|
+
kind: 'model',
|
|
138
|
+
snapshot: { identity: room.locator, version: '', schema: room.schema, revision: null },
|
|
139
|
+
}, roomTypes);
|
|
140
|
+
return { model, selection: null, typedPaths: [] };
|
|
141
|
+
}
|
|
142
|
+
export function writtenIn(room, roomTypes, batch) {
|
|
143
|
+
const written = writtenDocuments({
|
|
144
|
+
documents: room.documents,
|
|
145
|
+
binaries: {},
|
|
146
|
+
revisions: room.revisions ?? {},
|
|
147
|
+
fileIds: {},
|
|
148
|
+
created: {},
|
|
149
|
+
changes: {},
|
|
150
|
+
}, batch, composedRoom(room, roomTypes));
|
|
151
|
+
for (;;) {
|
|
152
|
+
const step = written.next();
|
|
153
|
+
if (step.done === true)
|
|
154
|
+
return step.value;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function enteredRoom(room, roomTypes, connection) {
|
|
158
|
+
const composition = composedRoom(room, roomTypes);
|
|
159
|
+
const { model } = composition;
|
|
160
|
+
const key = room.enter(composition);
|
|
161
|
+
if (room.handle !== undefined)
|
|
162
|
+
connection.run("INSERT INTO replica_rooms (locator, key, record) VALUES (?, ?, json_object('declaration', json_object('handle', ?)))", [room.locator, key, room.handle]);
|
|
163
|
+
return {
|
|
164
|
+
locator: room.locator,
|
|
165
|
+
key,
|
|
166
|
+
composition,
|
|
167
|
+
...(room.handle === undefined ? {} : { handle: room.handle }),
|
|
168
|
+
facts: {
|
|
130
169
|
locator: room.locator,
|
|
131
170
|
available: model.status !== 'unavailable',
|
|
132
171
|
types: model.status === 'unavailable' ? [] : Object.values(model.types),
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function reachOf(rooms, followed) {
|
|
176
|
+
if (followed.every(({ readable, areas }) => readable === undefined && areas === undefined))
|
|
177
|
+
return null;
|
|
178
|
+
return {
|
|
179
|
+
rooms: [...rooms, ...followed.filter(({ readable }) => readable === undefined)].map(({ locator }) => locator),
|
|
180
|
+
documents: followed.flatMap(({ locator, readable }) => (readable ?? []).map((path) => documentKey(locator, path))),
|
|
181
|
+
areas: followed.flatMap(({ locator, areas }) => (areas ?? []).map(({ path, open }) => ({ room: locator, path, open }))),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function scope(rooms, roomTypes, connection, followed = []) {
|
|
185
|
+
for (const table of REPLICA_TABLES)
|
|
186
|
+
connection.run(table);
|
|
187
|
+
const keys = rooms.map((room) => enteredRoom(room, roomTypes, connection));
|
|
188
|
+
const follows = [
|
|
189
|
+
...keys,
|
|
190
|
+
...followed.map((room) => enteredRoom(room, roomTypes, connection)),
|
|
191
|
+
].filter(({ handle }) => handle !== undefined);
|
|
192
|
+
const planned = { listed: true, rooms: keys.map(({ facts }) => facts) };
|
|
193
|
+
const reach = reachOf(rooms, followed);
|
|
151
194
|
return {
|
|
152
195
|
async results(queries) {
|
|
153
196
|
const results = {};
|
|
154
197
|
for (const [name, query] of Object.entries(queries)) {
|
|
155
|
-
const plan = entryPlan(query, planned);
|
|
156
|
-
results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)));
|
|
198
|
+
const plan = entryPlan(query, planned, reach);
|
|
199
|
+
results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)), null, follows);
|
|
157
200
|
}
|
|
158
201
|
return results;
|
|
159
202
|
},
|
|
160
203
|
};
|
|
161
204
|
}
|
|
205
|
+
function scopedRoom(room, connection) {
|
|
206
|
+
return {
|
|
207
|
+
locator: room.locator,
|
|
208
|
+
...(room.handle === undefined ? {} : { handle: room.handle }),
|
|
209
|
+
...(room.readable === undefined ? {} : { readable: room.readable }),
|
|
210
|
+
...(room.areas === undefined ? {} : { areas: room.areas }),
|
|
211
|
+
schema: room.schema,
|
|
212
|
+
enter(composition) {
|
|
213
|
+
const heads = (path) => ({
|
|
214
|
+
revision: room.revisions?.[path] ?? null,
|
|
215
|
+
fileId: room.fileIds?.[path] ?? null,
|
|
216
|
+
created: room.created?.[path] ?? null,
|
|
217
|
+
change: room.changes?.[path] ?? null,
|
|
218
|
+
written: null,
|
|
219
|
+
});
|
|
220
|
+
const entries = [
|
|
221
|
+
...Object.entries(room.documents).map(([path, content]) => ({
|
|
222
|
+
path,
|
|
223
|
+
content,
|
|
224
|
+
facts: writtenFacts(path, content, composition),
|
|
225
|
+
binary: null,
|
|
226
|
+
...heads(path),
|
|
227
|
+
})),
|
|
228
|
+
...Object.entries(room.attachments ?? {}).map(([path, binary]) => ({
|
|
229
|
+
path,
|
|
230
|
+
content: null,
|
|
231
|
+
facts: null,
|
|
232
|
+
binary: { state: 'accepted', ...binary },
|
|
233
|
+
...heads(path),
|
|
234
|
+
})),
|
|
235
|
+
];
|
|
236
|
+
return entered(connection, room.locator, composition, entries.sort((left, right) => (left.path < right.path ? -1 : 1)));
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
export function entryScope(rooms, roomTypes, connection, followed = []) {
|
|
241
|
+
return scope(rooms.map((room) => scopedRoom(room, connection)), roomTypes, connection, followed.map((room) => scopedRoom(room, connection)));
|
|
242
|
+
}
|
|
243
|
+
export function countScope(room, roomTypes, connection) {
|
|
244
|
+
return scope([
|
|
245
|
+
{
|
|
246
|
+
locator: room.locator,
|
|
247
|
+
schema: room.schema,
|
|
248
|
+
enter: (composition) => enteredValues(connection, room.locator, composition, room.documents),
|
|
249
|
+
},
|
|
250
|
+
], roomTypes, connection);
|
|
251
|
+
}
|
package/dist/expectation.d.ts
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const heldType: unique symbol;
|
|
2
|
+
export type Descriptor<A, T> = {
|
|
3
|
+
place(asked: A): string;
|
|
4
|
+
readonly [heldType]?: T;
|
|
5
|
+
};
|
|
6
|
+
export type Expectation = {
|
|
5
7
|
readonly key: string;
|
|
6
|
-
|
|
8
|
+
readonly descriptor: object;
|
|
9
|
+
readonly places: ReadonlySet<string>;
|
|
10
|
+
draw(held: unknown): unknown;
|
|
11
|
+
shown(held: unknown): boolean;
|
|
12
|
+
};
|
|
13
|
+
export type Expected = Expectation | readonly Expectation[] | null;
|
|
14
|
+
export type Expecting = {
|
|
7
15
|
subscribe(listener: () => void): () => void;
|
|
8
16
|
version(): number;
|
|
9
17
|
begin(): number;
|
|
10
|
-
expect(act: number, expected:
|
|
18
|
+
expect(act: number, expected: Expected): void;
|
|
11
19
|
drop(act: number): void;
|
|
12
|
-
reads(reader: string,
|
|
13
|
-
heard(reader: string,
|
|
20
|
+
reads<A, T>(reader: string, descriptor: Descriptor<A, T>, places: readonly A[]): void;
|
|
21
|
+
heard<A, T>(reader: string, descriptor: Descriptor<A, T>, held: ReadonlyMap<A, T>): void;
|
|
14
22
|
left(reader: string): void;
|
|
15
|
-
|
|
23
|
+
draw<A, T>(descriptor: Descriptor<A, T>, place: A, held: T): T;
|
|
16
24
|
};
|
|
17
|
-
export declare function
|
|
18
|
-
readonly key: string;
|
|
19
|
-
}>(expected: ExpectedOf<E>): readonly E[];
|
|
20
|
-
export declare function expecting<E extends {
|
|
25
|
+
export declare function expectation<A, T>(descriptor: Descriptor<A, T>, made: {
|
|
21
26
|
readonly key: string;
|
|
22
|
-
|
|
27
|
+
readonly at: readonly A[];
|
|
28
|
+
draw(held: T): T;
|
|
29
|
+
shown(held: T): boolean;
|
|
30
|
+
}): Expectation;
|
|
31
|
+
export declare function expectedList(expected: Expected): readonly Expectation[];
|
|
32
|
+
export declare function expecting(): Expecting;
|
|
33
|
+
export {};
|
|
23
34
|
//# sourceMappingURL=expectation.d.ts.map
|