@agentshouse/mdruntime 0.1.0-alpha.9 → 0.1.0-c1954630fadb6
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 +227 -0
- package/README.md +44 -0
- package/dist/adapter.d.ts +184 -34
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +1 -10
- package/dist/attached-model.d.ts +11 -0
- package/dist/attached-model.d.ts.map +1 -0
- package/dist/attached-model.js +34 -0
- package/dist/attachment.d.ts +3 -0
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +8 -0
- package/dist/bootstrap.d.ts +7 -9
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +29 -28
- package/dist/change-set.d.ts +33 -0
- package/dist/change-set.d.ts.map +1 -0
- package/dist/change-set.js +83 -0
- package/dist/change.d.ts +9 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +6 -5
- package/dist/client.d.ts +38 -32
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +114 -183
- package/dist/collection.d.ts +13 -16
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +45 -88
- package/dist/connection.d.ts +47 -44
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1542 -1158
- package/dist/conversation.d.ts +44 -22
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +540 -328
- package/dist/durability.js +6 -6
- package/dist/file.d.ts +2 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +48 -71
- package/dist/host.d.ts +12 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +97 -119
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +10 -9
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/log.js +5 -6
- package/dist/memory.d.ts +15 -7
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +255 -220
- package/dist/model.d.ts +10 -29
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +18 -21
- package/dist/observation.d.ts +27 -0
- package/dist/observation.d.ts.map +1 -0
- package/dist/observation.js +95 -0
- package/dist/outcome.d.ts +10 -29
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +1 -23
- package/dist/overlay.d.ts +9 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +187 -43
- package/dist/paths.d.ts +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +12 -19
- package/dist/query.d.ts +215 -10
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +421 -15
- package/dist/reach.d.ts +40 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +277 -0
- package/dist/react.d.ts +30 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +62 -0
- package/dist/read-side.d.ts +18 -0
- package/dist/read-side.d.ts.map +1 -0
- package/dist/read-side.js +377 -0
- package/dist/refresh.d.ts +5 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +49 -30
- package/dist/replica.d.ts +25 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +227 -38
- package/dist/room-draft.d.ts +127 -0
- package/dist/room-draft.d.ts.map +1 -0
- package/dist/room-draft.js +329 -0
- package/dist/rows.d.ts +41 -0
- package/dist/rows.d.ts.map +1 -0
- package/dist/rows.js +100 -0
- package/dist/save.d.ts +6 -4
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +262 -350
- package/dist/search.d.ts +61 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +125 -0
- package/dist/status.d.ts +4 -6
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +9 -13
- package/dist/store.d.ts +59 -32
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +338 -134
- package/dist/transfer.d.ts +5 -0
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js +1 -5
- package/dist/wire.d.ts +51 -16
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +77 -108
- package/package.json +17 -11
- package/dist/adapter.js.map +0 -1
- package/dist/bootstrap.js.map +0 -1
- package/dist/change.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/collection.js.map +0 -1
- package/dist/connection.js.map +0 -1
- package/dist/conversation.js.map +0 -1
- package/dist/durability.js.map +0 -1
- package/dist/file.js.map +0 -1
- package/dist/host.js.map +0 -1
- package/dist/identity.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/log.js.map +0 -1
- package/dist/memory.js.map +0 -1
- package/dist/model.js.map +0 -1
- package/dist/outcome.js.map +0 -1
- package/dist/overlay.js.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/query.js.map +0 -1
- package/dist/refresh.js.map +0 -1
- package/dist/replica.js.map +0 -1
- package/dist/save.js.map +0 -1
- package/dist/status.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/transfer.js.map +0 -1
- package/dist/wire.js.map +0 -1
package/dist/replica.js
CHANGED
|
@@ -1,43 +1,69 @@
|
|
|
1
|
+
import { parse } from '@agentshouse/mdmodel';
|
|
1
2
|
import { immutable } from './change.js';
|
|
2
|
-
import { parseCollection, readCollection, validateCollection } from './collection.js';
|
|
3
|
-
import { overlay } from './overlay.js';
|
|
3
|
+
import { parseCollection, readCollection, validateCollection, } from './collection.js';
|
|
4
|
+
import { overlay, overlayChanged, sameLayerText } from './overlay.js';
|
|
5
|
+
import { providerRewritten } from './save.js';
|
|
6
|
+
import { equalValue } from './room-draft.js';
|
|
7
|
+
import { declaredAttachments } from './attachment.js';
|
|
4
8
|
export function compositionOf(record) {
|
|
5
9
|
return {
|
|
6
|
-
collectionRoot: record.collectionRoot,
|
|
7
10
|
model: record.model,
|
|
8
|
-
selection: record.typedSelection === null
|
|
9
|
-
|
|
10
|
-
model: record.selectionModel
|
|
11
|
-
}
|
|
11
|
+
selection: record.typedSelection === null
|
|
12
|
+
? null
|
|
13
|
+
: { roots: record.typedSelection.roots, model: record.selectionModel },
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
|
-
export function readConfirmed(record) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
record,
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
export function readConfirmed(record, previous) {
|
|
17
|
+
const read = readCollection(record.documents, compositionOf(record), previous === undefined
|
|
18
|
+
? undefined
|
|
19
|
+
: { text: previous.record.documents, collection: previous.collection });
|
|
20
|
+
return read.kind === 'read'
|
|
21
|
+
? { kind: 'staged', confirmed: { record, collection: read.collection } }
|
|
22
|
+
: read;
|
|
20
23
|
}
|
|
21
|
-
export function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
export function sameMembership(record, other) {
|
|
25
|
+
return (JSON.stringify(record.typedSelection?.roots ?? null) ===
|
|
26
|
+
JSON.stringify(other.typedSelection?.roots ?? null));
|
|
27
|
+
}
|
|
28
|
+
export function readStaged(record, previous) {
|
|
29
|
+
if ((record.model.status !== 'unavailable' || record.selectionModel.status !== 'unavailable') &&
|
|
30
|
+
(previous === undefined ||
|
|
31
|
+
!sameLayerText(record, previous.record) ||
|
|
32
|
+
record.model !== previous.record.model ||
|
|
33
|
+
record.selectionModel !== previous.record.selectionModel)) {
|
|
34
|
+
const verdict = validateCollection(record.documents, record.binaryTargets, compositionOf(record));
|
|
35
|
+
if (verdict.verdict === 'refuse' && verdict.rule !== 'model-unavailable') {
|
|
36
|
+
return { kind: 'refused', refusal: verdict };
|
|
37
|
+
}
|
|
25
38
|
}
|
|
26
|
-
return readConfirmed(record);
|
|
39
|
+
return readConfirmed(record, previous);
|
|
27
40
|
}
|
|
28
|
-
export function
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
export function readReclassified(record, previous) {
|
|
42
|
+
const verdict = validateCollection(record.documents, record.binaryTargets, compositionOf(record));
|
|
43
|
+
if (verdict.verdict !== 'refuse')
|
|
44
|
+
return readConfirmed(record, previous);
|
|
45
|
+
return verdict.rule === 'model-unavailable'
|
|
46
|
+
? { kind: 'deferred' }
|
|
47
|
+
: { kind: 'refused', refusal: verdict };
|
|
48
|
+
}
|
|
49
|
+
export function applyReturned(confirmed, documents, revisions, removals, attachments, roomVersion, writtenAt) {
|
|
50
|
+
const nextDocuments = { ...confirmed.record.documents, ...documents };
|
|
51
|
+
const nextRevisions = { ...confirmed.record.revisions, ...revisions };
|
|
52
|
+
const nextChanges = { ...confirmed.record.changes };
|
|
53
|
+
const nextWritten = {
|
|
54
|
+
...confirmed.record.written,
|
|
55
|
+
...Object.fromEntries(Object.keys(documents).map((path) => [path, writtenAt])),
|
|
36
56
|
};
|
|
37
57
|
const binaryTargets = new Set(confirmed.record.binaryTargets);
|
|
38
|
-
for (const path of
|
|
58
|
+
for (const [path, revision] of Object.entries(revisions)) {
|
|
59
|
+
if (confirmed.record.revisions[path] !== revision)
|
|
60
|
+
delete nextChanges[path];
|
|
61
|
+
}
|
|
62
|
+
for (const path of removals) {
|
|
39
63
|
delete nextDocuments[path];
|
|
40
64
|
delete nextRevisions[path];
|
|
65
|
+
delete nextChanges[path];
|
|
66
|
+
delete nextWritten[path];
|
|
41
67
|
binaryTargets.delete(path);
|
|
42
68
|
}
|
|
43
69
|
return readStaged({
|
|
@@ -45,12 +71,56 @@ export function applyReturned(confirmed, documents, revisions, removals, roomVer
|
|
|
45
71
|
roomVersion,
|
|
46
72
|
documents: nextDocuments,
|
|
47
73
|
revisions: nextRevisions,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
].sort()
|
|
51
|
-
|
|
74
|
+
changes: nextChanges,
|
|
75
|
+
written: nextWritten,
|
|
76
|
+
binaryTargets: [...binaryTargets].sort(),
|
|
77
|
+
attachments: attachments === undefined
|
|
78
|
+
? confirmed.record.attachments
|
|
79
|
+
: declaredAttachments([attachments]),
|
|
80
|
+
}, confirmed);
|
|
52
81
|
}
|
|
53
|
-
|
|
82
|
+
function predicted(confirmed, batches, previous) {
|
|
83
|
+
const composition = compositionOf(confirmed.record);
|
|
84
|
+
let layer = confirmed.record;
|
|
85
|
+
const replay = [];
|
|
86
|
+
const prior = new Map(previous?.replay.map((step) => [step.id, step]) ?? []);
|
|
87
|
+
for (const batch of batches) {
|
|
88
|
+
const before = layer;
|
|
89
|
+
const old = prior.get(batch.id);
|
|
90
|
+
const hasMove = batch.changes.some((change) => change.kind === 'move');
|
|
91
|
+
const reuseRewrite = old?.collection !== undefined &&
|
|
92
|
+
sameLayerText(before, old.before) &&
|
|
93
|
+
old.collection.composition.model === composition.model &&
|
|
94
|
+
old.collection.composition.selection?.model === composition.selection?.model &&
|
|
95
|
+
JSON.stringify(old.collection.composition.selection?.roots) ===
|
|
96
|
+
JSON.stringify(composition.selection?.roots);
|
|
97
|
+
const collection = hasMove
|
|
98
|
+
? reuseRewrite
|
|
99
|
+
? old.collection
|
|
100
|
+
: parseCollection(before.documents, composition, old?.collection === undefined
|
|
101
|
+
? { text: confirmed.record.documents, collection: confirmed.collection }
|
|
102
|
+
: { text: old.before.documents, collection: old.collection })
|
|
103
|
+
: undefined;
|
|
104
|
+
const effective = collection === undefined
|
|
105
|
+
? batch
|
|
106
|
+
: reuseRewrite
|
|
107
|
+
? old.effective
|
|
108
|
+
: providerRewritten(batch, { ...before, collection });
|
|
109
|
+
layer =
|
|
110
|
+
old === undefined
|
|
111
|
+
? overlay(before, [effective])
|
|
112
|
+
: overlayChanged(before, [effective], old.before, [old.effective], old.after);
|
|
113
|
+
replay.push({
|
|
114
|
+
id: batch.id,
|
|
115
|
+
before,
|
|
116
|
+
after: layer,
|
|
117
|
+
effective,
|
|
118
|
+
...(collection === undefined ? {} : { collection }),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return { layer, replay };
|
|
122
|
+
}
|
|
123
|
+
export function replicaOf(confirmed, queue, previous) {
|
|
54
124
|
const batches = Object.freeze(queue.map(immutable));
|
|
55
125
|
if (batches.length === 0) {
|
|
56
126
|
return {
|
|
@@ -60,19 +130,138 @@ export function replicaOf(confirmed, queue) {
|
|
|
60
130
|
documents: confirmed.record.documents,
|
|
61
131
|
binaryTargets: confirmed.record.binaryTargets,
|
|
62
132
|
revisions: confirmed.record.revisions,
|
|
63
|
-
|
|
64
|
-
|
|
133
|
+
changes: confirmed.record.changes,
|
|
134
|
+
collection: confirmed.collection,
|
|
135
|
+
},
|
|
136
|
+
replay: [],
|
|
65
137
|
};
|
|
66
138
|
}
|
|
67
|
-
const layer =
|
|
139
|
+
const { layer, replay } = predicted(confirmed, batches, previous);
|
|
68
140
|
return {
|
|
69
141
|
confirmed,
|
|
70
142
|
queue: batches,
|
|
143
|
+
replay,
|
|
71
144
|
visible: {
|
|
72
145
|
...layer,
|
|
73
|
-
collection: parseCollection(layer.documents, compositionOf(confirmed.record)
|
|
146
|
+
collection: parseCollection(layer.documents, compositionOf(confirmed.record), previous === undefined
|
|
147
|
+
? undefined
|
|
148
|
+
: { text: previous.visible.documents, collection: previous.visible.collection }),
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function present(layer, path) {
|
|
153
|
+
return layer.documents[path] !== undefined || layer.binaryTargets.includes(path);
|
|
154
|
+
}
|
|
155
|
+
function holds(layer, preconditions) {
|
|
156
|
+
const parsed = new Map();
|
|
157
|
+
const documentAt = (path) => {
|
|
158
|
+
if (!parsed.has(path)) {
|
|
159
|
+
const text = layer.documents[path];
|
|
160
|
+
const opened = text === undefined ? null : parse(text, path);
|
|
161
|
+
parsed.set(path, opened?.ok === true ? opened.document : null);
|
|
74
162
|
}
|
|
163
|
+
return parsed.get(path) ?? null;
|
|
75
164
|
};
|
|
165
|
+
return preconditions.every((precondition) => {
|
|
166
|
+
const path = precondition.path;
|
|
167
|
+
if (precondition.kind === 'absent')
|
|
168
|
+
return !present(layer, path);
|
|
169
|
+
if (precondition.kind === 'present')
|
|
170
|
+
return present(layer, path);
|
|
171
|
+
if (precondition.kind === 'revision') {
|
|
172
|
+
return present(layer, path) && layer.revisions[path] === precondition.revision;
|
|
173
|
+
}
|
|
174
|
+
const document = documentAt(path);
|
|
175
|
+
if (document === null)
|
|
176
|
+
return false;
|
|
177
|
+
if (precondition.kind === 'field') {
|
|
178
|
+
const value = Object.hasOwn(document.fields, precondition.name)
|
|
179
|
+
? document.fields[precondition.name]
|
|
180
|
+
: undefined;
|
|
181
|
+
return equalValue(value, precondition.value);
|
|
182
|
+
}
|
|
183
|
+
if (precondition.kind === 'section') {
|
|
184
|
+
return (Object.hasOwn(document.sections, precondition.name) &&
|
|
185
|
+
document.sections[precondition.name] === precondition.value);
|
|
186
|
+
}
|
|
187
|
+
return document.preamble === precondition.value;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function effects(change) {
|
|
191
|
+
const path = change.path;
|
|
192
|
+
if (change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble') {
|
|
193
|
+
return [change];
|
|
194
|
+
}
|
|
195
|
+
if (change.kind === 'create' && !('content' in change)) {
|
|
196
|
+
return [
|
|
197
|
+
{ kind: 'present', path },
|
|
198
|
+
...Object.entries(change.fields).map(([name, value]) => ({
|
|
199
|
+
kind: 'field',
|
|
200
|
+
path,
|
|
201
|
+
name,
|
|
202
|
+
value,
|
|
203
|
+
})),
|
|
204
|
+
...Object.entries(change.sections).map(([name, value]) => ({
|
|
205
|
+
kind: 'section',
|
|
206
|
+
path,
|
|
207
|
+
name,
|
|
208
|
+
value,
|
|
209
|
+
})),
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
if (change.kind === 'move') {
|
|
213
|
+
return [
|
|
214
|
+
{ kind: 'absent', path },
|
|
215
|
+
{ kind: 'present', path: change.to },
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
return [{ kind: 'absent', path }];
|
|
219
|
+
}
|
|
220
|
+
function after(changes, index, path) {
|
|
221
|
+
let at = path;
|
|
222
|
+
for (const change of changes.slice(index + 1)) {
|
|
223
|
+
if (change.path !== at)
|
|
224
|
+
continue;
|
|
225
|
+
if (change.kind === 'remove')
|
|
226
|
+
return null;
|
|
227
|
+
if (change.kind === 'move')
|
|
228
|
+
at = change.to;
|
|
229
|
+
}
|
|
230
|
+
return at;
|
|
231
|
+
}
|
|
232
|
+
export function landed(batch, confirmed) {
|
|
233
|
+
const layer = confirmed.record;
|
|
234
|
+
return batch.changes.every((change, index) => {
|
|
235
|
+
if (change.kind === 'replace' || (change.kind === 'create' && 'content' in change)) {
|
|
236
|
+
const at = after(batch.changes, index, change.path);
|
|
237
|
+
return at === null || layer.documents[at] === change.content;
|
|
238
|
+
}
|
|
239
|
+
return effects(change).every((effect) => {
|
|
240
|
+
if (effect.kind === 'absent')
|
|
241
|
+
return holds(layer, [effect]);
|
|
242
|
+
const at = after(batch.changes, index, effect.path);
|
|
243
|
+
return at === null || holds(layer, [{ ...effect, path: at }]);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
export function withdrawals(confirmed, queue, withdrawable) {
|
|
248
|
+
if (!queue.some(withdrawable))
|
|
249
|
+
return [];
|
|
250
|
+
const composition = compositionOf(confirmed.record);
|
|
251
|
+
let layer = confirmed.record;
|
|
252
|
+
const withdrawn = [];
|
|
253
|
+
for (const batch of queue) {
|
|
254
|
+
if (withdrawable(batch) && !holds(layer, batch.preconditions)) {
|
|
255
|
+
withdrawn.push(batch);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const effective = batch.changes.some((change) => change.kind === 'move')
|
|
259
|
+
? providerRewritten(batch, {
|
|
260
|
+
...layer,
|
|
261
|
+
collection: parseCollection(layer.documents, composition),
|
|
262
|
+
})
|
|
263
|
+
: batch;
|
|
264
|
+
layer = overlay(layer, [effective]);
|
|
265
|
+
}
|
|
266
|
+
return withdrawn;
|
|
76
267
|
}
|
|
77
|
-
|
|
78
|
-
//# sourceMappingURL=replica.js.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
+
import type { Change, Precondition } from './change.js';
|
|
3
|
+
import type { VisibleLayer } from './replica.js';
|
|
4
|
+
export type FieldValue = {
|
|
5
|
+
readonly value: unknown;
|
|
6
|
+
} | null;
|
|
7
|
+
export type RoomDraftCreation = {
|
|
8
|
+
readonly type: string;
|
|
9
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
10
|
+
readonly sections: Readonly<Record<string, string>>;
|
|
11
|
+
} | {
|
|
12
|
+
readonly markdown: string;
|
|
13
|
+
};
|
|
14
|
+
export type RoomDraftParts = {
|
|
15
|
+
readonly fields?: Readonly<Record<string, {
|
|
16
|
+
readonly value: unknown;
|
|
17
|
+
readonly base?: FieldValue;
|
|
18
|
+
}>>;
|
|
19
|
+
readonly sections?: Readonly<Record<string, {
|
|
20
|
+
readonly value: string;
|
|
21
|
+
readonly base?: string;
|
|
22
|
+
}>>;
|
|
23
|
+
readonly preamble?: {
|
|
24
|
+
readonly value: string;
|
|
25
|
+
readonly base?: string;
|
|
26
|
+
};
|
|
27
|
+
readonly markdown?: {
|
|
28
|
+
readonly value: string;
|
|
29
|
+
readonly base?: string;
|
|
30
|
+
};
|
|
31
|
+
readonly creation?: RoomDraftCreation;
|
|
32
|
+
readonly move?: {
|
|
33
|
+
readonly to: string;
|
|
34
|
+
readonly base?: string | null;
|
|
35
|
+
};
|
|
36
|
+
readonly removal?: {
|
|
37
|
+
readonly base?: string | null;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
type HeldParts = {
|
|
41
|
+
readonly fields?: Readonly<Record<string, {
|
|
42
|
+
readonly value: unknown;
|
|
43
|
+
readonly base: FieldValue;
|
|
44
|
+
}>>;
|
|
45
|
+
readonly sections?: Readonly<Record<string, {
|
|
46
|
+
readonly value: string;
|
|
47
|
+
readonly base: string;
|
|
48
|
+
}>>;
|
|
49
|
+
readonly preamble?: {
|
|
50
|
+
readonly value: string;
|
|
51
|
+
readonly base: string;
|
|
52
|
+
};
|
|
53
|
+
readonly markdown?: {
|
|
54
|
+
readonly value: string;
|
|
55
|
+
readonly base: string;
|
|
56
|
+
};
|
|
57
|
+
readonly creation?: RoomDraftCreation;
|
|
58
|
+
readonly move?: {
|
|
59
|
+
readonly to: string;
|
|
60
|
+
readonly base: string | null;
|
|
61
|
+
};
|
|
62
|
+
readonly removal?: {
|
|
63
|
+
readonly base: string | null;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
type ChangedUnderneath = {
|
|
67
|
+
readonly fields?: Readonly<Record<string, FieldValue>>;
|
|
68
|
+
readonly sections?: Readonly<Record<string, string | null>>;
|
|
69
|
+
readonly preamble?: string | null;
|
|
70
|
+
readonly markdown?: string | null;
|
|
71
|
+
readonly creation?: string;
|
|
72
|
+
readonly move?: string | null;
|
|
73
|
+
readonly removal?: string | null;
|
|
74
|
+
};
|
|
75
|
+
export type ReturnReason = (ProviderRefusal & {
|
|
76
|
+
readonly kind: 'conflicted' | 'rejected';
|
|
77
|
+
}) | {
|
|
78
|
+
readonly kind: 'expired';
|
|
79
|
+
} | {
|
|
80
|
+
readonly kind: 'withdrawn';
|
|
81
|
+
};
|
|
82
|
+
export type RoomDraft = {
|
|
83
|
+
readonly room: string;
|
|
84
|
+
readonly path: string;
|
|
85
|
+
readonly revision: string;
|
|
86
|
+
readonly parts: HeldParts;
|
|
87
|
+
readonly changedUnderneath: ChangedUnderneath;
|
|
88
|
+
readonly returned: ReturnReason | null;
|
|
89
|
+
};
|
|
90
|
+
export type RoomDraftWrite = {
|
|
91
|
+
readonly outcome: 'written';
|
|
92
|
+
readonly roomDraft: RoomDraft | null;
|
|
93
|
+
} | {
|
|
94
|
+
readonly outcome: 'stale';
|
|
95
|
+
readonly current: RoomDraft | null;
|
|
96
|
+
};
|
|
97
|
+
export type ChangedPart = {
|
|
98
|
+
readonly path: string;
|
|
99
|
+
readonly part: 'field' | 'section' | 'preamble' | 'markdown' | 'creation' | 'move' | 'removal';
|
|
100
|
+
readonly name?: string;
|
|
101
|
+
};
|
|
102
|
+
export type RoomDraftRecord = {
|
|
103
|
+
readonly locator: string;
|
|
104
|
+
readonly path: string;
|
|
105
|
+
readonly revision: string;
|
|
106
|
+
readonly parts: HeldParts;
|
|
107
|
+
readonly returned: ReturnReason | null;
|
|
108
|
+
};
|
|
109
|
+
export type SavedDraft = {
|
|
110
|
+
readonly path: string;
|
|
111
|
+
readonly parts: HeldParts;
|
|
112
|
+
};
|
|
113
|
+
export declare function readParts(value: unknown): RoomDraftParts;
|
|
114
|
+
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts): HeldParts;
|
|
115
|
+
export declare function equalValue(left: unknown, right: unknown): boolean;
|
|
116
|
+
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
117
|
+
export declare function changedParts(path: string, report: ChangedUnderneath): readonly ChangedPart[];
|
|
118
|
+
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
119
|
+
export declare function moveTarget(move: {
|
|
120
|
+
readonly to: string;
|
|
121
|
+
}): string;
|
|
122
|
+
export declare function changesOf(path: string, parts: HeldParts): {
|
|
123
|
+
changes: readonly Change[];
|
|
124
|
+
bases: readonly Precondition[];
|
|
125
|
+
};
|
|
126
|
+
export {};
|
|
127
|
+
//# sourceMappingURL=room-draft.d.ts.map
|
|
@@ -0,0 +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;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GACzB;IAC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