@agentshouse/mdruntime 0.1.0-ce531b51ff088 → 0.1.0-cebcd51f70ed1
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 +57 -20
- package/README.md +10 -10
- package/dist/adapter.d.ts +52 -25
- 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 +34 -0
- package/dist/bootstrap.d.ts +5 -3
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +3 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -10
- package/dist/connection.d.ts +10 -12
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +501 -512
- package/dist/conversation.d.ts +18 -6
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +179 -78
- package/dist/host.d.ts +7 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +34 -31
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/memory.d.ts +11 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +78 -26
- package/dist/model.d.ts +4 -11
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +4 -3
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +24 -14
- 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 +8 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +104 -36
- package/dist/reach.d.ts +40 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +270 -0
- package/dist/react.d.ts +32 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +62 -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 +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +7 -3
- package/dist/replica.d.ts +4 -4
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +12 -13
- package/dist/room-draft.d.ts +3 -0
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +6 -4
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +75 -38
- package/dist/save.d.ts +1 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +90 -48
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/wire.d.ts +51 -16
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +50 -59
- package/package.json +14 -2
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,18 +7,59 @@ function keyOf(...parts) {
|
|
|
7
7
|
export function documentKey(room, path) {
|
|
8
8
|
return keyOf('d', room, path);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function plainObject(value) {
|
|
11
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
13
|
+
function compared(reading, exact, value) {
|
|
14
|
+
if (!reading.references.has(exact))
|
|
15
|
+
return value;
|
|
16
|
+
return (typeof value === 'string' ? target(reading.path, value) : null) ?? undefined;
|
|
15
17
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
function record(reading, node, forms, exact) {
|
|
19
|
+
const value = Array.isArray(node)
|
|
20
|
+
? node.map((item, index) => compared(reading, `${exact}/${index}`, item))
|
|
21
|
+
: compared(reading, exact, node);
|
|
22
|
+
for (const form of forms) {
|
|
23
|
+
if (form.pending)
|
|
24
|
+
continue;
|
|
25
|
+
(reading.reached[form.text] ??= []).push(value);
|
|
26
|
+
if (!form.through && value !== undefined && !plainObject(value)) {
|
|
27
|
+
reading.values[form.text] = value;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(node) || plainObject(node) || !reading.references.has(exact))
|
|
31
|
+
return;
|
|
32
|
+
const found = compared(reading, exact, node);
|
|
33
|
+
if (typeof found !== 'string')
|
|
34
|
+
return;
|
|
35
|
+
const field = forms
|
|
36
|
+
.map((form) => form.text)
|
|
37
|
+
.reduce((left, right) => (right.length < left.length ? right : left));
|
|
38
|
+
const known = reading.targets.get(`${field}\u0000${found}`);
|
|
39
|
+
const kept = known ?? { field, target: found, forms: new Set() };
|
|
40
|
+
for (const form of forms)
|
|
41
|
+
kept.forms.add(form.text);
|
|
42
|
+
reading.targets.set(`${field}\u0000${found}`, kept);
|
|
43
|
+
}
|
|
44
|
+
function walk(reading, node, forms, exact) {
|
|
45
|
+
record(reading, node, forms, exact);
|
|
46
|
+
if (Array.isArray(node)) {
|
|
47
|
+
node.forEach((item, index) => walk(reading, item, forms.flatMap((form) => [
|
|
48
|
+
...(form.pending
|
|
49
|
+
? []
|
|
50
|
+
: [{ text: `${form.text}/${index}`, through: form.through, pending: false }]),
|
|
51
|
+
{ text: form.text, through: true, pending: true },
|
|
52
|
+
]), `${exact}/${index}`));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!plainObject(node))
|
|
56
|
+
return;
|
|
57
|
+
for (const [key, value] of Object.entries(node)) {
|
|
58
|
+
const segment = escapePointer(key);
|
|
59
|
+
walk(reading, value, forms.flatMap((form) => form.pending && ARRAY_INDEX.test(key)
|
|
60
|
+
? []
|
|
61
|
+
: [{ text: `${form.text}/${segment}`, through: form.through, pending: false }]), `${exact}/${segment}`);
|
|
62
|
+
}
|
|
22
63
|
}
|
|
23
64
|
function directoriesOf(path) {
|
|
24
65
|
const parts = path.split('/').slice(0, -1);
|
|
@@ -37,7 +78,7 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
37
78
|
type: null,
|
|
38
79
|
fields: {},
|
|
39
80
|
values: {},
|
|
40
|
-
|
|
81
|
+
reached: {},
|
|
41
82
|
directories: directoriesOf(path),
|
|
42
83
|
body,
|
|
43
84
|
change,
|
|
@@ -46,32 +87,18 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
46
87
|
}
|
|
47
88
|
const type = document.type ?? 'any';
|
|
48
89
|
const definition = definitionOf(governing(composition, path), document.type);
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
90
|
+
const reading = {
|
|
91
|
+
path,
|
|
92
|
+
references: new Set(definition === undefined ? [] : references(document, definition).map((one) => one.pointer)),
|
|
93
|
+
values: {},
|
|
94
|
+
reached: {},
|
|
95
|
+
targets: new Map(),
|
|
96
|
+
};
|
|
52
97
|
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
|
-
}
|
|
98
|
+
const segment = escapePointer(name);
|
|
99
|
+
walk(reading, value, [{ text: `/${segment}`, through: false, pending: false }], `/${segment}`);
|
|
74
100
|
}
|
|
101
|
+
const { values, reached } = reading;
|
|
75
102
|
return [
|
|
76
103
|
{
|
|
77
104
|
key,
|
|
@@ -81,7 +108,7 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
81
108
|
type,
|
|
82
109
|
fields: document.fields,
|
|
83
110
|
values,
|
|
84
|
-
|
|
111
|
+
reached,
|
|
85
112
|
directories: directoriesOf(path),
|
|
86
113
|
body,
|
|
87
114
|
change,
|
|
@@ -95,6 +122,16 @@ export function rowsOf(room, path, document, composition, change) {
|
|
|
95
122
|
sections: document.sections,
|
|
96
123
|
markdown: document.content,
|
|
97
124
|
},
|
|
98
|
-
...
|
|
125
|
+
...[...reading.targets.values()].map(({ field, target: found, forms }) => ({
|
|
126
|
+
key: keyOf('r', room, path, field, found),
|
|
127
|
+
kind: 'reference',
|
|
128
|
+
room,
|
|
129
|
+
source: key,
|
|
130
|
+
target: documentKey(room, found),
|
|
131
|
+
field,
|
|
132
|
+
forms: [...forms].sort(),
|
|
133
|
+
path,
|
|
134
|
+
type,
|
|
135
|
+
})),
|
|
99
136
|
];
|
|
100
137
|
}
|
package/dist/save.d.ts
CHANGED
|
@@ -10,15 +10,14 @@ export type SaveRefusal = {
|
|
|
10
10
|
referrers?: readonly string[];
|
|
11
11
|
parts?: readonly ChangedPart[];
|
|
12
12
|
};
|
|
13
|
-
export type Rewriting = 'runtime' | 'provider';
|
|
14
13
|
export type SaveInput = {
|
|
15
14
|
composition: Composition;
|
|
16
|
-
rewriting: Rewriting;
|
|
17
15
|
baseRoomVersion: string;
|
|
18
16
|
operations: import('./adapter.js').OperationScopes;
|
|
19
17
|
providerOwnedPaths: readonly string[];
|
|
20
18
|
providerLimits: readonly ProviderLimit[];
|
|
21
19
|
visible: VisibleLayer;
|
|
20
|
+
handle: string;
|
|
22
21
|
changes: readonly Change[];
|
|
23
22
|
bases: readonly Precondition[];
|
|
24
23
|
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,EAKL,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,WAAW,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,cAAc,EAAE,eAAe,CAAC;IACnD,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AA+K9C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,GAAG,WAAW,CAOxF;AAsQD,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAyFxD"}
|
package/dist/save.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { definitionOf } from './model.js';
|
|
2
|
-
import { apply, links, parse, retarget, serialize, target, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { apply, ATTACHMENT, links, parse, pointerSegments, references, relative, relativize, retarget, serialize, target, } from '@agentshouse/mdmodel';
|
|
3
3
|
import { immutable, } from './change.js';
|
|
4
4
|
import { governing, parseCollection, validateCollection, } from './collection.js';
|
|
5
5
|
import { changeBatchIdentity } from './identity.js';
|
|
6
6
|
import { overlay } from './overlay.js';
|
|
7
|
-
import { covered, normalize
|
|
7
|
+
import { covered, normalize } from './paths.js';
|
|
8
8
|
function refuse(rule, file, location) {
|
|
9
9
|
return {
|
|
10
10
|
kind: 'refused',
|
|
@@ -15,21 +15,34 @@ function refuse(rule, file, location) {
|
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
function repointed(document, definition, from, to, moves, settled) {
|
|
19
|
+
const parsed = parse(document.content, from);
|
|
20
|
+
if (!parsed.ok)
|
|
21
|
+
return [];
|
|
22
|
+
let next = parsed.document;
|
|
23
|
+
const names = new Set();
|
|
24
|
+
for (const { pointer, value } of definition === undefined
|
|
25
|
+
? []
|
|
26
|
+
: references(document, definition)) {
|
|
27
|
+
const [name = ''] = pointerSegments(pointer);
|
|
28
|
+
const named = target(from, value);
|
|
29
|
+
if (named === null || settled.has(`${from} ${name}`))
|
|
30
|
+
continue;
|
|
31
|
+
const destination = moves.get(named) ?? named;
|
|
32
|
+
if (target(to, value) === destination)
|
|
33
|
+
continue;
|
|
34
|
+
const applied = apply(next, {
|
|
35
|
+
kind: 'reference',
|
|
36
|
+
pointer,
|
|
37
|
+
value: retarget(value, relative(to, destination)),
|
|
38
|
+
prior: value,
|
|
39
|
+
});
|
|
40
|
+
if (applied.outcome !== 'applied')
|
|
41
|
+
continue;
|
|
42
|
+
next = applied.document;
|
|
43
|
+
names.add(name);
|
|
25
44
|
}
|
|
26
|
-
|
|
27
|
-
return undefined;
|
|
28
|
-
const named = target(from, value);
|
|
29
|
-
if (named === null)
|
|
30
|
-
return undefined;
|
|
31
|
-
const destination = moves.get(named) ?? named;
|
|
32
|
-
return target(to, value) === destination ? undefined : retarget(value, relative(to, destination));
|
|
45
|
+
return [...names].map((name) => ({ kind: 'field', path: from, name, value: next.fields[name] }));
|
|
33
46
|
}
|
|
34
47
|
function edited(document, path, changes) {
|
|
35
48
|
let next = document;
|
|
@@ -122,14 +135,7 @@ function rewrites(changes, visible) {
|
|
|
122
135
|
continue;
|
|
123
136
|
const moved = moves.get(path) ?? path;
|
|
124
137
|
const definition = definitionOf(governing(visible.collection.composition, path), document.type);
|
|
125
|
-
|
|
126
|
-
if (!referenceField(spec) || settled.has(`${path} ${name}`))
|
|
127
|
-
continue;
|
|
128
|
-
const value = repointed(document.fields[name], path, moved, moves);
|
|
129
|
-
if (value === undefined)
|
|
130
|
-
continue;
|
|
131
|
-
added.push({ kind: 'field', path, name, value });
|
|
132
|
-
}
|
|
138
|
+
added.push(...repointed(document, definition, path, moved, moves, settled));
|
|
133
139
|
const relinked = relinks(path, moved, edited(document, path, merged), moves);
|
|
134
140
|
if (relinked.kind === 'refused')
|
|
135
141
|
return relinked;
|
|
@@ -166,18 +172,6 @@ export function providerRewritten(batch, visible) {
|
|
|
166
172
|
...anticipated(batch.changes, batch.preconditions, rewritten.changes, visible),
|
|
167
173
|
};
|
|
168
174
|
}
|
|
169
|
-
function targets(value, from) {
|
|
170
|
-
const values = Array.isArray(value) ? value : [value];
|
|
171
|
-
const resolved = [];
|
|
172
|
-
for (const item of values) {
|
|
173
|
-
if (typeof item !== 'string')
|
|
174
|
-
continue;
|
|
175
|
-
const named = target(from, item);
|
|
176
|
-
if (named !== null)
|
|
177
|
-
resolved.push(named);
|
|
178
|
-
}
|
|
179
|
-
return resolved;
|
|
180
|
-
}
|
|
181
175
|
function incoming(collection, removed) {
|
|
182
176
|
const found = new Map();
|
|
183
177
|
const note = (target, file) => {
|
|
@@ -189,14 +183,13 @@ function incoming(collection, removed) {
|
|
|
189
183
|
};
|
|
190
184
|
for (const [path, document] of Object.entries(collection.documents)) {
|
|
191
185
|
const definition = definitionOf(governing(collection.composition, path), document.type);
|
|
192
|
-
for (const
|
|
193
|
-
if (
|
|
186
|
+
for (const { value, to } of definition === undefined ? [] : references(document, definition)) {
|
|
187
|
+
if (to.includes(ATTACHMENT))
|
|
194
188
|
continue;
|
|
195
|
-
|
|
189
|
+
const named = target(path, value);
|
|
190
|
+
if (named !== null)
|
|
196
191
|
note(named, path);
|
|
197
192
|
}
|
|
198
|
-
for (const link of links(document, path))
|
|
199
|
-
note(link.target, path);
|
|
200
193
|
}
|
|
201
194
|
const [first] = [...found.keys()].sort();
|
|
202
195
|
if (first === undefined)
|
|
@@ -368,26 +361,75 @@ function exceeded(limits, changes, resulting) {
|
|
|
368
361
|
}
|
|
369
362
|
return null;
|
|
370
363
|
}
|
|
364
|
+
function shellRelative(text, path, handle, definition) {
|
|
365
|
+
if (!text.includes(`/rooms/${handle}/`))
|
|
366
|
+
return null;
|
|
367
|
+
const parsed = parse(text, path);
|
|
368
|
+
if (!parsed.ok)
|
|
369
|
+
return null;
|
|
370
|
+
const result = relativize(parsed.document, path, handle, definition(parsed.document.type));
|
|
371
|
+
return result.outcome === 'applied' && result.document.content !== text ? result.document : null;
|
|
372
|
+
}
|
|
373
|
+
function relativeField(path, name, value, handle, definition) {
|
|
374
|
+
const opened = parse('---\n---\n');
|
|
375
|
+
if (definition === undefined ||
|
|
376
|
+
!opened.ok ||
|
|
377
|
+
!JSON.stringify(value ?? null).includes(`/rooms/${handle}/`))
|
|
378
|
+
return value;
|
|
379
|
+
const held = apply(opened.document, { kind: 'field', name, value, prior: undefined });
|
|
380
|
+
if (held.outcome !== 'applied')
|
|
381
|
+
return value;
|
|
382
|
+
const result = relativize(held.document, path, handle, definition);
|
|
383
|
+
return result.outcome === 'applied' ? result.document.fields[name] : value;
|
|
384
|
+
}
|
|
385
|
+
function relativeChanges(input) {
|
|
386
|
+
const { handle, composition, visible } = input;
|
|
387
|
+
const typed = (path) => (type) => definitionOf(governing(composition, path), type);
|
|
388
|
+
const body = (path, text) => shellRelative(text, path, handle, () => undefined)?.content ?? text;
|
|
389
|
+
return input.changes.map((change) => {
|
|
390
|
+
const definition = typed(change.path);
|
|
391
|
+
if (change.kind === 'field') {
|
|
392
|
+
const type = visible.collection.documents[change.path]?.type;
|
|
393
|
+
const value = relativeField(change.path, change.name, change.value, handle, definition(type));
|
|
394
|
+
return value === change.value ? change : { ...change, value };
|
|
395
|
+
}
|
|
396
|
+
if (change.kind === 'section' || change.kind === 'preamble') {
|
|
397
|
+
const value = body(change.path, change.value);
|
|
398
|
+
return value === change.value ? change : { ...change, value };
|
|
399
|
+
}
|
|
400
|
+
if (change.kind === 'replace' || (change.kind === 'create' && 'content' in change)) {
|
|
401
|
+
const content = shellRelative(change.content, change.path, handle, definition)?.content ?? change.content;
|
|
402
|
+
return content === change.content ? change : { ...change, content };
|
|
403
|
+
}
|
|
404
|
+
if (change.kind !== 'create')
|
|
405
|
+
return change;
|
|
406
|
+
const type = typeof change.fields.type === 'string' ? change.fields.type : undefined;
|
|
407
|
+
const fields = Object.fromEntries(Object.entries(change.fields).map(([name, value]) => [
|
|
408
|
+
name,
|
|
409
|
+
relativeField(change.path, name, value, handle, definition(type)),
|
|
410
|
+
]));
|
|
411
|
+
const sections = Object.fromEntries(Object.entries(change.sections).map(([name, value]) => [name, body(change.path, value)]));
|
|
412
|
+
return { ...change, fields, sections };
|
|
413
|
+
});
|
|
414
|
+
}
|
|
371
415
|
export function buildBatch(input) {
|
|
372
|
-
const
|
|
416
|
+
const changes = relativeChanges(input);
|
|
417
|
+
const structural = changes.find((change) => change.kind === 'move' || change.kind === 'remove');
|
|
373
418
|
if (structural !== undefined &&
|
|
374
419
|
Object.entries(input.visible.collection.documents).some(([path, document]) => document.type !== undefined &&
|
|
375
420
|
document.type !== 'any' &&
|
|
376
421
|
governing(input.composition, path).status === 'unavailable'))
|
|
377
422
|
return refuse('model-unavailable', structural.path);
|
|
378
|
-
if (
|
|
423
|
+
if (changes.length === 0)
|
|
379
424
|
return refuse('no-change');
|
|
380
|
-
const rewritten = rewrites(
|
|
425
|
+
const rewritten = rewrites(changes, input.visible);
|
|
381
426
|
if (rewritten.kind === 'refused')
|
|
382
427
|
return rewritten;
|
|
383
|
-
const changes = input.rewriting === 'provider' ? input.changes : rewritten.changes;
|
|
384
428
|
const refusal = guard(changes, input);
|
|
385
429
|
if (refusal !== null)
|
|
386
430
|
return refusal;
|
|
387
431
|
const preconditions = preconditionsOf(changes, input.visible, input.bases);
|
|
388
|
-
const predicted = input.
|
|
389
|
-
? anticipated(changes, preconditions, rewritten.changes, input.visible)
|
|
390
|
-
: { changes, preconditions };
|
|
432
|
+
const predicted = anticipated(changes, preconditions, rewritten.changes, input.visible);
|
|
391
433
|
const resulting = overlay(input.visible, [
|
|
392
434
|
{ id: '', baseRoomVersion: input.baseRoomVersion, ...predicted },
|
|
393
435
|
]);
|
package/dist/store.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
|
|
|
8
8
|
export type ReplicaRecord = {
|
|
9
9
|
locator: string;
|
|
10
10
|
name: string;
|
|
11
|
+
handle: string;
|
|
11
12
|
operations: OperationScopes;
|
|
12
13
|
replica: ReplicaAdmission;
|
|
13
14
|
model: ModelState;
|
|
14
|
-
attachedModel: import('./model.js').ModelIdentity | null;
|
|
15
15
|
typedSelection: TypedSelection | null;
|
|
16
16
|
selectionModel: ModelState;
|
|
17
17
|
providerOwnedPaths: readonly string[];
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiBnE,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE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
|
3
|
-
export declare const PROTOCOL_MISMATCH: ConnectionRefusal;
|
|
4
2
|
export type RuntimePort = {
|
|
5
3
|
postMessage(message: unknown): void;
|
|
6
4
|
addEventListener(type: 'message' | 'close', listener: (event: {
|
|
@@ -8,10 +6,57 @@ export type RuntimePort = {
|
|
|
8
6
|
}) => void): void;
|
|
9
7
|
start(): void;
|
|
10
8
|
};
|
|
11
|
-
|
|
12
|
-
declare const
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export type WireReach = 'within' | 'app' | 'runtime' | 'actions' | 'whole';
|
|
10
|
+
declare const MEMBERS: {
|
|
11
|
+
readonly rooms: 'within';
|
|
12
|
+
readonly query: 'within';
|
|
13
|
+
readonly search: 'within';
|
|
14
|
+
readonly types: 'within';
|
|
15
|
+
readonly save: 'within';
|
|
16
|
+
readonly history: 'within';
|
|
17
|
+
readonly call: 'actions';
|
|
18
|
+
readonly reached: 'within';
|
|
19
|
+
readonly log: 'whole';
|
|
20
|
+
readonly persistence: 'runtime';
|
|
21
|
+
readonly reauthorize: 'runtime';
|
|
22
|
+
readonly 'roomDraft.list': 'within';
|
|
23
|
+
readonly 'roomDraft.read': 'within';
|
|
24
|
+
readonly 'roomDraft.write': 'within';
|
|
25
|
+
readonly 'roomDraft.discard': 'within';
|
|
26
|
+
readonly 'presentation.read': 'app';
|
|
27
|
+
readonly 'presentation.write': 'app';
|
|
28
|
+
readonly 'conversation.list': 'within';
|
|
29
|
+
readonly 'conversation.read': 'within';
|
|
30
|
+
readonly 'conversation.create': 'within';
|
|
31
|
+
readonly 'conversation.send': 'within';
|
|
32
|
+
readonly 'conversation.answer': 'within';
|
|
33
|
+
readonly 'conversation.interrupt': 'within';
|
|
34
|
+
readonly 'conversation.kill': 'within';
|
|
35
|
+
readonly 'conversation.cancel': 'within';
|
|
36
|
+
readonly 'conversation.delete': 'within';
|
|
37
|
+
readonly 'chatDraft.write': 'within';
|
|
38
|
+
readonly 'chatDraft.discard': 'within';
|
|
39
|
+
};
|
|
40
|
+
declare const TOPICS: {
|
|
41
|
+
readonly rooms: 'within';
|
|
42
|
+
readonly 'connection-refusal': 'runtime';
|
|
43
|
+
readonly 'storage-loss': 'runtime';
|
|
44
|
+
readonly 'deployment-facts': 'runtime';
|
|
45
|
+
readonly 'sync-status': 'within';
|
|
46
|
+
readonly 'service-mode': 'runtime';
|
|
47
|
+
readonly query: 'within';
|
|
48
|
+
readonly queue: 'within';
|
|
49
|
+
readonly 'room-drafts': 'within';
|
|
50
|
+
readonly presentation: 'app';
|
|
51
|
+
readonly conversation: 'within';
|
|
52
|
+
readonly conversations: 'within';
|
|
53
|
+
};
|
|
54
|
+
export declare const WIRE_REACH: {
|
|
55
|
+
readonly members: Readonly<Record<string, WireReach>>;
|
|
56
|
+
readonly topics: Readonly<Record<string, WireReach>>;
|
|
57
|
+
};
|
|
58
|
+
export type WireMember = keyof typeof MEMBERS;
|
|
59
|
+
export type WireTopic = keyof typeof TOPICS;
|
|
15
60
|
export type WireRequest = {
|
|
16
61
|
kind: 'hello';
|
|
17
62
|
} | {
|
|
@@ -48,16 +93,6 @@ export type WireAnswer = {
|
|
|
48
93
|
};
|
|
49
94
|
export declare const AUTHORIZATION_ENDED = "the host authorization ended";
|
|
50
95
|
export declare const PORT_CLOSED = "the port closed";
|
|
51
|
-
export type WireEnvelope = {
|
|
52
|
-
mdRuntime: number;
|
|
53
|
-
message: WireRequest | WireAnswer;
|
|
54
|
-
};
|
|
55
|
-
export type Carried = {
|
|
56
|
-
matching: boolean;
|
|
57
|
-
message: unknown;
|
|
58
|
-
};
|
|
59
|
-
export declare function envelope(message: WireRequest | WireAnswer): WireEnvelope;
|
|
60
|
-
export declare function carried(data: unknown): Carried | null;
|
|
61
96
|
export declare function request(message: unknown): WireRequest | null;
|
|
62
97
|
export declare function answer(message: unknown): WireAnswer | null;
|
|
63
98
|
export {};
|
package/dist/wire.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRo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M,mBAAmB,iCAAiC,CAAC;AAElE,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAQ7C,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAiC5D;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAe1D"}
|
package/dist/wire.js
CHANGED
|
@@ -1,63 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const MEMBERS = {
|
|
2
|
+
rooms: 'within',
|
|
3
|
+
query: 'within',
|
|
4
|
+
search: 'within',
|
|
5
|
+
types: 'within',
|
|
6
|
+
save: 'within',
|
|
7
|
+
history: 'within',
|
|
8
|
+
call: 'actions',
|
|
9
|
+
reached: 'within',
|
|
10
|
+
log: 'whole',
|
|
11
|
+
persistence: 'runtime',
|
|
12
|
+
reauthorize: 'runtime',
|
|
13
|
+
'roomDraft.list': 'within',
|
|
14
|
+
'roomDraft.read': 'within',
|
|
15
|
+
'roomDraft.write': 'within',
|
|
16
|
+
'roomDraft.discard': 'within',
|
|
17
|
+
'presentation.read': 'app',
|
|
18
|
+
'presentation.write': 'app',
|
|
19
|
+
'conversation.list': 'within',
|
|
20
|
+
'conversation.read': 'within',
|
|
21
|
+
'conversation.create': 'within',
|
|
22
|
+
'conversation.send': 'within',
|
|
23
|
+
'conversation.answer': 'within',
|
|
24
|
+
'conversation.interrupt': 'within',
|
|
25
|
+
'conversation.kill': 'within',
|
|
26
|
+
'conversation.cancel': 'within',
|
|
27
|
+
'conversation.delete': 'within',
|
|
28
|
+
'chatDraft.write': 'within',
|
|
29
|
+
'chatDraft.discard': 'within',
|
|
6
30
|
};
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'roomDraft.discard',
|
|
23
|
-
'presentation.read',
|
|
24
|
-
'presentation.write',
|
|
25
|
-
'conversation.list',
|
|
26
|
-
'conversation.read',
|
|
27
|
-
'conversation.create',
|
|
28
|
-
'conversation.send',
|
|
29
|
-
'conversation.answer',
|
|
30
|
-
'conversation.interrupt',
|
|
31
|
-
'conversation.kill',
|
|
32
|
-
'conversation.cancel',
|
|
33
|
-
'conversation.delete',
|
|
34
|
-
'chatDraft.write',
|
|
35
|
-
'chatDraft.discard',
|
|
36
|
-
];
|
|
37
|
-
const TOPICS = [
|
|
38
|
-
'rooms',
|
|
39
|
-
'connection-refusal',
|
|
40
|
-
'storage-loss',
|
|
41
|
-
'deployment-facts',
|
|
42
|
-
'sync-status',
|
|
43
|
-
'service-mode',
|
|
44
|
-
'query',
|
|
45
|
-
'queue',
|
|
46
|
-
'room-drafts',
|
|
47
|
-
'presentation',
|
|
48
|
-
'conversation',
|
|
49
|
-
];
|
|
31
|
+
const TOPICS = {
|
|
32
|
+
rooms: 'within',
|
|
33
|
+
'connection-refusal': 'runtime',
|
|
34
|
+
'storage-loss': 'runtime',
|
|
35
|
+
'deployment-facts': 'runtime',
|
|
36
|
+
'sync-status': 'within',
|
|
37
|
+
'service-mode': 'runtime',
|
|
38
|
+
query: 'within',
|
|
39
|
+
queue: 'within',
|
|
40
|
+
'room-drafts': 'within',
|
|
41
|
+
presentation: 'app',
|
|
42
|
+
conversation: 'within',
|
|
43
|
+
conversations: 'within',
|
|
44
|
+
};
|
|
45
|
+
export const WIRE_REACH = { members: MEMBERS, topics: TOPICS };
|
|
50
46
|
export const AUTHORIZATION_ENDED = 'the host authorization ended';
|
|
51
47
|
export const PORT_CLOSED = 'the port closed';
|
|
52
|
-
export function envelope(message) {
|
|
53
|
-
return { mdRuntime: RUNTIME_WIRE_PROTOCOL, message };
|
|
54
|
-
}
|
|
55
|
-
export function carried(data) {
|
|
56
|
-
if (typeof data !== 'object' || data === null || !('mdRuntime' in data))
|
|
57
|
-
return null;
|
|
58
|
-
const record = data;
|
|
59
|
-
return { matching: record.mdRuntime === RUNTIME_WIRE_PROTOCOL, message: record.message };
|
|
60
|
-
}
|
|
61
48
|
function body(message) {
|
|
62
49
|
if (typeof message !== 'object' || message === null)
|
|
63
50
|
return null;
|
|
@@ -77,7 +64,9 @@ export function request(message) {
|
|
|
77
64
|
return { kind: 'stop', id: shape.id };
|
|
78
65
|
if (!Array.isArray(record.input))
|
|
79
66
|
return null;
|
|
80
|
-
if (shape.kind === 'call' &&
|
|
67
|
+
if (shape.kind === 'call' &&
|
|
68
|
+
typeof record.member === 'string' &&
|
|
69
|
+
Object.hasOwn(MEMBERS, record.member)) {
|
|
81
70
|
return {
|
|
82
71
|
kind: 'call',
|
|
83
72
|
id: shape.id,
|
|
@@ -85,7 +74,9 @@ export function request(message) {
|
|
|
85
74
|
input: record.input,
|
|
86
75
|
};
|
|
87
76
|
}
|
|
88
|
-
if (shape.kind === 'observe' &&
|
|
77
|
+
if (shape.kind === 'observe' &&
|
|
78
|
+
typeof record.topic === 'string' &&
|
|
79
|
+
Object.hasOwn(TOPICS, record.topic)) {
|
|
89
80
|
return {
|
|
90
81
|
kind: 'observe',
|
|
91
82
|
id: shape.id,
|