@agentshouse/mdruntime 0.1.0-ce978a4a44895 → 0.1.0-cea5b657b3dba
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 +1 -1
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +31 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +45 -17
- package/dist/adapter.d.ts +123 -24
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- 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/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +2 -2
- package/dist/chat-types.js +2 -2
- package/dist/client.d.ts +16 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -15
- package/dist/collection.d.ts +1 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -1
- package/dist/compile.d.ts +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +71 -39
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +11 -5
- package/dist/conversation-live.d.ts +3 -3
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +4 -3
- package/dist/conversation-row.d.ts +16 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +17 -1
- package/dist/conversation.d.ts +15 -8
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +69 -51
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -5
- package/dist/download.d.ts +2 -2
- package/dist/download.d.ts.map +1 -1
- package/dist/download.js +2 -2
- package/dist/entry.d.ts +23 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +126 -47
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/host.d.ts +5 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +50 -22
- package/dist/house-query.d.ts +14 -11
- package/dist/house-query.d.ts.map +1 -1
- package/dist/house-query.js +69 -8
- 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 +16 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +24 -19
- 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/live.d.ts +14 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +29 -12
- package/dist/loaded.d.ts +5 -3
- package/dist/loaded.d.ts.map +1 -1
- package/dist/loaded.js +12 -6
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -0
- package/dist/media.d.ts +5 -6
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +94 -25
- package/dist/memory.d.ts +2 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +16 -13
- package/dist/messages.d.ts +10 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +19 -3
- package/dist/model.d.ts +6 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +20 -2
- package/dist/outcome.d.ts +21 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +5 -5
- package/dist/overlay.d.ts +19 -8
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +108 -37
- package/dist/parts.d.ts +1 -0
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +1 -1
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +10 -5
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +78 -48
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +59 -14
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +2 -1
- package/dist/queue.d.ts +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +4 -2
- package/dist/reach.d.ts +5 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +55 -15
- package/dist/react.d.ts +6 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +17 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -7
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +15 -4
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +3 -3
- package/dist/room-draft.d.ts +1 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +9 -6
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +8 -6
- package/dist/room-list.d.ts.map +1 -1
- package/dist/room-list.js +2 -0
- package/dist/rows.d.ts +9 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +19 -5
- 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/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +6 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +21 -17
- package/dist/saves.d.ts +5 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +74 -47
- 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 +1 -1
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +28 -14
- package/dist/socket/session.d.ts +3 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +2 -0
- package/dist/socket.d.ts +3 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +7 -0
- package/dist/source.d.ts +37 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +63 -7
- package/dist/store/records.d.ts +13 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +10 -4
- package/dist/store.d.ts +3 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +4 -1
- package/dist/stored.d.ts +17 -3
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +138 -31
- package/dist/surface.d.ts +11 -5
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +9 -6
- package/dist/sync.d.ts +2 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +26 -18
- package/dist/tables.d.ts +26 -2
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +24 -3
- package/dist/tallies.js +2 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +49 -3
- package/dist/wire.d.ts +7 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +7 -6
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type
|
|
1
|
+
import type { HeldAttachment } from './overlay.js';
|
|
2
|
+
export type AttachmentRecord = {
|
|
3
3
|
readonly state: 'accepted';
|
|
4
4
|
readonly revision: string;
|
|
5
5
|
readonly path: string;
|
|
6
6
|
readonly byteLength: number;
|
|
7
7
|
readonly mediaType: string;
|
|
8
8
|
readonly sha256: string;
|
|
9
|
+
readonly width: number | null;
|
|
10
|
+
readonly height: number | null;
|
|
9
11
|
} | {
|
|
10
12
|
readonly state: 'pending';
|
|
11
13
|
readonly localId: string;
|
|
@@ -13,6 +15,8 @@ export type BinaryFileRecord = {
|
|
|
13
15
|
readonly byteLength: number;
|
|
14
16
|
readonly mediaType: string;
|
|
15
17
|
readonly sha256: string;
|
|
18
|
+
readonly width: null;
|
|
19
|
+
readonly height: null;
|
|
16
20
|
};
|
|
17
|
-
export declare function
|
|
18
|
-
//# sourceMappingURL=
|
|
21
|
+
export declare function attachmentRecord(path: string, held: HeldAttachment, revision: string | undefined): AttachmentRecord;
|
|
22
|
+
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,MAAM,gBAAgB,GACxB;IACE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,GACD;IACE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;CACvB,CAAC;AAEN,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B,gBAAgB,CAalB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function attachmentRecord(path, held, revision) {
|
|
2
|
+
const facts = { byteLength: held.byteLength, mediaType: held.mediaType, sha256: held.sha256 };
|
|
3
|
+
if (held.state === 'pending')
|
|
4
|
+
return { state: 'pending', localId: held.localId, path, ...facts, width: null, height: null };
|
|
5
|
+
if (revision === undefined)
|
|
6
|
+
throw new Error(`the accepted attachment ${path} has no revision`);
|
|
7
|
+
return {
|
|
8
|
+
state: 'accepted',
|
|
9
|
+
revision,
|
|
10
|
+
path,
|
|
11
|
+
...facts,
|
|
12
|
+
width: held.width ?? null,
|
|
13
|
+
height: held.height ?? null,
|
|
14
|
+
};
|
|
15
|
+
}
|
package/dist/chain.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export type WindowChain = {
|
|
|
7
7
|
want(count: number): void;
|
|
8
8
|
close(): void;
|
|
9
9
|
};
|
|
10
|
-
export declare function chainedWindows(runtime: MdRuntimeClient, query: DocumentQuery | GroupQuery, count: number, publish: (answers: readonly (WindowAnswer | null)[], settled: boolean) => void): WindowChain;
|
|
10
|
+
export declare function chainedWindows(runtime: MdRuntimeClient, query: DocumentQuery | GroupQuery, count: number, publish: (answers: readonly (WindowAnswer | null)[], settled: boolean) => void, refused?: (error: Error) => void): WindowChain;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=chain.d.ts.map
|
package/dist/chain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E,KAAK,IAAI,GAAG,cAAc,GAAG,WAAW,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,aAAa,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAaF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,GAAG,UAAU,EACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E,KAAK,IAAI,GAAG,cAAc,GAAG,WAAW,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,aAAa,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAaF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,GAAG,UAAU,EACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,EAC9E,OAAO,GAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAe,GACzC,WAAW,CAoEb"}
|
package/dist/chain.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function answered(answer) {
|
|
2
2
|
return answer !== null && !('pending' in answer);
|
|
3
3
|
}
|
|
4
|
-
export function chainedWindows(runtime, query, count, publish) {
|
|
4
|
+
export function chainedWindows(runtime, query, count, publish, refused = () => { }) {
|
|
5
5
|
let links = [];
|
|
6
6
|
let wanted = count;
|
|
7
7
|
let closed = false;
|
|
@@ -21,7 +21,10 @@ export function chainedWindows(runtime, query, count, publish) {
|
|
|
21
21
|
};
|
|
22
22
|
observation.subscribe(take);
|
|
23
23
|
take(observation.current());
|
|
24
|
-
}, () => {
|
|
24
|
+
}, (error) => {
|
|
25
|
+
if (!closed && links.includes(link))
|
|
26
|
+
refused(error);
|
|
27
|
+
});
|
|
25
28
|
return link;
|
|
26
29
|
};
|
|
27
30
|
const settle = () => {
|
package/dist/change.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Attachment, HeadChange } from './adapter.js';
|
|
2
2
|
export type Change = {
|
|
3
3
|
readonly kind: 'field';
|
|
4
4
|
readonly path: string;
|
|
@@ -43,7 +43,7 @@ export type Change = {
|
|
|
43
43
|
} | (Arriving & {
|
|
44
44
|
readonly content: string;
|
|
45
45
|
}) | (Arriving & {
|
|
46
|
-
readonly binary:
|
|
46
|
+
readonly binary: Attachment;
|
|
47
47
|
});
|
|
48
48
|
type Arriving = {
|
|
49
49
|
readonly kind: 'arrival';
|
package/dist/chat-types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const KEPT_LINE = /^\[([^\]\n]+)\]\(\1\)$/u;
|
|
2
|
-
const
|
|
2
|
+
const UNKEPT_LINE = /^\[(?:too big to keep|not kept, [^:\n]+): [^\n]*\]$/u;
|
|
3
3
|
export function keptFile(line) {
|
|
4
4
|
return KEPT_LINE.exec(line)?.[1] ?? null;
|
|
5
5
|
}
|
|
@@ -7,5 +7,5 @@ export function keptLines(body) {
|
|
|
7
7
|
const trimmed = body.replace(/\n+$/u, '');
|
|
8
8
|
const at = trimmed.lastIndexOf('\n\n');
|
|
9
9
|
const lines = (at === -1 ? trimmed : trimmed.slice(at + 2)).split('\n');
|
|
10
|
-
return lines.every((line) => keptFile(line) !== null ||
|
|
10
|
+
return lines.every((line) => keptFile(line) !== null || UNKEPT_LINE.test(line)) ? lines : [];
|
|
11
11
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -8,27 +8,29 @@ import type { ListedAgent, Member, RoomList, ServiceMode } from './adapter.js';
|
|
|
8
8
|
import type { UnsentWork } from './durability.js';
|
|
9
9
|
import type { ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationSurface, ConversationView } from './conversation.js';
|
|
10
10
|
import { type Observation } from './observation.js';
|
|
11
|
-
import { type AttachAnswer, type
|
|
11
|
+
import { type AttachAnswer, type AttachmentAnswer, type CallResult, type DownloadAnswer, type HistoryAnswer, type QueueEntry, type Resolution, type ShownAnswer } from './outcome.js';
|
|
12
12
|
import type { FiguresResult } from './figures.js';
|
|
13
13
|
import type { Holdings } from './holdings.js';
|
|
14
14
|
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
15
15
|
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
16
16
|
import type { SearchRequest, SearchResult } from './search.js';
|
|
17
|
-
import type { HouseQuery, HouseQueryResult } from './house-query.js';
|
|
17
|
+
import type { HouseQuery, HouseQueryOptions, HouseQueryResult } from './house-query.js';
|
|
18
18
|
import type { Readiness } from './readiness.js';
|
|
19
19
|
import type { ObservedRead } from './reads.js';
|
|
20
|
+
import type { Runs } from './runs.js';
|
|
20
21
|
import type { SyncStatus } from './status.js';
|
|
21
22
|
import { type RuntimePort } from './wire.js';
|
|
22
|
-
export type
|
|
23
|
+
export type BuiltFile = Blob | string;
|
|
24
|
+
export type BuildFile = (name: string) => Promise<BuiltFile | null>;
|
|
23
25
|
export type MdRuntimeClient = {
|
|
24
|
-
buildFile(name: string): Promise<
|
|
26
|
+
buildFile(name: string): Promise<BuiltFile | null>;
|
|
25
27
|
rooms(): Promise<readonly AppRoom[]>;
|
|
26
28
|
query: {
|
|
27
29
|
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
28
30
|
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
29
31
|
};
|
|
30
32
|
search(request: SearchRequest): Promise<SearchResult>;
|
|
31
|
-
queryHouse(query: HouseQuery): Promise<HouseQueryResult>;
|
|
33
|
+
queryHouse(query: HouseQuery, options?: HouseQueryOptions): Promise<HouseQueryResult>;
|
|
32
34
|
types(locator: string): Promise<RoomSchemas>;
|
|
33
35
|
roomDraft: {
|
|
34
36
|
list(): Promise<readonly RoomDraft[]>;
|
|
@@ -49,8 +51,9 @@ export type MdRuntimeClient = {
|
|
|
49
51
|
chatDraft: ChatDraftSurface;
|
|
50
52
|
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
51
53
|
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
52
|
-
|
|
53
|
-
read(room: string, path: string, revision?: string): Promise<
|
|
54
|
+
attachment: {
|
|
55
|
+
read(room: string, path: string, revision?: string): Promise<AttachmentAnswer>;
|
|
56
|
+
show(room: string, path: string, revision?: string): Promise<ShownAnswer>;
|
|
54
57
|
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
55
58
|
download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
|
|
56
59
|
};
|
|
@@ -88,6 +91,11 @@ export type MdRuntimeClient = {
|
|
|
88
91
|
(topic: 'figures'): Promise<Observation<FiguresResult>>;
|
|
89
92
|
(topic: 'holdings'): Promise<Observation<Holdings>>;
|
|
90
93
|
(topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
|
|
94
|
+
(topic: 'runs', asked: {
|
|
95
|
+
room: string;
|
|
96
|
+
} | {
|
|
97
|
+
sent: true;
|
|
98
|
+
}): Promise<Observation<Runs | PendingResult>>;
|
|
91
99
|
};
|
|
92
100
|
reauthorize(): Promise<void>;
|
|
93
101
|
settled(): Promise<void>;
|
|
@@ -96,6 +104,7 @@ export declare function connectMdRuntime(port: RuntimePort, buildFile?: BuildFil
|
|
|
96
104
|
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
97
105
|
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
98
106
|
export { roomDraftRevision } from './identity.js';
|
|
107
|
+
export { atAddress, importedFile } from './loaded.js';
|
|
99
108
|
export { defineRoomMedia, ROOM_MEDIA, viewFile } from './media.js';
|
|
100
109
|
export { shownModal } from './modal.js';
|
|
101
110
|
export type { Observation } from './observation.js';
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAe,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,Y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.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { handedCopy, handedLink } from './download.js';
|
|
2
|
-
import { shownBy } from './media.js';
|
|
3
2
|
import { pageMetadataBlock } from './page-metadata.js';
|
|
4
3
|
import { appRooms, observed } from './observation.js';
|
|
5
4
|
import { runtimeError } from './failure.js';
|
|
6
|
-
import {
|
|
5
|
+
import { attachmentBlob, } from './outcome.js';
|
|
7
6
|
import { AUTHORIZATION_ENDED, PORT_CLOSED, wireAnswer, } from './wire.js';
|
|
8
7
|
// React renders an arrived value in a later task and opens what that render observes as it commits, so this many frames opening nothing mean the page drew what it observes.
|
|
9
8
|
const SETTLED_FRAMES = 2;
|
|
@@ -146,12 +145,12 @@ export function connectMdRuntime(port, buildFile = UNBUILT) {
|
|
|
146
145
|
let received = 0;
|
|
147
146
|
const stream = new ReadableStream({
|
|
148
147
|
async pull(controller) {
|
|
149
|
-
const bytes = await ask('
|
|
148
|
+
const bytes = await ask('attachment.part', [file, part]);
|
|
150
149
|
if (bytes === null) {
|
|
151
150
|
if (received === byteLength)
|
|
152
151
|
controller.close();
|
|
153
152
|
else
|
|
154
|
-
controller.error(runtimeError('
|
|
153
|
+
controller.error(runtimeError('attachment-absent', 'The file ended early'));
|
|
155
154
|
return;
|
|
156
155
|
}
|
|
157
156
|
part += 1;
|
|
@@ -162,13 +161,13 @@ export function connectMdRuntime(port, buildFile = UNBUILT) {
|
|
|
162
161
|
return { kind: 'binary', stream, byteLength, mediaType };
|
|
163
162
|
}
|
|
164
163
|
async function download(room, path, revision) {
|
|
165
|
-
const linked = await handedLink(path, () => ask('
|
|
164
|
+
const linked = await handedLink(path, () => ask('attachment.link', [room, path, revision]));
|
|
166
165
|
if (linked.kind !== 'absent')
|
|
167
166
|
return linked;
|
|
168
|
-
const read = streamed(await ask('
|
|
167
|
+
const read = streamed(await ask('attachment.read', [room, path, revision]));
|
|
169
168
|
if (read.kind !== 'binary')
|
|
170
169
|
return read;
|
|
171
|
-
return handedCopy(await
|
|
170
|
+
return handedCopy(await attachmentBlob(read), path.slice(path.lastIndexOf('/') + 1));
|
|
172
171
|
}
|
|
173
172
|
function settled() {
|
|
174
173
|
if (settling !== null)
|
|
@@ -199,13 +198,12 @@ export function connectMdRuntime(port, buildFile = UNBUILT) {
|
|
|
199
198
|
});
|
|
200
199
|
return settling;
|
|
201
200
|
}
|
|
202
|
-
|
|
203
|
-
return shownBy(show, {
|
|
201
|
+
return {
|
|
204
202
|
buildFile,
|
|
205
203
|
rooms: () => ask('rooms', []).then(appRooms),
|
|
206
204
|
query: ((query) => ask('query', [query])),
|
|
207
205
|
search: (request) => ask('search', [request]),
|
|
208
|
-
queryHouse: (query) => ask('queryHouse', [query]),
|
|
206
|
+
queryHouse: (query, options) => ask('queryHouse', options === undefined ? [query] : [query, options]),
|
|
209
207
|
types: (locator) => ask('types', [locator]),
|
|
210
208
|
roomDraft: {
|
|
211
209
|
list: () => ask('roomDraft.list', []),
|
|
@@ -232,7 +230,7 @@ export function connectMdRuntime(port, buildFile = UNBUILT) {
|
|
|
232
230
|
takeOut: (conversation, message, operation) => ask('conversation.takeOut', [conversation, message, operation]),
|
|
233
231
|
decide: (request, decision, operation) => ask('conversation.decide', [request, decision, operation]),
|
|
234
232
|
rename: (conversation, name, operation) => ask('conversation.rename', [conversation, name, operation]),
|
|
235
|
-
|
|
233
|
+
set: (conversation, settings, operation) => ask('conversation.set', [conversation, settings, operation]),
|
|
236
234
|
retry: (conversation, message, operation) => ask('conversation.retry', [conversation, message, operation]),
|
|
237
235
|
pin: (figures) => ask('conversation.pin', [figures]),
|
|
238
236
|
openTurn: (conversation, turn) => ask('conversation.openTurn', [conversation, turn]),
|
|
@@ -251,9 +249,10 @@ export function connectMdRuntime(port, buildFile = UNBUILT) {
|
|
|
251
249
|
},
|
|
252
250
|
history: (locator, path, query) => ask('history', [locator, path, query]),
|
|
253
251
|
resolve: (room, path, destination) => ask('resolve', [room, path, destination]),
|
|
254
|
-
|
|
255
|
-
read: (room, path, revision) => ask('
|
|
256
|
-
|
|
252
|
+
attachment: {
|
|
253
|
+
read: (room, path, revision) => ask('attachment.read', [room, path, revision]).then((read) => streamed(read)),
|
|
254
|
+
show: (room, path, revision) => ask('attachment.show', [room, path, revision]).then((shown) => streamed(shown)),
|
|
255
|
+
attach: (room, file) => ask('attachment.attach', [room, file]),
|
|
257
256
|
download,
|
|
258
257
|
},
|
|
259
258
|
call: (name, input) => ask('call', [name, input]),
|
|
@@ -269,7 +268,7 @@ export function connectMdRuntime(port, buildFile = UNBUILT) {
|
|
|
269
268
|
observe: ((topic, ...input) => watch(topic, input)),
|
|
270
269
|
reauthorize: () => ask('reauthorize', []),
|
|
271
270
|
settled,
|
|
272
|
-
}
|
|
271
|
+
};
|
|
273
272
|
}
|
|
274
273
|
const turns = new WeakMap();
|
|
275
274
|
export function inTurn(client, work) {
|
|
@@ -279,6 +278,7 @@ export function inTurn(client, work) {
|
|
|
279
278
|
}
|
|
280
279
|
export { chainedWindows } from './chain.js';
|
|
281
280
|
export { roomDraftRevision } from './identity.js';
|
|
281
|
+
export { atAddress, importedFile } from './loaded.js';
|
|
282
282
|
export { defineRoomMedia, ROOM_MEDIA, viewFile } from './media.js';
|
|
283
283
|
export { shownModal } from './modal.js';
|
|
284
284
|
export { unanswered, undelivered } from './wire.js';
|
package/dist/collection.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export declare function documentsOf(collection: Collection): Generator<number, I
|
|
|
45
45
|
export declare function validRoot(root: unknown): root is string;
|
|
46
46
|
export declare const UNTYPED = "any";
|
|
47
47
|
export declare function textType(read: ParseResult): string | undefined;
|
|
48
|
+
export declare function typeAt(composition: Composition, path: string, read: ParseResult): string | undefined;
|
|
48
49
|
export declare function typedText(read: ParseResult): boolean;
|
|
49
50
|
export declare function available(composition: Composition): boolean;
|
|
50
51
|
export {};
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/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C;AAE7B,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,MAAM,CACpB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,GAChB,MAAM,GAAG,SAAS,CAIpB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAEpD;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAE3D"}
|
package/dist/collection.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definitionAt, parse, VERSION, } from '@agentshouse/mdmodel';
|
|
1
|
+
import { definitionAt, folderType, parse, VERSION, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { beneath, normalize } from './paths.js';
|
|
3
3
|
import { hashed } from './observation.js';
|
|
4
4
|
import { sortedKeys } from './shared.js';
|
|
@@ -78,6 +78,12 @@ export const UNTYPED = 'any';
|
|
|
78
78
|
export function textType(read) {
|
|
79
79
|
return read.ok ? (read.document.type ?? UNTYPED) : undefined;
|
|
80
80
|
}
|
|
81
|
+
export function typeAt(composition, path, read) {
|
|
82
|
+
if (!read.ok || read.document.type !== undefined)
|
|
83
|
+
return textType(read);
|
|
84
|
+
const model = governing(composition, path);
|
|
85
|
+
return (model.status === 'unavailable' ? undefined : folderType(model, path)) ?? UNTYPED;
|
|
86
|
+
}
|
|
81
87
|
export function typedText(read) {
|
|
82
88
|
return (textType(read) ?? UNTYPED) !== UNTYPED;
|
|
83
89
|
}
|
package/dist/compile.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare function within(alias: string, path: string): Fragment;
|
|
|
13
13
|
export type QueryAnswer = QueryRows & {
|
|
14
14
|
readonly more?: string;
|
|
15
15
|
};
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function namedHandles(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], handles: readonly string[]): readonly string[];
|
|
17
|
+
export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null, follows?: readonly QueryRoom[]): QueryAnswer;
|
|
17
18
|
export {};
|
|
18
19
|
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,GAAG,EAQJ,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAE,IAAI,EAAuC,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,GAAG,EAQJ,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAE,IAAI,EAAuC,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvF,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAG1D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;CACpC,CAAC;AAEF,KAAK,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAI7B,eAAO,MAAM,OAAO,UAAW,MAAM,KAAG,MAAyD,CAAC;AAsBlG,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAE5D;AAufD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAkajE,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,SAAS,MAAM,EAAE,CAenB;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,MAAM,GAAE,MAAM,GAAG,IAAW,EAC5B,OAAO,GAAE,SAAS,SAAS,EAAO,GACjC,WAAW,CAUb"}
|
package/dist/compile.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { ARRAY_INDEX, bodied, byCodePoint, compared, cursorOf, heldKind, parse, pointerSegments, sql, } from '@agentshouse/mdmodel';
|
|
2
|
-
import {
|
|
2
|
+
import { attachmentRecord } from './attachment.js';
|
|
3
3
|
import { definitionsAt, UNTYPED } from './collection.js';
|
|
4
4
|
import { documentKey, pathOfKey, roomOfKey } from './rows.js';
|
|
5
|
+
import { ROOM_HANDLE } from './stored.js';
|
|
5
6
|
import { FROM_START, MAXIMUM_WINDOW } from './windows.js';
|
|
6
7
|
const { all, any, exists, fragment, grouped, joined, listed } = sql;
|
|
7
8
|
export const VISIBLE = (alias) => `${alias}.visible = 1 AND ${alias}.present = 1`;
|
|
8
9
|
function located(alias) {
|
|
9
10
|
return fragment(`(SELECT k.locator FROM replica_keys k WHERE k.key = ${alias}.key)`);
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
return fragment(`(${
|
|
13
|
-
|
|
14
|
-
`${
|
|
15
|
-
`${
|
|
12
|
+
function inside(path, folder) {
|
|
13
|
+
return fragment(`(${path} = ? OR (${path} >= ? AND ${path} < ?))`, [
|
|
14
|
+
folder,
|
|
15
|
+
`${folder}/`,
|
|
16
|
+
`${folder}0`,
|
|
16
17
|
]);
|
|
17
18
|
}
|
|
19
|
+
export function within(alias, path) {
|
|
20
|
+
return inside(`${alias}.path`, path);
|
|
21
|
+
}
|
|
18
22
|
function ancestors(area) {
|
|
19
23
|
const depth = area.path.split('/').length;
|
|
20
24
|
return area.open.flatMap((open) => {
|
|
@@ -22,18 +26,18 @@ function ancestors(area) {
|
|
|
22
26
|
return segments.slice(depth - 1, -1).map((_, at) => segments.slice(0, depth + at).join('/'));
|
|
23
27
|
});
|
|
24
28
|
}
|
|
25
|
-
function fenced(
|
|
29
|
+
function fenced(key, path, held, area, folders) {
|
|
26
30
|
const opened = any([
|
|
27
|
-
...area.open.map((open) =>
|
|
28
|
-
...(folders ? ancestors(area).map((
|
|
31
|
+
...area.open.map((open) => inside(path, open)),
|
|
32
|
+
...(folders ? ancestors(area).map((ancestor) => fragment(`${path} = ?`, [ancestor])) : []),
|
|
29
33
|
]);
|
|
30
34
|
return all([
|
|
31
|
-
fragment(`${
|
|
32
|
-
|
|
35
|
+
fragment(`${key} = ?`, [held]),
|
|
36
|
+
inside(path, area.path),
|
|
33
37
|
fragment(`NOT ${grouped(opened).sql}`, opened.bind),
|
|
34
38
|
]);
|
|
35
39
|
}
|
|
36
|
-
function reached(bound,
|
|
40
|
+
function reached(bound, key, path) {
|
|
37
41
|
const reach = bound.reach;
|
|
38
42
|
if (reach === null)
|
|
39
43
|
return fragment('1');
|
|
@@ -46,49 +50,65 @@ function reached(bound, alias) {
|
|
|
46
50
|
return key === undefined ? [] : [[key, pathOfKey(held)]];
|
|
47
51
|
});
|
|
48
52
|
const outside = any(reach.areas.flatMap((area) => {
|
|
49
|
-
const
|
|
50
|
-
return
|
|
53
|
+
const held = bound.keys.get(area.room);
|
|
54
|
+
return held === undefined ? [] : [fenced(key, path, held, area, false)];
|
|
51
55
|
}));
|
|
52
56
|
return all([
|
|
53
57
|
any([
|
|
54
|
-
...(rooms.length === 0 ? [] : [fragment(`${
|
|
58
|
+
...(rooms.length === 0 ? [] : [fragment(`${key} IN ${listed(rooms).sql}`, rooms)]),
|
|
55
59
|
...(documents.length === 0
|
|
56
60
|
? []
|
|
57
61
|
: [
|
|
58
|
-
fragment(`EXISTS (SELECT 1 FROM json_each(?) j WHERE j.value ->> 0 = ${
|
|
62
|
+
fragment(`EXISTS (SELECT 1 FROM json_each(?) j WHERE j.value ->> 0 = ${key} AND j.value ->> 1 = ${path})`, [JSON.stringify(documents)]),
|
|
59
63
|
]),
|
|
60
64
|
]),
|
|
61
65
|
...(reach.areas.length === 0 ? [] : [fragment(`NOT ${grouped(outside).sql}`, outside.bind)]),
|
|
62
66
|
]);
|
|
63
67
|
}
|
|
68
|
+
function handled(bound, link) {
|
|
69
|
+
return fragment(`FROM replica_rooms h WHERE ${ROOM_HANDLE('h')} = ${link}.handle AND h.key IN (SELECT value FROM json_each(?))`, [bound.follows]);
|
|
70
|
+
}
|
|
71
|
+
function followed(bound) {
|
|
72
|
+
return {
|
|
73
|
+
targets: (link, document) => {
|
|
74
|
+
const room = handled(bound, link);
|
|
75
|
+
return joined([
|
|
76
|
+
fragment(`replica_entries ${document} ON ${document}.key = CASE WHEN ${link}.handle IS NULL THEN d.key ELSE (SELECT h.key ${room.sql}) END AND ${document}.path = ${link}.target AND ${VISIBLE(document)} AND`, room.bind),
|
|
77
|
+
grouped(reached(bound, `${document}.key`, `${document}.path`)),
|
|
78
|
+
], ' ');
|
|
79
|
+
},
|
|
80
|
+
unfollowed: (link) => {
|
|
81
|
+
const own = reached(bound, 'd.key', `${link}.target`);
|
|
82
|
+
const room = handled(bound, link);
|
|
83
|
+
const other = reached(bound, 'h.key', `${link}.target`);
|
|
84
|
+
return fragment(`NOT ((${link}.handle IS NULL AND ${own.sql}) OR EXISTS (SELECT 1 ${room.sql} AND ${other.sql}))`, [...own.bind, ...room.bind, ...other.bind]);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
64
88
|
function related(bound, plan) {
|
|
65
89
|
const parts = [];
|
|
66
|
-
if (plan.hop !== null)
|
|
67
|
-
parts.push(
|
|
68
|
-
fragment(`SELECT 1 FROM replica_links l JOIN replica_entries m ON m.key = d.key AND m.path = l.target AND ${VISIBLE('m')} WHERE l.doc = d.id AND l.kind = 'field' AND`),
|
|
69
|
-
grouped(sql.placed('l', plan.hop.field, 'link')),
|
|
70
|
-
fragment('AND'),
|
|
71
|
-
grouped(all([sql.scoped('m', plan.hop), reached(bound, 'm')])),
|
|
72
|
-
], ' ')));
|
|
73
|
-
}
|
|
90
|
+
if (plan.hop !== null)
|
|
91
|
+
parts.push(sql.hopped('d', plan.hop, followed(bound)));
|
|
74
92
|
if (plan.backlinks !== null) {
|
|
75
93
|
const field = plan.backlinks.field;
|
|
76
94
|
parts.push(exists(joined([
|
|
77
|
-
fragment(`SELECT 1 FROM replica_links l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE l.key = d.key AND l.target = d.path AND l.kind = 'field' AND`),
|
|
95
|
+
fragment(`SELECT 1 FROM replica_links l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE l.key = d.key AND l.handle IS NULL AND l.target = d.path AND l.kind = 'field' AND`),
|
|
78
96
|
...(field === null ? [] : [grouped(sql.placed('l', field, 'link')), fragment('AND')]),
|
|
79
|
-
grouped(all([sql.scoped('s', plan.backlinks), reached(bound, 's')])),
|
|
97
|
+
grouped(all([sql.scoped('s', plan.backlinks), reached(bound, 's.key', 's.path')])),
|
|
80
98
|
], ' ')));
|
|
81
99
|
}
|
|
82
100
|
return parts;
|
|
83
101
|
}
|
|
84
|
-
function
|
|
102
|
+
function tested(bound, plan) {
|
|
85
103
|
const keys = bound.rooms.map(({ key }) => key);
|
|
86
|
-
return
|
|
104
|
+
return [
|
|
87
105
|
fragment(`d.key IN ${listed(keys).sql} AND ${VISIBLE('d')}`, keys),
|
|
88
|
-
reached(bound, 'd'),
|
|
106
|
+
reached(bound, 'd.key', 'd.path'),
|
|
89
107
|
sql.tests('d', plan),
|
|
90
|
-
|
|
91
|
-
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
function filtered(bound, plan) {
|
|
111
|
+
return all([...tested(bound, plan), ...related(bound, plan)]);
|
|
92
112
|
}
|
|
93
113
|
function orderingOf(options) {
|
|
94
114
|
const stringSort = options.stringSort ?? 'locale';
|
|
@@ -334,7 +354,7 @@ function documentOf(shape, queried, row, linked) {
|
|
|
334
354
|
...(binary === null
|
|
335
355
|
? {}
|
|
336
356
|
: {
|
|
337
|
-
|
|
357
|
+
attachment: attachmentRecord(path, binary, revision ?? undefined),
|
|
338
358
|
}),
|
|
339
359
|
...(shape.markdown && content !== null ? { markdown: content } : {}),
|
|
340
360
|
...(shape.change ? { change: changeOf(row) } : {}),
|
|
@@ -388,10 +408,10 @@ function backlinksOf(connection, bound, rows) {
|
|
|
388
408
|
held.push(row.path);
|
|
389
409
|
byKey.set(key, held);
|
|
390
410
|
}
|
|
391
|
-
const reach = reached(bound, 's');
|
|
411
|
+
const reach = reached(bound, 's.key', 's.path');
|
|
392
412
|
for (const [key, targets] of byKey) {
|
|
393
413
|
const room = bound.rooms.find((one) => one.key === key).locator;
|
|
394
|
-
const found = connection.rows(`SELECT target, path, type, field FROM (SELECT l.target, s.path, s.type, l.field, ROW_NUMBER() OVER (PARTITION BY l.target ORDER BY s.path, l.field) AS rank FROM (SELECT DISTINCT doc, target, field FROM replica_links WHERE key = ? AND kind = 'field' AND target IN (SELECT value FROM json_each(?))) l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE ${reach.sql}) WHERE rank <= ? ORDER BY target, path, field`, [key, JSON.stringify(targets), ...reach.bind, MAXIMUM_WINDOW]);
|
|
414
|
+
const found = connection.rows(`SELECT target, path, type, field FROM (SELECT l.target, s.path, s.type, l.field, ROW_NUMBER() OVER (PARTITION BY l.target ORDER BY s.path, l.field) AS rank FROM (SELECT DISTINCT doc, target, field FROM replica_links WHERE key = ? AND kind = 'field' AND handle IS NULL AND target IN (SELECT value FROM json_each(?))) l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE ${reach.sql}) WHERE rank <= ? ORDER BY target, path, field`, [key, JSON.stringify(targets), ...reach.bind, MAXIMUM_WINDOW]);
|
|
395
415
|
for (const row of found) {
|
|
396
416
|
const at = documentKey(room, row.target);
|
|
397
417
|
const held = linked.get(at) ?? [];
|
|
@@ -506,7 +526,7 @@ function storedFolders(bound, plan, subfolder) {
|
|
|
506
526
|
const key = bound.keys.get(area.room);
|
|
507
527
|
if (key === undefined)
|
|
508
528
|
return [];
|
|
509
|
-
const fence = fenced('f', key, area, true);
|
|
529
|
+
const fence = fenced('f.key', 'f.path', key, area, true);
|
|
510
530
|
return [fragment(`NOT ${grouped(fence).sql}`, fence.bind)];
|
|
511
531
|
});
|
|
512
532
|
const under = prefix === ''
|
|
@@ -702,16 +722,28 @@ function groups(connection, bound, plan, shape) {
|
|
|
702
722
|
...(total === undefined ? {} : { total }),
|
|
703
723
|
};
|
|
704
724
|
}
|
|
705
|
-
function boundOf(connection, plan, rooms) {
|
|
725
|
+
function boundOf(connection, plan, rooms, follows) {
|
|
706
726
|
return {
|
|
707
727
|
rooms: [...rooms].sort((left, right) => left.locator < right.locator ? -1 : left.locator > right.locator ? 1 : 0),
|
|
708
|
-
keys: new Map(rooms.map(({ locator, key }) => [locator, key])),
|
|
728
|
+
keys: new Map([...rooms, ...follows].map(({ locator, key }) => [locator, key])),
|
|
729
|
+
follows: JSON.stringify(follows.map(({ key }) => key)),
|
|
709
730
|
reach: plan.reach,
|
|
710
731
|
collate: collating(connection),
|
|
711
732
|
};
|
|
712
733
|
}
|
|
713
|
-
export function
|
|
714
|
-
|
|
734
|
+
export function namedHandles(connection, plan, rooms, handles) {
|
|
735
|
+
if (plan.hop === null)
|
|
736
|
+
return [];
|
|
737
|
+
const statement = joined([
|
|
738
|
+
fragment("SELECT DISTINCT l.handle FROM replica_entries d JOIN replica_links l ON l.doc = d.id AND l.kind = 'field' AND l.handle IN (SELECT value FROM json_each(?)) AND ", [JSON.stringify(handles)]),
|
|
739
|
+
grouped(sql.placed('l', plan.hop.field, 'link')),
|
|
740
|
+
fragment(' WHERE '),
|
|
741
|
+
all(tested(boundOf(connection, plan, rooms, []), plan)),
|
|
742
|
+
], '');
|
|
743
|
+
return connection.rows(statement.sql, statement.bind).map((row) => row.handle);
|
|
744
|
+
}
|
|
745
|
+
export function answerQuery(connection, plan, rooms, budget = null, follows = []) {
|
|
746
|
+
const bound = boundOf(connection, plan, rooms, follows);
|
|
715
747
|
if (rooms.length === 0) {
|
|
716
748
|
return plan.shape.kind === 'groups'
|
|
717
749
|
? { groups: [], ...(plan.total ? { total: 0 } : {}) }
|
package/dist/connection.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export type MdRuntimeOptions = {
|
|
|
10
10
|
authorization?: Authorization;
|
|
11
11
|
signal?: AbortSignal;
|
|
12
12
|
recovery?: Recovery;
|
|
13
|
-
usableWhenHeld?: readonly string[];
|
|
14
13
|
build?: string;
|
|
14
|
+
storeOnNeed?: boolean;
|
|
15
15
|
};
|
|
16
16
|
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
17
17
|
//# sourceMappingURL=connection.d.ts.map
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAsC,MAAM,cAAc,CAAC;AAI/F,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAUrE,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9D,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAOrE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAIF,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CA6GzE"}
|