@agentshouse/mdruntime 0.1.0-c5fe3b2cddda7 → 0.1.0-c6197367d5fad
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 +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +299 -0
- 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 +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +302 -0
- package/dist/adapter.d.ts +156 -89
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -11
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +20 -60
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/bootstrap.d.ts +9 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +204 -85
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +5 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +3 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +11 -0
- package/dist/client.d.ts +33 -23
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +43 -56
- package/dist/collection.d.ts +26 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +19 -2
- 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 +8 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +286 -336
- package/dist/connection.d.ts +5 -142
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +111 -4993
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +150 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +40 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +66 -0
- package/dist/conversation.d.ts +72 -51
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +1001 -926
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +11 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +157 -0
- 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 +20 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -8
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +199 -0
- 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 +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +21 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +83 -41
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +37 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -5
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +282 -0
- package/dist/listing.d.ts +52 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +152 -0
- package/dist/live.d.ts +9 -6
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +118 -36
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +32 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +19 -2
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +105 -27
- package/dist/memory.d.ts +18 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +214 -91
- package/dist/messages.d.ts +35 -5
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +109 -39
- package/dist/model.d.ts +2 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -14
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/observation.d.ts +28 -13
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +185 -81
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +53 -0
- package/dist/outcome.d.ts +17 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +35 -2
- package/dist/overlay.d.ts +7 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +48 -24
- 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 +4 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +13 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +41 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +314 -0
- 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 +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +308 -0
- package/dist/query.d.ts +14 -210
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +30 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +116 -0
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +16 -15
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +257 -148
- package/dist/react.d.ts +19 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +9 -6
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +39 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +178 -0
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +38 -8
- package/dist/refresh.d.ts +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +31 -3
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +11 -16
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +66 -32
- 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 +34 -10
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +331 -111
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +220 -0
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +16 -22
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +49 -186
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +332 -228
- package/dist/saves.d.ts +34 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +437 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +35 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +313 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +67 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +164 -0
- package/dist/source.d.ts +59 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +93 -0
- package/dist/status.d.ts +0 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +40 -0
- package/dist/store/readiness.d.ts +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +224 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +466 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- 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/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +115 -143
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +171 -364
- package/dist/stored.d.ts +72 -35
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +337 -197
- package/dist/surface.d.ts +92 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +251 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +538 -0
- package/dist/tables.d.ts +118 -67
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +199 -278
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +128 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +9 -12
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +72 -9
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +26 -5
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -370
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DiscoveredRoom, OperationScopes, PathRule, RoomDeclaration } from './adapter.js';
|
|
2
|
+
export type WriteRefusal = {
|
|
3
|
+
readonly code: 'room-root' | 'provider-owned-path' | 'invalid-path' | `${keyof OperationScopes}-grant`;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
};
|
|
6
|
+
export type WriteRule = (path: string, needs: readonly (keyof OperationScopes)[]) => WriteRefusal | null;
|
|
7
|
+
export declare function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }: DiscoveredRoom): RoomDeclaration;
|
|
8
|
+
export declare function sameDeclaration(left: RoomDeclaration, right: RoomDeclaration): boolean;
|
|
9
|
+
export declare function writeRule({ operations, providerOwnedPaths, authoredPaths, }: Pick<RoomDeclaration, 'operations' | 'providerOwnedPaths' | 'authoredPaths'>, pathRule: PathRule, local: boolean): WriteRule;
|
|
10
|
+
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../src/declaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/F,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EACT,WAAW,GACX,qBAAqB,GACrB,cAAc,GACd,GAAG,MAAM,eAAe,QAAQ,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,CAAC,MAAM,eAAe,CAAC,EAAE,KACtC,YAAY,GAAG,IAAI,CAAC;AAEzB,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EAAE,QAAQ,EACjB,WAAW,EAAE,YAAY,EACzB,GAAG,WAAW,EACf,EAAE,cAAc,GAAG,eAAe,CAElC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAEtF;AAED,wBAAgB,SAAS,CACvB,EACE,UAAU,EACV,kBAAkB,EAClB,aAAa,GACd,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,oBAAoB,GAAG,eAAe,CAAC,EAC/E,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAYX"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { equalValue } from '@agentshouse/mdmodel';
|
|
2
|
+
import { authoredAt, covered, normalize } from './paths.js';
|
|
3
|
+
export function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }) {
|
|
4
|
+
return declaration;
|
|
5
|
+
}
|
|
6
|
+
export function sameDeclaration(left, right) {
|
|
7
|
+
return equalValue(left, right);
|
|
8
|
+
}
|
|
9
|
+
export function writeRule({ operations, providerOwnedPaths, authoredPaths, }, pathRule, local) {
|
|
10
|
+
return (path, needs) => {
|
|
11
|
+
const normalized = normalize(path);
|
|
12
|
+
if (normalized === null || normalized === '')
|
|
13
|
+
return { code: 'room-root', path };
|
|
14
|
+
if (covered(providerOwnedPaths, normalized) || !authoredAt(authoredPaths, normalized)) {
|
|
15
|
+
return { code: 'provider-owned-path', path: normalized };
|
|
16
|
+
}
|
|
17
|
+
if (!pathRule(normalized))
|
|
18
|
+
return { code: 'invalid-path', path: normalized };
|
|
19
|
+
if (local)
|
|
20
|
+
return null;
|
|
21
|
+
const missing = needs.find((operation) => !covered(operations[operation], normalized));
|
|
22
|
+
return missing === undefined ? null : { code: `${missing}-grant`, path: normalized };
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Discovery, DiscoveredRoom, Member } from './adapter.js';
|
|
2
|
+
import type { Runtime } from './runtime.js';
|
|
3
|
+
import type { Live } from './socket.js';
|
|
4
|
+
import type { CycleProgress } from './status.js';
|
|
5
|
+
import type { RuntimeStore } from './store.js';
|
|
6
|
+
export declare function malformed(listed: readonly DiscoveredRoom[]): string | null;
|
|
7
|
+
export declare function applyDiscovery(runtime: Runtime, found: readonly DiscoveredRoom[], started: number, left?: readonly string[]): Promise<readonly DiscoveredRoom[]>;
|
|
8
|
+
export declare function signIn(runtime: Runtime, local: RuntimeStore, signedIn: Member | null): Promise<void>;
|
|
9
|
+
export declare function zoned(runtime: Runtime, local: RuntimeStore, zone: string | null): Promise<void>;
|
|
10
|
+
export declare function discoverRooms(runtime: Runtime, local: RuntimeStore, progress: CycleProgress, live: Live, found: Discovery | null): Promise<readonly DiscoveredRoom[] | null>;
|
|
11
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +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;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,CA0CpC;AAYD,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,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,OAAO,CAAC,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,CAgE3C"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { validRoot } from './collection.js';
|
|
2
|
+
import { lockedRooms, relocked } from './locks.js';
|
|
3
|
+
import { loseRooms } from './lost.js';
|
|
4
|
+
import { cachedModels } from './models.js';
|
|
5
|
+
import { beneath } from './paths.js';
|
|
6
|
+
import { refuse } from './refusal.js';
|
|
7
|
+
import { emitMember, emitRefusal, emitRooms, emitTimeZone, moveTo, transferring } from './shown.js';
|
|
8
|
+
function within(root, path) {
|
|
9
|
+
return root === '' || beneath(root, path);
|
|
10
|
+
}
|
|
11
|
+
function declaredSelection(room) {
|
|
12
|
+
const selection = room.typedSelection;
|
|
13
|
+
if (selection === null)
|
|
14
|
+
return true;
|
|
15
|
+
if (!Array.isArray(selection.roots) || selection.roots.length === 0)
|
|
16
|
+
return false;
|
|
17
|
+
return selection.roots.every((root, index) => validRoot(root) &&
|
|
18
|
+
root !== '' &&
|
|
19
|
+
selection.roots.every((other, at) => at === index || !within(other, root)));
|
|
20
|
+
}
|
|
21
|
+
export function malformed(listed) {
|
|
22
|
+
for (const room of listed) {
|
|
23
|
+
if (room.operations === undefined ||
|
|
24
|
+
!['write', 'erase'].every((operation) => Array.isArray(room.operations[operation]) &&
|
|
25
|
+
room.operations[operation].every((scope) => typeof scope === 'string')) ||
|
|
26
|
+
room.replica === undefined ||
|
|
27
|
+
typeof room.replica.selection !== 'string' ||
|
|
28
|
+
room.replica.selection.length === 0 ||
|
|
29
|
+
!['admitted', 'unavailable'].includes(room.replica.admission) ||
|
|
30
|
+
!['locked', 'open'].includes(room.replica.offline)) {
|
|
31
|
+
return `invalid model or replica declaration ${room.locator}`;
|
|
32
|
+
}
|
|
33
|
+
if (!declaredSelection(room))
|
|
34
|
+
return `invalid typed selection declaration ${room.locator}`;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
export async function applyDiscovery(runtime, found, started, left) {
|
|
39
|
+
const { store, socket, presence } = runtime;
|
|
40
|
+
const lockedBefore = await lockedRooms(runtime);
|
|
41
|
+
const local = await store.open();
|
|
42
|
+
const fenced = new Set(await local.fences());
|
|
43
|
+
const relisting = found
|
|
44
|
+
.map(({ locator }) => locator)
|
|
45
|
+
.filter((locator) => fenced.has(locator) && presence.liftable(locator, started));
|
|
46
|
+
const unfenced = relisting.length === 0
|
|
47
|
+
? new Set()
|
|
48
|
+
: await store.durably((held) => held.unfence(relisting));
|
|
49
|
+
const clear = found.filter(({ locator }) => !fenced.has(locator) || unfenced.has(locator));
|
|
50
|
+
for (const { locator } of clear)
|
|
51
|
+
presence.lift(locator, started, unfenced.has(locator));
|
|
52
|
+
const kept = await local.held();
|
|
53
|
+
await loseRooms(runtime, found
|
|
54
|
+
.filter((room) => room.replica.admission !== 'admitted' &&
|
|
55
|
+
(kept.held.has(room.locator) || store.installs.of(room.locator).transfer !== null))
|
|
56
|
+
.map((room) => room.locator));
|
|
57
|
+
const named = new Set(found.map((room) => room.locator));
|
|
58
|
+
await loseRooms(runtime, left ??
|
|
59
|
+
[
|
|
60
|
+
...new Set([
|
|
61
|
+
...presence.rooms().map(({ locator }) => locator),
|
|
62
|
+
...kept.held,
|
|
63
|
+
...store.installs.transferring(),
|
|
64
|
+
]),
|
|
65
|
+
].filter((locator) => !named.has(locator)));
|
|
66
|
+
const listed = presence.list(clear, { whole: left === undefined, live: socket.isOpen() });
|
|
67
|
+
socket.session.set({ roomsListed: true });
|
|
68
|
+
emitRooms(runtime);
|
|
69
|
+
await relocked(runtime, lockedBefore);
|
|
70
|
+
return listed;
|
|
71
|
+
}
|
|
72
|
+
async function asked({ socket }, authorized) {
|
|
73
|
+
try {
|
|
74
|
+
return (await socket.discover(authorized)) ?? { kind: 'transport-uncertainty' };
|
|
75
|
+
}
|
|
76
|
+
catch (failure) {
|
|
77
|
+
return { kind: 'transport-uncertainty', failure };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const DISCOVERY = 'discovery';
|
|
81
|
+
export async function signIn(runtime, local, signedIn) {
|
|
82
|
+
if (JSON.stringify(signedIn) === JSON.stringify((await local.facts()).member))
|
|
83
|
+
return;
|
|
84
|
+
await local.fact('member', signedIn);
|
|
85
|
+
emitMember(runtime, signedIn);
|
|
86
|
+
}
|
|
87
|
+
export async function zoned(runtime, local, zone) {
|
|
88
|
+
if (zone === (await local.facts()).timeZone)
|
|
89
|
+
return;
|
|
90
|
+
await local.fact('timeZone', zone);
|
|
91
|
+
emitTimeZone(runtime, zone);
|
|
92
|
+
}
|
|
93
|
+
export async function discoverRooms(runtime, local, progress, live, found) {
|
|
94
|
+
const { socket } = runtime;
|
|
95
|
+
const { session } = socket;
|
|
96
|
+
const { closed, authorization } = session.now();
|
|
97
|
+
if (closed || authorization === undefined) {
|
|
98
|
+
socket.notifyReady();
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
moveTo(runtime, transferring(runtime));
|
|
102
|
+
const started = session.now().discoveries + 1;
|
|
103
|
+
session.set({ discoveries: started });
|
|
104
|
+
const result = found ?? (await asked(runtime, authorization));
|
|
105
|
+
if (result.kind === 'discovery')
|
|
106
|
+
session.set({ roomsNamed: true });
|
|
107
|
+
if (!live()) {
|
|
108
|
+
progress.complete = false;
|
|
109
|
+
socket.notifyReady();
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (result.kind === 'transport-uncertainty')
|
|
113
|
+
runtime.retries.uncertain('connection', DISCOVERY, result);
|
|
114
|
+
if (result.kind === 'discovery')
|
|
115
|
+
runtime.retries.succeeded('connection', DISCOVERY);
|
|
116
|
+
if (result.kind === 'transport-uncertainty') {
|
|
117
|
+
await cachedModels(runtime, local);
|
|
118
|
+
progress.reachable = false;
|
|
119
|
+
progress.complete = false;
|
|
120
|
+
socket.notifyReady();
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (result.kind === 'contract-unavailable') {
|
|
124
|
+
await refuse(runtime, 'missing-required-guarantee', {
|
|
125
|
+
code: result.code,
|
|
126
|
+
fields: result.fields,
|
|
127
|
+
retryable: result.retryable,
|
|
128
|
+
});
|
|
129
|
+
socket.notifyReady();
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
if (result.kind === 'revoked-authorization') {
|
|
133
|
+
await refuse(runtime, 'revoked-authorization');
|
|
134
|
+
socket.notifyReady();
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const invalid = malformed(result.rooms);
|
|
138
|
+
if (invalid !== null) {
|
|
139
|
+
await refuse(runtime, 'missing-required-guarantee');
|
|
140
|
+
socket.notifyReady();
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
if (session.now().refusal !== null) {
|
|
144
|
+
session.set({ refusal: null });
|
|
145
|
+
emitRefusal(runtime);
|
|
146
|
+
}
|
|
147
|
+
const held = await local.facts();
|
|
148
|
+
if (JSON.stringify(result.providerLimits) !== JSON.stringify(held.providerLimits) ||
|
|
149
|
+
JSON.stringify(result.capabilities) !== JSON.stringify(held.capabilities)) {
|
|
150
|
+
await local.fact('providerLimits', result.providerLimits);
|
|
151
|
+
await local.fact('capabilities', result.capabilities);
|
|
152
|
+
}
|
|
153
|
+
socket.notifyReady();
|
|
154
|
+
await signIn(runtime, local, result.member ?? null);
|
|
155
|
+
await zoned(runtime, local, result.timeZone ?? null);
|
|
156
|
+
return applyDiscovery(runtime, result.rooms, started);
|
|
157
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './client.js';
|
|
2
|
+
import type { BinaryLinkAnswer, DownloadAnswer } from './outcome.js';
|
|
3
|
+
export declare function handedCopy(copy: Blob, name: string): DownloadAnswer;
|
|
4
|
+
export declare function handedLink(path: string, link: () => Promise<BinaryLinkAnswer>): 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":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAuBrE,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,gBAAgB,CAAC,GACpC,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 { roomTarget } from '@agentshouse/mdmodel';
|
|
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(roomTarget(link)?.path ?? link, () => client.conversation.attachment(link));
|
|
42
|
+
}
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
+
import type { RetriedFailure, Step } from './retried.js';
|
|
3
|
+
export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
|
|
4
|
+
export type UnsentWork = {
|
|
5
|
+
readonly kind: UnsentKind;
|
|
6
|
+
readonly count: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function leftToSend(unsent: readonly UnsentWork[]): boolean;
|
|
9
|
+
export type AppCode = {
|
|
10
|
+
readonly running: number;
|
|
11
|
+
readonly older: number;
|
|
12
|
+
};
|
|
13
|
+
export type HeldCode = {
|
|
14
|
+
readonly house: number | null;
|
|
15
|
+
readonly apps: readonly string[];
|
|
16
|
+
};
|
|
2
17
|
export type RuntimeShell = {
|
|
3
18
|
persistence: Persistence;
|
|
4
19
|
generation: string | null;
|
|
5
20
|
keepGeneration(value: string): void | Promise<void>;
|
|
6
21
|
dropGeneration(): void | Promise<void>;
|
|
7
22
|
cleanUp?(): Promise<number>;
|
|
23
|
+
measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
|
|
24
|
+
reset(): Promise<void>;
|
|
25
|
+
retried?(failure: RetriedFailure): void;
|
|
26
|
+
succeeded?(step: Step): void;
|
|
8
27
|
};
|
|
9
28
|
export declare function refusedForSpace(error: unknown): boolean;
|
|
10
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;
|
|
11
31
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
12
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,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnF,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,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
2
|
import { type QueryRows } from './query.js';
|
|
3
3
|
import type { Connection } from './tables.js';
|
|
4
|
-
export { QueryError } from '
|
|
4
|
+
export { QueryError } from '@agentshouse/mdmodel';
|
|
5
5
|
export type EntryRoom = {
|
|
6
6
|
locator: string;
|
|
7
7
|
schema: string | null;
|
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,KAAK,
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AA0D7E,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAE3E;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAMpE;AAyCD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAQ7D;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;CACzF,CAAC;AAEF,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,GACrB,UAAU,CAoDZ"}
|
package/dist/entry.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { invalid, plain, QueryError, } from '@agentshouse/mdmodel';
|
|
1
2
|
import { attachedModel } from './attached-model.js';
|
|
2
3
|
import { answerQuery } from './compile.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { planWithin } from './query.js';
|
|
5
|
+
import { writtenFacts } from './rows.js';
|
|
5
6
|
import { entered, REPLICA_TABLES } from './stored.js';
|
|
6
|
-
export { QueryError } from '
|
|
7
|
+
export { QueryError } from '@agentshouse/mdmodel';
|
|
7
8
|
const PARAMETER = '$param';
|
|
8
9
|
const KIND = 'as';
|
|
9
10
|
const INTEGER = /^-?(?:0|[1-9][0-9]*)$/u;
|
|
@@ -83,6 +84,7 @@ const SAMPLED = {
|
|
|
83
84
|
$all: 'entry',
|
|
84
85
|
$size: 0,
|
|
85
86
|
$exists: true,
|
|
87
|
+
$prefix: 'entry',
|
|
86
88
|
$gt: 0,
|
|
87
89
|
$gte: 0,
|
|
88
90
|
$lt: 0,
|
|
@@ -98,9 +100,15 @@ function sampled(template, key) {
|
|
|
98
100
|
}
|
|
99
101
|
return template;
|
|
100
102
|
}
|
|
103
|
+
function entryPlan(query, facts) {
|
|
104
|
+
const plan = planWithin(query, facts);
|
|
105
|
+
if (plan.fileIds !== null)
|
|
106
|
+
invalid('fileIds', 'an entry Room holds no file IDs');
|
|
107
|
+
return plan;
|
|
108
|
+
}
|
|
101
109
|
export function entryRefusal(template) {
|
|
102
110
|
try {
|
|
103
|
-
|
|
111
|
+
entryPlan(sampled(template, ''), { listed: false, rooms: [] });
|
|
104
112
|
return null;
|
|
105
113
|
}
|
|
106
114
|
catch (error) {
|
|
@@ -117,32 +125,34 @@ export function entryScope(rooms, roomTypes, connection) {
|
|
|
117
125
|
const model = attachedModel({
|
|
118
126
|
kind: 'model',
|
|
119
127
|
snapshot: { identity: room.locator, version: '', schema: room.schema, revision: null },
|
|
120
|
-
},
|
|
128
|
+
}, roomTypes);
|
|
121
129
|
held.push({
|
|
122
130
|
locator: room.locator,
|
|
123
131
|
available: model.status !== 'unavailable',
|
|
124
132
|
types: model.status === 'unavailable' ? [] : Object.values(model.types),
|
|
125
133
|
});
|
|
126
|
-
const composition = { model, selection: null };
|
|
134
|
+
const composition = { model, selection: null, typedPaths: [] };
|
|
127
135
|
const key = entered(connection, room.locator, composition, Object.keys(room.documents)
|
|
128
136
|
.sort()
|
|
129
137
|
.map((path) => ({
|
|
130
138
|
path,
|
|
131
139
|
content: room.documents[path],
|
|
140
|
+
facts: writtenFacts(path, room.documents[path], composition),
|
|
132
141
|
binary: null,
|
|
133
142
|
revision: room.revisions?.[path] ?? null,
|
|
134
143
|
fileId: null,
|
|
144
|
+
created: null,
|
|
135
145
|
change: null,
|
|
136
146
|
written: null,
|
|
137
147
|
})));
|
|
138
|
-
return { locator: room.locator, key };
|
|
148
|
+
return { locator: room.locator, key, composition };
|
|
139
149
|
});
|
|
140
150
|
const planned = { listed: true, rooms: held };
|
|
141
151
|
return {
|
|
142
152
|
async results(queries) {
|
|
143
153
|
const results = {};
|
|
144
154
|
for (const [name, query] of Object.entries(queries)) {
|
|
145
|
-
const plan =
|
|
155
|
+
const plan = entryPlan(query, planned);
|
|
146
156
|
results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)));
|
|
147
157
|
}
|
|
148
158
|
return results;
|
package/dist/expectation.d.ts
CHANGED
|
@@ -1,21 +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
|
-
|
|
13
|
-
|
|
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;
|
|
22
|
+
left(reader: string): void;
|
|
23
|
+
draw<A, T>(descriptor: Descriptor<A, T>, place: A, held: T): T;
|
|
14
24
|
};
|
|
15
|
-
export declare function
|
|
16
|
-
readonly key: string;
|
|
17
|
-
}>(expected: ExpectedOf<E>): readonly E[];
|
|
18
|
-
export declare function expecting<E extends {
|
|
25
|
+
export declare function expectation<A, T>(descriptor: Descriptor<A, T>, made: {
|
|
19
26
|
readonly key: string;
|
|
20
|
-
|
|
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 {};
|
|
21
34
|
//# sourceMappingURL=expectation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expectation.d.ts","sourceRoot":"","sources":["../src/expectation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"expectation.d.ts","sourceRoot":"","sources":["../src/expectation.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,EAAE,OAAO,MAAM,CAAC;AAEtC,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI;IAC7B,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,SAAS,WAAW,EAAE,GAAG,IAAI,CAAC;AAEnE,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5C,OAAO,IAAI,MAAM,CAAC;IAClB,KAAK,IAAI,MAAM,CAAC;IAChB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9C,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;IACtF,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;IACzF,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;CAChE,CAAC;AAcF,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5B,IAAI,EAAE;IACJ,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,EAAE,CAAC;IAC1B,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;CACzB,GACA,WAAW,CAQb;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,WAAW,EAAE,CAGvE;AA+BD,wBAAgB,SAAS,IAAI,SAAS,CAqFrC"}
|
package/dist/expectation.js
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
|
+
const NOWHERE = new Set();
|
|
2
|
+
const NOTHING = new Map();
|
|
3
|
+
export function expectation(descriptor, made) {
|
|
4
|
+
return {
|
|
5
|
+
key: made.key,
|
|
6
|
+
descriptor,
|
|
7
|
+
places: new Set(made.at.map((one) => descriptor.place(one))),
|
|
8
|
+
draw: (value) => made.draw(value),
|
|
9
|
+
shown: (value) => made.shown(value),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
1
12
|
export function expectedList(expected) {
|
|
2
13
|
if (expected === null)
|
|
3
14
|
return [];
|
|
4
15
|
return 'key' in expected ? [expected] : expected;
|
|
5
16
|
}
|
|
17
|
+
function asks(reader, one) {
|
|
18
|
+
return (reader.descriptor === one.descriptor && [...one.places].some((at) => reader.places.has(at)));
|
|
19
|
+
}
|
|
20
|
+
function shows(reader, one) {
|
|
21
|
+
return (reader.descriptor === one.descriptor &&
|
|
22
|
+
[...reader.held].some(([at, value]) => one.places.has(at) && one.shown(value)));
|
|
23
|
+
}
|
|
6
24
|
function superseded(entries, at) {
|
|
7
|
-
const key = entries[at]?.
|
|
8
|
-
return entries.slice(at + 1).some((later) => later.
|
|
25
|
+
const key = entries[at]?.one.key;
|
|
26
|
+
return entries.slice(at + 1).some((later) => later.one.key === key);
|
|
9
27
|
}
|
|
10
28
|
function unended(entries, ends) {
|
|
11
29
|
const ended = new Set();
|
|
12
30
|
const kept = [];
|
|
13
|
-
for (const
|
|
14
|
-
if (ended.has(one.
|
|
31
|
+
for (const entry of [...entries].reverse()) {
|
|
32
|
+
if (ended.has(entry.one.key))
|
|
15
33
|
continue;
|
|
16
|
-
if (ends(
|
|
17
|
-
ended.add(one.
|
|
34
|
+
if (ends(entry))
|
|
35
|
+
ended.add(entry.one.key);
|
|
18
36
|
else
|
|
19
|
-
kept.unshift(
|
|
37
|
+
kept.unshift(entry);
|
|
20
38
|
}
|
|
21
39
|
return kept;
|
|
22
40
|
}
|
|
@@ -24,6 +42,7 @@ export function expecting() {
|
|
|
24
42
|
let entries = [];
|
|
25
43
|
let version = 0;
|
|
26
44
|
let acts = 0;
|
|
45
|
+
const readers = new Map();
|
|
27
46
|
const listeners = new Set();
|
|
28
47
|
const set = (next) => {
|
|
29
48
|
if (next.length === entries.length && next.every((one, at) => one === entries[at]))
|
|
@@ -33,6 +52,18 @@ export function expecting() {
|
|
|
33
52
|
for (const listener of listeners)
|
|
34
53
|
listener();
|
|
35
54
|
};
|
|
55
|
+
const settle = (next) => {
|
|
56
|
+
for (const entry of next)
|
|
57
|
+
for (const [id, reader] of readers)
|
|
58
|
+
if (asks(reader, entry.one) && shows(reader, entry.one))
|
|
59
|
+
entry.seen.add(id);
|
|
60
|
+
set(unended(next, (entry) => {
|
|
61
|
+
const asking = [...readers].filter(([, reader]) => asks(reader, entry.one));
|
|
62
|
+
const seen = asking.filter(([id]) => entry.seen.has(id));
|
|
63
|
+
return (seen.length > 0 &&
|
|
64
|
+
(seen.length === asking.length || seen.some(([, reader]) => !shows(reader, entry.one))));
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
36
67
|
return {
|
|
37
68
|
subscribe(listener) {
|
|
38
69
|
listeners.add(listener);
|
|
@@ -45,26 +76,48 @@ export function expecting() {
|
|
|
45
76
|
acts += 1;
|
|
46
77
|
return acts;
|
|
47
78
|
},
|
|
48
|
-
expect(act, expected
|
|
79
|
+
expect(act, expected) {
|
|
49
80
|
const fresh = expectedList(expected);
|
|
50
81
|
if (fresh.length === 0)
|
|
51
82
|
return;
|
|
52
83
|
const keys = new Set(fresh.map((one) => one.key));
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
...kept,
|
|
57
|
-
...fresh
|
|
58
|
-
.filter((one) => over.has(one.key) || !settled(one))
|
|
59
|
-
.map((expectation) => ({ act, expectation })),
|
|
84
|
+
settle([
|
|
85
|
+
...entries.filter((entry) => entry.act !== act || !keys.has(entry.one.key)),
|
|
86
|
+
...fresh.map((one) => ({ act, one, seen: new Set() })),
|
|
60
87
|
]);
|
|
61
88
|
},
|
|
62
89
|
drop(act) {
|
|
63
|
-
set(entries.filter((
|
|
90
|
+
set(entries.filter((entry) => entry.act !== act));
|
|
91
|
+
},
|
|
92
|
+
reads(reader, descriptor, places) {
|
|
93
|
+
readers.set(reader, {
|
|
94
|
+
descriptor,
|
|
95
|
+
places: new Set(places.map((one) => descriptor.place(one))),
|
|
96
|
+
held: readers.get(reader)?.held ?? NOTHING,
|
|
97
|
+
});
|
|
98
|
+
settle(entries);
|
|
99
|
+
},
|
|
100
|
+
heard(reader, descriptor, held) {
|
|
101
|
+
readers.set(reader, {
|
|
102
|
+
descriptor,
|
|
103
|
+
places: readers.get(reader)?.places ?? NOWHERE,
|
|
104
|
+
held: new Map([...held].map(([place, value]) => [descriptor.place(place), value])),
|
|
105
|
+
});
|
|
106
|
+
settle(entries);
|
|
107
|
+
},
|
|
108
|
+
left(reader) {
|
|
109
|
+
readers.delete(reader);
|
|
110
|
+
for (const entry of entries)
|
|
111
|
+
entry.seen.delete(reader);
|
|
112
|
+
settle(entries);
|
|
64
113
|
},
|
|
65
|
-
|
|
66
|
-
|
|
114
|
+
draw(descriptor, place, held) {
|
|
115
|
+
const at = descriptor.place(place);
|
|
116
|
+
return entries.reduce((now, entry, index) => entry.one.descriptor === descriptor &&
|
|
117
|
+
entry.one.places.has(at) &&
|
|
118
|
+
!superseded(entries, index)
|
|
119
|
+
? entry.one.draw(now)
|
|
120
|
+
: now, held);
|
|
67
121
|
},
|
|
68
|
-
drawn: () => entries.flatMap((one, at) => (superseded(entries, at) ? [] : [one.expectation])),
|
|
69
122
|
};
|
|
70
123
|
}
|
package/dist/failure.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
1
2
|
export type RuntimeError = Error & {
|
|
2
3
|
readonly code: string;
|
|
3
4
|
readonly retryable: boolean;
|
|
@@ -8,6 +9,8 @@ export type Described = {
|
|
|
8
9
|
retryable: boolean;
|
|
9
10
|
};
|
|
10
11
|
export declare function runtimeError(code: string, message?: string, retryable?: boolean): RuntimeError;
|
|
12
|
+
export declare function refusalError(refusal: ProviderRefusal): RuntimeError;
|
|
11
13
|
export declare function failed(error: unknown): RuntimeError;
|
|
14
|
+
export declare function uncaught(error: unknown): void;
|
|
12
15
|
export declare function described(error: unknown): Described;
|
|
13
16
|
//# sourceMappingURL=failure.d.ts.map
|
package/dist/failure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1F,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAa,EACtB,SAAS,UAAQ,GAChB,YAAY,CAEd;AAYD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAGnD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAGnD"}
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1F,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAa,EACtB,SAAS,UAAQ,GAChB,YAAY,CAEd;AAYD,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,YAAY,CAEnE;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAGnD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE7C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAGnD"}
|