@voidhash/mimic-effect 1.0.0-beta.1 → 1.0.0-beta.10

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 (142) hide show
  1. package/.turbo/turbo-build.log +116 -74
  2. package/dist/ColdStorage.cjs +9 -5
  3. package/dist/ColdStorage.d.cts.map +1 -1
  4. package/dist/ColdStorage.d.mts.map +1 -1
  5. package/dist/ColdStorage.mjs +9 -5
  6. package/dist/ColdStorage.mjs.map +1 -1
  7. package/dist/DocumentInstance.cjs +263 -0
  8. package/dist/DocumentInstance.d.cts +78 -0
  9. package/dist/DocumentInstance.d.cts.map +1 -0
  10. package/dist/DocumentInstance.d.mts +78 -0
  11. package/dist/DocumentInstance.d.mts.map +1 -0
  12. package/dist/DocumentInstance.mjs +264 -0
  13. package/dist/DocumentInstance.mjs.map +1 -0
  14. package/dist/Errors.cjs +10 -1
  15. package/dist/Errors.d.cts +18 -3
  16. package/dist/Errors.d.cts.map +1 -1
  17. package/dist/Errors.d.mts +18 -3
  18. package/dist/Errors.d.mts.map +1 -1
  19. package/dist/Errors.mjs +9 -1
  20. package/dist/Errors.mjs.map +1 -1
  21. package/dist/HotStorage.cjs +39 -12
  22. package/dist/HotStorage.d.cts +17 -1
  23. package/dist/HotStorage.d.cts.map +1 -1
  24. package/dist/HotStorage.d.mts +17 -1
  25. package/dist/HotStorage.d.mts.map +1 -1
  26. package/dist/HotStorage.mjs +39 -12
  27. package/dist/HotStorage.mjs.map +1 -1
  28. package/dist/Metrics.cjs +29 -1
  29. package/dist/Metrics.d.cts +5 -0
  30. package/dist/Metrics.d.cts.map +1 -1
  31. package/dist/Metrics.d.mts +5 -0
  32. package/dist/Metrics.d.mts.map +1 -1
  33. package/dist/Metrics.mjs +26 -1
  34. package/dist/Metrics.mjs.map +1 -1
  35. package/dist/MimicClusterServerEngine.cjs +44 -139
  36. package/dist/MimicClusterServerEngine.d.cts.map +1 -1
  37. package/dist/MimicClusterServerEngine.d.mts +1 -1
  38. package/dist/MimicClusterServerEngine.d.mts.map +1 -1
  39. package/dist/MimicClusterServerEngine.mjs +46 -141
  40. package/dist/MimicClusterServerEngine.mjs.map +1 -1
  41. package/dist/MimicServer.cjs +20 -20
  42. package/dist/MimicServer.d.cts.map +1 -1
  43. package/dist/MimicServer.d.mts.map +1 -1
  44. package/dist/MimicServer.mjs +20 -20
  45. package/dist/MimicServer.mjs.map +1 -1
  46. package/dist/MimicServerEngine.cjs +92 -11
  47. package/dist/MimicServerEngine.d.cts +12 -4
  48. package/dist/MimicServerEngine.d.cts.map +1 -1
  49. package/dist/MimicServerEngine.d.mts +12 -4
  50. package/dist/MimicServerEngine.d.mts.map +1 -1
  51. package/dist/MimicServerEngine.mjs +94 -13
  52. package/dist/MimicServerEngine.mjs.map +1 -1
  53. package/dist/PresenceManager.cjs +5 -5
  54. package/dist/PresenceManager.d.cts.map +1 -1
  55. package/dist/PresenceManager.d.mts.map +1 -1
  56. package/dist/PresenceManager.mjs +5 -5
  57. package/dist/PresenceManager.mjs.map +1 -1
  58. package/dist/Protocol.d.cts +1 -1
  59. package/dist/Protocol.d.mts +1 -1
  60. package/dist/Types.d.cts +9 -2
  61. package/dist/Types.d.cts.map +1 -1
  62. package/dist/Types.d.mts +9 -2
  63. package/dist/Types.d.mts.map +1 -1
  64. package/dist/index.cjs +5 -6
  65. package/dist/index.d.cts +3 -3
  66. package/dist/index.d.mts +3 -3
  67. package/dist/index.mjs +3 -3
  68. package/dist/testing/ColdStorageTestSuite.cjs +508 -0
  69. package/dist/testing/ColdStorageTestSuite.d.cts +36 -0
  70. package/dist/testing/ColdStorageTestSuite.d.cts.map +1 -0
  71. package/dist/testing/ColdStorageTestSuite.d.mts +36 -0
  72. package/dist/testing/ColdStorageTestSuite.d.mts.map +1 -0
  73. package/dist/testing/ColdStorageTestSuite.mjs +508 -0
  74. package/dist/testing/ColdStorageTestSuite.mjs.map +1 -0
  75. package/dist/testing/FailingStorage.cjs +162 -0
  76. package/dist/testing/FailingStorage.d.cts +43 -0
  77. package/dist/testing/FailingStorage.d.cts.map +1 -0
  78. package/dist/testing/FailingStorage.d.mts +43 -0
  79. package/dist/testing/FailingStorage.d.mts.map +1 -0
  80. package/dist/testing/FailingStorage.mjs +163 -0
  81. package/dist/testing/FailingStorage.mjs.map +1 -0
  82. package/dist/testing/HotStorageTestSuite.cjs +820 -0
  83. package/dist/testing/HotStorageTestSuite.d.cts +42 -0
  84. package/dist/testing/HotStorageTestSuite.d.cts.map +1 -0
  85. package/dist/testing/HotStorageTestSuite.d.mts +42 -0
  86. package/dist/testing/HotStorageTestSuite.d.mts.map +1 -0
  87. package/dist/testing/HotStorageTestSuite.mjs +820 -0
  88. package/dist/testing/HotStorageTestSuite.mjs.map +1 -0
  89. package/dist/testing/StorageIntegrationTestSuite.cjs +487 -0
  90. package/dist/testing/StorageIntegrationTestSuite.d.cts +37 -0
  91. package/dist/testing/StorageIntegrationTestSuite.d.cts.map +1 -0
  92. package/dist/testing/StorageIntegrationTestSuite.d.mts +37 -0
  93. package/dist/testing/StorageIntegrationTestSuite.d.mts.map +1 -0
  94. package/dist/testing/StorageIntegrationTestSuite.mjs +487 -0
  95. package/dist/testing/StorageIntegrationTestSuite.mjs.map +1 -0
  96. package/dist/testing/assertions.cjs +117 -0
  97. package/dist/testing/assertions.mjs +112 -0
  98. package/dist/testing/assertions.mjs.map +1 -0
  99. package/dist/testing/index.cjs +14 -0
  100. package/dist/testing/index.d.cts +6 -0
  101. package/dist/testing/index.d.mts +6 -0
  102. package/dist/testing/index.mjs +7 -0
  103. package/dist/testing/types.cjs +15 -0
  104. package/dist/testing/types.d.cts +90 -0
  105. package/dist/testing/types.d.cts.map +1 -0
  106. package/dist/testing/types.d.mts +90 -0
  107. package/dist/testing/types.d.mts.map +1 -0
  108. package/dist/testing/types.mjs +16 -0
  109. package/dist/testing/types.mjs.map +1 -0
  110. package/package.json +8 -3
  111. package/src/ColdStorage.ts +21 -12
  112. package/src/DocumentInstance.ts +527 -0
  113. package/src/Errors.ts +15 -1
  114. package/src/HotStorage.ts +115 -24
  115. package/src/Metrics.ts +30 -0
  116. package/src/MimicClusterServerEngine.ts +120 -275
  117. package/src/MimicServer.ts +83 -75
  118. package/src/MimicServerEngine.ts +230 -30
  119. package/src/PresenceManager.ts +44 -34
  120. package/src/Types.ts +9 -2
  121. package/src/index.ts +5 -35
  122. package/src/testing/ColdStorageTestSuite.ts +589 -0
  123. package/src/testing/FailingStorage.ts +338 -0
  124. package/src/testing/HotStorageTestSuite.ts +1105 -0
  125. package/src/testing/StorageIntegrationTestSuite.ts +736 -0
  126. package/src/testing/assertions.ts +188 -0
  127. package/src/testing/index.ts +83 -0
  128. package/src/testing/types.ts +100 -0
  129. package/tests/ColdStorage.test.ts +8 -120
  130. package/tests/DocumentInstance.test.ts +669 -0
  131. package/tests/HotStorage.test.ts +7 -126
  132. package/tests/StorageIntegration.test.ts +259 -0
  133. package/tsdown.config.ts +1 -1
  134. package/dist/DocumentManager.cjs +0 -229
  135. package/dist/DocumentManager.d.cts +0 -59
  136. package/dist/DocumentManager.d.cts.map +0 -1
  137. package/dist/DocumentManager.d.mts +0 -59
  138. package/dist/DocumentManager.d.mts.map +0 -1
  139. package/dist/DocumentManager.mjs +0 -227
  140. package/dist/DocumentManager.mjs.map +0 -1
  141. package/src/DocumentManager.ts +0 -506
  142. package/tests/DocumentManager.test.ts +0 -335
@@ -0,0 +1,820 @@
1
+ import { HotStorageTag } from "../HotStorage.mjs";
2
+ import { assertEmpty, assertEqual, assertLength, assertSortedBy, assertTrue } from "./assertions.mjs";
3
+ import { Effect, Schema } from "effect";
4
+ import { Operation, OperationDefinition, OperationPath, Transaction } from "@voidhash/mimic";
5
+
6
+ //#region src/testing/HotStorageTestSuite.ts
7
+ /**
8
+ * @voidhash/mimic-effect/testing - HotStorage Test Suite
9
+ *
10
+ * Comprehensive test suite for HotStorage (WAL) adapter implementations.
11
+ * These tests verify that an adapter correctly implements the HotStorage interface
12
+ * and can reliably store/retrieve WAL entries for document recovery.
13
+ */
14
+ /**
15
+ * Test operation definition for creating proper Operation objects in tests.
16
+ * Using Schema.Unknown allows any payload type for flexibility in testing.
17
+ */
18
+ const TestSetDefinition = OperationDefinition.make({
19
+ kind: "test.set",
20
+ payload: Schema.Unknown,
21
+ target: Schema.Unknown,
22
+ apply: (payload) => payload
23
+ });
24
+ /**
25
+ * Custom operation definition for testing operation kind preservation.
26
+ */
27
+ const CustomOpDefinition = OperationDefinition.make({
28
+ kind: "custom.operation",
29
+ payload: Schema.Unknown,
30
+ target: Schema.Unknown,
31
+ apply: (payload) => payload
32
+ });
33
+ const Categories = {
34
+ BasicOperations: "Basic Operations",
35
+ VersionFiltering: "Version Filtering",
36
+ OrderingGuarantees: "Ordering Guarantees",
37
+ TruncationEdgeCases: "Truncation Edge Cases",
38
+ WalEntryIntegrity: "WAL Entry Integrity",
39
+ DocumentIsolation: "Document Isolation",
40
+ LargeScaleOperations: "Large-Scale Operations",
41
+ DocumentIdEdgeCases: "Document ID Edge Cases",
42
+ GapChecking: "Gap Checking",
43
+ TransactionEncoding: "Transaction Encoding"
44
+ };
45
+ const makeEntry = (version, timestamp) => ({
46
+ transaction: Transaction.make([]),
47
+ version,
48
+ timestamp: timestamp !== null && timestamp !== void 0 ? timestamp : Date.now()
49
+ });
50
+ const makeEntryWithData = (version, data, timestamp) => ({
51
+ transaction: Transaction.make([Operation.fromDefinition(OperationPath.make("data"), TestSetDefinition, data)]),
52
+ version,
53
+ timestamp: timestamp !== null && timestamp !== void 0 ? timestamp : Date.now()
54
+ });
55
+ const makeEntryWithPath = (version, pathString, payload, timestamp) => ({
56
+ transaction: Transaction.make([Operation.fromDefinition(OperationPath.make(pathString), TestSetDefinition, payload)]),
57
+ version,
58
+ timestamp: timestamp !== null && timestamp !== void 0 ? timestamp : Date.now()
59
+ });
60
+ const tests = [
61
+ {
62
+ name: "getEntries returns empty array for non-existent document",
63
+ category: Categories.BasicOperations,
64
+ run: Effect.gen(function* () {
65
+ yield* assertEmpty(yield* (yield* HotStorageTag).getEntries("non-existent-hot-doc", 0), "Should return empty array for non-existent document");
66
+ })
67
+ },
68
+ {
69
+ name: "append then getEntries returns the entry",
70
+ category: Categories.BasicOperations,
71
+ run: Effect.gen(function* () {
72
+ const storage = yield* HotStorageTag;
73
+ const entry = makeEntry(1);
74
+ yield* storage.append("basic-append", entry);
75
+ const entries = yield* storage.getEntries("basic-append", 0);
76
+ yield* assertLength(entries, 1, "Should have one entry");
77
+ yield* assertEqual(entries[0].version, 1, "Entry version should match");
78
+ })
79
+ },
80
+ {
81
+ name: "multiple append calls accumulate entries",
82
+ category: Categories.BasicOperations,
83
+ run: Effect.gen(function* () {
84
+ const storage = yield* HotStorageTag;
85
+ yield* storage.append("multi-append", makeEntry(1));
86
+ yield* storage.append("multi-append", makeEntry(2));
87
+ yield* storage.append("multi-append", makeEntry(3));
88
+ yield* assertLength(yield* storage.getEntries("multi-append", 0), 3, "Should have three entries");
89
+ })
90
+ },
91
+ {
92
+ name: "truncate removes entries with version <= upToVersion",
93
+ category: Categories.BasicOperations,
94
+ run: Effect.gen(function* () {
95
+ const storage = yield* HotStorageTag;
96
+ yield* storage.append("truncate-basic", makeEntry(1));
97
+ yield* storage.append("truncate-basic", makeEntry(2));
98
+ yield* storage.append("truncate-basic", makeEntry(3));
99
+ yield* storage.truncate("truncate-basic", 2);
100
+ const entries = yield* storage.getEntries("truncate-basic", 0);
101
+ yield* assertLength(entries, 1, "Should have one entry after truncate");
102
+ yield* assertEqual(entries[0].version, 3, "Only version 3 should remain");
103
+ })
104
+ },
105
+ {
106
+ name: "truncate on non-existent document does not error",
107
+ category: Categories.BasicOperations,
108
+ run: Effect.gen(function* () {
109
+ yield* (yield* HotStorageTag).truncate("non-existent-truncate", 100);
110
+ })
111
+ },
112
+ {
113
+ name: "getEntries(doc, 0) returns all entries",
114
+ category: Categories.VersionFiltering,
115
+ run: Effect.gen(function* () {
116
+ const storage = yield* HotStorageTag;
117
+ yield* storage.append("filter-all", makeEntry(1));
118
+ yield* storage.append("filter-all", makeEntry(2));
119
+ yield* storage.append("filter-all", makeEntry(3));
120
+ yield* assertLength(yield* storage.getEntries("filter-all", 0), 3, "sinceVersion=0 should return all entries");
121
+ })
122
+ },
123
+ {
124
+ name: "getEntries(doc, n) returns only entries with version > n",
125
+ category: Categories.VersionFiltering,
126
+ run: Effect.gen(function* () {
127
+ const storage = yield* HotStorageTag;
128
+ yield* storage.append("filter-n", makeEntry(1));
129
+ yield* storage.append("filter-n", makeEntry(2));
130
+ yield* storage.append("filter-n", makeEntry(3));
131
+ yield* storage.append("filter-n", makeEntry(4));
132
+ const entries = yield* storage.getEntries("filter-n", 2);
133
+ yield* assertLength(entries, 2, "Should return entries with version > 2");
134
+ yield* assertEqual(entries[0].version, 3, "First entry should be version 3");
135
+ yield* assertEqual(entries[1].version, 4, "Second entry should be version 4");
136
+ })
137
+ },
138
+ {
139
+ name: "getEntries(doc, exactVersion) excludes that exact version",
140
+ category: Categories.VersionFiltering,
141
+ run: Effect.gen(function* () {
142
+ const storage = yield* HotStorageTag;
143
+ yield* storage.append("filter-exact", makeEntry(5));
144
+ yield* storage.append("filter-exact", makeEntry(6));
145
+ yield* storage.append("filter-exact", makeEntry(7));
146
+ const entries = yield* storage.getEntries("filter-exact", 6);
147
+ yield* assertLength(entries, 1, "Should exclude version 6");
148
+ yield* assertEqual(entries[0].version, 7, "Only version 7 should be returned");
149
+ })
150
+ },
151
+ {
152
+ name: "getEntries(doc, maxVersion) returns empty array",
153
+ category: Categories.VersionFiltering,
154
+ run: Effect.gen(function* () {
155
+ const storage = yield* HotStorageTag;
156
+ yield* storage.append("filter-max", makeEntry(1));
157
+ yield* storage.append("filter-max", makeEntry(2));
158
+ yield* storage.append("filter-max", makeEntry(3));
159
+ yield* assertEmpty(yield* storage.getEntries("filter-max", 3), "sinceVersion >= maxVersion should return empty");
160
+ })
161
+ },
162
+ {
163
+ name: "getEntries(doc, MAX_SAFE_INTEGER) returns empty array",
164
+ category: Categories.VersionFiltering,
165
+ run: Effect.gen(function* () {
166
+ const storage = yield* HotStorageTag;
167
+ yield* storage.append("filter-huge", makeEntry(1));
168
+ yield* storage.append("filter-huge", makeEntry(1e6));
169
+ yield* assertEmpty(yield* storage.getEntries("filter-huge", Number.MAX_SAFE_INTEGER), "sinceVersion=MAX_SAFE_INTEGER should return empty");
170
+ })
171
+ },
172
+ {
173
+ name: "entries returned sorted by version ascending",
174
+ category: Categories.OrderingGuarantees,
175
+ run: Effect.gen(function* () {
176
+ const storage = yield* HotStorageTag;
177
+ yield* storage.append("order-test", makeEntry(1));
178
+ yield* storage.append("order-test", makeEntry(2));
179
+ yield* storage.append("order-test", makeEntry(3));
180
+ yield* assertSortedBy(yield* storage.getEntries("order-test", 0), "version", "Entries should be sorted by version");
181
+ })
182
+ },
183
+ {
184
+ name: "out-of-order appends are sorted correctly on retrieval",
185
+ category: Categories.OrderingGuarantees,
186
+ run: Effect.gen(function* () {
187
+ const storage = yield* HotStorageTag;
188
+ yield* storage.append("ooo-test", makeEntry(3));
189
+ yield* storage.append("ooo-test", makeEntry(1));
190
+ yield* storage.append("ooo-test", makeEntry(4));
191
+ yield* storage.append("ooo-test", makeEntry(2));
192
+ const entries = yield* storage.getEntries("ooo-test", 0);
193
+ yield* assertLength(entries, 4, "Should have all 4 entries");
194
+ yield* assertEqual(entries[0].version, 1, "First should be version 1");
195
+ yield* assertEqual(entries[1].version, 2, "Second should be version 2");
196
+ yield* assertEqual(entries[2].version, 3, "Third should be version 3");
197
+ yield* assertEqual(entries[3].version, 4, "Fourth should be version 4");
198
+ })
199
+ },
200
+ {
201
+ name: "truncate(doc, 0) removes nothing (versions > 0 kept)",
202
+ category: Categories.TruncationEdgeCases,
203
+ run: Effect.gen(function* () {
204
+ const storage = yield* HotStorageTag;
205
+ yield* storage.append("trunc-0", makeEntry(1));
206
+ yield* storage.append("trunc-0", makeEntry(2));
207
+ yield* storage.truncate("trunc-0", 0);
208
+ yield* assertLength(yield* storage.getEntries("trunc-0", 0), 2, "truncate(0) should keep all entries with version > 0");
209
+ })
210
+ },
211
+ {
212
+ name: "truncate(doc, maxVersion) removes all entries",
213
+ category: Categories.TruncationEdgeCases,
214
+ run: Effect.gen(function* () {
215
+ const storage = yield* HotStorageTag;
216
+ yield* storage.append("trunc-all", makeEntry(1));
217
+ yield* storage.append("trunc-all", makeEntry(2));
218
+ yield* storage.append("trunc-all", makeEntry(3));
219
+ yield* storage.truncate("trunc-all", 3);
220
+ yield* assertEmpty(yield* storage.getEntries("trunc-all", 0), "truncate(maxVersion) should remove all entries");
221
+ })
222
+ },
223
+ {
224
+ name: "truncate(doc, middleVersion) removes correct entries",
225
+ category: Categories.TruncationEdgeCases,
226
+ run: Effect.gen(function* () {
227
+ const storage = yield* HotStorageTag;
228
+ yield* storage.append("trunc-mid", makeEntry(1));
229
+ yield* storage.append("trunc-mid", makeEntry(2));
230
+ yield* storage.append("trunc-mid", makeEntry(3));
231
+ yield* storage.append("trunc-mid", makeEntry(4));
232
+ yield* storage.append("trunc-mid", makeEntry(5));
233
+ yield* storage.truncate("trunc-mid", 3);
234
+ const entries = yield* storage.getEntries("trunc-mid", 0);
235
+ yield* assertLength(entries, 2, "Should keep versions 4 and 5");
236
+ yield* assertEqual(entries[0].version, 4, "First remaining should be 4");
237
+ yield* assertEqual(entries[1].version, 5, "Second remaining should be 5");
238
+ })
239
+ },
240
+ {
241
+ name: "multiple truncates work correctly",
242
+ category: Categories.TruncationEdgeCases,
243
+ run: Effect.gen(function* () {
244
+ const storage = yield* HotStorageTag;
245
+ yield* storage.append("multi-trunc", makeEntry(1));
246
+ yield* storage.append("multi-trunc", makeEntry(2));
247
+ yield* storage.append("multi-trunc", makeEntry(3));
248
+ yield* storage.append("multi-trunc", makeEntry(4));
249
+ yield* storage.append("multi-trunc", makeEntry(5));
250
+ yield* storage.truncate("multi-trunc", 2);
251
+ yield* storage.truncate("multi-trunc", 4);
252
+ const entries = yield* storage.getEntries("multi-trunc", 0);
253
+ yield* assertLength(entries, 1, "Should only have version 5");
254
+ yield* assertEqual(entries[0].version, 5, "Only version 5 should remain");
255
+ })
256
+ },
257
+ {
258
+ name: "truncate followed by append works correctly",
259
+ category: Categories.TruncationEdgeCases,
260
+ run: Effect.gen(function* () {
261
+ const storage = yield* HotStorageTag;
262
+ yield* storage.append("trunc-append", makeEntry(1));
263
+ yield* storage.append("trunc-append", makeEntry(2));
264
+ yield* storage.truncate("trunc-append", 2);
265
+ yield* storage.append("trunc-append", makeEntry(3));
266
+ yield* storage.append("trunc-append", makeEntry(4));
267
+ const entries = yield* storage.getEntries("trunc-append", 0);
268
+ yield* assertLength(entries, 2, "Should have versions 3 and 4");
269
+ yield* assertEqual(entries[0].version, 3, "First should be 3");
270
+ yield* assertEqual(entries[1].version, 4, "Second should be 4");
271
+ })
272
+ },
273
+ {
274
+ name: "transaction data is preserved exactly",
275
+ category: Categories.WalEntryIntegrity,
276
+ run: Effect.gen(function* () {
277
+ const storage = yield* HotStorageTag;
278
+ const entry = makeEntryWithData(1, {
279
+ key: "value",
280
+ nested: { a: 1 }
281
+ });
282
+ yield* storage.append("tx-data", entry);
283
+ const entries = yield* storage.getEntries("tx-data", 0);
284
+ yield* assertLength(entries, 1, "Should have one entry");
285
+ yield* assertEqual(entries[0].transaction, entry.transaction, "Transaction should be preserved exactly");
286
+ })
287
+ },
288
+ {
289
+ name: "version number is preserved exactly",
290
+ category: Categories.WalEntryIntegrity,
291
+ run: Effect.gen(function* () {
292
+ const storage = yield* HotStorageTag;
293
+ const version = 42;
294
+ const entry = makeEntry(version);
295
+ yield* storage.append("version-preserve", entry);
296
+ yield* assertEqual((yield* storage.getEntries("version-preserve", 0))[0].version, version, "Version should be preserved exactly");
297
+ })
298
+ },
299
+ {
300
+ name: "timestamp is preserved exactly",
301
+ category: Categories.WalEntryIntegrity,
302
+ run: Effect.gen(function* () {
303
+ const storage = yield* HotStorageTag;
304
+ const timestamp = 17040672e5;
305
+ const entry = makeEntry(1, timestamp);
306
+ yield* storage.append("timestamp-preserve", entry);
307
+ yield* assertEqual((yield* storage.getEntries("timestamp-preserve", 0))[0].timestamp, timestamp, "Timestamp should be preserved exactly");
308
+ })
309
+ },
310
+ {
311
+ name: "complex transaction operations survive roundtrip",
312
+ category: Categories.WalEntryIntegrity,
313
+ run: Effect.gen(function* () {
314
+ const storage = yield* HotStorageTag;
315
+ const entry = {
316
+ transaction: Transaction.make([
317
+ Operation.fromDefinition(OperationPath.make("a"), TestSetDefinition, 1),
318
+ Operation.fromDefinition(OperationPath.make("b/c"), TestSetDefinition, "nested"),
319
+ Operation.fromDefinition(OperationPath.make("arr"), TestSetDefinition, [
320
+ 1,
321
+ 2,
322
+ 3
323
+ ])
324
+ ]),
325
+ version: 1,
326
+ timestamp: Date.now()
327
+ };
328
+ yield* storage.append("complex-tx", entry);
329
+ yield* assertEqual((yield* storage.getEntries("complex-tx", 0))[0].transaction, entry.transaction, "Complex transaction should survive roundtrip");
330
+ })
331
+ },
332
+ {
333
+ name: "different documents have independent entry lists",
334
+ category: Categories.DocumentIsolation,
335
+ run: Effect.gen(function* () {
336
+ const storage = yield* HotStorageTag;
337
+ yield* storage.append("iso-hot-1", makeEntry(1));
338
+ yield* storage.append("iso-hot-1", makeEntry(2));
339
+ yield* storage.append("iso-hot-2", makeEntry(10));
340
+ const entries1 = yield* storage.getEntries("iso-hot-1", 0);
341
+ const entries2 = yield* storage.getEntries("iso-hot-2", 0);
342
+ yield* assertLength(entries1, 2, "Doc 1 should have 2 entries");
343
+ yield* assertLength(entries2, 1, "Doc 2 should have 1 entry");
344
+ yield* assertEqual(entries1[0].version, 1, "Doc 1 first entry version");
345
+ yield* assertEqual(entries2[0].version, 10, "Doc 2 first entry version");
346
+ })
347
+ },
348
+ {
349
+ name: "appending to one doc does not affect others",
350
+ category: Categories.DocumentIsolation,
351
+ run: Effect.gen(function* () {
352
+ const storage = yield* HotStorageTag;
353
+ yield* storage.append("append-iso-1", makeEntry(1));
354
+ const beforeAppend = yield* storage.getEntries("append-iso-1", 0);
355
+ yield* storage.append("append-iso-2", makeEntry(100));
356
+ yield* storage.append("append-iso-2", makeEntry(101));
357
+ const afterAppend = yield* storage.getEntries("append-iso-1", 0);
358
+ yield* assertEqual(beforeAppend.length, afterAppend.length, "Appending to doc 2 should not affect doc 1");
359
+ })
360
+ },
361
+ {
362
+ name: "truncating one doc does not affect others",
363
+ category: Categories.DocumentIsolation,
364
+ run: Effect.gen(function* () {
365
+ const storage = yield* HotStorageTag;
366
+ yield* storage.append("trunc-iso-1", makeEntry(1));
367
+ yield* storage.append("trunc-iso-1", makeEntry(2));
368
+ yield* storage.append("trunc-iso-2", makeEntry(1));
369
+ yield* storage.append("trunc-iso-2", makeEntry(2));
370
+ yield* storage.truncate("trunc-iso-1", 2);
371
+ const entries1 = yield* storage.getEntries("trunc-iso-1", 0);
372
+ const entries2 = yield* storage.getEntries("trunc-iso-2", 0);
373
+ yield* assertEmpty(entries1, "Doc 1 should be empty after truncate");
374
+ yield* assertLength(entries2, 2, "Doc 2 should still have 2 entries");
375
+ })
376
+ },
377
+ {
378
+ name: "handle 1000+ entries per document",
379
+ category: Categories.LargeScaleOperations,
380
+ run: Effect.gen(function* () {
381
+ const storage = yield* HotStorageTag;
382
+ const count = 1e3;
383
+ for (let i = 1; i <= count; i++) yield* storage.append("large-entries", makeEntry(i));
384
+ const entries = yield* storage.getEntries("large-entries", 0);
385
+ yield* assertLength(entries, count, `Should have ${count} entries`);
386
+ yield* assertSortedBy(entries, "version", "Should be sorted by version");
387
+ yield* assertEqual(entries[0].version, 1, "First should be version 1");
388
+ yield* assertEqual(entries[count - 1].version, count, `Last should be version ${count}`);
389
+ })
390
+ },
391
+ {
392
+ name: "handle 100+ documents",
393
+ category: Categories.LargeScaleOperations,
394
+ run: Effect.gen(function* () {
395
+ const storage = yield* HotStorageTag;
396
+ const docCount = 100;
397
+ for (let i = 0; i < docCount; i++) {
398
+ yield* storage.append(`multi-doc-${i}`, makeEntry(1));
399
+ yield* storage.append(`multi-doc-${i}`, makeEntry(2));
400
+ }
401
+ let totalEntries = 0;
402
+ for (let i = 0; i < docCount; i++) {
403
+ const entries = yield* storage.getEntries(`multi-doc-${i}`, 0);
404
+ totalEntries += entries.length;
405
+ yield* assertLength(entries, 2, `Doc ${i} should have 2 entries`);
406
+ }
407
+ yield* assertEqual(totalEntries, docCount * 2, "Total entries should match");
408
+ })
409
+ },
410
+ {
411
+ name: "large transaction data (10KB+) survives roundtrip",
412
+ category: Categories.LargeScaleOperations,
413
+ run: Effect.gen(function* () {
414
+ const storage = yield* HotStorageTag;
415
+ const entry = makeEntryWithData(1, { content: "x".repeat(10 * 1024) });
416
+ yield* storage.append("large-tx", entry);
417
+ const entries = yield* storage.getEntries("large-tx", 0);
418
+ yield* assertLength(entries, 1, "Should have one entry");
419
+ yield* assertEqual(entries[0].transaction, entry.transaction, "Large transaction data should survive roundtrip");
420
+ })
421
+ },
422
+ {
423
+ name: "long documentId (1000+ chars) works",
424
+ category: Categories.DocumentIdEdgeCases,
425
+ run: Effect.gen(function* () {
426
+ const storage = yield* HotStorageTag;
427
+ const longId = "h".repeat(1e3);
428
+ const entry = makeEntry(1);
429
+ yield* storage.append(longId, entry);
430
+ yield* assertLength(yield* storage.getEntries(longId, 0), 1, "Long documentId should work");
431
+ })
432
+ },
433
+ {
434
+ name: "unicode documentId works",
435
+ category: Categories.DocumentIdEdgeCases,
436
+ run: Effect.gen(function* () {
437
+ const storage = yield* HotStorageTag;
438
+ const unicodeId = "hot-doc-id";
439
+ const entry = makeEntry(1);
440
+ yield* storage.append(unicodeId, entry);
441
+ yield* assertLength(yield* storage.getEntries(unicodeId, 0), 1, "Unicode documentId should work");
442
+ })
443
+ },
444
+ {
445
+ name: "documentId with special chars works",
446
+ category: Categories.DocumentIdEdgeCases,
447
+ run: Effect.gen(function* () {
448
+ const storage = yield* HotStorageTag;
449
+ const specialId = "hot/path:to.wal";
450
+ const entry = makeEntry(1);
451
+ yield* storage.append(specialId, entry);
452
+ yield* assertLength(yield* storage.getEntries(specialId, 0), 1, "DocumentId with special chars should work");
453
+ })
454
+ },
455
+ {
456
+ name: "documentId with spaces works",
457
+ category: Categories.DocumentIdEdgeCases,
458
+ run: Effect.gen(function* () {
459
+ const storage = yield* HotStorageTag;
460
+ const spacedId = "hot doc with spaces";
461
+ const entry = makeEntry(1);
462
+ yield* storage.append(spacedId, entry);
463
+ yield* assertLength(yield* storage.getEntries(spacedId, 0), 1, "DocumentId with spaces should work");
464
+ })
465
+ },
466
+ {
467
+ name: "version 0 entry is handled correctly",
468
+ category: Categories.VersionFiltering,
469
+ run: Effect.gen(function* () {
470
+ const storage = yield* HotStorageTag;
471
+ yield* storage.append("version-0-entry", makeEntry(0));
472
+ yield* storage.append("version-0-entry", makeEntry(1));
473
+ yield* assertTrue((yield* storage.getEntries("version-0-entry", -1)).some((e) => e.version === 0), "Version 0 entry should be retrievable with sinceVersion < 0");
474
+ yield* assertTrue(!(yield* storage.getEntries("version-0-entry", 0)).some((e) => e.version === 0), "Version 0 entry should be excluded with sinceVersion = 0");
475
+ })
476
+ },
477
+ {
478
+ name: "appendWithCheck succeeds for first entry (expectedVersion=1)",
479
+ category: Categories.GapChecking,
480
+ run: Effect.gen(function* () {
481
+ const storage = yield* HotStorageTag;
482
+ const entry = makeEntry(1);
483
+ yield* storage.appendWithCheck("gap-check-first", entry, 1);
484
+ const entries = yield* storage.getEntries("gap-check-first", 0);
485
+ yield* assertLength(entries, 1, "Should have one entry");
486
+ yield* assertEqual(entries[0].version, 1, "Entry version should be 1");
487
+ })
488
+ },
489
+ {
490
+ name: "appendWithCheck succeeds for consecutive versions",
491
+ category: Categories.GapChecking,
492
+ run: Effect.gen(function* () {
493
+ const storage = yield* HotStorageTag;
494
+ yield* storage.appendWithCheck("gap-check-consecutive", makeEntry(1), 1);
495
+ yield* storage.appendWithCheck("gap-check-consecutive", makeEntry(2), 2);
496
+ yield* storage.appendWithCheck("gap-check-consecutive", makeEntry(3), 3);
497
+ const entries = yield* storage.getEntries("gap-check-consecutive", 0);
498
+ yield* assertLength(entries, 3, "Should have three entries");
499
+ yield* assertEqual(entries[0].version, 1, "First entry version should be 1");
500
+ yield* assertEqual(entries[1].version, 2, "Second entry version should be 2");
501
+ yield* assertEqual(entries[2].version, 3, "Third entry version should be 3");
502
+ })
503
+ },
504
+ {
505
+ name: "appendWithCheck fails for version gap (skipping version 2)",
506
+ category: Categories.GapChecking,
507
+ run: Effect.gen(function* () {
508
+ const storage = yield* HotStorageTag;
509
+ yield* storage.appendWithCheck("gap-check-fail", makeEntry(1), 1);
510
+ const result = yield* Effect.either(storage.appendWithCheck("gap-check-fail", makeEntry(3), 3));
511
+ yield* assertTrue(result._tag === "Left", "appendWithCheck should fail when there's a version gap");
512
+ if (result._tag === "Left") yield* assertTrue(result.left._tag === "WalVersionGapError", "Error should be WalVersionGapError");
513
+ const entries = yield* storage.getEntries("gap-check-fail", 0);
514
+ yield* assertLength(entries, 1, "Should only have version 1");
515
+ yield* assertEqual(entries[0].version, 1, "Only version 1 should exist");
516
+ })
517
+ },
518
+ {
519
+ name: "appendWithCheck fails if first entry is not version 1",
520
+ category: Categories.GapChecking,
521
+ run: Effect.gen(function* () {
522
+ const storage = yield* HotStorageTag;
523
+ const result = yield* Effect.either(storage.appendWithCheck("gap-check-not-first", makeEntry(2), 2));
524
+ yield* assertTrue(result._tag === "Left", "appendWithCheck should fail when first entry is not version 1");
525
+ if (result._tag === "Left") yield* assertTrue(result.left._tag === "WalVersionGapError", "Error should be WalVersionGapError");
526
+ yield* assertEmpty(yield* storage.getEntries("gap-check-not-first", 0), "No entries should exist after failed append");
527
+ })
528
+ },
529
+ {
530
+ name: "appendWithCheck fails when entry already exists at expectedVersion",
531
+ category: Categories.GapChecking,
532
+ run: Effect.gen(function* () {
533
+ const storage = yield* HotStorageTag;
534
+ yield* storage.appendWithCheck("gap-check-duplicate", makeEntry(1), 1);
535
+ yield* assertTrue((yield* Effect.either(storage.appendWithCheck("gap-check-duplicate", makeEntry(1), 1)))._tag === "Left", "appendWithCheck should fail when version already exists");
536
+ yield* assertLength(yield* storage.getEntries("gap-check-duplicate", 0), 1, "Should still only have one entry");
537
+ })
538
+ },
539
+ {
540
+ name: "appendWithCheck after truncate works correctly",
541
+ category: Categories.GapChecking,
542
+ run: Effect.gen(function* () {
543
+ const storage = yield* HotStorageTag;
544
+ yield* storage.appendWithCheck("gap-check-truncate", makeEntry(1), 1);
545
+ yield* storage.appendWithCheck("gap-check-truncate", makeEntry(2), 2);
546
+ yield* storage.appendWithCheck("gap-check-truncate", makeEntry(3), 3);
547
+ yield* storage.truncate("gap-check-truncate", 2);
548
+ yield* storage.appendWithCheck("gap-check-truncate", makeEntry(4), 4);
549
+ const entries = yield* storage.getEntries("gap-check-truncate", 0);
550
+ yield* assertLength(entries, 2, "Should have versions 3 and 4");
551
+ yield* assertEqual(entries[0].version, 3, "First should be version 3");
552
+ yield* assertEqual(entries[1].version, 4, "Second should be version 4");
553
+ })
554
+ },
555
+ {
556
+ name: "OperationPath has _tag after roundtrip",
557
+ category: Categories.TransactionEncoding,
558
+ run: Effect.gen(function* () {
559
+ const storage = yield* HotStorageTag;
560
+ const entry = makeEntryWithPath(1, "users/0/name", "Alice");
561
+ yield* storage.append("op-path-tag", entry);
562
+ const entries = yield* storage.getEntries("op-path-tag", 0);
563
+ yield* assertLength(entries, 1, "Should have one entry");
564
+ const op = entries[0].transaction.ops[0];
565
+ yield* assertTrue(op.path._tag === "OperationPath", "path should have _tag 'OperationPath'");
566
+ })
567
+ },
568
+ {
569
+ name: "OperationPath.toTokens() works after roundtrip",
570
+ category: Categories.TransactionEncoding,
571
+ run: Effect.gen(function* () {
572
+ const storage = yield* HotStorageTag;
573
+ const entry = makeEntryWithPath(1, "users/0/name", "Alice");
574
+ yield* storage.append("op-path-tokens", entry);
575
+ const entries = yield* storage.getEntries("op-path-tokens", 0);
576
+ yield* assertLength(entries, 1, "Should have one entry");
577
+ const op = entries[0].transaction.ops[0];
578
+ yield* assertTrue(typeof op.path.toTokens === "function", "path.toTokens should be a function");
579
+ yield* assertEqual(op.path.toTokens(), [
580
+ "users",
581
+ "0",
582
+ "name"
583
+ ], "toTokens() should return correct path tokens");
584
+ })
585
+ },
586
+ {
587
+ name: "OperationPath.concat() works after roundtrip",
588
+ category: Categories.TransactionEncoding,
589
+ run: Effect.gen(function* () {
590
+ const storage = yield* HotStorageTag;
591
+ const entry = makeEntryWithPath(1, "users/0", { name: "Alice" });
592
+ yield* storage.append("op-path-concat", entry);
593
+ const entries = yield* storage.getEntries("op-path-concat", 0);
594
+ yield* assertLength(entries, 1, "Should have one entry");
595
+ const op = entries[0].transaction.ops[0];
596
+ yield* assertTrue(typeof op.path.concat === "function", "path.concat should be a function");
597
+ yield* assertEqual(op.path.concat(OperationPath.make("name")).toTokens(), [
598
+ "users",
599
+ "0",
600
+ "name"
601
+ ], "concat() should work correctly");
602
+ })
603
+ },
604
+ {
605
+ name: "OperationPath.append() works after roundtrip",
606
+ category: Categories.TransactionEncoding,
607
+ run: Effect.gen(function* () {
608
+ const storage = yield* HotStorageTag;
609
+ const entry = makeEntryWithPath(1, "users", []);
610
+ yield* storage.append("op-path-append", entry);
611
+ const entries = yield* storage.getEntries("op-path-append", 0);
612
+ yield* assertLength(entries, 1, "Should have one entry");
613
+ const op = entries[0].transaction.ops[0];
614
+ yield* assertTrue(typeof op.path.append === "function", "path.append should be a function");
615
+ yield* assertEqual(op.path.append("0").toTokens(), ["users", "0"], "append() should work correctly");
616
+ })
617
+ },
618
+ {
619
+ name: "OperationPath.pop() works after roundtrip",
620
+ category: Categories.TransactionEncoding,
621
+ run: Effect.gen(function* () {
622
+ const storage = yield* HotStorageTag;
623
+ const entry = makeEntryWithPath(1, "users/0/name", "Alice");
624
+ yield* storage.append("op-path-pop", entry);
625
+ const entries = yield* storage.getEntries("op-path-pop", 0);
626
+ yield* assertLength(entries, 1, "Should have one entry");
627
+ const op = entries[0].transaction.ops[0];
628
+ yield* assertTrue(typeof op.path.pop === "function", "path.pop should be a function");
629
+ yield* assertEqual(op.path.pop().toTokens(), ["users", "0"], "pop() should remove last token");
630
+ })
631
+ },
632
+ {
633
+ name: "OperationPath.shift() works after roundtrip",
634
+ category: Categories.TransactionEncoding,
635
+ run: Effect.gen(function* () {
636
+ const storage = yield* HotStorageTag;
637
+ const entry = makeEntryWithPath(1, "users/0/name", "Alice");
638
+ yield* storage.append("op-path-shift", entry);
639
+ const entries = yield* storage.getEntries("op-path-shift", 0);
640
+ yield* assertLength(entries, 1, "Should have one entry");
641
+ const op = entries[0].transaction.ops[0];
642
+ yield* assertTrue(typeof op.path.shift === "function", "path.shift should be a function");
643
+ yield* assertEqual(op.path.shift().toTokens(), ["0", "name"], "shift() should remove first token");
644
+ })
645
+ },
646
+ {
647
+ name: "transaction with multiple operations preserves all OperationPaths",
648
+ category: Categories.TransactionEncoding,
649
+ run: Effect.gen(function* () {
650
+ const storage = yield* HotStorageTag;
651
+ const entry = {
652
+ transaction: Transaction.make([
653
+ Operation.fromDefinition(OperationPath.make("users/0/name"), TestSetDefinition, "Alice"),
654
+ Operation.fromDefinition(OperationPath.make("users/1/name"), TestSetDefinition, "Bob"),
655
+ Operation.fromDefinition(OperationPath.make("count"), TestSetDefinition, 2)
656
+ ]),
657
+ version: 1,
658
+ timestamp: Date.now()
659
+ };
660
+ yield* storage.append("multi-op-paths", entry);
661
+ const entries = yield* storage.getEntries("multi-op-paths", 0);
662
+ yield* assertLength(entries, 1, "Should have one entry");
663
+ const ops = entries[0].transaction.ops;
664
+ yield* assertLength([...ops], 3, "Should have 3 operations");
665
+ for (const op of ops) {
666
+ yield* assertTrue(op.path._tag === "OperationPath", "Each operation path should have _tag");
667
+ yield* assertTrue(typeof op.path.toTokens === "function", "Each operation path should have toTokens method");
668
+ }
669
+ yield* assertEqual(ops[0].path.toTokens(), [
670
+ "users",
671
+ "0",
672
+ "name"
673
+ ], "First path should be correct");
674
+ yield* assertEqual(ops[1].path.toTokens(), [
675
+ "users",
676
+ "1",
677
+ "name"
678
+ ], "Second path should be correct");
679
+ yield* assertEqual(ops[2].path.toTokens(), ["count"], "Third path should be correct");
680
+ })
681
+ },
682
+ {
683
+ name: "nested path with many segments survives roundtrip",
684
+ category: Categories.TransactionEncoding,
685
+ run: Effect.gen(function* () {
686
+ const storage = yield* HotStorageTag;
687
+ const entry = makeEntryWithPath(1, "level1/level2/level3/level4/level5", "deep value");
688
+ yield* storage.append("deep-path", entry);
689
+ const entries = yield* storage.getEntries("deep-path", 0);
690
+ yield* assertLength(entries, 1, "Should have one entry");
691
+ const op = entries[0].transaction.ops[0];
692
+ yield* assertEqual(op.path.toTokens(), [
693
+ "level1",
694
+ "level2",
695
+ "level3",
696
+ "level4",
697
+ "level5"
698
+ ], "Deep nested path should survive roundtrip");
699
+ })
700
+ },
701
+ {
702
+ name: "empty path survives roundtrip",
703
+ category: Categories.TransactionEncoding,
704
+ run: Effect.gen(function* () {
705
+ const storage = yield* HotStorageTag;
706
+ const entry = makeEntryWithPath(1, "", { root: true });
707
+ yield* storage.append("empty-path", entry);
708
+ const entries = yield* storage.getEntries("empty-path", 0);
709
+ yield* assertLength(entries, 1, "Should have one entry");
710
+ const op = entries[0].transaction.ops[0];
711
+ yield* assertTrue(op.path._tag === "OperationPath", "Empty path should still be OperationPath");
712
+ yield* assertTrue(typeof op.path.toTokens === "function", "Empty path should have toTokens method");
713
+ })
714
+ },
715
+ {
716
+ name: "transaction id is preserved after roundtrip",
717
+ category: Categories.TransactionEncoding,
718
+ run: Effect.gen(function* () {
719
+ const storage = yield* HotStorageTag;
720
+ const entry = makeEntryWithPath(1, "test", "value");
721
+ const originalId = entry.transaction.id;
722
+ yield* storage.append("tx-id-preserve", entry);
723
+ const entries = yield* storage.getEntries("tx-id-preserve", 0);
724
+ yield* assertLength(entries, 1, "Should have one entry");
725
+ yield* assertEqual(entries[0].transaction.id, originalId, "Transaction id should be preserved");
726
+ })
727
+ },
728
+ {
729
+ name: "transaction timestamp is preserved after roundtrip",
730
+ category: Categories.TransactionEncoding,
731
+ run: Effect.gen(function* () {
732
+ const storage = yield* HotStorageTag;
733
+ const entry = makeEntryWithPath(1, "test", "value");
734
+ const originalTimestamp = entry.transaction.timestamp;
735
+ yield* storage.append("tx-timestamp-preserve", entry);
736
+ const entries = yield* storage.getEntries("tx-timestamp-preserve", 0);
737
+ yield* assertLength(entries, 1, "Should have one entry");
738
+ yield* assertEqual(entries[0].transaction.timestamp, originalTimestamp, "Transaction timestamp should be preserved");
739
+ })
740
+ },
741
+ {
742
+ name: "operation kind is preserved after roundtrip",
743
+ category: Categories.TransactionEncoding,
744
+ run: Effect.gen(function* () {
745
+ const storage = yield* HotStorageTag;
746
+ const entry = {
747
+ transaction: Transaction.make([Operation.fromDefinition(OperationPath.make("data"), CustomOpDefinition, "test")]),
748
+ version: 1,
749
+ timestamp: Date.now()
750
+ };
751
+ yield* storage.append("op-kind-preserve", entry);
752
+ const entries = yield* storage.getEntries("op-kind-preserve", 0);
753
+ yield* assertLength(entries, 1, "Should have one entry");
754
+ yield* assertEqual(entries[0].transaction.ops[0].kind, "custom.operation", "Operation kind should be preserved");
755
+ })
756
+ },
757
+ {
758
+ name: "operation payload with complex object survives roundtrip",
759
+ category: Categories.TransactionEncoding,
760
+ run: Effect.gen(function* () {
761
+ const storage = yield* HotStorageTag;
762
+ const complexPayload = {
763
+ nested: {
764
+ value: 42,
765
+ array: [
766
+ 1,
767
+ 2,
768
+ 3
769
+ ]
770
+ },
771
+ nullValue: null,
772
+ string: "test"
773
+ };
774
+ const entry = makeEntryWithPath(1, "data", complexPayload);
775
+ yield* storage.append("complex-payload", entry);
776
+ const entries = yield* storage.getEntries("complex-payload", 0);
777
+ yield* assertLength(entries, 1, "Should have one entry");
778
+ yield* assertEqual(entries[0].transaction.ops[0].payload, complexPayload, "Complex payload should survive roundtrip");
779
+ })
780
+ }
781
+ ];
782
+ /**
783
+ * Get all HotStorage test cases.
784
+ *
785
+ * @returns Array of test cases that require HotStorageTag
786
+ */
787
+ const makeTests = () => tests;
788
+ /**
789
+ * Run all tests and collect results.
790
+ *
791
+ * @returns Effect that produces TestResults
792
+ */
793
+ const runAll = () => Effect.gen(function* () {
794
+ const passed = [];
795
+ const failed = [];
796
+ for (const test of tests) {
797
+ const result = yield* Effect.either(test.run);
798
+ if (result._tag === "Right") passed.push(test);
799
+ else failed.push({
800
+ test,
801
+ error: result.left
802
+ });
803
+ }
804
+ return {
805
+ passed,
806
+ failed,
807
+ total: tests.length,
808
+ passCount: passed.length,
809
+ failCount: failed.length
810
+ };
811
+ });
812
+ const HotStorageTestSuite = {
813
+ Categories,
814
+ makeTests,
815
+ runAll
816
+ };
817
+
818
+ //#endregion
819
+ export { Categories, HotStorageTestSuite };
820
+ //# sourceMappingURL=HotStorageTestSuite.mjs.map