@procedures/collections 0.2.3 → 0.4.0

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.
@@ -0,0 +1,405 @@
1
+ /**
2
+ * The contract of `CollectionStorage` as one test suite (finding of roadmap R45).
3
+ *
4
+ * Each storage package runs the suite with a factory of its storage: `InMemoryStorage` in this
5
+ * package, `ApiStorage` and `HybridStorage` in `@procedures/store`, and `SqliteStorage` in
6
+ * `@procedures/sqlite`. Before, each package copied the cases of `InMemoryStorage`.
7
+ *
8
+ * The suite is in the test-only entry `@procedures/collections/testing`. It imports no test
9
+ * framework: the caller gives `describe` and `it`, and the checks throw `ContractViolation`. So a
10
+ * storage package imports the suite without a cycle, and a runtime entry never loads vitest.
11
+ *
12
+ * ```ts
13
+ * import { describe, it } from "vitest";
14
+ * import { describeCollectionStorageContract } from "@procedures/collections/testing";
15
+ *
16
+ * describeCollectionStorageContract("MyStorage", { create: () => new MyStorage() }, { describe, it });
17
+ * ```
18
+ */
19
+ import { byId, holds, rejects, same, show } from "./check.js";
20
+ const item = (id, n, tags) => (tags === undefined ? { id, n } : { id, n, tags });
21
+ const ids = (items) => items.map((value) => value.id);
22
+ /** True for a value with a `then` function. */
23
+ function isPromise(value) {
24
+ return typeof value?.then === "function";
25
+ }
26
+ /** This function makes a storage, runs the body, and closes the storage. */
27
+ async function withStorage(create, body) {
28
+ const storage = await create();
29
+ try {
30
+ await body(storage);
31
+ }
32
+ finally {
33
+ await storage.close().catch(() => undefined);
34
+ }
35
+ }
36
+ /** The changes of a storage that has `getChangesSince`. */
37
+ function changesOf(storage) {
38
+ return (since) => storage.getChangesSince(since);
39
+ }
40
+ /** This function skips a case for a storage without an optional method, and gives true. */
41
+ function lacks(storage, method, context) {
42
+ if (typeof storage[method] === "function")
43
+ return false;
44
+ context?.skip?.(`The storage has no ${method}()`);
45
+ return true;
46
+ }
47
+ /** A random number generator with a seed, so a failed sequence comes again in the next run. */
48
+ function seeded(seed) {
49
+ let state = seed >>> 0;
50
+ return (below) => {
51
+ state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
52
+ return state % below;
53
+ };
54
+ }
55
+ /**
56
+ * This function gives the cases of the contract for a storage. Each case makes its own storage
57
+ * with `options.create`. A case for an optional method (`getEntries`, `getChangesSince`, `flush`,
58
+ * `getMetadata`) skips a storage without the method.
59
+ */
60
+ export function collectionStorageContract(options) {
61
+ const create = () => options.create();
62
+ const nullValues = options.nullValues ?? true;
63
+ const cases = [];
64
+ const add = (name, run) => {
65
+ cases.push({ name, run });
66
+ };
67
+ add("each method gives a promise", () => withStorage(create, async (storage) => {
68
+ const results = [
69
+ ["get", storage.get("a")],
70
+ ["getAll", storage.getAll()],
71
+ ["find", storage.find(() => true)],
72
+ ["has", storage.has("a")],
73
+ ["size", storage.size()],
74
+ ["getBatch", storage.getBatch(["a"])],
75
+ ];
76
+ for (const [name, result] of results)
77
+ holds(isPromise(result), `${name}() did not give a promise`);
78
+ await Promise.all(results.map(([, result]) => result));
79
+ for (const [name, start] of [
80
+ ["set", () => storage.set("a", item("a", 1))],
81
+ ["setBatch", () => storage.setBatch([["b", item("b", 2)]])],
82
+ ["delete", () => storage.delete("a")],
83
+ ["deleteBatch", () => storage.deleteBatch(["b"])],
84
+ ["clear", () => storage.clear()],
85
+ ]) {
86
+ const result = start();
87
+ holds(isPromise(result), `${name}() did not give a promise`);
88
+ await result;
89
+ }
90
+ }));
91
+ add("an empty storage has no item", () => withStorage(create, async (storage) => {
92
+ same(await storage.size(), 0, "size() of an empty storage");
93
+ same(await storage.getAll(), [], "getAll() of an empty storage");
94
+ same(await storage.get("a"), undefined, "get() of a missing id");
95
+ same(await storage.has("a"), false, "has() of a missing id");
96
+ same(await storage.getBatch(["a", "b"]), new Map(), "getBatch() of missing ids");
97
+ same(await storage.find(() => true), [], "find() in an empty storage");
98
+ same(await storage.delete("a"), false, "delete() of a missing id");
99
+ same(await storage.deleteBatch(["a", "b"]), 0, "deleteBatch() of missing ids");
100
+ if (storage.getEntries)
101
+ same(await storage.getEntries(), [], "getEntries() of an empty storage");
102
+ }));
103
+ add("set() stores an item, and a second set() of the id replaces it", () => withStorage(create, async (storage) => {
104
+ await storage.set("a", item("a", 1, ["x"]));
105
+ await storage.set("b", item("b", 2));
106
+ same(await storage.get("a"), item("a", 1, ["x"]), "get() after set()");
107
+ same(await storage.has("a"), true, "has() after set()");
108
+ same(await storage.size(), 2, "size() after two set() calls");
109
+ await storage.set("a", item("a", 10));
110
+ same(await storage.get("a"), item("a", 10), "get() after a second set() of the id");
111
+ same(await storage.size(), 2, "size() after a second set() of an id");
112
+ }));
113
+ add("delete() gives true for an item that existed, and deleteBatch() counts the items that existed", () => withStorage(create, async (storage) => {
114
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)], ["c", item("c", 3)]]);
115
+ same(await storage.delete("a"), true, "delete() of an item");
116
+ same(await storage.delete("a"), false, "a second delete() of the id");
117
+ same(await storage.has("a"), false, "has() after delete()");
118
+ same(await storage.get("a"), undefined, "get() after delete()");
119
+ same(await storage.deleteBatch(["b", "missing", "b"]), 1, "deleteBatch() with a missing id and a repeated id");
120
+ same(ids(await storage.getAll()), ["c"], "getAll() after the deletes");
121
+ }));
122
+ add("setBatch() and getBatch(): the last value of an id wins, a missing id is not in the map, and empty batches change nothing", () => withStorage(create, async (storage) => {
123
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)], ["a", item("a", 3)]]);
124
+ same(await storage.get("a"), item("a", 3), "get() of an id that setBatch() set two times");
125
+ same(await storage.size(), 2, "size() after setBatch() with a repeated id");
126
+ same(await storage.getBatch(["b", "missing", "a"]), new Map([["b", item("b", 2)], ["a", item("a", 3)]]), "getBatch() with a missing id");
127
+ await storage.setBatch([]);
128
+ same(await storage.deleteBatch([]), 0, "deleteBatch() of no id");
129
+ same(await storage.getBatch([]), new Map(), "getBatch() of no id");
130
+ same(await storage.size(), 2, "size() after the empty batches");
131
+ }));
132
+ add("the entries keep the order of the first set() of each id, as a Map does", () => withStorage(create, async (storage) => {
133
+ await storage.setBatch([["c", item("c", 3)], ["a", item("a", 1)], ["b", item("b", 2)]]);
134
+ await storage.set("a", item("a", 10));
135
+ same(ids(await storage.getAll()), ["c", "a", "b"], "getAll() after a second set() of an id: the id keeps its place");
136
+ // A delete, then a set: the id goes to the end
137
+ await storage.delete("c");
138
+ await storage.set("c", item("c", 30));
139
+ const expected = [["a", item("a", 10)], ["b", item("b", 2)], ["c", item("c", 30)]];
140
+ same(await storage.getAll(), expected.map(([, value]) => value), "getAll() after a delete and a new set() of an id");
141
+ same(ids(await storage.find(() => true)), ["a", "b", "c"], "find() keeps the order of the entries");
142
+ if (storage.getEntries)
143
+ same(await storage.getEntries(), expected, "getEntries() keeps the order of the entries");
144
+ }));
145
+ add("find() gives the matching items in order, and an error of the predicate rejects the promise", () => withStorage(create, async (storage) => {
146
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)], ["c", item("c", 3)], ["d", item("d", 4)]]);
147
+ same(ids(await storage.find((value) => value.n % 2 === 0)), ["b", "d"], "find() of the even items");
148
+ same(await storage.find(() => false), [], "find() without a match");
149
+ const error = await rejects(() => storage.find(() => {
150
+ throw new Error("the predicate failed");
151
+ }), "find() with a predicate that throws");
152
+ holds(error instanceof Error && error.message.includes("the predicate failed"), `find() must reject with the error of the predicate, not ${show(error instanceof Error ? error.message : error)}`);
153
+ }));
154
+ add("clear() deletes every item, and the storage takes new items after it", () => withStorage(create, async (storage) => {
155
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)], ["c", item("c", 3)]]);
156
+ await storage.clear();
157
+ same(await storage.size(), 0, "size() after clear()");
158
+ same(await storage.getAll(), [], "getAll() after clear()");
159
+ same(await storage.has("a"), false, "has() after clear()");
160
+ await storage.clear();
161
+ await storage.set("d", item("d", 4));
162
+ same(await storage.getAll(), [item("d", 4)], "getAll() after clear() and set()");
163
+ }));
164
+ add("each result is a new array or map: a change of a result does not change the storage", () => withStorage(create, async (storage) => {
165
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)]]);
166
+ const all = await storage.getAll();
167
+ all.pop();
168
+ all.push(item("z", 0));
169
+ const found = await storage.find(() => true);
170
+ found.length = 0;
171
+ const batch = await storage.getBatch(["a"]);
172
+ batch.delete("a");
173
+ batch.set("z", item("z", 0));
174
+ if (storage.getEntries)
175
+ (await storage.getEntries()).splice(0);
176
+ same(ids(await storage.getAll()), ["a", "b"], "getAll() after changes of the results");
177
+ same(await storage.has("z"), false, "has() of an id that only a result got");
178
+ same(await storage.getBatch(["a"]), new Map([["a", item("a", 1)]]), "getBatch() after a change of a result");
179
+ }));
180
+ if (options.copies) {
181
+ add("the storage keeps copies: a change of a written or a read value does not change the item", () => withStorage(create, async (storage) => {
182
+ const value = item("a", 1, ["x"]);
183
+ await storage.set("a", value);
184
+ value.n = 99;
185
+ value.tags.push("changed after set");
186
+ const read = (await storage.get("a"));
187
+ same(read, item("a", 1, ["x"]), "get() after a change of the value that set() took");
188
+ read.n = 98;
189
+ read.tags.push("changed after get");
190
+ (await storage.getAll())[0].n = 97;
191
+ (await storage.getBatch(["a"])).get("a").n = 96;
192
+ (await storage.find(() => true))[0].n = 95;
193
+ same(await storage.get("a"), item("a", 1, ["x"]), "get() after changes of the read values");
194
+ }));
195
+ }
196
+ add(`the storage keeps JSON values${nullValues ? ", also null" : ""}`, () => withStorage(create, async (typed) => {
197
+ const storage = typed;
198
+ const values = [
199
+ ["object", { text: "é ✓ 😀", list: [1, null, { deep: true }], n: 1.5, empty: {}, none: [] }],
200
+ ["text", "plain"],
201
+ ["empty", ""],
202
+ ["zero", 0],
203
+ ["negative", -2.25],
204
+ ["false", false],
205
+ ["list", [1, "two", [3]]],
206
+ ];
207
+ if (nullValues)
208
+ values.push(["null", null]);
209
+ await storage.setBatch(values);
210
+ for (const [id, value] of values)
211
+ same(await storage.get(id), value, `get("${id}")`);
212
+ same(await storage.getAll(), values.map(([, value]) => value), "getAll() of the JSON values");
213
+ same(await storage.getBatch(values.map(([id]) => id)), new Map(values), "getBatch() of the JSON values");
214
+ same(await storage.size(), values.length, "size() with the JSON values");
215
+ if (nullValues)
216
+ same(await storage.has("null"), true, "has() of an id whose value is null");
217
+ }));
218
+ add("writes that run at the same time keep each write", () => withStorage(create, async (storage) => {
219
+ const count = 20;
220
+ await Promise.all(Array.from({ length: count }, (_, n) => storage.set(`k${n}`, item(`k${n}`, n))));
221
+ same(await storage.size(), count, `size() after ${count} writes at the same time`);
222
+ same(ids(await storage.getAll()).sort(), Array.from({ length: count }, (_, n) => `k${n}`).sort(), "the ids after the writes at the same time");
223
+ }));
224
+ add("getChangesSince() without a version gives every item", (context) => withStorage(create, async (storage) => {
225
+ if (lacks(storage, "getChangesSince", context))
226
+ return;
227
+ const changes = changesOf(storage);
228
+ const entries = [["a", item("a", 1)], ["b", item("b", 2)], ["c", item("c", 3)]];
229
+ await storage.setBatch(entries);
230
+ const first = await changes();
231
+ holds(typeof first.version === "string" && first.version !== "", `the version must be a text that is not empty, not ${show(first.version)}`);
232
+ same(first.full, true, "full of the first call");
233
+ same(byId(first.changed), entries, "changed of the first call: every item");
234
+ same(first.deleted, [], "deleted of a full result");
235
+ }));
236
+ add("getChangesSince(version) gives the items that changed after the version and the ids that were deleted", (context) => withStorage(create, async (storage) => {
237
+ if (lacks(storage, "getChangesSince", context))
238
+ return;
239
+ const changes = changesOf(storage);
240
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)], ["c", item("c", 3)]]);
241
+ const start = await changes();
242
+ await storage.set("a", item("a", 10));
243
+ await storage.delete("b");
244
+ await storage.delete("missing");
245
+ await storage.set("d", item("d", 4));
246
+ const delta = await changes(start.version);
247
+ same(delta.full, false, "full of a delta");
248
+ same(byId(delta.changed), [["a", item("a", 10)], ["d", item("d", 4)]], "changed of a delta");
249
+ same(delta.deleted, ["b"], "deleted of a delta");
250
+ holds(delta.version !== start.version, "the version must change after a write");
251
+ }));
252
+ add("getChangesSince(): a deleted id that comes back is a change, clear() deletes each id, and no write gives no change", (context) => withStorage(create, async (storage) => {
253
+ if (lacks(storage, "getChangesSince", context))
254
+ return;
255
+ const changes = changesOf(storage);
256
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)], ["c", item("c", 3)]]);
257
+ const start = await changes();
258
+ await storage.delete("b");
259
+ await storage.set("b", item("b", 20));
260
+ const back = await changes(start.version);
261
+ same({ full: back.full, changed: byId(back.changed), deleted: back.deleted }, { full: false, changed: [["b", item("b", 20)]], deleted: [] }, "a delete, then a set of the id");
262
+ await storage.clear();
263
+ const cleared = await changes(back.version);
264
+ same({ full: cleared.full, changed: cleared.changed, deleted: [...cleared.deleted].sort() }, { full: false, changed: [], deleted: ["a", "b", "c"] }, "the changes of clear()");
265
+ const quiet = await changes(cleared.version);
266
+ same({ full: quiet.full, changed: quiet.changed, deleted: quiet.deleted }, { full: false, changed: [], deleted: [] }, "the changes without a write");
267
+ }));
268
+ add("getChangesSince() gives every item for an unknown version and for a version of another storage", (context) => withStorage(create, async (storage) => {
269
+ if (lacks(storage, "getChangesSince", context))
270
+ return;
271
+ const changes = changesOf(storage);
272
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)]]);
273
+ await changes();
274
+ for (const unknown of ["not a version", ""]) {
275
+ const result = await changes(unknown);
276
+ same({ full: result.full, changed: byId(result.changed), deleted: result.deleted }, { full: true, changed: [["a", item("a", 1)], ["b", item("b", 2)]], deleted: [] }, `the changes since ${show(unknown)}`);
277
+ }
278
+ await withStorage(create, async (other) => {
279
+ await other.set("x", item("x", 9));
280
+ const foreign = (await changesOf(other)()).version;
281
+ same((await changes(foreign)).full, true, "full for a version of another storage");
282
+ });
283
+ }));
284
+ if (options.createWithMaxTombstones) {
285
+ const withLimit = options.createWithMaxTombstones;
286
+ add("getChangesSince() gives every item for a version older than the deletes that the log dropped", (context) => withStorage(() => withLimit(2), async (storage) => {
287
+ if (lacks(storage, "getChangesSince", context))
288
+ return;
289
+ const changes = changesOf(storage);
290
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)], ["c", item("c", 3)], ["d", item("d", 4)]]);
291
+ const start = await changes();
292
+ // Two deletes fit in the log
293
+ await storage.deleteBatch(["a", "b"]);
294
+ const two = await changes(start.version);
295
+ same({ full: two.full, changed: two.changed, deleted: [...two.deleted].sort() }, { full: false, changed: [], deleted: ["a", "b"] }, "two deletes in a log of two");
296
+ // The third delete drops the oldest one: the start version gives all items now
297
+ await storage.delete("c");
298
+ const after = await changes(start.version);
299
+ same({ full: after.full, changed: byId(after.changed), deleted: after.deleted }, { full: true, changed: [["d", item("d", 4)]], deleted: [] }, "a version older than a dropped delete");
300
+ same((await changes(after.version)).full, false, "a version after the dropped deletes still gives a delta");
301
+ }));
302
+ }
303
+ add("a random sequence of writes agrees with a Map, and each version gives the right changes", () => withStorage(create, async (storage) => {
304
+ const random = seeded(45);
305
+ const pool = ["a", "b", "c", "d", "e", "f", "g"];
306
+ const pick = () => pool[random(pool.length)];
307
+ const model = new Map();
308
+ const versions = [];
309
+ const hasChanges = typeof storage.getChangesSince === "function";
310
+ for (let step = 0; step < 80; step++) {
311
+ const kind = random(20);
312
+ let label;
313
+ if (kind < 8) {
314
+ const id = pick();
315
+ const value = item(id, step);
316
+ label = `set(${id})`;
317
+ await storage.set(id, value);
318
+ model.set(id, value);
319
+ }
320
+ else if (kind < 12) {
321
+ const id = pick();
322
+ label = `delete(${id})`;
323
+ same(await storage.delete(id), model.delete(id), `the result of step ${step}: ${label}`);
324
+ }
325
+ else if (kind < 15) {
326
+ const batch = Array.from({ length: 1 + random(3) }, (_, index) => {
327
+ const id = pick();
328
+ return [id, item(id, step * 10 + index)];
329
+ });
330
+ label = `setBatch(${batch.map(([id]) => id).join(", ")})`;
331
+ await storage.setBatch(batch);
332
+ for (const [id, value] of batch)
333
+ model.set(id, value);
334
+ }
335
+ else if (kind < 18) {
336
+ const batch = Array.from({ length: 1 + random(3) }, pick);
337
+ label = `deleteBatch(${batch.join(", ")})`;
338
+ const expected = batch.filter((id) => model.delete(id)).length;
339
+ same(await storage.deleteBatch(batch), expected, `the result of step ${step}: ${label}`);
340
+ }
341
+ else if (kind < 19) {
342
+ label = "clear()";
343
+ await storage.clear();
344
+ model.clear();
345
+ }
346
+ else {
347
+ label = "a saved version";
348
+ if (hasChanges)
349
+ versions.push({ version: (await storage.getChangesSince()).version, entries: new Map(model) });
350
+ }
351
+ same(await storage.getAll(), [...model.values()], `getAll() after step ${step}: ${label}`);
352
+ }
353
+ same(await storage.size(), model.size, "size() after the sequence");
354
+ if (storage.getEntries)
355
+ same(await storage.getEntries(), [...model.entries()], "getEntries() after the sequence");
356
+ if (!hasChanges)
357
+ return;
358
+ holds(versions.length > 0, "the sequence saved no version: change the seed");
359
+ for (const [index, saved] of versions.entries()) {
360
+ const result = await storage.getChangesSince(saved.version);
361
+ const deleted = new Set(result.deleted);
362
+ holds(result.changed.every(([id]) => !deleted.has(id)), `the changes since version ${index} have an id in changed and in deleted`);
363
+ const rebuilt = result.full ? new Map() : new Map(saved.entries);
364
+ for (const id of result.deleted)
365
+ rebuilt.delete(id);
366
+ for (const [id, value] of result.changed)
367
+ rebuilt.set(id, value);
368
+ same(byId([...rebuilt.entries()]), byId([...model.entries()]), `the items of version ${index} with its changes`);
369
+ }
370
+ }));
371
+ add("flush() resolves, and the items stay", (context) => withStorage(create, async (storage) => {
372
+ if (lacks(storage, "flush", context))
373
+ return;
374
+ await storage.flush();
375
+ await storage.set("a", item("a", 1));
376
+ await storage.flush();
377
+ same(await storage.get("a"), item("a", 1), "get() after flush()");
378
+ }));
379
+ add("getMetadata() gives a known type and the size", (context) => withStorage(create, async (storage) => {
380
+ if (lacks(storage, "getMetadata", context))
381
+ return;
382
+ await storage.setBatch([["a", item("a", 1)], ["b", item("b", 2)]]);
383
+ const metadata = await storage.getMetadata();
384
+ holds(["memory", "api", "hybrid", "synced", "custom"].includes(metadata.type), `getMetadata() gave the unknown type ${show(metadata.type)}`);
385
+ same(metadata.size, 2, "the size of getMetadata()");
386
+ }));
387
+ add("close() resolves, and a second close() resolves too", () => withStorage(create, async (storage) => {
388
+ await storage.set("a", item("a", 1));
389
+ await storage.close();
390
+ await storage.close();
391
+ }));
392
+ return cases;
393
+ }
394
+ /**
395
+ * This function declares the suite in a test framework: one `describe` with one `it` for each
396
+ * case. Vitest gives `skip` to a case, so a case for a missing optional method shows as skipped.
397
+ */
398
+ export function describeCollectionStorageContract(name, options, api) {
399
+ api.describe(`${name} follows the CollectionStorage contract`, () => {
400
+ for (const contractCase of collectionStorageContract(options)) {
401
+ api.it(contractCase.name, (context) => contractCase.run(context));
402
+ }
403
+ });
404
+ }
405
+ //# sourceMappingURL=storage-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-contract.js","sourceRoot":"","sources":["../../src/testing/storage-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAmD9D,MAAM,IAAI,GAAG,CAAC,EAAU,EAAE,CAAS,EAAE,IAAe,EAAgB,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1H,MAAM,GAAG,GAAG,CAAC,KAAqB,EAAY,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAEhF,+CAA+C;AAC/C,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAQ,KAAmC,EAAE,IAAI,KAAK,UAAU,CAAC;AAC1E,CAAC;AAED,4EAA4E;AAC5E,KAAK,UAAU,WAAW,CAAC,MAAwD,EAAE,IAAiD;IACpI,MAAM,OAAO,GAAG,MAAM,MAAM,EAAE,CAA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AW,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACpC,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACrC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,IAAY,EAAE,OAAyC,EAAE,GAAoB;IAC7H,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,yCAAyC,EAAE,GAAG,EAAE;QAClE,KAAK,MAAM,YAAY,IAAI,yBAAyB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9D,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACpE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@procedures/collections",
4
- "version": "0.2.3",
4
+ "version": "0.4.0",
5
5
  "description": "Collections for TypeScript: ArrayList, LinkedList, ArrayDeque, HashMap, LinkedHashMap, TreeMap (red-black), PriorityQueue, LRU and TTL maps, async queues, channels and collectors, tested with fast-check.",
6
6
  "keywords": [
7
7
  "collections",
@@ -36,6 +36,10 @@
36
36
  ".": {
37
37
  "types": "./dist/index.d.ts",
38
38
  "import": "./dist/index.js"
39
+ },
40
+ "./testing": {
41
+ "types": "./dist/testing/index.d.ts",
42
+ "import": "./dist/testing/index.js"
39
43
  }
40
44
  },
41
45
  "files": [
@@ -10,7 +10,8 @@
10
10
  * does not depend on the client package.
11
11
  */
12
12
 
13
- export type { CollectionStorage, StorageMetadata } from "./interface.js";
13
+ export type { CollectionStorage, StorageChanges, StorageMetadata } from "./interface.js";
14
14
  export { normalizeStorageResult } from "./interface.js";
15
15
 
16
16
  export { InMemoryStorage } from "./memory.js";
17
+ export type { InMemoryStorageOptions } from "./memory.js";
@@ -38,6 +38,23 @@ export interface CollectionStorage<T> {
38
38
  */
39
39
  getAll(): Promise<T[]>;
40
40
 
41
+ /**
42
+ * Every item with its id. A sync needs the ids: `getAll` gives only the values (roadmap R2).
43
+ * A storage that cannot give the ids does not have this method.
44
+ *
45
+ * @returns Promise resolving to the [id, item] pairs
46
+ */
47
+ getEntries?(): Promise<Array<[string, T]>>;
48
+
49
+ /**
50
+ * The changes after a version (roadmap R28). A storage without a change log does not have
51
+ * this method, and a sync uses `getEntries()`.
52
+ *
53
+ * @param since - A `version` that an earlier call gave. Without it, the result has all items.
54
+ * @returns Promise resolving to the changed items, the deleted ids and the new version
55
+ */
56
+ getChangesSince?(since?: string): Promise<StorageChanges<T>>;
57
+
41
58
  /**
42
59
  * Find items matching predicate.
43
60
  *
@@ -121,6 +138,14 @@ export interface CollectionStorage<T> {
121
138
  // ═══ Lifecycle & Metadata ═══
122
139
  //
123
140
 
141
+ /**
142
+ * This method sends the writes that wait in the storage to their destination (roadmap R28). A storage
143
+ * that keeps no writes does not have this method.
144
+ *
145
+ * @returns Promise resolving when the waiting writes reached their destination
146
+ */
147
+ flush?(): Promise<void>;
148
+
124
149
  /**
125
150
  * Close storage and cleanup resources.
126
151
  * Should be called when collection is no longer needed.
@@ -138,6 +163,27 @@ export interface CollectionStorage<T> {
138
163
  getMetadata?(): Promise<StorageMetadata>;
139
164
  }
140
165
 
166
+ /**
167
+ * The changes of a storage after a version (roadmap R28).
168
+ *
169
+ * - `version` is opaque. The next call gives it back as `since`.
170
+ * - When `full` is true, `changed` has every item, and each id that it does not have was
171
+ * deleted. A storage gives a full result when it cannot find the changes since the version:
172
+ * the first call, a version of an older run, or a change log that dropped old deletes.
173
+ * - When `full` is false, `changed` has the items that changed after the version, and `deleted`
174
+ * has the ids that were deleted after it.
175
+ */
176
+ export interface StorageChanges<T> {
177
+ /** The version of the storage that includes these changes. */
178
+ version: string;
179
+ /** True when `changed` has every item of the storage. */
180
+ full: boolean;
181
+ /** The items that changed, with their ids. */
182
+ changed: Array<[string, T]>;
183
+ /** The ids that were deleted. Empty when `full` is true. */
184
+ deleted: string[];
185
+ }
186
+
141
187
  /**
142
188
  * Optional storage metadata for monitoring.
143
189
  */