@agentshouse/mdruntime 0.1.0-cec6690d5712e → 0.1.0-cede5a74284be
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 +28 -9
- package/dist/adapter.d.ts +34 -11
- package/dist/adapter.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/bootstrap.js +5 -8
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +8 -7
- package/dist/change.d.ts +11 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +26 -1
- package/dist/chat/style.js +1 -1
- package/dist/client.d.ts +6 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -0
- package/dist/connection.d.ts +9 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +237 -46
- package/dist/host.d.ts +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +5 -1
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/memory.d.ts +3 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +31 -11
- package/dist/outcome.d.ts +7 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +6 -0
- package/dist/overlay.d.ts +13 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +56 -22
- package/dist/query.d.ts +2 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts +2 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +23 -1
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +9 -2
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +12 -17
- package/dist/replica.d.ts +5 -2
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +33 -28
- package/dist/room-draft.d.ts +19 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +119 -1
- package/dist/rows.d.ts +3 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -1
- package/dist/save.d.ts +24 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +304 -14
- package/dist/store.d.ts +12 -12
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +150 -157
- package/dist/wire.d.ts +2 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -0
- package/package.json +8 -8
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
package/dist/replica.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { equalValue, parse } from '@agentshouse/mdmodel';
|
|
2
|
-
import { immutable } from './change.js';
|
|
2
|
+
import { immutable, landing } from './change.js';
|
|
3
3
|
import { collectionOf, unreadable, validateCollection, } from './collection.js';
|
|
4
|
-
import { overlay, overlayChanged, sameLayerText } from './overlay.js';
|
|
4
|
+
import { acceptedBinaries, overlay, overlayChanged, sameLayerText, } from './overlay.js';
|
|
5
5
|
import { providerRewritten } from './save.js';
|
|
6
|
-
import { declaredAttachments } from './attachment.js';
|
|
7
6
|
export function compositionOf(record) {
|
|
8
7
|
return {
|
|
9
8
|
model: record.model,
|
|
@@ -29,7 +28,7 @@ export function readStaged(record, previous) {
|
|
|
29
28
|
(textChanged ||
|
|
30
29
|
record.model !== previous?.record.model ||
|
|
31
30
|
record.selectionModel !== previous?.record.selectionModel)) {
|
|
32
|
-
const verdict = validateCollection(record.documents, record.
|
|
31
|
+
const verdict = validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
33
32
|
if (verdict.verdict === 'refuse' && verdict.rule !== 'model-unavailable') {
|
|
34
33
|
return { kind: 'refused', refusal: verdict };
|
|
35
34
|
}
|
|
@@ -47,14 +46,31 @@ export function readStaged(record, previous) {
|
|
|
47
46
|
return { kind: 'staged', confirmed: confirmedOf(record, previous) };
|
|
48
47
|
}
|
|
49
48
|
export function readReclassified(record, previous) {
|
|
50
|
-
const verdict = validateCollection(record.documents, record.
|
|
49
|
+
const verdict = validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
51
50
|
if (verdict.verdict !== 'refuse')
|
|
52
51
|
return { kind: 'staged', confirmed: confirmedOf(record, previous) };
|
|
53
52
|
return verdict.rule === 'model-unavailable'
|
|
54
53
|
? { kind: 'deferred' }
|
|
55
54
|
: { kind: 'refused', refusal: verdict };
|
|
56
55
|
}
|
|
57
|
-
|
|
56
|
+
function returnedBinaries(held, submitted, accepted) {
|
|
57
|
+
const binaries = { ...held };
|
|
58
|
+
for (const change of submitted.changes) {
|
|
59
|
+
if (change.kind !== 'move')
|
|
60
|
+
continue;
|
|
61
|
+
const moved = binaries[change.path];
|
|
62
|
+
if (moved === undefined || accepted.revisions[change.to] === undefined)
|
|
63
|
+
continue;
|
|
64
|
+
binaries[change.to] = moved;
|
|
65
|
+
delete binaries[change.path];
|
|
66
|
+
}
|
|
67
|
+
Object.assign(binaries, acceptedBinaries(accepted.binaryFiles ?? {}));
|
|
68
|
+
for (const path of accepted.removals)
|
|
69
|
+
delete binaries[path];
|
|
70
|
+
return binaries;
|
|
71
|
+
}
|
|
72
|
+
export function applyReturned(confirmed, submitted, accepted, roomVersion, writtenAt) {
|
|
73
|
+
const { documents, revisions, changes, removals } = accepted;
|
|
58
74
|
const nextDocuments = { ...confirmed.record.documents, ...documents };
|
|
59
75
|
const nextRevisions = { ...confirmed.record.revisions, ...revisions };
|
|
60
76
|
const nextChanges = { ...confirmed.record.changes };
|
|
@@ -62,7 +78,6 @@ export function applyReturned(confirmed, documents, revisions, changes, removals
|
|
|
62
78
|
...confirmed.record.written,
|
|
63
79
|
...Object.fromEntries(Object.keys(documents).map((path) => [path, writtenAt])),
|
|
64
80
|
};
|
|
65
|
-
const binaryTargets = new Set(confirmed.record.binaryTargets);
|
|
66
81
|
for (const [path, revision] of Object.entries(revisions)) {
|
|
67
82
|
if (confirmed.record.revisions[path] !== revision)
|
|
68
83
|
delete nextChanges[path];
|
|
@@ -73,7 +88,6 @@ export function applyReturned(confirmed, documents, revisions, changes, removals
|
|
|
73
88
|
delete nextRevisions[path];
|
|
74
89
|
delete nextChanges[path];
|
|
75
90
|
delete nextWritten[path];
|
|
76
|
-
binaryTargets.delete(path);
|
|
77
91
|
}
|
|
78
92
|
return readStaged({
|
|
79
93
|
...confirmed.record,
|
|
@@ -82,10 +96,7 @@ export function applyReturned(confirmed, documents, revisions, changes, removals
|
|
|
82
96
|
revisions: nextRevisions,
|
|
83
97
|
changes: nextChanges,
|
|
84
98
|
written: nextWritten,
|
|
85
|
-
|
|
86
|
-
attachments: attachments === undefined
|
|
87
|
-
? confirmed.record.attachments
|
|
88
|
-
: declaredAttachments([attachments]),
|
|
99
|
+
binaries: returnedBinaries(confirmed.record.binaries, submitted, accepted),
|
|
89
100
|
}, confirmed);
|
|
90
101
|
}
|
|
91
102
|
function predicted(confirmed, batches, previous) {
|
|
@@ -135,7 +146,7 @@ export function replicaOf(confirmed, queue, previous) {
|
|
|
135
146
|
queue: batches,
|
|
136
147
|
visible: {
|
|
137
148
|
documents: confirmed.record.documents,
|
|
138
|
-
|
|
149
|
+
binaries: confirmed.record.binaries,
|
|
139
150
|
revisions: confirmed.record.revisions,
|
|
140
151
|
changes: confirmed.record.changes,
|
|
141
152
|
collection: confirmed.collection,
|
|
@@ -155,7 +166,7 @@ export function replicaOf(confirmed, queue, previous) {
|
|
|
155
166
|
};
|
|
156
167
|
}
|
|
157
168
|
function present(layer, path) {
|
|
158
|
-
return layer.documents[path] !== undefined || layer.
|
|
169
|
+
return layer.documents[path] !== undefined || layer.binaries[path] !== undefined;
|
|
159
170
|
}
|
|
160
171
|
function holds(layer, preconditions) {
|
|
161
172
|
const parsed = new Map();
|
|
@@ -222,31 +233,25 @@ function effects(change) {
|
|
|
222
233
|
{ kind: 'present', path: change.to },
|
|
223
234
|
];
|
|
224
235
|
}
|
|
236
|
+
if (change.kind === 'binary')
|
|
237
|
+
return [{ kind: 'present', path }];
|
|
225
238
|
return [{ kind: 'absent', path }];
|
|
226
239
|
}
|
|
227
|
-
function after(changes, index, path) {
|
|
228
|
-
let at = path;
|
|
229
|
-
for (const change of changes.slice(index + 1)) {
|
|
230
|
-
if (change.path !== at)
|
|
231
|
-
continue;
|
|
232
|
-
if (change.kind === 'remove')
|
|
233
|
-
return null;
|
|
234
|
-
if (change.kind === 'move')
|
|
235
|
-
at = change.to;
|
|
236
|
-
}
|
|
237
|
-
return at;
|
|
238
|
-
}
|
|
239
240
|
export function landed(batch, confirmed, current = {}) {
|
|
240
241
|
const layer = { ...confirmed.record, documents: { ...confirmed.record.documents, ...current } };
|
|
241
242
|
return batch.changes.every((change, index) => {
|
|
242
243
|
if (change.kind === 'replace' || (change.kind === 'create' && 'content' in change)) {
|
|
243
|
-
const at =
|
|
244
|
+
const at = landing(batch.changes, index, change.path);
|
|
244
245
|
return at === null || layer.documents[at] === change.content;
|
|
245
246
|
}
|
|
247
|
+
if (change.kind === 'binary') {
|
|
248
|
+
const at = landing(batch.changes, index, change.path);
|
|
249
|
+
return at === null || layer.binaries[at]?.sha256 === change.sha256;
|
|
250
|
+
}
|
|
246
251
|
return effects(change).every((effect) => {
|
|
247
252
|
if (effect.kind === 'absent')
|
|
248
253
|
return holds(layer, [effect]);
|
|
249
|
-
const at =
|
|
254
|
+
const at = landing(batch.changes, index, effect.path);
|
|
250
255
|
return at === null || holds(layer, [{ ...effect, path: at }]);
|
|
251
256
|
});
|
|
252
257
|
});
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -37,6 +37,17 @@ export type RoomDraftParts = {
|
|
|
37
37
|
readonly removal?: {
|
|
38
38
|
readonly base?: string | null;
|
|
39
39
|
};
|
|
40
|
+
readonly file?: {
|
|
41
|
+
readonly blob: Blob;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type HeldFile = {
|
|
45
|
+
readonly blob: Blob;
|
|
46
|
+
readonly localId: string;
|
|
47
|
+
readonly byteLength: number;
|
|
48
|
+
readonly mediaType: string;
|
|
49
|
+
readonly sha256: string;
|
|
50
|
+
readonly base: string | null;
|
|
40
51
|
};
|
|
41
52
|
type HeldParts = {
|
|
42
53
|
readonly fields?: Readonly<Record<string, {
|
|
@@ -63,6 +74,7 @@ type HeldParts = {
|
|
|
63
74
|
readonly removal?: {
|
|
64
75
|
readonly base: string | null;
|
|
65
76
|
};
|
|
77
|
+
readonly file?: HeldFile;
|
|
66
78
|
};
|
|
67
79
|
type ChangedUnderneath = {
|
|
68
80
|
readonly fields?: Readonly<Record<string, FieldValue>>;
|
|
@@ -72,6 +84,7 @@ type ChangedUnderneath = {
|
|
|
72
84
|
readonly creation?: string;
|
|
73
85
|
readonly move?: string | null;
|
|
74
86
|
readonly removal?: string | null;
|
|
87
|
+
readonly file?: string | null;
|
|
75
88
|
};
|
|
76
89
|
export type ReturnReason = ProviderRefusal & {
|
|
77
90
|
readonly kind: 'conflicted' | 'rejected' | 'expired' | 'withdrawn';
|
|
@@ -97,7 +110,7 @@ export type RoomDraftWrite = {
|
|
|
97
110
|
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
98
111
|
export type ChangedPart = {
|
|
99
112
|
readonly path: string;
|
|
100
|
-
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'creation' | 'move' | 'removal'>;
|
|
113
|
+
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'creation' | 'move' | 'removal' | 'file'>;
|
|
101
114
|
readonly name?: string;
|
|
102
115
|
};
|
|
103
116
|
export type RoomDraftRecord = {
|
|
@@ -112,8 +125,10 @@ export type SavedDraft = {
|
|
|
112
125
|
readonly parts: HeldParts;
|
|
113
126
|
};
|
|
114
127
|
export declare function readParts(value: unknown): RoomDraftParts;
|
|
115
|
-
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts): HeldParts;
|
|
128
|
+
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
|
|
116
129
|
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
130
|
+
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
131
|
+
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
117
132
|
export declare function changedParts(path: string, report: ChangedUnderneath): readonly ChangedPart[];
|
|
118
133
|
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
119
134
|
export declare function moveTarget(move: {
|
|
@@ -123,5 +138,7 @@ export declare function changesOf(path: string, parts: HeldParts): {
|
|
|
123
138
|
changes: readonly Change[];
|
|
124
139
|
bases: readonly Precondition[];
|
|
125
140
|
};
|
|
141
|
+
export declare function joinedDraft(carried: SavedDraft, saved: readonly SavedDraft[]): SavedDraft;
|
|
142
|
+
export declare function withdrawnDrafts(drafts: readonly SavedDraft[], changes: readonly Change[]): readonly SavedDraft[];
|
|
126
143
|
export {};
|
|
127
144
|
//# sourceMappingURL=room-draft.d.ts.map
|
package/dist/room-draft.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,K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,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,GACf;IAAE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAA;CAAE,CA2ChE;AAkBD,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAkBzF;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,SAAS,UAAU,EAAE,CAqBvB"}
|
package/dist/room-draft.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
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) {
|
|
@@ -271,12 +325,15 @@ export function returnedInto(existing, returned) {
|
|
|
271
325
|
const creation = existing.creation ?? returned.creation;
|
|
272
326
|
const move = existing.move ?? returned.move;
|
|
273
327
|
const removal = existing.removal ?? returned.removal;
|
|
328
|
+
const file = existing.file ?? returned.file;
|
|
274
329
|
if (creation !== undefined)
|
|
275
330
|
next.creation = creation;
|
|
276
331
|
if (move !== undefined)
|
|
277
332
|
next.move = move;
|
|
278
333
|
if (removal !== undefined)
|
|
279
334
|
next.removal = removal;
|
|
335
|
+
if (file !== undefined)
|
|
336
|
+
next.file = file;
|
|
280
337
|
return next;
|
|
281
338
|
}
|
|
282
339
|
export function moveTarget(move) {
|
|
@@ -312,9 +369,70 @@ export function changesOf(path, parts) {
|
|
|
312
369
|
if (parts.markdown !== undefined) {
|
|
313
370
|
changes.push({ kind: 'replace', path, content: parts.markdown.value });
|
|
314
371
|
}
|
|
372
|
+
if (parts.file !== undefined && parts.removal === undefined) {
|
|
373
|
+
const { base, ...file } = parts.file;
|
|
374
|
+
const at = parts.move === undefined ? path : moveTarget(parts.move);
|
|
375
|
+
if (base !== null && at !== path)
|
|
376
|
+
changes.push({ kind: 'move', path, to: at });
|
|
377
|
+
changes.push({ kind: 'binary', path: at, ...file });
|
|
378
|
+
if (base === null && at !== path)
|
|
379
|
+
bases.push({ kind: 'absent', path: at });
|
|
380
|
+
return { changes, bases };
|
|
381
|
+
}
|
|
382
|
+
if (parts.file?.base === null)
|
|
383
|
+
return { changes, bases };
|
|
315
384
|
if (parts.move !== undefined)
|
|
316
385
|
changes.push({ kind: 'move', path, to: moveTarget(parts.move) });
|
|
317
386
|
if (parts.removal !== undefined)
|
|
318
387
|
changes.push({ kind: 'remove', path });
|
|
319
388
|
return { changes, bases };
|
|
320
389
|
}
|
|
390
|
+
function rebased(before, after) {
|
|
391
|
+
return before === undefined ? after : { ...after, base: before.base };
|
|
392
|
+
}
|
|
393
|
+
function rebasedAll(before, after) {
|
|
394
|
+
return {
|
|
395
|
+
...before,
|
|
396
|
+
...Object.fromEntries(Object.entries(after).map(([name, part]) => [name, rebased(before?.[name], part)])),
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
export function joinedDraft(carried, saved) {
|
|
400
|
+
const draft = saved.find((item) => item.path === carried.path);
|
|
401
|
+
if (draft === undefined)
|
|
402
|
+
return carried;
|
|
403
|
+
const held = carried.parts;
|
|
404
|
+
const next = draft.parts;
|
|
405
|
+
return {
|
|
406
|
+
path: carried.path,
|
|
407
|
+
parts: {
|
|
408
|
+
...held,
|
|
409
|
+
...next,
|
|
410
|
+
...(next.fields === undefined ? {} : { fields: rebasedAll(held.fields, next.fields) }),
|
|
411
|
+
...(next.sections === undefined
|
|
412
|
+
? {}
|
|
413
|
+
: { sections: rebasedAll(held.sections, next.sections) }),
|
|
414
|
+
...(next.preamble === undefined ? {} : { preamble: rebased(held.preamble, next.preamble) }),
|
|
415
|
+
...(next.markdown === undefined ? {} : { markdown: rebased(held.markdown, next.markdown) }),
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
export function withdrawnDrafts(drafts, changes) {
|
|
420
|
+
return drafts.flatMap((draft) => {
|
|
421
|
+
const file = draft.parts.file;
|
|
422
|
+
const at = draft.parts.move?.to ?? draft.path;
|
|
423
|
+
const change = changes.find((item) => (item.kind === 'move' || item.kind === 'remove') && item.path === at);
|
|
424
|
+
if (file === undefined || change === undefined)
|
|
425
|
+
return [draft];
|
|
426
|
+
if (change.kind === 'move') {
|
|
427
|
+
return [
|
|
428
|
+
{
|
|
429
|
+
path: draft.path,
|
|
430
|
+
parts: change.to === draft.path ? { file } : { file, move: { to: change.to, base: null } },
|
|
431
|
+
},
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
return file.base === null
|
|
435
|
+
? []
|
|
436
|
+
: [{ path: draft.path, parts: { file, removal: { base: null } } }];
|
|
437
|
+
});
|
|
438
|
+
}
|
package/dist/rows.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Document } 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 = {
|
|
@@ -14,6 +15,7 @@ export type DocumentRow = {
|
|
|
14
15
|
directories: readonly string[];
|
|
15
16
|
body: string;
|
|
16
17
|
change: HeadChange | null;
|
|
18
|
+
binary: BinaryFileRecord | null;
|
|
17
19
|
};
|
|
18
20
|
export type BodyRow = {
|
|
19
21
|
key: string;
|
|
@@ -39,6 +41,6 @@ export type Row = DocumentRow | BodyRow | ReferenceRow;
|
|
|
39
41
|
export declare function documentKey(room: string, path: string): string;
|
|
40
42
|
export declare function roomOfKey(key: string): string;
|
|
41
43
|
export declare function markdownPath(path: string): boolean;
|
|
42
|
-
export declare function rowsOf(room: string, path: string, document: Document | null, composition: Composition, change: HeadChange | null): readonly Row[];
|
|
44
|
+
export declare function rowsOf(room: string, path: string, document: Document | null, composition: Composition, change: HeadChange | null, binary: BinaryFileRecord | null): readonly Row[];
|
|
43
45
|
export {};
|
|
44
46
|
//# 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,QAAQ,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,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,IAAI,E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EAAE,MAAM,CAAC;CAClB,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,OAAO,GAAG,YAAY,CAAC;AAMvD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAmFD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,GAAG,IAAI,EACzB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAC9B,SAAS,GAAG,EAAE,CAyEhB"}
|
package/dist/rows.js
CHANGED
|
@@ -71,7 +71,7 @@ function directoriesOf(path) {
|
|
|
71
71
|
export function markdownPath(path) {
|
|
72
72
|
return path.endsWith('.md');
|
|
73
73
|
}
|
|
74
|
-
export function rowsOf(room, path, document, composition, change) {
|
|
74
|
+
export function rowsOf(room, path, document, composition, change, binary) {
|
|
75
75
|
const key = documentKey(room, path);
|
|
76
76
|
const body = keyOf('b', room, path);
|
|
77
77
|
if (document === null || !markdownPath(path)) {
|
|
@@ -88,6 +88,7 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
88
88
|
directories: directoriesOf(path),
|
|
89
89
|
body,
|
|
90
90
|
change,
|
|
91
|
+
binary,
|
|
91
92
|
},
|
|
92
93
|
];
|
|
93
94
|
}
|
|
@@ -118,6 +119,7 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
118
119
|
directories: directoriesOf(path),
|
|
119
120
|
body,
|
|
120
121
|
change,
|
|
122
|
+
binary,
|
|
121
123
|
},
|
|
122
124
|
{
|
|
123
125
|
key: body,
|
package/dist/save.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ProviderLimit } from './adapter.js';
|
|
2
2
|
import { type Change, type ChangeBatch, type Precondition, type WrittenBy } from './change.js';
|
|
3
3
|
import { type Composition } from './collection.js';
|
|
4
|
+
import { type Layer } from './overlay.js';
|
|
4
5
|
import type { VisibleLayer } from './replica.js';
|
|
5
6
|
import type { ChangedPart } from './room-draft.js';
|
|
6
7
|
export type SaveRefusal = {
|
|
@@ -22,6 +23,7 @@ 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;
|
|
26
28
|
};
|
|
27
29
|
export type BatchResult = {
|
|
@@ -32,5 +34,27 @@ export type BatchResult = {
|
|
|
32
34
|
refusal: SaveRefusal;
|
|
33
35
|
};
|
|
34
36
|
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): ChangeBatch;
|
|
37
|
+
export type Requeued = {
|
|
38
|
+
kind: 'requeued';
|
|
39
|
+
queue: readonly ChangeBatch[];
|
|
40
|
+
changes: readonly Change[];
|
|
41
|
+
queued: ReadonlySet<string>;
|
|
42
|
+
withdrawn: ReadonlyMap<string, ChangeBatch | null>;
|
|
43
|
+
owners: ReadonlySet<string>;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'refused';
|
|
46
|
+
refusal: SaveRefusal;
|
|
47
|
+
};
|
|
48
|
+
export type Joining = {
|
|
49
|
+
kind: 'joined';
|
|
50
|
+
batch: ChangeBatch;
|
|
51
|
+
queue: readonly ChangeBatch[];
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'refused';
|
|
54
|
+
refusal: SaveRefusal;
|
|
55
|
+
};
|
|
56
|
+
export declare function requeued(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: (queue: readonly ChangeBatch[]) => VisibleLayer): Requeued;
|
|
57
|
+
export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
|
|
58
|
+
export declare function limitedIn(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: (queue: readonly ChangeBatch[]) => Layer): SaveRefusal | null;
|
|
35
59
|
export declare function buildBatch(input: SaveInput): BatchResult;
|
|
36
60
|
//# 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":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AAgBA,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,EAML,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,MAA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