@agentshouse/mdruntime 0.1.0-c99e5271060cd → 0.1.0-c9b1e59e5baeb
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/AGENTS.md +274 -244
- package/README.md +18 -8
- package/dist/adapter.d.ts +98 -20
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +70 -0
- package/dist/binary.d.ts +23 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +3 -2
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +38 -15
- package/dist/change-set.d.ts +7 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +45 -13
- package/dist/change.d.ts +11 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +26 -1
- package/dist/chat/acts.d.ts +33 -0
- package/dist/chat/acts.d.ts.map +1 -0
- package/dist/chat/acts.js +36 -0
- package/dist/chat/context.d.ts +3 -0
- package/dist/chat/context.d.ts.map +1 -0
- package/dist/chat/context.js +10 -0
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/input.d.ts +9 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +99 -0
- package/dist/chat/kit.d.ts +61 -0
- package/dist/chat/kit.d.ts.map +1 -0
- package/dist/chat/kit.js +123 -0
- package/dist/chat/lasting.d.ts +6 -0
- package/dist/chat/lasting.d.ts.map +1 -0
- package/dist/chat/lasting.js +19 -0
- package/dist/chat/list.d.ts +28 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +99 -0
- package/dist/chat/markdown.d.ts +21 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +246 -0
- package/dist/chat/message.d.ts +6 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +199 -0
- package/dist/chat/messages.d.ts +22 -0
- package/dist/chat/messages.d.ts.map +1 -0
- package/dist/chat/messages.js +175 -0
- package/dist/chat/name.d.ts +6 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +11 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +17 -0
- package/dist/chat/overlay.d.ts +32 -0
- package/dist/chat/overlay.d.ts.map +1 -0
- package/dist/chat/overlay.js +107 -0
- package/dist/chat/parts.d.ts +57 -0
- package/dist/chat/parts.d.ts.map +1 -0
- package/dist/chat/parts.js +119 -0
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -0
- package/dist/chat/process.d.ts +20 -0
- package/dist/chat/process.d.ts.map +1 -0
- package/dist/chat/process.js +32 -0
- package/dist/chat/provider.d.ts +64 -0
- package/dist/chat/provider.d.ts.map +1 -0
- package/dist/chat/provider.js +637 -0
- package/dist/chat/question.d.ts +9 -0
- package/dist/chat/question.d.ts.map +1 -0
- package/dist/chat/question.js +69 -0
- package/dist/chat/questions.d.ts +31 -0
- package/dist/chat/questions.d.ts.map +1 -0
- package/dist/chat/questions.js +111 -0
- package/dist/chat/read.d.ts +5 -0
- package/dist/chat/read.d.ts.map +1 -0
- package/dist/chat/read.js +13 -0
- package/dist/chat/ready.d.ts +34 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +91 -0
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +302 -0
- package/dist/chat.d.ts +14 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +8 -0
- package/dist/client.d.ts +26 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +27 -4
- package/dist/collection.d.ts +20 -5
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +309 -33
- package/dist/connection.d.ts +41 -13
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1819 -407
- package/dist/conversation.d.ts +34 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +552 -168
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +17 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +157 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/host.d.ts +15 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +99 -13
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +12 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/memory.d.ts +10 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +64 -17
- package/dist/model.d.ts +4 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -1
- package/dist/observation.d.ts +7 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +29 -12
- package/dist/outcome.d.ts +17 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +10 -0
- package/dist/overlay.d.ts +18 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +238 -160
- package/dist/query.d.ts +58 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +36 -7
- package/dist/reach.d.ts +8 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +55 -8
- package/dist/react.d.ts +10 -7
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/read-side.d.ts +16 -7
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +495 -102
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts +4 -4
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +51 -30
- package/dist/replica.d.ts +15 -6
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +137 -66
- package/dist/room-draft.d.ts +32 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +129 -12
- package/dist/rows.d.ts +8 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +12 -13
- package/dist/save.d.ts +32 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +495 -97
- package/dist/search.d.ts +49 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +192 -47
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +15 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +398 -0
- package/dist/status.d.ts +4 -1
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +71 -21
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +625 -320
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +64 -0
- package/dist/windows.d.ts +26 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +93 -0
- package/dist/wire.d.ts +153 -30
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +53 -29
- package/package.json +26 -14
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
package/dist/room-draft.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { apply, equalValue, frontmatterValue, parse, serialize } from '@agentshouse/mdmodel';
|
|
1
|
+
import { apply, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { runtimeError } from './failure.js';
|
|
3
|
+
import { hexDigest } from './file.js';
|
|
4
|
+
import { binaryLocalId } from './identity.js';
|
|
3
5
|
import { normalize } from './paths.js';
|
|
4
6
|
export function returnedBy(kind) {
|
|
5
7
|
return { kind, code: kind, fields: {}, retryable: false };
|
|
@@ -60,6 +62,7 @@ const PART_NAMES = new Set([
|
|
|
60
62
|
'creation',
|
|
61
63
|
'move',
|
|
62
64
|
'removal',
|
|
65
|
+
'file',
|
|
63
66
|
]);
|
|
64
67
|
export function readParts(value) {
|
|
65
68
|
if (!plain(value) || Object.keys(value).some((name) => !PART_NAMES.has(name)))
|
|
@@ -95,6 +98,13 @@ export function readParts(value) {
|
|
|
95
98
|
const base = markdownBase(value.removal.base);
|
|
96
99
|
parts.removal = base === undefined ? {} : { base };
|
|
97
100
|
}
|
|
101
|
+
if (value.file !== undefined) {
|
|
102
|
+
if (!plain(value.file) || !(value.file.blob instanceof Blob))
|
|
103
|
+
malformed();
|
|
104
|
+
if (Object.keys(value).length > 1)
|
|
105
|
+
throw runtimeError('room-draft-file-exclusive');
|
|
106
|
+
parts.file = { blob: value.file.blob };
|
|
107
|
+
}
|
|
98
108
|
return parts;
|
|
99
109
|
}
|
|
100
110
|
function named(record) {
|
|
@@ -115,10 +125,33 @@ function editsText(parts) {
|
|
|
115
125
|
named(parts.fields).length > 0 ||
|
|
116
126
|
named(parts.sections).length > 0);
|
|
117
127
|
}
|
|
118
|
-
export function held(current, parts) {
|
|
128
|
+
export function held(current, parts, file) {
|
|
119
129
|
if (parts.markdown !== undefined && editsText(parts)) {
|
|
120
130
|
throw runtimeError('room-draft-markdown-exclusive');
|
|
121
131
|
}
|
|
132
|
+
if (file !== undefined) {
|
|
133
|
+
if (current !== undefined && current.file === undefined) {
|
|
134
|
+
throw runtimeError('room-draft-file-exclusive');
|
|
135
|
+
}
|
|
136
|
+
return { file: { ...file, base: current?.file === undefined ? file.base : current.file.base } };
|
|
137
|
+
}
|
|
138
|
+
if (current?.file !== undefined) {
|
|
139
|
+
if (editsText(parts) ||
|
|
140
|
+
parts.markdown !== undefined ||
|
|
141
|
+
parts.creation !== undefined ||
|
|
142
|
+
(parts.move === undefined && parts.removal === undefined)) {
|
|
143
|
+
throw runtimeError('room-draft-file-exclusive');
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
file: current.file,
|
|
147
|
+
...(parts.move === undefined
|
|
148
|
+
? {}
|
|
149
|
+
: { move: { to: parts.move.to, base: kept(current.move, parts.move.base) } }),
|
|
150
|
+
...(parts.removal === undefined
|
|
151
|
+
? {}
|
|
152
|
+
: { removal: { base: kept(current.removal, parts.removal.base) } }),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
122
155
|
const next = {};
|
|
123
156
|
const fields = named(parts.fields);
|
|
124
157
|
if (fields.length > 0) {
|
|
@@ -198,8 +231,28 @@ export function underneath(parts, path, visible) {
|
|
|
198
231
|
report.move = markdown;
|
|
199
232
|
if (parts.removal !== undefined && markdown !== parts.removal.base)
|
|
200
233
|
report.removal = markdown;
|
|
234
|
+
if (parts.file !== undefined) {
|
|
235
|
+
const file = binaryBase(visible, path);
|
|
236
|
+
if (file !== parts.file.base || markdown !== null)
|
|
237
|
+
report.file = file;
|
|
238
|
+
}
|
|
201
239
|
return report;
|
|
202
240
|
}
|
|
241
|
+
const UNTYPED_MEDIA_TYPE = 'application/octet-stream';
|
|
242
|
+
export async function heldFile(blob, base) {
|
|
243
|
+
const bytes = await blob.arrayBuffer();
|
|
244
|
+
return {
|
|
245
|
+
blob,
|
|
246
|
+
localId: binaryLocalId(),
|
|
247
|
+
byteLength: bytes.byteLength,
|
|
248
|
+
mediaType: blob.type === '' ? UNTYPED_MEDIA_TYPE : blob.type,
|
|
249
|
+
sha256: hexDigest(await crypto.subtle.digest('SHA-256', bytes)),
|
|
250
|
+
base,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
export function binaryBase(visible, path) {
|
|
254
|
+
return visible?.binaries[path] === undefined ? null : (visible.revisions[path] ?? null);
|
|
255
|
+
}
|
|
203
256
|
export function changedParts(path, report) {
|
|
204
257
|
return [
|
|
205
258
|
...(report.creation === undefined ? [] : [{ path, part: 'creation' }]),
|
|
@@ -209,6 +262,7 @@ export function changedParts(path, report) {
|
|
|
209
262
|
...(report.markdown === undefined ? [] : [{ path, part: 'markdown' }]),
|
|
210
263
|
...(report.move === undefined ? [] : [{ path, part: 'move' }]),
|
|
211
264
|
...(report.removal === undefined ? [] : [{ path, part: 'removal' }]),
|
|
265
|
+
...(report.file === undefined ? [] : [{ path, part: 'file' }]),
|
|
212
266
|
];
|
|
213
267
|
}
|
|
214
268
|
function joined(existing, returned) {
|
|
@@ -225,16 +279,15 @@ function frontmatterOf(fields) {
|
|
|
225
279
|
const opened = parse('---\n---\n');
|
|
226
280
|
if (!opened.ok)
|
|
227
281
|
return malformed();
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return serialize(document);
|
|
282
|
+
const next = apply(opened.document, fields.map(([name, part]) => ({
|
|
283
|
+
kind: 'field',
|
|
284
|
+
name,
|
|
285
|
+
value: part.value,
|
|
286
|
+
prior: undefined,
|
|
287
|
+
})));
|
|
288
|
+
return next.outcome === 'applied' ? serialize(next.document) : malformed();
|
|
236
289
|
}
|
|
237
|
-
function
|
|
290
|
+
export function partsAfter(markdown, parts) {
|
|
238
291
|
const fields = named(parts.fields);
|
|
239
292
|
const pieces = [
|
|
240
293
|
...(fields.length === 0 ? [] : [frontmatterOf(fields)]),
|
|
@@ -265,18 +318,21 @@ export function returnedInto(existing, returned) {
|
|
|
265
318
|
delete next.fields;
|
|
266
319
|
delete next.sections;
|
|
267
320
|
delete next.preamble;
|
|
268
|
-
const value =
|
|
321
|
+
const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned);
|
|
269
322
|
next.markdown = { value, base: whole.base };
|
|
270
323
|
}
|
|
271
324
|
const creation = existing.creation ?? returned.creation;
|
|
272
325
|
const move = existing.move ?? returned.move;
|
|
273
326
|
const removal = existing.removal ?? returned.removal;
|
|
327
|
+
const file = existing.file ?? returned.file;
|
|
274
328
|
if (creation !== undefined)
|
|
275
329
|
next.creation = creation;
|
|
276
330
|
if (move !== undefined)
|
|
277
331
|
next.move = move;
|
|
278
332
|
if (removal !== undefined)
|
|
279
333
|
next.removal = removal;
|
|
334
|
+
if (file !== undefined)
|
|
335
|
+
next.file = file;
|
|
280
336
|
return next;
|
|
281
337
|
}
|
|
282
338
|
export function moveTarget(move) {
|
|
@@ -312,9 +368,70 @@ export function changesOf(path, parts) {
|
|
|
312
368
|
if (parts.markdown !== undefined) {
|
|
313
369
|
changes.push({ kind: 'replace', path, content: parts.markdown.value });
|
|
314
370
|
}
|
|
371
|
+
if (parts.file !== undefined && parts.removal === undefined) {
|
|
372
|
+
const { base, ...file } = parts.file;
|
|
373
|
+
const at = parts.move === undefined ? path : moveTarget(parts.move);
|
|
374
|
+
if (base !== null && at !== path)
|
|
375
|
+
changes.push({ kind: 'move', path, to: at });
|
|
376
|
+
changes.push({ kind: 'binary', path: at, ...file });
|
|
377
|
+
if (base === null && at !== path)
|
|
378
|
+
bases.push({ kind: 'absent', path: at });
|
|
379
|
+
return { changes, bases };
|
|
380
|
+
}
|
|
381
|
+
if (parts.file?.base === null)
|
|
382
|
+
return { changes, bases };
|
|
315
383
|
if (parts.move !== undefined)
|
|
316
384
|
changes.push({ kind: 'move', path, to: moveTarget(parts.move) });
|
|
317
385
|
if (parts.removal !== undefined)
|
|
318
386
|
changes.push({ kind: 'remove', path });
|
|
319
387
|
return { changes, bases };
|
|
320
388
|
}
|
|
389
|
+
function rebased(before, after) {
|
|
390
|
+
return before === undefined ? after : { ...after, base: before.base };
|
|
391
|
+
}
|
|
392
|
+
function rebasedAll(before, after) {
|
|
393
|
+
return {
|
|
394
|
+
...before,
|
|
395
|
+
...Object.fromEntries(Object.entries(after).map(([name, part]) => [name, rebased(before?.[name], part)])),
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
export function joinedDraft(carried, saved) {
|
|
399
|
+
const draft = saved.find((item) => item.path === carried.path);
|
|
400
|
+
if (draft === undefined)
|
|
401
|
+
return carried;
|
|
402
|
+
const held = carried.parts;
|
|
403
|
+
const next = draft.parts;
|
|
404
|
+
return {
|
|
405
|
+
path: carried.path,
|
|
406
|
+
parts: {
|
|
407
|
+
...held,
|
|
408
|
+
...next,
|
|
409
|
+
...(next.fields === undefined ? {} : { fields: rebasedAll(held.fields, next.fields) }),
|
|
410
|
+
...(next.sections === undefined
|
|
411
|
+
? {}
|
|
412
|
+
: { sections: rebasedAll(held.sections, next.sections) }),
|
|
413
|
+
...(next.preamble === undefined ? {} : { preamble: rebased(held.preamble, next.preamble) }),
|
|
414
|
+
...(next.markdown === undefined ? {} : { markdown: rebased(held.markdown, next.markdown) }),
|
|
415
|
+
},
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
export function withdrawnDrafts(drafts, changes) {
|
|
419
|
+
return drafts.flatMap((draft) => {
|
|
420
|
+
const file = draft.parts.file;
|
|
421
|
+
const at = draft.parts.move?.to ?? draft.path;
|
|
422
|
+
const change = changes.find((item) => (item.kind === 'move' || item.kind === 'remove') && item.path === at);
|
|
423
|
+
if (file === undefined || change === undefined)
|
|
424
|
+
return [draft];
|
|
425
|
+
if (change.kind === 'move') {
|
|
426
|
+
return [
|
|
427
|
+
{
|
|
428
|
+
path: draft.path,
|
|
429
|
+
parts: change.to === draft.path ? { file } : { file, move: { to: change.to, base: null } },
|
|
430
|
+
},
|
|
431
|
+
];
|
|
432
|
+
}
|
|
433
|
+
return file.base === null
|
|
434
|
+
? []
|
|
435
|
+
: [{ path: draft.path, parts: { file, removal: { base: null } } }];
|
|
436
|
+
});
|
|
437
|
+
}
|
package/dist/rows.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Frontmatter } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { HeadChange } from './adapter.js';
|
|
3
|
+
import type { BinaryFileRecord } from './binary.js';
|
|
3
4
|
import { type Composition } from './collection.js';
|
|
4
5
|
type Fields = Readonly<Record<string, unknown>>;
|
|
5
6
|
export type DocumentRow = {
|
|
@@ -12,17 +13,11 @@ export type DocumentRow = {
|
|
|
12
13
|
values: Fields;
|
|
13
14
|
reached: Readonly<Record<string, readonly unknown[]>>;
|
|
14
15
|
directories: readonly string[];
|
|
15
|
-
|
|
16
|
+
folder: string;
|
|
17
|
+
text: string | null;
|
|
16
18
|
change: HeadChange | null;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
key: string;
|
|
20
|
-
kind: 'body';
|
|
21
|
-
room: string;
|
|
22
|
-
path: string;
|
|
23
|
-
preamble: string;
|
|
24
|
-
sections: Readonly<Record<string, string>>;
|
|
25
|
-
markdown: string;
|
|
19
|
+
fileId: string | null;
|
|
20
|
+
binary: BinaryFileRecord | null;
|
|
26
21
|
};
|
|
27
22
|
export type ReferenceRow = {
|
|
28
23
|
key: string;
|
|
@@ -35,10 +30,10 @@ export type ReferenceRow = {
|
|
|
35
30
|
path: string;
|
|
36
31
|
type: string;
|
|
37
32
|
};
|
|
38
|
-
export type Row = DocumentRow |
|
|
33
|
+
export type Row = DocumentRow | ReferenceRow;
|
|
39
34
|
export declare function documentKey(room: string, path: string): string;
|
|
40
35
|
export declare function roomOfKey(key: string): string;
|
|
41
36
|
export declare function markdownPath(path: string): boolean;
|
|
42
|
-
export declare function rowsOf(room: string, path: string, document:
|
|
37
|
+
export declare function rowsOf(room: string, path: string, document: Frontmatter | null, composition: Composition, change: HeadChange | null, fileId: string | null, binary: BinaryFileRecord | null): readonly Row[];
|
|
43
38
|
export {};
|
|
44
39
|
//# sourceMappingURL=rows.d.ts.map
|
package/dist/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,KAAK,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;IACtD,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG,YAAY,CAAC;AAM7C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAuFD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,WAAW,GAAG,IAAI,EAC5B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAC9B,SAAS,GAAG,EAAE,CAmEhB"}
|
package/dist/rows.js
CHANGED
|
@@ -64,6 +64,9 @@ function walk(reading, node, forms, exact) {
|
|
|
64
64
|
: [{ text: `${form.text}/${segment}`, through: form.through, pending: false }]), `${exact}/${segment}`);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
function folderOf(path) {
|
|
68
|
+
return path.slice(0, Math.max(path.lastIndexOf('/'), 0));
|
|
69
|
+
}
|
|
67
70
|
function directoriesOf(path) {
|
|
68
71
|
const parts = path.split('/').slice(0, -1);
|
|
69
72
|
return ['', ...parts.map((_, index) => parts.slice(0, index + 1).join('/'))];
|
|
@@ -71,9 +74,8 @@ function directoriesOf(path) {
|
|
|
71
74
|
export function markdownPath(path) {
|
|
72
75
|
return path.endsWith('.md');
|
|
73
76
|
}
|
|
74
|
-
export function rowsOf(room, path, document, composition, change) {
|
|
77
|
+
export function rowsOf(room, path, document, composition, change, fileId, binary) {
|
|
75
78
|
const key = documentKey(room, path);
|
|
76
|
-
const body = keyOf('b', room, path);
|
|
77
79
|
if (document === null || !markdownPath(path)) {
|
|
78
80
|
return [
|
|
79
81
|
{
|
|
@@ -86,8 +88,11 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
86
88
|
values: {},
|
|
87
89
|
reached: {},
|
|
88
90
|
directories: directoriesOf(path),
|
|
89
|
-
|
|
91
|
+
folder: folderOf(path),
|
|
92
|
+
text: null,
|
|
90
93
|
change,
|
|
94
|
+
fileId,
|
|
95
|
+
binary,
|
|
91
96
|
},
|
|
92
97
|
];
|
|
93
98
|
}
|
|
@@ -116,17 +121,11 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
116
121
|
values,
|
|
117
122
|
reached,
|
|
118
123
|
directories: directoriesOf(path),
|
|
119
|
-
|
|
124
|
+
folder: folderOf(path),
|
|
125
|
+
text: document.content,
|
|
120
126
|
change,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
key: body,
|
|
124
|
-
kind: 'body',
|
|
125
|
-
room,
|
|
126
|
-
path,
|
|
127
|
-
preamble: document.preamble,
|
|
128
|
-
sections: document.sections,
|
|
129
|
-
markdown: document.content,
|
|
127
|
+
fileId,
|
|
128
|
+
binary,
|
|
130
129
|
},
|
|
131
130
|
...[...reading.targets.values()].map(({ field, target: found, forms }) => ({
|
|
132
131
|
key: keyOf('r', room, path, field, found),
|
package/dist/save.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type Change, type ChangeBatch, type Precondition, type WrittenBy } from
|
|
|
3
3
|
import { type Composition } from './collection.js';
|
|
4
4
|
import type { VisibleLayer } from './replica.js';
|
|
5
5
|
import type { ChangedPart } from './room-draft.js';
|
|
6
|
+
import { type Later } from './turn.js';
|
|
6
7
|
export type SaveRefusal = {
|
|
7
8
|
code: string;
|
|
8
9
|
retryable: boolean;
|
|
@@ -22,7 +23,13 @@ export type SaveInput = {
|
|
|
22
23
|
handle: string;
|
|
23
24
|
changes: readonly Change[];
|
|
24
25
|
bases: readonly Precondition[];
|
|
26
|
+
queued?: ReadonlySet<string>;
|
|
25
27
|
writtenBy?: WrittenBy;
|
|
28
|
+
clean?: {
|
|
29
|
+
text: Readonly<Record<string, string>>;
|
|
30
|
+
binaries: Readonly<Record<string, unknown>>;
|
|
31
|
+
composition: Composition;
|
|
32
|
+
};
|
|
26
33
|
};
|
|
27
34
|
export type BatchResult = {
|
|
28
35
|
kind: 'batch';
|
|
@@ -31,6 +38,29 @@ export type BatchResult = {
|
|
|
31
38
|
kind: 'refused';
|
|
32
39
|
refusal: SaveRefusal;
|
|
33
40
|
};
|
|
34
|
-
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): ChangeBatch
|
|
35
|
-
export declare function
|
|
41
|
+
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
42
|
+
export declare function queuedDocuments(queue: readonly ChangeBatch[]): ReadonlySet<string>;
|
|
43
|
+
export type Requeued = {
|
|
44
|
+
kind: 'requeued';
|
|
45
|
+
queue: readonly ChangeBatch[];
|
|
46
|
+
changes: readonly Change[];
|
|
47
|
+
queued: ReadonlySet<string>;
|
|
48
|
+
withdrawn: ReadonlyMap<string, ChangeBatch | null>;
|
|
49
|
+
owners: ReadonlySet<string>;
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'refused';
|
|
52
|
+
refusal: SaveRefusal;
|
|
53
|
+
};
|
|
54
|
+
export type Joining = {
|
|
55
|
+
kind: 'joined';
|
|
56
|
+
batch: ChangeBatch;
|
|
57
|
+
queue: readonly ChangeBatch[];
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'refused';
|
|
60
|
+
refusal: SaveRefusal;
|
|
61
|
+
};
|
|
62
|
+
export declare function requeued(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: (queue: readonly ChangeBatch[]) => VisibleLayer): Requeued;
|
|
63
|
+
export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
|
|
64
|
+
export declare function limitedIn(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: (queue: readonly ChangeBatch[]) => VisibleLayer): SaveRefusal | null;
|
|
65
|
+
export declare function buildBatch(input: SaveInput): Later<BatchResult>;
|
|
36
66
|
//# sourceMappingURL=save.d.ts.map
|
package/dist/save.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EASL,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAiC,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAEtE,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChC,CAAC;AAEF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