@voidhash/mimic-effect 1.0.0-beta.3 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +21 -21
- package/dist/MimicServer.d.cts +1 -1
- package/dist/MimicServer.d.cts.map +1 -1
- package/dist/MimicServer.d.mts +1 -1
- package/dist/MimicServer.d.mts.map +1 -1
- package/dist/testing/FailingStorage.cjs +27 -0
- package/dist/testing/FailingStorage.d.cts.map +1 -1
- package/dist/testing/FailingStorage.d.mts.map +1 -1
- package/dist/testing/FailingStorage.mjs +28 -1
- package/dist/testing/FailingStorage.mjs.map +1 -1
- package/dist/testing/HotStorageTestSuite.cjs +253 -6
- package/dist/testing/HotStorageTestSuite.d.cts +2 -0
- package/dist/testing/HotStorageTestSuite.d.cts.map +1 -1
- package/dist/testing/HotStorageTestSuite.d.mts +2 -0
- package/dist/testing/HotStorageTestSuite.d.mts.map +1 -1
- package/dist/testing/HotStorageTestSuite.mjs +255 -8
- package/dist/testing/HotStorageTestSuite.mjs.map +1 -1
- package/dist/testing/StorageIntegrationTestSuite.cjs +150 -12
- package/dist/testing/StorageIntegrationTestSuite.d.cts +2 -0
- package/dist/testing/StorageIntegrationTestSuite.d.cts.map +1 -1
- package/dist/testing/StorageIntegrationTestSuite.d.mts +2 -0
- package/dist/testing/StorageIntegrationTestSuite.d.mts.map +1 -1
- package/dist/testing/StorageIntegrationTestSuite.mjs +151 -13
- package/dist/testing/StorageIntegrationTestSuite.mjs.map +1 -1
- package/dist/testing/types.d.cts +3 -3
- package/package.json +3 -3
- package/src/testing/FailingStorage.ts +53 -1
- package/src/testing/HotStorageTestSuite.ts +346 -3
- package/src/testing/StorageIntegrationTestSuite.ts +239 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @voidhash/mimic-effect@1.0.0-beta.
|
|
2
|
+
> @voidhash/mimic-effect@1.0.0-beta.4 build /home/runner/work/mimic/mimic/packages/mimic-effect
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.18.2[22m powered by rolldown [2mv1.0.0-beta.55[22m
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mℹ[39m Build start
|
|
11
11
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m [2m 2.43 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
12
12
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mtesting/index.cjs[22m [2m 0.95 kB[22m [2m│ gzip: 0.22 kB[22m
|
|
13
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/HotStorageTestSuite.cjs [
|
|
13
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/HotStorageTestSuite.cjs [2m37.91 kB[22m [2m│ gzip: 5.16 kB[22m
|
|
14
14
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicClusterServerEngine.cjs [2m21.55 kB[22m [2m│ gzip: 4.91 kB[22m
|
|
15
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.cjs [2m20.68 kB[22m [2m│ gzip: 3.67 kB[22m
|
|
15
16
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/ColdStorageTestSuite.cjs [2m18.14 kB[22m [2m│ gzip: 3.22 kB[22m
|
|
16
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.cjs [2m13.93 kB[22m [2m│ gzip: 2.58 kB[22m
|
|
17
17
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentManager.cjs [2m12.28 kB[22m [2m│ gzip: 2.97 kB[22m
|
|
18
18
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.cjs [2m10.10 kB[22m [2m│ gzip: 2.74 kB[22m
|
|
19
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/FailingStorage.cjs [2m
|
|
19
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/FailingStorage.cjs [2m 6.91 kB[22m [2m│ gzip: 1.53 kB[22m
|
|
20
20
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMetrics.cjs [2m 4.26 kB[22m [2m│ gzip: 1.04 kB[22m
|
|
21
21
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServerEngine.cjs [2m 4.23 kB[22m [2m│ gzip: 1.34 kB[22m
|
|
22
22
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mProtocol.cjs [2m 3.78 kB[22m [2m│ gzip: 1.14 kB[22m
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs [2m 0.37 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
34
34
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/rolldown_runtime.cjs [2m 0.36 kB[22m [2m│ gzip: 0.25 kB[22m
|
|
35
35
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/types.cjs [2m 0.34 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
36
|
-
[34mℹ[39m [33m[CJS][39m 25 files, total:
|
|
36
|
+
[34mℹ[39m [33m[CJS][39m 25 files, total: 163.63 kB
|
|
37
37
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mProtocol.d.cts.map [2m1.57 kB[22m [2m│ gzip: 0.70 kB[22m
|
|
38
38
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mTypes.d.cts.map [2m1.41 kB[22m [2m│ gzip: 0.65 kB[22m
|
|
39
39
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServerEngine.d.cts.map [2m1.09 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mPresenceManager.d.cts.map [2m0.45 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
47
47
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/types.d.cts.map [2m0.38 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
48
48
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/ColdStorageTestSuite.d.cts.map [2m0.35 kB[22m [2m│ gzip: 0.25 kB[22m
|
|
49
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.d.cts.map [2m0.
|
|
49
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.d.cts.map [2m0.32 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
50
50
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mtesting/FailingStorage.d.cts.map [2m0.26 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
51
51
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicClusterServerEngine.d.cts.map [2m0.25 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
52
52
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.d.cts.map [2m0.22 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
@@ -61,30 +61,30 @@
|
|
|
61
61
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mDocumentManager.d.cts[39m [2m2.74 kB[22m [2m│ gzip: 0.84 kB[22m
|
|
62
62
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mHotStorage.d.cts[39m [2m2.72 kB[22m [2m│ gzip: 1.08 kB[22m
|
|
63
63
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicAuthService.d.cts[39m [2m2.70 kB[22m [2m│ gzip: 1.04 kB[22m
|
|
64
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mtesting/HotStorageTestSuite.d.cts[39m [2m1.
|
|
64
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mtesting/HotStorageTestSuite.d.cts[39m [2m1.93 kB[22m [2m│ gzip: 0.57 kB[22m
|
|
65
65
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mColdStorage.d.cts[39m [2m1.74 kB[22m [2m│ gzip: 0.70 kB[22m
|
|
66
66
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mPresenceManager.d.cts[39m [2m1.60 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
67
67
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMetrics.d.cts[39m [2m1.59 kB[22m [2m│ gzip: 0.39 kB[22m
|
|
68
68
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mtesting/ColdStorageTestSuite.d.cts[39m [2m1.55 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
69
69
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mtesting/FailingStorage.d.cts[39m [2m1.44 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
70
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mtesting/StorageIntegrationTestSuite.d.cts[39m [2m1.
|
|
70
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mtesting/StorageIntegrationTestSuite.d.cts[39m [2m1.43 kB[22m [2m│ gzip: 0.57 kB[22m
|
|
71
71
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicClusterServerEngine.d.cts[39m [2m0.82 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
72
72
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicServer.d.cts[39m [2m0.74 kB[22m [2m│ gzip: 0.31 kB[22m
|
|
73
|
-
[34mℹ[39m [33m[CJS][39m 36 files, total: 56.
|
|
74
|
-
[32m✔[39m Build complete in [
|
|
73
|
+
[34mℹ[39m [33m[CJS][39m 36 files, total: 56.62 kB
|
|
74
|
+
[32m✔[39m Build complete in [32m6416ms[39m
|
|
75
75
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.mjs[22m [2m 1.38 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
76
76
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mtesting/index.mjs[22m [2m 0.60 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
77
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/HotStorageTestSuite.mjs.map [
|
|
77
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/HotStorageTestSuite.mjs.map [2m63.35 kB[22m [2m│ gzip: 8.67 kB[22m
|
|
78
78
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicClusterServerEngine.mjs.map [2m42.30 kB[22m [2m│ gzip: 9.99 kB[22m
|
|
79
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.mjs.map [2m35.60 kB[22m [2m│ gzip: 6.44 kB[22m
|
|
80
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/HotStorageTestSuite.mjs [2m34.18 kB[22m [2m│ gzip: 5.10 kB[22m
|
|
79
81
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/ColdStorageTestSuite.mjs.map [2m31.92 kB[22m [2m│ gzip: 5.21 kB[22m
|
|
80
82
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.mjs.map [2m28.52 kB[22m [2m│ gzip: 6.84 kB[22m
|
|
81
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.mjs.map [2m24.17 kB[22m [2m│ gzip: 4.50 kB[22m
|
|
82
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/HotStorageTestSuite.mjs [2m23.90 kB[22m [2m│ gzip: 3.87 kB[22m
|
|
83
83
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.mjs.map [2m20.88 kB[22m [2m│ gzip: 5.46 kB[22m
|
|
84
84
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicClusterServerEngine.mjs [2m20.10 kB[22m [2m│ gzip: 4.94 kB[22m
|
|
85
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.mjs [2m18.49 kB[22m [2m│ gzip: 3.63 kB[22m
|
|
85
86
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/ColdStorageTestSuite.mjs [2m16.50 kB[22m [2m│ gzip: 3.21 kB[22m
|
|
86
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/FailingStorage.mjs.map [
|
|
87
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.mjs [2m12.56 kB[22m [2m│ gzip: 2.56 kB[22m
|
|
87
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/FailingStorage.mjs.map [2m15.60 kB[22m [2m│ gzip: 3.07 kB[22m
|
|
88
88
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.mjs [2m11.59 kB[22m [2m│ gzip: 3.00 kB[22m
|
|
89
89
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mHotStorage.mjs.map [2m10.05 kB[22m [2m│ gzip: 2.85 kB[22m
|
|
90
90
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServerEngine.mjs.map [2m10.01 kB[22m [2m│ gzip: 2.73 kB[22m
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mProtocol.mjs.map [2m 9.18 kB[22m [2m│ gzip: 2.15 kB[22m
|
|
93
93
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mPresenceManager.mjs.map [2m 9.11 kB[22m [2m│ gzip: 2.27 kB[22m
|
|
94
94
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/assertions.mjs.map [2m 6.69 kB[22m [2m│ gzip: 1.78 kB[22m
|
|
95
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/FailingStorage.mjs [2m 6.49 kB[22m [2m│ gzip: 1.52 kB[22m
|
|
95
96
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMetrics.mjs.map [2m 6.13 kB[22m [2m│ gzip: 1.43 kB[22m
|
|
96
97
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicAuthService.mjs.map [2m 6.09 kB[22m [2m│ gzip: 1.85 kB[22m
|
|
97
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/FailingStorage.mjs [2m 5.41 kB[22m [2m│ gzip: 1.30 kB[22m
|
|
98
98
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mColdStorage.mjs.map [2m 4.90 kB[22m [2m│ gzip: 1.52 kB[22m
|
|
99
99
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServerEngine.mjs [2m 4.10 kB[22m [2m│ gzip: 1.35 kB[22m
|
|
100
100
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mErrors.mjs.map [2m 4.00 kB[22m [2m│ gzip: 1.05 kB[22m
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/types.mjs [2m 0.35 kB[22m [2m│ gzip: 0.25 kB[22m
|
|
126
126
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs [2m 0.35 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
127
127
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/ColdStorageTestSuite.d.mts.map [2m 0.35 kB[22m [2m│ gzip: 0.25 kB[22m
|
|
128
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.d.mts.map [2m 0.
|
|
128
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/StorageIntegrationTestSuite.d.mts.map [2m 0.32 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
129
129
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs [2m 0.30 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
130
130
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mtesting/FailingStorage.d.mts.map [2m 0.26 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
131
131
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicClusterServerEngine.d.mts.map [2m 0.25 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
@@ -141,14 +141,14 @@
|
|
|
141
141
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mDocumentManager.d.mts[39m [2m 2.74 kB[22m [2m│ gzip: 0.84 kB[22m
|
|
142
142
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mHotStorage.d.mts[39m [2m 2.72 kB[22m [2m│ gzip: 1.08 kB[22m
|
|
143
143
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicAuthService.d.mts[39m [2m 2.70 kB[22m [2m│ gzip: 1.04 kB[22m
|
|
144
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mtesting/HotStorageTestSuite.d.mts[39m [2m 1.
|
|
144
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mtesting/HotStorageTestSuite.d.mts[39m [2m 1.93 kB[22m [2m│ gzip: 0.57 kB[22m
|
|
145
145
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mColdStorage.d.mts[39m [2m 1.74 kB[22m [2m│ gzip: 0.70 kB[22m
|
|
146
146
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mPresenceManager.d.mts[39m [2m 1.60 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
147
147
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMetrics.d.mts[39m [2m 1.59 kB[22m [2m│ gzip: 0.39 kB[22m
|
|
148
148
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mtesting/ColdStorageTestSuite.d.mts[39m [2m 1.55 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
149
149
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mtesting/FailingStorage.d.mts[39m [2m 1.44 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
150
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mtesting/StorageIntegrationTestSuite.d.mts[39m [2m 1.
|
|
150
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mtesting/StorageIntegrationTestSuite.d.mts[39m [2m 1.43 kB[22m [2m│ gzip: 0.57 kB[22m
|
|
151
151
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicClusterServerEngine.d.mts[39m [2m 0.82 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
152
152
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicServer.d.mts[39m [2m 0.74 kB[22m [2m│ gzip: 0.31 kB[22m
|
|
153
|
-
[34mℹ[39m [34m[ESM][39m 78 files, total:
|
|
154
|
-
[32m✔[39m Build complete in [
|
|
153
|
+
[34mℹ[39m [34m[ESM][39m 78 files, total: 513.37 kB
|
|
154
|
+
[32m✔[39m Build complete in [32m6441ms[39m
|
package/dist/MimicServer.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ import { HttpLayerRouter } from "@effect/platform";
|
|
|
8
8
|
//#region src/MimicServer.d.ts
|
|
9
9
|
|
|
10
10
|
declare const MimicServer: {
|
|
11
|
-
layerHttpLayerRouter: (options?: MimicServerRouteConfig) => Layer.Layer<never, never,
|
|
11
|
+
layerHttpLayerRouter: (options?: MimicServerRouteConfig) => Layer.Layer<never, never, MimicServerEngineTag | MimicAuthServiceTag | HttpLayerRouter.HttpRouter | HttpLayerRouter.Request<"Error", _effect_platform_HttpServerError0.RequestError>>;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
14
14
|
export { MimicServer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimicServer.d.cts","names":[],"sources":["../src/MimicServer.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAmea;mCA7DD,2BAAsB,KAAA,CAAA,oBAAA,sBAAA,
|
|
1
|
+
{"version":3,"file":"MimicServer.d.cts","names":[],"sources":["../src/MimicServer.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAmea;mCA7DD,2BAAsB,KAAA,CAAA,oBAAA,uBAAA,sBAAA,eAAA,CAAA,aAAA,eAAA,CAAA,iBAAA,iCAAA,CAAA,YAAA"}
|
package/dist/MimicServer.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ import * as _effect_platform_HttpServerError0 from "@effect/platform/HttpServerE
|
|
|
8
8
|
//#region src/MimicServer.d.ts
|
|
9
9
|
|
|
10
10
|
declare const MimicServer: {
|
|
11
|
-
layerHttpLayerRouter: (options?: MimicServerRouteConfig) => Layer.Layer<never, never,
|
|
11
|
+
layerHttpLayerRouter: (options?: MimicServerRouteConfig) => Layer.Layer<never, never, MimicServerEngineTag | MimicAuthServiceTag | HttpLayerRouter.HttpRouter | HttpLayerRouter.Request<"Error", _effect_platform_HttpServerError0.RequestError>>;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
14
14
|
export { MimicServer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimicServer.d.mts","names":[],"sources":["../src/MimicServer.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAmea;mCA7DD,2BAAsB,KAAA,CAAA,oBAAA,sBAAA,
|
|
1
|
+
{"version":3,"file":"MimicServer.d.mts","names":[],"sources":["../src/MimicServer.ts"],"sourcesContent":[],"mappings":";;;;;;;;;cAmea;mCA7DD,2BAAsB,KAAA,CAAA,oBAAA,uBAAA,sBAAA,eAAA,CAAA,aAAA,eAAA,CAAA,iBAAA,iCAAA,CAAA,YAAA"}
|
|
@@ -101,6 +101,33 @@ const makeHotStorage = (config = {}) => effect.Layer.effect(require_HotStorage.H
|
|
|
101
101
|
return effect.HashMap.set(map, documentId, [...entries, entry]);
|
|
102
102
|
});
|
|
103
103
|
}),
|
|
104
|
+
appendWithCheck: (documentId, entry, expectedVersion) => effect.Effect.gen(function* () {
|
|
105
|
+
if (yield* shouldFail("append")) return yield* effect.Effect.fail(new require_Errors.HotStorageError({
|
|
106
|
+
documentId,
|
|
107
|
+
operation: "appendWithCheck",
|
|
108
|
+
cause: new Error(errorMessage)
|
|
109
|
+
}));
|
|
110
|
+
const result = yield* effect.Ref.modify(store, (map) => {
|
|
111
|
+
const existing = effect.HashMap.get(map, documentId);
|
|
112
|
+
const entries = existing._tag === "Some" ? existing.value : [];
|
|
113
|
+
const lastVersion = entries.length > 0 ? Math.max(...entries.map((e) => e.version)) : 0;
|
|
114
|
+
if (expectedVersion === 1) {
|
|
115
|
+
if (lastVersion >= 1) return [{
|
|
116
|
+
type: "gap",
|
|
117
|
+
lastVersion
|
|
118
|
+
}, map];
|
|
119
|
+
} else if (lastVersion !== expectedVersion - 1) return [{
|
|
120
|
+
type: "gap",
|
|
121
|
+
lastVersion: lastVersion > 0 ? lastVersion : void 0
|
|
122
|
+
}, map];
|
|
123
|
+
return [{ type: "ok" }, effect.HashMap.set(map, documentId, [...entries, entry])];
|
|
124
|
+
});
|
|
125
|
+
if (result.type === "gap") return yield* effect.Effect.fail(new require_Errors.WalVersionGapError({
|
|
126
|
+
documentId,
|
|
127
|
+
expectedVersion,
|
|
128
|
+
actualPreviousVersion: result.lastVersion
|
|
129
|
+
}));
|
|
130
|
+
}),
|
|
104
131
|
getEntries: (documentId, sinceVersion) => effect.Effect.gen(function* () {
|
|
105
132
|
if (yield* shouldFail("getEntries")) return yield* effect.Effect.fail(new require_Errors.HotStorageError({
|
|
106
133
|
documentId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FailingStorage.d.cts","names":[],"sources":["../../src/testing/FailingStorage.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UA8BiB,wBAAA;;;;;;;;;;;;;;;UAgBA,uBAAA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"FailingStorage.d.cts","names":[],"sources":["../../src/testing/FailingStorage.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UA8BiB,wBAAA;;;;;;;;;;;;;;;UAgBA,uBAAA;;;;;;;;;;;;cAgSJ;6BA1QH,6BACP,KAAA,CAAM,MAAM;4BAqGL,4BACP,KAAA,CAAM,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FailingStorage.d.mts","names":[],"sources":["../../src/testing/FailingStorage.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UA8BiB,wBAAA;;;;;;;;;;;;;;;UAgBA,uBAAA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"FailingStorage.d.mts","names":[],"sources":["../../src/testing/FailingStorage.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UA8BiB,wBAAA;;;;;;;;;;;;;;;UAgBA,uBAAA;;;;;;;;;;;;cAgSJ;6BA1QH,6BACP,KAAA,CAAM,MAAM;4BAqGL,4BACP,KAAA,CAAM,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColdStorageTag } from "../ColdStorage.mjs";
|
|
2
|
-
import { ColdStorageError, HotStorageError } from "../Errors.mjs";
|
|
2
|
+
import { ColdStorageError, HotStorageError, WalVersionGapError } from "../Errors.mjs";
|
|
3
3
|
import { HotStorageTag } from "../HotStorage.mjs";
|
|
4
4
|
import { Effect, HashMap, Layer, Ref } from "effect";
|
|
5
5
|
|
|
@@ -101,6 +101,33 @@ const makeHotStorage = (config = {}) => Layer.effect(HotStorageTag, Effect.gen(f
|
|
|
101
101
|
return HashMap.set(map, documentId, [...entries, entry]);
|
|
102
102
|
});
|
|
103
103
|
}),
|
|
104
|
+
appendWithCheck: (documentId, entry, expectedVersion) => Effect.gen(function* () {
|
|
105
|
+
if (yield* shouldFail("append")) return yield* Effect.fail(new HotStorageError({
|
|
106
|
+
documentId,
|
|
107
|
+
operation: "appendWithCheck",
|
|
108
|
+
cause: new Error(errorMessage)
|
|
109
|
+
}));
|
|
110
|
+
const result = yield* Ref.modify(store, (map) => {
|
|
111
|
+
const existing = HashMap.get(map, documentId);
|
|
112
|
+
const entries = existing._tag === "Some" ? existing.value : [];
|
|
113
|
+
const lastVersion = entries.length > 0 ? Math.max(...entries.map((e) => e.version)) : 0;
|
|
114
|
+
if (expectedVersion === 1) {
|
|
115
|
+
if (lastVersion >= 1) return [{
|
|
116
|
+
type: "gap",
|
|
117
|
+
lastVersion
|
|
118
|
+
}, map];
|
|
119
|
+
} else if (lastVersion !== expectedVersion - 1) return [{
|
|
120
|
+
type: "gap",
|
|
121
|
+
lastVersion: lastVersion > 0 ? lastVersion : void 0
|
|
122
|
+
}, map];
|
|
123
|
+
return [{ type: "ok" }, HashMap.set(map, documentId, [...entries, entry])];
|
|
124
|
+
});
|
|
125
|
+
if (result.type === "gap") return yield* Effect.fail(new WalVersionGapError({
|
|
126
|
+
documentId,
|
|
127
|
+
expectedVersion,
|
|
128
|
+
actualPreviousVersion: result.lastVersion
|
|
129
|
+
}));
|
|
130
|
+
}),
|
|
104
131
|
getEntries: (documentId, sinceVersion) => Effect.gen(function* () {
|
|
105
132
|
if (yield* shouldFail("getEntries")) return yield* Effect.fail(new HotStorageError({
|
|
106
133
|
documentId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FailingStorage.mjs","names":[],"sources":["../../src/testing/FailingStorage.ts"],"sourcesContent":["/**\n * @voidhash/mimic-effect/testing - FailingStorage\n *\n * Mock storage implementations that simulate failures for testing error handling.\n * Use these to verify that your application correctly handles storage unavailability.\n *\n * @example\n * ```typescript\n * import { FailingStorage } from \"@voidhash/mimic-effect/testing\";\n *\n * // Create a ColdStorage that fails on load\n * const failingCold = FailingStorage.makeColdStorage({ failLoad: true });\n *\n * // Create a HotStorage that fails after 3 successful appends\n * const failingHot = FailingStorage.makeHotStorage({ failAfterN: 3, failAppend: true });\n * ```\n */\nimport { Effect, Layer, Ref, HashMap } from \"effect\";\nimport { ColdStorageTag, type ColdStorage } from \"../ColdStorage\";\nimport { HotStorageTag, type HotStorage } from \"../HotStorage\";\nimport { ColdStorageError, HotStorageError } from \"../Errors\";\nimport type { StoredDocument, WalEntry } from \"../Types\";\n\n// =============================================================================\n// Configuration Types\n// =============================================================================\n\n/**\n * Configuration for failing ColdStorage\n */\nexport interface FailingColdStorageConfig {\n /** Fail load operations */\n readonly failLoad?: boolean;\n /** Fail save operations */\n readonly failSave?: boolean;\n /** Fail delete operations */\n readonly failDelete?: boolean;\n /** Fail after N successful operations (total across all operation types) */\n readonly failAfterN?: number;\n /** Custom error message */\n readonly errorMessage?: string;\n}\n\n/**\n * Configuration for failing HotStorage\n */\nexport interface FailingHotStorageConfig {\n /** Fail append operations */\n readonly failAppend?: boolean;\n /** Fail getEntries operations */\n readonly failGetEntries?: boolean;\n /** Fail truncate operations */\n readonly failTruncate?: boolean;\n /** Fail after N successful operations (total across all operation types) */\n readonly failAfterN?: number;\n /** Custom error message */\n readonly errorMessage?: string;\n}\n\n// =============================================================================\n// Failing ColdStorage\n// =============================================================================\n\n/**\n * Create a ColdStorage layer that simulates failures.\n * Wraps an in-memory storage and fails according to configuration.\n */\nexport const makeColdStorage = (\n config: FailingColdStorageConfig = {}\n): Layer.Layer<ColdStorageTag> =>\n Layer.effect(\n ColdStorageTag,\n Effect.gen(function* () {\n const store = yield* Ref.make(HashMap.empty<string, StoredDocument>());\n const operationCount = yield* Ref.make(0);\n\n const errorMessage = config.errorMessage ?? \"Simulated storage failure\";\n\n const shouldFail = (operation: \"load\" | \"save\" | \"delete\") =>\n Effect.gen(function* () {\n // Check if this specific operation should fail\n const opFails =\n (operation === \"load\" && config.failLoad) ||\n (operation === \"save\" && config.failSave) ||\n (operation === \"delete\" && config.failDelete);\n\n // If failAfterN is set, count operations first\n if (config.failAfterN !== undefined) {\n const count = yield* Ref.get(operationCount);\n yield* Ref.update(operationCount, (n) => n + 1);\n\n // Only start failing after N successful operations\n if (count < config.failAfterN) {\n return false;\n }\n // After N operations, fail if the specific op flag is set\n return opFails;\n }\n\n // No failAfterN - fail immediately if op flag is set\n return opFails;\n });\n\n const storage: ColdStorage = {\n load: (documentId) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"load\");\n if (fail) {\n return yield* Effect.fail(\n new ColdStorageError({\n documentId,\n operation: \"load\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n const current = yield* Ref.get(store);\n const doc = HashMap.get(current, documentId);\n return doc._tag === \"Some\" ? doc.value : undefined;\n }),\n\n save: (documentId, document) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"save\");\n if (fail) {\n return yield* Effect.fail(\n new ColdStorageError({\n documentId,\n operation: \"save\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n yield* Ref.update(store, (map) =>\n HashMap.set(map, documentId, document)\n );\n }),\n\n delete: (documentId) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"delete\");\n if (fail) {\n return yield* Effect.fail(\n new ColdStorageError({\n documentId,\n operation: \"delete\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n yield* Ref.update(store, (map) => HashMap.remove(map, documentId));\n }),\n };\n\n return storage;\n })\n );\n\n// =============================================================================\n// Failing HotStorage\n// =============================================================================\n\n/**\n * Create a HotStorage layer that simulates failures.\n * Wraps an in-memory storage and fails according to configuration.\n */\nexport const makeHotStorage = (\n config: FailingHotStorageConfig = {}\n): Layer.Layer<HotStorageTag> =>\n Layer.effect(\n HotStorageTag,\n Effect.gen(function* () {\n const store = yield* Ref.make(HashMap.empty<string, WalEntry[]>());\n const operationCount = yield* Ref.make(0);\n\n const errorMessage = config.errorMessage ?? \"Simulated storage failure\";\n\n const shouldFail = (operation: \"append\" | \"getEntries\" | \"truncate\") =>\n Effect.gen(function* () {\n // Check if this specific operation should fail\n const opFails =\n (operation === \"append\" && config.failAppend) ||\n (operation === \"getEntries\" && config.failGetEntries) ||\n (operation === \"truncate\" && config.failTruncate);\n\n // If failAfterN is set, count operations first\n if (config.failAfterN !== undefined) {\n const count = yield* Ref.get(operationCount);\n yield* Ref.update(operationCount, (n) => n + 1);\n\n // Only start failing after N successful operations\n if (count < config.failAfterN) {\n return false;\n }\n // After N operations, fail if the specific op flag is set\n return opFails;\n }\n\n // No failAfterN - fail immediately if op flag is set\n return opFails;\n });\n\n const storage: HotStorage = {\n append: (documentId, entry) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"append\");\n if (fail) {\n return yield* Effect.fail(\n new HotStorageError({\n documentId,\n operation: \"append\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n yield* Ref.update(store, (map) => {\n const current = HashMap.get(map, documentId);\n const entries = current._tag === \"Some\" ? current.value : [];\n return HashMap.set(map, documentId, [...entries, entry]);\n });\n }),\n\n getEntries: (documentId, sinceVersion) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"getEntries\");\n if (fail) {\n return yield* Effect.fail(\n new HotStorageError({\n documentId,\n operation: \"getEntries\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n const current = yield* Ref.get(store);\n const existing = HashMap.get(current, documentId);\n const entries = existing._tag === \"Some\" ? existing.value : [];\n\n return entries\n .filter((e) => e.version > sinceVersion)\n .sort((a, b) => a.version - b.version);\n }),\n\n truncate: (documentId, upToVersion) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"truncate\");\n if (fail) {\n return yield* Effect.fail(\n new HotStorageError({\n documentId,\n operation: \"truncate\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n yield* Ref.update(store, (map) => {\n const existing = HashMap.get(map, documentId);\n if (existing._tag === \"None\") {\n return map;\n }\n const filtered = existing.value.filter(\n (e) => e.version > upToVersion\n );\n return HashMap.set(map, documentId, filtered);\n });\n }),\n };\n\n return storage;\n })\n );\n\n// =============================================================================\n// Export Namespace\n// =============================================================================\n\nexport const FailingStorage = {\n makeColdStorage,\n makeHotStorage,\n};\n"],"mappings":";;;;;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,QAAO,OAAO,OAAO,KACnB,IAAI,gBAAgB;IAClB;IACA,WAAW;IACX,OAAO,IAAI,MAAM,aAAa;IAC/B,CAAC,CACH;GAGH,MAAM,UAAU,OAAO,IAAI,IAAI,MAAM;GACrC,MAAM,WAAW,QAAQ,IAAI,SAAS,WAAW;AAGjD,WAFgB,SAAS,SAAS,SAAS,SAAS,QAAQ,EAAE,EAG3D,QAAQ,MAAM,EAAE,UAAU,aAAa,CACvC,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,QAAQ;IACxC;EAEJ,WAAW,YAAY,gBACrB,OAAO,IAAI,aAAa;AAEtB,OADa,OAAO,WAAW,WAAW,CAExC,QAAO,OAAO,OAAO,KACnB,IAAI,gBAAgB;IAClB;IACA,WAAW;IACX,OAAO,IAAI,MAAM,aAAa;IAC/B,CAAC,CACH;AAGH,UAAO,IAAI,OAAO,QAAQ,QAAQ;IAChC,MAAM,WAAW,QAAQ,IAAI,KAAK,WAAW;AAC7C,QAAI,SAAS,SAAS,OACpB,QAAO;IAET,MAAM,WAAW,SAAS,MAAM,QAC7B,MAAM,EAAE,UAAU,YACpB;AACD,WAAO,QAAQ,IAAI,KAAK,YAAY,SAAS;KAC7C;IACF;EACL;EAGD,CACH;AAMH,MAAa,iBAAiB;CAC5B;CACA;CACD"}
|
|
1
|
+
{"version":3,"file":"FailingStorage.mjs","names":["result: CheckResult"],"sources":["../../src/testing/FailingStorage.ts"],"sourcesContent":["/**\n * @voidhash/mimic-effect/testing - FailingStorage\n *\n * Mock storage implementations that simulate failures for testing error handling.\n * Use these to verify that your application correctly handles storage unavailability.\n *\n * @example\n * ```typescript\n * import { FailingStorage } from \"@voidhash/mimic-effect/testing\";\n *\n * // Create a ColdStorage that fails on load\n * const failingCold = FailingStorage.makeColdStorage({ failLoad: true });\n *\n * // Create a HotStorage that fails after 3 successful appends\n * const failingHot = FailingStorage.makeHotStorage({ failAfterN: 3, failAppend: true });\n * ```\n */\nimport { Effect, Layer, Ref, HashMap } from \"effect\";\nimport { ColdStorageTag, type ColdStorage } from \"../ColdStorage\";\nimport { HotStorageTag, type HotStorage } from \"../HotStorage\";\nimport { ColdStorageError, HotStorageError, WalVersionGapError } from \"../Errors\";\nimport type { StoredDocument, WalEntry } from \"../Types\";\n\n// =============================================================================\n// Configuration Types\n// =============================================================================\n\n/**\n * Configuration for failing ColdStorage\n */\nexport interface FailingColdStorageConfig {\n /** Fail load operations */\n readonly failLoad?: boolean;\n /** Fail save operations */\n readonly failSave?: boolean;\n /** Fail delete operations */\n readonly failDelete?: boolean;\n /** Fail after N successful operations (total across all operation types) */\n readonly failAfterN?: number;\n /** Custom error message */\n readonly errorMessage?: string;\n}\n\n/**\n * Configuration for failing HotStorage\n */\nexport interface FailingHotStorageConfig {\n /** Fail append operations */\n readonly failAppend?: boolean;\n /** Fail getEntries operations */\n readonly failGetEntries?: boolean;\n /** Fail truncate operations */\n readonly failTruncate?: boolean;\n /** Fail after N successful operations (total across all operation types) */\n readonly failAfterN?: number;\n /** Custom error message */\n readonly errorMessage?: string;\n}\n\n// =============================================================================\n// Failing ColdStorage\n// =============================================================================\n\n/**\n * Create a ColdStorage layer that simulates failures.\n * Wraps an in-memory storage and fails according to configuration.\n */\nexport const makeColdStorage = (\n config: FailingColdStorageConfig = {}\n): Layer.Layer<ColdStorageTag> =>\n Layer.effect(\n ColdStorageTag,\n Effect.gen(function* () {\n const store = yield* Ref.make(HashMap.empty<string, StoredDocument>());\n const operationCount = yield* Ref.make(0);\n\n const errorMessage = config.errorMessage ?? \"Simulated storage failure\";\n\n const shouldFail = (operation: \"load\" | \"save\" | \"delete\") =>\n Effect.gen(function* () {\n // Check if this specific operation should fail\n const opFails =\n (operation === \"load\" && config.failLoad) ||\n (operation === \"save\" && config.failSave) ||\n (operation === \"delete\" && config.failDelete);\n\n // If failAfterN is set, count operations first\n if (config.failAfterN !== undefined) {\n const count = yield* Ref.get(operationCount);\n yield* Ref.update(operationCount, (n) => n + 1);\n\n // Only start failing after N successful operations\n if (count < config.failAfterN) {\n return false;\n }\n // After N operations, fail if the specific op flag is set\n return opFails;\n }\n\n // No failAfterN - fail immediately if op flag is set\n return opFails;\n });\n\n const storage: ColdStorage = {\n load: (documentId) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"load\");\n if (fail) {\n return yield* Effect.fail(\n new ColdStorageError({\n documentId,\n operation: \"load\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n const current = yield* Ref.get(store);\n const doc = HashMap.get(current, documentId);\n return doc._tag === \"Some\" ? doc.value : undefined;\n }),\n\n save: (documentId, document) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"save\");\n if (fail) {\n return yield* Effect.fail(\n new ColdStorageError({\n documentId,\n operation: \"save\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n yield* Ref.update(store, (map) =>\n HashMap.set(map, documentId, document)\n );\n }),\n\n delete: (documentId) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"delete\");\n if (fail) {\n return yield* Effect.fail(\n new ColdStorageError({\n documentId,\n operation: \"delete\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n yield* Ref.update(store, (map) => HashMap.remove(map, documentId));\n }),\n };\n\n return storage;\n })\n );\n\n// =============================================================================\n// Failing HotStorage\n// =============================================================================\n\n/**\n * Create a HotStorage layer that simulates failures.\n * Wraps an in-memory storage and fails according to configuration.\n */\nexport const makeHotStorage = (\n config: FailingHotStorageConfig = {}\n): Layer.Layer<HotStorageTag> =>\n Layer.effect(\n HotStorageTag,\n Effect.gen(function* () {\n const store = yield* Ref.make(HashMap.empty<string, WalEntry[]>());\n const operationCount = yield* Ref.make(0);\n\n const errorMessage = config.errorMessage ?? \"Simulated storage failure\";\n\n const shouldFail = (operation: \"append\" | \"getEntries\" | \"truncate\") =>\n Effect.gen(function* () {\n // Check if this specific operation should fail\n const opFails =\n (operation === \"append\" && config.failAppend) ||\n (operation === \"getEntries\" && config.failGetEntries) ||\n (operation === \"truncate\" && config.failTruncate);\n\n // If failAfterN is set, count operations first\n if (config.failAfterN !== undefined) {\n const count = yield* Ref.get(operationCount);\n yield* Ref.update(operationCount, (n) => n + 1);\n\n // Only start failing after N successful operations\n if (count < config.failAfterN) {\n return false;\n }\n // After N operations, fail if the specific op flag is set\n return opFails;\n }\n\n // No failAfterN - fail immediately if op flag is set\n return opFails;\n });\n\n const storage: HotStorage = {\n append: (documentId, entry) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"append\");\n if (fail) {\n return yield* Effect.fail(\n new HotStorageError({\n documentId,\n operation: \"append\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n yield* Ref.update(store, (map) => {\n const current = HashMap.get(map, documentId);\n const entries = current._tag === \"Some\" ? current.value : [];\n return HashMap.set(map, documentId, [...entries, entry]);\n });\n }),\n\n appendWithCheck: (documentId, entry, expectedVersion) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"append\");\n if (fail) {\n return yield* Effect.fail(\n new HotStorageError({\n documentId,\n operation: \"appendWithCheck\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n type CheckResult =\n | { type: \"ok\" }\n | { type: \"gap\"; lastVersion: number | undefined };\n\n const result: CheckResult = yield* Ref.modify(store, (map): [CheckResult, HashMap.HashMap<string, WalEntry[]>] => {\n const existing = HashMap.get(map, documentId);\n const entries = existing._tag === \"Some\" ? existing.value : [];\n\n const lastVersion = entries.length > 0\n ? Math.max(...entries.map((e) => e.version))\n : 0;\n\n if (expectedVersion === 1) {\n if (lastVersion >= 1) {\n return [{ type: \"gap\", lastVersion }, map];\n }\n } else {\n if (lastVersion !== expectedVersion - 1) {\n return [{ type: \"gap\", lastVersion: lastVersion > 0 ? lastVersion : undefined }, map];\n }\n }\n\n return [\n { type: \"ok\" },\n HashMap.set(map, documentId, [...entries, entry]),\n ];\n });\n\n if (result.type === \"gap\") {\n return yield* Effect.fail(\n new WalVersionGapError({\n documentId,\n expectedVersion,\n actualPreviousVersion: result.lastVersion,\n })\n );\n }\n }),\n\n getEntries: (documentId, sinceVersion) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"getEntries\");\n if (fail) {\n return yield* Effect.fail(\n new HotStorageError({\n documentId,\n operation: \"getEntries\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n const current = yield* Ref.get(store);\n const existing = HashMap.get(current, documentId);\n const entries = existing._tag === \"Some\" ? existing.value : [];\n\n return entries\n .filter((e) => e.version > sinceVersion)\n .sort((a, b) => a.version - b.version);\n }),\n\n truncate: (documentId, upToVersion) =>\n Effect.gen(function* () {\n const fail = yield* shouldFail(\"truncate\");\n if (fail) {\n return yield* Effect.fail(\n new HotStorageError({\n documentId,\n operation: \"truncate\",\n cause: new Error(errorMessage),\n })\n );\n }\n\n yield* Ref.update(store, (map) => {\n const existing = HashMap.get(map, documentId);\n if (existing._tag === \"None\") {\n return map;\n }\n const filtered = existing.value.filter(\n (e) => e.version > upToVersion\n );\n return HashMap.set(map, documentId, filtered);\n });\n }),\n };\n\n return storage;\n })\n );\n\n// =============================================================================\n// Export Namespace\n// =============================================================================\n\nexport const FailingStorage = {\n makeColdStorage,\n makeHotStorage,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa,mBACX,SAAmC,EAAE,KAErC,MAAM,OACJ,gBACA,OAAO,IAAI,aAAa;;CACtB,MAAM,QAAQ,OAAO,IAAI,KAAK,QAAQ,OAA+B,CAAC;CACtE,MAAM,iBAAiB,OAAO,IAAI,KAAK,EAAE;CAEzC,MAAM,uCAAe,OAAO,mFAAgB;CAE5C,MAAM,cAAc,cAClB,OAAO,IAAI,aAAa;EAEtB,MAAM,UACH,cAAc,UAAU,OAAO,YAC/B,cAAc,UAAU,OAAO,YAC/B,cAAc,YAAY,OAAO;AAGpC,MAAI,OAAO,eAAe,QAAW;GACnC,MAAM,QAAQ,OAAO,IAAI,IAAI,eAAe;AAC5C,UAAO,IAAI,OAAO,iBAAiB,MAAM,IAAI,EAAE;AAG/C,OAAI,QAAQ,OAAO,WACjB,Q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correctly implements the HotStorage interface
|
|
12
12
|
* and can reliably store/retrieve WAL entries for document recovery.
|
|
13
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 = _voidhash_mimic.OperationDefinition.make({
|
|
19
|
+
kind: "test.set",
|
|
20
|
+
payload: effect.Schema.Unknown,
|
|
21
|
+
target: effect.Schema.Unknown,
|
|
22
|
+
apply: (payload) => payload
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Custom operation definition for testing operation kind preservation.
|
|
26
|
+
*/
|
|
27
|
+
const CustomOpDefinition = _voidhash_mimic.OperationDefinition.make({
|
|
28
|
+
kind: "custom.operation",
|
|
29
|
+
payload: effect.Schema.Unknown,
|
|
30
|
+
target: effect.Schema.Unknown,
|
|
31
|
+
apply: (payload) => payload
|
|
32
|
+
});
|
|
14
33
|
const Categories = {
|
|
15
34
|
BasicOperations: "Basic Operations",
|
|
16
35
|
VersionFiltering: "Version Filtering",
|
|
@@ -20,7 +39,8 @@ const Categories = {
|
|
|
20
39
|
DocumentIsolation: "Document Isolation",
|
|
21
40
|
LargeScaleOperations: "Large-Scale Operations",
|
|
22
41
|
DocumentIdEdgeCases: "Document ID Edge Cases",
|
|
23
|
-
GapChecking: "Gap Checking"
|
|
42
|
+
GapChecking: "Gap Checking",
|
|
43
|
+
TransactionEncoding: "Transaction Encoding"
|
|
24
44
|
};
|
|
25
45
|
const makeEntry = (version, timestamp) => ({
|
|
26
46
|
transaction: _voidhash_mimic.Transaction.make([]),
|
|
@@ -28,11 +48,12 @@ const makeEntry = (version, timestamp) => ({
|
|
|
28
48
|
timestamp: timestamp !== null && timestamp !== void 0 ? timestamp : Date.now()
|
|
29
49
|
});
|
|
30
50
|
const makeEntryWithData = (version, data, timestamp) => ({
|
|
31
|
-
transaction: _voidhash_mimic.Transaction.make([
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
transaction: _voidhash_mimic.Transaction.make([_voidhash_mimic.Operation.fromDefinition(_voidhash_mimic.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: _voidhash_mimic.Transaction.make([_voidhash_mimic.Operation.fromDefinition(_voidhash_mimic.OperationPath.make(pathString), TestSetDefinition, payload)]),
|
|
36
57
|
version,
|
|
37
58
|
timestamp: timestamp !== null && timestamp !== void 0 ? timestamp : Date.now()
|
|
38
59
|
});
|
|
@@ -542,6 +563,232 @@ const tests = [
|
|
|
542
563
|
yield* require_assertions.assertEqual(entries[0].version, 3, "First should be version 3");
|
|
543
564
|
yield* require_assertions.assertEqual(entries[1].version, 4, "Second should be version 4");
|
|
544
565
|
})
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: "OperationPath has _tag after roundtrip",
|
|
569
|
+
category: Categories.TransactionEncoding,
|
|
570
|
+
run: effect.Effect.gen(function* () {
|
|
571
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
572
|
+
const entry = makeEntryWithPath(1, "users/0/name", "Alice");
|
|
573
|
+
yield* storage.append("op-path-tag", entry);
|
|
574
|
+
const entries = yield* storage.getEntries("op-path-tag", 0);
|
|
575
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
576
|
+
const op = entries[0].transaction.ops[0];
|
|
577
|
+
yield* require_assertions.assertTrue(op.path._tag === "OperationPath", "path should have _tag 'OperationPath'");
|
|
578
|
+
})
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
name: "OperationPath.toTokens() works after roundtrip",
|
|
582
|
+
category: Categories.TransactionEncoding,
|
|
583
|
+
run: effect.Effect.gen(function* () {
|
|
584
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
585
|
+
const entry = makeEntryWithPath(1, "users/0/name", "Alice");
|
|
586
|
+
yield* storage.append("op-path-tokens", entry);
|
|
587
|
+
const entries = yield* storage.getEntries("op-path-tokens", 0);
|
|
588
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
589
|
+
const op = entries[0].transaction.ops[0];
|
|
590
|
+
yield* require_assertions.assertTrue(typeof op.path.toTokens === "function", "path.toTokens should be a function");
|
|
591
|
+
yield* require_assertions.assertEqual(op.path.toTokens(), [
|
|
592
|
+
"users",
|
|
593
|
+
"0",
|
|
594
|
+
"name"
|
|
595
|
+
], "toTokens() should return correct path tokens");
|
|
596
|
+
})
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
name: "OperationPath.concat() works after roundtrip",
|
|
600
|
+
category: Categories.TransactionEncoding,
|
|
601
|
+
run: effect.Effect.gen(function* () {
|
|
602
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
603
|
+
const entry = makeEntryWithPath(1, "users/0", { name: "Alice" });
|
|
604
|
+
yield* storage.append("op-path-concat", entry);
|
|
605
|
+
const entries = yield* storage.getEntries("op-path-concat", 0);
|
|
606
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
607
|
+
const op = entries[0].transaction.ops[0];
|
|
608
|
+
yield* require_assertions.assertTrue(typeof op.path.concat === "function", "path.concat should be a function");
|
|
609
|
+
yield* require_assertions.assertEqual(op.path.concat(_voidhash_mimic.OperationPath.make("name")).toTokens(), [
|
|
610
|
+
"users",
|
|
611
|
+
"0",
|
|
612
|
+
"name"
|
|
613
|
+
], "concat() should work correctly");
|
|
614
|
+
})
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
name: "OperationPath.append() works after roundtrip",
|
|
618
|
+
category: Categories.TransactionEncoding,
|
|
619
|
+
run: effect.Effect.gen(function* () {
|
|
620
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
621
|
+
const entry = makeEntryWithPath(1, "users", []);
|
|
622
|
+
yield* storage.append("op-path-append", entry);
|
|
623
|
+
const entries = yield* storage.getEntries("op-path-append", 0);
|
|
624
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
625
|
+
const op = entries[0].transaction.ops[0];
|
|
626
|
+
yield* require_assertions.assertTrue(typeof op.path.append === "function", "path.append should be a function");
|
|
627
|
+
yield* require_assertions.assertEqual(op.path.append("0").toTokens(), ["users", "0"], "append() should work correctly");
|
|
628
|
+
})
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
name: "OperationPath.pop() works after roundtrip",
|
|
632
|
+
category: Categories.TransactionEncoding,
|
|
633
|
+
run: effect.Effect.gen(function* () {
|
|
634
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
635
|
+
const entry = makeEntryWithPath(1, "users/0/name", "Alice");
|
|
636
|
+
yield* storage.append("op-path-pop", entry);
|
|
637
|
+
const entries = yield* storage.getEntries("op-path-pop", 0);
|
|
638
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
639
|
+
const op = entries[0].transaction.ops[0];
|
|
640
|
+
yield* require_assertions.assertTrue(typeof op.path.pop === "function", "path.pop should be a function");
|
|
641
|
+
yield* require_assertions.assertEqual(op.path.pop().toTokens(), ["users", "0"], "pop() should remove last token");
|
|
642
|
+
})
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
name: "OperationPath.shift() works after roundtrip",
|
|
646
|
+
category: Categories.TransactionEncoding,
|
|
647
|
+
run: effect.Effect.gen(function* () {
|
|
648
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
649
|
+
const entry = makeEntryWithPath(1, "users/0/name", "Alice");
|
|
650
|
+
yield* storage.append("op-path-shift", entry);
|
|
651
|
+
const entries = yield* storage.getEntries("op-path-shift", 0);
|
|
652
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
653
|
+
const op = entries[0].transaction.ops[0];
|
|
654
|
+
yield* require_assertions.assertTrue(typeof op.path.shift === "function", "path.shift should be a function");
|
|
655
|
+
yield* require_assertions.assertEqual(op.path.shift().toTokens(), ["0", "name"], "shift() should remove first token");
|
|
656
|
+
})
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
name: "transaction with multiple operations preserves all OperationPaths",
|
|
660
|
+
category: Categories.TransactionEncoding,
|
|
661
|
+
run: effect.Effect.gen(function* () {
|
|
662
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
663
|
+
const entry = {
|
|
664
|
+
transaction: _voidhash_mimic.Transaction.make([
|
|
665
|
+
_voidhash_mimic.Operation.fromDefinition(_voidhash_mimic.OperationPath.make("users/0/name"), TestSetDefinition, "Alice"),
|
|
666
|
+
_voidhash_mimic.Operation.fromDefinition(_voidhash_mimic.OperationPath.make("users/1/name"), TestSetDefinition, "Bob"),
|
|
667
|
+
_voidhash_mimic.Operation.fromDefinition(_voidhash_mimic.OperationPath.make("count"), TestSetDefinition, 2)
|
|
668
|
+
]),
|
|
669
|
+
version: 1,
|
|
670
|
+
timestamp: Date.now()
|
|
671
|
+
};
|
|
672
|
+
yield* storage.append("multi-op-paths", entry);
|
|
673
|
+
const entries = yield* storage.getEntries("multi-op-paths", 0);
|
|
674
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
675
|
+
const ops = entries[0].transaction.ops;
|
|
676
|
+
yield* require_assertions.assertLength([...ops], 3, "Should have 3 operations");
|
|
677
|
+
for (const op of ops) {
|
|
678
|
+
yield* require_assertions.assertTrue(op.path._tag === "OperationPath", "Each operation path should have _tag");
|
|
679
|
+
yield* require_assertions.assertTrue(typeof op.path.toTokens === "function", "Each operation path should have toTokens method");
|
|
680
|
+
}
|
|
681
|
+
yield* require_assertions.assertEqual(ops[0].path.toTokens(), [
|
|
682
|
+
"users",
|
|
683
|
+
"0",
|
|
684
|
+
"name"
|
|
685
|
+
], "First path should be correct");
|
|
686
|
+
yield* require_assertions.assertEqual(ops[1].path.toTokens(), [
|
|
687
|
+
"users",
|
|
688
|
+
"1",
|
|
689
|
+
"name"
|
|
690
|
+
], "Second path should be correct");
|
|
691
|
+
yield* require_assertions.assertEqual(ops[2].path.toTokens(), ["count"], "Third path should be correct");
|
|
692
|
+
})
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
name: "nested path with many segments survives roundtrip",
|
|
696
|
+
category: Categories.TransactionEncoding,
|
|
697
|
+
run: effect.Effect.gen(function* () {
|
|
698
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
699
|
+
const entry = makeEntryWithPath(1, "level1/level2/level3/level4/level5", "deep value");
|
|
700
|
+
yield* storage.append("deep-path", entry);
|
|
701
|
+
const entries = yield* storage.getEntries("deep-path", 0);
|
|
702
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
703
|
+
const op = entries[0].transaction.ops[0];
|
|
704
|
+
yield* require_assertions.assertEqual(op.path.toTokens(), [
|
|
705
|
+
"level1",
|
|
706
|
+
"level2",
|
|
707
|
+
"level3",
|
|
708
|
+
"level4",
|
|
709
|
+
"level5"
|
|
710
|
+
], "Deep nested path should survive roundtrip");
|
|
711
|
+
})
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
name: "empty path survives roundtrip",
|
|
715
|
+
category: Categories.TransactionEncoding,
|
|
716
|
+
run: effect.Effect.gen(function* () {
|
|
717
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
718
|
+
const entry = makeEntryWithPath(1, "", { root: true });
|
|
719
|
+
yield* storage.append("empty-path", entry);
|
|
720
|
+
const entries = yield* storage.getEntries("empty-path", 0);
|
|
721
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
722
|
+
const op = entries[0].transaction.ops[0];
|
|
723
|
+
yield* require_assertions.assertTrue(op.path._tag === "OperationPath", "Empty path should still be OperationPath");
|
|
724
|
+
yield* require_assertions.assertTrue(typeof op.path.toTokens === "function", "Empty path should have toTokens method");
|
|
725
|
+
})
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
name: "transaction id is preserved after roundtrip",
|
|
729
|
+
category: Categories.TransactionEncoding,
|
|
730
|
+
run: effect.Effect.gen(function* () {
|
|
731
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
732
|
+
const entry = makeEntryWithPath(1, "test", "value");
|
|
733
|
+
const originalId = entry.transaction.id;
|
|
734
|
+
yield* storage.append("tx-id-preserve", entry);
|
|
735
|
+
const entries = yield* storage.getEntries("tx-id-preserve", 0);
|
|
736
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
737
|
+
yield* require_assertions.assertEqual(entries[0].transaction.id, originalId, "Transaction id should be preserved");
|
|
738
|
+
})
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
name: "transaction timestamp is preserved after roundtrip",
|
|
742
|
+
category: Categories.TransactionEncoding,
|
|
743
|
+
run: effect.Effect.gen(function* () {
|
|
744
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
745
|
+
const entry = makeEntryWithPath(1, "test", "value");
|
|
746
|
+
const originalTimestamp = entry.transaction.timestamp;
|
|
747
|
+
yield* storage.append("tx-timestamp-preserve", entry);
|
|
748
|
+
const entries = yield* storage.getEntries("tx-timestamp-preserve", 0);
|
|
749
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
750
|
+
yield* require_assertions.assertEqual(entries[0].transaction.timestamp, originalTimestamp, "Transaction timestamp should be preserved");
|
|
751
|
+
})
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
name: "operation kind is preserved after roundtrip",
|
|
755
|
+
category: Categories.TransactionEncoding,
|
|
756
|
+
run: effect.Effect.gen(function* () {
|
|
757
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
758
|
+
const entry = {
|
|
759
|
+
transaction: _voidhash_mimic.Transaction.make([_voidhash_mimic.Operation.fromDefinition(_voidhash_mimic.OperationPath.make("data"), CustomOpDefinition, "test")]),
|
|
760
|
+
version: 1,
|
|
761
|
+
timestamp: Date.now()
|
|
762
|
+
};
|
|
763
|
+
yield* storage.append("op-kind-preserve", entry);
|
|
764
|
+
const entries = yield* storage.getEntries("op-kind-preserve", 0);
|
|
765
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
766
|
+
yield* require_assertions.assertEqual(entries[0].transaction.ops[0].kind, "custom.operation", "Operation kind should be preserved");
|
|
767
|
+
})
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
name: "operation payload with complex object survives roundtrip",
|
|
771
|
+
category: Categories.TransactionEncoding,
|
|
772
|
+
run: effect.Effect.gen(function* () {
|
|
773
|
+
const storage = yield* require_HotStorage.HotStorageTag;
|
|
774
|
+
const complexPayload = {
|
|
775
|
+
nested: {
|
|
776
|
+
value: 42,
|
|
777
|
+
array: [
|
|
778
|
+
1,
|
|
779
|
+
2,
|
|
780
|
+
3
|
|
781
|
+
]
|
|
782
|
+
},
|
|
783
|
+
nullValue: null,
|
|
784
|
+
string: "test"
|
|
785
|
+
};
|
|
786
|
+
const entry = makeEntryWithPath(1, "data", complexPayload);
|
|
787
|
+
yield* storage.append("complex-payload", entry);
|
|
788
|
+
const entries = yield* storage.getEntries("complex-payload", 0);
|
|
789
|
+
yield* require_assertions.assertLength(entries, 1, "Should have one entry");
|
|
790
|
+
yield* require_assertions.assertEqual(entries[0].transaction.ops[0].payload, complexPayload, "Complex payload should survive roundtrip");
|
|
791
|
+
})
|
|
545
792
|
}
|
|
546
793
|
];
|
|
547
794
|
/**
|
|
@@ -19,6 +19,7 @@ declare const Categories: {
|
|
|
19
19
|
readonly LargeScaleOperations: "Large-Scale Operations";
|
|
20
20
|
readonly DocumentIdEdgeCases: "Document ID Edge Cases";
|
|
21
21
|
readonly GapChecking: "Gap Checking";
|
|
22
|
+
readonly TransactionEncoding: "Transaction Encoding";
|
|
22
23
|
};
|
|
23
24
|
declare const HotStorageTestSuite: {
|
|
24
25
|
Categories: {
|
|
@@ -31,6 +32,7 @@ declare const HotStorageTestSuite: {
|
|
|
31
32
|
readonly LargeScaleOperations: "Large-Scale Operations";
|
|
32
33
|
readonly DocumentIdEdgeCases: "Document ID Edge Cases";
|
|
33
34
|
readonly GapChecking: "Gap Checking";
|
|
35
|
+
readonly TransactionEncoding: "Transaction Encoding";
|
|
34
36
|
};
|
|
35
37
|
makeTests: () => StorageTestCase<HotStorageTestError, HotStorageTag>[];
|
|
36
38
|
runAll: () => Effect.Effect<TestResults<HotStorageTestError, HotStorageTag>, never, HotStorageTag>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HotStorageTestSuite.d.cts","names":[],"sources":["../../src/testing/HotStorageTestSuite.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"HotStorageTestSuite.d.cts","names":[],"sources":["../../src/testing/HotStorageTestSuite.ts"],"sourcesContent":[],"mappings":";;;;;;;AA4kCA;;;AAxC6B,KA3gCjB,mBAAA,GAAsB,SA2gCL,GA3gCiB,eA2gCjB,GA3gCmC,kBA2gCnC;AAWf,cAv/BD,UAu/BC,EAAA;EAAqB,SAAA,eAAA,EAAA,kBAAA;EAAjC,SAAA,gBAAA,EAAA,mBAAA;EAEA,SAAA,kBAAA,EAAA,qBAAA;EAHwB,SAAO,mBAAA,EAAA,uBAAA;EAAM,SAAA,iBAAA,EAAA,qBAAA;;;;;;;cA8B1B;;;;;;;;;;;;;mBAxCgB,gBAC3B,qBACA;gBAQwB,MAAA,CAAO,OAC/B,YAAY,qBAAqB,uBAEjC"}
|