@agentshouse/mdruntime 0.1.0-c8c4b020a3ec7 → 0.1.0-c967d1ca66fee
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 +94 -33
- package/README.md +10 -10
- package/dist/adapter.d.ts +92 -46
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +1 -9
- package/dist/attached-model.d.ts +11 -0
- package/dist/attached-model.d.ts.map +1 -0
- package/dist/attached-model.js +47 -0
- package/dist/bootstrap.d.ts +20 -6
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +89 -35
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +13 -7
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/client.d.ts +8 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +57 -24
- package/dist/collection.d.ts +6 -11
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +56 -19
- package/dist/connection.d.ts +20 -16
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +711 -587
- package/dist/conversation.d.ts +23 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +252 -106
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/host.d.ts +8 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +38 -38
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +7 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/memory.d.ts +12 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +108 -36
- package/dist/model.d.ts +13 -12
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -3
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +24 -14
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/outcome.d.ts +22 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +35 -1
- package/dist/overlay.d.ts +1 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +19 -15
- package/dist/paths.d.ts +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +0 -16
- package/dist/query.d.ts +10 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +78 -36
- package/dist/reach.d.ts +40 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +272 -0
- package/dist/react.d.ts +40 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +64 -0
- package/dist/read-side.d.ts +4 -0
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +116 -54
- package/dist/refresh.d.ts +12 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +35 -22
- package/dist/replica.d.ts +6 -6
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +53 -39
- package/dist/room-draft.d.ts +11 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +19 -26
- package/dist/rows.d.ts +4 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +82 -39
- package/dist/save.d.ts +4 -3
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +127 -68
- package/dist/search.d.ts +3 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/status.d.ts +2 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -8
- package/dist/store.d.ts +25 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +206 -90
- package/dist/wire.d.ts +55 -19
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +62 -61
- package/package.json +14 -2
package/dist/room-draft.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
+
import type { Open } from './open.js';
|
|
2
3
|
import type { Change, Precondition } from './change.js';
|
|
3
4
|
import type { VisibleLayer } from './replica.js';
|
|
4
5
|
export type FieldValue = {
|
|
@@ -72,13 +73,10 @@ type ChangedUnderneath = {
|
|
|
72
73
|
readonly move?: string | null;
|
|
73
74
|
readonly removal?: string | null;
|
|
74
75
|
};
|
|
75
|
-
export type ReturnReason =
|
|
76
|
-
readonly kind: 'conflicted' | 'rejected';
|
|
77
|
-
}) | {
|
|
78
|
-
readonly kind: 'expired';
|
|
79
|
-
} | {
|
|
80
|
-
readonly kind: 'withdrawn';
|
|
76
|
+
export type ReturnReason = ProviderRefusal & {
|
|
77
|
+
readonly kind: 'conflicted' | 'rejected' | 'expired' | 'withdrawn';
|
|
81
78
|
};
|
|
79
|
+
export declare function returnedBy(kind: 'expired' | 'withdrawn'): ReturnReason;
|
|
82
80
|
export type RoomDraft = {
|
|
83
81
|
readonly room: string;
|
|
84
82
|
readonly path: string;
|
|
@@ -92,11 +90,14 @@ export type RoomDraftWrite = {
|
|
|
92
90
|
readonly roomDraft: RoomDraft | null;
|
|
93
91
|
} | {
|
|
94
92
|
readonly outcome: 'stale';
|
|
93
|
+
readonly code: string;
|
|
94
|
+
readonly retryable: boolean;
|
|
95
95
|
readonly current: RoomDraft | null;
|
|
96
96
|
};
|
|
97
|
+
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
97
98
|
export type ChangedPart = {
|
|
98
99
|
readonly path: string;
|
|
99
|
-
readonly part: 'field' | 'section' | 'preamble' | 'markdown' | 'creation' | 'move' | 'removal'
|
|
100
|
+
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'creation' | 'move' | 'removal'>;
|
|
100
101
|
readonly name?: string;
|
|
101
102
|
};
|
|
102
103
|
export type RoomDraftRecord = {
|
|
@@ -112,10 +113,12 @@ export type SavedDraft = {
|
|
|
112
113
|
};
|
|
113
114
|
export declare function readParts(value: unknown): RoomDraftParts;
|
|
114
115
|
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts): HeldParts;
|
|
115
|
-
export declare function equalValue(left: unknown, right: unknown): boolean;
|
|
116
116
|
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
117
117
|
export declare function changedParts(path: string, report: ChangedUnderneath): readonly ChangedPart[];
|
|
118
118
|
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
|
|
119
|
+
export declare function moveTarget(move: {
|
|
120
|
+
readonly to: string;
|
|
121
|
+
}): string;
|
|
119
122
|
export declare function changesOf(path: string, parts: HeldParts): {
|
|
120
123
|
changes: readonly Change[];
|
|
121
124
|
bases: readonly Precondition[];
|
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;
|
|
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;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;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,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M,EACZ,KAAK,EAAE,SAAS,GACf;IAAE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAA;CAAE,CAkChE"}
|
package/dist/room-draft.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { apply, parse, serialize } from '@agentshouse/mdmodel';
|
|
1
|
+
import { apply, equalValue, frontmatterValue, parse, serialize } from '@agentshouse/mdmodel';
|
|
2
|
+
import { runtimeError } from './failure.js';
|
|
2
3
|
import { normalize } from './paths.js';
|
|
4
|
+
export function returnedBy(kind) {
|
|
5
|
+
return { kind, code: kind, fields: {}, retryable: false };
|
|
6
|
+
}
|
|
7
|
+
export function staleWrite(current) {
|
|
8
|
+
return { outcome: 'stale', code: 'stale', retryable: false, current };
|
|
9
|
+
}
|
|
3
10
|
function malformed() {
|
|
4
|
-
throw
|
|
11
|
+
throw runtimeError('room-draft-malformed');
|
|
5
12
|
}
|
|
6
13
|
function plain(value) {
|
|
7
14
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
15
|
}
|
|
9
|
-
function frontmatterValue(value) {
|
|
10
|
-
if (Array.isArray(value))
|
|
11
|
-
return value.every(frontmatterValue);
|
|
12
|
-
return (value === null ||
|
|
13
|
-
typeof value === 'string' ||
|
|
14
|
-
typeof value === 'boolean' ||
|
|
15
|
-
(typeof value === 'number' && Number.isFinite(value)));
|
|
16
|
-
}
|
|
17
16
|
function text(value) {
|
|
18
17
|
return typeof value === 'string' ? value : malformed();
|
|
19
18
|
}
|
|
@@ -108,7 +107,7 @@ function kept(prior, base) {
|
|
|
108
107
|
if (prior !== undefined)
|
|
109
108
|
return prior.base;
|
|
110
109
|
if (base === undefined)
|
|
111
|
-
throw
|
|
110
|
+
throw runtimeError('room-draft-base-missing');
|
|
112
111
|
return base;
|
|
113
112
|
}
|
|
114
113
|
function editsText(parts) {
|
|
@@ -118,7 +117,7 @@ function editsText(parts) {
|
|
|
118
117
|
}
|
|
119
118
|
export function held(current, parts) {
|
|
120
119
|
if (parts.markdown !== undefined && editsText(parts)) {
|
|
121
|
-
throw
|
|
120
|
+
throw runtimeError('room-draft-markdown-exclusive');
|
|
122
121
|
}
|
|
123
122
|
const next = {};
|
|
124
123
|
const fields = named(parts.fields);
|
|
@@ -156,17 +155,9 @@ export function held(current, parts) {
|
|
|
156
155
|
next.removal = { base: kept(current?.removal, parts.removal.base) };
|
|
157
156
|
}
|
|
158
157
|
if (Object.keys(next).length === 0)
|
|
159
|
-
throw
|
|
158
|
+
throw runtimeError('room-draft-empty');
|
|
160
159
|
return next;
|
|
161
160
|
}
|
|
162
|
-
export function equalValue(left, right) {
|
|
163
|
-
if (left === right)
|
|
164
|
-
return true;
|
|
165
|
-
return (Array.isArray(left) &&
|
|
166
|
-
Array.isArray(right) &&
|
|
167
|
-
left.length === right.length &&
|
|
168
|
-
left.every((item, index) => equalValue(item, right[index])));
|
|
169
|
-
}
|
|
170
161
|
function sameField(left, right) {
|
|
171
162
|
if (left === null || right === null)
|
|
172
163
|
return left === right;
|
|
@@ -174,7 +165,7 @@ function sameField(left, right) {
|
|
|
174
165
|
}
|
|
175
166
|
export function underneath(parts, path, visible) {
|
|
176
167
|
const markdown = visible?.documents[path] ?? null;
|
|
177
|
-
const document = visible?.collection.
|
|
168
|
+
const document = visible?.collection.document(path);
|
|
178
169
|
const report = {};
|
|
179
170
|
const fields = {};
|
|
180
171
|
for (const [name, part] of named(parts.fields)) {
|
|
@@ -288,6 +279,10 @@ export function returnedInto(existing, returned) {
|
|
|
288
279
|
next.removal = removal;
|
|
289
280
|
return next;
|
|
290
281
|
}
|
|
282
|
+
export function moveTarget(move) {
|
|
283
|
+
const to = normalize(move.to);
|
|
284
|
+
return to === null || to === '' ? move.to : to;
|
|
285
|
+
}
|
|
291
286
|
export function changesOf(path, parts) {
|
|
292
287
|
const changes = [];
|
|
293
288
|
const bases = [];
|
|
@@ -317,10 +312,8 @@ export function changesOf(path, parts) {
|
|
|
317
312
|
if (parts.markdown !== undefined) {
|
|
318
313
|
changes.push({ kind: 'replace', path, content: parts.markdown.value });
|
|
319
314
|
}
|
|
320
|
-
if (parts.move !== undefined)
|
|
321
|
-
|
|
322
|
-
changes.push({ kind: 'move', path, to: to === null || to === '' ? parts.move.to : to });
|
|
323
|
-
}
|
|
315
|
+
if (parts.move !== undefined)
|
|
316
|
+
changes.push({ kind: 'move', path, to: moveTarget(parts.move) });
|
|
324
317
|
if (parts.removal !== undefined)
|
|
325
318
|
changes.push({ kind: 'remove', path });
|
|
326
319
|
return { changes, bases };
|
package/dist/rows.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type DocumentRow = {
|
|
|
10
10
|
type: string | null;
|
|
11
11
|
fields: Fields;
|
|
12
12
|
values: Fields;
|
|
13
|
-
|
|
13
|
+
reached: Readonly<Record<string, readonly unknown[]>>;
|
|
14
14
|
directories: readonly string[];
|
|
15
15
|
body: string;
|
|
16
16
|
change: HeadChange | null;
|
|
@@ -31,11 +31,14 @@ export type ReferenceRow = {
|
|
|
31
31
|
source: string;
|
|
32
32
|
target: string;
|
|
33
33
|
field: string;
|
|
34
|
+
forms: readonly string[];
|
|
34
35
|
path: string;
|
|
35
36
|
type: string;
|
|
36
37
|
};
|
|
37
38
|
export type Row = DocumentRow | BodyRow | ReferenceRow;
|
|
38
39
|
export declare function documentKey(room: string, path: string): string;
|
|
40
|
+
export declare function roomOfKey(key: string): string;
|
|
41
|
+
export declare function markdownPath(path: string): boolean;
|
|
39
42
|
export declare function rowsOf(room: string, path: string, document: Document | null, composition: Composition, change: HeadChange | null): readonly Row[];
|
|
40
43
|
export {};
|
|
41
44
|
//# 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,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src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,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,GACxB,SAAS,GAAG,EAAE,CAuEhB"}
|
package/dist/rows.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { target } from '@agentshouse/mdmodel';
|
|
1
|
+
import { ARRAY_INDEX, escapePointer, references, target, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { governing } from './collection.js';
|
|
3
3
|
import { definitionOf } from './model.js';
|
|
4
4
|
function keyOf(...parts) {
|
|
@@ -7,27 +7,74 @@ function keyOf(...parts) {
|
|
|
7
7
|
export function documentKey(room, path) {
|
|
8
8
|
return keyOf('d', room, path);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
export function roomOfKey(key) {
|
|
11
|
+
return key.split('\u0000')[1];
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return typeof value === '
|
|
13
|
+
function plainObject(value) {
|
|
14
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
function compared(reading, exact, value) {
|
|
17
|
+
if (!reading.references.has(exact))
|
|
18
|
+
return value;
|
|
19
|
+
return (typeof value === 'string' ? target(reading.path, value) : null) ?? undefined;
|
|
20
|
+
}
|
|
21
|
+
function record(reading, node, forms, exact) {
|
|
22
|
+
const value = Array.isArray(node)
|
|
23
|
+
? node.map((item, index) => compared(reading, `${exact}/${index}`, item))
|
|
24
|
+
: compared(reading, exact, node);
|
|
25
|
+
for (const form of forms) {
|
|
26
|
+
if (form.pending)
|
|
27
|
+
continue;
|
|
28
|
+
(reading.reached[form.text] ??= []).push(value);
|
|
29
|
+
if (!form.through && value !== undefined && !plainObject(value)) {
|
|
30
|
+
reading.values[form.text] = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(node) || plainObject(node) || !reading.references.has(exact))
|
|
34
|
+
return;
|
|
35
|
+
const found = compared(reading, exact, node);
|
|
36
|
+
if (typeof found !== 'string')
|
|
37
|
+
return;
|
|
38
|
+
const field = forms
|
|
39
|
+
.map((form) => form.text)
|
|
40
|
+
.reduce((left, right) => (right.length < left.length ? right : left));
|
|
41
|
+
const known = reading.targets.get(`${field}\u0000${found}`);
|
|
42
|
+
const kept = known ?? { field, target: found, forms: new Set() };
|
|
43
|
+
for (const form of forms)
|
|
44
|
+
kept.forms.add(form.text);
|
|
45
|
+
reading.targets.set(`${field}\u0000${found}`, kept);
|
|
46
|
+
}
|
|
47
|
+
function walk(reading, node, forms, exact) {
|
|
48
|
+
record(reading, node, forms, exact);
|
|
49
|
+
if (Array.isArray(node)) {
|
|
50
|
+
node.forEach((item, index) => walk(reading, item, forms.flatMap((form) => [
|
|
51
|
+
...(form.pending
|
|
52
|
+
? []
|
|
53
|
+
: [{ text: `${form.text}/${index}`, through: form.through, pending: false }]),
|
|
54
|
+
{ text: form.text, through: true, pending: true },
|
|
55
|
+
]), `${exact}/${index}`));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!plainObject(node))
|
|
59
|
+
return;
|
|
60
|
+
for (const [key, value] of Object.entries(node)) {
|
|
61
|
+
const segment = escapePointer(key);
|
|
62
|
+
walk(reading, value, forms.flatMap((form) => form.pending && ARRAY_INDEX.test(key)
|
|
63
|
+
? []
|
|
64
|
+
: [{ text: `${form.text}/${segment}`, through: form.through, pending: false }]), `${exact}/${segment}`);
|
|
65
|
+
}
|
|
22
66
|
}
|
|
23
67
|
function directoriesOf(path) {
|
|
24
68
|
const parts = path.split('/').slice(0, -1);
|
|
25
69
|
return ['', ...parts.map((_, index) => parts.slice(0, index + 1).join('/'))];
|
|
26
70
|
}
|
|
71
|
+
export function markdownPath(path) {
|
|
72
|
+
return path.endsWith('.md');
|
|
73
|
+
}
|
|
27
74
|
export function rowsOf(room, path, document, composition, change) {
|
|
28
75
|
const key = documentKey(room, path);
|
|
29
76
|
const body = keyOf('b', room, path);
|
|
30
|
-
if (document === null || !path
|
|
77
|
+
if (document === null || !markdownPath(path)) {
|
|
31
78
|
return [
|
|
32
79
|
{
|
|
33
80
|
key,
|
|
@@ -37,7 +84,7 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
37
84
|
type: null,
|
|
38
85
|
fields: {},
|
|
39
86
|
values: {},
|
|
40
|
-
|
|
87
|
+
reached: {},
|
|
41
88
|
directories: directoriesOf(path),
|
|
42
89
|
body,
|
|
43
90
|
change,
|
|
@@ -46,32 +93,18 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
46
93
|
}
|
|
47
94
|
const type = document.type ?? 'any';
|
|
48
95
|
const definition = definitionOf(governing(composition, path), document.type);
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
96
|
+
const reading = {
|
|
97
|
+
path,
|
|
98
|
+
references: new Set(definition === undefined ? [] : references(document, definition).map((one) => one.pointer)),
|
|
99
|
+
values: {},
|
|
100
|
+
reached: {},
|
|
101
|
+
targets: new Map(),
|
|
102
|
+
};
|
|
52
103
|
for (const [name, value] of Object.entries(document.fields)) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
if (compared !== undefined)
|
|
56
|
-
values[name] = compared;
|
|
57
|
-
if (Array.isArray(value))
|
|
58
|
-
sizes[name] = value.length;
|
|
59
|
-
if (!reference)
|
|
60
|
-
continue;
|
|
61
|
-
const targets = [compared].flat().filter((found) => typeof found === 'string');
|
|
62
|
-
for (const found of new Set(targets)) {
|
|
63
|
-
references.push({
|
|
64
|
-
key: keyOf('r', room, path, name, found),
|
|
65
|
-
kind: 'reference',
|
|
66
|
-
room,
|
|
67
|
-
source: key,
|
|
68
|
-
target: documentKey(room, found),
|
|
69
|
-
field: name,
|
|
70
|
-
path,
|
|
71
|
-
type,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
104
|
+
const segment = escapePointer(name);
|
|
105
|
+
walk(reading, value, [{ text: `/${segment}`, through: false, pending: false }], `/${segment}`);
|
|
74
106
|
}
|
|
107
|
+
const { values, reached } = reading;
|
|
75
108
|
return [
|
|
76
109
|
{
|
|
77
110
|
key,
|
|
@@ -81,7 +114,7 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
81
114
|
type,
|
|
82
115
|
fields: document.fields,
|
|
83
116
|
values,
|
|
84
|
-
|
|
117
|
+
reached,
|
|
85
118
|
directories: directoriesOf(path),
|
|
86
119
|
body,
|
|
87
120
|
change,
|
|
@@ -95,6 +128,16 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
95
128
|
sections: document.sections,
|
|
96
129
|
markdown: document.content,
|
|
97
130
|
},
|
|
98
|
-
...
|
|
131
|
+
...[...reading.targets.values()].map(({ field, target: found, forms }) => ({
|
|
132
|
+
key: keyOf('r', room, path, field, found),
|
|
133
|
+
kind: 'reference',
|
|
134
|
+
room,
|
|
135
|
+
source: key,
|
|
136
|
+
target: documentKey(room, found),
|
|
137
|
+
field,
|
|
138
|
+
forms: [...forms].sort(),
|
|
139
|
+
path,
|
|
140
|
+
type,
|
|
141
|
+
})),
|
|
99
142
|
];
|
|
100
143
|
}
|
package/dist/save.d.ts
CHANGED
|
@@ -4,21 +4,22 @@ import { type Composition } from './collection.js';
|
|
|
4
4
|
import type { VisibleLayer } from './replica.js';
|
|
5
5
|
import type { ChangedPart } from './room-draft.js';
|
|
6
6
|
export type SaveRefusal = {
|
|
7
|
-
|
|
7
|
+
code: string;
|
|
8
|
+
retryable: boolean;
|
|
8
9
|
file?: string;
|
|
9
10
|
location?: string;
|
|
10
11
|
referrers?: readonly string[];
|
|
11
12
|
parts?: readonly ChangedPart[];
|
|
12
13
|
};
|
|
13
|
-
export type Rewriting = 'runtime' | 'provider';
|
|
14
14
|
export type SaveInput = {
|
|
15
|
+
local: boolean;
|
|
15
16
|
composition: Composition;
|
|
16
|
-
rewriting: Rewriting;
|
|
17
17
|
baseRoomVersion: string;
|
|
18
18
|
operations: import('./adapter.js').OperationScopes;
|
|
19
19
|
providerOwnedPaths: readonly string[];
|
|
20
20
|
providerLimits: readonly ProviderLimit[];
|
|
21
21
|
visible: VisibleLayer;
|
|
22
|
+
handle: string;
|
|
22
23
|
changes: readonly Change[];
|
|
23
24
|
bases: readonly Precondition[];
|
|
24
25
|
writtenBy?: WrittenBy;
|
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":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,M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