@agentshouse/mdruntime 0.1.0-c38dcfe165d81 → 0.1.0-c38e1bde25d7f
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 +151 -78
- 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/binary.d.ts +4 -0
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +9 -2
- package/dist/bootstrap.d.ts +9 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +204 -86
- 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 +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 +37 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -62
- 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 +7 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +218 -83
- package/dist/connection.d.ts +6 -142
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +113 -5024
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +149 -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 +64 -45
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +998 -883
- 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 +20 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +14 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +47 -16
- 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 +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 +25 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +109 -26
- package/dist/house-query.d.ts +18 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +54 -0
- package/dist/index.d.ts +37 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -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 +8 -6
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +110 -31
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts +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 +20 -4
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +170 -36
- package/dist/memory.d.ts +11 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +133 -32
- package/dist/messages.d.ts +38 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +105 -25
- 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 +5 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -11
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +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 +28 -5
- 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 +6 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +36 -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 +46 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +344 -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 +10 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +30 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +117 -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 +20 -9
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +323 -120
- package/dist/react.d.ts +18 -2
- 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 +20 -5
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -10
- 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 +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +40 -9
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +9 -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 +10 -16
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +65 -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 +31 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +278 -68
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +222 -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 +15 -5
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +51 -55
- 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 +43 -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 +457 -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 +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 +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 +116 -141
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +174 -360
- package/dist/stored.d.ts +80 -35
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +410 -120
- 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 +112 -62
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +192 -267
- 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 +6 -12
- package/dist/wire.d.ts +81 -7
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +31 -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/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/job.d.ts +0 -14
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -28
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/compile.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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
|
-
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
|
}
|
|
10
|
-
function within(alias, path) {
|
|
11
|
+
export function within(alias, path) {
|
|
11
12
|
return fragment(`(${alias}.path = ? OR (${alias}.path >= ? AND ${alias}.path < ?))`, [
|
|
12
13
|
path,
|
|
13
14
|
`${path}/`,
|
|
@@ -63,11 +64,9 @@ function reached(bound, alias) {
|
|
|
63
64
|
function related(bound, plan) {
|
|
64
65
|
const parts = [];
|
|
65
66
|
if (plan.hop !== null) {
|
|
66
|
-
parts.push(
|
|
67
|
-
fragment(`
|
|
68
|
-
grouped(
|
|
69
|
-
fragment('AND'),
|
|
70
|
-
grouped(all([sql.scoped('m', plan.hop), reached(bound, 'm')])),
|
|
67
|
+
parts.push(sql.hopped('d', plan.hop, (link, document) => joined([
|
|
68
|
+
fragment(`replica_entries ${document} ON ${document}.key = d.key AND ${document}.path = ${link}.target AND ${VISIBLE(document)} AND`),
|
|
69
|
+
grouped(reached(bound, document)),
|
|
71
70
|
], ' ')));
|
|
72
71
|
}
|
|
73
72
|
if (plan.backlinks !== null) {
|
|
@@ -116,7 +115,18 @@ const GROUP_TIES = {
|
|
|
116
115
|
locale: undefined,
|
|
117
116
|
localeOptions: undefined,
|
|
118
117
|
};
|
|
119
|
-
|
|
118
|
+
const GREATEST = { ...GROUP_ORDER, direction: 'desc', nulls: 'last' };
|
|
119
|
+
const TIMES = {
|
|
120
|
+
created: { value: 'd.created', instant: 'd.created_instant' },
|
|
121
|
+
updated: { value: "(d.change ->> '$.time')", instant: 'd.changed_instant' },
|
|
122
|
+
};
|
|
123
|
+
function subfolderOf(column, prefix) {
|
|
124
|
+
const root = prefix ?? '';
|
|
125
|
+
const base = root === '' ? '' : `${root}/`;
|
|
126
|
+
const rest = `substr(${column}, length(?) + 1)`;
|
|
127
|
+
return fragment(`(CASE WHEN ${column} = ? THEN NULL WHEN instr(${rest}, '/') = 0 THEN ${column} ELSE ? || substr(${rest}, 1, instr(${rest}, '/') - 1) END)`, [root, base, base, base, base]);
|
|
128
|
+
}
|
|
129
|
+
function keyTerm(key, ordering, index, prefix) {
|
|
120
130
|
if (key.of === 'field') {
|
|
121
131
|
const alias = `o${index}`;
|
|
122
132
|
return {
|
|
@@ -133,13 +143,37 @@ function keyTerm(key, ordering, index) {
|
|
|
133
143
|
], ''),
|
|
134
144
|
};
|
|
135
145
|
}
|
|
146
|
+
if (key.of === 'size') {
|
|
147
|
+
return {
|
|
148
|
+
term: {
|
|
149
|
+
ordering,
|
|
150
|
+
kind: fragment("(CASE WHEN d.bytes IS NULL THEN 'null' ELSE 'number' END)"),
|
|
151
|
+
value: fragment('d.bytes'),
|
|
152
|
+
},
|
|
153
|
+
join: null,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (key.of === 'created' || key.of === 'updated') {
|
|
157
|
+
const { value, instant } = TIMES[key.of];
|
|
158
|
+
return {
|
|
159
|
+
term: {
|
|
160
|
+
ordering,
|
|
161
|
+
kind: fragment(`(CASE WHEN ${value} IS NULL THEN 'null' ELSE 'string' END)`),
|
|
162
|
+
value: fragment(value),
|
|
163
|
+
instant: fragment(instant),
|
|
164
|
+
},
|
|
165
|
+
join: null,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
136
168
|
const expression = key.of === 'room'
|
|
137
169
|
? located('d')
|
|
138
170
|
: key.of === 'path'
|
|
139
171
|
? fragment('d.path')
|
|
140
172
|
: key.of === 'type'
|
|
141
173
|
? fragment('d.type')
|
|
142
|
-
:
|
|
174
|
+
: key.of === 'subfolder'
|
|
175
|
+
? subfolderOf('d.folder', prefix)
|
|
176
|
+
: fragment('d.folder');
|
|
143
177
|
return {
|
|
144
178
|
term: {
|
|
145
179
|
ordering,
|
|
@@ -160,16 +194,17 @@ function decoded(kind, value) {
|
|
|
160
194
|
return JSON.parse(value);
|
|
161
195
|
return null;
|
|
162
196
|
}
|
|
197
|
+
function sortedOf(kind, value, instant) {
|
|
198
|
+
return sql.sortValue(kind, decoded(kind, value), instant);
|
|
199
|
+
}
|
|
163
200
|
function sortedValue(row, index) {
|
|
164
|
-
|
|
165
|
-
return sql.sortValue(kind, decoded(kind, row[`v${index}`]), row[`i${index}`]);
|
|
201
|
+
return sortedOf(row[`k${index}`], row[`v${index}`], row[`i${index}`]);
|
|
166
202
|
}
|
|
167
203
|
function decodedKey(key, row, index) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
return row[`v${index}`] ?? null;
|
|
204
|
+
const kind = row[`k${index}`];
|
|
205
|
+
if (key.of === 'field' && (kind === null || kind === undefined))
|
|
206
|
+
return undefined;
|
|
207
|
+
return sortedValue(row, index);
|
|
173
208
|
}
|
|
174
209
|
function instantOf(term) {
|
|
175
210
|
return term.instant ?? fragment('NULL');
|
|
@@ -274,11 +309,20 @@ function sectionsOf(sections, names) {
|
|
|
274
309
|
return sections;
|
|
275
310
|
return Object.fromEntries(names.flatMap((name) => (Object.hasOwn(sections, name) ? [[name, sections[name]]] : [])));
|
|
276
311
|
}
|
|
277
|
-
function
|
|
312
|
+
function freeParts(room, path, type, content) {
|
|
313
|
+
const definitions = room.composition === undefined ? undefined : definitionsAt(room.composition, path);
|
|
314
|
+
const definition = definitions?.(type === UNTYPED ? undefined : type);
|
|
315
|
+
if (definition === undefined && type !== UNTYPED)
|
|
316
|
+
return null;
|
|
317
|
+
const read = parse(content, path, definition);
|
|
318
|
+
return read.ok ? read.document : null;
|
|
319
|
+
}
|
|
320
|
+
function documentOf(shape, queried, row, linked) {
|
|
321
|
+
const room = queried.locator;
|
|
278
322
|
const path = row.path;
|
|
279
323
|
const type = row.type;
|
|
280
|
-
const fileId = row.file_id
|
|
281
|
-
const revision = row.revision
|
|
324
|
+
const fileId = row.file_id;
|
|
325
|
+
const revision = row.revision;
|
|
282
326
|
if (type === null) {
|
|
283
327
|
const binary = row.binary === null ? null : JSON.parse(row.binary);
|
|
284
328
|
const content = row.content ?? null;
|
|
@@ -291,12 +335,15 @@ function documentOf(shape, room, row, linked) {
|
|
|
291
335
|
binaryFile: binaryRecord(path, binary, revision ?? undefined),
|
|
292
336
|
}),
|
|
293
337
|
...(shape.markdown && content !== null ? { markdown: content } : {}),
|
|
338
|
+
...(shape.change ? { change: changeOf(row) } : {}),
|
|
294
339
|
...(shape.fileId ? { fileId } : {}),
|
|
295
340
|
...(shape.revision ? { revision } : {}),
|
|
341
|
+
...heldFacts(shape, row),
|
|
296
342
|
};
|
|
297
343
|
}
|
|
298
|
-
const
|
|
299
|
-
|
|
344
|
+
const body = shape.sections !== null || shape.preamble
|
|
345
|
+
? freeParts(queried, path, type, row.content)
|
|
346
|
+
: null;
|
|
300
347
|
const fields = JSON.parse(row.fields ?? '{}');
|
|
301
348
|
return {
|
|
302
349
|
room,
|
|
@@ -315,13 +362,19 @@ function documentOf(shape, room, row, linked) {
|
|
|
315
362
|
...(shape.preamble && body !== null ? { preamble: body.preamble } : {}),
|
|
316
363
|
...(shape.markdown ? { markdown: row.content } : {}),
|
|
317
364
|
...(shape.backlinks ? { backlinks: linked.get(documentKey(room, path)) ?? [] } : {}),
|
|
318
|
-
...(shape.change
|
|
319
|
-
? {
|
|
320
|
-
change: row.change === null ? null : JSON.parse(row.change),
|
|
321
|
-
}
|
|
322
|
-
: {}),
|
|
365
|
+
...(shape.change ? { change: changeOf(row) } : {}),
|
|
323
366
|
...(shape.fileId ? { fileId } : {}),
|
|
324
367
|
...(shape.revision ? { revision } : {}),
|
|
368
|
+
...heldFacts(shape, row),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function changeOf(row) {
|
|
372
|
+
return row.change === null ? null : JSON.parse(row.change);
|
|
373
|
+
}
|
|
374
|
+
function heldFacts(shape, row) {
|
|
375
|
+
return {
|
|
376
|
+
...(shape.size ? { size: row.bytes === null ? null : Number(row.bytes) } : {}),
|
|
377
|
+
...(shape.created ? { created: row.created } : {}),
|
|
325
378
|
};
|
|
326
379
|
}
|
|
327
380
|
function backlinksOf(connection, bound, rows) {
|
|
@@ -333,8 +386,8 @@ function backlinksOf(connection, bound, rows) {
|
|
|
333
386
|
held.push(row.path);
|
|
334
387
|
byKey.set(key, held);
|
|
335
388
|
}
|
|
389
|
+
const reach = reached(bound, 's');
|
|
336
390
|
for (const [key, targets] of byKey) {
|
|
337
|
-
const reach = reached(bound, 's');
|
|
338
391
|
const room = bound.rooms.find((one) => one.key === key).locator;
|
|
339
392
|
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]);
|
|
340
393
|
for (const row of found) {
|
|
@@ -347,28 +400,25 @@ function backlinksOf(connection, bound, rows) {
|
|
|
347
400
|
return linked;
|
|
348
401
|
}
|
|
349
402
|
function documents(connection, bound, plan, shape, budget) {
|
|
350
|
-
const terms = shape.orderBy.map(({ key, options }, index) => keyTerm(key, orderingOf(options), index));
|
|
403
|
+
const terms = shape.orderBy.map(({ key, options }, index) => keyTerm(key, orderingOf(options), index, plan.root.pathPrefix));
|
|
351
404
|
const filter = filtered(bound, plan);
|
|
352
405
|
const cursor = plan.after?.values ?? null;
|
|
353
406
|
const room = located('d');
|
|
354
|
-
const
|
|
407
|
+
const after = cursor === null
|
|
355
408
|
? null
|
|
356
409
|
: (() => {
|
|
357
410
|
const key = cursor[shape.orderBy.length];
|
|
358
|
-
return any([
|
|
411
|
+
return sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), any([
|
|
359
412
|
fragment(`${room.sql} > ?`, [...room.bind, roomOfKey(key)]),
|
|
360
413
|
fragment(`${room.sql} = ? AND d.path > ?`, [
|
|
361
414
|
...room.bind,
|
|
362
415
|
roomOfKey(key),
|
|
363
416
|
pathOfKey(key),
|
|
364
417
|
]),
|
|
365
|
-
]);
|
|
418
|
+
]));
|
|
366
419
|
})();
|
|
367
|
-
const after = cursor === null || tie === null
|
|
368
|
-
? null
|
|
369
|
-
: sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), tie);
|
|
370
420
|
const selected = joined([
|
|
371
|
-
fragment('SELECT d.id, d.key, d.path, d.type, d.binary, d.revision, d.fields, d.change, d.file_id'),
|
|
421
|
+
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'),
|
|
372
422
|
...terms.map(({ term }, index) => joined([
|
|
373
423
|
fragment(`, ${term.kind.sql} AS k${index}`, term.kind.bind),
|
|
374
424
|
fragment(`, ${term.value.sql} AS v${index}`, term.value.bind),
|
|
@@ -387,8 +437,9 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
387
437
|
const kept = bodied(shape) ? withContent(connection, windowed, budget) : windowed;
|
|
388
438
|
const cut = kept.length;
|
|
389
439
|
const roomOf = new Map(bound.rooms.map(({ key, locator }) => [key, locator]));
|
|
440
|
+
const queried = new Map(bound.rooms.map((one) => [one.key, one]));
|
|
390
441
|
const linked = shape.backlinks ? backlinksOf(connection, bound, kept) : new Map();
|
|
391
|
-
const found = kept.map((row) => documentOf(shape,
|
|
442
|
+
const found = kept.map((row) => documentOf(shape, queried.get(Number(row.key)), row, linked));
|
|
392
443
|
const last = kept.at(-1);
|
|
393
444
|
const cursorAt = (row) => cursorOf([
|
|
394
445
|
...shape.orderBy.map(({ key }, index) => decodedKey(key, row, index)),
|
|
@@ -437,16 +488,18 @@ function withContent(connection, rows, budget) {
|
|
|
437
488
|
.map((row) => [row.id, row.content]));
|
|
438
489
|
return kept.map((row) => ({ ...row, content: held.get(row.id) ?? null }));
|
|
439
490
|
}
|
|
440
|
-
function storedFolders(bound, plan) {
|
|
491
|
+
function storedFolders(bound, plan, subfolder) {
|
|
441
492
|
if (plan.paths !== null || plan.fileIds !== null)
|
|
442
493
|
return null;
|
|
443
494
|
if (plan.hop !== null || plan.backlinks !== null)
|
|
444
495
|
return null;
|
|
496
|
+
if (subfolder && plan.folder !== null)
|
|
497
|
+
return null;
|
|
445
498
|
const whole = bound.rooms.filter(({ locator }) => bound.reach === null || bound.reach.rooms.includes(locator));
|
|
446
499
|
if (whole.length === 0)
|
|
447
500
|
return null;
|
|
448
501
|
const keys = whole.map(({ key }) => key);
|
|
449
|
-
const prefix = plan.root.pathPrefix;
|
|
502
|
+
const prefix = plan.root.pathPrefix ?? '';
|
|
450
503
|
const outside = (bound.reach?.areas ?? []).flatMap((area) => {
|
|
451
504
|
const key = bound.keys.get(area.room);
|
|
452
505
|
if (key === undefined)
|
|
@@ -454,27 +507,51 @@ function storedFolders(bound, plan) {
|
|
|
454
507
|
const fence = fenced('f', key, area, true);
|
|
455
508
|
return [fragment(`NOT ${grouped(fence).sql}`, fence.bind)];
|
|
456
509
|
});
|
|
510
|
+
const under = prefix === ''
|
|
511
|
+
? subfolder
|
|
512
|
+
? [fragment("f.path <> ''")]
|
|
513
|
+
: []
|
|
514
|
+
: [
|
|
515
|
+
subfolder
|
|
516
|
+
? fragment('(f.path >= ? AND f.path < ?)', [`${prefix}/`, `${prefix}0`])
|
|
517
|
+
: within('f', prefix),
|
|
518
|
+
];
|
|
457
519
|
return all([
|
|
458
520
|
fragment(`f.key IN ${listed(keys).sql} AND f.layer = 0 AND f.present = 1`, keys),
|
|
459
521
|
...outside,
|
|
460
|
-
...
|
|
461
|
-
|
|
462
|
-
: [
|
|
463
|
-
fragment('(f.path = ? OR (f.path >= ? AND f.path < ?))', [
|
|
464
|
-
prefix,
|
|
465
|
-
`${prefix}/`,
|
|
466
|
-
`${prefix}0`,
|
|
467
|
-
]),
|
|
468
|
-
]),
|
|
522
|
+
...under,
|
|
523
|
+
...(plan.outside ?? []).map((folder) => fragment(`NOT ${within('f', folder).sql}`, within('f', folder).bind)),
|
|
469
524
|
...(plan.folder === null ? [] : [fragment('f.path = ?', [plan.folder])]),
|
|
470
525
|
]);
|
|
471
526
|
}
|
|
527
|
+
const SIZES = [
|
|
528
|
+
'CASE WHEN d.binary IS NULL THEN 1 ELSE 0 END AS dn',
|
|
529
|
+
'CASE WHEN d.binary IS NULL THEN d.bytes ELSE 0 END AS ds',
|
|
530
|
+
'CASE WHEN d.binary IS NULL THEN 0 ELSE 1 END AS fn',
|
|
531
|
+
'CASE WHEN d.binary IS NULL THEN 0 ELSE d.bytes END AS fs',
|
|
532
|
+
];
|
|
533
|
+
const LATEST = "d.changed_instant || ' ' || (d.change ->> '$.time') AS u";
|
|
534
|
+
function greatestTerm(ordering) {
|
|
535
|
+
return { ordering, kind: fragment('gk'), value: fragment('gv'), instant: fragment('gi') };
|
|
536
|
+
}
|
|
537
|
+
function latestOf(held) {
|
|
538
|
+
if (typeof held !== 'string')
|
|
539
|
+
return null;
|
|
540
|
+
return held.slice(held.indexOf(' ') + 1);
|
|
541
|
+
}
|
|
472
542
|
function groups(connection, bound, plan, shape) {
|
|
543
|
+
const prefix = plan.root.pathPrefix;
|
|
473
544
|
const keyed = shape.groupBy.map((key, index) => {
|
|
474
|
-
const { term, join } = keyTerm(key, GROUP_ORDER, index);
|
|
545
|
+
const { term, join } = keyTerm(key, GROUP_ORDER, index, prefix);
|
|
475
546
|
const kind = fragment(`COALESCE(${term.kind.sql}, 'null')`, term.kind.bind);
|
|
476
547
|
return { term: { ...term, kind }, join };
|
|
477
548
|
});
|
|
549
|
+
const ordering = shape.orderBy.map(({ by }) => by);
|
|
550
|
+
const sized = shape.size || ordering.includes('size');
|
|
551
|
+
const dated = shape.updated || ordering.includes('updated');
|
|
552
|
+
const greatest = shape.greatest === null
|
|
553
|
+
? null
|
|
554
|
+
: keyTerm({ of: 'field', field: shape.greatest }, GREATEST, keyed.length, prefix);
|
|
478
555
|
const filter = filtered(bound, plan);
|
|
479
556
|
const inner = joined([
|
|
480
557
|
fragment('SELECT '),
|
|
@@ -483,57 +560,107 @@ function groups(connection, bound, plan, shape) {
|
|
|
483
560
|
fragment(`, ${term.value.sql} AS v${index}`, term.value.bind),
|
|
484
561
|
fragment(`, ${instantOf(term).sql} AS i${index}`, instantOf(term).bind),
|
|
485
562
|
], '')), ', '),
|
|
486
|
-
fragment(', 1 AS n
|
|
487
|
-
...
|
|
563
|
+
fragment(['', '1 AS n', ...(sized ? SIZES : []), ...(dated ? [LATEST] : [])].join(', ')),
|
|
564
|
+
...(greatest === null
|
|
565
|
+
? []
|
|
566
|
+
: [
|
|
567
|
+
fragment(`, ${greatest.term.kind.sql} AS gk`, greatest.term.kind.bind),
|
|
568
|
+
fragment(`, ${greatest.term.value.sql} AS gv`, greatest.term.value.bind),
|
|
569
|
+
fragment(`, ${instantOf(greatest.term).sql} AS gi`, instantOf(greatest.term).bind),
|
|
570
|
+
]),
|
|
571
|
+
fragment(' FROM replica_entries d'),
|
|
572
|
+
...[...keyed, ...(greatest === null ? [] : [greatest])].flatMap(({ join }) => join === null ? [] : [fragment(' '), join]),
|
|
488
573
|
fragment(' WHERE '),
|
|
489
574
|
filter,
|
|
490
575
|
], '');
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
576
|
+
const only = shape.groupBy.length === 1 ? shape.groupBy[0].of : null;
|
|
577
|
+
const subfolder = only === 'subfolder';
|
|
578
|
+
const folders = only === 'folder' || subfolder ? storedFolders(bound, plan, subfolder) : null;
|
|
579
|
+
const folderKey = subfolder ? subfolderOf('f.path', prefix) : fragment('f.path');
|
|
580
|
+
const zeros = [
|
|
581
|
+
...(sized ? ['0', '0', '0', '0'] : []),
|
|
582
|
+
...(dated ? ['NULL'] : []),
|
|
583
|
+
...(greatest === null ? [] : ['NULL', 'NULL', 'NULL']),
|
|
584
|
+
];
|
|
494
585
|
const source = folders === null
|
|
495
586
|
? inner
|
|
496
587
|
: joined([
|
|
497
588
|
inner,
|
|
498
|
-
fragment(
|
|
589
|
+
fragment(` UNION ALL SELECT 'string' AS k0, ${folderKey.sql} AS v0, NULL AS i0, 0 AS n${zeros.map((one) => `, ${one}`).join('')} FROM replica_folders f WHERE `, folderKey.bind),
|
|
499
590
|
folders,
|
|
500
591
|
], '');
|
|
501
|
-
const columns = keyed
|
|
502
|
-
.map((_, index) => `k${index}, min(v${index}) AS v${index}, i${index}`)
|
|
503
|
-
.join(', ');
|
|
504
592
|
const held = keyed
|
|
505
593
|
.map((_, index) => `k${index}, i${index}, CASE WHEN i${index} IS NULL THEN v${index} END`)
|
|
506
594
|
.join(', ');
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
595
|
+
const ranked = greatest === null
|
|
596
|
+
? source
|
|
597
|
+
: joined([
|
|
598
|
+
fragment(`SELECT *, ROW_NUMBER() OVER (PARTITION BY ${held} ORDER BY `),
|
|
599
|
+
sql.sorted(bound.collate, greatestTerm(GREATEST)),
|
|
600
|
+
fragment(', gv) AS gr FROM ('),
|
|
601
|
+
source,
|
|
602
|
+
fragment(')'),
|
|
603
|
+
], '');
|
|
604
|
+
const columns = [
|
|
605
|
+
...keyed.map((_, index) => `k${index}, min(v${index}) AS v${index}, i${index}`),
|
|
606
|
+
'sum(n) AS n',
|
|
607
|
+
...(sized ? ['sum(dn) AS dn', 'sum(ds) AS ds', 'sum(fn) AS fn', 'sum(fs) AS fs'] : []),
|
|
608
|
+
...(dated ? ['max(u) AS u'] : []),
|
|
609
|
+
...(greatest === null
|
|
610
|
+
? []
|
|
611
|
+
: ['gk', 'gv', 'gi'].map((column) => `min(CASE WHEN gr = 1 THEN ${column} END) AS ${column}`)),
|
|
612
|
+
].join(', ');
|
|
613
|
+
const outer = (index, order) => ({
|
|
614
|
+
ordering: order,
|
|
514
615
|
kind: fragment(`k${index}`),
|
|
515
616
|
value: fragment(`v${index}`),
|
|
516
617
|
});
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
618
|
+
const termOf = (by, order) => {
|
|
619
|
+
if (by === 'count')
|
|
620
|
+
return { ordering: order, kind: fragment("'number'"), value: fragment('n') };
|
|
621
|
+
if (by === 'size') {
|
|
622
|
+
return { ordering: order, kind: fragment("'number'"), value: fragment('(ds + fs)') };
|
|
623
|
+
}
|
|
624
|
+
if (by === 'updated') {
|
|
625
|
+
return {
|
|
626
|
+
ordering: order,
|
|
627
|
+
kind: fragment("(CASE WHEN u IS NULL THEN 'null' ELSE 'string' END)"),
|
|
628
|
+
value: fragment("substr(u, instr(u, ' ') + 1)"),
|
|
629
|
+
instant: fragment("substr(u, 1, instr(u, ' ') - 1)"),
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
if (by === 'greatest')
|
|
633
|
+
return greatestTerm(order);
|
|
634
|
+
return { ...outer(by, order), instant: fragment(`i${by}`) };
|
|
635
|
+
};
|
|
636
|
+
const valueOf = (row, by) => {
|
|
637
|
+
if (by === 'count')
|
|
638
|
+
return Number(row.n);
|
|
639
|
+
if (by === 'size')
|
|
640
|
+
return Number(row.ds) + Number(row.fs);
|
|
641
|
+
if (by === 'updated') {
|
|
642
|
+
const text = latestOf(row.u);
|
|
643
|
+
return text === null ? null : sql.sortValue('string', text, row.u.split(' ')[0]);
|
|
644
|
+
}
|
|
645
|
+
if (by === 'greatest')
|
|
646
|
+
return sortedOf(row.gk, row.gv, row.gi);
|
|
647
|
+
return sortedValue(row, by);
|
|
648
|
+
};
|
|
649
|
+
const ordered = shape.orderBy.map(({ by, direction, nulls }) => termOf(by, { ...GROUP_ORDER, direction, nulls: nulls ?? GROUP_ORDER.nulls }));
|
|
520
650
|
const ties = keyed.flatMap((_, index) => [
|
|
521
651
|
{ ...outer(index, GROUP_TIES), total: true },
|
|
522
652
|
{ ordering: GROUP_TIES, kind: fragment("'string'"), value: fragment(`k${index}`) },
|
|
523
653
|
]);
|
|
524
654
|
const cursor = plan.after?.values ?? null;
|
|
525
|
-
const
|
|
655
|
+
const after = cursor === null
|
|
526
656
|
? null
|
|
527
|
-
:
|
|
528
|
-
value,
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
.slice(0, -1)
|
|
535
|
-
.map((term, index) => sql.beyond(bound.collate, term, tieValues[index])), sql.beyond(bound.collate, ties.at(-1), tieValues.at(-1)).beyond));
|
|
536
|
-
const grouping = joined([fragment(`SELECT ${columns}, sum(n) AS n FROM (`), source, fragment(`) GROUP BY ${held}`)], '');
|
|
657
|
+
: (() => {
|
|
658
|
+
const tieValues = cursor[shape.orderBy.length].flatMap((value) => [value, heldKind(value ?? null)]);
|
|
659
|
+
return sql.following(ordered.map((term, index) => sql.beyond(bound.collate, term, cursor[index])), sql.following(ties
|
|
660
|
+
.slice(0, -1)
|
|
661
|
+
.map((term, index) => sql.beyond(bound.collate, term, tieValues[index])), sql.beyond(bound.collate, ties.at(-1), tieValues.at(-1)).beyond));
|
|
662
|
+
})();
|
|
663
|
+
const grouping = joined([fragment(`SELECT ${columns} FROM (`), ranked, fragment(`) GROUP BY ${held}`)], '');
|
|
537
664
|
const windowed = joined([
|
|
538
665
|
fragment('SELECT * FROM ('),
|
|
539
666
|
grouping,
|
|
@@ -546,16 +673,24 @@ function groups(connection, bound, plan, shape) {
|
|
|
546
673
|
const rows = connection.rows(windowed.sql, windowed.bind);
|
|
547
674
|
const kept = plan.limit === null ? rows : rows.slice(0, plan.limit);
|
|
548
675
|
const keyOf = (row) => keyed.map((_, index) => decoded(row[`k${index}`], row[`v${index}`]));
|
|
549
|
-
const found = kept.map((row) => ({
|
|
676
|
+
const found = kept.map((row) => ({
|
|
677
|
+
key: keyOf(row),
|
|
678
|
+
count: Number(row.n),
|
|
679
|
+
...(shape.size
|
|
680
|
+
? {
|
|
681
|
+
documents: { count: Number(row.dn), size: Number(row.ds) },
|
|
682
|
+
files: { count: Number(row.fn), size: Number(row.fs) },
|
|
683
|
+
}
|
|
684
|
+
: {}),
|
|
685
|
+
...(shape.updated ? { updated: latestOf(row.u) } : {}),
|
|
686
|
+
...(shape.greatest === null ? {} : { greatest: decoded(row.gk, row.gv) }),
|
|
687
|
+
}));
|
|
550
688
|
const last = kept.at(-1);
|
|
551
689
|
const next = plan.limit === null || rows.length <= plan.limit
|
|
552
690
|
? undefined
|
|
553
691
|
: last === undefined
|
|
554
692
|
? (plan.after?.text ?? FROM_START)
|
|
555
|
-
: cursorOf([
|
|
556
|
-
...shape.orderBy.map(({ by }) => by === 'count' ? Number(last.n) : sortedValue(last, by)),
|
|
557
|
-
keyOf(last),
|
|
558
|
-
]);
|
|
693
|
+
: cursorOf([...shape.orderBy.map(({ by }) => valueOf(last, by)), keyOf(last)]);
|
|
559
694
|
const total = plan.total
|
|
560
695
|
? Number(connection.rows(joined([fragment('SELECT count(*) AS held FROM ('), grouping, fragment(')')], '').sql, grouping.bind)[0].held)
|
|
561
696
|
: undefined;
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,53 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type TypesResult } from './model.js';
|
|
3
|
-
import { type Observation } from './observation.js';
|
|
4
|
-
import { type DocumentResult, type GroupResult, type PendingResult } from './query.js';
|
|
5
|
-
import { type EntrySeed } from './seed.js';
|
|
6
|
-
import { type SearchRequest, type SearchResult } from './search.js';
|
|
7
|
-
import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
|
|
8
|
-
import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
9
|
-
import { type WrittenBy } from './change.js';
|
|
10
|
-
import type { Open } from './open.js';
|
|
11
|
-
import { type AttachAnswer, type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HeldShownAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
|
|
12
|
-
import { type Recovery } from './recovery.js';
|
|
13
|
-
import { type SaveRefusal } from './save.js';
|
|
14
|
-
import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
|
|
15
|
-
import { type SyncStatus } from './status.js';
|
|
1
|
+
import type { Adapter, Authorization } from './adapter.js';
|
|
16
2
|
import { type RuntimeShell } from './durability.js';
|
|
17
|
-
import { type
|
|
18
|
-
import type
|
|
19
|
-
import { type
|
|
20
|
-
export type AppTypedSelection = {
|
|
21
|
-
roots: readonly string[];
|
|
22
|
-
model: TypesResult;
|
|
23
|
-
};
|
|
24
|
-
export type AppRoom = {
|
|
25
|
-
name: string;
|
|
26
|
-
locator: string;
|
|
27
|
-
handle: string;
|
|
28
|
-
operations: import('./adapter.js').OperationScopes;
|
|
29
|
-
replica: import('./adapter.js').ReplicaAdmission;
|
|
30
|
-
model: TypesResult;
|
|
31
|
-
typedSelection: AppTypedSelection | null;
|
|
32
|
-
providerOwnedPaths: readonly string[];
|
|
33
|
-
roomVersion: string | null;
|
|
34
|
-
documents: number;
|
|
35
|
-
synchronizationAvailable: boolean;
|
|
36
|
-
refusal: ProviderRefusal | null;
|
|
37
|
-
locked: boolean;
|
|
38
|
-
};
|
|
39
|
-
export type RoomSchemas = {
|
|
40
|
-
collection: TypesResult;
|
|
41
|
-
typedSelection: TypesResult | null;
|
|
42
|
-
};
|
|
43
|
-
type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
|
|
44
|
-
export type ConnectionRefusalCode = Open<RefusalReason>;
|
|
45
|
-
export type ConnectionRefusal = {
|
|
46
|
-
code: ConnectionRefusalCode;
|
|
47
|
-
retryable: boolean;
|
|
48
|
-
reauthorizationOffered: boolean;
|
|
49
|
-
refusal: ProviderRefusal | null;
|
|
50
|
-
};
|
|
3
|
+
import { type Recovery } from './recovery.js';
|
|
4
|
+
import { type RuntimeDatabase } from './store.js';
|
|
5
|
+
import { type ComposedRuntime } from './surface.js';
|
|
51
6
|
export type MdRuntimeOptions = {
|
|
52
7
|
adapter: Adapter;
|
|
53
8
|
shell: RuntimeShell;
|
|
@@ -55,99 +10,8 @@ export type MdRuntimeOptions = {
|
|
|
55
10
|
authorization?: Authorization;
|
|
56
11
|
signal?: AbortSignal;
|
|
57
12
|
recovery?: Recovery;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export type SaveResult = {
|
|
61
|
-
outcome: 'saved';
|
|
62
|
-
identifier: string;
|
|
63
|
-
} | ({
|
|
64
|
-
outcome: 'refused';
|
|
65
|
-
} & SaveRefusal);
|
|
66
|
-
export type SavedRoomDraft = {
|
|
67
|
-
readonly path: string;
|
|
68
|
-
readonly revision: string;
|
|
69
|
-
};
|
|
70
|
-
export type SavedParts = {
|
|
71
|
-
readonly path: string;
|
|
72
|
-
readonly parts: RoomDraftParts;
|
|
73
|
-
};
|
|
74
|
-
export type RoomDraftSurface = {
|
|
75
|
-
list(): Promise<readonly RoomDraft[]>;
|
|
76
|
-
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
77
|
-
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
78
|
-
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
79
|
-
};
|
|
80
|
-
export type PresentationSurface = {
|
|
81
|
-
read(app: string): Promise<unknown>;
|
|
82
|
-
write(app: string, value: unknown): Promise<void>;
|
|
83
|
-
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
84
|
-
};
|
|
85
|
-
export type BinaryFileSurface = {
|
|
86
|
-
read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
|
|
87
|
-
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
88
|
-
show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
|
|
89
|
-
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
90
|
-
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
91
|
-
};
|
|
92
|
-
export type HistoryQuery = {
|
|
93
|
-
revision?: string;
|
|
94
|
-
pageToken?: string;
|
|
95
|
-
};
|
|
96
|
-
export type MdRuntime = {
|
|
97
|
-
loaded(): Promise<void>;
|
|
98
|
-
rooms(): Promise<readonly AppRoom[]>;
|
|
99
|
-
query: {
|
|
100
|
-
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
101
|
-
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
102
|
-
};
|
|
103
|
-
search(request: SearchRequest): Promise<SearchResult>;
|
|
104
|
-
types(locator: string): RoomSchemas;
|
|
105
|
-
roomDraft: RoomDraftSurface;
|
|
106
|
-
conversation: ConversationSurface;
|
|
107
|
-
chatDraft: ChatDraftSurface;
|
|
108
|
-
presentation: PresentationSurface;
|
|
109
|
-
save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
110
|
-
saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
111
|
-
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
112
|
-
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
113
|
-
binaryFile: BinaryFileSurface;
|
|
114
|
-
call(name: string, input: unknown): Promise<CallResult>;
|
|
115
|
-
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
116
|
-
log(): string;
|
|
117
|
-
persistence(): boolean;
|
|
118
|
-
retry(): Promise<void>;
|
|
119
|
-
cleanUp(): Promise<number>;
|
|
120
|
-
observe: {
|
|
121
|
-
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
122
|
-
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
123
|
-
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
124
|
-
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
125
|
-
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
126
|
-
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
127
|
-
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
128
|
-
(topic: 'authority-changes'): Promise<Observation<number>>;
|
|
129
|
-
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
130
|
-
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
131
|
-
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
132
|
-
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
133
|
-
(topic: 'presentation', app: string): Promise<Observation<unknown>>;
|
|
134
|
-
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
135
|
-
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
136
|
-
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
137
|
-
};
|
|
138
|
-
reauthorize(): Promise<void>;
|
|
139
|
-
};
|
|
140
|
-
export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
|
|
141
|
-
export type ReadinessPort = {
|
|
142
|
-
readonly target: string;
|
|
143
|
-
readonly code: CodeAvailability;
|
|
144
|
-
};
|
|
145
|
-
export type ComposedRuntime = RuntimeView & {
|
|
146
|
-
seed(entry: EntrySeed): void;
|
|
147
|
-
stop(): Promise<void>;
|
|
148
|
-
persisted(answer: Persistence): void;
|
|
149
|
-
within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
13
|
+
build?: string;
|
|
14
|
+
storeOnNeed?: boolean;
|
|
150
15
|
};
|
|
151
16
|
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
152
|
-
export {};
|
|
153
17
|
//# sourceMappingURL=connection.d.ts.map
|