@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/react.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
export function useObserve(client, topic, ...input) {
|
|
3
|
+
const key = JSON.stringify([topic, ...input]);
|
|
4
|
+
const [held, setHeld] = useState(null);
|
|
5
|
+
const opened = useRef(input);
|
|
6
|
+
opened.current = input;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (client === null)
|
|
9
|
+
return;
|
|
10
|
+
let live = true;
|
|
11
|
+
let observation = null;
|
|
12
|
+
const observe = client.observe;
|
|
13
|
+
void observe(topic, ...opened.current).then((open) => {
|
|
14
|
+
if (!live) {
|
|
15
|
+
open.close();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
observation = open;
|
|
19
|
+
const take = (value) => {
|
|
20
|
+
if (live)
|
|
21
|
+
setHeld({ client, key, value });
|
|
22
|
+
};
|
|
23
|
+
take(open.current());
|
|
24
|
+
open.subscribe(take);
|
|
25
|
+
});
|
|
26
|
+
return () => {
|
|
27
|
+
live = false;
|
|
28
|
+
observation?.close();
|
|
29
|
+
};
|
|
30
|
+
}, [client, key]);
|
|
31
|
+
return held !== null && held.client === client && held.key === key ? held.value : undefined;
|
|
32
|
+
}
|
|
33
|
+
const IDLE = { busy: false, outcome: null, failure: null };
|
|
34
|
+
export async function saveRoomDrafts(client, room, roomDrafts) {
|
|
35
|
+
const kept = [];
|
|
36
|
+
for (const [path, parts] of roomDrafts) {
|
|
37
|
+
const prior = await client.roomDraft.read(room, path);
|
|
38
|
+
const write = await client.roomDraft.write(room, path, prior?.revision ?? null, parts);
|
|
39
|
+
if (write.outcome !== 'written' || write.roomDraft === null) {
|
|
40
|
+
throw new Error(`the Room Draft at ${path} was not written`);
|
|
41
|
+
}
|
|
42
|
+
kept.push({ path, revision: write.roomDraft.revision });
|
|
43
|
+
}
|
|
44
|
+
return client.save(room, kept);
|
|
45
|
+
}
|
|
46
|
+
export function useSave(client) {
|
|
47
|
+
const [state, setState] = useState(IDLE);
|
|
48
|
+
const save = useCallback(async (room, roomDrafts) => {
|
|
49
|
+
setState({ busy: true, outcome: null, failure: null });
|
|
50
|
+
try {
|
|
51
|
+
const outcome = await saveRoomDrafts(client, room, roomDrafts);
|
|
52
|
+
setState({ busy: false, outcome, failure: null });
|
|
53
|
+
return outcome;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
57
|
+
setState({ busy: false, outcome: null, failure });
|
|
58
|
+
throw failure;
|
|
59
|
+
}
|
|
60
|
+
}, [client]);
|
|
61
|
+
return { ...state, save };
|
|
62
|
+
}
|
package/dist/read-side.d.ts
CHANGED
|
@@ -10,5 +10,9 @@ export type ReadSide = {
|
|
|
10
10
|
document(room: string, path: string): SearchedDocument | null;
|
|
11
11
|
close(): void;
|
|
12
12
|
};
|
|
13
|
+
export declare function reconciled(previous: KeyedResult, next: KeyedResult): {
|
|
14
|
+
keyed: KeyedResult;
|
|
15
|
+
change: QueryChange;
|
|
16
|
+
} | null;
|
|
13
17
|
export declare function createReadSide(): ReadSide;
|
|
14
18
|
//# sourceMappingURL=read-side.d.ts.map
|
package/dist/read-side.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-side.d.ts","sourceRoot":"","sources":["../src/read-side.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-side.d.ts","sourceRoot":"","sources":["../src/read-side.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAU,KAAK,WAAW,EAAE,KAAK,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAOV,IAAI,EAIJ,WAAW,EAIZ,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAuDpD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CACH,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,KAAK,IAAI,GACpD,MAAM,IAAI,CAAC;IACd,SAAS,IAAI,SAAS,gBAAgB,EAAE,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AA+UF,wBAAgB,UAAU,CACxB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,WAAW,GAChB;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAAG,IAAI,CA4BpD;AAED,wBAAgB,cAAc,IAAI,QAAQ,CA4HzC"}
|
package/dist/read-side.js
CHANGED
|
@@ -1,62 +1,71 @@
|
|
|
1
|
-
import { and, BasicIndex, configureIndexDevMode, count, createCollection, createLiveQueryCollection, deepEquals, eq,
|
|
1
|
+
import { and, BasicIndex, configureIndexDevMode, count, createCollection, createLiveQueryCollection, deepEquals, eq, inArray, or, toArray, } from '@tanstack/db';
|
|
2
|
+
import { ARRAY_INDEX, pointerSegments } from '@agentshouse/mdmodel';
|
|
2
3
|
import { rowsOf } from './observation.js';
|
|
3
4
|
import { documentKey } from './rows.js';
|
|
4
5
|
function every(expressions) {
|
|
5
6
|
const [first, second, ...rest] = expressions;
|
|
6
7
|
return second === undefined ? first : and(first, second, ...rest);
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
return second === undefined ? first : or(first, second, ...rest);
|
|
9
|
+
function same(held, value) {
|
|
10
|
+
return Array.isArray(held) ? held.includes(value) : held === value;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
12
|
+
function ordered(held, [operator, bound]) {
|
|
13
|
+
if (typeof held !== typeof bound || held === null || typeof held === 'object')
|
|
14
|
+
return false;
|
|
15
|
+
const left = held;
|
|
16
|
+
const right = bound;
|
|
17
|
+
if (operator === 'gt')
|
|
18
|
+
return left > right;
|
|
19
|
+
if (operator === 'gte')
|
|
20
|
+
return left >= right;
|
|
21
|
+
if (operator === 'lt')
|
|
22
|
+
return left < right;
|
|
23
|
+
return left <= right;
|
|
14
24
|
}
|
|
15
|
-
function
|
|
25
|
+
function satisfied(test, held) {
|
|
16
26
|
if (test.op === 'eq')
|
|
17
|
-
return
|
|
18
|
-
if (test.op === 'ne')
|
|
19
|
-
return test.value
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const compare = { gt, gte, lt, lte };
|
|
37
|
-
return every(test.bounds.map(([operator, bound]) => compare[operator](field, bound)));
|
|
38
|
-
}
|
|
39
|
-
if (test.op === 'all') {
|
|
40
|
-
return every([not(isUndefined(size)), ...test.values.map((value) => inArray(value, field))]);
|
|
41
|
-
}
|
|
42
|
-
if (test.op === 'size')
|
|
43
|
-
return eq(size, test.size);
|
|
44
|
-
return test.exists ? not(isUndefined(written)) : isUndefined(written);
|
|
27
|
+
return same(held, test.value);
|
|
28
|
+
if (test.op === 'ne')
|
|
29
|
+
return !same(held, test.value);
|
|
30
|
+
if (test.op === 'in')
|
|
31
|
+
return test.values.some((value) => same(held, value));
|
|
32
|
+
if (test.op === 'nin')
|
|
33
|
+
return !test.values.some((value) => same(held, value));
|
|
34
|
+
if (test.op === 'range')
|
|
35
|
+
return test.bounds.every((bound) => ordered(held, bound));
|
|
36
|
+
if (test.op === 'all')
|
|
37
|
+
return Array.isArray(held) && test.values.every((value) => same(held, value));
|
|
38
|
+
return Array.isArray(held) && held.length === test.size;
|
|
39
|
+
}
|
|
40
|
+
function tested(test, reached) {
|
|
41
|
+
if (test.op === 'exists')
|
|
42
|
+
return test.exists === (reached !== undefined);
|
|
43
|
+
if (reached === undefined)
|
|
44
|
+
return test.op === 'ne' || test.op === 'nin';
|
|
45
|
+
return reached.some((held) => satisfied(test, held));
|
|
45
46
|
}
|
|
46
47
|
function conditioned(condition, row) {
|
|
47
48
|
if ('every' in condition)
|
|
48
|
-
return
|
|
49
|
+
return condition.every.every((item) => conditioned(item, row));
|
|
49
50
|
if ('some' in condition)
|
|
50
|
-
return
|
|
51
|
-
return tested(condition.test, row.
|
|
51
|
+
return condition.some.some((item) => conditioned(item, row));
|
|
52
|
+
return tested(condition.test, row.reached[condition.field]);
|
|
53
|
+
}
|
|
54
|
+
function narrowed(query, where, alias) {
|
|
55
|
+
return where === null ? query : query.fn.where((row) => conditioned(where, row[alias]));
|
|
56
|
+
}
|
|
57
|
+
function reached(reach, room, document) {
|
|
58
|
+
return reach === null
|
|
59
|
+
? []
|
|
60
|
+
: [or(inArray(room, [...reach.rooms]), inArray(document, [...reach.documents]))];
|
|
52
61
|
}
|
|
53
|
-
function scoped(scope, row, rooms) {
|
|
62
|
+
function scoped(scope, row, rooms, reach) {
|
|
54
63
|
return every([
|
|
55
64
|
eq(row.kind, 'document'),
|
|
56
65
|
...(rooms === null ? [] : [inArray(row.room, [...rooms])]),
|
|
66
|
+
...reached(reach, row.room, row.key),
|
|
57
67
|
...(scope.types === null ? [] : [inArray(row.type, [...scope.types])]),
|
|
58
68
|
...(scope.pathPrefix === null ? [] : [inArray(scope.pathPrefix, row.directories)]),
|
|
59
|
-
...(scope.where === null ? [] : [conditioned(scope.where, row)]),
|
|
60
69
|
]);
|
|
61
70
|
}
|
|
62
71
|
function keyed(key, row) {
|
|
@@ -68,25 +77,26 @@ function live(query) {
|
|
|
68
77
|
startSync: true,
|
|
69
78
|
});
|
|
70
79
|
}
|
|
71
|
-
function related(q, rows, scope, field, kept) {
|
|
80
|
+
function related(q, rows, scope, field, kept, reach) {
|
|
72
81
|
const matched = kept === 'source' ? 'target' : 'source';
|
|
73
82
|
const from = q.from({ r: rows });
|
|
74
|
-
|
|
75
|
-
.where(({ r }) => every([eq(r.kind, 'reference'), ...(field === null ? [] : [
|
|
83
|
+
const joined = from
|
|
84
|
+
.where(({ r }) => every([eq(r.kind, 'reference'), ...(field === null ? [] : [inArray(field, r.forms)])]))
|
|
76
85
|
.innerJoin({ m: rows }, ({ r, m }) => eq(r[matched], m.key))
|
|
77
|
-
.where(({ m }) => scoped(scope, m, null))
|
|
86
|
+
.where(({ m }) => scoped(scope, m, null, reach));
|
|
87
|
+
return narrowed(joined, scope.where, 'm')
|
|
78
88
|
.groupBy(({ r }) => r[kept])
|
|
79
89
|
.select(({ r }) => ({ key: r[kept] }));
|
|
80
90
|
}
|
|
81
91
|
function filtered(q, rows, plan) {
|
|
82
92
|
const from = q.from({ d: rows });
|
|
83
|
-
let query = from.where(({ d }) => scoped(plan.root, d, plan.rooms));
|
|
93
|
+
let query = narrowed(from.where(({ d }) => scoped(plan.root, d, plan.rooms, plan.reach)), plan.root.where, 'd');
|
|
84
94
|
if (plan.hop !== null) {
|
|
85
|
-
const hop = related(q, rows, plan.hop, plan.hop.field, 'source');
|
|
95
|
+
const hop = related(q, rows, plan.hop, plan.hop.field, 'source', plan.reach);
|
|
86
96
|
query = query.innerJoin({ h: hop }, ({ d, h }) => eq(d.key, h.key));
|
|
87
97
|
}
|
|
88
98
|
if (plan.backlinks !== null) {
|
|
89
|
-
const backlinks = related(q, rows, plan.backlinks, plan.backlinks.field, 'target');
|
|
99
|
+
const backlinks = related(q, rows, plan.backlinks, plan.backlinks.field, 'target', plan.reach);
|
|
90
100
|
query = query.innerJoin({ k: backlinks }, ({ d, k }) => eq(d.key, k.key));
|
|
91
101
|
}
|
|
92
102
|
return query;
|
|
@@ -111,20 +121,19 @@ function documents(q, rows, plan, shape) {
|
|
|
111
121
|
room: d.room,
|
|
112
122
|
path: d.path,
|
|
113
123
|
type: d.type,
|
|
114
|
-
...(shape.fields ===
|
|
115
|
-
...(Array.isArray(shape.fields) ? named('field', shape.fields, d.fields) : {}),
|
|
124
|
+
...(shape.fields === null ? {} : { fields: d.fields }),
|
|
116
125
|
...(shape.sections === 'all' ? { sections: b.sections } : {}),
|
|
117
126
|
...(Array.isArray(shape.sections) ? named('section', shape.sections, b.sections) : {}),
|
|
118
127
|
...(shape.preamble ? { preamble: b.preamble } : {}),
|
|
119
128
|
...(shape.markdown ? { markdown: b.markdown } : {}),
|
|
120
|
-
...(shape.backlinks ? { backlinks: toArray(backlinked(q, rows, d)) } : {}),
|
|
129
|
+
...(shape.backlinks ? { backlinks: toArray(backlinked(q, rows, d, plan.reach)) } : {}),
|
|
121
130
|
...(shape.change ? { change: d.change } : {}),
|
|
122
131
|
}));
|
|
123
132
|
}
|
|
124
|
-
function backlinked(q, rows, document) {
|
|
133
|
+
function backlinked(q, rows, document, reach) {
|
|
125
134
|
const from = q.from({ r: rows });
|
|
126
135
|
return from
|
|
127
|
-
.where(({ r }) => eq(r.target, document.key))
|
|
136
|
+
.where(({ r }) => every([eq(r.target, document.key), ...reached(reach, r.room, r.source)]))
|
|
128
137
|
.orderBy(({ r }) => r.path, { stringSort: 'lexical' })
|
|
129
138
|
.orderBy(({ r }) => r.field, { stringSort: 'lexical' })
|
|
130
139
|
.select(({ r }) => ({ path: r.path, type: r.type, field: r.field }));
|
|
@@ -170,6 +179,55 @@ function part(row, prefix, names, whole) {
|
|
|
170
179
|
return whole;
|
|
171
180
|
return present(names.map((name, index) => [name, row[`${prefix}${index}`]]));
|
|
172
181
|
}
|
|
182
|
+
function masked(pointers) {
|
|
183
|
+
const root = { whole: false, members: new Map() };
|
|
184
|
+
for (const pointer of pointers) {
|
|
185
|
+
let mask = root;
|
|
186
|
+
for (const token of pointerSegments(pointer)) {
|
|
187
|
+
const next = mask.members.get(token) ?? { whole: false, members: new Map() };
|
|
188
|
+
mask.members.set(token, next);
|
|
189
|
+
mask = next;
|
|
190
|
+
}
|
|
191
|
+
mask.whole = true;
|
|
192
|
+
}
|
|
193
|
+
return root;
|
|
194
|
+
}
|
|
195
|
+
function merged(left, right) {
|
|
196
|
+
if (left === undefined)
|
|
197
|
+
return right;
|
|
198
|
+
const members = new Map(left.members);
|
|
199
|
+
for (const [token, mask] of right.members)
|
|
200
|
+
members.set(token, merged(members.get(token), mask));
|
|
201
|
+
return { whole: left.whole || right.whole, members };
|
|
202
|
+
}
|
|
203
|
+
function cut(value, mask) {
|
|
204
|
+
if (mask.whole)
|
|
205
|
+
return value;
|
|
206
|
+
if (Array.isArray(value)) {
|
|
207
|
+
const each = {
|
|
208
|
+
whole: false,
|
|
209
|
+
members: new Map([...mask.members].filter(([token]) => !ARRAY_INDEX.test(token))),
|
|
210
|
+
};
|
|
211
|
+
const kept = [];
|
|
212
|
+
value.forEach((item, index) => {
|
|
213
|
+
const part = cut(item, merged(mask.members.get(String(index)), each));
|
|
214
|
+
if (part !== undefined)
|
|
215
|
+
kept[index] = part;
|
|
216
|
+
});
|
|
217
|
+
return kept.length === 0 ? undefined : kept;
|
|
218
|
+
}
|
|
219
|
+
if (typeof value !== 'object' || value === null)
|
|
220
|
+
return undefined;
|
|
221
|
+
const kept = Object.entries(value).flatMap(([key, held]) => {
|
|
222
|
+
const member = mask.members.get(key);
|
|
223
|
+
const part = member === undefined ? undefined : cut(held, member);
|
|
224
|
+
return part === undefined ? [] : [[key, part]];
|
|
225
|
+
});
|
|
226
|
+
return kept.length === 0 ? undefined : Object.fromEntries(kept);
|
|
227
|
+
}
|
|
228
|
+
function selected(fields, pointers) {
|
|
229
|
+
return (cut(fields, masked(pointers)) ?? {});
|
|
230
|
+
}
|
|
173
231
|
function documentOf(row, shape) {
|
|
174
232
|
if (row.type === null)
|
|
175
233
|
return { room: row.room, path: row.path };
|
|
@@ -179,7 +237,11 @@ function documentOf(row, shape) {
|
|
|
179
237
|
type: row.type,
|
|
180
238
|
...(shape.fields === null
|
|
181
239
|
? {}
|
|
182
|
-
: {
|
|
240
|
+
: {
|
|
241
|
+
fields: shape.fields === 'all'
|
|
242
|
+
? row.fields
|
|
243
|
+
: selected(row.fields, shape.fields),
|
|
244
|
+
}),
|
|
183
245
|
...(shape.sections === null
|
|
184
246
|
? {}
|
|
185
247
|
: {
|
|
@@ -214,7 +276,7 @@ function keyedOf(plan, entries) {
|
|
|
214
276
|
keys: bounded.map(([key]) => key),
|
|
215
277
|
};
|
|
216
278
|
}
|
|
217
|
-
function reconciled(previous, next) {
|
|
279
|
+
export function reconciled(previous, next) {
|
|
218
280
|
const before = rowsOf(previous.result);
|
|
219
281
|
const held = new Map(previous.keys.map((key, index) => [key, before[index]]));
|
|
220
282
|
const changed = [];
|
package/dist/refresh.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Adapter, AdapterFailure, Authorization, RetryableRefusal } from './adapter.js';
|
|
2
|
+
import type { Remodel } from './bootstrap.js';
|
|
2
3
|
import { type ConfirmedLayer } from './replica.js';
|
|
3
4
|
import { type Refused, type Unconfirmed } from './transfer.js';
|
|
4
5
|
export type RefreshOutcome = {
|
|
@@ -9,5 +10,5 @@ export type RefreshOutcome = {
|
|
|
9
10
|
} | {
|
|
10
11
|
kind: 'beyond-horizon';
|
|
11
12
|
} | RetryableRefusal | Unconfirmed | Refused | AdapterFailure;
|
|
12
|
-
export declare function refreshRoom(adapter: Adapter, authorization: Authorization, confirmed: ConfirmedLayer, continuing: () => boolean
|
|
13
|
+
export declare function refreshRoom(adapter: Adapter, authorization: Authorization, confirmed: ConfirmedLayer, remodel: Remodel, continuing: () => boolean): Promise<RefreshOutcome>;
|
|
13
14
|
//# sourceMappingURL=refresh.d.ts.map
|
package/dist/refresh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,aAAa,EAGb,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAe,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,cAAc,CAAC;AAEnB,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,cAAc,EACzB,
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,aAAa,EAGb,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAe,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,OAAO,GACP,cAAc,CAAC;AAEnB,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,cAAc,CAAC,CA8EzB"}
|
package/dist/refresh.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { declaredAttachments } from './attachment.js';
|
|
2
2
|
import { readStaged } from './replica.js';
|
|
3
3
|
import { unconfirmed } from './transfer.js';
|
|
4
|
-
export async function refreshRoom(adapter, authorization, confirmed,
|
|
4
|
+
export async function refreshRoom(adapter, authorization, confirmed, remodel, continuing) {
|
|
5
5
|
const locator = confirmed.record.locator;
|
|
6
6
|
const fromRoomVersion = confirmed.record.roomVersion;
|
|
7
7
|
const first = await adapter.refresh(authorization, {
|
|
8
8
|
locator,
|
|
9
9
|
selection: confirmed.record.replica.selection,
|
|
10
10
|
fromRoomVersion,
|
|
11
|
-
...(minPosition === undefined ? {} : { minPosition }),
|
|
12
11
|
});
|
|
13
12
|
if (first.kind !== 'net-advancement')
|
|
14
13
|
return first;
|
|
15
14
|
const roomVersion = first.roomVersion;
|
|
15
|
+
const models = remodel(first.models, {
|
|
16
|
+
collection: confirmed.record.model,
|
|
17
|
+
selection: confirmed.record.selectionModel,
|
|
18
|
+
});
|
|
16
19
|
const documents = { ...confirmed.record.documents };
|
|
17
20
|
const revisions = { ...confirmed.record.revisions };
|
|
18
21
|
const changes = { ...confirmed.record.changes };
|
|
@@ -54,7 +57,6 @@ export async function refreshRoom(adapter, authorization, confirmed, continuing,
|
|
|
54
57
|
locator,
|
|
55
58
|
selection: confirmed.record.replica.selection,
|
|
56
59
|
fromRoomVersion,
|
|
57
|
-
...(minPosition === undefined ? {} : { minPosition }),
|
|
58
60
|
pageToken,
|
|
59
61
|
});
|
|
60
62
|
if (page.kind === 'still-current' || page.kind === 'beyond-horizon')
|
|
@@ -68,6 +70,8 @@ export async function refreshRoom(adapter, authorization, confirmed, continuing,
|
|
|
68
70
|
}
|
|
69
71
|
const staged = readStaged({
|
|
70
72
|
...confirmed.record,
|
|
73
|
+
model: models.collection,
|
|
74
|
+
selectionModel: models.selection,
|
|
71
75
|
roomVersion,
|
|
72
76
|
documents,
|
|
73
77
|
binaryTargets: [...binaryTargets].sort(),
|
package/dist/replica.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ChangeBatch } from './change.js';
|
|
2
2
|
import { type Collection, type Composition } from './collection.js';
|
|
3
3
|
import { type Layer } from './overlay.js';
|
|
4
|
-
import {
|
|
4
|
+
import type { RoomAttachment } from './adapter.js';
|
|
5
5
|
import type { ReplicaRecord } from './store.js';
|
|
6
6
|
import type { Refused } from './transfer.js';
|
|
7
7
|
export type ConfirmedLayer = {
|
|
@@ -35,9 +35,9 @@ export declare function readStaged(record: ReplicaRecord, previous?: ConfirmedLa
|
|
|
35
35
|
export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Staged | {
|
|
36
36
|
kind: 'deferred';
|
|
37
37
|
};
|
|
38
|
-
export declare function applyReturned(confirmed: ConfirmedLayer, documents: Readonly<Record<string, string>>, revisions: Readonly<Record<string, string>>, removals: readonly string[], roomVersion: string): Staged;
|
|
39
|
-
export declare function replicaOf(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[],
|
|
38
|
+
export declare function applyReturned(confirmed: ConfirmedLayer, documents: Readonly<Record<string, string>>, revisions: Readonly<Record<string, string>>, removals: readonly string[], attachments: readonly RoomAttachment[] | undefined, roomVersion: string, writtenAt: string): Staged;
|
|
39
|
+
export declare function replicaOf(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], previous?: Replica): Replica;
|
|
40
40
|
export declare function landed(batch: ChangeBatch, confirmed: ConfirmedLayer): boolean;
|
|
41
|
-
export declare function withdrawals(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean
|
|
41
|
+
export declare function withdrawals(confirmed: ConfirmedLayer, queue: readonly ChangeBatch[], withdrawable: (batch: ChangeBatch) => boolean): readonly ChangeBatch[];
|
|
42
42
|
export {};
|
|
43
43
|
//# sourceMappingURL=replica.d.ts.map
|
package/dist/replica.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AAC1F,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA0C,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AAC1F,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA0C,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAGlF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,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E,CAM/B;AAED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,cAAc,EACzB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC3C,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC3C,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,WAAW,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,EAClD,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,MAAM,CAmCR;AAsDD,wBAAgB,SAAS,CACvB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CAgCT;AAkFD,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAa7E;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,GAC5C,SAAS,WAAW,EAAE,CAmBxB"}
|
package/dist/replica.js
CHANGED
|
@@ -4,6 +4,7 @@ import { parseCollection, readCollection, validateCollection, } from './collecti
|
|
|
4
4
|
import { overlay, overlayChanged, sameLayerText } from './overlay.js';
|
|
5
5
|
import { providerRewritten } from './save.js';
|
|
6
6
|
import { equalValue } from './room-draft.js';
|
|
7
|
+
import { declaredAttachments } from './attachment.js';
|
|
7
8
|
export function compositionOf(record) {
|
|
8
9
|
return {
|
|
9
10
|
model: record.model,
|
|
@@ -25,7 +26,7 @@ export function sameMembership(record, other) {
|
|
|
25
26
|
JSON.stringify(other.typedSelection?.roots ?? null));
|
|
26
27
|
}
|
|
27
28
|
export function readStaged(record, previous) {
|
|
28
|
-
if ((record.model.status
|
|
29
|
+
if ((record.model.status !== 'unavailable' || record.selectionModel.status !== 'unavailable') &&
|
|
29
30
|
(previous === undefined ||
|
|
30
31
|
!sameLayerText(record, previous.record) ||
|
|
31
32
|
record.model !== previous.record.model ||
|
|
@@ -45,13 +46,13 @@ export function readReclassified(record, previous) {
|
|
|
45
46
|
? { kind: 'deferred' }
|
|
46
47
|
: { kind: 'refused', refusal: verdict };
|
|
47
48
|
}
|
|
48
|
-
export function applyReturned(confirmed, documents, revisions, removals, roomVersion) {
|
|
49
|
+
export function applyReturned(confirmed, documents, revisions, removals, attachments, roomVersion, writtenAt) {
|
|
49
50
|
const nextDocuments = { ...confirmed.record.documents, ...documents };
|
|
50
51
|
const nextRevisions = { ...confirmed.record.revisions, ...revisions };
|
|
51
52
|
const nextChanges = { ...confirmed.record.changes };
|
|
52
53
|
const nextWritten = {
|
|
53
54
|
...confirmed.record.written,
|
|
54
|
-
...Object.fromEntries(Object.keys(documents).map((path) => [path,
|
|
55
|
+
...Object.fromEntries(Object.keys(documents).map((path) => [path, writtenAt])),
|
|
55
56
|
};
|
|
56
57
|
const binaryTargets = new Set(confirmed.record.binaryTargets);
|
|
57
58
|
for (const [path, revision] of Object.entries(revisions)) {
|
|
@@ -73,6 +74,9 @@ export function applyReturned(confirmed, documents, revisions, removals, roomVer
|
|
|
73
74
|
changes: nextChanges,
|
|
74
75
|
written: nextWritten,
|
|
75
76
|
binaryTargets: [...binaryTargets].sort(),
|
|
77
|
+
attachments: attachments === undefined
|
|
78
|
+
? confirmed.record.attachments
|
|
79
|
+
: declaredAttachments([attachments]),
|
|
76
80
|
}, confirmed);
|
|
77
81
|
}
|
|
78
82
|
function predicted(confirmed, batches, previous) {
|
|
@@ -116,7 +120,7 @@ function predicted(confirmed, batches, previous) {
|
|
|
116
120
|
}
|
|
117
121
|
return { layer, replay };
|
|
118
122
|
}
|
|
119
|
-
export function replicaOf(confirmed, queue,
|
|
123
|
+
export function replicaOf(confirmed, queue, previous) {
|
|
120
124
|
const batches = Object.freeze(queue.map(immutable));
|
|
121
125
|
if (batches.length === 0) {
|
|
122
126
|
return {
|
|
@@ -132,16 +136,11 @@ export function replicaOf(confirmed, queue, rewriting, previous) {
|
|
|
132
136
|
replay: [],
|
|
133
137
|
};
|
|
134
138
|
}
|
|
135
|
-
const
|
|
136
|
-
const layer = rewriting === 'provider'
|
|
137
|
-
? predictedState.layer
|
|
138
|
-
: previous === undefined
|
|
139
|
-
? overlay(confirmed.record, batches)
|
|
140
|
-
: overlayChanged(confirmed.record, batches, previous.confirmed.record, previous.queue, previous.visible);
|
|
139
|
+
const { layer, replay } = predicted(confirmed, batches, previous);
|
|
141
140
|
return {
|
|
142
141
|
confirmed,
|
|
143
142
|
queue: batches,
|
|
144
|
-
replay
|
|
143
|
+
replay,
|
|
145
144
|
visible: {
|
|
146
145
|
...layer,
|
|
147
146
|
collection: parseCollection(layer.documents, compositionOf(confirmed.record), previous === undefined
|
|
@@ -245,7 +244,7 @@ export function landed(batch, confirmed) {
|
|
|
245
244
|
});
|
|
246
245
|
});
|
|
247
246
|
}
|
|
248
|
-
export function withdrawals(confirmed, queue, withdrawable
|
|
247
|
+
export function withdrawals(confirmed, queue, withdrawable) {
|
|
249
248
|
if (!queue.some(withdrawable))
|
|
250
249
|
return [];
|
|
251
250
|
const composition = compositionOf(confirmed.record);
|
|
@@ -256,7 +255,7 @@ export function withdrawals(confirmed, queue, withdrawable, rewriting) {
|
|
|
256
255
|
withdrawn.push(batch);
|
|
257
256
|
continue;
|
|
258
257
|
}
|
|
259
|
-
const effective =
|
|
258
|
+
const effective = batch.changes.some((change) => change.kind === 'move')
|
|
260
259
|
? providerRewritten(batch, {
|
|
261
260
|
...layer,
|
|
262
261
|
collection: parseCollection(layer.documents, composition),
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -116,6 +116,9 @@ 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;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;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,MAAM,CAAC,CAAC,CAAC;CACrD,GACD;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CACxB,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE,CAAC,CACxE,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ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AI,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAGhE;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,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
|
@@ -288,6 +288,10 @@ export function returnedInto(existing, returned) {
|
|
|
288
288
|
next.removal = removal;
|
|
289
289
|
return next;
|
|
290
290
|
}
|
|
291
|
+
export function moveTarget(move) {
|
|
292
|
+
const to = normalize(move.to);
|
|
293
|
+
return to === null || to === '' ? move.to : to;
|
|
294
|
+
}
|
|
291
295
|
export function changesOf(path, parts) {
|
|
292
296
|
const changes = [];
|
|
293
297
|
const bases = [];
|
|
@@ -317,10 +321,8 @@ export function changesOf(path, parts) {
|
|
|
317
321
|
if (parts.markdown !== undefined) {
|
|
318
322
|
changes.push({ kind: 'replace', path, content: parts.markdown.value });
|
|
319
323
|
}
|
|
320
|
-
if (parts.move !== undefined)
|
|
321
|
-
|
|
322
|
-
changes.push({ kind: 'move', path, to: to === null || to === '' ? parts.move.to : to });
|
|
323
|
-
}
|
|
324
|
+
if (parts.move !== undefined)
|
|
325
|
+
changes.push({ kind: 'move', path, to: moveTarget(parts.move) });
|
|
324
326
|
if (parts.removal !== undefined)
|
|
325
327
|
changes.push({ kind: 'remove', path });
|
|
326
328
|
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,6 +31,7 @@ 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
|
};
|
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,EAKL,KAAK,QAAQ,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,KAAK,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;IACtD,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,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