@agentshouse/mdruntime 0.1.0-alpha.20 → 0.1.0-alpha.22

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.
Files changed (57) hide show
  1. package/AGENTS.md +9 -1
  2. package/dist/adapter.d.ts +20 -3
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/adapter.js.map +1 -1
  5. package/dist/change-set.d.ts +40 -0
  6. package/dist/change-set.d.ts.map +1 -0
  7. package/dist/change-set.js +94 -0
  8. package/dist/change-set.js.map +1 -0
  9. package/dist/client.d.ts +7 -6
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/client.js +19 -13
  12. package/dist/client.js.map +1 -1
  13. package/dist/collection.d.ts +8 -2
  14. package/dist/collection.d.ts.map +1 -1
  15. package/dist/collection.js +8 -3
  16. package/dist/collection.js.map +1 -1
  17. package/dist/connection.d.ts +4 -2
  18. package/dist/connection.d.ts.map +1 -1
  19. package/dist/connection.js +308 -168
  20. package/dist/connection.js.map +1 -1
  21. package/dist/conversation.d.ts +28 -16
  22. package/dist/conversation.d.ts.map +1 -1
  23. package/dist/conversation.js +371 -269
  24. package/dist/conversation.js.map +1 -1
  25. package/dist/file.d.ts +2 -2
  26. package/dist/file.d.ts.map +1 -1
  27. package/dist/file.js.map +1 -1
  28. package/dist/host.d.ts.map +1 -1
  29. package/dist/host.js +7 -8
  30. package/dist/host.js.map +1 -1
  31. package/dist/index.d.ts +3 -3
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/memory.d.ts +3 -2
  35. package/dist/memory.d.ts.map +1 -1
  36. package/dist/memory.js +24 -20
  37. package/dist/memory.js.map +1 -1
  38. package/dist/overlay.d.ts +2 -0
  39. package/dist/overlay.d.ts.map +1 -1
  40. package/dist/overlay.js +106 -0
  41. package/dist/overlay.js.map +1 -1
  42. package/dist/refresh.d.ts.map +1 -1
  43. package/dist/refresh.js +1 -1
  44. package/dist/refresh.js.map +1 -1
  45. package/dist/replica.d.ts +12 -3
  46. package/dist/replica.d.ts.map +1 -1
  47. package/dist/replica.js +61 -26
  48. package/dist/replica.js.map +1 -1
  49. package/dist/store.d.ts +43 -19
  50. package/dist/store.d.ts.map +1 -1
  51. package/dist/store.js +371 -106
  52. package/dist/store.js.map +1 -1
  53. package/dist/wire.d.ts +2 -2
  54. package/dist/wire.d.ts.map +1 -1
  55. package/dist/wire.js +4 -5
  56. package/dist/wire.js.map +1 -1
  57. package/package.json +1 -1
package/dist/store.js CHANGED
@@ -1,18 +1,17 @@
1
1
  const DATABASE = 'mdruntime';
2
- const REPLICAS = 'replicas';
3
- const SYNCHRONIZATION = 'synchronization';
4
- const DISCOVERY = 'discovery';
5
- const QUEUES = 'queues';
2
+ const ROOMS = 'rooms';
3
+ const DOCUMENTS = 'documents';
4
+ const BINARY_TARGETS = 'binaryTargets';
5
+ const PENDING_CHANGES = 'pendingChanges';
6
+ const OUTCOMES = 'outcomes';
7
+ const DECLARATIONS = 'declarations';
6
8
  const DRAFTS = 'drafts';
7
9
  const PRESENTATION = 'presentation';
8
10
  const CONVERSATIONS = 'conversations';
9
- const INSTRUCTIONS = 'instructions';
10
- const LAST_COMPLETED = 'lastCompleted';
11
- const GENERATION = 'generation';
12
- const PROVIDER_LIMITS = 'providerLimits';
13
- const CAPABILITIES = 'capabilities';
14
- const SLOTS = 'slots';
15
- const SCHEMA = 9;
11
+ const MESSAGES = 'messages';
12
+ const CHAT_DRAFTS = 'chatDrafts';
13
+ const CURRENT = 'current';
14
+ const SCHEMA = 11;
16
15
  function settled(request) {
17
16
  return new Promise((resolve, reject)=>{
18
17
  request.onsuccess = ()=>resolve(request.result);
@@ -26,6 +25,41 @@ function completed(transaction) {
26
25
  transaction.onabort = ()=>reject(transaction.error);
27
26
  });
28
27
  }
28
+ const EMPTY_DECLARATIONS = {
29
+ lastCompleted: null,
30
+ generation: null,
31
+ providerLimits: [],
32
+ capabilities: [],
33
+ slots: []
34
+ };
35
+ function declaration(database) {
36
+ const transaction = database.transaction(DECLARATIONS, 'readonly');
37
+ return settled(transaction.objectStore(DECLARATIONS).get(CURRENT)).then((record)=>record ?? EMPTY_DECLARATIONS);
38
+ }
39
+ function updateDeclaration(database, update) {
40
+ const transaction = database.transaction(DECLARATIONS, 'readwrite');
41
+ const store = transaction.objectStore(DECLARATIONS);
42
+ const prior = store.get(CURRENT);
43
+ prior.onsuccess = ()=>{
44
+ store.put(update(prior.result ?? EMPTY_DECLARATIONS), CURRENT);
45
+ };
46
+ return completed(transaction);
47
+ }
48
+ function roomRecord(record, queue) {
49
+ const { documents, binaryTargets, revisions, ...room } = record;
50
+ return {
51
+ ...room,
52
+ order: queue.map((batch)=>batch.id)
53
+ };
54
+ }
55
+ function removeRoomEntries(store, locator) {
56
+ const keys = store.getAllKeys();
57
+ keys.onsuccess = ()=>{
58
+ for (const key of keys.result){
59
+ if (Array.isArray(key) && key[0] === locator) store.delete(key);
60
+ }
61
+ };
62
+ }
29
63
  export function removeRuntimeStore() {
30
64
  return new Promise((resolve, reject)=>{
31
65
  const removal = indexedDB.deleteDatabase(DATABASE);
@@ -33,24 +67,39 @@ export function removeRuntimeStore() {
33
67
  removal.onerror = ()=>reject(removal.error);
34
68
  });
35
69
  }
36
- function discardEveryEarlierStore(database) {
37
- for (const name of [
38
- ...database.objectStoreNames
39
- ])database.deleteObjectStore(name);
40
- }
41
70
  export async function openRuntimeStore() {
42
71
  const opening = indexedDB.open(DATABASE, SCHEMA);
43
72
  opening.onupgradeneeded = ()=>{
44
73
  const database = opening.result;
45
- discardEveryEarlierStore(database);
46
- database.createObjectStore(REPLICAS, {
74
+ for (const name of [
75
+ ...database.objectStoreNames
76
+ ])database.deleteObjectStore(name);
77
+ database.createObjectStore(ROOMS, {
47
78
  keyPath: 'locator'
48
79
  });
49
- database.createObjectStore(SYNCHRONIZATION);
50
- database.createObjectStore(DISCOVERY);
51
- database.createObjectStore(QUEUES, {
52
- keyPath: 'locator'
80
+ database.createObjectStore(DOCUMENTS, {
81
+ keyPath: [
82
+ 'locator',
83
+ 'path'
84
+ ]
85
+ });
86
+ database.createObjectStore(BINARY_TARGETS, {
87
+ keyPath: [
88
+ 'locator',
89
+ 'path'
90
+ ]
91
+ });
92
+ database.createObjectStore(PENDING_CHANGES, {
93
+ keyPath: [
94
+ 'locator',
95
+ 'id'
96
+ ]
97
+ });
98
+ const outcomes = database.createObjectStore(OUTCOMES, {
99
+ keyPath: 'id'
53
100
  });
101
+ outcomes.createIndex('locator', 'locator');
102
+ database.createObjectStore(DECLARATIONS);
54
103
  database.createObjectStore(DRAFTS, {
55
104
  keyPath: [
56
105
  'locator',
@@ -63,56 +112,228 @@ export async function openRuntimeStore() {
63
112
  database.createObjectStore(CONVERSATIONS, {
64
113
  keyPath: 'conversation'
65
114
  });
66
- database.createObjectStore(INSTRUCTIONS, {
115
+ const messages = database.createObjectStore(MESSAGES, {
116
+ keyPath: [
117
+ 'conversation',
118
+ 'identity'
119
+ ]
120
+ });
121
+ messages.createIndex('conversation', 'conversation');
122
+ database.createObjectStore(CHAT_DRAFTS, {
67
123
  keyPath: 'conversation'
68
124
  });
69
125
  };
70
126
  const database = await settled(opening);
71
127
  return {
72
128
  async all () {
73
- const transaction = database.transaction(REPLICAS, 'readonly');
74
- return settled(transaction.objectStore(REPLICAS).getAll());
129
+ const transaction = database.transaction([
130
+ ROOMS,
131
+ DOCUMENTS,
132
+ BINARY_TARGETS
133
+ ], 'readonly');
134
+ const [rooms, documents, targets] = await Promise.all([
135
+ settled(transaction.objectStore(ROOMS).getAll()),
136
+ settled(transaction.objectStore(DOCUMENTS).getAll()),
137
+ settled(transaction.objectStore(BINARY_TARGETS).getAll())
138
+ ]);
139
+ const byRoom = new Map();
140
+ for (const { order, ...room } of rooms){
141
+ byRoom.set(room.locator, {
142
+ ...room,
143
+ documents: {},
144
+ revisions: {},
145
+ binaryTargets: []
146
+ });
147
+ }
148
+ for (const document of documents){
149
+ const room = byRoom.get(document.locator);
150
+ if (room === undefined) continue;
151
+ room.documents[document.path] = document.content;
152
+ if (document.revision !== null) {
153
+ room.revisions[document.path] = document.revision;
154
+ }
155
+ }
156
+ for (const target of targets){
157
+ const room = byRoom.get(target.locator);
158
+ if (room === undefined) continue;
159
+ room.binaryTargets.push(target.path);
160
+ if (target.revision !== null) {
161
+ room.revisions[target.path] = target.revision;
162
+ }
163
+ }
164
+ return [
165
+ ...byRoom.values()
166
+ ];
167
+ },
168
+ async write ({ next, previous, queue, previousQueue, outcomes, consumedDrafts }) {
169
+ const transaction = database.transaction([
170
+ ROOMS,
171
+ DOCUMENTS,
172
+ BINARY_TARGETS,
173
+ PENDING_CHANGES,
174
+ OUTCOMES,
175
+ DRAFTS
176
+ ], 'readwrite');
177
+ transaction.objectStore(ROOMS).put(roomRecord(next, queue));
178
+ const documents = transaction.objectStore(DOCUMENTS);
179
+ for (const path of Object.keys(previous?.documents ?? {})){
180
+ if (next.documents[path] === undefined) documents.delete([
181
+ next.locator,
182
+ path
183
+ ]);
184
+ }
185
+ for (const [path, content] of Object.entries(next.documents)){
186
+ if (previous?.documents[path] === content && previous.revisions[path] === next.revisions[path]) continue;
187
+ documents.put({
188
+ locator: next.locator,
189
+ path,
190
+ content,
191
+ revision: next.revisions[path] ?? null
192
+ });
193
+ }
194
+ const targets = transaction.objectStore(BINARY_TARGETS);
195
+ const beforeTargets = new Set(previous?.binaryTargets ?? []);
196
+ const afterTargets = new Set(next.binaryTargets);
197
+ for (const path of beforeTargets){
198
+ if (!afterTargets.has(path)) targets.delete([
199
+ next.locator,
200
+ path
201
+ ]);
202
+ }
203
+ for (const path of afterTargets){
204
+ if (!beforeTargets.has(path) || previous?.revisions[path] !== next.revisions[path]) {
205
+ targets.put({
206
+ locator: next.locator,
207
+ path,
208
+ revision: next.revisions[path] ?? null
209
+ });
210
+ }
211
+ }
212
+ if (previousQueue !== undefined) {
213
+ const pending = transaction.objectStore(PENDING_CHANGES);
214
+ const before = new Set(previousQueue.map((batch)=>batch.id));
215
+ const after = new Set(queue.map((batch)=>batch.id));
216
+ for (const id of before){
217
+ if (!after.has(id)) pending.delete([
218
+ next.locator,
219
+ id
220
+ ]);
221
+ }
222
+ for (const batch of queue){
223
+ if (!before.has(batch.id)) {
224
+ pending.put({
225
+ locator: next.locator,
226
+ id: batch.id,
227
+ batch,
228
+ submitted: false
229
+ });
230
+ }
231
+ }
232
+ }
233
+ const outcomeStore = transaction.objectStore(OUTCOMES);
234
+ for (const entry of outcomes ?? []){
235
+ if (entry.outcome === null) outcomeStore.delete(entry.id);
236
+ else outcomeStore.put({
237
+ locator: next.locator,
238
+ id: entry.id,
239
+ outcome: entry.outcome
240
+ });
241
+ }
242
+ const draftStore = transaction.objectStore(DRAFTS);
243
+ for (const path of consumedDrafts ?? [])draftStore.delete([
244
+ next.locator,
245
+ path
246
+ ]);
247
+ await completed(transaction);
75
248
  },
76
- async publish (record) {
77
- const transaction = database.transaction(REPLICAS, 'readwrite');
78
- transaction.objectStore(REPLICAS).put(record);
249
+ async revokeModels (records) {
250
+ const transaction = database.transaction(ROOMS, 'readwrite');
251
+ const rooms = transaction.objectStore(ROOMS);
252
+ const revoked = {
253
+ status: 'unavailable',
254
+ reason: 'revoked'
255
+ };
256
+ for (const { record, queue } of records){
257
+ rooms.put(roomRecord({
258
+ ...record,
259
+ model: revoked,
260
+ selectionModel: revoked
261
+ }, queue));
262
+ }
79
263
  await completed(transaction);
80
264
  },
81
265
  async lastCompleted () {
82
- const transaction = database.transaction(SYNCHRONIZATION, 'readonly');
83
- const value = await settled(transaction.objectStore(SYNCHRONIZATION).get(LAST_COMPLETED));
84
- return value ?? null;
266
+ return (await declaration(database)).lastCompleted;
85
267
  },
86
- async complete (at) {
87
- const transaction = database.transaction(SYNCHRONIZATION, 'readwrite');
88
- transaction.objectStore(SYNCHRONIZATION).put(at, LAST_COMPLETED);
89
- await completed(transaction);
268
+ complete (at) {
269
+ return updateDeclaration(database, (record)=>({
270
+ ...record,
271
+ lastCompleted: at
272
+ }));
90
273
  },
91
274
  async providerLimits () {
92
- const transaction = database.transaction(DISCOVERY, 'readonly');
93
- const value = await settled(transaction.objectStore(DISCOVERY).get(PROVIDER_LIMITS));
94
- return value ?? [];
275
+ return (await declaration(database)).providerLimits;
95
276
  },
96
277
  async capabilities () {
97
- const transaction = database.transaction(DISCOVERY, 'readonly');
98
- const value = await settled(transaction.objectStore(DISCOVERY).get(CAPABILITIES));
99
- return value ?? [];
278
+ return (await declaration(database)).capabilities;
100
279
  },
101
280
  async slots () {
102
- const transaction = database.transaction(DISCOVERY, 'readonly');
103
- const value = await settled(transaction.objectStore(DISCOVERY).get(SLOTS));
104
- return value ?? [];
105
- },
106
- async declare (limits, capabilities, slots) {
107
- const transaction = database.transaction(DISCOVERY, 'readwrite');
108
- transaction.objectStore(DISCOVERY).put(limits, PROVIDER_LIMITS);
109
- transaction.objectStore(DISCOVERY).put(capabilities, CAPABILITIES);
110
- transaction.objectStore(DISCOVERY).put(slots, SLOTS);
111
- await completed(transaction);
281
+ return (await declaration(database)).slots;
282
+ },
283
+ declare (limits, capabilities, slots) {
284
+ return updateDeclaration(database, (record)=>({
285
+ ...record,
286
+ providerLimits: limits,
287
+ capabilities,
288
+ slots
289
+ }));
112
290
  },
113
291
  async queues () {
114
- const transaction = database.transaction(QUEUES, 'readonly');
115
- return settled(transaction.objectStore(QUEUES).getAll());
292
+ const transaction = database.transaction([
293
+ ROOMS,
294
+ PENDING_CHANGES
295
+ ], 'readonly');
296
+ const [rooms, pending] = await Promise.all([
297
+ settled(transaction.objectStore(ROOMS).getAll()),
298
+ settled(transaction.objectStore(PENDING_CHANGES).getAll())
299
+ ]);
300
+ const byId = new Map(pending.map((record)=>[
301
+ `${record.locator}\0${record.id}`,
302
+ record.batch
303
+ ]));
304
+ return rooms.map((room)=>({
305
+ locator: room.locator,
306
+ batches: room.order.map((id)=>{
307
+ const batch = byId.get(`${room.locator}\0${id}`);
308
+ if (batch === undefined) throw new Error(`Missing Pending Change ${room.locator}/${id}`);
309
+ return batch;
310
+ })
311
+ }));
312
+ },
313
+ async outcomes () {
314
+ const transaction = database.transaction(OUTCOMES, 'readonly');
315
+ return settled(transaction.objectStore(OUTCOMES).getAll());
316
+ },
317
+ async markSubmitted (locator, id) {
318
+ const transaction = database.transaction(PENDING_CHANGES, 'readwrite');
319
+ const pending = transaction.objectStore(PENDING_CHANGES);
320
+ let marked = false;
321
+ const request = pending.get([
322
+ locator,
323
+ id
324
+ ]);
325
+ request.onsuccess = ()=>{
326
+ const record = request.result;
327
+ if (record !== undefined && !record.submitted) {
328
+ pending.put({
329
+ ...record,
330
+ submitted: true
331
+ });
332
+ marked = true;
333
+ }
334
+ };
335
+ await completed(transaction);
336
+ return marked;
116
337
  },
117
338
  async drafts () {
118
339
  const transaction = database.transaction(DRAFTS, 'readonly');
@@ -128,31 +349,86 @@ export async function openRuntimeStore() {
128
349
  await completed(transaction);
129
350
  },
130
351
  async conversations () {
131
- const transaction = database.transaction(CONVERSATIONS, 'readonly');
132
- return settled(transaction.objectStore(CONVERSATIONS).getAll());
352
+ const transaction = database.transaction([
353
+ CONVERSATIONS,
354
+ MESSAGES
355
+ ], 'readonly');
356
+ const [reads, messages] = await Promise.all([
357
+ settled(transaction.objectStore(CONVERSATIONS).getAll()),
358
+ settled(transaction.objectStore(MESSAGES).getAll())
359
+ ]);
360
+ const held = new Map();
361
+ for (const { conversation, read } of reads){
362
+ held.set(conversation, {
363
+ conversation,
364
+ read,
365
+ messages: []
366
+ });
367
+ }
368
+ for (const { conversation, ...message } of messages){
369
+ const entry = held.get(conversation) ?? {
370
+ conversation,
371
+ read: undefined,
372
+ messages: []
373
+ };
374
+ entry.messages.push(message);
375
+ held.set(conversation, entry);
376
+ }
377
+ return [
378
+ ...held.values()
379
+ ];
133
380
  },
134
- async keepConversation (record) {
135
- const transaction = database.transaction(CONVERSATIONS, 'readwrite');
136
- transaction.objectStore(CONVERSATIONS).put(record);
381
+ async keepMessages ({ conversation, messages, read, sealed }) {
382
+ const transaction = database.transaction([
383
+ CONVERSATIONS,
384
+ MESSAGES,
385
+ CHAT_DRAFTS
386
+ ], 'readwrite');
387
+ const stored = transaction.objectStore(MESSAGES);
388
+ for (const message of messages){
389
+ stored.put({
390
+ ...message,
391
+ conversation
392
+ });
393
+ }
394
+ if (read !== undefined) {
395
+ transaction.objectStore(CONVERSATIONS).put({
396
+ conversation,
397
+ read
398
+ });
399
+ }
400
+ if (sealed === true) transaction.objectStore(CHAT_DRAFTS).delete(conversation);
137
401
  await completed(transaction);
138
402
  },
139
- async dropConversation (conversation) {
140
- const transaction = database.transaction(CONVERSATIONS, 'readwrite');
141
- transaction.objectStore(CONVERSATIONS).delete(conversation);
403
+ async dropConversations (conversations) {
404
+ const transaction = database.transaction([
405
+ CONVERSATIONS,
406
+ MESSAGES,
407
+ CHAT_DRAFTS
408
+ ], 'readwrite');
409
+ const messages = transaction.objectStore(MESSAGES);
410
+ for (const conversation of conversations){
411
+ transaction.objectStore(CONVERSATIONS).delete(conversation);
412
+ transaction.objectStore(CHAT_DRAFTS).delete(conversation);
413
+ const keys = messages.index('conversation').getAllKeys(conversation);
414
+ keys.onsuccess = ()=>{
415
+ for (const key of keys.result)messages.delete(key);
416
+ };
417
+ }
142
418
  await completed(transaction);
143
419
  },
144
- async instructions () {
145
- const transaction = database.transaction(INSTRUCTIONS, 'readonly');
146
- return settled(transaction.objectStore(INSTRUCTIONS).getAll());
420
+ async chatDrafts () {
421
+ const transaction = database.transaction(CHAT_DRAFTS, 'readonly');
422
+ return settled(transaction.objectStore(CHAT_DRAFTS).getAll());
147
423
  },
148
- async keepInstruction (record) {
149
- const transaction = database.transaction(INSTRUCTIONS, 'readwrite');
150
- transaction.objectStore(INSTRUCTIONS).put(record);
424
+ async keepChatDraft (record) {
425
+ const transaction = database.transaction(CHAT_DRAFTS, 'readwrite');
426
+ transaction.objectStore(CHAT_DRAFTS).put(record);
151
427
  await completed(transaction);
152
428
  },
153
- async dropInstruction (conversation) {
154
- const transaction = database.transaction(INSTRUCTIONS, 'readwrite');
155
- transaction.objectStore(INSTRUCTIONS).delete(conversation);
429
+ async dropChatDraft (conversation) {
430
+ const transaction = database.transaction(CHAT_DRAFTS, 'readwrite');
431
+ transaction.objectStore(CHAT_DRAFTS).delete(conversation);
156
432
  await completed(transaction);
157
433
  },
158
434
  async keep (draft) {
@@ -168,52 +444,41 @@ export async function openRuntimeStore() {
168
444
  ]);
169
445
  await completed(transaction);
170
446
  },
171
- async append (queue, consumed) {
172
- const transaction = database.transaction([
173
- QUEUES,
174
- DRAFTS
175
- ], 'readwrite');
176
- transaction.objectStore(QUEUES).put(queue);
177
- const drafts = transaction.objectStore(DRAFTS);
178
- for (const path of consumed)drafts.delete([
179
- queue.locator,
180
- path
181
- ]);
182
- await completed(transaction);
183
- },
184
- async writeQueue (queue) {
185
- const transaction = database.transaction(QUEUES, 'readwrite');
186
- transaction.objectStore(QUEUES).put(queue);
187
- await completed(transaction);
188
- },
189
447
  async dropRooms (locators) {
190
448
  const transaction = database.transaction([
191
- REPLICAS,
192
- QUEUES,
449
+ ROOMS,
450
+ DOCUMENTS,
451
+ BINARY_TARGETS,
452
+ PENDING_CHANGES,
453
+ OUTCOMES,
193
454
  DRAFTS
194
455
  ], 'readwrite');
195
456
  for (const locator of locators){
196
- transaction.objectStore(REPLICAS).delete(locator);
197
- transaction.objectStore(QUEUES).delete(locator);
198
- }
199
- const drafts = transaction.objectStore(DRAFTS);
200
- const keys = drafts.getAllKeys();
201
- keys.onsuccess = ()=>{
202
- for (const key of keys.result){
203
- if (locators.includes(key[0])) drafts.delete(key);
457
+ transaction.objectStore(ROOMS).delete(locator);
458
+ for (const name of [
459
+ DOCUMENTS,
460
+ BINARY_TARGETS,
461
+ PENDING_CHANGES,
462
+ DRAFTS
463
+ ]){
464
+ removeRoomEntries(transaction.objectStore(name), locator);
204
465
  }
205
- };
466
+ const outcomes = transaction.objectStore(OUTCOMES);
467
+ const ids = outcomes.index('locator').getAllKeys(locator);
468
+ ids.onsuccess = ()=>{
469
+ for (const id of ids.result)outcomes.delete(id);
470
+ };
471
+ }
206
472
  await completed(transaction);
207
473
  },
208
474
  async generation () {
209
- const transaction = database.transaction(SYNCHRONIZATION, 'readonly');
210
- const value = await settled(transaction.objectStore(SYNCHRONIZATION).get(GENERATION));
211
- return value ?? null;
475
+ return (await declaration(database)).generation;
212
476
  },
213
- async rememberGeneration (value) {
214
- const transaction = database.transaction(SYNCHRONIZATION, 'readwrite');
215
- transaction.objectStore(SYNCHRONIZATION).put(value, GENERATION);
216
- await completed(transaction);
477
+ rememberGeneration (value) {
478
+ return updateDeclaration(database, (record)=>({
479
+ ...record,
480
+ generation: value
481
+ }));
217
482
  },
218
483
  close () {
219
484
  database.close();