@agentshouse/mdruntime 0.1.0-cbe358f60d1d3 → 0.1.0-cc00e9289ddf4
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 +18 -16
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +299 -0
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +302 -0
- package/dist/adapter.d.ts +68 -72
- 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/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 +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -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 +23 -20
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +34 -19
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts +7 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +216 -78
- package/dist/connection.d.ts +5 -143
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +110 -5026
- package/dist/conversation-live.d.ts +150 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +35 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +55 -0
- package/dist/conversation.d.ts +56 -41
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +981 -881
- 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 +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +150 -0
- package/dist/durability.d.ts +13 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +5 -3
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +199 -0
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- 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 +19 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +62 -19
- package/dist/index.d.ts +30 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -5
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +278 -0
- package/dist/listing.d.ts +52 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +152 -0
- package/dist/live.d.ts +8 -6
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +110 -31
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +32 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +10 -13
- package/dist/memory.d.ts +9 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +97 -27
- package/dist/messages.d.ts +33 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +95 -22
- package/dist/model.d.ts +1 -8
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -11
- 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 +27 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +184 -85
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +53 -0
- package/dist/outcome.d.ts +11 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +26 -2
- package/dist/overlay.d.ts +6 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +47 -21
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +4 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +13 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +41 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +314 -0
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +233 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +308 -0
- package/dist/query.d.ts +10 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +29 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +115 -0
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +450 -0
- package/dist/reach.d.ts +9 -8
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +223 -111
- package/dist/react.d.ts +14 -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 +9 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +39 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +178 -0
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +38 -8
- package/dist/refresh.d.ts +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 +63 -30
- 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 +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +48 -59
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts +15 -4
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +54 -55
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +42 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +339 -166
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +410 -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 +33 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +309 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +67 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +164 -0
- package/dist/source.d.ts +54 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -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 +217 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +464 -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 +113 -142
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +171 -360
- package/dist/stored.d.ts +72 -34
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +316 -106
- package/dist/surface.d.ts +89 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +222 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +535 -0
- package/dist/tables.d.ts +116 -25
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +222 -51
- 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 +5 -5
- package/dist/wire.d.ts +52 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +18 -4
- 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,15 @@
|
|
|
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 } from './collection.js';
|
|
3
4
|
import { documentKey, pathOfKey, roomOfKey } from './rows.js';
|
|
4
5
|
import { FROM_START, MAXIMUM_WINDOW } from './windows.js';
|
|
6
|
+
const UNTYPED = 'any';
|
|
5
7
|
const { all, any, exists, fragment, grouped, joined, listed } = sql;
|
|
6
|
-
const VISIBLE = (alias) => `${alias}.visible = 1 AND ${alias}.present = 1 AND ${alias}.queried = 1`;
|
|
8
|
+
export const VISIBLE = (alias) => `${alias}.visible = 1 AND ${alias}.present = 1 AND ${alias}.queried = 1`;
|
|
7
9
|
function located(alias) {
|
|
8
10
|
return fragment(`(SELECT k.locator FROM replica_keys k WHERE k.key = ${alias}.key)`);
|
|
9
11
|
}
|
|
10
|
-
function within(alias, path) {
|
|
12
|
+
export function within(alias, path) {
|
|
11
13
|
return fragment(`(${alias}.path = ? OR (${alias}.path >= ? AND ${alias}.path < ?))`, [
|
|
12
14
|
path,
|
|
13
15
|
`${path}/`,
|
|
@@ -116,7 +118,18 @@ const GROUP_TIES = {
|
|
|
116
118
|
locale: undefined,
|
|
117
119
|
localeOptions: undefined,
|
|
118
120
|
};
|
|
119
|
-
|
|
121
|
+
const GREATEST = { ...GROUP_ORDER, direction: 'desc', nulls: 'last' };
|
|
122
|
+
const TIMES = {
|
|
123
|
+
created: { value: 'd.created', instant: 'd.created_instant' },
|
|
124
|
+
updated: { value: "(d.change ->> '$.time')", instant: 'd.changed_instant' },
|
|
125
|
+
};
|
|
126
|
+
function subfolderOf(column, prefix) {
|
|
127
|
+
const root = prefix ?? '';
|
|
128
|
+
const base = root === '' ? '' : `${root}/`;
|
|
129
|
+
const rest = `substr(${column}, length(?) + 1)`;
|
|
130
|
+
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]);
|
|
131
|
+
}
|
|
132
|
+
function keyTerm(key, ordering, index, prefix) {
|
|
120
133
|
if (key.of === 'field') {
|
|
121
134
|
const alias = `o${index}`;
|
|
122
135
|
return {
|
|
@@ -133,13 +146,37 @@ function keyTerm(key, ordering, index) {
|
|
|
133
146
|
], ''),
|
|
134
147
|
};
|
|
135
148
|
}
|
|
149
|
+
if (key.of === 'size') {
|
|
150
|
+
return {
|
|
151
|
+
term: {
|
|
152
|
+
ordering,
|
|
153
|
+
kind: fragment("(CASE WHEN d.bytes IS NULL THEN 'null' ELSE 'number' END)"),
|
|
154
|
+
value: fragment('d.bytes'),
|
|
155
|
+
},
|
|
156
|
+
join: null,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (key.of === 'created' || key.of === 'updated') {
|
|
160
|
+
const { value, instant } = TIMES[key.of];
|
|
161
|
+
return {
|
|
162
|
+
term: {
|
|
163
|
+
ordering,
|
|
164
|
+
kind: fragment(`(CASE WHEN ${value} IS NULL THEN 'null' ELSE 'string' END)`),
|
|
165
|
+
value: fragment(value),
|
|
166
|
+
instant: fragment(instant),
|
|
167
|
+
},
|
|
168
|
+
join: null,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
136
171
|
const expression = key.of === 'room'
|
|
137
172
|
? located('d')
|
|
138
173
|
: key.of === 'path'
|
|
139
174
|
? fragment('d.path')
|
|
140
175
|
: key.of === 'type'
|
|
141
176
|
? fragment('d.type')
|
|
142
|
-
:
|
|
177
|
+
: key.of === 'subfolder'
|
|
178
|
+
? subfolderOf('d.folder', prefix)
|
|
179
|
+
: fragment('d.folder');
|
|
143
180
|
return {
|
|
144
181
|
term: {
|
|
145
182
|
ordering,
|
|
@@ -160,16 +197,17 @@ function decoded(kind, value) {
|
|
|
160
197
|
return JSON.parse(value);
|
|
161
198
|
return null;
|
|
162
199
|
}
|
|
200
|
+
function sortedOf(kind, value, instant) {
|
|
201
|
+
return sql.sortValue(kind, decoded(kind, value), instant);
|
|
202
|
+
}
|
|
163
203
|
function sortedValue(row, index) {
|
|
164
|
-
|
|
165
|
-
return sql.sortValue(kind, decoded(kind, row[`v${index}`]), row[`i${index}`]);
|
|
204
|
+
return sortedOf(row[`k${index}`], row[`v${index}`], row[`i${index}`]);
|
|
166
205
|
}
|
|
167
206
|
function decodedKey(key, row, index) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
return row[`v${index}`] ?? null;
|
|
207
|
+
const kind = row[`k${index}`];
|
|
208
|
+
if (key.of === 'field' && (kind === null || kind === undefined))
|
|
209
|
+
return undefined;
|
|
210
|
+
return sortedValue(row, index);
|
|
173
211
|
}
|
|
174
212
|
function instantOf(term) {
|
|
175
213
|
return term.instant ?? fragment('NULL');
|
|
@@ -274,11 +312,20 @@ function sectionsOf(sections, names) {
|
|
|
274
312
|
return sections;
|
|
275
313
|
return Object.fromEntries(names.flatMap((name) => (Object.hasOwn(sections, name) ? [[name, sections[name]]] : [])));
|
|
276
314
|
}
|
|
277
|
-
function
|
|
315
|
+
function freeParts(room, path, type, content) {
|
|
316
|
+
const definitions = room.composition === undefined ? undefined : definitionsAt(room.composition, path);
|
|
317
|
+
const definition = definitions?.(type === UNTYPED ? undefined : type);
|
|
318
|
+
if (definition === undefined && type !== UNTYPED)
|
|
319
|
+
return null;
|
|
320
|
+
const read = parse(content, path, definition);
|
|
321
|
+
return read.ok ? read.document : null;
|
|
322
|
+
}
|
|
323
|
+
function documentOf(shape, queried, row, linked) {
|
|
324
|
+
const room = queried.locator;
|
|
278
325
|
const path = row.path;
|
|
279
326
|
const type = row.type;
|
|
280
|
-
const fileId = row.file_id
|
|
281
|
-
const revision = row.revision
|
|
327
|
+
const fileId = row.file_id;
|
|
328
|
+
const revision = row.revision;
|
|
282
329
|
if (type === null) {
|
|
283
330
|
const binary = row.binary === null ? null : JSON.parse(row.binary);
|
|
284
331
|
const content = row.content ?? null;
|
|
@@ -291,12 +338,15 @@ function documentOf(shape, room, row, linked) {
|
|
|
291
338
|
binaryFile: binaryRecord(path, binary, revision ?? undefined),
|
|
292
339
|
}),
|
|
293
340
|
...(shape.markdown && content !== null ? { markdown: content } : {}),
|
|
341
|
+
...(shape.change ? { change: changeOf(row) } : {}),
|
|
294
342
|
...(shape.fileId ? { fileId } : {}),
|
|
295
343
|
...(shape.revision ? { revision } : {}),
|
|
344
|
+
...heldFacts(shape, row),
|
|
296
345
|
};
|
|
297
346
|
}
|
|
298
|
-
const
|
|
299
|
-
|
|
347
|
+
const body = shape.sections !== null || shape.preamble
|
|
348
|
+
? freeParts(queried, path, type, row.content)
|
|
349
|
+
: null;
|
|
300
350
|
const fields = JSON.parse(row.fields ?? '{}');
|
|
301
351
|
return {
|
|
302
352
|
room,
|
|
@@ -315,13 +365,19 @@ function documentOf(shape, room, row, linked) {
|
|
|
315
365
|
...(shape.preamble && body !== null ? { preamble: body.preamble } : {}),
|
|
316
366
|
...(shape.markdown ? { markdown: row.content } : {}),
|
|
317
367
|
...(shape.backlinks ? { backlinks: linked.get(documentKey(room, path)) ?? [] } : {}),
|
|
318
|
-
...(shape.change
|
|
319
|
-
? {
|
|
320
|
-
change: row.change === null ? null : JSON.parse(row.change),
|
|
321
|
-
}
|
|
322
|
-
: {}),
|
|
368
|
+
...(shape.change ? { change: changeOf(row) } : {}),
|
|
323
369
|
...(shape.fileId ? { fileId } : {}),
|
|
324
370
|
...(shape.revision ? { revision } : {}),
|
|
371
|
+
...heldFacts(shape, row),
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
function changeOf(row) {
|
|
375
|
+
return row.change === null ? null : JSON.parse(row.change);
|
|
376
|
+
}
|
|
377
|
+
function heldFacts(shape, row) {
|
|
378
|
+
return {
|
|
379
|
+
...(shape.size ? { size: row.bytes === null ? null : Number(row.bytes) } : {}),
|
|
380
|
+
...(shape.created ? { created: row.created } : {}),
|
|
325
381
|
};
|
|
326
382
|
}
|
|
327
383
|
function backlinksOf(connection, bound, rows) {
|
|
@@ -333,8 +389,8 @@ function backlinksOf(connection, bound, rows) {
|
|
|
333
389
|
held.push(row.path);
|
|
334
390
|
byKey.set(key, held);
|
|
335
391
|
}
|
|
392
|
+
const reach = reached(bound, 's');
|
|
336
393
|
for (const [key, targets] of byKey) {
|
|
337
|
-
const reach = reached(bound, 's');
|
|
338
394
|
const room = bound.rooms.find((one) => one.key === key).locator;
|
|
339
395
|
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
396
|
for (const row of found) {
|
|
@@ -347,28 +403,25 @@ function backlinksOf(connection, bound, rows) {
|
|
|
347
403
|
return linked;
|
|
348
404
|
}
|
|
349
405
|
function documents(connection, bound, plan, shape, budget) {
|
|
350
|
-
const terms = shape.orderBy.map(({ key, options }, index) => keyTerm(key, orderingOf(options), index));
|
|
406
|
+
const terms = shape.orderBy.map(({ key, options }, index) => keyTerm(key, orderingOf(options), index, plan.root.pathPrefix));
|
|
351
407
|
const filter = filtered(bound, plan);
|
|
352
408
|
const cursor = plan.after?.values ?? null;
|
|
353
409
|
const room = located('d');
|
|
354
|
-
const
|
|
410
|
+
const after = cursor === null
|
|
355
411
|
? null
|
|
356
412
|
: (() => {
|
|
357
413
|
const key = cursor[shape.orderBy.length];
|
|
358
|
-
return any([
|
|
414
|
+
return sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), any([
|
|
359
415
|
fragment(`${room.sql} > ?`, [...room.bind, roomOfKey(key)]),
|
|
360
416
|
fragment(`${room.sql} = ? AND d.path > ?`, [
|
|
361
417
|
...room.bind,
|
|
362
418
|
roomOfKey(key),
|
|
363
419
|
pathOfKey(key),
|
|
364
420
|
]),
|
|
365
|
-
]);
|
|
421
|
+
]));
|
|
366
422
|
})();
|
|
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
423
|
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'),
|
|
424
|
+
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
425
|
...terms.map(({ term }, index) => joined([
|
|
373
426
|
fragment(`, ${term.kind.sql} AS k${index}`, term.kind.bind),
|
|
374
427
|
fragment(`, ${term.value.sql} AS v${index}`, term.value.bind),
|
|
@@ -387,8 +440,9 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
387
440
|
const kept = bodied(shape) ? withContent(connection, windowed, budget) : windowed;
|
|
388
441
|
const cut = kept.length;
|
|
389
442
|
const roomOf = new Map(bound.rooms.map(({ key, locator }) => [key, locator]));
|
|
443
|
+
const queried = new Map(bound.rooms.map((one) => [one.key, one]));
|
|
390
444
|
const linked = shape.backlinks ? backlinksOf(connection, bound, kept) : new Map();
|
|
391
|
-
const found = kept.map((row) => documentOf(shape,
|
|
445
|
+
const found = kept.map((row) => documentOf(shape, queried.get(Number(row.key)), row, linked));
|
|
392
446
|
const last = kept.at(-1);
|
|
393
447
|
const cursorAt = (row) => cursorOf([
|
|
394
448
|
...shape.orderBy.map(({ key }, index) => decodedKey(key, row, index)),
|
|
@@ -437,16 +491,18 @@ function withContent(connection, rows, budget) {
|
|
|
437
491
|
.map((row) => [row.id, row.content]));
|
|
438
492
|
return kept.map((row) => ({ ...row, content: held.get(row.id) ?? null }));
|
|
439
493
|
}
|
|
440
|
-
function storedFolders(bound, plan) {
|
|
494
|
+
function storedFolders(bound, plan, subfolder) {
|
|
441
495
|
if (plan.paths !== null || plan.fileIds !== null)
|
|
442
496
|
return null;
|
|
443
497
|
if (plan.hop !== null || plan.backlinks !== null)
|
|
444
498
|
return null;
|
|
499
|
+
if (subfolder && plan.folder !== null)
|
|
500
|
+
return null;
|
|
445
501
|
const whole = bound.rooms.filter(({ locator }) => bound.reach === null || bound.reach.rooms.includes(locator));
|
|
446
502
|
if (whole.length === 0)
|
|
447
503
|
return null;
|
|
448
504
|
const keys = whole.map(({ key }) => key);
|
|
449
|
-
const prefix = plan.root.pathPrefix;
|
|
505
|
+
const prefix = plan.root.pathPrefix ?? '';
|
|
450
506
|
const outside = (bound.reach?.areas ?? []).flatMap((area) => {
|
|
451
507
|
const key = bound.keys.get(area.room);
|
|
452
508
|
if (key === undefined)
|
|
@@ -454,27 +510,51 @@ function storedFolders(bound, plan) {
|
|
|
454
510
|
const fence = fenced('f', key, area, true);
|
|
455
511
|
return [fragment(`NOT ${grouped(fence).sql}`, fence.bind)];
|
|
456
512
|
});
|
|
513
|
+
const under = prefix === ''
|
|
514
|
+
? subfolder
|
|
515
|
+
? [fragment("f.path <> ''")]
|
|
516
|
+
: []
|
|
517
|
+
: [
|
|
518
|
+
subfolder
|
|
519
|
+
? fragment('(f.path >= ? AND f.path < ?)', [`${prefix}/`, `${prefix}0`])
|
|
520
|
+
: within('f', prefix),
|
|
521
|
+
];
|
|
457
522
|
return all([
|
|
458
523
|
fragment(`f.key IN ${listed(keys).sql} AND f.layer = 0 AND f.present = 1`, keys),
|
|
459
524
|
...outside,
|
|
460
|
-
...
|
|
461
|
-
|
|
462
|
-
: [
|
|
463
|
-
fragment('(f.path = ? OR (f.path >= ? AND f.path < ?))', [
|
|
464
|
-
prefix,
|
|
465
|
-
`${prefix}/`,
|
|
466
|
-
`${prefix}0`,
|
|
467
|
-
]),
|
|
468
|
-
]),
|
|
525
|
+
...under,
|
|
526
|
+
...(plan.outside ?? []).map((folder) => fragment(`NOT ${within('f', folder).sql}`, within('f', folder).bind)),
|
|
469
527
|
...(plan.folder === null ? [] : [fragment('f.path = ?', [plan.folder])]),
|
|
470
528
|
]);
|
|
471
529
|
}
|
|
530
|
+
const SIZES = [
|
|
531
|
+
'CASE WHEN d.binary IS NULL THEN 1 ELSE 0 END AS dn',
|
|
532
|
+
'CASE WHEN d.binary IS NULL THEN d.bytes ELSE 0 END AS ds',
|
|
533
|
+
'CASE WHEN d.binary IS NULL THEN 0 ELSE 1 END AS fn',
|
|
534
|
+
'CASE WHEN d.binary IS NULL THEN 0 ELSE d.bytes END AS fs',
|
|
535
|
+
];
|
|
536
|
+
const LATEST = "d.changed_instant || ' ' || (d.change ->> '$.time') AS u";
|
|
537
|
+
function greatestTerm(ordering) {
|
|
538
|
+
return { ordering, kind: fragment('gk'), value: fragment('gv'), instant: fragment('gi') };
|
|
539
|
+
}
|
|
540
|
+
function latestOf(held) {
|
|
541
|
+
if (typeof held !== 'string')
|
|
542
|
+
return null;
|
|
543
|
+
return held.slice(held.indexOf(' ') + 1);
|
|
544
|
+
}
|
|
472
545
|
function groups(connection, bound, plan, shape) {
|
|
546
|
+
const prefix = plan.root.pathPrefix;
|
|
473
547
|
const keyed = shape.groupBy.map((key, index) => {
|
|
474
|
-
const { term, join } = keyTerm(key, GROUP_ORDER, index);
|
|
548
|
+
const { term, join } = keyTerm(key, GROUP_ORDER, index, prefix);
|
|
475
549
|
const kind = fragment(`COALESCE(${term.kind.sql}, 'null')`, term.kind.bind);
|
|
476
550
|
return { term: { ...term, kind }, join };
|
|
477
551
|
});
|
|
552
|
+
const ordering = shape.orderBy.map(({ by }) => by);
|
|
553
|
+
const sized = shape.size || ordering.includes('size');
|
|
554
|
+
const dated = shape.updated || ordering.includes('updated');
|
|
555
|
+
const greatest = shape.greatest === null
|
|
556
|
+
? null
|
|
557
|
+
: keyTerm({ of: 'field', field: shape.greatest }, GREATEST, keyed.length, prefix);
|
|
478
558
|
const filter = filtered(bound, plan);
|
|
479
559
|
const inner = joined([
|
|
480
560
|
fragment('SELECT '),
|
|
@@ -483,57 +563,107 @@ function groups(connection, bound, plan, shape) {
|
|
|
483
563
|
fragment(`, ${term.value.sql} AS v${index}`, term.value.bind),
|
|
484
564
|
fragment(`, ${instantOf(term).sql} AS i${index}`, instantOf(term).bind),
|
|
485
565
|
], '')), ', '),
|
|
486
|
-
fragment(', 1 AS n
|
|
487
|
-
...
|
|
566
|
+
fragment(['', '1 AS n', ...(sized ? SIZES : []), ...(dated ? [LATEST] : [])].join(', ')),
|
|
567
|
+
...(greatest === null
|
|
568
|
+
? []
|
|
569
|
+
: [
|
|
570
|
+
fragment(`, ${greatest.term.kind.sql} AS gk`, greatest.term.kind.bind),
|
|
571
|
+
fragment(`, ${greatest.term.value.sql} AS gv`, greatest.term.value.bind),
|
|
572
|
+
fragment(`, ${instantOf(greatest.term).sql} AS gi`, instantOf(greatest.term).bind),
|
|
573
|
+
]),
|
|
574
|
+
fragment(' FROM replica_entries d'),
|
|
575
|
+
...[...keyed, ...(greatest === null ? [] : [greatest])].flatMap(({ join }) => join === null ? [] : [fragment(' '), join]),
|
|
488
576
|
fragment(' WHERE '),
|
|
489
577
|
filter,
|
|
490
578
|
], '');
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
579
|
+
const only = shape.groupBy.length === 1 ? shape.groupBy[0].of : null;
|
|
580
|
+
const subfolder = only === 'subfolder';
|
|
581
|
+
const folders = only === 'folder' || subfolder ? storedFolders(bound, plan, subfolder) : null;
|
|
582
|
+
const folderKey = subfolder ? subfolderOf('f.path', prefix) : fragment('f.path');
|
|
583
|
+
const zeros = [
|
|
584
|
+
...(sized ? ['0', '0', '0', '0'] : []),
|
|
585
|
+
...(dated ? ['NULL'] : []),
|
|
586
|
+
...(greatest === null ? [] : ['NULL', 'NULL', 'NULL']),
|
|
587
|
+
];
|
|
494
588
|
const source = folders === null
|
|
495
589
|
? inner
|
|
496
590
|
: joined([
|
|
497
591
|
inner,
|
|
498
|
-
fragment(
|
|
592
|
+
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
593
|
folders,
|
|
500
594
|
], '');
|
|
501
|
-
const columns = keyed
|
|
502
|
-
.map((_, index) => `k${index}, min(v${index}) AS v${index}, i${index}`)
|
|
503
|
-
.join(', ');
|
|
504
595
|
const held = keyed
|
|
505
596
|
.map((_, index) => `k${index}, i${index}, CASE WHEN i${index} IS NULL THEN v${index} END`)
|
|
506
597
|
.join(', ');
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
598
|
+
const ranked = greatest === null
|
|
599
|
+
? source
|
|
600
|
+
: joined([
|
|
601
|
+
fragment(`SELECT *, ROW_NUMBER() OVER (PARTITION BY ${held} ORDER BY `),
|
|
602
|
+
sql.sorted(bound.collate, greatestTerm(GREATEST)),
|
|
603
|
+
fragment(', gv) AS gr FROM ('),
|
|
604
|
+
source,
|
|
605
|
+
fragment(')'),
|
|
606
|
+
], '');
|
|
607
|
+
const columns = [
|
|
608
|
+
...keyed.map((_, index) => `k${index}, min(v${index}) AS v${index}, i${index}`),
|
|
609
|
+
'sum(n) AS n',
|
|
610
|
+
...(sized ? ['sum(dn) AS dn', 'sum(ds) AS ds', 'sum(fn) AS fn', 'sum(fs) AS fs'] : []),
|
|
611
|
+
...(dated ? ['max(u) AS u'] : []),
|
|
612
|
+
...(greatest === null
|
|
613
|
+
? []
|
|
614
|
+
: ['gk', 'gv', 'gi'].map((column) => `min(CASE WHEN gr = 1 THEN ${column} END) AS ${column}`)),
|
|
615
|
+
].join(', ');
|
|
616
|
+
const outer = (index, order) => ({
|
|
617
|
+
ordering: order,
|
|
514
618
|
kind: fragment(`k${index}`),
|
|
515
619
|
value: fragment(`v${index}`),
|
|
516
620
|
});
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
621
|
+
const termOf = (by, order) => {
|
|
622
|
+
if (by === 'count')
|
|
623
|
+
return { ordering: order, kind: fragment("'number'"), value: fragment('n') };
|
|
624
|
+
if (by === 'size') {
|
|
625
|
+
return { ordering: order, kind: fragment("'number'"), value: fragment('(ds + fs)') };
|
|
626
|
+
}
|
|
627
|
+
if (by === 'updated') {
|
|
628
|
+
return {
|
|
629
|
+
ordering: order,
|
|
630
|
+
kind: fragment("(CASE WHEN u IS NULL THEN 'null' ELSE 'string' END)"),
|
|
631
|
+
value: fragment("substr(u, instr(u, ' ') + 1)"),
|
|
632
|
+
instant: fragment("substr(u, 1, instr(u, ' ') - 1)"),
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
if (by === 'greatest')
|
|
636
|
+
return greatestTerm(order);
|
|
637
|
+
return { ...outer(by, order), instant: fragment(`i${by}`) };
|
|
638
|
+
};
|
|
639
|
+
const valueOf = (row, by) => {
|
|
640
|
+
if (by === 'count')
|
|
641
|
+
return Number(row.n);
|
|
642
|
+
if (by === 'size')
|
|
643
|
+
return Number(row.ds) + Number(row.fs);
|
|
644
|
+
if (by === 'updated') {
|
|
645
|
+
const text = latestOf(row.u);
|
|
646
|
+
return text === null ? null : sql.sortValue('string', text, row.u.split(' ')[0]);
|
|
647
|
+
}
|
|
648
|
+
if (by === 'greatest')
|
|
649
|
+
return sortedOf(row.gk, row.gv, row.gi);
|
|
650
|
+
return sortedValue(row, by);
|
|
651
|
+
};
|
|
652
|
+
const ordered = shape.orderBy.map(({ by, direction, nulls }) => termOf(by, { ...GROUP_ORDER, direction, nulls: nulls ?? GROUP_ORDER.nulls }));
|
|
520
653
|
const ties = keyed.flatMap((_, index) => [
|
|
521
654
|
{ ...outer(index, GROUP_TIES), total: true },
|
|
522
655
|
{ ordering: GROUP_TIES, kind: fragment("'string'"), value: fragment(`k${index}`) },
|
|
523
656
|
]);
|
|
524
657
|
const cursor = plan.after?.values ?? null;
|
|
525
|
-
const
|
|
658
|
+
const after = cursor === null
|
|
526
659
|
? 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}`)], '');
|
|
660
|
+
: (() => {
|
|
661
|
+
const tieValues = cursor[shape.orderBy.length].flatMap((value) => [value, heldKind(value ?? null)]);
|
|
662
|
+
return sql.following(ordered.map((term, index) => sql.beyond(bound.collate, term, cursor[index])), sql.following(ties
|
|
663
|
+
.slice(0, -1)
|
|
664
|
+
.map((term, index) => sql.beyond(bound.collate, term, tieValues[index])), sql.beyond(bound.collate, ties.at(-1), tieValues.at(-1)).beyond));
|
|
665
|
+
})();
|
|
666
|
+
const grouping = joined([fragment(`SELECT ${columns} FROM (`), ranked, fragment(`) GROUP BY ${held}`)], '');
|
|
537
667
|
const windowed = joined([
|
|
538
668
|
fragment('SELECT * FROM ('),
|
|
539
669
|
grouping,
|
|
@@ -546,16 +676,24 @@ function groups(connection, bound, plan, shape) {
|
|
|
546
676
|
const rows = connection.rows(windowed.sql, windowed.bind);
|
|
547
677
|
const kept = plan.limit === null ? rows : rows.slice(0, plan.limit);
|
|
548
678
|
const keyOf = (row) => keyed.map((_, index) => decoded(row[`k${index}`], row[`v${index}`]));
|
|
549
|
-
const found = kept.map((row) => ({
|
|
679
|
+
const found = kept.map((row) => ({
|
|
680
|
+
key: keyOf(row),
|
|
681
|
+
count: Number(row.n),
|
|
682
|
+
...(shape.size
|
|
683
|
+
? {
|
|
684
|
+
documents: { count: Number(row.dn), size: Number(row.ds) },
|
|
685
|
+
files: { count: Number(row.fn), size: Number(row.fs) },
|
|
686
|
+
}
|
|
687
|
+
: {}),
|
|
688
|
+
...(shape.updated ? { updated: latestOf(row.u) } : {}),
|
|
689
|
+
...(shape.greatest === null ? {} : { greatest: decoded(row.gk, row.gv) }),
|
|
690
|
+
}));
|
|
550
691
|
const last = kept.at(-1);
|
|
551
692
|
const next = plan.limit === null || rows.length <= plan.limit
|
|
552
693
|
? undefined
|
|
553
694
|
: last === undefined
|
|
554
695
|
? (plan.after?.text ?? FROM_START)
|
|
555
|
-
: cursorOf([
|
|
556
|
-
...shape.orderBy.map(({ by }) => by === 'count' ? Number(last.n) : sortedValue(last, by)),
|
|
557
|
-
keyOf(last),
|
|
558
|
-
]);
|
|
696
|
+
: cursorOf([...shape.orderBy.map(({ by }) => valueOf(last, by)), keyOf(last)]);
|
|
559
697
|
const total = plan.total
|
|
560
698
|
? Number(connection.rows(joined([fragment('SELECT count(*) AS held FROM ('), grouping, fragment(')')], '').sql, grouping.bind)[0].held)
|
|
561
699
|
: undefined;
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,53 +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 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';
|
|
1
|
+
import type { Adapter, Authorization } from './adapter.js';
|
|
2
|
+
import { type RuntimeShell } from './durability.js';
|
|
12
3
|
import { type Recovery } from './recovery.js';
|
|
13
|
-
import { type
|
|
14
|
-
import { type
|
|
15
|
-
import { type SyncStatus } from './status.js';
|
|
16
|
-
import { type RuntimeShell, type UnsentWork } from './durability.js';
|
|
17
|
-
import { type CodeAvailability, type Persistence, type Readiness } from './readiness.js';
|
|
18
|
-
import type { RuntimeDatabase } from './tables.js';
|
|
19
|
-
import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
|
|
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
|
-
};
|
|
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;
|
|
@@ -56,100 +11,7 @@ export type MdRuntimeOptions = {
|
|
|
56
11
|
signal?: AbortSignal;
|
|
57
12
|
recovery?: Recovery;
|
|
58
13
|
usableWhenHeld?: readonly string[];
|
|
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
|
-
unsent(): Promise<readonly UnsentWork[]>;
|
|
121
|
-
reset(): Promise<void>;
|
|
122
|
-
observe: {
|
|
123
|
-
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
124
|
-
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
125
|
-
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
126
|
-
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
127
|
-
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
128
|
-
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
129
|
-
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
130
|
-
(topic: 'authority-changes'): Promise<Observation<number>>;
|
|
131
|
-
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
132
|
-
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
133
|
-
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
134
|
-
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
135
|
-
(topic: 'presentation', app: string): Promise<Observation<unknown>>;
|
|
136
|
-
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
137
|
-
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
138
|
-
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
139
|
-
};
|
|
140
|
-
reauthorize(): Promise<void>;
|
|
141
|
-
};
|
|
142
|
-
export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
|
|
143
|
-
export type ReadinessPort = {
|
|
144
|
-
readonly target: string;
|
|
145
|
-
readonly code: CodeAvailability;
|
|
146
|
-
};
|
|
147
|
-
export type ComposedRuntime = RuntimeView & {
|
|
148
|
-
seed(entry: EntrySeed): void;
|
|
149
|
-
stop(): Promise<void>;
|
|
150
|
-
persisted(answer: Persistence): void;
|
|
151
|
-
within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
14
|
+
build?: string;
|
|
152
15
|
};
|
|
153
16
|
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
154
|
-
export {};
|
|
155
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":"AAEA,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;AAErE,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,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAIF,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAqGzE"}
|