@fireproof/core 0.19.100 → 0.19.101
Sign up to get free protection for your applications and to get access to all the features.
- package/{chunk-OFGPKRCM.js → chunk-3EB3ENHT.js} +54 -25
- package/chunk-3EB3ENHT.js.map +1 -0
- package/chunk-HQ7D3PEU.js +61 -0
- package/chunk-HQ7D3PEU.js.map +1 -0
- package/chunk-PZ5AY32C.js +10 -0
- package/deno-filesystem-Q2IJ7YDR.js +57 -0
- package/deno-filesystem-Q2IJ7YDR.js.map +1 -0
- package/{gateway-5FCWPX5W.js → gateway-GK5QZ6KP.js} +13 -12
- package/gateway-GK5QZ6KP.js.map +1 -0
- package/{gateway-H7UD6TNB.js → gateway-TQTGDRCN.js} +9 -8
- package/gateway-TQTGDRCN.js.map +1 -0
- package/index.cjs +2158 -1718
- package/index.cjs.map +1 -1
- package/index.d.cts +261 -117
- package/index.d.ts +261 -117
- package/index.global.js +11834 -11354
- package/index.global.js.map +1 -1
- package/index.js +1865 -1519
- package/index.js.map +1 -1
- package/{key-bag-file-WADZBHYG.js → key-bag-file-VOSSK46F.js} +4 -3
- package/{key-bag-file-WADZBHYG.js.map → key-bag-file-VOSSK46F.js.map} +1 -1
- package/{key-bag-indexdb-PGVAI3FJ.js → key-bag-indexdb-AXTQOSMC.js} +4 -3
- package/{key-bag-indexdb-PGVAI3FJ.js.map → key-bag-indexdb-AXTQOSMC.js.map} +1 -1
- package/key-bag-memory-LWE6ARPX.js +29 -0
- package/key-bag-memory-LWE6ARPX.js.map +1 -0
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/metafile-iife.json +1 -1
- package/{node-filesystem-INX4ZTHE.js → node-filesystem-CFRXFSO7.js} +6 -9
- package/node-filesystem-CFRXFSO7.js.map +1 -0
- package/package.json +1 -1
- package/tests/blockstore/keyed-crypto-indexdb-file.test.ts +129 -0
- package/tests/blockstore/keyed-crypto.test.ts +63 -227
- package/tests/blockstore/loader.test.ts +19 -11
- package/tests/blockstore/store.test.ts +23 -19
- package/tests/blockstore/transaction.test.ts +12 -12
- package/tests/fireproof/all-gateway.test.ts +201 -193
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +324 -316
- package/tests/fireproof/crdt.test.ts +67 -16
- package/tests/fireproof/database.test.ts +183 -21
- package/tests/fireproof/fireproof.test.ts +83 -74
- package/tests/fireproof/hello.test.ts +18 -14
- package/tests/fireproof/indexer.test.ts +53 -43
- package/tests/fireproof/utils.test.ts +18 -6
- package/tests/gateway/file/loader-config.test.ts +303 -0
- package/tests/gateway/indexdb/loader-config.test.ts +75 -0
- package/tests/helpers.ts +27 -9
- package/tests/react/useFireproof.test.tsx +1 -1
- package/{utils-QO2HIWGI.js → utils-STA2C35G.js} +4 -3
- package/utils-STA2C35G.js.map +1 -0
- package/chunk-OFGPKRCM.js.map +0 -1
- package/chunk-WS3YRPIA.js +0 -75
- package/chunk-WS3YRPIA.js.map +0 -1
- package/gateway-5FCWPX5W.js.map +0 -1
- package/gateway-H7UD6TNB.js.map +0 -1
- package/mem-filesystem-YPPJV7Q2.js +0 -41
- package/mem-filesystem-YPPJV7Q2.js.map +0 -1
- package/node-filesystem-INX4ZTHE.js.map +0 -1
- package/tests/fireproof/config.test.ts +0 -172
- /package/{utils-QO2HIWGI.js.map → chunk-PZ5AY32C.js.map} +0 -0
- /package/tests/fireproof/{fireproof.test.fixture.ts → fireproof.fixture.ts} +0 -0
@@ -1,8 +1,9 @@
|
|
1
|
-
import { CRDT } from "@fireproof/core";
|
1
|
+
import { CRDT, DatabaseOpts, toStoreURIRuntime } from "@fireproof/core";
|
2
2
|
import { bs } from "@fireproof/core";
|
3
3
|
import { CRDTMeta, DocValue } from "@fireproof/core";
|
4
4
|
import { Index, index } from "@fireproof/core";
|
5
5
|
import { mockSuperThis } from "../helpers";
|
6
|
+
import { defaultKeyBagOpts } from "../../src/runtime/key-bag";
|
6
7
|
|
7
8
|
describe("Fresh crdt", function () {
|
8
9
|
let crdt: CRDT<{ hello: string } | { points: number }>;
|
@@ -13,7 +14,12 @@ describe("Fresh crdt", function () {
|
|
13
14
|
});
|
14
15
|
beforeEach(async function () {
|
15
16
|
await sthis.start();
|
16
|
-
|
17
|
+
const dbOpts: DatabaseOpts = {
|
18
|
+
keyBag: defaultKeyBagOpts(sthis),
|
19
|
+
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
20
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
21
|
+
};
|
22
|
+
crdt = new CRDT(sthis, dbOpts);
|
17
23
|
});
|
18
24
|
it("should have an empty head", async function () {
|
19
25
|
const head = crdt.clock.head;
|
@@ -50,7 +56,12 @@ describe("CRDT with one record", function () {
|
|
50
56
|
|
51
57
|
beforeEach(async function () {
|
52
58
|
await sthis.start();
|
53
|
-
|
59
|
+
const dbOpts: DatabaseOpts = {
|
60
|
+
keyBag: defaultKeyBagOpts(sthis),
|
61
|
+
storeUrls: toStoreURIRuntime(sthis, `test@${sthis.nextId()}`),
|
62
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
63
|
+
};
|
64
|
+
crdt = new CRDT(sthis, dbOpts);
|
54
65
|
firstPut = await crdt.bulk([{ id: "hello", value: { hello: "world" } }]);
|
55
66
|
});
|
56
67
|
it("should have a one-element head", async function () {
|
@@ -100,7 +111,12 @@ describe("CRDT with a multi-write", function () {
|
|
100
111
|
});
|
101
112
|
beforeEach(async function () {
|
102
113
|
await sthis.start();
|
103
|
-
|
114
|
+
const dbOpts: DatabaseOpts = {
|
115
|
+
keyBag: defaultKeyBagOpts(sthis),
|
116
|
+
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
117
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
118
|
+
};
|
119
|
+
crdt = new CRDT(sthis, dbOpts);
|
104
120
|
firstPut = await crdt.bulk([
|
105
121
|
{ id: "ace", value: { points: 11 } },
|
106
122
|
{ id: "king", value: { points: 10 } },
|
@@ -165,7 +181,12 @@ describe("CRDT with two multi-writes", function () {
|
|
165
181
|
});
|
166
182
|
beforeEach(async () => {
|
167
183
|
await sthis.start();
|
168
|
-
|
184
|
+
const dbOpts: DatabaseOpts = {
|
185
|
+
keyBag: defaultKeyBagOpts(sthis),
|
186
|
+
storeUrls: toStoreURIRuntime(sthis, `test-multiple-writes@${sthis.nextId()}`),
|
187
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
188
|
+
};
|
189
|
+
crdt = new CRDT(sthis, dbOpts);
|
169
190
|
firstPut = await crdt.bulk([
|
170
191
|
{ id: "ace", value: { points: 11 } },
|
171
192
|
{ id: "king", value: { points: 10 } },
|
@@ -213,7 +234,12 @@ describe("Compact a named CRDT with writes", function () {
|
|
213
234
|
});
|
214
235
|
beforeEach(async function () {
|
215
236
|
await sthis.start();
|
216
|
-
|
237
|
+
const dbOpts: DatabaseOpts = {
|
238
|
+
keyBag: defaultKeyBagOpts(sthis),
|
239
|
+
storeUrls: toStoreURIRuntime(sthis, `named-crdt-compaction`),
|
240
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
241
|
+
};
|
242
|
+
crdt = new CRDT(sthis, dbOpts);
|
217
243
|
for (let i = 0; i < 10; i++) {
|
218
244
|
const bulk = [
|
219
245
|
{ id: "ace", value: { points: 11 } },
|
@@ -269,12 +295,17 @@ describe("CRDT with an index", function () {
|
|
269
295
|
});
|
270
296
|
beforeEach(async function () {
|
271
297
|
await sthis.start();
|
272
|
-
|
298
|
+
const dbOpts: DatabaseOpts = {
|
299
|
+
keyBag: defaultKeyBagOpts(sthis),
|
300
|
+
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
301
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
302
|
+
};
|
303
|
+
crdt = new CRDT<CRDTTestType>(sthis, dbOpts);
|
273
304
|
await crdt.bulk([
|
274
305
|
{ id: "ace", value: { points: 11 } },
|
275
306
|
{ id: "king", value: { points: 10 } },
|
276
307
|
]);
|
277
|
-
idx = await index<number, CRDTTestType>(
|
308
|
+
idx = await index<number, CRDTTestType>({ crdt: crdt }, "points");
|
278
309
|
});
|
279
310
|
it("should query the data", async function () {
|
280
311
|
const got = await idx.query({ range: [9, 12] });
|
@@ -283,7 +314,7 @@ describe("CRDT with an index", function () {
|
|
283
314
|
expect(got.rows[0].key).toBe(10);
|
284
315
|
});
|
285
316
|
it("should register the index", async function () {
|
286
|
-
const rIdx = await index<number, CRDTTestType>(
|
317
|
+
const rIdx = await index<number, CRDTTestType>({ crdt: crdt }, "points");
|
287
318
|
expect(rIdx).toBeTruthy();
|
288
319
|
expect(rIdx.name).toBe("points");
|
289
320
|
const got = await rIdx.query({ range: [9, 12] });
|
@@ -292,7 +323,7 @@ describe("CRDT with an index", function () {
|
|
292
323
|
expect(got.rows[0].key).toBe(10);
|
293
324
|
});
|
294
325
|
it("creating a different index with same name should not work", async function () {
|
295
|
-
const e = await index(
|
326
|
+
const e = await index({ crdt: crdt }, "points", (doc) => doc._id)
|
296
327
|
.query()
|
297
328
|
.catch((err) => err);
|
298
329
|
expect(e.message).toMatch(/cannot apply/);
|
@@ -315,15 +346,25 @@ describe("Loader with a committed transaction", function () {
|
|
315
346
|
});
|
316
347
|
beforeEach(async function () {
|
317
348
|
await sthis.start();
|
318
|
-
|
349
|
+
const dbOpts: DatabaseOpts = {
|
350
|
+
keyBag: defaultKeyBagOpts(sthis),
|
351
|
+
storeUrls: toStoreURIRuntime(sthis, dbname),
|
352
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
353
|
+
};
|
354
|
+
crdt = new CRDT(sthis, dbOpts);
|
319
355
|
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
|
320
356
|
expect(blockstore.loader).toBeTruthy();
|
321
357
|
loader = blockstore.loader;
|
322
358
|
done = await crdt.bulk([{ id: "foo", value: { foo: "bar" } }]);
|
323
359
|
});
|
324
|
-
it("should have a name", function () {
|
325
|
-
|
326
|
-
|
360
|
+
// it("should have a name", function () {
|
361
|
+
// expect(loader.ebOpts.storeUrls).toEqual({
|
362
|
+
// data: "file://./dist/fp-dir-file?name=test-loader&store=data&storekey=%40test-loader-data%40&suffix=.car&urlGen=fromEnv",
|
363
|
+
// file: "file://./dist/fp-dir-file?name=test-loader&store=data&storekey=%40test-loader-data%40&urlGen=fromEnv",
|
364
|
+
// meta: "file://./dist/fp-dir-file?name=test-loader&store=meta&storekey=%40test-loader-meta%40&urlGen=fromEnv",
|
365
|
+
// wal: "file://./dist/fp-dir-file?name=test-loader&store=wal&storekey=%40test-loader-wal%40&urlGen=fromEnv",
|
366
|
+
// });
|
367
|
+
// });
|
327
368
|
it("should commit a transaction", function () {
|
328
369
|
expect(done.head).toBeTruthy();
|
329
370
|
// expect(done.cars).toBeTruthy();
|
@@ -358,7 +399,12 @@ describe("Loader with two committed transactions", function () {
|
|
358
399
|
});
|
359
400
|
beforeEach(async function () {
|
360
401
|
await sthis.start();
|
361
|
-
|
402
|
+
const dbOpts: DatabaseOpts = {
|
403
|
+
keyBag: defaultKeyBagOpts(sthis),
|
404
|
+
storeUrls: toStoreURIRuntime(sthis, "test-loader"),
|
405
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
406
|
+
};
|
407
|
+
crdt = new CRDT(sthis, dbOpts);
|
362
408
|
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
|
363
409
|
expect(blockstore.loader).toBeTruthy();
|
364
410
|
loader = blockstore.loader;
|
@@ -408,7 +454,12 @@ describe("Loader with many committed transactions", function () {
|
|
408
454
|
});
|
409
455
|
beforeEach(async function () {
|
410
456
|
await sthis.start();
|
411
|
-
|
457
|
+
const dbOpts: DatabaseOpts = {
|
458
|
+
keyBag: defaultKeyBagOpts(sthis),
|
459
|
+
storeUrls: toStoreURIRuntime(sthis, "test-loader-many"),
|
460
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
461
|
+
};
|
462
|
+
crdt = new CRDT(sthis, dbOpts);
|
412
463
|
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
|
413
464
|
expect(blockstore.loader).toBeTruthy();
|
414
465
|
loader = blockstore.loader;
|
@@ -1,5 +1,19 @@
|
|
1
|
+
import { URI } from "@adviser/cement";
|
1
2
|
import { buildBlobFiles, FileWithCid, mockSuperThis } from "../helpers.js";
|
2
|
-
import {
|
3
|
+
import {
|
4
|
+
bs,
|
5
|
+
Database,
|
6
|
+
DocResponse,
|
7
|
+
DocFileMeta,
|
8
|
+
DocWithId,
|
9
|
+
DocFiles,
|
10
|
+
toStoreURIRuntime,
|
11
|
+
keyConfigOpts,
|
12
|
+
DatabaseFactory,
|
13
|
+
DatabaseShell,
|
14
|
+
} from "@fireproof/core";
|
15
|
+
import { fileGatewayFactoryItem } from "../../src/blockstore/register-store-protocol.js";
|
16
|
+
import { FILESTORE_VERSION } from "../../src/runtime/index.js";
|
3
17
|
|
4
18
|
describe("basic Database", () => {
|
5
19
|
let db: Database;
|
@@ -10,7 +24,9 @@ describe("basic Database", () => {
|
|
10
24
|
});
|
11
25
|
beforeEach(async () => {
|
12
26
|
await sthis.start();
|
13
|
-
db =
|
27
|
+
db = DatabaseFactory(undefined, {
|
28
|
+
logger: sthis.logger,
|
29
|
+
});
|
14
30
|
});
|
15
31
|
it("should put", async () => {
|
16
32
|
/** @type {Doc} */
|
@@ -38,7 +54,7 @@ describe("basic Database with record", function () {
|
|
38
54
|
interface Doc {
|
39
55
|
readonly value: string;
|
40
56
|
}
|
41
|
-
let db:
|
57
|
+
let db: DatabaseShell;
|
42
58
|
const sthis = mockSuperThis();
|
43
59
|
afterEach(async () => {
|
44
60
|
await db.close();
|
@@ -46,7 +62,7 @@ describe("basic Database with record", function () {
|
|
46
62
|
});
|
47
63
|
beforeEach(async function () {
|
48
64
|
await sthis.start();
|
49
|
-
db =
|
65
|
+
db = DatabaseFactory("factory-name") as DatabaseShell;
|
50
66
|
const ok = await db.put<Doc>({ _id: "hello", value: "world" });
|
51
67
|
expect(ok.id).toBe("hello");
|
52
68
|
});
|
@@ -78,13 +94,13 @@ describe("basic Database with record", function () {
|
|
78
94
|
expect(rows[0].value._id).toBe("hello");
|
79
95
|
});
|
80
96
|
it("is not persisted", async function () {
|
81
|
-
const db2 =
|
97
|
+
const db2 = DatabaseFactory("factory-name") as DatabaseShell;
|
82
98
|
const { rows } = await db2.changes([]);
|
83
|
-
expect(rows.length).toBe(
|
84
|
-
|
85
|
-
|
99
|
+
expect(rows.length).toBe(1);
|
100
|
+
expect(db2.ref).toBe(db.ref);
|
101
|
+
const doc = await db2.get<Doc>("hello").catch((e) => e);
|
102
|
+
expect(doc.value).toBe("world");
|
86
103
|
await db2.close();
|
87
|
-
await db2.destroy();
|
88
104
|
});
|
89
105
|
});
|
90
106
|
|
@@ -100,7 +116,7 @@ describe("named Database with record", function () {
|
|
100
116
|
});
|
101
117
|
beforeEach(async function () {
|
102
118
|
await sthis.start();
|
103
|
-
db =
|
119
|
+
db = DatabaseFactory("test-db-name");
|
104
120
|
/** @type {Doc} */
|
105
121
|
const doc = { _id: "hello", value: "world" };
|
106
122
|
const ok = await db.put(doc);
|
@@ -136,7 +152,7 @@ describe("named Database with record", function () {
|
|
136
152
|
it("should have a key", async function () {
|
137
153
|
const { rows } = await db.changes([]);
|
138
154
|
expect(rows.length).toBe(1);
|
139
|
-
const blocks = db.
|
155
|
+
const blocks = db.crdt.blockstore as bs.EncryptedBlockstore;
|
140
156
|
const loader = blocks.loader;
|
141
157
|
expect(loader).toBeTruthy();
|
142
158
|
await loader.ready();
|
@@ -227,7 +243,7 @@ describe("basic Database parallel writes / public", function () {
|
|
227
243
|
});
|
228
244
|
beforeEach(async function () {
|
229
245
|
await sthis.start();
|
230
|
-
db =
|
246
|
+
db = DatabaseFactory("test-parallel-writes", { public: true });
|
231
247
|
for (let i = 0; i < 10; i++) {
|
232
248
|
const doc = { _id: `id-${i}`, hello: "world" };
|
233
249
|
writes.push(db.put(doc));
|
@@ -235,7 +251,7 @@ describe("basic Database parallel writes / public", function () {
|
|
235
251
|
await Promise.all(writes);
|
236
252
|
});
|
237
253
|
it("should have one head", function () {
|
238
|
-
const crdt = db.
|
254
|
+
const crdt = db.crdt;
|
239
255
|
expect(crdt.clock.head.length).toBe(1);
|
240
256
|
});
|
241
257
|
it("should write all", async function () {
|
@@ -272,7 +288,7 @@ describe("basic Database parallel writes / public", function () {
|
|
272
288
|
});
|
273
289
|
it("has changes", async function () {
|
274
290
|
const { rows, clock } = await db.changes([]);
|
275
|
-
expect(clock[0]).toBe(db.
|
291
|
+
expect(clock[0]).toBe(db.crdt.clock.head[0]);
|
276
292
|
expect(rows.length).toBe(10);
|
277
293
|
// rows.sort((a, b) => a.key.localeCompare(b.key));
|
278
294
|
for (let i = 0; i < 10; i++) {
|
@@ -283,9 +299,9 @@ describe("basic Database parallel writes / public", function () {
|
|
283
299
|
it("should not have a key", async function () {
|
284
300
|
const { rows } = await db.changes([]);
|
285
301
|
expect(rows.length).toBe(10);
|
286
|
-
expect(db.opts.public).toBeTruthy();
|
287
|
-
expect(db._crdt.opts.public).toBeTruthy();
|
288
|
-
const blocks = db.
|
302
|
+
// expect(db.opts.public).toBeTruthy();
|
303
|
+
// expect(db._crdt.opts.public).toBeTruthy();
|
304
|
+
const blocks = db.crdt.blockstore as bs.EncryptedBlockstore;
|
289
305
|
const loader = blocks.loader;
|
290
306
|
expect(loader).toBeTruthy();
|
291
307
|
await loader.ready();
|
@@ -307,7 +323,7 @@ describe("basic Database with subscription", function () {
|
|
307
323
|
});
|
308
324
|
beforeEach(async function () {
|
309
325
|
await sthis.start();
|
310
|
-
db =
|
326
|
+
db = DatabaseFactory("factory-name");
|
311
327
|
didRun = 0;
|
312
328
|
waitForSub = new Promise((resolve) => {
|
313
329
|
unsubscribe = db.subscribe((docs) => {
|
@@ -351,9 +367,8 @@ describe("basic Database with no update subscription", function () {
|
|
351
367
|
});
|
352
368
|
beforeEach(async function () {
|
353
369
|
await sthis.start();
|
354
|
-
db =
|
370
|
+
db = DatabaseFactory("factory-name");
|
355
371
|
didRun = 0;
|
356
|
-
|
357
372
|
unsubscribe = db.subscribe(() => {
|
358
373
|
didRun++;
|
359
374
|
});
|
@@ -390,7 +405,7 @@ describe("database with files input", () => {
|
|
390
405
|
beforeEach(async function () {
|
391
406
|
await sthis.start();
|
392
407
|
imagefiles = await buildBlobFiles();
|
393
|
-
db =
|
408
|
+
db = DatabaseFactory("fireproof-with-images");
|
394
409
|
const doc = {
|
395
410
|
_id: "images-main",
|
396
411
|
type: "files",
|
@@ -472,3 +487,150 @@ describe("database with files input", () => {
|
|
472
487
|
expect(file.size).toBe(imagefiles[0].file.size);
|
473
488
|
});
|
474
489
|
});
|
490
|
+
|
491
|
+
describe("StoreURIRuntime", () => {
|
492
|
+
const sthis = mockSuperThis();
|
493
|
+
let safeEnv: string | undefined;
|
494
|
+
let unreg: () => void;
|
495
|
+
beforeEach(async () => {
|
496
|
+
await sthis.start();
|
497
|
+
safeEnv = sthis.env.get("FP_STORAGE_URL");
|
498
|
+
sthis.env.set("FP_STORAGE_URL", "my://bla/storage");
|
499
|
+
unreg = bs.registerStoreProtocol({
|
500
|
+
protocol: "murks",
|
501
|
+
isDefault: true,
|
502
|
+
defaultURI: function (): URI {
|
503
|
+
return URI.from("murks://fp");
|
504
|
+
},
|
505
|
+
gateway: function (): Promise<bs.Gateway> {
|
506
|
+
throw new Error("Function not implemented.");
|
507
|
+
},
|
508
|
+
test: function (): Promise<bs.TestGateway> {
|
509
|
+
throw new Error("Function not implemented.");
|
510
|
+
},
|
511
|
+
});
|
512
|
+
});
|
513
|
+
afterEach(() => {
|
514
|
+
sthis.env.set("FP_STORAGE_URL", safeEnv);
|
515
|
+
unreg();
|
516
|
+
});
|
517
|
+
it("default toStoreURIRuntime", () => {
|
518
|
+
expect(JSON.parse(JSON.stringify(toStoreURIRuntime(sthis, "test")))).toEqual({
|
519
|
+
data: {
|
520
|
+
data: "my://bla/storage?name=test&store=data&storekey=%40test-data%40&suffix=.car&urlGen=fromEnv",
|
521
|
+
file: "my://bla/storage?name=test&store=data&storekey=%40test-data%40&urlGen=fromEnv",
|
522
|
+
meta: "my://bla/storage?name=test&store=meta&storekey=%40test-meta%40&urlGen=fromEnv",
|
523
|
+
wal: "my://bla/storage?name=test&store=wal&storekey=%40test-wal%40&urlGen=fromEnv",
|
524
|
+
},
|
525
|
+
idx: {
|
526
|
+
data: "my://bla/storage?index=idx&name=test&store=data&storekey=%40test-data-idx%40&suffix=.car&urlGen=fromEnv",
|
527
|
+
file: "my://bla/storage?index=idx&name=test&store=data&storekey=%40test-data-idx%40&urlGen=fromEnv",
|
528
|
+
meta: "my://bla/storage?index=idx&name=test&store=meta&storekey=%40test-meta-idx%40&urlGen=fromEnv",
|
529
|
+
wal: "my://bla/storage?index=idx&name=test&store=wal&storekey=%40test-wal-idx%40&urlGen=fromEnv",
|
530
|
+
},
|
531
|
+
});
|
532
|
+
// keyConfigOpts(sthis: SuperThis, name: string, opts?: ConfigOpts): string {
|
533
|
+
});
|
534
|
+
it("no name toStoreURIRuntime", () => {
|
535
|
+
expect(JSON.parse(JSON.stringify(toStoreURIRuntime(sthis)))).toEqual({
|
536
|
+
data: {
|
537
|
+
data: "my://bla/storage?name=storage&store=data&storekey=%40storage-data%40&suffix=.car&urlGen=fromEnv",
|
538
|
+
file: "my://bla/storage?name=storage&store=data&storekey=%40storage-data%40&urlGen=fromEnv",
|
539
|
+
meta: "my://bla/storage?name=storage&store=meta&storekey=%40storage-meta%40&urlGen=fromEnv",
|
540
|
+
wal: "my://bla/storage?name=storage&store=wal&storekey=%40storage-wal%40&urlGen=fromEnv",
|
541
|
+
},
|
542
|
+
idx: {
|
543
|
+
data: "my://bla/storage?index=idx&name=storage&store=data&storekey=%40storage-data-idx%40&suffix=.car&urlGen=fromEnv",
|
544
|
+
file: "my://bla/storage?index=idx&name=storage&store=data&storekey=%40storage-data-idx%40&urlGen=fromEnv",
|
545
|
+
meta: "my://bla/storage?index=idx&name=storage&store=meta&storekey=%40storage-meta-idx%40&urlGen=fromEnv",
|
546
|
+
wal: "my://bla/storage?index=idx&name=storage&store=wal&storekey=%40storage-wal-idx%40&urlGen=fromEnv",
|
547
|
+
},
|
548
|
+
});
|
549
|
+
});
|
550
|
+
|
551
|
+
it("set toStoreURIRuntime", () => {
|
552
|
+
expect(
|
553
|
+
JSON.parse(
|
554
|
+
JSON.stringify(
|
555
|
+
toStoreURIRuntime(sthis, "xxx", {
|
556
|
+
base: "my://storage-base",
|
557
|
+
data: {
|
558
|
+
data: "my://storage-data?name=yyy",
|
559
|
+
meta: "my://storage-meta",
|
560
|
+
},
|
561
|
+
idx: {
|
562
|
+
data: "my://storage-idx-data?name=yyy&index=bla",
|
563
|
+
meta: "my://storage-idx-meta",
|
564
|
+
},
|
565
|
+
}),
|
566
|
+
),
|
567
|
+
),
|
568
|
+
).toEqual({
|
569
|
+
data: {
|
570
|
+
data: "my://storage-data?name=yyy&store=data&storekey=%40yyy-data%40&suffix=.car",
|
571
|
+
file: "my://storage-data?name=yyy&store=data&storekey=%40yyy-data%40",
|
572
|
+
meta: "my://storage-meta?name=storage-meta&store=meta&storekey=%40storage-meta-meta%40",
|
573
|
+
wal: "my://storage-base?name=xxx&store=wal&storekey=%40xxx-wal%40",
|
574
|
+
},
|
575
|
+
idx: {
|
576
|
+
data: "my://storage-idx-data?index=bla&name=yyy&store=data&storekey=%40yyy-data-idx%40&suffix=.car",
|
577
|
+
file: "my://storage-idx-data?index=bla&name=yyy&store=data&storekey=%40yyy-data-idx%40",
|
578
|
+
meta: "my://storage-idx-meta?index=idx&name=storage-idx-meta&store=meta&storekey=%40storage-idx-meta-meta-idx%40",
|
579
|
+
wal: "my://storage-base?index=idx&name=xxx&store=wal&storekey=%40xxx-wal-idx%40",
|
580
|
+
},
|
581
|
+
});
|
582
|
+
});
|
583
|
+
|
584
|
+
it("default-reg toStoreURIRuntime", () => {
|
585
|
+
sthis.env.delete("FP_STORAGE_URL");
|
586
|
+
expect(JSON.parse(JSON.stringify(toStoreURIRuntime(sthis, "maxi")))).toEqual({
|
587
|
+
data: {
|
588
|
+
data: "murks://fp?name=maxi&store=data&storekey=%40maxi-data%40&suffix=.car&urlGen=default",
|
589
|
+
file: "murks://fp?name=maxi&store=data&storekey=%40maxi-data%40&urlGen=default",
|
590
|
+
meta: "murks://fp?name=maxi&store=meta&storekey=%40maxi-meta%40&urlGen=default",
|
591
|
+
wal: "murks://fp?name=maxi&store=wal&storekey=%40maxi-wal%40&urlGen=default",
|
592
|
+
},
|
593
|
+
idx: {
|
594
|
+
data: "murks://fp?index=idx&name=maxi&store=data&storekey=%40maxi-data-idx%40&suffix=.car&urlGen=default",
|
595
|
+
file: "murks://fp?index=idx&name=maxi&store=data&storekey=%40maxi-data-idx%40&urlGen=default",
|
596
|
+
meta: "murks://fp?index=idx&name=maxi&store=meta&storekey=%40maxi-meta-idx%40&urlGen=default",
|
597
|
+
wal: "murks://fp?index=idx&name=maxi&store=wal&storekey=%40maxi-wal-idx%40&urlGen=default",
|
598
|
+
},
|
599
|
+
});
|
600
|
+
});
|
601
|
+
|
602
|
+
it("keyConfigOpts", () => {
|
603
|
+
expect(JSON.parse(keyConfigOpts(sthis, "test"))).toEqual([
|
604
|
+
{
|
605
|
+
name: "test",
|
606
|
+
},
|
607
|
+
{
|
608
|
+
stores: [
|
609
|
+
{
|
610
|
+
data: {
|
611
|
+
data: "my://bla/storage?name=test&store=data&storekey=%40test-data%40&suffix=.car&urlGen=fromEnv",
|
612
|
+
file: "my://bla/storage?name=test&store=data&storekey=%40test-data%40&urlGen=fromEnv",
|
613
|
+
meta: "my://bla/storage?name=test&store=meta&storekey=%40test-meta%40&urlGen=fromEnv",
|
614
|
+
wal: "my://bla/storage?name=test&store=wal&storekey=%40test-wal%40&urlGen=fromEnv",
|
615
|
+
},
|
616
|
+
},
|
617
|
+
{
|
618
|
+
idx: {
|
619
|
+
data: "my://bla/storage?index=idx&name=test&store=data&storekey=%40test-data-idx%40&suffix=.car&urlGen=fromEnv",
|
620
|
+
file: "my://bla/storage?index=idx&name=test&store=data&storekey=%40test-data-idx%40&urlGen=fromEnv",
|
621
|
+
meta: "my://bla/storage?index=idx&name=test&store=meta&storekey=%40test-meta-idx%40&urlGen=fromEnv",
|
622
|
+
wal: "my://bla/storage?index=idx&name=test&store=wal&storekey=%40test-wal-idx%40&urlGen=fromEnv",
|
623
|
+
},
|
624
|
+
},
|
625
|
+
],
|
626
|
+
},
|
627
|
+
]);
|
628
|
+
});
|
629
|
+
|
630
|
+
it("check file protocol defaultURI", () => {
|
631
|
+
const gw = fileGatewayFactoryItem();
|
632
|
+
expect(gw.defaultURI(sthis).toString()).toBe(
|
633
|
+
`file://${sthis.env.get("HOME")}/.fireproof/${FILESTORE_VERSION.replace(/-.*$/, "")}`,
|
634
|
+
);
|
635
|
+
});
|
636
|
+
});
|