@fireproof/core-test 0.0.0-smoke-1b31059-1752074105
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/LICENSE.md +232 -0
- package/blockstore/fp-envelope.test.ts-off +65 -0
- package/blockstore/fragment-gateway.test.ts-off +106 -0
- package/blockstore/interceptor-gateway.test.d.ts +19 -0
- package/blockstore/interceptor-gateway.test.js +217 -0
- package/blockstore/interceptor-gateway.test.js.map +1 -0
- package/blockstore/interceptor-gateway.test.ts +259 -0
- package/blockstore/keyed-crypto-indexeddb-file.test.d.ts +1 -0
- package/blockstore/keyed-crypto-indexeddb-file.test.js +114 -0
- package/blockstore/keyed-crypto-indexeddb-file.test.js.map +1 -0
- package/blockstore/keyed-crypto-indexeddb-file.test.ts +134 -0
- package/blockstore/keyed-crypto.test.d.ts +1 -0
- package/blockstore/keyed-crypto.test.js +310 -0
- package/blockstore/keyed-crypto.test.js.map +1 -0
- package/blockstore/keyed-crypto.test.ts +382 -0
- package/blockstore/loader.test.d.ts +1 -0
- package/blockstore/loader.test.js +241 -0
- package/blockstore/loader.test.js.map +1 -0
- package/blockstore/loader.test.ts +313 -0
- package/blockstore/standalone.test.d.ts +1 -0
- package/blockstore/standalone.test.js +112 -0
- package/blockstore/standalone.test.js.map +1 -0
- package/blockstore/standalone.test.ts +156 -0
- package/blockstore/store.test.d.ts +1 -0
- package/blockstore/store.test.js +152 -0
- package/blockstore/store.test.js.map +1 -0
- package/blockstore/store.test.ts +199 -0
- package/blockstore/transaction.test.d.ts +1 -0
- package/blockstore/transaction.test.js +109 -0
- package/blockstore/transaction.test.js.map +1 -0
- package/blockstore/transaction.test.ts +132 -0
- package/fireproof/all-gateway.test.d.ts +1 -0
- package/fireproof/all-gateway.test.js +333 -0
- package/fireproof/all-gateway.test.js.map +1 -0
- package/fireproof/all-gateway.test.ts +477 -0
- package/fireproof/attachable.test.d.ts +1 -0
- package/fireproof/attachable.test.js +438 -0
- package/fireproof/attachable.test.js.map +1 -0
- package/fireproof/attachable.test.ts +677 -0
- package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.car +0 -0
- package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.d.ts +4 -0
- package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.js +325 -0
- package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.js.map +1 -0
- package/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +324 -0
- package/fireproof/charwise-boolean.test.d.ts +1 -0
- package/fireproof/charwise-boolean.test.js +43 -0
- package/fireproof/charwise-boolean.test.js.map +1 -0
- package/fireproof/charwise-boolean.test.ts +68 -0
- package/fireproof/crdt.test.d.ts +1 -0
- package/fireproof/crdt.test.js +509 -0
- package/fireproof/crdt.test.js.map +1 -0
- package/fireproof/crdt.test.ts +572 -0
- package/fireproof/database.test.d.ts +1 -0
- package/fireproof/database.test.js +658 -0
- package/fireproof/database.test.js.map +1 -0
- package/fireproof/database.test.ts +772 -0
- package/fireproof/deleted-docs-handling.test.d.ts +1 -0
- package/fireproof/deleted-docs-handling.test.js +69 -0
- package/fireproof/deleted-docs-handling.test.js.map +1 -0
- package/fireproof/deleted-docs-handling.test.ts +112 -0
- package/fireproof/fireproof.test.d.ts +3 -0
- package/fireproof/fireproof.test.fixture.d.ts +15 -0
- package/fireproof/fireproof.test.fixture.js +134 -0
- package/fireproof/fireproof.test.fixture.js.map +1 -0
- package/fireproof/fireproof.test.fixture.ts +133 -0
- package/fireproof/fireproof.test.js +574 -0
- package/fireproof/fireproof.test.js.map +1 -0
- package/fireproof/fireproof.test.ts +767 -0
- package/fireproof/hello.test.d.ts +1 -0
- package/fireproof/hello.test.js +67 -0
- package/fireproof/hello.test.js.map +1 -0
- package/fireproof/hello.test.ts +75 -0
- package/fireproof/indexer.test.d.ts +1 -0
- package/fireproof/indexer.test.js +408 -0
- package/fireproof/indexer.test.js.map +1 -0
- package/fireproof/indexer.test.ts +459 -0
- package/fireproof/multiple-ledger.test.d.ts +1 -0
- package/fireproof/multiple-ledger.test.js +51 -0
- package/fireproof/multiple-ledger.test.js.map +1 -0
- package/fireproof/multiple-ledger.test.ts +67 -0
- package/fireproof/query-docs.test.d.ts +1 -0
- package/fireproof/query-docs.test.js +69 -0
- package/fireproof/query-docs.test.js.map +1 -0
- package/fireproof/query-docs.test.ts +117 -0
- package/fireproof/query-limit-issue.test.d.ts +1 -0
- package/fireproof/query-limit-issue.test.js +89 -0
- package/fireproof/query-limit-issue.test.js.map +1 -0
- package/fireproof/query-limit-issue.test.ts +147 -0
- package/fireproof/query-property-inconsistency.test.d.ts +1 -0
- package/fireproof/query-property-inconsistency.test.js +52 -0
- package/fireproof/query-property-inconsistency.test.js.map +1 -0
- package/fireproof/query-property-inconsistency.test.ts +90 -0
- package/fireproof/query-result-properties.test.d.ts +1 -0
- package/fireproof/query-result-properties.test.js +25 -0
- package/fireproof/query-result-properties.test.js.map +1 -0
- package/fireproof/query-result-properties.test.ts +43 -0
- package/fireproof/stable-cid.test.d.ts +1 -0
- package/fireproof/stable-cid.test.js +52 -0
- package/fireproof/stable-cid.test.js.map +1 -0
- package/fireproof/stable-cid.test.ts +72 -0
- package/fireproof/utils.test.d.ts +1 -0
- package/fireproof/utils.test.js +124 -0
- package/fireproof/utils.test.js.map +1 -0
- package/fireproof/utils.test.ts +137 -0
- package/gateway/file/loader-config.test.d.ts +1 -0
- package/gateway/file/loader-config.test.js +255 -0
- package/gateway/file/loader-config.test.js.map +1 -0
- package/gateway/file/loader-config.test.ts +309 -0
- package/gateway/indexeddb/loader-config.test.d.ts +1 -0
- package/gateway/indexeddb/loader-config.test.js +77 -0
- package/gateway/indexeddb/loader-config.test.js.map +1 -0
- package/gateway/indexeddb/loader-config.test.ts +80 -0
- package/global-setup.d.ts +2 -0
- package/global-setup.js +9 -0
- package/global-setup.js.map +1 -0
- package/global-setup.ts +11 -0
- package/helpers.d.ts +31 -0
- package/helpers.js +140 -0
- package/helpers.js.map +1 -0
- package/helpers.ts +177 -0
- package/package.json +75 -0
- package/protocols/cloud/msger.test.d.ts +1 -0
- package/protocols/cloud/msger.test.js +464 -0
- package/protocols/cloud/msger.test.js.map +1 -0
- package/protocols/cloud/msger.test.ts +559 -0
- package/runtime/fp-envelope-serialize.test.d.ts +1 -0
- package/runtime/fp-envelope-serialize.test.js +223 -0
- package/runtime/fp-envelope-serialize.test.js.map +1 -0
- package/runtime/fp-envelope-serialize.test.ts +266 -0
- package/runtime/meta-key-hack.test.d.ts +1 -0
- package/runtime/meta-key-hack.test.js +85 -0
- package/runtime/meta-key-hack.test.js.map +1 -0
- package/runtime/meta-key-hack.test.ts +103 -0
- package/setup.file.d.ts +1 -0
- package/setup.file.js +3 -0
- package/setup.file.js.map +1 -0
- package/setup.file.ts +1 -0
- package/setup.indexeddb.d.ts +1 -0
- package/setup.indexeddb.js +2 -0
- package/setup.indexeddb.js.map +1 -0
- package/setup.indexeddb.ts +0 -0
- package/setup.memory.d.ts +1 -0
- package/setup.memory.js +4 -0
- package/setup.memory.js.map +1 -0
- package/setup.memory.ts +2 -0
- package/tsconfig.json +18 -0
- package/vitest.config.d.ts +2 -0
- package/vitest.config.js +8 -0
- package/vitest.config.js.map +1 -0
- package/vitest.config.ts +8 -0
- package/vitest.file.config.d.ts +2 -0
- package/vitest.file.config.js +11 -0
- package/vitest.file.config.js.map +1 -0
- package/vitest.file.config.ts +11 -0
- package/vitest.indexeddb.config.d.ts +2 -0
- package/vitest.indexeddb.config.js +21 -0
- package/vitest.indexeddb.config.js.map +1 -0
- package/vitest.indexeddb.config.ts +34 -0
- package/vitest.memory.config.d.ts +2 -0
- package/vitest.memory.config.js +24 -0
- package/vitest.memory.config.js.map +1 -0
- package/vitest.memory.config.ts +24 -0
|
@@ -0,0 +1,309 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { fireproof } from "@fireproof/core";
|
|
2
|
+
import { mockSuperThis } from "../../helpers.js";
|
|
3
|
+
import { describe, beforeAll, it, expect } from "vitest";
|
|
4
|
+
describe("fireproof config indexeddb", () => {
|
|
5
|
+
const _my_app = "my-app";
|
|
6
|
+
function my_app() {
|
|
7
|
+
return _my_app;
|
|
8
|
+
}
|
|
9
|
+
const sthis = mockSuperThis();
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
await sthis.start();
|
|
12
|
+
});
|
|
13
|
+
it("indexeddb-loader", async () => {
|
|
14
|
+
const db = fireproof(my_app());
|
|
15
|
+
await db.put({ name: "my-app" });
|
|
16
|
+
expect(db.ledger.name).toBe(my_app());
|
|
17
|
+
const fileStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.file;
|
|
18
|
+
expect(fileStore?.url().asObj()).toEqual({
|
|
19
|
+
pathname: "fp",
|
|
20
|
+
protocol: "indexeddb:",
|
|
21
|
+
searchParams: {
|
|
22
|
+
name: "my-app",
|
|
23
|
+
store: "file",
|
|
24
|
+
runtime: "browser",
|
|
25
|
+
storekey: "@my-app-data@",
|
|
26
|
+
urlGen: "default",
|
|
27
|
+
version: "v0.19-indexeddb",
|
|
28
|
+
},
|
|
29
|
+
style: "path",
|
|
30
|
+
});
|
|
31
|
+
const dataStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.car;
|
|
32
|
+
expect(dataStore?.url().asObj()).toEqual({
|
|
33
|
+
pathname: "fp",
|
|
34
|
+
protocol: "indexeddb:",
|
|
35
|
+
searchParams: {
|
|
36
|
+
name: "my-app",
|
|
37
|
+
store: "car",
|
|
38
|
+
runtime: "browser",
|
|
39
|
+
storekey: "@my-app-data@",
|
|
40
|
+
suffix: ".car",
|
|
41
|
+
urlGen: "default",
|
|
42
|
+
version: "v0.19-indexeddb",
|
|
43
|
+
},
|
|
44
|
+
style: "path",
|
|
45
|
+
});
|
|
46
|
+
const metaStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.meta;
|
|
47
|
+
expect(metaStore?.url().asObj()).toEqual({
|
|
48
|
+
pathname: "fp",
|
|
49
|
+
protocol: "indexeddb:",
|
|
50
|
+
searchParams: {
|
|
51
|
+
name: "my-app",
|
|
52
|
+
store: "meta",
|
|
53
|
+
runtime: "browser",
|
|
54
|
+
storekey: "@my-app-meta@",
|
|
55
|
+
urlGen: "default",
|
|
56
|
+
version: "v0.19-indexeddb",
|
|
57
|
+
},
|
|
58
|
+
style: "path",
|
|
59
|
+
});
|
|
60
|
+
const WALStore = await db.ledger.crdt.blockstore.loader.attachedStores.local().active.wal;
|
|
61
|
+
expect(WALStore?.url().asObj()).toEqual({
|
|
62
|
+
pathname: "fp",
|
|
63
|
+
protocol: "indexeddb:",
|
|
64
|
+
searchParams: {
|
|
65
|
+
name: "my-app",
|
|
66
|
+
store: "wal",
|
|
67
|
+
runtime: "browser",
|
|
68
|
+
storekey: "@my-app-wal@",
|
|
69
|
+
urlGen: "default",
|
|
70
|
+
version: "v0.19-indexeddb",
|
|
71
|
+
},
|
|
72
|
+
style: "path",
|
|
73
|
+
});
|
|
74
|
+
await db.close();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=loader-config.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-config.test.js","sourceRoot":"","sources":["loader-config.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,80 @@
|
|
|
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.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-setup.js","sourceRoot":"","sources":["global-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC;AAG3B,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAoB;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;IACpD,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;IACjB,EAAE,CAAC,IAAI,CAAC,CAAC;IACT,OAAO,GAAG,EAAE;IAEZ,CAAC,CAAC;AACJ,CAAC"}
|
package/global-setup.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
package/helpers.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { URI, LogCollector } from "@adviser/cement";
|
|
2
|
+
import { SuperThis, SuperThisOpts } from "@fireproof/core";
|
|
3
|
+
import { CID } from "multiformats";
|
|
4
|
+
import { Loadable } from "@fireproof/core-types-blockstore";
|
|
5
|
+
export declare function tracer(): void;
|
|
6
|
+
export interface FileWithCid {
|
|
7
|
+
file: File;
|
|
8
|
+
cid: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function buildBlobFiles(): Promise<FileWithCid[]>;
|
|
11
|
+
export declare function storageURL(sthis: SuperThis): URI;
|
|
12
|
+
export type MockSuperThis = SuperThis & {
|
|
13
|
+
ctx: {
|
|
14
|
+
readonly logCollector: LogCollector;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function mockSuperThis(sthis?: Partial<SuperThisOpts>): MockSuperThis;
|
|
18
|
+
export declare function noopUrl(name?: string): URI;
|
|
19
|
+
export declare function simpleBlockOpts(sthis: SuperThis, name?: string): {
|
|
20
|
+
keyBag: import("@fireproof/core").KeyBagRuntime;
|
|
21
|
+
storeRuntime: import("@fireproof/core-types-blockstore").StoreRuntime;
|
|
22
|
+
storeUrls: {
|
|
23
|
+
file: URI;
|
|
24
|
+
wal: URI;
|
|
25
|
+
meta: URI;
|
|
26
|
+
car: URI;
|
|
27
|
+
};
|
|
28
|
+
tracer: typeof tracer;
|
|
29
|
+
};
|
|
30
|
+
export declare function simpleCID(sthis: SuperThis): Promise<CID<unknown, 512, 18, 1>>;
|
|
31
|
+
export declare function mockLoader(sthis: SuperThis): Loadable;
|
package/helpers.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { BuildURI, MockLogger, runtimeFn, toCryptoRuntime, URI, utils, AppContext } from "@adviser/cement";
|
|
2
|
+
import { PARAM } from "@fireproof/core";
|
|
3
|
+
import { CID } from "multiformats";
|
|
4
|
+
import { sha256 } from "multiformats/hashes/sha2";
|
|
5
|
+
import * as json from "multiformats/codecs/json";
|
|
6
|
+
import { CommitQueue, encodeFile, ensureSuperThis, TaskManager } from "@fireproof/core-runtime";
|
|
7
|
+
import { defaultKeyBagOpts, getKeyBag } from "@fireproof/core-keybag";
|
|
8
|
+
import { AttachedRemotesImpl, toStoreRuntime } from "@fireproof/core-blockstore";
|
|
9
|
+
import { CarLog, } from "@fireproof/core-types-blockstore";
|
|
10
|
+
export function tracer() { }
|
|
11
|
+
async function toFileWithCid(buffer, name, opts) {
|
|
12
|
+
return {
|
|
13
|
+
file: new File([new Blob([buffer])], name, opts),
|
|
14
|
+
cid: (await encodeFile(new File([new Blob([buffer])], name, opts))).cid.toString(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export async function buildBlobFiles() {
|
|
18
|
+
const cp = toCryptoRuntime();
|
|
19
|
+
return [
|
|
20
|
+
await toFileWithCid(cp.randomBytes(Math.random() * 51283), `image.jpg`, { type: "image/jpeg" }),
|
|
21
|
+
await toFileWithCid(cp.randomBytes(Math.random() * 51283), `fireproof.png`, { type: "image/png" }),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
export function storageURL(sthis) {
|
|
25
|
+
const old = sthis.env.get("FP_STORAGE_URL");
|
|
26
|
+
let merged;
|
|
27
|
+
if (runtimeFn().isBrowser) {
|
|
28
|
+
merged = URI.merge(`indexeddb://fp`, old, "indexeddb:");
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
merged = URI.merge(`./dist/env`, old);
|
|
32
|
+
}
|
|
33
|
+
return merged;
|
|
34
|
+
}
|
|
35
|
+
export function mockSuperThis(sthis) {
|
|
36
|
+
const mockLog = MockLogger({
|
|
37
|
+
pass: new utils.ConsoleWriterStreamDefaultWriter(new utils.ConsoleWriterStream()),
|
|
38
|
+
});
|
|
39
|
+
return ensureSuperThis({
|
|
40
|
+
...sthis,
|
|
41
|
+
logger: mockLog.logger,
|
|
42
|
+
ctx: AppContext.merge({
|
|
43
|
+
logCollector: mockLog.logCollector,
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export function noopUrl(name) {
|
|
48
|
+
const burl = BuildURI.from("memory://noop");
|
|
49
|
+
burl.setParam(PARAM.NAME, name || "test");
|
|
50
|
+
return burl.URI();
|
|
51
|
+
}
|
|
52
|
+
export function simpleBlockOpts(sthis, name) {
|
|
53
|
+
const url = noopUrl(name);
|
|
54
|
+
return {
|
|
55
|
+
keyBag: defaultKeyBagOpts(sthis),
|
|
56
|
+
storeRuntime: toStoreRuntime(sthis),
|
|
57
|
+
storeUrls: {
|
|
58
|
+
file: url,
|
|
59
|
+
wal: url,
|
|
60
|
+
meta: url,
|
|
61
|
+
car: url,
|
|
62
|
+
},
|
|
63
|
+
tracer,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export async function simpleCID(sthis) {
|
|
67
|
+
const bytes = json.encode({ hello: sthis.nextId().str });
|
|
68
|
+
const hash = await sha256.digest(bytes);
|
|
69
|
+
return CID.create(1, json.code, hash);
|
|
70
|
+
}
|
|
71
|
+
class MockLoader {
|
|
72
|
+
sthis;
|
|
73
|
+
logger;
|
|
74
|
+
ebOpts;
|
|
75
|
+
carLog;
|
|
76
|
+
attachedStores;
|
|
77
|
+
taskManager;
|
|
78
|
+
commitQueue;
|
|
79
|
+
constructor(sthis) {
|
|
80
|
+
this.sthis = sthis;
|
|
81
|
+
this.logger = sthis.logger;
|
|
82
|
+
this.ebOpts = {
|
|
83
|
+
storeUrls: {
|
|
84
|
+
file: noopUrl("test"),
|
|
85
|
+
wal: noopUrl("test"),
|
|
86
|
+
meta: noopUrl("test"),
|
|
87
|
+
car: noopUrl("test"),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
this.carLog = new CarLog();
|
|
91
|
+
this.taskManager = new TaskManager(sthis, () => Promise.resolve(), {
|
|
92
|
+
removeAfter: 3,
|
|
93
|
+
retryTimeout: 50,
|
|
94
|
+
});
|
|
95
|
+
this.attachedStores = new AttachedRemotesImpl(this);
|
|
96
|
+
this.commitQueue = new CommitQueue({
|
|
97
|
+
tracer,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
attach(attached) {
|
|
101
|
+
throw new Error("Method not implemented.");
|
|
102
|
+
}
|
|
103
|
+
ready() {
|
|
104
|
+
throw new Error("Method not implemented.");
|
|
105
|
+
}
|
|
106
|
+
close() {
|
|
107
|
+
throw new Error("Method not implemented.");
|
|
108
|
+
}
|
|
109
|
+
keyBag() {
|
|
110
|
+
return getKeyBag(this.sthis, {});
|
|
111
|
+
}
|
|
112
|
+
handleDbMetasFromStore(metas, store) {
|
|
113
|
+
return Promise.resolve([]);
|
|
114
|
+
}
|
|
115
|
+
commit(t, done, opts) {
|
|
116
|
+
throw new Error("Method not implemented.");
|
|
117
|
+
}
|
|
118
|
+
destroy() {
|
|
119
|
+
throw new Error("Method not implemented.");
|
|
120
|
+
}
|
|
121
|
+
getBlock(cid, store) {
|
|
122
|
+
throw new Error("Method not implemented.");
|
|
123
|
+
}
|
|
124
|
+
loadFileCar(cid, store) {
|
|
125
|
+
throw new Error("Method not implemented.");
|
|
126
|
+
}
|
|
127
|
+
loadCar(cid, store) {
|
|
128
|
+
throw new Error("Method not implemented.");
|
|
129
|
+
}
|
|
130
|
+
commitFiles(t, done) {
|
|
131
|
+
throw new Error("Method not implemented.");
|
|
132
|
+
}
|
|
133
|
+
entries(cache) {
|
|
134
|
+
throw new Error("Method not implemented.");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export function mockLoader(sthis) {
|
|
138
|
+
return new MockLoader(sthis);
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=helpers.js.map
|