@agentshouse/mdruntime 0.1.0-c1ffd2bc60355 → 0.1.0-c219104d36ac5
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 +10 -8
- package/dist/adapter.d.ts +25 -7
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +2 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +28 -4
- package/dist/bootstrap.d.ts +8 -8
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +90 -84
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +7 -3
- package/dist/client.d.ts +4 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -5
- package/dist/collection.d.ts +5 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -2
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +74 -24
- package/dist/connection.d.ts +5 -2
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +654 -359
- package/dist/conversation.d.ts +5 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +126 -33
- package/dist/entry.d.ts +1 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/fulltext.d.ts.map +1 -1
- package/dist/fulltext.js +8 -6
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +4 -2
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +2 -1
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +208 -0
- package/dist/memory.d.ts +2 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +47 -9
- package/dist/model.d.ts +6 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/observation.d.ts +1 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +1 -1
- package/dist/outcome.d.ts +13 -2
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -2
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +6 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts +8 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +51 -17
- package/dist/readiness.d.ts +1 -2
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +10 -19
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +1 -5
- package/dist/replica.d.ts +3 -4
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +4 -3
- package/dist/room-draft.d.ts +17 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +40 -6
- package/dist/rows.d.ts +15 -6
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +102 -74
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +11 -5
- package/dist/status.d.ts +5 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +16 -19
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +23 -29
- package/dist/stored.d.ts +9 -19
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +197 -196
- package/dist/tables.d.ts +14 -16
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +6 -9
- package/dist/wire.d.ts +8 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -1
- package/dist/words.d.ts.map +1 -1
- package/dist/words.js +8 -2
- package/package.json +10 -17
- package/AGENTS.md +0 -317
- package/dist/chat/acts.d.ts +0 -33
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/earlier.d.ts +0 -10
- package/dist/chat/earlier.d.ts.map +0 -1
- package/dist/chat/earlier.js +0 -54
- package/dist/chat/house.d.ts +0 -25
- package/dist/chat/house.d.ts.map +0 -1
- package/dist/chat/house.js +0 -38
- package/dist/chat/input.d.ts +0 -11
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -92
- package/dist/chat/kit.d.ts +0 -61
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -28
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -103
- package/dist/chat/markdown.d.ts +0 -20
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -229
- package/dist/chat/message.d.ts +0 -7
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -254
- package/dist/chat/messages.d.ts +0 -35
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -210
- package/dist/chat/name.d.ts +0 -7
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -12
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -19
- package/dist/chat/overlay.d.ts +0 -32
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -103
- package/dist/chat/parts.d.ts +0 -58
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -120
- package/dist/chat/pieces.d.ts +0 -62
- package/dist/chat/pieces.d.ts.map +0 -1
- package/dist/chat/pieces.js +0 -1110
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -70
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -635
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -69
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -37
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -93
- package/dist/chat/room-file.d.ts +0 -8
- package/dist/chat/room-file.d.ts.map +0 -1
- package/dist/chat/room-file.js +0 -72
- package/dist/chat/steady.d.ts +0 -3
- package/dist/chat/steady.d.ts.map +0 -1
- package/dist/chat/steady.js +0 -26
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -307
- package/dist/chat.d.ts +0 -15
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
package/dist/reach.js
CHANGED
|
@@ -16,7 +16,6 @@ const NO_CONVERSATION = {
|
|
|
16
16
|
read: (conversation) => Promise.resolve(unheldView(conversation)),
|
|
17
17
|
create: unconversed('conversation.create'),
|
|
18
18
|
send: unconversed('conversation.send'),
|
|
19
|
-
attach: unconversed('conversation.attach'),
|
|
20
19
|
answer: unconversed('conversation.answer'),
|
|
21
20
|
interrupt: unconversed('conversation.interrupt'),
|
|
22
21
|
kill: unconversed('conversation.kill'),
|
|
@@ -28,10 +27,20 @@ const NO_CHAT_DRAFT = {
|
|
|
28
27
|
prepend: () => Promise.resolve(),
|
|
29
28
|
discard: () => Promise.resolve(),
|
|
30
29
|
};
|
|
30
|
+
function areasOf(reach) {
|
|
31
|
+
return reach.areas ?? [];
|
|
32
|
+
}
|
|
33
|
+
function typedAreas(reach, room) {
|
|
34
|
+
return areasOf(reach).filter((area) => area.room === room && area.types.length > 0);
|
|
35
|
+
}
|
|
36
|
+
function fenced(reach, room, path) {
|
|
37
|
+
return areasOf(reach).some((area) => area.room === room && beneath(area.path, path));
|
|
38
|
+
}
|
|
31
39
|
export function holds(reach, room) {
|
|
32
40
|
return (reach === null ||
|
|
33
41
|
reach.rooms.includes(room) ||
|
|
34
|
-
reach.documents.some((document) => document.room === room)
|
|
42
|
+
reach.documents.some((document) => document.room === room) ||
|
|
43
|
+
typedAreas(reach, room).length > 0);
|
|
35
44
|
}
|
|
36
45
|
function wholly(reach, room) {
|
|
37
46
|
return reach === null || reach.rooms.includes(room);
|
|
@@ -41,15 +50,19 @@ export function governs(reach, room) {
|
|
|
41
50
|
return { collection: true, selection: room.typedSelection !== null };
|
|
42
51
|
}
|
|
43
52
|
const selected = (path) => room.typedSelection?.roots.some((root) => beneath(root, path)) ?? false;
|
|
44
|
-
const paths =
|
|
45
|
-
.
|
|
46
|
-
|
|
53
|
+
const paths = [
|
|
54
|
+
...reach.documents
|
|
55
|
+
.filter((document) => document.room === room.locator)
|
|
56
|
+
.map(({ path }) => path),
|
|
57
|
+
...typedAreas(reach, room.locator).map(({ path }) => path),
|
|
58
|
+
];
|
|
47
59
|
return { collection: paths.some((path) => !selected(path)), selection: paths.some(selected) };
|
|
48
60
|
}
|
|
49
61
|
function covers(reach, room, path) {
|
|
50
62
|
return (reach === null ||
|
|
51
|
-
reach
|
|
52
|
-
|
|
63
|
+
(!fenced(reach, room, path) &&
|
|
64
|
+
(reach.rooms.includes(room) ||
|
|
65
|
+
reach.documents.some((document) => document.room === room && document.path === path))));
|
|
53
66
|
}
|
|
54
67
|
function conversing(reach) {
|
|
55
68
|
return reach === null || reach.conversations;
|
|
@@ -62,6 +75,9 @@ export function planReach(reach) {
|
|
|
62
75
|
documents: [
|
|
63
76
|
...new Set(reach.documents.map(({ room, path }) => documentKey(room, path))),
|
|
64
77
|
].sort(),
|
|
78
|
+
areas: areasOf(reach)
|
|
79
|
+
.map(({ room, path, types }) => ({ room, path, types: [...new Set(types)].sort() }))
|
|
80
|
+
.sort((left, right) => documentKey(left.room, left.path) < documentKey(right.room, right.path) ? -1 : 1),
|
|
65
81
|
};
|
|
66
82
|
}
|
|
67
83
|
function roomsWithin(reach, rooms) {
|
|
@@ -111,6 +127,7 @@ function statusWithin(reach, status) {
|
|
|
111
127
|
return {
|
|
112
128
|
...status,
|
|
113
129
|
attentionRequired: status.attentionRequired.filter((entry) => 'refusal' in entry ? wholly(reach, entry.room) : covers(reach, entry.room, entry.path)),
|
|
130
|
+
unsent: status.unsent.filter((change) => covers(reach, change.room, change.path)),
|
|
114
131
|
};
|
|
115
132
|
}
|
|
116
133
|
function queueWithin(reach, room, entries) {
|
|
@@ -135,6 +152,13 @@ function lockedError(room) {
|
|
|
135
152
|
function deviceUnreached() {
|
|
136
153
|
return runtimeError('device-unreached', 'Only the panel cleans up this device');
|
|
137
154
|
}
|
|
155
|
+
const ATTACH_REQUIRED = 'attach-required';
|
|
156
|
+
function attachRequired() {
|
|
157
|
+
return runtimeError(ATTACH_REQUIRED, 'App code takes a file in with binaryFile.attach');
|
|
158
|
+
}
|
|
159
|
+
function carriesFile(parts) {
|
|
160
|
+
return parts !== null && typeof parts === 'object' && Object.hasOwn(parts, 'file');
|
|
161
|
+
}
|
|
138
162
|
export function narrowed(runtime, given, told) {
|
|
139
163
|
const { md, watch } = runtime;
|
|
140
164
|
let reach = given;
|
|
@@ -245,7 +269,7 @@ export function narrowed(runtime, given, told) {
|
|
|
245
269
|
};
|
|
246
270
|
const files = new Map();
|
|
247
271
|
let handed = 0;
|
|
248
|
-
|
|
272
|
+
async function hand(reading) {
|
|
249
273
|
const answer = await reading;
|
|
250
274
|
if (answer.kind !== 'binary')
|
|
251
275
|
return answer;
|
|
@@ -253,12 +277,12 @@ export function narrowed(runtime, given, told) {
|
|
|
253
277
|
const file = String(handed);
|
|
254
278
|
files.set(file, answer.file);
|
|
255
279
|
return { ...answer, file };
|
|
256
|
-
}
|
|
280
|
+
}
|
|
257
281
|
const conversation = () => (conversing(reach) ? md.conversation : NO_CONVERSATION);
|
|
258
282
|
const chatDraft = () => (conversing(reach) ? md.chatDraft : NO_CHAT_DRAFT);
|
|
259
283
|
const view = {
|
|
260
284
|
...md,
|
|
261
|
-
rooms: () => roomsWithin(reach,
|
|
285
|
+
rooms: () => md.rooms().then((rooms) => roomsWithin(reach, rooms)),
|
|
262
286
|
query: ((input) => {
|
|
263
287
|
const plan = runtime.plan(input, reach);
|
|
264
288
|
return Promise.resolve(unlocking(plan.rooms) ?? runtime.query({ ...plan, locked: runtime.lockedRooms() }));
|
|
@@ -273,8 +297,7 @@ export function narrowed(runtime, given, told) {
|
|
|
273
297
|
return md.types(room);
|
|
274
298
|
if (!holds(reach, room))
|
|
275
299
|
return structuredClone(UNHELD_TYPES);
|
|
276
|
-
|
|
277
|
-
return typesWithin(reach, listed, md.types(room));
|
|
300
|
+
return typesWithin(reach, runtime.room(room), md.types(room));
|
|
278
301
|
},
|
|
279
302
|
async save(room, roomDrafts, writtenBy) {
|
|
280
303
|
if (!holds(reach, room))
|
|
@@ -293,6 +316,10 @@ export function narrowed(runtime, given, told) {
|
|
|
293
316
|
async saveParts(room, parts, writtenBy) {
|
|
294
317
|
if (!holds(reach, room))
|
|
295
318
|
throw unreached(room);
|
|
319
|
+
const filed = reach === null ? undefined : parts.find(({ parts: one }) => carriesFile(one));
|
|
320
|
+
if (filed !== undefined) {
|
|
321
|
+
return { outcome: 'refused', code: ATTACH_REQUIRED, retryable: false, file: filed.path };
|
|
322
|
+
}
|
|
296
323
|
if (runtime.locked(room))
|
|
297
324
|
return { outcome: 'refused', code: ROOM_LOCKED, retryable: true };
|
|
298
325
|
const held = parts.map(({ parts: one }) => readParts(one).move);
|
|
@@ -325,6 +352,16 @@ export function narrowed(runtime, given, told) {
|
|
|
325
352
|
: runtime.locked(room)
|
|
326
353
|
? Promise.resolve(lockedRoom(room))
|
|
327
354
|
: md.binaryFile.link(room, path, revision),
|
|
355
|
+
show: (room, path, revision) => !covers(reach, room, path)
|
|
356
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
357
|
+
: runtime.locked(room)
|
|
358
|
+
? Promise.resolve(lockedRoom(room))
|
|
359
|
+
: hand(md.binaryFile.show(room, path, revision)),
|
|
360
|
+
attach: (room, file) => !wholly(reach, room)
|
|
361
|
+
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
362
|
+
: runtime.locked(room)
|
|
363
|
+
? Promise.resolve(lockedRoom(room))
|
|
364
|
+
: md.binaryFile.attach(room, file),
|
|
328
365
|
async part(file, part) {
|
|
329
366
|
const key = files.get(file);
|
|
330
367
|
if (key === undefined)
|
|
@@ -351,6 +388,8 @@ export function narrowed(runtime, given, told) {
|
|
|
351
388
|
},
|
|
352
389
|
write(room, path, revision, parts, next) {
|
|
353
390
|
try {
|
|
391
|
+
if (reach !== null && carriesFile(parts))
|
|
392
|
+
throw attachRequired();
|
|
354
393
|
const move = readParts(parts).move;
|
|
355
394
|
if (!covers(reach, room, path) || !moves(reach, room, move))
|
|
356
395
|
throw unreached(room);
|
|
@@ -379,11 +418,6 @@ export function narrowed(runtime, given, told) {
|
|
|
379
418
|
read: (id, options) => conversation().read(id, options),
|
|
380
419
|
create: (input) => conversation().create(input),
|
|
381
420
|
send: (id, operation, draft) => conversation().send(id, operation, draft),
|
|
382
|
-
attach: (room, file) => !wholly(reach, room)
|
|
383
|
-
? Promise.resolve(failure({ kind: 'room-not-readable', locator: room }))
|
|
384
|
-
: runtime.locked(room)
|
|
385
|
-
? Promise.resolve(lockedRoom(room))
|
|
386
|
-
: conversation().attach(room, file),
|
|
387
421
|
answer: (id, answer) => conversation().answer(id, answer),
|
|
388
422
|
interrupt: (id) => conversation().interrupt(id),
|
|
389
423
|
kill: (id) => conversation().kill(id),
|
package/dist/readiness.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type RefusedRoom = {
|
|
|
26
26
|
readonly rule: string;
|
|
27
27
|
readonly location: string | null;
|
|
28
28
|
};
|
|
29
|
-
export type InstallationStep = Open<'
|
|
29
|
+
export type InstallationStep = Open<'downloading' | 'writing' | 'replaying'>;
|
|
30
30
|
export type InstallationPause = Open<'hidden'>;
|
|
31
31
|
export type InstallationAmount = {
|
|
32
32
|
readonly done: number;
|
|
@@ -38,7 +38,6 @@ export type Installation = {
|
|
|
38
38
|
readonly rooms: InstallationAmount;
|
|
39
39
|
readonly parts: InstallationAmount;
|
|
40
40
|
readonly bytes: InstallationAmount;
|
|
41
|
-
readonly received: InstallationAmount;
|
|
42
41
|
};
|
|
43
42
|
export type ReadinessStatus = Open<'preparing' | 'paused' | 'refused' | 'ready' | 'lost'>;
|
|
44
43
|
export type Readiness = {
|
package/dist/readiness.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,CAClE,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC;AAEtF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC;AAEjF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,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,EAAE,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,SAAS,EACT,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAC1D,GAAG;IACF,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAMF,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAiC5D"}
|
package/dist/reads.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../src/reads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../src/reads.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAgD,MAAM,cAAc,CAAC;AAC1F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG;IAC9B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;IAChB,IAAI,IAAI,IAAI,CAAC;CACd,CAAC;AA2BF,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,EACzC,UAAU,EAAE,MAAM,MAAM,GACvB,SAAS,CA4EX"}
|
package/dist/reads.js
CHANGED
|
@@ -4,31 +4,24 @@ function declaredAs(declaration) {
|
|
|
4
4
|
const { roomVersion: _version, ...declared } = declaration;
|
|
5
5
|
return declared;
|
|
6
6
|
}
|
|
7
|
-
function sameHeld(one, other) {
|
|
8
|
-
return one === other;
|
|
9
|
-
}
|
|
10
7
|
function failed(answer) {
|
|
11
|
-
return answer
|
|
8
|
+
return answer.kind === 'transport-uncertainty';
|
|
12
9
|
}
|
|
13
10
|
function continues(answer) {
|
|
14
|
-
|
|
15
|
-
return page?.kind === 'net-advancement' && page.pageToken !== undefined;
|
|
11
|
+
return answer?.kind === 'net-advancement' && answer.pageToken !== undefined;
|
|
16
12
|
}
|
|
17
13
|
export function doorReads(adapter, declaration, generation) {
|
|
18
14
|
const reading = new Map();
|
|
19
15
|
const taken = new Map();
|
|
20
16
|
let carrying = false;
|
|
21
|
-
function joined(
|
|
22
|
-
const key = `${
|
|
23
|
-
const
|
|
24
|
-
const asked = JSON.stringify([declaredAs(declaration(request.locator)), named]);
|
|
17
|
+
function joined(authorization, request) {
|
|
18
|
+
const key = `${request.locator} ${request.pageToken ?? ''}`;
|
|
19
|
+
const asked = JSON.stringify([declaredAs(declaration(request.locator)), request]);
|
|
25
20
|
const asking = generation();
|
|
26
21
|
const current = reading.get(key);
|
|
27
22
|
if (current !== undefined &&
|
|
28
23
|
current.authorization === authorization &&
|
|
29
24
|
current.asked === asked &&
|
|
30
|
-
sameHeld(current.held, held) &&
|
|
31
|
-
current.received === received &&
|
|
32
25
|
(!current.settled || current.holder < asking)) {
|
|
33
26
|
if (current.settled && !current.continued)
|
|
34
27
|
reading.delete(key);
|
|
@@ -36,7 +29,7 @@ export function doorReads(adapter, declaration, generation) {
|
|
|
36
29
|
current.holder = Math.max(current.holder, asking);
|
|
37
30
|
if (current.from === asking)
|
|
38
31
|
return current.answer;
|
|
39
|
-
const again = () => joined(
|
|
32
|
+
const again = () => joined(authorization, request);
|
|
40
33
|
return current.answer.then((answer) => {
|
|
41
34
|
if (failed(answer))
|
|
42
35
|
return again();
|
|
@@ -44,13 +37,11 @@ export function doorReads(adapter, declaration, generation) {
|
|
|
44
37
|
return answer;
|
|
45
38
|
}, again);
|
|
46
39
|
}
|
|
47
|
-
const answer =
|
|
40
|
+
const answer = adapter.refresh(authorization, request);
|
|
48
41
|
const sent = {
|
|
49
42
|
locator: request.locator,
|
|
50
43
|
authorization,
|
|
51
44
|
asked,
|
|
52
|
-
held,
|
|
53
|
-
received,
|
|
54
45
|
answer,
|
|
55
46
|
from: asking,
|
|
56
47
|
holder: asking,
|
|
@@ -60,7 +51,7 @@ export function doorReads(adapter, declaration, generation) {
|
|
|
60
51
|
reading.set(key, sent);
|
|
61
52
|
const settled = (result, kept) => {
|
|
62
53
|
sent.settled = true;
|
|
63
|
-
sent.continued = kept &&
|
|
54
|
+
sent.continued = kept && continues(result);
|
|
64
55
|
if (reading.get(key) !== sent)
|
|
65
56
|
return;
|
|
66
57
|
const live = sent.holder === generation();
|
|
@@ -71,8 +62,8 @@ export function doorReads(adapter, declaration, generation) {
|
|
|
71
62
|
return answer;
|
|
72
63
|
}
|
|
73
64
|
return {
|
|
74
|
-
bootstrap: (authorization, request) =>
|
|
75
|
-
refresh:
|
|
65
|
+
bootstrap: (authorization, request) => adapter.bootstrap(authorization, request),
|
|
66
|
+
refresh: joined,
|
|
76
67
|
reached: (locator, roomVersion, target) => adapter.reached(locator, roomVersion, target),
|
|
77
68
|
carried: (locator) => taken.get(locator) ?? 0,
|
|
78
69
|
finished(locator, turn) {
|
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,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,aAA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WAAW,EACjB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAC3E,OAAO,CAAC,WAAW,EAAE,CAAC,CAKxB;AAeD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,EACzB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
|
package/dist/refresh.js
CHANGED
|
@@ -107,10 +107,7 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
107
107
|
if (first.kind !== 'net-advancement')
|
|
108
108
|
return first;
|
|
109
109
|
const roomVersion = first.roomVersion;
|
|
110
|
-
const models = remodel(first.models, {
|
|
111
|
-
collection: held.model,
|
|
112
|
-
selection: held.selectionModel,
|
|
113
|
-
});
|
|
110
|
+
const models = remodel(first.models, { collection: held.model });
|
|
114
111
|
const changed = new Set();
|
|
115
112
|
const staged = async (page) => {
|
|
116
113
|
const read = await pageOf(page, roomVersion, staging);
|
|
@@ -148,7 +145,6 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
148
145
|
record: {
|
|
149
146
|
...held,
|
|
150
147
|
model: models.collection,
|
|
151
|
-
selectionModel: models.selection,
|
|
152
148
|
roomVersion,
|
|
153
149
|
},
|
|
154
150
|
changed,
|
package/dist/replica.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BootstrapInventory, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
|
|
2
2
|
import { type ChangeBatch, type Precondition } from './change.js';
|
|
3
3
|
import { type Collection, type Composition } from './collection.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type ModelState } from './model.js';
|
|
5
5
|
import { type Layer } from './overlay.js';
|
|
6
6
|
import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
|
|
7
7
|
export type ReplicaRecord = {
|
|
@@ -12,11 +12,10 @@ export type ReplicaRecord = {
|
|
|
12
12
|
readonly replica: ReplicaAdmission;
|
|
13
13
|
readonly model: ModelState;
|
|
14
14
|
readonly typedSelection: TypedSelection | null;
|
|
15
|
-
readonly selectionModel: ModelState;
|
|
16
15
|
readonly providerOwnedPaths: readonly string[];
|
|
17
16
|
readonly roomVersion: string;
|
|
18
17
|
readonly transfer: string;
|
|
19
|
-
readonly inventory: BootstrapInventory
|
|
18
|
+
readonly inventory: BootstrapInventory;
|
|
20
19
|
readonly key: number;
|
|
21
20
|
};
|
|
22
21
|
export type HeldReplica = {
|
|
@@ -34,7 +33,7 @@ export type Slice = Layer & {
|
|
|
34
33
|
readonly written: Readonly<Record<string, string>>;
|
|
35
34
|
readonly held: ReadonlySet<string>;
|
|
36
35
|
};
|
|
37
|
-
export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'
|
|
36
|
+
export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState): Composition;
|
|
38
37
|
export declare function sameMembership(record: Pick<ReplicaRecord, 'typedSelection'>, other: Pick<ReplicaRecord, 'typedSelection'>): boolean;
|
|
39
38
|
export declare function storedRecord(record: ReplicaRecord): string;
|
|
40
39
|
export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
|
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,KAAK,EACV,kBAAkB,EAElB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAmC,KAAK,WAAW,EAAE,KAAK,YAAY,E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C,MAAM,EAAE,MAAM,CAAC,CAAM,GAC7C,OAAO,CAwBT;AAgBD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;CACvC,CAAC;AAEF,wBAAiB,QAAQ,CACvB,SAAS,EAAE,KAAK,EAChB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,EAC7C,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,GACvB,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CA4BnC;AAED,KAAK,QAAQ,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,GAAG,EAAE,SAAS,WAAW,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF,wBAAgB,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAiBrF;AAED,wBAAiB,SAAS,CACxB,SAAS,EAAE,KAAK,EAChB,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,GAChB,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CA8EnC"}
|
package/dist/replica.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { equalValue, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { immutable, landing } from './change.js';
|
|
3
3
|
import { collectionOf } from './collection.js';
|
|
4
|
+
import { storedModel } from './model.js';
|
|
4
5
|
import { acceptedBinaries, overlaying } from './overlay.js';
|
|
5
6
|
import { effectiveIn, rewriting } from './save.js';
|
|
6
7
|
import { ROW_WEIGHT } from './turn.js';
|
|
7
|
-
export function compositionOf(record) {
|
|
8
|
+
export function compositionOf(record, builtIn) {
|
|
8
9
|
return {
|
|
9
10
|
model: record.model,
|
|
10
11
|
selection: record.typedSelection === null
|
|
11
12
|
? null
|
|
12
|
-
: { roots: record.typedSelection.roots, model:
|
|
13
|
+
: { roots: record.typedSelection.roots, model: builtIn },
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
export function sameMembership(record, other) {
|
|
@@ -18,7 +19,7 @@ export function sameMembership(record, other) {
|
|
|
18
19
|
}
|
|
19
20
|
export function storedRecord(record) {
|
|
20
21
|
const { key: _key, ...stored } = record;
|
|
21
|
-
return JSON.stringify(stored);
|
|
22
|
+
return JSON.stringify({ ...stored, model: storedModel(stored.model) });
|
|
22
23
|
}
|
|
23
24
|
const PROBES = new Set([
|
|
24
25
|
'then',
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export type RoomDraftParts = {
|
|
|
40
40
|
};
|
|
41
41
|
readonly file?: {
|
|
42
42
|
readonly blob: Blob;
|
|
43
|
+
readonly base?: string | null;
|
|
43
44
|
};
|
|
44
45
|
};
|
|
45
46
|
export type HeldFile = {
|
|
@@ -112,7 +113,7 @@ export type RoomDraftWrite = {
|
|
|
112
113
|
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
113
114
|
export type ChangedPart = {
|
|
114
115
|
readonly path: string;
|
|
115
|
-
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | '
|
|
116
|
+
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
|
|
116
117
|
readonly name?: string;
|
|
117
118
|
};
|
|
118
119
|
export type RoomDraftRecord = {
|
|
@@ -132,7 +133,7 @@ export declare function held(current: HeldParts | undefined, parts: RoomDraftPar
|
|
|
132
133
|
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
133
134
|
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
134
135
|
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
135
|
-
export declare function changedParts(path: string,
|
|
136
|
+
export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
|
|
136
137
|
export type TextParts = {
|
|
137
138
|
readonly fields?: Readonly<Record<string, {
|
|
138
139
|
readonly value: unknown;
|
|
@@ -149,6 +150,20 @@ export declare function returnedInto(existing: HeldParts | undefined, returned:
|
|
|
149
150
|
export declare function moveTarget(move: {
|
|
150
151
|
readonly to: string;
|
|
151
152
|
}): string;
|
|
153
|
+
export declare function readSavedParts(named: readonly {
|
|
154
|
+
readonly path: string;
|
|
155
|
+
readonly parts: unknown;
|
|
156
|
+
}[]): readonly {
|
|
157
|
+
readonly path: string;
|
|
158
|
+
readonly parts: RoomDraftParts;
|
|
159
|
+
}[];
|
|
160
|
+
export declare function partsChanges(named: readonly {
|
|
161
|
+
readonly path: string;
|
|
162
|
+
readonly parts: unknown;
|
|
163
|
+
}[]): {
|
|
164
|
+
readonly changes: readonly Change[];
|
|
165
|
+
readonly preconditions: readonly Precondition[];
|
|
166
|
+
};
|
|
152
167
|
export declare function changesOf(path: string, parts: HeldParts): {
|
|
153
168
|
changes: readonly Change[];
|
|
154
169
|
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":"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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AE,SAAS,GAAG,SAAS,CA2B5F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAGhE;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,GACnE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;CAAE,EAAE,CAatE;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,GACnE;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,SAAS,YAAY,EAAE,CAAA;CAAE,CAgB1F;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,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
|
@@ -108,7 +108,8 @@ export function readParts(value) {
|
|
|
108
108
|
malformed();
|
|
109
109
|
if (Object.keys(value).length > 1)
|
|
110
110
|
throw runtimeError('room-draft-file-exclusive');
|
|
111
|
-
|
|
111
|
+
const base = markdownBase(value.file.base);
|
|
112
|
+
parts.file = base === undefined ? { blob: value.file.blob } : { blob: value.file.blob, base };
|
|
112
113
|
}
|
|
113
114
|
return parts;
|
|
114
115
|
}
|
|
@@ -292,18 +293,22 @@ export async function heldFile(blob, base) {
|
|
|
292
293
|
};
|
|
293
294
|
}
|
|
294
295
|
export function binaryBase(visible, path) {
|
|
295
|
-
|
|
296
|
+
const binary = visible?.binaries[path];
|
|
297
|
+
if (binary === undefined)
|
|
298
|
+
return null;
|
|
299
|
+
return visible?.revisions[path] ?? (binary.state === 'pending' ? binary.localId : null);
|
|
296
300
|
}
|
|
297
|
-
export function changedParts(path,
|
|
301
|
+
export function changedParts(path, parts, visible) {
|
|
302
|
+
const report = underneath(parts, path, visible);
|
|
303
|
+
const made = parts.file?.base === null;
|
|
298
304
|
return [
|
|
299
|
-
...(report.creation === undefined ? [] : [{ path, part: 'creation' }]),
|
|
300
305
|
...named(report.fields).map(([name]) => ({ path, part: 'field', name })),
|
|
301
306
|
...named(report.sections).map(([name]) => ({ path, part: 'section', name })),
|
|
302
307
|
...(report.preamble === undefined ? [] : [{ path, part: 'preamble' }]),
|
|
303
308
|
...(report.markdown === undefined ? [] : [{ path, part: 'markdown' }]),
|
|
304
309
|
...(report.move === undefined ? [] : [{ path, part: 'move' }]),
|
|
305
310
|
...(report.removal === undefined ? [] : [{ path, part: 'removal' }]),
|
|
306
|
-
...(report.file === undefined ? [] : [{ path, part: 'file' }]),
|
|
311
|
+
...(report.file === undefined || made ? [] : [{ path, part: 'file' }]),
|
|
307
312
|
];
|
|
308
313
|
}
|
|
309
314
|
function joined(existing, returned) {
|
|
@@ -380,6 +385,35 @@ export function moveTarget(move) {
|
|
|
380
385
|
const to = normalize(move.to);
|
|
381
386
|
return to === null || to === '' ? move.to : to;
|
|
382
387
|
}
|
|
388
|
+
export function readSavedParts(named) {
|
|
389
|
+
const read = named.map(({ path, parts }) => ({ path, parts: readParts(parts) }));
|
|
390
|
+
if (read.some(({ path }, at) => path === '' ||
|
|
391
|
+
normalize(path) !== path ||
|
|
392
|
+
read.findIndex((one) => one.path === path) !== at)) {
|
|
393
|
+
throw runtimeError('room-draft-malformed');
|
|
394
|
+
}
|
|
395
|
+
return read;
|
|
396
|
+
}
|
|
397
|
+
export function partsChanges(named) {
|
|
398
|
+
const changes = [];
|
|
399
|
+
const preconditions = [];
|
|
400
|
+
for (const { path, parts } of readSavedParts(named)) {
|
|
401
|
+
const parted = held(undefined, parts);
|
|
402
|
+
const made = changesOf(path, parted);
|
|
403
|
+
changes.push(...made.changes);
|
|
404
|
+
preconditions.push(...made.bases);
|
|
405
|
+
for (const change of made.changes) {
|
|
406
|
+
if (change.kind === 'create')
|
|
407
|
+
preconditions.push({ kind: 'absent', path });
|
|
408
|
+
if (change.kind === 'move')
|
|
409
|
+
preconditions.push({ kind: 'absent', path: change.to });
|
|
410
|
+
}
|
|
411
|
+
const revision = parted.markdown?.base ?? parted.move?.base ?? parted.removal?.base;
|
|
412
|
+
if (typeof revision === 'string')
|
|
413
|
+
preconditions.push({ kind: 'revision', path, revision });
|
|
414
|
+
}
|
|
415
|
+
return { changes, preconditions };
|
|
416
|
+
}
|
|
383
417
|
export function changesOf(path, parts) {
|
|
384
418
|
const changes = [];
|
|
385
419
|
const bases = [];
|
|
@@ -415,7 +449,7 @@ export function changesOf(path, parts) {
|
|
|
415
449
|
if (base !== null && at !== path)
|
|
416
450
|
changes.push({ kind: 'move', path, to: at });
|
|
417
451
|
changes.push({ kind: 'binary', path: at, ...file });
|
|
418
|
-
if (base === null
|
|
452
|
+
if (base === null)
|
|
419
453
|
bases.push({ kind: 'absent', path: at });
|
|
420
454
|
return { changes, bases };
|
|
421
455
|
}
|
package/dist/rows.d.ts
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { type Composition } from './collection.js';
|
|
2
2
|
export type ValueKind = 'string' | 'number' | 'boolean' | 'null' | 'array' | 'object' | 'undefined';
|
|
3
3
|
type HeldValue = {
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
4
|
+
readonly keys: string;
|
|
5
|
+
readonly places: string;
|
|
6
6
|
readonly item: number;
|
|
7
7
|
readonly kind: ValueKind;
|
|
8
8
|
readonly value: string | number | null;
|
|
9
9
|
readonly size: number | null;
|
|
10
|
-
readonly single: boolean;
|
|
11
10
|
};
|
|
12
11
|
type LinkKind = 'field' | 'section' | 'body';
|
|
13
12
|
type HeldLink = {
|
|
14
13
|
readonly kind: LinkKind;
|
|
15
|
-
readonly
|
|
14
|
+
readonly keys: string;
|
|
15
|
+
readonly places: string;
|
|
16
16
|
readonly target: string;
|
|
17
17
|
readonly field: string;
|
|
18
18
|
};
|
|
19
|
-
export type
|
|
19
|
+
export type Described = {
|
|
20
20
|
readonly type: string | null;
|
|
21
21
|
readonly declared: string | null;
|
|
22
22
|
readonly queried: boolean;
|
|
23
23
|
readonly folder: string;
|
|
24
24
|
readonly fields: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type Derived = Described & {
|
|
25
27
|
readonly values: readonly HeldValue[];
|
|
26
28
|
readonly links: readonly HeldLink[];
|
|
27
29
|
};
|
|
@@ -29,9 +31,16 @@ export declare function documentKey(room: string, path: string): string;
|
|
|
29
31
|
export declare function roomOfKey(key: string): string;
|
|
30
32
|
export declare function pathOfKey(key: string): string;
|
|
31
33
|
export declare function markdownPath(path: string): boolean;
|
|
32
|
-
export declare function settingsTextPath(path: string): boolean;
|
|
33
34
|
export declare function folderOf(path: string): string;
|
|
35
|
+
export type Reach = 'exact' | 'value' | 'link';
|
|
36
|
+
export type Placed = {
|
|
37
|
+
readonly keys: string;
|
|
38
|
+
readonly places: string;
|
|
39
|
+
readonly glob: boolean;
|
|
40
|
+
};
|
|
41
|
+
export declare function placedOf(pointer: string, reach: Reach): Placed;
|
|
34
42
|
export declare function kindOf(value: unknown): ValueKind;
|
|
43
|
+
export declare function described(path: string, content: string | null): Described;
|
|
35
44
|
export declare function derived(path: string, content: string | null, composition: Composition): Derived;
|
|
36
45
|
export {};
|
|
37
46
|
//# 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":"AAWA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEpG,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAWA,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEpG,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,KAAK,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE7C,KAAK,QAAQ,GAAG;IACd,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAA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