@agentshouse/mdruntime 0.1.0-cfbf80d8d4644 → 0.1.0-cfcf93be6310b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -11
- package/dist/adapter.d.ts +182 -47
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +53 -6
- 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 +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +33 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +202 -48
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -56
- package/dist/change.d.ts +45 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +34 -0
- package/dist/client.d.ts +38 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +156 -20
- package/dist/collection.d.ts +13 -14
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +52 -56
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +789 -0
- package/dist/connection.d.ts +59 -20
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +4080 -879
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation.d.ts +51 -20
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +732 -242
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +4 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +20 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +152 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/fence.d.ts +6 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +10 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- package/dist/host.d.ts +11 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +128 -24
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +16 -1
- package/dist/index.d.ts +22 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/job.d.ts +14 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +28 -0
- package/dist/live.d.ts +23 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +127 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +20 -7
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +253 -92
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +89 -0
- package/dist/model.d.ts +19 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +10 -2
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +22 -4
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +120 -14
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +72 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +81 -1
- package/dist/overlay.d.ts +15 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +136 -180
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/phrase.d.ts +3 -0
- package/dist/phrase.d.ts.map +1 -0
- package/dist/phrase.js +8 -0
- package/dist/query.d.ts +75 -5
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +119 -26
- package/dist/reach.d.ts +18 -4
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +234 -69
- package/dist/react.d.ts +32 -19
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +13 -21
- package/dist/readiness.d.ts +50 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +27 -0
- package/dist/recovery.d.ts +26 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +224 -0
- package/dist/refresh.d.ts +20 -7
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +167 -59
- package/dist/replica.d.ts +59 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +324 -157
- package/dist/room-draft.d.ts +59 -11
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +276 -80
- package/dist/rows.d.ts +40 -34
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +202 -80
- package/dist/save.d.ts +73 -4
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +825 -152
- package/dist/search.d.ts +15 -54
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +10 -121
- 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 +421 -0
- package/dist/status.d.ts +7 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -9
- package/dist/store.d.ts +118 -59
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +354 -344
- package/dist/stored.d.ts +162 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +549 -0
- package/dist/tables.d.ts +353 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +585 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +29 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +104 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +170 -33
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +69 -31
- package/package.json +26 -15
- package/AGENTS.md +0 -232
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
- package/dist/read-side.d.ts +0 -18
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -377
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":"
|
|
1
|
+
{"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"AAQA,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;AAIxD,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,IA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,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,59 +1,68 @@
|
|
|
1
|
-
import { apply, parse, serialize } from '@agentshouse/mdmodel';
|
|
1
|
+
import { apply, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { runtimeError } from './failure.js';
|
|
3
|
+
import { sha256 } from './digest.js';
|
|
4
|
+
import { binaryLocalId } from './identity.js';
|
|
2
5
|
import { normalize } from './paths.js';
|
|
3
|
-
function
|
|
4
|
-
|
|
6
|
+
export function returnedBy(kind) {
|
|
7
|
+
return { kind, code: kind, fields: {}, retryable: false };
|
|
8
|
+
}
|
|
9
|
+
export function staleWrite(current) {
|
|
10
|
+
return { outcome: 'stale', code: 'stale', retryable: false, current };
|
|
11
|
+
}
|
|
12
|
+
function malformed(at, needs) {
|
|
13
|
+
throw runtimeError('room-draft-malformed', at === undefined ? 'room-draft-malformed' : `room-draft-malformed at ${at}: ${needs}`);
|
|
5
14
|
}
|
|
6
15
|
function plain(value) {
|
|
7
16
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
17
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
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
|
-
function text(value) {
|
|
18
|
-
return typeof value === 'string' ? value : malformed();
|
|
18
|
+
function text(value, at) {
|
|
19
|
+
return typeof value === 'string' ? value : malformed(at, 'text');
|
|
19
20
|
}
|
|
20
|
-
function optionalText(value) {
|
|
21
|
-
return value === undefined ? undefined : text(value);
|
|
21
|
+
function optionalText(value, at) {
|
|
22
|
+
return value === undefined ? undefined : text(value, at);
|
|
22
23
|
}
|
|
23
|
-
function markdownBase(value) {
|
|
24
|
-
return value === null ? null : optionalText(value);
|
|
24
|
+
function markdownBase(value, at) {
|
|
25
|
+
return value === null ? null : optionalText(value, at);
|
|
25
26
|
}
|
|
26
|
-
function entries(value, each) {
|
|
27
|
+
function entries(value, at, each) {
|
|
27
28
|
if (!plain(value))
|
|
28
|
-
malformed();
|
|
29
|
+
malformed(at, 'an object of named values');
|
|
29
30
|
const read = {};
|
|
30
31
|
for (const [name, item] of Object.entries(value))
|
|
31
|
-
read[name] = each(item);
|
|
32
|
+
read[name] = each(item, `${at}.${name}`);
|
|
32
33
|
return read;
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function frontmatter(item, at) {
|
|
36
|
+
return frontmatterValue(item) ? item : malformed(at, 'a frontmatter value');
|
|
37
|
+
}
|
|
38
|
+
function fieldValue(value, at) {
|
|
35
39
|
if (value === null)
|
|
36
40
|
return null;
|
|
37
41
|
if (!plain(value) || !Object.hasOwn(value, 'value') || !frontmatterValue(value.value)) {
|
|
38
|
-
malformed();
|
|
42
|
+
malformed(at, '{ value } with a frontmatter value, or null where the document lacks it');
|
|
39
43
|
}
|
|
40
44
|
return { value: value.value };
|
|
41
45
|
}
|
|
42
|
-
function textPart(value) {
|
|
46
|
+
function textPart(value, at) {
|
|
43
47
|
if (!plain(value))
|
|
44
|
-
malformed();
|
|
45
|
-
const base = optionalText(value.base);
|
|
46
|
-
return { value: text(value.value), ...(base === undefined ? {} : { base }) };
|
|
48
|
+
malformed(at, '{ value, base }');
|
|
49
|
+
const base = optionalText(value.base, `${at}.base`);
|
|
50
|
+
return { value: text(value.value, `${at}.value`), ...(base === undefined ? {} : { base }) };
|
|
47
51
|
}
|
|
48
|
-
function creationOf(value) {
|
|
52
|
+
function creationOf(value, at) {
|
|
49
53
|
if (!plain(value))
|
|
50
|
-
malformed();
|
|
54
|
+
malformed(at, '{ type, fields, sections }, or { markdown }');
|
|
51
55
|
if (Object.hasOwn(value, 'markdown'))
|
|
52
|
-
return { markdown: text(value.markdown) };
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
return { markdown: text(value.markdown, `${at}.markdown`) };
|
|
57
|
+
if (typeof value.type !== 'string')
|
|
58
|
+
malformed(`${at}.type`, 'a type name, or markdown in place of type, fields and sections');
|
|
59
|
+
return {
|
|
60
|
+
type: value.type,
|
|
61
|
+
fields: entries(value.fields, `${at}.fields`, frontmatter),
|
|
62
|
+
sections: entries(value.sections, `${at}.sections`, text),
|
|
63
|
+
};
|
|
55
64
|
}
|
|
56
|
-
const PART_NAMES =
|
|
65
|
+
const PART_NAMES = [
|
|
57
66
|
'fields',
|
|
58
67
|
'sections',
|
|
59
68
|
'preamble',
|
|
@@ -61,41 +70,59 @@ const PART_NAMES = new Set([
|
|
|
61
70
|
'creation',
|
|
62
71
|
'move',
|
|
63
72
|
'removal',
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
'file',
|
|
74
|
+
];
|
|
75
|
+
const NAMED_PARTS = `a part named ${PART_NAMES.slice(0, -1).join(', ')} or ${PART_NAMES.at(-1)}`;
|
|
76
|
+
export function readParts(value, path) {
|
|
77
|
+
if (!plain(value))
|
|
78
|
+
malformed(path, 'an object of parts');
|
|
79
|
+
const unknown = Object.keys(value).find((name) => !PART_NAMES.includes(name));
|
|
80
|
+
if (unknown !== undefined)
|
|
81
|
+
malformed(`${path} ${unknown}`, NAMED_PARTS);
|
|
68
82
|
const parts = {};
|
|
69
83
|
if (value.fields !== undefined) {
|
|
70
|
-
parts.fields = entries(value.fields, (item) => {
|
|
84
|
+
parts.fields = entries(value.fields, `${path} fields`, (item, at) => {
|
|
71
85
|
if (!plain(item) || !Object.hasOwn(item, 'value') || !frontmatterValue(item.value)) {
|
|
72
|
-
malformed();
|
|
86
|
+
malformed(at, '{ value, base } with a frontmatter value');
|
|
73
87
|
}
|
|
74
88
|
return item.base === undefined
|
|
75
89
|
? { value: item.value }
|
|
76
|
-
: { value: item.value, base: fieldValue(item.base) };
|
|
90
|
+
: { value: item.value, base: fieldValue(item.base, `${at}.base`) };
|
|
77
91
|
});
|
|
78
92
|
}
|
|
79
93
|
if (value.sections !== undefined)
|
|
80
|
-
parts.sections = entries(value.sections, textPart);
|
|
94
|
+
parts.sections = entries(value.sections, `${path} sections`, textPart);
|
|
81
95
|
if (value.preamble !== undefined)
|
|
82
|
-
parts.preamble = textPart(value.preamble);
|
|
96
|
+
parts.preamble = textPart(value.preamble, `${path} preamble`);
|
|
83
97
|
if (value.markdown !== undefined)
|
|
84
|
-
parts.markdown = textPart(value.markdown);
|
|
98
|
+
parts.markdown = textPart(value.markdown, `${path} markdown`);
|
|
85
99
|
if (value.creation !== undefined)
|
|
86
|
-
parts.creation = creationOf(value.creation);
|
|
100
|
+
parts.creation = creationOf(value.creation, `${path} creation`);
|
|
87
101
|
if (value.move !== undefined) {
|
|
88
102
|
if (!plain(value.move))
|
|
89
|
-
malformed();
|
|
90
|
-
const base = markdownBase(value.move.base);
|
|
91
|
-
|
|
103
|
+
malformed(`${path} move`, '{ to, room, base }');
|
|
104
|
+
const base = markdownBase(value.move.base, `${path} move.base`);
|
|
105
|
+
const room = optionalText(value.move.room, `${path} move.room`);
|
|
106
|
+
parts.move = {
|
|
107
|
+
to: text(value.move.to, `${path} move.to`),
|
|
108
|
+
...(room === undefined ? {} : { room }),
|
|
109
|
+
...(base === undefined ? {} : { base }),
|
|
110
|
+
};
|
|
92
111
|
}
|
|
93
112
|
if (value.removal !== undefined) {
|
|
94
113
|
if (!plain(value.removal))
|
|
95
|
-
malformed();
|
|
96
|
-
const base = markdownBase(value.removal.base);
|
|
114
|
+
malformed(`${path} removal`, '{ base }');
|
|
115
|
+
const base = markdownBase(value.removal.base, `${path} removal.base`);
|
|
97
116
|
parts.removal = base === undefined ? {} : { base };
|
|
98
117
|
}
|
|
118
|
+
if (value.file !== undefined) {
|
|
119
|
+
if (!plain(value.file) || !(value.file.blob instanceof Blob))
|
|
120
|
+
malformed(`${path} file`, '{ blob, base } with a Blob');
|
|
121
|
+
if (Object.keys(value).length > 1)
|
|
122
|
+
throw runtimeError('room-draft-file-exclusive');
|
|
123
|
+
const base = markdownBase(value.file.base, `${path} file.base`);
|
|
124
|
+
parts.file = base === undefined ? { blob: value.file.blob } : { blob: value.file.blob, base };
|
|
125
|
+
}
|
|
99
126
|
return parts;
|
|
100
127
|
}
|
|
101
128
|
function named(record) {
|
|
@@ -108,17 +135,78 @@ function kept(prior, base) {
|
|
|
108
135
|
if (prior !== undefined)
|
|
109
136
|
return prior.base;
|
|
110
137
|
if (base === undefined)
|
|
111
|
-
throw
|
|
138
|
+
throw runtimeError('room-draft-base-missing');
|
|
112
139
|
return base;
|
|
113
140
|
}
|
|
141
|
+
function movePart(current, move) {
|
|
142
|
+
return {
|
|
143
|
+
to: move.to,
|
|
144
|
+
...(move.room === undefined ? {} : { room: move.room }),
|
|
145
|
+
base: kept(current, move.base),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
114
148
|
function editsText(parts) {
|
|
115
149
|
return (parts.preamble !== undefined ||
|
|
116
150
|
named(parts.fields).length > 0 ||
|
|
117
151
|
named(parts.sections).length > 0);
|
|
118
152
|
}
|
|
119
|
-
|
|
153
|
+
function partNames(parts) {
|
|
154
|
+
const names = [];
|
|
155
|
+
for (const [name, part] of Object.entries(parts)) {
|
|
156
|
+
if (name === 'preamble' || name === 'markdown')
|
|
157
|
+
names.push(name);
|
|
158
|
+
else if ((name === 'fields' || name === 'sections') && plain(part))
|
|
159
|
+
names.push(...Object.keys(part).map((one) => `${name}/${one}`));
|
|
160
|
+
else
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return names.sort().join('\u0000');
|
|
164
|
+
}
|
|
165
|
+
function withBaseOf(prior, part) {
|
|
166
|
+
return plain(part) && plain(prior) && Object.hasOwn(prior, 'base')
|
|
167
|
+
? { ...part, base: prior.base }
|
|
168
|
+
: part;
|
|
169
|
+
}
|
|
170
|
+
export function gatheredParts(earlier, later) {
|
|
171
|
+
if (!plain(earlier) || !plain(later))
|
|
172
|
+
return null;
|
|
173
|
+
const named = partNames(earlier);
|
|
174
|
+
if (named === null || named !== partNames(later))
|
|
175
|
+
return null;
|
|
176
|
+
return Object.fromEntries(Object.entries(later).map(([name, part]) => [
|
|
177
|
+
name,
|
|
178
|
+
name === 'fields' || name === 'sections'
|
|
179
|
+
? Object.fromEntries(Object.entries(part).map(([one, value]) => [
|
|
180
|
+
one,
|
|
181
|
+
withBaseOf(earlier[name][one], value),
|
|
182
|
+
]))
|
|
183
|
+
: withBaseOf(earlier[name], part),
|
|
184
|
+
]));
|
|
185
|
+
}
|
|
186
|
+
export function held(current, parts, file) {
|
|
120
187
|
if (parts.markdown !== undefined && editsText(parts)) {
|
|
121
|
-
throw
|
|
188
|
+
throw runtimeError('room-draft-markdown-exclusive');
|
|
189
|
+
}
|
|
190
|
+
if (file !== undefined) {
|
|
191
|
+
if (current !== undefined && current.file === undefined) {
|
|
192
|
+
throw runtimeError('room-draft-file-exclusive');
|
|
193
|
+
}
|
|
194
|
+
return { file: { ...file, base: current?.file === undefined ? file.base : current.file.base } };
|
|
195
|
+
}
|
|
196
|
+
if (current?.file !== undefined) {
|
|
197
|
+
if (editsText(parts) ||
|
|
198
|
+
parts.markdown !== undefined ||
|
|
199
|
+
parts.creation !== undefined ||
|
|
200
|
+
(parts.move === undefined && parts.removal === undefined)) {
|
|
201
|
+
throw runtimeError('room-draft-file-exclusive');
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
file: current.file,
|
|
205
|
+
...(parts.move === undefined ? {} : { move: movePart(current.move, parts.move) }),
|
|
206
|
+
...(parts.removal === undefined
|
|
207
|
+
? {}
|
|
208
|
+
: { removal: { base: kept(current.removal, parts.removal.base) } }),
|
|
209
|
+
};
|
|
122
210
|
}
|
|
123
211
|
const next = {};
|
|
124
212
|
const fields = named(parts.fields);
|
|
@@ -149,24 +237,15 @@ export function held(current, parts) {
|
|
|
149
237
|
}
|
|
150
238
|
if (parts.creation !== undefined)
|
|
151
239
|
next.creation = parts.creation;
|
|
152
|
-
if (parts.move !== undefined)
|
|
153
|
-
next.move =
|
|
154
|
-
}
|
|
240
|
+
if (parts.move !== undefined)
|
|
241
|
+
next.move = movePart(current?.move, parts.move);
|
|
155
242
|
if (parts.removal !== undefined) {
|
|
156
243
|
next.removal = { base: kept(current?.removal, parts.removal.base) };
|
|
157
244
|
}
|
|
158
245
|
if (Object.keys(next).length === 0)
|
|
159
|
-
throw
|
|
246
|
+
throw runtimeError('room-draft-empty');
|
|
160
247
|
return next;
|
|
161
248
|
}
|
|
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
249
|
function sameField(left, right) {
|
|
171
250
|
if (left === null || right === null)
|
|
172
251
|
return left === right;
|
|
@@ -174,7 +253,7 @@ function sameField(left, right) {
|
|
|
174
253
|
}
|
|
175
254
|
export function underneath(parts, path, visible) {
|
|
176
255
|
const markdown = visible?.documents[path] ?? null;
|
|
177
|
-
const document = visible?.collection.
|
|
256
|
+
const document = visible?.collection.document(path);
|
|
178
257
|
const report = {};
|
|
179
258
|
const fields = {};
|
|
180
259
|
for (const [name, part] of named(parts.fields)) {
|
|
@@ -207,17 +286,41 @@ export function underneath(parts, path, visible) {
|
|
|
207
286
|
report.move = markdown;
|
|
208
287
|
if (parts.removal !== undefined && markdown !== parts.removal.base)
|
|
209
288
|
report.removal = markdown;
|
|
289
|
+
if (parts.file !== undefined) {
|
|
290
|
+
const file = binaryBase(visible, path);
|
|
291
|
+
if (file !== parts.file.base || markdown !== null)
|
|
292
|
+
report.file = file;
|
|
293
|
+
}
|
|
210
294
|
return report;
|
|
211
295
|
}
|
|
212
|
-
|
|
296
|
+
const UNTYPED_MEDIA_TYPE = 'application/octet-stream';
|
|
297
|
+
export async function heldFile(blob, base) {
|
|
298
|
+
return {
|
|
299
|
+
localId: binaryLocalId(),
|
|
300
|
+
...(blob instanceof File ? { name: blob.name } : {}),
|
|
301
|
+
byteLength: blob.size,
|
|
302
|
+
mediaType: blob.type === '' ? UNTYPED_MEDIA_TYPE : blob.type,
|
|
303
|
+
sha256: await sha256(blob),
|
|
304
|
+
base,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
export function binaryBase(visible, path) {
|
|
308
|
+
const binary = visible?.binaries[path];
|
|
309
|
+
if (binary === undefined)
|
|
310
|
+
return null;
|
|
311
|
+
return visible?.revisions[path] ?? (binary.state === 'pending' ? binary.localId : null);
|
|
312
|
+
}
|
|
313
|
+
export function changedParts(path, parts, visible) {
|
|
314
|
+
const report = underneath(parts, path, visible);
|
|
315
|
+
const made = parts.file?.base === null;
|
|
213
316
|
return [
|
|
214
|
-
...(report.creation === undefined ? [] : [{ path, part: 'creation' }]),
|
|
215
317
|
...named(report.fields).map(([name]) => ({ path, part: 'field', name })),
|
|
216
318
|
...named(report.sections).map(([name]) => ({ path, part: 'section', name })),
|
|
217
319
|
...(report.preamble === undefined ? [] : [{ path, part: 'preamble' }]),
|
|
218
320
|
...(report.markdown === undefined ? [] : [{ path, part: 'markdown' }]),
|
|
219
321
|
...(report.move === undefined ? [] : [{ path, part: 'move' }]),
|
|
220
322
|
...(report.removal === undefined ? [] : [{ path, part: 'removal' }]),
|
|
323
|
+
...(report.file === undefined || made ? [] : [{ path, part: 'file' }]),
|
|
221
324
|
];
|
|
222
325
|
}
|
|
223
326
|
function joined(existing, returned) {
|
|
@@ -227,23 +330,22 @@ function joined(existing, returned) {
|
|
|
227
330
|
merged[name] = part;
|
|
228
331
|
return Object.keys(merged).length === 0 ? undefined : merged;
|
|
229
332
|
}
|
|
230
|
-
function
|
|
333
|
+
export function lineEnded(text) {
|
|
231
334
|
return text === '' || text.endsWith('\n') ? text : `${text}\n`;
|
|
232
335
|
}
|
|
233
336
|
function frontmatterOf(fields) {
|
|
234
337
|
const opened = parse('---\n---\n');
|
|
235
338
|
if (!opened.ok)
|
|
236
339
|
return malformed();
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return serialize(document);
|
|
340
|
+
const next = apply(opened.document, fields.map(([name, part]) => ({
|
|
341
|
+
kind: 'field',
|
|
342
|
+
name,
|
|
343
|
+
value: part.value,
|
|
344
|
+
prior: undefined,
|
|
345
|
+
})));
|
|
346
|
+
return next.outcome === 'applied' ? serialize(next.document) : malformed();
|
|
245
347
|
}
|
|
246
|
-
function
|
|
348
|
+
export function partsAfter(markdown, parts) {
|
|
247
349
|
const fields = named(parts.fields);
|
|
248
350
|
const pieces = [
|
|
249
351
|
...(fields.length === 0 ? [] : [frontmatterOf(fields)]),
|
|
@@ -252,7 +354,7 @@ function concatenated(markdown, parts) {
|
|
|
252
354
|
];
|
|
253
355
|
if (pieces.length === 0)
|
|
254
356
|
return markdown;
|
|
255
|
-
return `${
|
|
357
|
+
return `${lineEnded(markdown)}\n${pieces.map(lineEnded).join('')}`;
|
|
256
358
|
}
|
|
257
359
|
export function returnedInto(existing, returned) {
|
|
258
360
|
if (existing === undefined)
|
|
@@ -274,24 +376,57 @@ export function returnedInto(existing, returned) {
|
|
|
274
376
|
delete next.fields;
|
|
275
377
|
delete next.sections;
|
|
276
378
|
delete next.preamble;
|
|
277
|
-
const value =
|
|
379
|
+
const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned);
|
|
278
380
|
next.markdown = { value, base: whole.base };
|
|
279
381
|
}
|
|
280
382
|
const creation = existing.creation ?? returned.creation;
|
|
281
383
|
const move = existing.move ?? returned.move;
|
|
282
384
|
const removal = existing.removal ?? returned.removal;
|
|
385
|
+
const file = existing.file ?? returned.file;
|
|
283
386
|
if (creation !== undefined)
|
|
284
387
|
next.creation = creation;
|
|
285
388
|
if (move !== undefined)
|
|
286
389
|
next.move = move;
|
|
287
390
|
if (removal !== undefined)
|
|
288
391
|
next.removal = removal;
|
|
392
|
+
if (file !== undefined)
|
|
393
|
+
next.file = file;
|
|
289
394
|
return next;
|
|
290
395
|
}
|
|
291
396
|
export function moveTarget(move) {
|
|
292
397
|
const to = normalize(move.to);
|
|
293
398
|
return to === null || to === '' ? move.to : to;
|
|
294
399
|
}
|
|
400
|
+
export function readSavedParts(named) {
|
|
401
|
+
const read = named.map(({ path, parts }) => ({ path, parts: readParts(parts, path) }));
|
|
402
|
+
read.forEach(({ path }, at) => {
|
|
403
|
+
if (path === '' || normalize(path) !== path)
|
|
404
|
+
malformed(path, 'a path inside the Room, such as notes/a.md');
|
|
405
|
+
if (read.findIndex((one) => one.path === path) !== at)
|
|
406
|
+
malformed(path, 'each path once in one save');
|
|
407
|
+
});
|
|
408
|
+
return read;
|
|
409
|
+
}
|
|
410
|
+
export function partsChanges(named) {
|
|
411
|
+
const changes = [];
|
|
412
|
+
const preconditions = [];
|
|
413
|
+
for (const { path, parts } of readSavedParts(named)) {
|
|
414
|
+
const parted = held(undefined, parts);
|
|
415
|
+
const made = changesOf(path, parted);
|
|
416
|
+
changes.push(...made.changes);
|
|
417
|
+
preconditions.push(...made.bases);
|
|
418
|
+
for (const change of made.changes) {
|
|
419
|
+
if (change.kind === 'create')
|
|
420
|
+
preconditions.push({ kind: 'absent', path });
|
|
421
|
+
if (change.kind === 'move')
|
|
422
|
+
preconditions.push({ kind: 'absent', path: change.to });
|
|
423
|
+
}
|
|
424
|
+
const revision = parted.markdown?.base ?? parted.move?.base ?? parted.removal?.base;
|
|
425
|
+
if (typeof revision === 'string')
|
|
426
|
+
preconditions.push({ kind: 'revision', path, revision });
|
|
427
|
+
}
|
|
428
|
+
return { changes, preconditions };
|
|
429
|
+
}
|
|
295
430
|
export function changesOf(path, parts) {
|
|
296
431
|
const changes = [];
|
|
297
432
|
const bases = [];
|
|
@@ -311,19 +446,80 @@ export function changesOf(path, parts) {
|
|
|
311
446
|
bases.push({ kind: 'field', path, name, value: part.base?.value });
|
|
312
447
|
}
|
|
313
448
|
for (const [name, part] of named(parts.sections)) {
|
|
314
|
-
changes.push({ kind: 'section', path, name, value: part.value });
|
|
449
|
+
changes.push({ kind: 'section', path, name, value: lineEnded(part.value) });
|
|
315
450
|
bases.push({ kind: 'section', path, name, value: part.base });
|
|
316
451
|
}
|
|
317
452
|
if (parts.preamble !== undefined) {
|
|
318
|
-
changes.push({ kind: 'preamble', path, value: parts.preamble.value });
|
|
453
|
+
changes.push({ kind: 'preamble', path, value: lineEnded(parts.preamble.value) });
|
|
319
454
|
bases.push({ kind: 'preamble', path, value: parts.preamble.base });
|
|
320
455
|
}
|
|
321
456
|
if (parts.markdown !== undefined) {
|
|
322
457
|
changes.push({ kind: 'replace', path, content: parts.markdown.value });
|
|
323
458
|
}
|
|
459
|
+
if (parts.file !== undefined && parts.removal === undefined) {
|
|
460
|
+
const { base, name: _name, ...file } = parts.file;
|
|
461
|
+
const at = parts.move === undefined ? path : moveTarget(parts.move);
|
|
462
|
+
if (base !== null && at !== path)
|
|
463
|
+
changes.push({ kind: 'move', path, to: at });
|
|
464
|
+
changes.push({ kind: 'binary', path: at, ...file });
|
|
465
|
+
if (base === null)
|
|
466
|
+
bases.push({ kind: 'absent', path: at });
|
|
467
|
+
return { changes, bases };
|
|
468
|
+
}
|
|
469
|
+
if (parts.file?.base === null)
|
|
470
|
+
return { changes, bases };
|
|
324
471
|
if (parts.move !== undefined)
|
|
325
472
|
changes.push({ kind: 'move', path, to: moveTarget(parts.move) });
|
|
326
473
|
if (parts.removal !== undefined)
|
|
327
474
|
changes.push({ kind: 'remove', path });
|
|
328
475
|
return { changes, bases };
|
|
329
476
|
}
|
|
477
|
+
function rebased(before, after) {
|
|
478
|
+
return before === undefined ? after : { ...after, base: before.base };
|
|
479
|
+
}
|
|
480
|
+
function rebasedAll(before, after) {
|
|
481
|
+
return {
|
|
482
|
+
...before,
|
|
483
|
+
...Object.fromEntries(Object.entries(after).map(([name, part]) => [name, rebased(before?.[name], part)])),
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
export function joinedDraft(carried, saved) {
|
|
487
|
+
const draft = saved.find((item) => item.path === carried.path);
|
|
488
|
+
if (draft === undefined)
|
|
489
|
+
return carried;
|
|
490
|
+
const held = carried.parts;
|
|
491
|
+
const next = draft.parts;
|
|
492
|
+
return {
|
|
493
|
+
path: carried.path,
|
|
494
|
+
parts: {
|
|
495
|
+
...held,
|
|
496
|
+
...next,
|
|
497
|
+
...(next.fields === undefined ? {} : { fields: rebasedAll(held.fields, next.fields) }),
|
|
498
|
+
...(next.sections === undefined
|
|
499
|
+
? {}
|
|
500
|
+
: { sections: rebasedAll(held.sections, next.sections) }),
|
|
501
|
+
...(next.preamble === undefined ? {} : { preamble: rebased(held.preamble, next.preamble) }),
|
|
502
|
+
...(next.markdown === undefined ? {} : { markdown: rebased(held.markdown, next.markdown) }),
|
|
503
|
+
},
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
export function withdrawnDrafts(drafts, changes) {
|
|
507
|
+
return drafts.flatMap((draft) => {
|
|
508
|
+
const file = draft.parts.file;
|
|
509
|
+
const at = draft.parts.move?.to ?? draft.path;
|
|
510
|
+
const change = changes.find((item) => (item.kind === 'move' || item.kind === 'remove') && item.path === at);
|
|
511
|
+
if (file === undefined || change === undefined)
|
|
512
|
+
return [draft];
|
|
513
|
+
if (change.kind === 'move') {
|
|
514
|
+
return [
|
|
515
|
+
{
|
|
516
|
+
path: draft.path,
|
|
517
|
+
parts: change.to === draft.path ? { file } : { file, move: { to: change.to, base: null } },
|
|
518
|
+
},
|
|
519
|
+
];
|
|
520
|
+
}
|
|
521
|
+
return file.base === null
|
|
522
|
+
? []
|
|
523
|
+
: [{ path: draft.path, parts: { file, removal: { base: null } } }];
|
|
524
|
+
});
|
|
525
|
+
}
|
package/dist/rows.d.ts
CHANGED
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { HeadChange } from './adapter.js';
|
|
1
|
+
import { type Outline } from '@agentshouse/mdmodel';
|
|
3
2
|
import { type Composition } from './collection.js';
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
values: Fields;
|
|
13
|
-
sizes: Readonly<Record<string, number>>;
|
|
14
|
-
directories: readonly string[];
|
|
15
|
-
body: string;
|
|
16
|
-
change: HeadChange | null;
|
|
3
|
+
export type ValueKind = 'string' | 'number' | 'boolean' | 'null' | 'array' | 'object' | 'undefined';
|
|
4
|
+
type HeldValue = {
|
|
5
|
+
readonly keys: string;
|
|
6
|
+
readonly places: string;
|
|
7
|
+
readonly item: number;
|
|
8
|
+
readonly kind: ValueKind;
|
|
9
|
+
readonly value: string | number | null;
|
|
10
|
+
readonly size: number | null;
|
|
17
11
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
kind:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
markdown: string;
|
|
12
|
+
type LinkKind = 'field' | 'section' | 'body';
|
|
13
|
+
type HeldLink = {
|
|
14
|
+
readonly kind: LinkKind;
|
|
15
|
+
readonly keys: string;
|
|
16
|
+
readonly places: string;
|
|
17
|
+
readonly target: string;
|
|
18
|
+
readonly field: string;
|
|
26
19
|
};
|
|
27
|
-
export type
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
export type Described = {
|
|
21
|
+
readonly type: string | null;
|
|
22
|
+
readonly declared: string | null;
|
|
23
|
+
readonly queried: boolean;
|
|
24
|
+
readonly folder: string;
|
|
25
|
+
readonly fields: string | null;
|
|
26
|
+
};
|
|
27
|
+
export type Derived = Described & {
|
|
28
|
+
readonly values: readonly HeldValue[];
|
|
29
|
+
readonly links: readonly HeldLink[];
|
|
36
30
|
};
|
|
37
|
-
export type Row = DocumentRow | BodyRow | ReferenceRow;
|
|
38
31
|
export declare function documentKey(room: string, path: string): string;
|
|
39
|
-
export declare function
|
|
32
|
+
export declare function roomOfKey(key: string): string;
|
|
33
|
+
export declare function pathOfKey(key: string): string;
|
|
34
|
+
export declare function markdownPath(path: string): boolean;
|
|
35
|
+
export declare function folderOf(path: string): string;
|
|
36
|
+
export type Reach = 'exact' | 'value' | 'link';
|
|
37
|
+
export type Placed = {
|
|
38
|
+
readonly keys: string;
|
|
39
|
+
readonly places: string;
|
|
40
|
+
readonly glob: boolean;
|
|
41
|
+
};
|
|
42
|
+
export declare function placedOf(pointer: string, reach: Reach): Placed;
|
|
43
|
+
export declare function kindOf(value: unknown): ValueKind;
|
|
44
|
+
export declare function described(path: string, content: string | null, outlined: Outline | null): Described;
|
|
45
|
+
export declare function derived(path: string, content: string | null, outlined: Outline | null, composition: Composition): Derived;
|
|
40
46
|
export {};
|
|
41
47
|
//# 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/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,OAAO,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAA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