@agentshouse/mdruntime 0.1.0-c835af48a82d3 → 0.1.0-c83bc1fac9b35
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 +321 -0
- package/dist/adapter.d.ts +115 -57
- 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 +0 -5
- 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 +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- 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 +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +2 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -2
- package/dist/client.d.ts +26 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +45 -58
- package/dist/collection.d.ts +26 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +28 -10
- 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 +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +31 -25
- package/dist/connection.d.ts +5 -149
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +112 -5364
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +152 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +261 -0
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +22 -3
- package/dist/conversation.d.ts +57 -45
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +977 -1031
- 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 +12 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -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 +14 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +5 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +23 -12
- 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 +8 -0
- package/dist/figures.d.ts +1 -0
- 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 +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +24 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +87 -20
- package/dist/house-query.d.ts +21 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +41 -0
- package/dist/index.d.ts +30 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -6
- 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 +290 -0
- package/dist/listing.d.ts +60 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +168 -0
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +74 -33
- 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 +34 -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 +9 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +94 -32
- package/dist/messages.d.ts +12 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +35 -39
- 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 +4 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -5
- 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 +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +217 -85
- 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 +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 +69 -0
- package/dist/outcome.d.ts +16 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +32 -2
- package/dist/overlay.d.ts +6 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +37 -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 +5 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +28 -110
- 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 +45 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +335 -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 +287 -0
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +3 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +4 -6
- 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 +15 -5
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +164 -33
- package/dist/react.d.ts +18 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +16 -5
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +10 -10
- package/dist/reads.d.ts +6 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +61 -11
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refresh.js +2 -2
- 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 +5 -13
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +17 -18
- 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 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +273 -66
- 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 +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +9 -10
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +35 -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 +326 -225
- package/dist/saves.d.ts +34 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +437 -0
- 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 +326 -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 +41 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +26 -0
- package/dist/socket.d.ts +68 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +165 -0
- package/dist/source.d.ts +5 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +18 -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 +227 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +468 -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 +119 -204
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +170 -394
- package/dist/stored.d.ts +26 -14
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +101 -36
- package/dist/surface.d.ts +94 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +255 -0
- package/dist/sync.d.ts +21 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +557 -0
- package/dist/tables.d.ts +28 -59
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +106 -331
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +4 -10
- package/dist/wire.d.ts +68 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +26 -9
- 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/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/collection.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { parse, VERSION } from '@agentshouse/mdmodel';
|
|
1
|
+
import { definitionAt, 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';
|
|
5
5
|
export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
|
|
6
6
|
const typesPrinted = new WeakMap();
|
|
7
|
-
function typesPrint(
|
|
8
|
-
|
|
9
|
-
return '';
|
|
10
|
-
let print = typesPrinted.get(model.types);
|
|
7
|
+
export function typesPrint(types) {
|
|
8
|
+
let print = typesPrinted.get(types);
|
|
11
9
|
if (print === undefined) {
|
|
12
|
-
print = hashed(JSON.stringify(
|
|
13
|
-
typesPrinted.set(
|
|
10
|
+
print = hashed(JSON.stringify(types)).toString(36);
|
|
11
|
+
typesPrinted.set(types, print);
|
|
14
12
|
}
|
|
15
13
|
return print;
|
|
16
14
|
}
|
|
15
|
+
function modelPrint(model) {
|
|
16
|
+
return model.status === 'unavailable' ? '' : typesPrint(model.types);
|
|
17
|
+
}
|
|
17
18
|
export function composedOf(composition) {
|
|
18
19
|
const { model, selection } = composition;
|
|
19
20
|
return {
|
|
20
21
|
composition,
|
|
21
22
|
fingerprint: JSON.stringify([
|
|
22
|
-
|
|
23
|
-
selection === null ? null : [selection.roots,
|
|
23
|
+
modelPrint(model),
|
|
24
|
+
selection === null ? null : [selection.roots, modelPrint(selection.model)],
|
|
24
25
|
]),
|
|
25
26
|
};
|
|
26
27
|
}
|
|
@@ -33,6 +34,16 @@ export function governing(composition, path) {
|
|
|
33
34
|
? composition.selection.model
|
|
34
35
|
: composition.model;
|
|
35
36
|
}
|
|
37
|
+
function definitionsUnder(composition, path, typedPaths, typesOf) {
|
|
38
|
+
const types = typesOf(governing(composition, path));
|
|
39
|
+
return types === null ? () => undefined : definitionAt({ types }, path, typedPaths);
|
|
40
|
+
}
|
|
41
|
+
export function definitionsAt(composition, path) {
|
|
42
|
+
return definitionsUnder(composition, path, composition.typedPaths, (model) => model.status === 'unavailable' ? null : model.types);
|
|
43
|
+
}
|
|
44
|
+
export function definitionsIn(room, path, typedPaths) {
|
|
45
|
+
return definitionsUnder({ model: room.model, selection: room.typedSelection }, path, typedPaths, ({ types }) => types === null ? null : Object.fromEntries(types.map((type) => [type.name, type])));
|
|
46
|
+
}
|
|
36
47
|
export function collectionOf(text, composition) {
|
|
37
48
|
const parsed = new Map();
|
|
38
49
|
return {
|
|
@@ -44,7 +55,7 @@ export function collectionOf(text, composition) {
|
|
|
44
55
|
const content = text[path];
|
|
45
56
|
if (content === undefined)
|
|
46
57
|
return undefined;
|
|
47
|
-
const read = parse(content, path);
|
|
58
|
+
const read = parse(content, path, definitionsAt(composition, path));
|
|
48
59
|
parsed.set(path, read.ok ? read.document : null);
|
|
49
60
|
return read.ok ? read.document : undefined;
|
|
50
61
|
},
|
|
@@ -63,6 +74,13 @@ export function* documentsOf(collection) {
|
|
|
63
74
|
export function validRoot(root) {
|
|
64
75
|
return typeof root === 'string' && normalize(root) === root;
|
|
65
76
|
}
|
|
77
|
+
export const UNTYPED = 'any';
|
|
78
|
+
export function textType(read) {
|
|
79
|
+
return read.ok ? (read.document.type ?? UNTYPED) : undefined;
|
|
80
|
+
}
|
|
81
|
+
export function typedText(read) {
|
|
82
|
+
return (textType(read) ?? UNTYPED) !== UNTYPED;
|
|
83
|
+
}
|
|
66
84
|
export function available(composition) {
|
|
67
85
|
return composition.model.status !== 'unavailable';
|
|
68
86
|
}
|
package/dist/column.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Row, Value } from './tables.js';
|
|
2
|
+
export declare function text(value: Value | undefined): string;
|
|
3
|
+
export declare function texts(rows: readonly Row[], column: string): string[];
|
|
4
|
+
export declare function count(value: Value | undefined): number;
|
|
5
|
+
//# sourceMappingURL=column.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../src/column.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE9C,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAErD;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpE;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAEtD"}
|
package/dist/column.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function text(value) {
|
|
2
|
+
return typeof value === 'string' ? value : String(value);
|
|
3
|
+
}
|
|
4
|
+
export function texts(rows, column) {
|
|
5
|
+
return rows.map((row) => text(row[column]));
|
|
6
|
+
}
|
|
7
|
+
export function count(value) {
|
|
8
|
+
return typeof value === 'bigint' ? Number(value) : typeof value === 'number' ? value : 0;
|
|
9
|
+
}
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { sql } from '@agentshouse/mdmodel';
|
|
2
|
+
import { type Composition } from './collection.js';
|
|
2
3
|
import type { Plan, QueryRows } from './query.js';
|
|
3
4
|
import type { Connection } from './tables.js';
|
|
4
5
|
export type QueryRoom = {
|
|
5
6
|
readonly locator: string;
|
|
6
7
|
readonly key: number;
|
|
8
|
+
readonly composition?: Composition;
|
|
7
9
|
};
|
|
8
10
|
type Fragment = sql.Fragment;
|
|
9
11
|
export declare const VISIBLE: (alias: string) => string;
|
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,
|
|
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;AAEvF,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;AAalG,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAM5D;AA2dD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA4ZjE,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,MAAM,GAAE,MAAM,GAAG,IAAW,GAC3B,WAAW,CAUb"}
|
package/dist/compile.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ARRAY_INDEX, bodied, byCodePoint, compared, cursorOf, heldKind, parse, pointerSegments, sql, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { binaryRecord } from './binary.js';
|
|
3
|
+
import { definitionsAt, UNTYPED } from './collection.js';
|
|
3
4
|
import { documentKey, pathOfKey, roomOfKey } from './rows.js';
|
|
4
5
|
import { FROM_START, MAXIMUM_WINDOW } from './windows.js';
|
|
5
6
|
const { all, any, exists, fragment, grouped, joined, listed } = sql;
|
|
6
|
-
export const VISIBLE = (alias) => `${alias}.visible = 1 AND ${alias}.present = 1
|
|
7
|
+
export const VISIBLE = (alias) => `${alias}.visible = 1 AND ${alias}.present = 1`;
|
|
7
8
|
function located(alias) {
|
|
8
9
|
return fragment(`(SELECT k.locator FROM replica_keys k WHERE k.key = ${alias}.key)`);
|
|
9
10
|
}
|
|
@@ -310,11 +311,20 @@ function sectionsOf(sections, names) {
|
|
|
310
311
|
return sections;
|
|
311
312
|
return Object.fromEntries(names.flatMap((name) => (Object.hasOwn(sections, name) ? [[name, sections[name]]] : [])));
|
|
312
313
|
}
|
|
313
|
-
function
|
|
314
|
+
function freeParts(room, path, type, content) {
|
|
315
|
+
const definitions = room.composition === undefined ? undefined : definitionsAt(room.composition, path);
|
|
316
|
+
const definition = definitions?.(type === UNTYPED ? undefined : type);
|
|
317
|
+
if (definition === undefined && type !== UNTYPED)
|
|
318
|
+
return null;
|
|
319
|
+
const read = parse(content, path, definition);
|
|
320
|
+
return read.ok ? read.document : null;
|
|
321
|
+
}
|
|
322
|
+
function documentOf(shape, queried, row, linked) {
|
|
323
|
+
const room = queried.locator;
|
|
314
324
|
const path = row.path;
|
|
315
325
|
const type = row.type;
|
|
316
|
-
const fileId = row.file_id
|
|
317
|
-
const revision = row.revision
|
|
326
|
+
const fileId = row.file_id;
|
|
327
|
+
const revision = row.revision;
|
|
318
328
|
if (type === null) {
|
|
319
329
|
const binary = row.binary === null ? null : JSON.parse(row.binary);
|
|
320
330
|
const content = row.content ?? null;
|
|
@@ -333,8 +343,9 @@ function documentOf(shape, room, row, linked) {
|
|
|
333
343
|
...heldFacts(shape, row),
|
|
334
344
|
};
|
|
335
345
|
}
|
|
336
|
-
const
|
|
337
|
-
|
|
346
|
+
const body = shape.sections !== null || shape.preamble
|
|
347
|
+
? freeParts(queried, path, type, row.content)
|
|
348
|
+
: null;
|
|
338
349
|
const fields = JSON.parse(row.fields ?? '{}');
|
|
339
350
|
return {
|
|
340
351
|
room,
|
|
@@ -365,7 +376,7 @@ function changeOf(row) {
|
|
|
365
376
|
function heldFacts(shape, row) {
|
|
366
377
|
return {
|
|
367
378
|
...(shape.size ? { size: row.bytes === null ? null : Number(row.bytes) } : {}),
|
|
368
|
-
...(shape.created ? { created: row.created
|
|
379
|
+
...(shape.created ? { created: row.created } : {}),
|
|
369
380
|
};
|
|
370
381
|
}
|
|
371
382
|
function backlinksOf(connection, bound, rows) {
|
|
@@ -377,8 +388,8 @@ function backlinksOf(connection, bound, rows) {
|
|
|
377
388
|
held.push(row.path);
|
|
378
389
|
byKey.set(key, held);
|
|
379
390
|
}
|
|
391
|
+
const reach = reached(bound, 's');
|
|
380
392
|
for (const [key, targets] of byKey) {
|
|
381
|
-
const reach = reached(bound, 's');
|
|
382
393
|
const room = bound.rooms.find((one) => one.key === key).locator;
|
|
383
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]);
|
|
384
395
|
for (const row of found) {
|
|
@@ -395,22 +406,19 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
395
406
|
const filter = filtered(bound, plan);
|
|
396
407
|
const cursor = plan.after?.values ?? null;
|
|
397
408
|
const room = located('d');
|
|
398
|
-
const
|
|
409
|
+
const after = cursor === null
|
|
399
410
|
? null
|
|
400
411
|
: (() => {
|
|
401
412
|
const key = cursor[shape.orderBy.length];
|
|
402
|
-
return any([
|
|
413
|
+
return sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), any([
|
|
403
414
|
fragment(`${room.sql} > ?`, [...room.bind, roomOfKey(key)]),
|
|
404
415
|
fragment(`${room.sql} = ? AND d.path > ?`, [
|
|
405
416
|
...room.bind,
|
|
406
417
|
roomOfKey(key),
|
|
407
418
|
pathOfKey(key),
|
|
408
419
|
]),
|
|
409
|
-
]);
|
|
420
|
+
]));
|
|
410
421
|
})();
|
|
411
|
-
const after = cursor === null || tie === null
|
|
412
|
-
? null
|
|
413
|
-
: sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), tie);
|
|
414
422
|
const selected = joined([
|
|
415
423
|
fragment('SELECT d.id, d.key, d.path, d.type, d.binary, d.revision, d.fields, d.change, d.file_id, d.bytes, d.created'),
|
|
416
424
|
...terms.map(({ term }, index) => joined([
|
|
@@ -431,8 +439,9 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
431
439
|
const kept = bodied(shape) ? withContent(connection, windowed, budget) : windowed;
|
|
432
440
|
const cut = kept.length;
|
|
433
441
|
const roomOf = new Map(bound.rooms.map(({ key, locator }) => [key, locator]));
|
|
442
|
+
const queried = new Map(bound.rooms.map((one) => [one.key, one]));
|
|
434
443
|
const linked = shape.backlinks ? backlinksOf(connection, bound, kept) : new Map();
|
|
435
|
-
const found = kept.map((row) => documentOf(shape,
|
|
444
|
+
const found = kept.map((row) => documentOf(shape, queried.get(Number(row.key)), row, linked));
|
|
436
445
|
const last = kept.at(-1);
|
|
437
446
|
const cursorAt = (row) => cursorOf([
|
|
438
447
|
...shape.orderBy.map(({ key }, index) => decodedKey(key, row, index)),
|
|
@@ -645,17 +654,14 @@ function groups(connection, bound, plan, shape) {
|
|
|
645
654
|
{ ordering: GROUP_TIES, kind: fragment("'string'"), value: fragment(`k${index}`) },
|
|
646
655
|
]);
|
|
647
656
|
const cursor = plan.after?.values ?? null;
|
|
648
|
-
const
|
|
657
|
+
const after = cursor === null
|
|
649
658
|
? null
|
|
650
|
-
:
|
|
651
|
-
value,
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
: sql.following(ordered.map((term, index) => sql.beyond(bound.collate, term, cursor[index])), sql.following(ties
|
|
657
|
-
.slice(0, -1)
|
|
658
|
-
.map((term, index) => sql.beyond(bound.collate, term, tieValues[index])), sql.beyond(bound.collate, ties.at(-1), tieValues.at(-1)).beyond));
|
|
659
|
+
: (() => {
|
|
660
|
+
const tieValues = cursor[shape.orderBy.length].flatMap((value) => [value, heldKind(value ?? null)]);
|
|
661
|
+
return sql.following(ordered.map((term, index) => sql.beyond(bound.collate, term, cursor[index])), sql.following(ties
|
|
662
|
+
.slice(0, -1)
|
|
663
|
+
.map((term, index) => sql.beyond(bound.collate, term, tieValues[index])), sql.beyond(bound.collate, ties.at(-1), tieValues.at(-1)).beyond));
|
|
664
|
+
})();
|
|
659
665
|
const grouping = joined([fragment(`SELECT ${columns} FROM (`), ranked, fragment(`) GROUP BY ${held}`)], '');
|
|
660
666
|
const windowed = joined([
|
|
661
667
|
fragment('SELECT * FROM ('),
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,55 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
3
|
-
import { type Observation } from './observation.js';
|
|
4
|
-
import { type DocumentResult, type GroupResult, type PendingResult } from './query.js';
|
|
5
|
-
import { type FiguresResult } from './figures.js';
|
|
6
|
-
import { type EntrySeed } from './seed.js';
|
|
7
|
-
import { type SearchRequest, type SearchResult } from './search.js';
|
|
8
|
-
import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
|
|
9
|
-
import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
10
|
-
import { type WrittenBy } from './change.js';
|
|
11
|
-
import type { Open } from './open.js';
|
|
12
|
-
import { type AttachAnswer, type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HeldShownAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
|
|
13
|
-
import { type ObservedRead } from './reads.js';
|
|
1
|
+
import type { Adapter, Authorization } from './adapter.js';
|
|
2
|
+
import { type RuntimeShell } from './durability.js';
|
|
14
3
|
import { type Recovery } from './recovery.js';
|
|
15
|
-
import { type
|
|
16
|
-
import { type
|
|
17
|
-
import { type SyncStatus } from './status.js';
|
|
18
|
-
import { type RuntimeShell, type UnsentWork } from './durability.js';
|
|
19
|
-
import { type CodeAvailability, type Persistence, type Readiness } from './readiness.js';
|
|
20
|
-
import type { RuntimeDatabase } from './tables.js';
|
|
21
|
-
import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
|
|
22
|
-
export type AppTypedSelection = {
|
|
23
|
-
roots: readonly string[];
|
|
24
|
-
model: TypesResult;
|
|
25
|
-
};
|
|
26
|
-
export type AppRoom = {
|
|
27
|
-
name: string;
|
|
28
|
-
locator: string;
|
|
29
|
-
handle: string;
|
|
30
|
-
operations: import('./adapter.js').OperationScopes;
|
|
31
|
-
replica: import('./adapter.js').ReplicaAdmission;
|
|
32
|
-
model: TypesResult;
|
|
33
|
-
typedSelection: AppTypedSelection | null;
|
|
34
|
-
providerOwnedPaths: readonly string[];
|
|
35
|
-
roomVersion: string | null;
|
|
36
|
-
documents: number;
|
|
37
|
-
synchronizationAvailable: boolean;
|
|
38
|
-
refusal: ProviderRefusal | null;
|
|
39
|
-
locked: boolean;
|
|
40
|
-
};
|
|
41
|
-
export type RoomSchemas = {
|
|
42
|
-
collection: TypesResult;
|
|
43
|
-
typedSelection: TypesResult | null;
|
|
44
|
-
};
|
|
45
|
-
type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
|
|
46
|
-
export type ConnectionRefusalCode = Open<RefusalReason>;
|
|
47
|
-
export type ConnectionRefusal = {
|
|
48
|
-
code: ConnectionRefusalCode;
|
|
49
|
-
retryable: boolean;
|
|
50
|
-
reauthorizationOffered: boolean;
|
|
51
|
-
refusal: ProviderRefusal | null;
|
|
52
|
-
};
|
|
4
|
+
import { type RuntimeDatabase } from './store.js';
|
|
5
|
+
import { type ComposedRuntime } from './surface.js';
|
|
53
6
|
export type MdRuntimeOptions = {
|
|
54
7
|
adapter: Adapter;
|
|
55
8
|
shell: RuntimeShell;
|
|
@@ -57,105 +10,8 @@ export type MdRuntimeOptions = {
|
|
|
57
10
|
authorization?: Authorization;
|
|
58
11
|
signal?: AbortSignal;
|
|
59
12
|
recovery?: Recovery;
|
|
60
|
-
usableWhenHeld?: readonly string[];
|
|
61
13
|
build?: string;
|
|
62
|
-
|
|
63
|
-
export type SaveResult = {
|
|
64
|
-
outcome: 'saved';
|
|
65
|
-
identifier: string;
|
|
66
|
-
} | ({
|
|
67
|
-
outcome: 'refused';
|
|
68
|
-
} & SaveRefusal);
|
|
69
|
-
export type SavedRoomDraft = {
|
|
70
|
-
readonly path: string;
|
|
71
|
-
readonly revision: string;
|
|
72
|
-
};
|
|
73
|
-
export type SavedParts = {
|
|
74
|
-
readonly path: string;
|
|
75
|
-
readonly parts: RoomDraftParts;
|
|
76
|
-
};
|
|
77
|
-
export type RoomDraftSurface = {
|
|
78
|
-
list(): Promise<readonly RoomDraft[]>;
|
|
79
|
-
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
80
|
-
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
81
|
-
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
82
|
-
};
|
|
83
|
-
export type PresentationSurface = {
|
|
84
|
-
read(app: string): Promise<unknown>;
|
|
85
|
-
write(app: string, value: unknown): Promise<void>;
|
|
86
|
-
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
87
|
-
};
|
|
88
|
-
export type BinaryFileSurface = {
|
|
89
|
-
read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
|
|
90
|
-
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
91
|
-
show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
|
|
92
|
-
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
93
|
-
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
94
|
-
};
|
|
95
|
-
export type HistoryQuery = {
|
|
96
|
-
revision?: string;
|
|
97
|
-
pageToken?: string;
|
|
98
|
-
};
|
|
99
|
-
export type MdRuntime = {
|
|
100
|
-
loaded(): Promise<void>;
|
|
101
|
-
rooms(): Promise<readonly AppRoom[]>;
|
|
102
|
-
query: {
|
|
103
|
-
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
104
|
-
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
105
|
-
};
|
|
106
|
-
search(request: SearchRequest): Promise<SearchResult>;
|
|
107
|
-
types(locator: string): Promise<RoomSchemas>;
|
|
108
|
-
roomDraft: RoomDraftSurface;
|
|
109
|
-
conversation: ConversationSurface;
|
|
110
|
-
chatDraft: ChatDraftSurface;
|
|
111
|
-
presentation: PresentationSurface;
|
|
112
|
-
save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
113
|
-
saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
114
|
-
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
115
|
-
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
116
|
-
binaryFile: BinaryFileSurface;
|
|
117
|
-
call(name: string, input: unknown): Promise<CallResult>;
|
|
118
|
-
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
119
|
-
log(): string;
|
|
120
|
-
persistence(): boolean;
|
|
121
|
-
retry(): Promise<void>;
|
|
122
|
-
cleanUp(): Promise<number>;
|
|
123
|
-
unsent(): Promise<readonly UnsentWork[]>;
|
|
124
|
-
reset(): Promise<void>;
|
|
125
|
-
readAgain(): Promise<void>;
|
|
126
|
-
observe: {
|
|
127
|
-
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
128
|
-
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
129
|
-
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
130
|
-
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
131
|
-
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
132
|
-
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
133
|
-
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
134
|
-
(topic: 'authority-changes'): Promise<Observation<number>>;
|
|
135
|
-
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
136
|
-
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
137
|
-
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
138
|
-
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
139
|
-
(topic: 'presentation', app: string): Promise<Observation<unknown>>;
|
|
140
|
-
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
141
|
-
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
142
|
-
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
143
|
-
(topic: 'figures'): Promise<Observation<FiguresResult>>;
|
|
144
|
-
(topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
|
|
145
|
-
};
|
|
146
|
-
reauthorize(): Promise<void>;
|
|
147
|
-
};
|
|
148
|
-
export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents' | 'figures' | 'read';
|
|
149
|
-
export type ReadinessPort = {
|
|
150
|
-
readonly target: string;
|
|
151
|
-
readonly code: CodeAvailability;
|
|
152
|
-
};
|
|
153
|
-
export type ComposedRuntime = RuntimeView & {
|
|
154
|
-
seed(entry: EntrySeed): void;
|
|
155
|
-
stop(): Promise<void>;
|
|
156
|
-
persisted(answer: Persistence): void;
|
|
157
|
-
within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
14
|
+
storeOnNeed?: boolean;
|
|
158
15
|
};
|
|
159
16
|
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
160
|
-
export {};
|
|
161
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":"
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAI/E,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;AAGrE,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,CAsGzE"}
|