@fireproof/core-test 0.23.1 → 0.23.3
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/blockstore/interceptor-gateway.test.js.map +1 -1
- package/blockstore/keyed-crypto-indexeddb-file.test.js.map +1 -1
- package/blockstore/keyed-crypto.test.js.map +1 -1
- package/blockstore/loader.test.js.map +1 -1
- package/blockstore/standalone.test.js.map +1 -1
- package/blockstore/store.test.js.map +1 -1
- package/blockstore/transaction.test.js.map +1 -1
- package/fireproof/all-gateway.test.js.map +1 -1
- package/fireproof/attachable.test.js.map +1 -1
- package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.js.map +1 -1
- package/fireproof/charwise-boolean.test.js.map +1 -1
- package/fireproof/compact-strategy.test.js.map +1 -1
- package/fireproof/concurrent.test.js.map +1 -1
- package/fireproof/crdt.test.js.map +1 -1
- package/fireproof/database.test.js.map +1 -1
- package/fireproof/deleted-docs-handling.test.js.map +1 -1
- package/fireproof/fireproof.test.fixture.js.map +1 -1
- package/fireproof/fireproof.test.js.map +1 -1
- package/fireproof/hello.test.js.map +1 -1
- package/fireproof/indexer.test.js.map +1 -1
- package/fireproof/multiple-ledger.test.js.map +1 -1
- package/fireproof/query-docs.test.js.map +1 -1
- package/fireproof/query-limit-issue.test.js.map +1 -1
- package/fireproof/query-property-inconsistency.test.js.map +1 -1
- package/fireproof/query-result-properties.test.js.map +1 -1
- package/fireproof/stable-cid.test.js.map +1 -1
- package/fireproof/utils.test.js.map +1 -1
- package/gateway/file/loader-config.test.js.map +1 -1
- package/gateway/indexeddb/create-db-on-write.test.js.map +1 -1
- package/gateway/indexeddb/loader-config.test.js.map +1 -1
- package/global-setup.js.map +1 -1
- package/helpers.js.map +1 -1
- package/package.json +18 -18
- package/protocols/cloud/msger.test.js.map +1 -1
- package/runtime/fp-envelope-serialize.test.js.map +1 -1
- package/runtime/key-bag.test.js.map +1 -1
- package/runtime/meta-key-hack.test.js.map +1 -1
- package/setup.file.js.map +1 -1
- package/setup.indexeddb.js.map +1 -1
- package/setup.memory.js.map +1 -1
- package/vitest.config.js.map +1 -1
- package/vitest.file.config.js.map +1 -1
- package/vitest.indexeddb.config.js.map +1 -1
- package/vitest.memory.config.js.map +1 -1
- package/blockstore/fp-envelope.test.ts-off +0 -65
- package/blockstore/fragment-gateway.test.ts-off +0 -106
- package/blockstore/interceptor-gateway.test.ts +0 -259
- package/blockstore/keyed-crypto-indexeddb-file.test.ts +0 -134
- package/blockstore/keyed-crypto.test.ts +0 -381
- package/blockstore/loader.test.ts +0 -313
- package/blockstore/standalone.test.ts +0 -156
- package/blockstore/store.test.ts +0 -199
- package/blockstore/transaction.test.ts +0 -132
- package/fireproof/all-gateway.test.ts +0 -477
- package/fireproof/attachable.test.ts +0 -677
- package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.car +0 -0
- package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +0 -324
- package/fireproof/charwise-boolean.test.ts +0 -68
- package/fireproof/compact-strategy.test.ts +0 -40
- package/fireproof/concurrent.test.ts +0 -37
- package/fireproof/crdt.test.ts +0 -572
- package/fireproof/database.test.ts +0 -772
- package/fireproof/deleted-docs-handling.test.ts +0 -112
- package/fireproof/fireproof.test.fixture.ts +0 -133
- package/fireproof/fireproof.test.ts +0 -767
- package/fireproof/hello.test.ts +0 -75
- package/fireproof/indexer.test.ts +0 -459
- package/fireproof/multiple-ledger.test.ts +0 -67
- package/fireproof/query-docs.test.ts +0 -117
- package/fireproof/query-limit-issue.test.ts +0 -147
- package/fireproof/query-property-inconsistency.test.ts +0 -90
- package/fireproof/query-result-properties.test.ts +0 -43
- package/fireproof/stable-cid.test.ts +0 -72
- package/fireproof/utils.test.ts +0 -137
- package/gateway/file/loader-config.test.ts +0 -309
- package/gateway/indexeddb/create-db-on-write.test.ts +0 -202
- package/gateway/indexeddb/loader-config.test.ts +0 -80
- package/global-setup.ts +0 -11
- package/helpers.ts +0 -177
- package/protocols/cloud/msger.test.ts +0 -559
- package/runtime/fp-envelope-serialize.test.ts +0 -266
- package/runtime/key-bag.test.ts +0 -243
- package/runtime/meta-key-hack.test.ts +0 -103
- package/setup.file.ts +0 -1
- package/setup.indexeddb.ts +0 -0
- package/setup.memory.ts +0 -2
- package/tsconfig.json +0 -18
- package/vitest.config.ts +0 -8
- package/vitest.file.config.ts +0 -11
- package/vitest.indexeddb.config.ts +0 -34
- package/vitest.memory.config.ts +0 -24
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { BuildURI, CoerceURI, runtimeFn, URI } from "@adviser/cement";
|
|
2
|
-
import { fireproof, PARAM, SuperThis } from "@fireproof/core";
|
|
3
|
-
import { mockSuperThis } from "../../helpers.js";
|
|
4
|
-
import { describe, beforeAll, it, expect } from "vitest";
|
|
5
|
-
import { FILESTORE_VERSION, sysFileSystemFactory } from "@fireproof/core-gateways-file";
|
|
6
|
-
|
|
7
|
-
function dataDir(sthis: SuperThis, name?: string, base?: CoerceURI): URI {
|
|
8
|
-
if (!base) {
|
|
9
|
-
const home = sthis.env.get("HOME") || "./";
|
|
10
|
-
base =
|
|
11
|
-
sthis.env.get("FP_STORAGE_URL") ||
|
|
12
|
-
`file://${sthis.pathOps.join(home, ".fireproof", FILESTORE_VERSION.replace(/-.*$/, ""))}?${PARAM.URL_GEN}=default`;
|
|
13
|
-
}
|
|
14
|
-
return URI.from(base.toString())
|
|
15
|
-
.build()
|
|
16
|
-
.setParam(PARAM.NAME, name || "")
|
|
17
|
-
.URI();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const _my_app = "my-app";
|
|
21
|
-
function my_app() {
|
|
22
|
-
return _my_app;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe("config file gateway", () => {
|
|
26
|
-
const sthis = mockSuperThis();
|
|
27
|
-
// const isMemFS: { fs?: string } = {};
|
|
28
|
-
|
|
29
|
-
beforeAll(async () => {
|
|
30
|
-
await sthis.start();
|
|
31
|
-
// const url = URI.from(sthis.env.get("FP_STORAGE_URL"));
|
|
32
|
-
// if (url.getParam("fs") === "mem") {
|
|
33
|
-
// isMemFS.fs = "mem";
|
|
34
|
-
// }
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("loader", async () => {
|
|
38
|
-
const db = fireproof(my_app());
|
|
39
|
-
await db.put({ name: "my-app" });
|
|
40
|
-
expect(db.ledger.name).toBe(my_app());
|
|
41
|
-
|
|
42
|
-
const fileStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.file;
|
|
43
|
-
expect(fileStore?.url().asObj()).toEqual({
|
|
44
|
-
pathname: "./dist/fp-dir-file",
|
|
45
|
-
protocol: "file:",
|
|
46
|
-
searchParams: {
|
|
47
|
-
// ...isMemFS,
|
|
48
|
-
name: "my-app",
|
|
49
|
-
store: "file",
|
|
50
|
-
storekey: "@my-app-data@",
|
|
51
|
-
urlGen: "fromEnv",
|
|
52
|
-
version: "v0.19-file",
|
|
53
|
-
},
|
|
54
|
-
style: "path",
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const dataStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.car;
|
|
58
|
-
expect(dataStore?.url().asObj()).toEqual({
|
|
59
|
-
pathname: "./dist/fp-dir-file",
|
|
60
|
-
protocol: "file:",
|
|
61
|
-
searchParams: {
|
|
62
|
-
// ...isMemFS,
|
|
63
|
-
name: "my-app",
|
|
64
|
-
store: "car",
|
|
65
|
-
suffix: ".car",
|
|
66
|
-
storekey: "@my-app-data@",
|
|
67
|
-
urlGen: "fromEnv",
|
|
68
|
-
version: "v0.19-file",
|
|
69
|
-
},
|
|
70
|
-
style: "path",
|
|
71
|
-
});
|
|
72
|
-
const metaStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.meta;
|
|
73
|
-
expect(metaStore?.url().asObj()).toEqual({
|
|
74
|
-
pathname: "./dist/fp-dir-file",
|
|
75
|
-
protocol: "file:",
|
|
76
|
-
searchParams: {
|
|
77
|
-
// ...isMemFS,
|
|
78
|
-
name: "my-app",
|
|
79
|
-
store: "meta",
|
|
80
|
-
storekey: "@my-app-meta@",
|
|
81
|
-
urlGen: "fromEnv",
|
|
82
|
-
version: "v0.19-file",
|
|
83
|
-
},
|
|
84
|
-
style: "path",
|
|
85
|
-
});
|
|
86
|
-
const WALStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.wal;
|
|
87
|
-
expect(WALStore?.url().asObj()).toEqual({
|
|
88
|
-
pathname: "./dist/fp-dir-file",
|
|
89
|
-
protocol: "file:",
|
|
90
|
-
searchParams: {
|
|
91
|
-
// ...isMemFS,
|
|
92
|
-
name: "my-app",
|
|
93
|
-
store: "wal",
|
|
94
|
-
storekey: "@my-app-wal@",
|
|
95
|
-
urlGen: "fromEnv",
|
|
96
|
-
version: "v0.19-file",
|
|
97
|
-
},
|
|
98
|
-
style: "path",
|
|
99
|
-
});
|
|
100
|
-
await db.close();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("file path", async () => {
|
|
104
|
-
let baseDir = "./dist/data".replace(/\?.*$/, "").replace(/^file:\/\//, "");
|
|
105
|
-
baseDir = sthis.pathOps.join(baseDir, /* testCfg(sthis, "data").version, */ my_app());
|
|
106
|
-
const base = BuildURI.from("./dist/data");
|
|
107
|
-
// if (isMemFS.fs) {
|
|
108
|
-
// base.setParam("fs", isMemFS.fs);
|
|
109
|
-
// }
|
|
110
|
-
const sysfs = await sysFileSystemFactory(base.URI());
|
|
111
|
-
await sysfs.rm(baseDir, { recursive: true }).catch(() => {
|
|
112
|
-
/* */
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const db = fireproof(my_app(), { storeUrls: { base } });
|
|
116
|
-
// console.log(`>>>>>>>>>>>>>>>file-path`)
|
|
117
|
-
await db.put({ name: "my-app" });
|
|
118
|
-
expect(db.ledger.name).toBe(my_app());
|
|
119
|
-
const carStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.car;
|
|
120
|
-
expect(carStore?.url().asObj()).toEqual({
|
|
121
|
-
pathname: "./dist/data",
|
|
122
|
-
protocol: "file:",
|
|
123
|
-
searchParams: {
|
|
124
|
-
// ...isMemFS,
|
|
125
|
-
name: "my-app",
|
|
126
|
-
store: "car",
|
|
127
|
-
storekey: "@my-app-data@",
|
|
128
|
-
suffix: ".car",
|
|
129
|
-
version: "v0.19-file",
|
|
130
|
-
},
|
|
131
|
-
style: "path",
|
|
132
|
-
});
|
|
133
|
-
const fileStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.file;
|
|
134
|
-
expect(fileStore?.url().asObj()).toEqual({
|
|
135
|
-
pathname: "./dist/data",
|
|
136
|
-
protocol: "file:",
|
|
137
|
-
searchParams: {
|
|
138
|
-
// ...isMemFS,
|
|
139
|
-
name: "my-app",
|
|
140
|
-
store: "file",
|
|
141
|
-
storekey: "@my-app-data@",
|
|
142
|
-
version: "v0.19-file",
|
|
143
|
-
},
|
|
144
|
-
style: "path",
|
|
145
|
-
});
|
|
146
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
|
147
|
-
const metaStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.meta;
|
|
148
|
-
expect(metaStore?.url().asObj()).toEqual({
|
|
149
|
-
pathname: "./dist/data",
|
|
150
|
-
protocol: "file:",
|
|
151
|
-
searchParams: {
|
|
152
|
-
// ...isMemFS,
|
|
153
|
-
name: "my-app",
|
|
154
|
-
store: "meta",
|
|
155
|
-
storekey: "@my-app-meta@",
|
|
156
|
-
version: "v0.19-file",
|
|
157
|
-
},
|
|
158
|
-
style: "path",
|
|
159
|
-
});
|
|
160
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
|
|
161
|
-
await db.close();
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("homedir default", async () => {
|
|
165
|
-
const old = sthis.env.get("FP_STORAGE_URL");
|
|
166
|
-
sthis.env.delete("FP_STORAGE_URL");
|
|
167
|
-
// this switches file: protocol not memory:
|
|
168
|
-
let baseDir = dataDir(sthis, my_app()).pathname;
|
|
169
|
-
baseDir = sthis.pathOps.join(baseDir, my_app());
|
|
170
|
-
|
|
171
|
-
const base = BuildURI.from(baseDir);
|
|
172
|
-
// if (isMemFS.fs) {
|
|
173
|
-
// base.setParam("fs", isMemFS.fs);
|
|
174
|
-
// }
|
|
175
|
-
const sysfs = await sysFileSystemFactory(base.URI());
|
|
176
|
-
await sysfs.rm(baseDir, { recursive: true }).catch(() => {
|
|
177
|
-
/* */
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
expect(baseDir).toMatch(new RegExp(`/\\.fireproof/${FILESTORE_VERSION.replace(/-file/, "")}/${my_app()}`));
|
|
181
|
-
|
|
182
|
-
const db = fireproof(my_app());
|
|
183
|
-
await db.put({ name: "my-app" });
|
|
184
|
-
expect(db.ledger.name).toBe(my_app());
|
|
185
|
-
const carStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.car;
|
|
186
|
-
|
|
187
|
-
expect(carStore?.url().asObj()).toEqual({
|
|
188
|
-
pathname: `${sthis.env.get("HOME")}/.fireproof/v0.19`,
|
|
189
|
-
protocol: "file:",
|
|
190
|
-
style: "path",
|
|
191
|
-
searchParams: {
|
|
192
|
-
// ...isMemFS,
|
|
193
|
-
suffix: ".car",
|
|
194
|
-
runtime: runtimeFn().isDeno ? "deno" : "node",
|
|
195
|
-
urlGen: "default",
|
|
196
|
-
store: "car",
|
|
197
|
-
name: my_app(),
|
|
198
|
-
storekey: `@${my_app()}-data@`,
|
|
199
|
-
version: FILESTORE_VERSION,
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
|
204
|
-
|
|
205
|
-
const fileStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.file;
|
|
206
|
-
expect(fileStore?.url().asObj()).toEqual({
|
|
207
|
-
pathname: `${sthis.env.get("HOME")}/.fireproof/v0.19`,
|
|
208
|
-
protocol: "file:",
|
|
209
|
-
style: "path",
|
|
210
|
-
searchParams: {
|
|
211
|
-
// ...isMemFS,
|
|
212
|
-
runtime: runtimeFn().isDeno ? "deno" : "node",
|
|
213
|
-
urlGen: "default",
|
|
214
|
-
store: "file",
|
|
215
|
-
name: my_app(),
|
|
216
|
-
storekey: `@${my_app()}-data@`,
|
|
217
|
-
version: FILESTORE_VERSION,
|
|
218
|
-
},
|
|
219
|
-
});
|
|
220
|
-
const metaStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.meta;
|
|
221
|
-
expect(metaStore?.url().asObj()).toEqual({
|
|
222
|
-
pathname: `${sthis.env.get("HOME")}/.fireproof/v0.19`,
|
|
223
|
-
protocol: "file:",
|
|
224
|
-
style: "path",
|
|
225
|
-
searchParams: {
|
|
226
|
-
// ...isMemFS,
|
|
227
|
-
runtime: runtimeFn().isDeno ? "deno" : "node",
|
|
228
|
-
urlGen: "default",
|
|
229
|
-
store: "meta",
|
|
230
|
-
name: my_app(),
|
|
231
|
-
storekey: `@${my_app()}-meta@`,
|
|
232
|
-
version: FILESTORE_VERSION,
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
|
|
237
|
-
sthis.env.set("FP_STORAGE_URL", old);
|
|
238
|
-
await db.close();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("set by env", async () => {
|
|
242
|
-
const old = sthis.env.get("FP_STORAGE_URL");
|
|
243
|
-
// assert(!old, "FP_STORAGE_URL must set")
|
|
244
|
-
const testUrl = BuildURI.from(old);
|
|
245
|
-
// sthis.env.set("FP_STORAGE_URL", testUrl.toString());
|
|
246
|
-
|
|
247
|
-
let baseDir = dataDir(sthis, my_app()).pathname;
|
|
248
|
-
baseDir = sthis.pathOps.join(baseDir, /* testCfg(sthis, "data").version, */ my_app());
|
|
249
|
-
|
|
250
|
-
const sysfs = await sysFileSystemFactory(testUrl.URI());
|
|
251
|
-
await sysfs.rm(baseDir, { recursive: true }).catch(() => {
|
|
252
|
-
/* */
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
const db = fireproof(my_app());
|
|
256
|
-
await db.put({ name: "my-app" });
|
|
257
|
-
expect(db.ledger.name).toBe(my_app());
|
|
258
|
-
const carStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.car;
|
|
259
|
-
expect(carStore?.url().asObj()).toEqual({
|
|
260
|
-
pathname: "./dist/fp-dir-file",
|
|
261
|
-
protocol: "file:",
|
|
262
|
-
style: "path",
|
|
263
|
-
searchParams: {
|
|
264
|
-
// ...isMemFS,
|
|
265
|
-
urlGen: "fromEnv",
|
|
266
|
-
store: "car",
|
|
267
|
-
// runtime: "node",
|
|
268
|
-
suffix: ".car",
|
|
269
|
-
name: my_app(),
|
|
270
|
-
storekey: `@${my_app()}-data@`,
|
|
271
|
-
version: FILESTORE_VERSION,
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
|
276
|
-
const fileStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.file;
|
|
277
|
-
expect(fileStore?.url().asObj()).toEqual({
|
|
278
|
-
pathname: `./dist/fp-dir-file`,
|
|
279
|
-
protocol: "file:",
|
|
280
|
-
style: "path",
|
|
281
|
-
searchParams: {
|
|
282
|
-
// ...isMemFS,
|
|
283
|
-
urlGen: "fromEnv",
|
|
284
|
-
store: "file",
|
|
285
|
-
name: my_app(),
|
|
286
|
-
storekey: `@${my_app()}-data@`,
|
|
287
|
-
version: FILESTORE_VERSION,
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
const metaStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.meta;
|
|
292
|
-
expect(metaStore?.url().asObj()).toEqual({
|
|
293
|
-
pathname: `./dist/fp-dir-file`,
|
|
294
|
-
protocol: "file:",
|
|
295
|
-
style: "path",
|
|
296
|
-
searchParams: {
|
|
297
|
-
// ...isMemFS,
|
|
298
|
-
urlGen: "fromEnv",
|
|
299
|
-
store: "meta",
|
|
300
|
-
name: my_app(),
|
|
301
|
-
storekey: `@${my_app()}-meta@`,
|
|
302
|
-
version: FILESTORE_VERSION,
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
|
|
306
|
-
await db.close();
|
|
307
|
-
sthis.env.set("FP_STORAGE_URL", old);
|
|
308
|
-
});
|
|
309
|
-
});
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { Database } from "@fireproof/core";
|
|
2
|
-
import { fireproof } from "@fireproof/core-base";
|
|
3
|
-
import { ensureSuperThis } from "@fireproof/core-runtime";
|
|
4
|
-
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
5
|
-
|
|
6
|
-
describe("IndexedDB create on write", () => {
|
|
7
|
-
const sthis = ensureSuperThis();
|
|
8
|
-
|
|
9
|
-
const creating = [
|
|
10
|
-
{
|
|
11
|
-
name: "put",
|
|
12
|
-
action: async (db: Database) => {
|
|
13
|
-
await db.put({ _id: "test", test: "test" });
|
|
14
|
-
// console.log("put", res);
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: "bulk",
|
|
19
|
-
action: async (db: Database) => {
|
|
20
|
-
await db.bulk([{ test: "test" }]);
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const notCreating = [
|
|
26
|
-
{
|
|
27
|
-
name: "onClosed",
|
|
28
|
-
action: async (db: Database) => {
|
|
29
|
-
db.onClosed(() => {
|
|
30
|
-
// console.log("closed");
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
// {
|
|
35
|
-
// name: "attach",
|
|
36
|
-
// action: async (db: Database) => {
|
|
37
|
-
// await db.attach({
|
|
38
|
-
// name: "test",
|
|
39
|
-
// prepare: async () => ({
|
|
40
|
-
// car: { url: "memory://test" },
|
|
41
|
-
// meta: { url: "memory://test" },
|
|
42
|
-
// file: { url: "memory://test" },
|
|
43
|
-
// wal: { url: "memory://test" },
|
|
44
|
-
// }),
|
|
45
|
-
// configHash: async () => "test",
|
|
46
|
-
// });
|
|
47
|
-
// },
|
|
48
|
-
// },
|
|
49
|
-
{
|
|
50
|
-
name: "allDocs",
|
|
51
|
-
action: async (db: Database) => {
|
|
52
|
-
await db.allDocs();
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
name: "get",
|
|
58
|
-
action: async (db: Database) => {
|
|
59
|
-
try {
|
|
60
|
-
await db.get("test");
|
|
61
|
-
} catch (e) {
|
|
62
|
-
// ignore
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: "query",
|
|
68
|
-
action: async (db: Database) => {
|
|
69
|
-
await db.query("test");
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "changes",
|
|
74
|
-
action: async (db: Database) => {
|
|
75
|
-
await db.changes();
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: "compact",
|
|
80
|
-
action: async (db: Database) => {
|
|
81
|
-
await db.compact();
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
// the core write on del in any case
|
|
85
|
-
// this will be a
|
|
86
|
-
// {
|
|
87
|
-
// name: "del",
|
|
88
|
-
// action: async (db: Database) => {
|
|
89
|
-
// await db.del("test-key-never-found");
|
|
90
|
-
// },
|
|
91
|
-
// },
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
describe("action is not creating a db", () => {
|
|
95
|
-
it("del", async () => {
|
|
96
|
-
console.warn(`⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ The Core writes on del currently that should not the case on empty db's`);
|
|
97
|
-
// const dbName = `indexdb-${sthis.nextId().str}`;
|
|
98
|
-
// const db = fireproof(dbName);
|
|
99
|
-
// try {
|
|
100
|
-
// await db.del("test");
|
|
101
|
-
// const idbs = await indexedDB.databases();
|
|
102
|
-
// expect(idbs.find((i) => i.name === `fp.${dbName}`)).not.toBeDefined();
|
|
103
|
-
// } finally {
|
|
104
|
-
// await db.destroy();
|
|
105
|
-
// }
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe("on fresh db", () => {
|
|
109
|
-
const dbName = `indexdb-${sthis.nextId().str}`;
|
|
110
|
-
const db = fireproof(dbName);
|
|
111
|
-
|
|
112
|
-
afterAll(async () => {
|
|
113
|
-
await db.destroy();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it.each(notCreating)("test $name", async (item) => {
|
|
117
|
-
await item.action(db);
|
|
118
|
-
const idbs = await indexedDB.databases();
|
|
119
|
-
// console.log("idbs", idbs, dbName);
|
|
120
|
-
expect(idbs.find((i) => i.name === `fp.${dbName}`)).not.toBeDefined();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
describe("action is creating a db", () => {
|
|
126
|
-
it.each(creating)("test $name", async (item) => {
|
|
127
|
-
const dbName = `indexdb-${sthis.nextId().str}`;
|
|
128
|
-
const db = fireproof(dbName);
|
|
129
|
-
try {
|
|
130
|
-
await item.action(db);
|
|
131
|
-
const idbs = await indexedDB.databases();
|
|
132
|
-
// console.log("idbs", idbs, dbName);
|
|
133
|
-
expect(idbs.find((i) => i.name === `fp.${dbName}`)).toBeDefined();
|
|
134
|
-
} finally {
|
|
135
|
-
await db.destroy();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
describe("combine not and creating", () => {
|
|
141
|
-
const dbName = `indexdb-${sthis.nextId().str}`;
|
|
142
|
-
let db = fireproof(dbName);
|
|
143
|
-
|
|
144
|
-
afterAll(async () => {
|
|
145
|
-
await db.destroy();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe("on fresh db", () => {
|
|
149
|
-
it.each(notCreating)("not creating $name", async (item) => {
|
|
150
|
-
await item.action(db);
|
|
151
|
-
const idbs = await indexedDB.databases();
|
|
152
|
-
// console.log("idbs", idbs, dbName);
|
|
153
|
-
expect(idbs.find((i) => i.name === `fp.${dbName}`)).not.toBeDefined();
|
|
154
|
-
});
|
|
155
|
-
it.each(creating)("creating $name", async (item) => {
|
|
156
|
-
await item.action(db);
|
|
157
|
-
const idbs = await indexedDB.databases();
|
|
158
|
-
// console.log("idbs", idbs, dbName);
|
|
159
|
-
expect(idbs.find((i) => i.name === `fp.${dbName}`)).toBeDefined();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("simple get", async () => {
|
|
163
|
-
const doc = await db.get("test");
|
|
164
|
-
expect(doc).toEqual({
|
|
165
|
-
_id: "test",
|
|
166
|
-
test: "test",
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
it.each(notCreating)("was created $name", async (item) => {
|
|
170
|
-
await item.action(db);
|
|
171
|
-
const idbs = await indexedDB.databases();
|
|
172
|
-
// console.log("idbs", idbs, dbName);
|
|
173
|
-
expect(idbs.find((i) => i.name === `fp.${dbName}`)).toBeDefined();
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
describe("reopen", () => {
|
|
178
|
-
beforeAll(async () => {
|
|
179
|
-
await db.close();
|
|
180
|
-
db = fireproof(dbName);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("simple get", async () => {
|
|
184
|
-
const doc = await db.get("test");
|
|
185
|
-
expect(doc).toEqual({
|
|
186
|
-
_id: "test",
|
|
187
|
-
test: "test",
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it.each(notCreating)("was created $name", async (item) => {
|
|
192
|
-
await item.action(db);
|
|
193
|
-
const idbs = await indexedDB.databases();
|
|
194
|
-
// console.log("idbs", idbs, dbName);
|
|
195
|
-
expect(idbs.find((i) => i.name === `fp.${dbName}`)).toBeDefined();
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// put<T extends DocTypes>(doc: DocSet<T>): Promise<DocResponse>;
|
|
201
|
-
// bulk<T extends DocTypes>(docs: DocSet<T>[]): Promise<BulkResponse>;
|
|
202
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { fireproof } from "@fireproof/core";
|
|
2
|
-
import { mockSuperThis } from "../../helpers.js";
|
|
3
|
-
import { describe, beforeAll, it, expect } from "vitest";
|
|
4
|
-
|
|
5
|
-
describe("fireproof config indexeddb", () => {
|
|
6
|
-
const _my_app = "my-app";
|
|
7
|
-
function my_app() {
|
|
8
|
-
return _my_app;
|
|
9
|
-
}
|
|
10
|
-
const sthis = mockSuperThis();
|
|
11
|
-
beforeAll(async () => {
|
|
12
|
-
await sthis.start();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("indexeddb-loader", async () => {
|
|
16
|
-
const db = fireproof(my_app());
|
|
17
|
-
await db.put({ name: "my-app" });
|
|
18
|
-
expect(db.ledger.name).toBe(my_app());
|
|
19
|
-
|
|
20
|
-
const fileStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.file;
|
|
21
|
-
expect(fileStore?.url().asObj()).toEqual({
|
|
22
|
-
pathname: "fp",
|
|
23
|
-
protocol: "indexeddb:",
|
|
24
|
-
searchParams: {
|
|
25
|
-
name: "my-app",
|
|
26
|
-
store: "file",
|
|
27
|
-
runtime: "browser",
|
|
28
|
-
storekey: "@my-app-data@",
|
|
29
|
-
urlGen: "default",
|
|
30
|
-
version: "v0.19-indexeddb",
|
|
31
|
-
},
|
|
32
|
-
style: "path",
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const dataStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.car;
|
|
36
|
-
expect(dataStore?.url().asObj()).toEqual({
|
|
37
|
-
pathname: "fp",
|
|
38
|
-
protocol: "indexeddb:",
|
|
39
|
-
searchParams: {
|
|
40
|
-
name: "my-app",
|
|
41
|
-
store: "car",
|
|
42
|
-
runtime: "browser",
|
|
43
|
-
storekey: "@my-app-data@",
|
|
44
|
-
suffix: ".car",
|
|
45
|
-
urlGen: "default",
|
|
46
|
-
version: "v0.19-indexeddb",
|
|
47
|
-
},
|
|
48
|
-
style: "path",
|
|
49
|
-
});
|
|
50
|
-
const metaStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.meta;
|
|
51
|
-
expect(metaStore?.url().asObj()).toEqual({
|
|
52
|
-
pathname: "fp",
|
|
53
|
-
protocol: "indexeddb:",
|
|
54
|
-
searchParams: {
|
|
55
|
-
name: "my-app",
|
|
56
|
-
store: "meta",
|
|
57
|
-
runtime: "browser",
|
|
58
|
-
storekey: "@my-app-meta@",
|
|
59
|
-
urlGen: "default",
|
|
60
|
-
version: "v0.19-indexeddb",
|
|
61
|
-
},
|
|
62
|
-
style: "path",
|
|
63
|
-
});
|
|
64
|
-
const WALStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.wal;
|
|
65
|
-
expect(WALStore?.url().asObj()).toEqual({
|
|
66
|
-
pathname: "fp",
|
|
67
|
-
protocol: "indexeddb:",
|
|
68
|
-
searchParams: {
|
|
69
|
-
name: "my-app",
|
|
70
|
-
store: "wal",
|
|
71
|
-
runtime: "browser",
|
|
72
|
-
storekey: "@my-app-wal@",
|
|
73
|
-
urlGen: "default",
|
|
74
|
-
version: "v0.19-indexeddb",
|
|
75
|
-
},
|
|
76
|
-
style: "path",
|
|
77
|
-
});
|
|
78
|
-
await db.close();
|
|
79
|
-
});
|
|
80
|
-
});
|
package/global-setup.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { cd, $ } from "zx";
|
|
2
|
-
import type { TestProject } from "vitest/node";
|
|
3
|
-
|
|
4
|
-
export async function setup(project: TestProject) {
|
|
5
|
-
const root = project.toJSON().serializedConfig.root;
|
|
6
|
-
$.verbose = true;
|
|
7
|
-
cd(root);
|
|
8
|
-
return () => {
|
|
9
|
-
/* no-op */
|
|
10
|
-
};
|
|
11
|
-
}
|