@agentshouse/mdruntime 0.1.0-c8f07dbee1c62 → 0.1.0-c8f16d1da438a
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 +21 -19
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +75 -165
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +171 -75
- package/dist/adapter.d.ts +147 -67
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -7
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/binary.d.ts +6 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +10 -3
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +2 -4
- package/dist/client.d.ts +23 -22
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +55 -68
- package/dist/collection.d.ts +27 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +34 -10
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +4 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +100 -62
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +41 -27
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +149 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +64 -49
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +987 -1035
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +47 -47
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +5 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +16 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +75 -30
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +8 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/host.d.ts +24 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +108 -32
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +82 -0
- package/dist/index.d.ts +24 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -7
- package/dist/install.d.ts +10 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +93 -116
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +79 -56
- package/dist/listing.d.ts +29 -22
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +71 -78
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +97 -39
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +12 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +11 -23
- package/dist/media.d.ts +20 -4
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +170 -36
- package/dist/memory.d.ts +10 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +99 -37
- package/dist/messages.d.ts +17 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +39 -38
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +4 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +97 -137
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +217 -85
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +24 -11
- package/dist/outcome.d.ts +24 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +33 -3
- package/dist/overlay.d.ts +9 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +37 -24
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +5 -58
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +28 -110
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +210 -92
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +137 -79
- package/dist/query.d.ts +2 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +184 -40
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -1
- package/dist/readiness.d.ts +20 -5
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -10
- package/dist/reads.d.ts +5 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +33 -5
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +6 -6
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -6
- package/dist/replica.d.ts +5 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +17 -19
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +31 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +278 -68
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +28 -22
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +11 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +27 -14
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +15 -20
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +43 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +324 -223
- package/dist/saves.d.ts +6 -42
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +177 -718
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -5
- package/dist/shared.d.ts +0 -5
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +4 -90
- package/dist/shown.d.ts +9 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +99 -67
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +4 -2
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +4 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +6 -16
- package/dist/source.d.ts +7 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +20 -6
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +26 -9
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +92 -26
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +26 -16
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +50 -18
- package/dist/stored.d.ts +40 -15
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +236 -66
- package/dist/surface.d.ts +15 -9
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +71 -38
- package/dist/sync.d.ts +4 -3
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +136 -110
- package/dist/tables.d.ts +31 -58
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +100 -334
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +6 -7
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +51 -11
- package/dist/wire.d.ts +71 -12
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +30 -14
- package/package.json +4 -3
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -43
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/room-drafts.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { plain } from '@agentshouse/mdmodel';
|
|
2
2
|
import { changeSet } from './change-set.js';
|
|
3
3
|
import { collectionOf } from './collection.js';
|
|
4
|
-
import { runtimeError } from './failure.js';
|
|
4
|
+
import { runtimeError, uncaught } from './failure.js';
|
|
5
5
|
import { roomDraftRevision } from './identity.js';
|
|
6
6
|
import { normalize } from './paths.js';
|
|
7
7
|
import { slicing } from './replica.js';
|
|
8
|
-
import { binaryBase, gatheredParts, held, heldFile, readParts, staleWrite, underneath, } from './room-draft.js';
|
|
8
|
+
import { binaryBase, gatheredParts, held, heldFile, heldMarks, readParts, staleWrite, underneath, } from './room-draft.js';
|
|
9
9
|
import { stepped } from './turn.js';
|
|
10
10
|
const ROOM_DRAFTS = 'room-drafts';
|
|
11
11
|
const presentationTopic = (app) => `presentation\u0000${app}`;
|
|
@@ -24,6 +24,7 @@ function roomDraftOf(record, visible) {
|
|
|
24
24
|
revision: record.revision,
|
|
25
25
|
parts: record.parts,
|
|
26
26
|
changedUnderneath: underneath(record.parts, record.path, visible),
|
|
27
|
+
marks: record.marks,
|
|
27
28
|
returned: record.returned,
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -100,30 +101,30 @@ async function writtenRoomDraft({ store }, room, path, revision, input, next) {
|
|
|
100
101
|
const local = await store.open();
|
|
101
102
|
const current = await store.draft(room, path);
|
|
102
103
|
if ((current?.revision ?? null) !== revision) {
|
|
103
|
-
return staleWrite(current === undefined ? null : (
|
|
104
|
+
return staleWrite(current === undefined ? null : (await roomDraftsOf(store, [current]))[0]);
|
|
104
105
|
}
|
|
105
106
|
const file = parts.file === undefined
|
|
106
107
|
? undefined
|
|
107
108
|
: await heldFile(parts.file.blob, parts.file.base === undefined
|
|
108
109
|
? binaryBase(await visibleOf(store, room, [path]), path)
|
|
109
110
|
: parts.file.base);
|
|
111
|
+
const kept = held(current?.parts, parts, file);
|
|
110
112
|
const record = {
|
|
111
113
|
locator: room,
|
|
112
114
|
path,
|
|
113
115
|
revision: next,
|
|
114
|
-
parts:
|
|
116
|
+
parts: kept,
|
|
117
|
+
marks: heldMarks(current?.marks ?? {}, kept),
|
|
115
118
|
returned: current?.returned ?? null,
|
|
116
119
|
};
|
|
117
120
|
await local.keepRoomDraft(record, parts.file === undefined || file === undefined
|
|
118
121
|
? []
|
|
119
122
|
: [{ key: file.localId, blob: parts.file.blob }]);
|
|
120
123
|
await store.changed(changeSet(room, { drafts: [path] }));
|
|
121
|
-
return { outcome: 'written', roomDraft: (await roomDraftsOf(store, [record]))[0]
|
|
124
|
+
return { outcome: 'written', roomDraft: (await roomDraftsOf(store, [record]))[0] };
|
|
122
125
|
}
|
|
123
|
-
async function keptPresentation({ store }, app,
|
|
124
|
-
|
|
125
|
-
const stored = next(await local.presentation(app));
|
|
126
|
-
await local.present({ app, value: stored });
|
|
126
|
+
async function keptPresentation({ store }, app, value) {
|
|
127
|
+
await (await store.open()).present({ app, value });
|
|
127
128
|
await store.changed(changeSet('', { presentation: app }));
|
|
128
129
|
}
|
|
129
130
|
export function roomDraftSurface(runtime) {
|
|
@@ -140,11 +141,12 @@ export function roomDraftSurface(runtime) {
|
|
|
140
141
|
return listed;
|
|
141
142
|
});
|
|
142
143
|
},
|
|
143
|
-
async read(room,
|
|
144
|
-
const record = await store.draft(room,
|
|
145
|
-
return record === undefined ? null : (
|
|
144
|
+
async read(room, written) {
|
|
145
|
+
const record = await store.draft(room, written.normalize('NFC'));
|
|
146
|
+
return record === undefined ? null : (await roomDraftsOf(store, [record]))[0];
|
|
146
147
|
},
|
|
147
|
-
write(room,
|
|
148
|
+
write(room, written, revision, input, next = roomDraftRevision()) {
|
|
149
|
+
const path = written.normalize('NFC');
|
|
148
150
|
if (typeof next !== 'string' || next === '')
|
|
149
151
|
return Promise.reject(runtimeError('room-draft-malformed'));
|
|
150
152
|
return store.gathered(`room-draft\u0000${room}\u0000${path}`, { revision, input, next }, (earlier, later) => {
|
|
@@ -156,12 +158,13 @@ export function roomDraftSurface(runtime) {
|
|
|
156
158
|
: { revision: earlier.revision, input: parts, next: later.next };
|
|
157
159
|
}, (written) => writtenRoomDraft(runtime, room, path, written.revision, written.input, written.next));
|
|
158
160
|
},
|
|
159
|
-
discard(room,
|
|
161
|
+
discard(room, written, revision) {
|
|
162
|
+
const path = written.normalize('NFC');
|
|
160
163
|
return store.exclusive(async () => {
|
|
161
164
|
const local = await store.open();
|
|
162
165
|
const current = await store.draft(room, path);
|
|
163
166
|
if (current === undefined || current.revision !== revision) {
|
|
164
|
-
return staleWrite(current === undefined ? null : (
|
|
167
|
+
return staleWrite(current === undefined ? null : (await roomDraftsOf(store, [current]))[0]);
|
|
165
168
|
}
|
|
166
169
|
await local.discardRoomDraft(room, path);
|
|
167
170
|
await store.changed(changeSet(room, { drafts: [path] }));
|
|
@@ -177,13 +180,16 @@ export function presentationSurface(runtime) {
|
|
|
177
180
|
return store.exclusive(() => presentationOf(store, app));
|
|
178
181
|
},
|
|
179
182
|
write(app, value) {
|
|
180
|
-
return store.exclusive(() => keptPresentation(runtime, app,
|
|
183
|
+
return store.exclusive(() => keptPresentation(runtime, app, structuredClone(value)));
|
|
181
184
|
},
|
|
182
185
|
edit(app, members) {
|
|
183
|
-
return store.gathered(`presentation\u0000${app}`, structuredClone(members), (earlier, later) => ({ ...earlier, ...later }), (edited) =>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
return store.gathered(`presentation\u0000${app}`, structuredClone(members), (earlier, later) => ({ ...earlier, ...later }), async (edited) => {
|
|
187
|
+
const kept = await (await store.open()).presentation(app);
|
|
188
|
+
await keptPresentation(runtime, app, Object.fromEntries([
|
|
189
|
+
...Object.entries(plain(kept) ? kept : {}).filter(([member]) => !Object.hasOwn(edited, member)),
|
|
190
|
+
...Object.entries(edited).filter(([, value]) => value !== null),
|
|
191
|
+
]));
|
|
192
|
+
});
|
|
187
193
|
},
|
|
188
194
|
};
|
|
189
195
|
}
|
|
@@ -200,7 +206,7 @@ export function watchRoomDrafts({ store, socket }, deliver) {
|
|
|
200
206
|
const value = await snapshotRoomDrafts(store);
|
|
201
207
|
if (!unwatched())
|
|
202
208
|
watcher.answer(value);
|
|
203
|
-
}),
|
|
209
|
+
}), uncaught);
|
|
204
210
|
return watcher.stop;
|
|
205
211
|
}
|
|
206
212
|
export function watchPresentation({ store, socket }, app, deliver) {
|
|
@@ -211,6 +217,6 @@ export function watchPresentation({ store, socket }, app, deliver) {
|
|
|
211
217
|
if (!socket.closed() && watcher.held())
|
|
212
218
|
watcher.answer(value);
|
|
213
219
|
})
|
|
214
|
-
.catch(
|
|
220
|
+
.catch(uncaught);
|
|
215
221
|
return watcher.stop;
|
|
216
222
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuthorityChange, RoomList } from './adapter.js';
|
|
2
|
+
import type { Runtime } from './runtime.js';
|
|
3
|
+
import type { Deliver } from './reach.js';
|
|
4
|
+
export declare const ROOM_LIST_TOPIC = "room-list";
|
|
5
|
+
type RoomListChange = NonNullable<AuthorityChange['roomList']>;
|
|
6
|
+
export declare function roomsListed(runtime: Runtime, list: RoomList | undefined): Promise<void>;
|
|
7
|
+
export declare function roomListChanged(runtime: Runtime, change: RoomListChange | undefined): Promise<void>;
|
|
8
|
+
export declare function watchRoomList(runtime: Runtime, deliver: Deliver): () => void;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=room-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-list.d.ts","sourceRoot":"","sources":["../src/room-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,KAAK,cAAc,GAAG,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;AA0B/D,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvF;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,cAAc,GAAG,SAAS,GACjC,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,IAAI,CAU5E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { uncaught } from './failure.js';
|
|
2
|
+
export const ROOM_LIST_TOPIC = 'room-list';
|
|
3
|
+
async function kept(runtime, next) {
|
|
4
|
+
const local = await runtime.store.open();
|
|
5
|
+
const { roomList } = await local.facts(['roomList']);
|
|
6
|
+
const listed = next(roomList);
|
|
7
|
+
if (listed === null || JSON.stringify(listed) === JSON.stringify(roomList))
|
|
8
|
+
return;
|
|
9
|
+
await local.fact('roomList', listed);
|
|
10
|
+
runtime.store.tell(ROOM_LIST_TOPIC, listed);
|
|
11
|
+
}
|
|
12
|
+
function changed(held, change) {
|
|
13
|
+
const named = new Map(change.rooms.map((room) => [room.room_ref, room]));
|
|
14
|
+
const left = new Set(change.left);
|
|
15
|
+
const known = new Set(held.rooms.map((room) => room.room_ref));
|
|
16
|
+
return {
|
|
17
|
+
rooms: [
|
|
18
|
+
...held.rooms.flatMap((room) => left.has(room.room_ref) ? [] : [named.get(room.room_ref) ?? room]),
|
|
19
|
+
...change.rooms.filter((room) => !known.has(room.room_ref)),
|
|
20
|
+
],
|
|
21
|
+
spaces: change.spaces,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function roomsListed(runtime, list) {
|
|
25
|
+
if (list === undefined)
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
return kept(runtime, () => list).catch(uncaught);
|
|
28
|
+
}
|
|
29
|
+
export function roomListChanged(runtime, change) {
|
|
30
|
+
if (change === undefined)
|
|
31
|
+
return Promise.resolve();
|
|
32
|
+
return kept(runtime, (held) => (held === null ? null : changed(held, change))).catch(uncaught);
|
|
33
|
+
}
|
|
34
|
+
export function watchRoomList(runtime, deliver) {
|
|
35
|
+
const { store } = runtime;
|
|
36
|
+
const watcher = store.watch(ROOM_LIST_TOPIC, deliver);
|
|
37
|
+
void store
|
|
38
|
+
.open()
|
|
39
|
+
.then((local) => local.facts(['roomList']))
|
|
40
|
+
.then(({ roomList }) => {
|
|
41
|
+
if (watcher.held())
|
|
42
|
+
deliver(roomList);
|
|
43
|
+
}, uncaught);
|
|
44
|
+
return watcher.stop;
|
|
45
|
+
}
|
package/dist/rows.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { type HeldValue } from '@agentshouse/mdmodel';
|
|
1
|
+
import { type Definition, type HeldValue } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { SavedFacts } from './adapter.js';
|
|
3
3
|
import { type Composition } from './collection.js';
|
|
4
|
+
import type { PlanReach } from './query.js';
|
|
4
5
|
type LinkKind = 'field' | 'link';
|
|
5
6
|
type HeldLink = {
|
|
6
7
|
readonly kind: LinkKind;
|
|
7
8
|
readonly keys: string;
|
|
8
9
|
readonly places: string;
|
|
10
|
+
readonly handle: string | null;
|
|
9
11
|
readonly target: string;
|
|
10
12
|
readonly field: string;
|
|
11
13
|
};
|
|
12
14
|
export type Described = {
|
|
13
15
|
readonly type: string | null;
|
|
14
16
|
readonly declared: string | null;
|
|
15
|
-
readonly queried: boolean;
|
|
16
17
|
readonly folder: string;
|
|
17
18
|
readonly fields: string | null;
|
|
18
19
|
readonly links: string | null;
|
|
@@ -22,18 +23,26 @@ export type Held = {
|
|
|
22
23
|
readonly fields: Readonly<Record<string, unknown>> | null;
|
|
23
24
|
readonly links: readonly string[];
|
|
24
25
|
};
|
|
26
|
+
export type Sought = {
|
|
27
|
+
readonly type: string;
|
|
28
|
+
readonly field: string;
|
|
29
|
+
readonly value: string;
|
|
30
|
+
};
|
|
25
31
|
export type Derived = {
|
|
26
32
|
readonly values: readonly HeldValue[];
|
|
27
33
|
readonly links: readonly HeldLink[];
|
|
34
|
+
readonly unique: readonly Sought[];
|
|
28
35
|
};
|
|
29
36
|
export declare function documentKey(room: string, path: string): string;
|
|
30
37
|
export declare function roomOfKey(key: string): string;
|
|
38
|
+
export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
|
|
31
39
|
export declare function pathOfKey(key: string): string;
|
|
32
40
|
export declare function markdownPath(path: string): boolean;
|
|
33
41
|
export declare function folderOf(path: string): string;
|
|
34
42
|
export declare function writtenFacts(path: string, content: string, composition: Composition): SavedFacts | null;
|
|
35
43
|
export declare function described(path: string, content: string | null, facts: SavedFacts | null): Described;
|
|
36
44
|
export declare function heldOf(path: string, content: string | null, facts: SavedFacts | null): Held;
|
|
45
|
+
export declare function uniqueValues(type: string, fields: Readonly<Record<string, unknown>>, definition: Definition | undefined): Sought[];
|
|
37
46
|
export declare function derived(path: string, held: Held, composition: Composition): Derived;
|
|
38
47
|
export {};
|
|
39
48
|
//# sourceMappingURL=rows.d.ts.map
|
package/dist/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjC,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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AAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAElE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAID,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAaD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,GACvB,UAAU,GAAG,IAAI,CAQnB;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,KAAK,EAAE,UAAU,GAAG,IAAI,GACvB,SAAS,CAaX;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAK3F;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,MAAM,EAAE,CAMV;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAiBnF"}
|
package/dist/rows.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { byCodePoint, documentFacts, indexed, parse } from '@agentshouse/mdmodel';
|
|
2
|
-
import { governing } from './collection.js';
|
|
3
|
-
import { definitionOf } from './model.js';
|
|
1
|
+
import { byCodePoint, documentFacts, fieldKey, indexed, parse, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { definitionsAt, governing } from './collection.js';
|
|
4
3
|
function keyOf(...parts) {
|
|
5
4
|
return `${parts.join('\u0000')}\u0000`;
|
|
6
5
|
}
|
|
@@ -10,11 +9,15 @@ export function documentKey(room, path) {
|
|
|
10
9
|
export function roomOfKey(key) {
|
|
11
10
|
return key.split('\u0000')[1];
|
|
12
11
|
}
|
|
12
|
+
export function roomsOfReach(reach) {
|
|
13
|
+
return new Set([...reach.rooms, ...reach.documents.map(roomOfKey)]);
|
|
14
|
+
}
|
|
13
15
|
export function pathOfKey(key) {
|
|
14
16
|
return key.split('\u0000')[2];
|
|
15
17
|
}
|
|
18
|
+
const MARKDOWN = /\.md$/iu;
|
|
16
19
|
export function markdownPath(path) {
|
|
17
|
-
return
|
|
20
|
+
return MARKDOWN.test(path);
|
|
18
21
|
}
|
|
19
22
|
export function folderOf(path) {
|
|
20
23
|
return path.slice(0, Math.max(path.lastIndexOf('/'), 0));
|
|
@@ -29,7 +32,7 @@ function fieldsText(fields) {
|
|
|
29
32
|
}
|
|
30
33
|
export function writtenFacts(path, content, composition) {
|
|
31
34
|
const model = governing(composition, path);
|
|
32
|
-
const facts = documentFacts(path, parse(content, path), {
|
|
35
|
+
const facts = documentFacts(path, parse(content, path, definitionsAt(composition, path)), {
|
|
33
36
|
types: model.status === 'unavailable' ? {} : model.types,
|
|
34
37
|
});
|
|
35
38
|
return facts === null
|
|
@@ -39,17 +42,14 @@ export function writtenFacts(path, content, composition) {
|
|
|
39
42
|
export function described(path, content, facts) {
|
|
40
43
|
const folder = folderOf(path);
|
|
41
44
|
const unread = { type: null, fields: null, links: null, folder };
|
|
42
|
-
if (content === null)
|
|
43
|
-
return { ...unread, declared: null
|
|
44
|
-
if (facts === null)
|
|
45
|
-
return { ...unread, declared: null, queried: !markdownPath(path) };
|
|
45
|
+
if (content === null || facts === null)
|
|
46
|
+
return { ...unread, declared: null };
|
|
46
47
|
const links = JSON.stringify(facts.links);
|
|
47
48
|
if (!markdownPath(path))
|
|
48
|
-
return { ...unread, declared: facts.type,
|
|
49
|
+
return { ...unread, declared: facts.type, links };
|
|
49
50
|
return {
|
|
50
51
|
type: facts.type,
|
|
51
52
|
declared: facts.type,
|
|
52
|
-
queried: true,
|
|
53
53
|
folder,
|
|
54
54
|
fields: fieldsText(facts.fields),
|
|
55
55
|
links,
|
|
@@ -62,17 +62,30 @@ export function heldOf(path, content, facts) {
|
|
|
62
62
|
? { type: facts.type, fields: facts.fields, links: facts.links }
|
|
63
63
|
: { type: null, fields: null, links: facts.links };
|
|
64
64
|
}
|
|
65
|
+
export function uniqueValues(type, fields, definition) {
|
|
66
|
+
if (definition === undefined)
|
|
67
|
+
return [];
|
|
68
|
+
return (definition.unique ?? []).flatMap((field) => {
|
|
69
|
+
const { key, unique } = fieldKey(definition, fields, field);
|
|
70
|
+
return unique ? [{ type, field, value: key }] : [];
|
|
71
|
+
});
|
|
72
|
+
}
|
|
65
73
|
export function derived(path, held, composition) {
|
|
66
74
|
const stored = held.links.map((target) => ({
|
|
67
75
|
kind: 'link',
|
|
68
76
|
keys: '',
|
|
69
77
|
places: '',
|
|
78
|
+
handle: null,
|
|
70
79
|
target,
|
|
71
80
|
field: '',
|
|
72
81
|
}));
|
|
73
82
|
if (held.type === null || held.fields === null)
|
|
74
|
-
return { values: [], links: stored };
|
|
75
|
-
const definition =
|
|
83
|
+
return { values: [], links: stored, unique: [] };
|
|
84
|
+
const definition = definitionsAt(composition, path)(held.type);
|
|
76
85
|
const { values, links: fields } = indexed(path, held.fields, definition);
|
|
77
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
values,
|
|
88
|
+
links: [...fields, ...stored],
|
|
89
|
+
unique: uniqueValues(held.type, held.fields, definition),
|
|
90
|
+
};
|
|
78
91
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"running.d.ts","sourceRoot":"","sources":["../src/running.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,KAAK,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAU/C,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,MAAM,EAAE,CAE3E"}
|
package/dist/running.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const NOUNS = {
|
|
2
|
+
subagent: ['sub-agent', 'sub-agents'],
|
|
3
|
+
shell: ['command', 'commands'],
|
|
4
|
+
task: ['task', 'tasks'],
|
|
5
|
+
monitor: ['monitor', 'monitors'],
|
|
6
|
+
schedule: ['schedule', 'schedules'],
|
|
7
|
+
};
|
|
8
|
+
export function runningWords(running) {
|
|
9
|
+
return running.map(({ kind, count }) => `${count} ${NOUNS[kind][count === 1 ? 0 : 1]}`);
|
|
10
|
+
}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ChangeSet } from './change-set.js';
|
|
3
|
-
import type { ChangeBatch } from './change.js';
|
|
1
|
+
import type { Discovery, RoomDeclaration, TypedPath } from './adapter.js';
|
|
4
2
|
import type { RuntimeShell } from './durability.js';
|
|
5
|
-
import type {
|
|
3
|
+
import type { LiveConversations } from './conversation-live.js';
|
|
4
|
+
import type { WriteRule } from './declaration.js';
|
|
6
5
|
import type { FiguresRead } from './figures.js';
|
|
7
|
-
import type { Withheld } from './install.js';
|
|
8
6
|
import type { LiveQueries } from './live.js';
|
|
9
|
-
import type { Log } from './log.js';
|
|
10
7
|
import type { ModelState } from './model.js';
|
|
8
|
+
import type { Presence } from './presence.js';
|
|
11
9
|
import type { ReadAnswers } from './reads.js';
|
|
12
10
|
import type { Recovery } from './recovery.js';
|
|
13
|
-
import type {
|
|
14
|
-
import type { RuntimeSocket
|
|
15
|
-
import type {
|
|
16
|
-
import type { Settling } from './saves.js';
|
|
17
|
-
import type { HeldCover, RuntimeStore, Store, Work } from './store.js';
|
|
11
|
+
import type { Retries } from './retried.js';
|
|
12
|
+
import type { RuntimeSocket } from './socket.js';
|
|
13
|
+
import type { HeldCover, Store } from './store.js';
|
|
18
14
|
import type { schemaTypes } from './attached-model.js';
|
|
19
15
|
export type Runtime = {
|
|
20
16
|
readonly store: Store;
|
|
21
17
|
readonly socket: RuntimeSocket;
|
|
22
|
-
readonly
|
|
18
|
+
readonly presence: Presence;
|
|
23
19
|
readonly recovery: Recovery;
|
|
20
|
+
readonly retries: Retries;
|
|
24
21
|
readonly shell: RuntimeShell;
|
|
25
22
|
readonly localSaves: boolean;
|
|
26
23
|
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
27
24
|
readonly builtIn: ModelState;
|
|
28
25
|
readonly typedPaths: readonly TypedPath[];
|
|
29
|
-
readonly
|
|
26
|
+
readonly renamedActions: ReadonlyMap<string, string>;
|
|
27
|
+
readonly rewrittenInputs: ReadonlyMap<string, (input: unknown) => unknown>;
|
|
28
|
+
readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
|
|
30
29
|
readonly build: string;
|
|
31
|
-
readonly conversations:
|
|
30
|
+
readonly conversations: LiveConversations;
|
|
32
31
|
readonly liveQueries: LiveQueries<HeldCover>;
|
|
33
32
|
readonly figures: FiguresRead;
|
|
34
33
|
readonly lastAnswers: ReadAnswers;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
submitLater(locator: string): void;
|
|
38
|
-
unpair(local: RuntimeStore): Promise<void>;
|
|
39
|
-
advanced(room: DiscoveredRoom, local: RuntimeStore, authorized: Authorization): Promise<Withheld | null>;
|
|
40
|
-
withhold(withheld: Withheld, room: DiscoveredRoom, local: RuntimeStore, progress: CycleProgress): Promise<void>;
|
|
34
|
+
readonly discover: () => Promise<void>;
|
|
35
|
+
readonly adopt: (unstored: Discovery) => Promise<void>;
|
|
41
36
|
};
|
|
42
37
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runt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,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC;IAC3E,QAAQ,CAAC,SAAS,EAAE,CAAC,WAAW,EAAE,eAAe,KAAK,SAAS,CAAC;IAChE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD,CAAC"}
|
package/dist/save.d.ts
CHANGED
|
@@ -1,103 +1,60 @@
|
|
|
1
1
|
import { type Validation } from '@agentshouse/mdmodel';
|
|
2
|
-
import type {
|
|
3
|
-
import { type
|
|
2
|
+
import type { ProviderLimit } from './adapter.js';
|
|
3
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
4
4
|
import { type Composition } from './collection.js';
|
|
5
|
+
import type { WriteRule } from './declaration.js';
|
|
5
6
|
import { type Layer } from './overlay.js';
|
|
6
|
-
import type { VisibleLayer } from './replica.js';
|
|
7
|
-
import type
|
|
7
|
+
import type { ReplicaRecord, VisibleLayer } from './replica.js';
|
|
8
|
+
import { type ChangedPart, type RoomDraftRecord, type SavedDraft } from './room-draft.js';
|
|
8
9
|
export type SaveRefusal = {
|
|
9
10
|
code: string;
|
|
10
11
|
retryable: boolean;
|
|
12
|
+
message?: string;
|
|
11
13
|
file?: string;
|
|
12
14
|
location?: string;
|
|
15
|
+
line?: number;
|
|
13
16
|
referrers?: readonly string[];
|
|
14
17
|
parts?: readonly ChangedPart[];
|
|
15
18
|
};
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
providerLimits: readonly ProviderLimit[];
|
|
23
|
-
visible: VisibleLayer;
|
|
24
|
-
folders: ReadonlySet<string>;
|
|
25
|
-
handle: string;
|
|
26
|
-
changes: readonly Change[];
|
|
27
|
-
bases: readonly Precondition[];
|
|
28
|
-
queued?: ReadonlySet<string>;
|
|
29
|
-
writtenBy?: WrittenBy;
|
|
30
|
-
unmodeled: boolean;
|
|
31
|
-
validate: Validator;
|
|
19
|
+
export type SaveAsk = {
|
|
20
|
+
readonly saved: readonly SavedDraft[];
|
|
21
|
+
readonly consumed: ReadonlySet<string>;
|
|
22
|
+
readonly writtenBy?: WrittenBy;
|
|
23
|
+
readonly local: boolean;
|
|
24
|
+
readonly providerLimits: readonly ProviderLimit[];
|
|
32
25
|
};
|
|
33
|
-
export type
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
export type SavingRoom = {
|
|
27
|
+
readonly record: ReplicaRecord;
|
|
28
|
+
readonly rule: WriteRule;
|
|
29
|
+
readonly composition: Composition;
|
|
30
|
+
readonly queue: readonly ChangeBatch[];
|
|
31
|
+
readonly changeable: ReadonlySet<string>;
|
|
32
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
33
|
+
readonly replay: (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
|
|
34
|
+
readonly folders: ReadonlySet<string>;
|
|
35
|
+
readonly modelled: boolean;
|
|
36
|
+
readonly drafts: ReadonlyMap<string, RoomDraftRecord>;
|
|
37
|
+
readonly validate: Validator;
|
|
37
38
|
};
|
|
38
|
-
export type
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
|
|
45
|
-
export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
46
|
-
export declare function queuedDocuments(queue: readonly ChangeBatch[]): ReadonlySet<string>;
|
|
47
|
-
export type Requeued = {
|
|
48
|
-
kind: 'requeued';
|
|
49
|
-
queue: readonly ChangeBatch[];
|
|
50
|
-
changes: readonly Change[];
|
|
51
|
-
queued: ReadonlySet<string>;
|
|
52
|
-
withdrawn: ReadonlyMap<string, ChangeBatch | null>;
|
|
53
|
-
owners: ReadonlySet<string>;
|
|
54
|
-
} | {
|
|
55
|
-
kind: 'refused';
|
|
56
|
-
refusal: SaveRefusal;
|
|
39
|
+
export type PlannedRoom = {
|
|
40
|
+
readonly locator: string;
|
|
41
|
+
readonly queue: readonly ChangeBatch[];
|
|
42
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
43
|
+
readonly consumed: readonly string[];
|
|
44
|
+
readonly carried: readonly RoomDraftRecord[];
|
|
57
45
|
};
|
|
58
|
-
export type
|
|
59
|
-
kind: '
|
|
60
|
-
|
|
61
|
-
queue: readonly ChangeBatch[];
|
|
46
|
+
export type SavePlan = {
|
|
47
|
+
readonly kind: 'refused';
|
|
48
|
+
readonly refusal: SaveRefusal;
|
|
62
49
|
} | {
|
|
63
|
-
kind: '
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
type VisibleOver = (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
|
|
67
|
-
export declare function requeuing(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: VisibleOver): Generator<number, Requeued, void>;
|
|
68
|
-
export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
|
|
69
|
-
export declare function limiting(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: VisibleOver): Generator<number, SaveRefusal | null, void>;
|
|
70
|
-
export declare const MOVE_DOCUMENTS = "move-documents";
|
|
71
|
-
export type MoveSide = {
|
|
72
|
-
room: string;
|
|
73
|
-
handle: string;
|
|
74
|
-
baseRoomVersion: string;
|
|
75
|
-
composition: Composition;
|
|
76
|
-
operations: OperationScopes;
|
|
77
|
-
providerOwnedPaths: readonly string[];
|
|
78
|
-
visible: VisibleLayer;
|
|
79
|
-
folders: ReadonlySet<string>;
|
|
80
|
-
queued: ReadonlySet<string>;
|
|
81
|
-
unmodeled: boolean;
|
|
82
|
-
validate: Validator;
|
|
50
|
+
readonly kind: 'planned';
|
|
51
|
+
readonly identifier: string;
|
|
52
|
+
readonly rooms: readonly PlannedRoom[];
|
|
83
53
|
};
|
|
84
|
-
export type
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}[];
|
|
91
|
-
providerLimits: readonly ProviderLimit[];
|
|
92
|
-
local: boolean;
|
|
93
|
-
writtenBy?: WrittenBy;
|
|
94
|
-
};
|
|
95
|
-
export type MoveResult = {
|
|
96
|
-
kind: 'moved';
|
|
97
|
-
leaving: ChangeBatch;
|
|
98
|
-
arriving: ChangeBatch;
|
|
99
|
-
} | Refusing;
|
|
100
|
-
export declare function buildMove(input: MoveInput): Promise<MoveResult>;
|
|
101
|
-
export declare function buildBatch(input: SaveInput): Promise<BatchResult>;
|
|
102
|
-
export {};
|
|
54
|
+
export type Validator = (resulting: Layer, touched: readonly string[]) => Promise<Validation>;
|
|
55
|
+
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
56
|
+
export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
|
|
57
|
+
export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
58
|
+
export declare function destination(locator: string, saved: readonly SavedDraft[]): string | null;
|
|
59
|
+
export declare function planSave(ask: SaveAsk, room: SavingRoom, into?: SavingRoom): Promise<SavePlan>;
|
|
103
60
|
//# sourceMappingURL=save.d.ts.map
|
package/dist/save.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AACA,OAAO,EAqBL,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAOL,KAAK,WAAW,EAIhB,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAQL,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAOL,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ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