@agentshouse/mdruntime 0.1.0-c38dcfe165d81 → 0.1.0-c3a4522b541bd
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 +215 -78
- 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}/`,
|
|
@@ -116,7 +117,18 @@ const GROUP_TIES = {
|
|
|
116
117
|
locale: undefined,
|
|
117
118
|
localeOptions: undefined,
|
|
118
119
|
};
|
|
119
|
-
|
|
120
|
+
const GREATEST = { ...GROUP_ORDER, direction: 'desc', nulls: 'last' };
|
|
121
|
+
const TIMES = {
|
|
122
|
+
created: { value: 'd.created', instant: 'd.created_instant' },
|
|
123
|
+
updated: { value: "(d.change ->> '$.time')", instant: 'd.changed_instant' },
|
|
124
|
+
};
|
|
125
|
+
function subfolderOf(column, prefix) {
|
|
126
|
+
const root = prefix ?? '';
|
|
127
|
+
const base = root === '' ? '' : `${root}/`;
|
|
128
|
+
const rest = `substr(${column}, length(?) + 1)`;
|
|
129
|
+
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]);
|
|
130
|
+
}
|
|
131
|
+
function keyTerm(key, ordering, index, prefix) {
|
|
120
132
|
if (key.of === 'field') {
|
|
121
133
|
const alias = `o${index}`;
|
|
122
134
|
return {
|
|
@@ -133,13 +145,37 @@ function keyTerm(key, ordering, index) {
|
|
|
133
145
|
], ''),
|
|
134
146
|
};
|
|
135
147
|
}
|
|
148
|
+
if (key.of === 'size') {
|
|
149
|
+
return {
|
|
150
|
+
term: {
|
|
151
|
+
ordering,
|
|
152
|
+
kind: fragment("(CASE WHEN d.bytes IS NULL THEN 'null' ELSE 'number' END)"),
|
|
153
|
+
value: fragment('d.bytes'),
|
|
154
|
+
},
|
|
155
|
+
join: null,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (key.of === 'created' || key.of === 'updated') {
|
|
159
|
+
const { value, instant } = TIMES[key.of];
|
|
160
|
+
return {
|
|
161
|
+
term: {
|
|
162
|
+
ordering,
|
|
163
|
+
kind: fragment(`(CASE WHEN ${value} IS NULL THEN 'null' ELSE 'string' END)`),
|
|
164
|
+
value: fragment(value),
|
|
165
|
+
instant: fragment(instant),
|
|
166
|
+
},
|
|
167
|
+
join: null,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
136
170
|
const expression = key.of === 'room'
|
|
137
171
|
? located('d')
|
|
138
172
|
: key.of === 'path'
|
|
139
173
|
? fragment('d.path')
|
|
140
174
|
: key.of === 'type'
|
|
141
175
|
? fragment('d.type')
|
|
142
|
-
:
|
|
176
|
+
: key.of === 'subfolder'
|
|
177
|
+
? subfolderOf('d.folder', prefix)
|
|
178
|
+
: fragment('d.folder');
|
|
143
179
|
return {
|
|
144
180
|
term: {
|
|
145
181
|
ordering,
|
|
@@ -160,16 +196,17 @@ function decoded(kind, value) {
|
|
|
160
196
|
return JSON.parse(value);
|
|
161
197
|
return null;
|
|
162
198
|
}
|
|
199
|
+
function sortedOf(kind, value, instant) {
|
|
200
|
+
return sql.sortValue(kind, decoded(kind, value), instant);
|
|
201
|
+
}
|
|
163
202
|
function sortedValue(row, index) {
|
|
164
|
-
|
|
165
|
-
return sql.sortValue(kind, decoded(kind, row[`v${index}`]), row[`i${index}`]);
|
|
203
|
+
return sortedOf(row[`k${index}`], row[`v${index}`], row[`i${index}`]);
|
|
166
204
|
}
|
|
167
205
|
function decodedKey(key, row, index) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
return row[`v${index}`] ?? null;
|
|
206
|
+
const kind = row[`k${index}`];
|
|
207
|
+
if (key.of === 'field' && (kind === null || kind === undefined))
|
|
208
|
+
return undefined;
|
|
209
|
+
return sortedValue(row, index);
|
|
173
210
|
}
|
|
174
211
|
function instantOf(term) {
|
|
175
212
|
return term.instant ?? fragment('NULL');
|
|
@@ -274,11 +311,20 @@ function sectionsOf(sections, names) {
|
|
|
274
311
|
return sections;
|
|
275
312
|
return Object.fromEntries(names.flatMap((name) => (Object.hasOwn(sections, name) ? [[name, sections[name]]] : [])));
|
|
276
313
|
}
|
|
277
|
-
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;
|
|
278
324
|
const path = row.path;
|
|
279
325
|
const type = row.type;
|
|
280
|
-
const fileId = row.file_id
|
|
281
|
-
const revision = row.revision
|
|
326
|
+
const fileId = row.file_id;
|
|
327
|
+
const revision = row.revision;
|
|
282
328
|
if (type === null) {
|
|
283
329
|
const binary = row.binary === null ? null : JSON.parse(row.binary);
|
|
284
330
|
const content = row.content ?? null;
|
|
@@ -291,12 +337,15 @@ function documentOf(shape, room, row, linked) {
|
|
|
291
337
|
binaryFile: binaryRecord(path, binary, revision ?? undefined),
|
|
292
338
|
}),
|
|
293
339
|
...(shape.markdown && content !== null ? { markdown: content } : {}),
|
|
340
|
+
...(shape.change ? { change: changeOf(row) } : {}),
|
|
294
341
|
...(shape.fileId ? { fileId } : {}),
|
|
295
342
|
...(shape.revision ? { revision } : {}),
|
|
343
|
+
...heldFacts(shape, row),
|
|
296
344
|
};
|
|
297
345
|
}
|
|
298
|
-
const
|
|
299
|
-
|
|
346
|
+
const body = shape.sections !== null || shape.preamble
|
|
347
|
+
? freeParts(queried, path, type, row.content)
|
|
348
|
+
: null;
|
|
300
349
|
const fields = JSON.parse(row.fields ?? '{}');
|
|
301
350
|
return {
|
|
302
351
|
room,
|
|
@@ -315,13 +364,19 @@ function documentOf(shape, room, row, linked) {
|
|
|
315
364
|
...(shape.preamble && body !== null ? { preamble: body.preamble } : {}),
|
|
316
365
|
...(shape.markdown ? { markdown: row.content } : {}),
|
|
317
366
|
...(shape.backlinks ? { backlinks: linked.get(documentKey(room, path)) ?? [] } : {}),
|
|
318
|
-
...(shape.change
|
|
319
|
-
? {
|
|
320
|
-
change: row.change === null ? null : JSON.parse(row.change),
|
|
321
|
-
}
|
|
322
|
-
: {}),
|
|
367
|
+
...(shape.change ? { change: changeOf(row) } : {}),
|
|
323
368
|
...(shape.fileId ? { fileId } : {}),
|
|
324
369
|
...(shape.revision ? { revision } : {}),
|
|
370
|
+
...heldFacts(shape, row),
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function changeOf(row) {
|
|
374
|
+
return row.change === null ? null : JSON.parse(row.change);
|
|
375
|
+
}
|
|
376
|
+
function heldFacts(shape, row) {
|
|
377
|
+
return {
|
|
378
|
+
...(shape.size ? { size: row.bytes === null ? null : Number(row.bytes) } : {}),
|
|
379
|
+
...(shape.created ? { created: row.created } : {}),
|
|
325
380
|
};
|
|
326
381
|
}
|
|
327
382
|
function backlinksOf(connection, bound, rows) {
|
|
@@ -333,8 +388,8 @@ function backlinksOf(connection, bound, rows) {
|
|
|
333
388
|
held.push(row.path);
|
|
334
389
|
byKey.set(key, held);
|
|
335
390
|
}
|
|
391
|
+
const reach = reached(bound, 's');
|
|
336
392
|
for (const [key, targets] of byKey) {
|
|
337
|
-
const reach = reached(bound, 's');
|
|
338
393
|
const room = bound.rooms.find((one) => one.key === key).locator;
|
|
339
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]);
|
|
340
395
|
for (const row of found) {
|
|
@@ -347,28 +402,25 @@ function backlinksOf(connection, bound, rows) {
|
|
|
347
402
|
return linked;
|
|
348
403
|
}
|
|
349
404
|
function documents(connection, bound, plan, shape, budget) {
|
|
350
|
-
const terms = shape.orderBy.map(({ key, options }, index) => keyTerm(key, orderingOf(options), index));
|
|
405
|
+
const terms = shape.orderBy.map(({ key, options }, index) => keyTerm(key, orderingOf(options), index, plan.root.pathPrefix));
|
|
351
406
|
const filter = filtered(bound, plan);
|
|
352
407
|
const cursor = plan.after?.values ?? null;
|
|
353
408
|
const room = located('d');
|
|
354
|
-
const
|
|
409
|
+
const after = cursor === null
|
|
355
410
|
? null
|
|
356
411
|
: (() => {
|
|
357
412
|
const key = cursor[shape.orderBy.length];
|
|
358
|
-
return any([
|
|
413
|
+
return sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), any([
|
|
359
414
|
fragment(`${room.sql} > ?`, [...room.bind, roomOfKey(key)]),
|
|
360
415
|
fragment(`${room.sql} = ? AND d.path > ?`, [
|
|
361
416
|
...room.bind,
|
|
362
417
|
roomOfKey(key),
|
|
363
418
|
pathOfKey(key),
|
|
364
419
|
]),
|
|
365
|
-
]);
|
|
420
|
+
]));
|
|
366
421
|
})();
|
|
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
422
|
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'),
|
|
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'),
|
|
372
424
|
...terms.map(({ term }, index) => joined([
|
|
373
425
|
fragment(`, ${term.kind.sql} AS k${index}`, term.kind.bind),
|
|
374
426
|
fragment(`, ${term.value.sql} AS v${index}`, term.value.bind),
|
|
@@ -387,8 +439,9 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
387
439
|
const kept = bodied(shape) ? withContent(connection, windowed, budget) : windowed;
|
|
388
440
|
const cut = kept.length;
|
|
389
441
|
const roomOf = new Map(bound.rooms.map(({ key, locator }) => [key, locator]));
|
|
442
|
+
const queried = new Map(bound.rooms.map((one) => [one.key, one]));
|
|
390
443
|
const linked = shape.backlinks ? backlinksOf(connection, bound, kept) : new Map();
|
|
391
|
-
const found = kept.map((row) => documentOf(shape,
|
|
444
|
+
const found = kept.map((row) => documentOf(shape, queried.get(Number(row.key)), row, linked));
|
|
392
445
|
const last = kept.at(-1);
|
|
393
446
|
const cursorAt = (row) => cursorOf([
|
|
394
447
|
...shape.orderBy.map(({ key }, index) => decodedKey(key, row, index)),
|
|
@@ -437,16 +490,18 @@ function withContent(connection, rows, budget) {
|
|
|
437
490
|
.map((row) => [row.id, row.content]));
|
|
438
491
|
return kept.map((row) => ({ ...row, content: held.get(row.id) ?? null }));
|
|
439
492
|
}
|
|
440
|
-
function storedFolders(bound, plan) {
|
|
493
|
+
function storedFolders(bound, plan, subfolder) {
|
|
441
494
|
if (plan.paths !== null || plan.fileIds !== null)
|
|
442
495
|
return null;
|
|
443
496
|
if (plan.hop !== null || plan.backlinks !== null)
|
|
444
497
|
return null;
|
|
498
|
+
if (subfolder && plan.folder !== null)
|
|
499
|
+
return null;
|
|
445
500
|
const whole = bound.rooms.filter(({ locator }) => bound.reach === null || bound.reach.rooms.includes(locator));
|
|
446
501
|
if (whole.length === 0)
|
|
447
502
|
return null;
|
|
448
503
|
const keys = whole.map(({ key }) => key);
|
|
449
|
-
const prefix = plan.root.pathPrefix;
|
|
504
|
+
const prefix = plan.root.pathPrefix ?? '';
|
|
450
505
|
const outside = (bound.reach?.areas ?? []).flatMap((area) => {
|
|
451
506
|
const key = bound.keys.get(area.room);
|
|
452
507
|
if (key === undefined)
|
|
@@ -454,27 +509,51 @@ function storedFolders(bound, plan) {
|
|
|
454
509
|
const fence = fenced('f', key, area, true);
|
|
455
510
|
return [fragment(`NOT ${grouped(fence).sql}`, fence.bind)];
|
|
456
511
|
});
|
|
512
|
+
const under = prefix === ''
|
|
513
|
+
? subfolder
|
|
514
|
+
? [fragment("f.path <> ''")]
|
|
515
|
+
: []
|
|
516
|
+
: [
|
|
517
|
+
subfolder
|
|
518
|
+
? fragment('(f.path >= ? AND f.path < ?)', [`${prefix}/`, `${prefix}0`])
|
|
519
|
+
: within('f', prefix),
|
|
520
|
+
];
|
|
457
521
|
return all([
|
|
458
522
|
fragment(`f.key IN ${listed(keys).sql} AND f.layer = 0 AND f.present = 1`, keys),
|
|
459
523
|
...outside,
|
|
460
|
-
...
|
|
461
|
-
|
|
462
|
-
: [
|
|
463
|
-
fragment('(f.path = ? OR (f.path >= ? AND f.path < ?))', [
|
|
464
|
-
prefix,
|
|
465
|
-
`${prefix}/`,
|
|
466
|
-
`${prefix}0`,
|
|
467
|
-
]),
|
|
468
|
-
]),
|
|
524
|
+
...under,
|
|
525
|
+
...(plan.outside ?? []).map((folder) => fragment(`NOT ${within('f', folder).sql}`, within('f', folder).bind)),
|
|
469
526
|
...(plan.folder === null ? [] : [fragment('f.path = ?', [plan.folder])]),
|
|
470
527
|
]);
|
|
471
528
|
}
|
|
529
|
+
const SIZES = [
|
|
530
|
+
'CASE WHEN d.binary IS NULL THEN 1 ELSE 0 END AS dn',
|
|
531
|
+
'CASE WHEN d.binary IS NULL THEN d.bytes ELSE 0 END AS ds',
|
|
532
|
+
'CASE WHEN d.binary IS NULL THEN 0 ELSE 1 END AS fn',
|
|
533
|
+
'CASE WHEN d.binary IS NULL THEN 0 ELSE d.bytes END AS fs',
|
|
534
|
+
];
|
|
535
|
+
const LATEST = "d.changed_instant || ' ' || (d.change ->> '$.time') AS u";
|
|
536
|
+
function greatestTerm(ordering) {
|
|
537
|
+
return { ordering, kind: fragment('gk'), value: fragment('gv'), instant: fragment('gi') };
|
|
538
|
+
}
|
|
539
|
+
function latestOf(held) {
|
|
540
|
+
if (typeof held !== 'string')
|
|
541
|
+
return null;
|
|
542
|
+
return held.slice(held.indexOf(' ') + 1);
|
|
543
|
+
}
|
|
472
544
|
function groups(connection, bound, plan, shape) {
|
|
545
|
+
const prefix = plan.root.pathPrefix;
|
|
473
546
|
const keyed = shape.groupBy.map((key, index) => {
|
|
474
|
-
const { term, join } = keyTerm(key, GROUP_ORDER, index);
|
|
547
|
+
const { term, join } = keyTerm(key, GROUP_ORDER, index, prefix);
|
|
475
548
|
const kind = fragment(`COALESCE(${term.kind.sql}, 'null')`, term.kind.bind);
|
|
476
549
|
return { term: { ...term, kind }, join };
|
|
477
550
|
});
|
|
551
|
+
const ordering = shape.orderBy.map(({ by }) => by);
|
|
552
|
+
const sized = shape.size || ordering.includes('size');
|
|
553
|
+
const dated = shape.updated || ordering.includes('updated');
|
|
554
|
+
const greatest = shape.greatest === null
|
|
555
|
+
? null
|
|
556
|
+
: keyTerm({ of: 'field', field: shape.greatest }, GREATEST, keyed.length, prefix);
|
|
478
557
|
const filter = filtered(bound, plan);
|
|
479
558
|
const inner = joined([
|
|
480
559
|
fragment('SELECT '),
|
|
@@ -483,57 +562,107 @@ function groups(connection, bound, plan, shape) {
|
|
|
483
562
|
fragment(`, ${term.value.sql} AS v${index}`, term.value.bind),
|
|
484
563
|
fragment(`, ${instantOf(term).sql} AS i${index}`, instantOf(term).bind),
|
|
485
564
|
], '')), ', '),
|
|
486
|
-
fragment(', 1 AS n
|
|
487
|
-
...
|
|
565
|
+
fragment(['', '1 AS n', ...(sized ? SIZES : []), ...(dated ? [LATEST] : [])].join(', ')),
|
|
566
|
+
...(greatest === null
|
|
567
|
+
? []
|
|
568
|
+
: [
|
|
569
|
+
fragment(`, ${greatest.term.kind.sql} AS gk`, greatest.term.kind.bind),
|
|
570
|
+
fragment(`, ${greatest.term.value.sql} AS gv`, greatest.term.value.bind),
|
|
571
|
+
fragment(`, ${instantOf(greatest.term).sql} AS gi`, instantOf(greatest.term).bind),
|
|
572
|
+
]),
|
|
573
|
+
fragment(' FROM replica_entries d'),
|
|
574
|
+
...[...keyed, ...(greatest === null ? [] : [greatest])].flatMap(({ join }) => join === null ? [] : [fragment(' '), join]),
|
|
488
575
|
fragment(' WHERE '),
|
|
489
576
|
filter,
|
|
490
577
|
], '');
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
578
|
+
const only = shape.groupBy.length === 1 ? shape.groupBy[0].of : null;
|
|
579
|
+
const subfolder = only === 'subfolder';
|
|
580
|
+
const folders = only === 'folder' || subfolder ? storedFolders(bound, plan, subfolder) : null;
|
|
581
|
+
const folderKey = subfolder ? subfolderOf('f.path', prefix) : fragment('f.path');
|
|
582
|
+
const zeros = [
|
|
583
|
+
...(sized ? ['0', '0', '0', '0'] : []),
|
|
584
|
+
...(dated ? ['NULL'] : []),
|
|
585
|
+
...(greatest === null ? [] : ['NULL', 'NULL', 'NULL']),
|
|
586
|
+
];
|
|
494
587
|
const source = folders === null
|
|
495
588
|
? inner
|
|
496
589
|
: joined([
|
|
497
590
|
inner,
|
|
498
|
-
fragment(
|
|
591
|
+
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
592
|
folders,
|
|
500
593
|
], '');
|
|
501
|
-
const columns = keyed
|
|
502
|
-
.map((_, index) => `k${index}, min(v${index}) AS v${index}, i${index}`)
|
|
503
|
-
.join(', ');
|
|
504
594
|
const held = keyed
|
|
505
595
|
.map((_, index) => `k${index}, i${index}, CASE WHEN i${index} IS NULL THEN v${index} END`)
|
|
506
596
|
.join(', ');
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
597
|
+
const ranked = greatest === null
|
|
598
|
+
? source
|
|
599
|
+
: joined([
|
|
600
|
+
fragment(`SELECT *, ROW_NUMBER() OVER (PARTITION BY ${held} ORDER BY `),
|
|
601
|
+
sql.sorted(bound.collate, greatestTerm(GREATEST)),
|
|
602
|
+
fragment(', gv) AS gr FROM ('),
|
|
603
|
+
source,
|
|
604
|
+
fragment(')'),
|
|
605
|
+
], '');
|
|
606
|
+
const columns = [
|
|
607
|
+
...keyed.map((_, index) => `k${index}, min(v${index}) AS v${index}, i${index}`),
|
|
608
|
+
'sum(n) AS n',
|
|
609
|
+
...(sized ? ['sum(dn) AS dn', 'sum(ds) AS ds', 'sum(fn) AS fn', 'sum(fs) AS fs'] : []),
|
|
610
|
+
...(dated ? ['max(u) AS u'] : []),
|
|
611
|
+
...(greatest === null
|
|
612
|
+
? []
|
|
613
|
+
: ['gk', 'gv', 'gi'].map((column) => `min(CASE WHEN gr = 1 THEN ${column} END) AS ${column}`)),
|
|
614
|
+
].join(', ');
|
|
615
|
+
const outer = (index, order) => ({
|
|
616
|
+
ordering: order,
|
|
514
617
|
kind: fragment(`k${index}`),
|
|
515
618
|
value: fragment(`v${index}`),
|
|
516
619
|
});
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
620
|
+
const termOf = (by, order) => {
|
|
621
|
+
if (by === 'count')
|
|
622
|
+
return { ordering: order, kind: fragment("'number'"), value: fragment('n') };
|
|
623
|
+
if (by === 'size') {
|
|
624
|
+
return { ordering: order, kind: fragment("'number'"), value: fragment('(ds + fs)') };
|
|
625
|
+
}
|
|
626
|
+
if (by === 'updated') {
|
|
627
|
+
return {
|
|
628
|
+
ordering: order,
|
|
629
|
+
kind: fragment("(CASE WHEN u IS NULL THEN 'null' ELSE 'string' END)"),
|
|
630
|
+
value: fragment("substr(u, instr(u, ' ') + 1)"),
|
|
631
|
+
instant: fragment("substr(u, 1, instr(u, ' ') - 1)"),
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
if (by === 'greatest')
|
|
635
|
+
return greatestTerm(order);
|
|
636
|
+
return { ...outer(by, order), instant: fragment(`i${by}`) };
|
|
637
|
+
};
|
|
638
|
+
const valueOf = (row, by) => {
|
|
639
|
+
if (by === 'count')
|
|
640
|
+
return Number(row.n);
|
|
641
|
+
if (by === 'size')
|
|
642
|
+
return Number(row.ds) + Number(row.fs);
|
|
643
|
+
if (by === 'updated') {
|
|
644
|
+
const text = latestOf(row.u);
|
|
645
|
+
return text === null ? null : sql.sortValue('string', text, row.u.split(' ')[0]);
|
|
646
|
+
}
|
|
647
|
+
if (by === 'greatest')
|
|
648
|
+
return sortedOf(row.gk, row.gv, row.gi);
|
|
649
|
+
return sortedValue(row, by);
|
|
650
|
+
};
|
|
651
|
+
const ordered = shape.orderBy.map(({ by, direction, nulls }) => termOf(by, { ...GROUP_ORDER, direction, nulls: nulls ?? GROUP_ORDER.nulls }));
|
|
520
652
|
const ties = keyed.flatMap((_, index) => [
|
|
521
653
|
{ ...outer(index, GROUP_TIES), total: true },
|
|
522
654
|
{ ordering: GROUP_TIES, kind: fragment("'string'"), value: fragment(`k${index}`) },
|
|
523
655
|
]);
|
|
524
656
|
const cursor = plan.after?.values ?? null;
|
|
525
|
-
const
|
|
657
|
+
const after = cursor === null
|
|
526
658
|
? 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}`)], '');
|
|
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
|
+
})();
|
|
665
|
+
const grouping = joined([fragment(`SELECT ${columns} FROM (`), ranked, fragment(`) GROUP BY ${held}`)], '');
|
|
537
666
|
const windowed = joined([
|
|
538
667
|
fragment('SELECT * FROM ('),
|
|
539
668
|
grouping,
|
|
@@ -546,16 +675,24 @@ function groups(connection, bound, plan, shape) {
|
|
|
546
675
|
const rows = connection.rows(windowed.sql, windowed.bind);
|
|
547
676
|
const kept = plan.limit === null ? rows : rows.slice(0, plan.limit);
|
|
548
677
|
const keyOf = (row) => keyed.map((_, index) => decoded(row[`k${index}`], row[`v${index}`]));
|
|
549
|
-
const found = kept.map((row) => ({
|
|
678
|
+
const found = kept.map((row) => ({
|
|
679
|
+
key: keyOf(row),
|
|
680
|
+
count: Number(row.n),
|
|
681
|
+
...(shape.size
|
|
682
|
+
? {
|
|
683
|
+
documents: { count: Number(row.dn), size: Number(row.ds) },
|
|
684
|
+
files: { count: Number(row.fn), size: Number(row.fs) },
|
|
685
|
+
}
|
|
686
|
+
: {}),
|
|
687
|
+
...(shape.updated ? { updated: latestOf(row.u) } : {}),
|
|
688
|
+
...(shape.greatest === null ? {} : { greatest: decoded(row.gk, row.gv) }),
|
|
689
|
+
}));
|
|
550
690
|
const last = kept.at(-1);
|
|
551
691
|
const next = plan.limit === null || rows.length <= plan.limit
|
|
552
692
|
? undefined
|
|
553
693
|
: last === undefined
|
|
554
694
|
? (plan.after?.text ?? FROM_START)
|
|
555
|
-
: cursorOf([
|
|
556
|
-
...shape.orderBy.map(({ by }) => by === 'count' ? Number(last.n) : sortedValue(last, by)),
|
|
557
|
-
keyOf(last),
|
|
558
|
-
]);
|
|
695
|
+
: cursorOf([...shape.orderBy.map(({ by }) => valueOf(last, by)), keyOf(last)]);
|
|
559
696
|
const total = plan.total
|
|
560
697
|
? Number(connection.rows(joined([fragment('SELECT count(*) AS held FROM ('), grouping, fragment(')')], '').sql, grouping.bind)[0].held)
|
|
561
698
|
: 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
|
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"}
|