@fireproof/core 0.19.121-dev → 0.20.0-dev-preview-05
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/README.md +13 -12
- package/deno/index.d.ts +7 -0
- package/deno/index.js +66 -0
- package/deno/index.js.map +1 -0
- package/deno/metafile-esm.json +1 -0
- package/deno.json +3 -4
- package/index.cjs +1797 -1431
- package/index.cjs.map +1 -1
- package/index.d.cts +760 -381
- package/index.d.ts +760 -381
- package/index.js +1976 -913
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/{node-filesystem.cjs → index.cjs} +17 -6
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +7 -0
- package/node/index.d.ts +7 -0
- package/node/{node-filesystem.js → index.js} +25 -5
- package/node/index.js.map +1 -0
- package/node/metafile-cjs.json +1 -1
- package/node/metafile-esm.json +1 -1
- package/package.json +27 -17
- package/react/index.cjs +22 -22
- package/react/index.cjs.map +1 -1
- package/react/index.d.cts +7 -7
- package/react/index.d.ts +7 -7
- package/react/index.js +22 -22
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -1
- package/react/metafile-esm.json +1 -1
- package/tests/blockstore/fp-envelope.test.ts-off +65 -0
- package/tests/blockstore/interceptor-gateway.test.ts +122 -0
- package/tests/blockstore/keyed-crypto-indexdb-file.test.ts +130 -0
- package/tests/blockstore/keyed-crypto.test.ts +75 -118
- package/tests/blockstore/loader.test.ts +18 -9
- package/tests/blockstore/store.test.ts +40 -31
- package/tests/blockstore/transaction.test.ts +14 -13
- package/tests/fireproof/all-gateway.test.ts +286 -216
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +324 -316
- package/tests/fireproof/crdt.test.ts +78 -19
- package/tests/fireproof/fireproof.test.ts +111 -92
- package/tests/fireproof/hello.test.ts +21 -17
- package/tests/fireproof/indexer.test.ts +74 -50
- package/tests/fireproof/{database.test.ts → ledger.test.ts} +241 -45
- package/tests/fireproof/multiple-ledger.test.ts +2 -2
- package/tests/fireproof/utils.test.ts +47 -6
- package/tests/gateway/file/loader-config.test.ts +307 -0
- package/tests/gateway/fp-envelope-serialize.test.ts +256 -0
- package/tests/gateway/indexdb/loader-config.test.ts +79 -0
- package/tests/helpers.ts +44 -17
- package/tests/react/useFireproof.test.tsx +2 -2
- package/tests/www/gallery.html +2 -2
- package/tests/www/todo-aws.html +1 -1
- package/tests/www/todo-ipfs.html +1 -1
- package/tests/www/todo-local.html +1 -1
- package/tests/www/todo.html +25 -4
- package/web/index.cjs +218 -0
- package/web/index.cjs.map +1 -0
- package/web/index.d.cts +30 -0
- package/web/index.d.ts +30 -0
- package/web/index.js +195 -0
- package/web/index.js.map +1 -0
- package/web/metafile-cjs.json +1 -1
- package/web/metafile-esm.json +1 -1
- package/chunk-7EWIAXTM.js +0 -7
- package/chunk-7EWIAXTM.js.map +0 -1
- package/chunk-F4FC6B2T.js +0 -63
- package/chunk-F4FC6B2T.js.map +0 -1
- package/chunk-PZ5AY32C.js +0 -10
- package/chunk-PZ5AY32C.js.map +0 -1
- package/chunk-RXC4JGJT.js +0 -301
- package/chunk-RXC4JGJT.js.map +0 -1
- package/gateway-C62S56GY.js +0 -66
- package/gateway-C62S56GY.js.map +0 -1
- package/gateway-VVS4QWDA.js +0 -145
- package/gateway-VVS4QWDA.js.map +0 -1
- package/key-bag-file-PWZ3QE7B.js +0 -55
- package/key-bag-file-PWZ3QE7B.js.map +0 -1
- package/key-bag-indexdb-SYG3YD4D.js +0 -51
- package/key-bag-indexdb-SYG3YD4D.js.map +0 -1
- package/node/chunk-4A4RAVNS.js +0 -17
- package/node/chunk-4A4RAVNS.js.map +0 -1
- package/node/mem-filesystem.cjs +0 -72
- package/node/mem-filesystem.cjs.map +0 -1
- package/node/mem-filesystem.d.cts +0 -25
- package/node/mem-filesystem.d.ts +0 -25
- package/node/mem-filesystem.js +0 -40
- package/node/mem-filesystem.js.map +0 -1
- package/node/node-filesystem.cjs.map +0 -1
- package/node/node-filesystem.d.cts +0 -35
- package/node/node-filesystem.d.ts +0 -35
- package/node/node-filesystem.js.map +0 -1
- package/tests/fireproof/config.test.ts +0 -172
- package/utils-ZVVGAXFE.js +0 -13
- package/utils-ZVVGAXFE.js.map +0 -1
- package/web/gateway-impl.cjs +0 -183
- package/web/gateway-impl.cjs.map +0 -1
- package/web/gateway-impl.d.cts +0 -31
- package/web/gateway-impl.d.ts +0 -31
- package/web/gateway-impl.js +0 -162
- package/web/gateway-impl.js.map +0 -1
- /package/tests/blockstore/{fragment-gateway.test.ts → fragment-gateway.test.ts-off} +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CRDT, ensureSuperThis } from "@fireproof/core";
|
1
|
+
import { CRDT, defaultWriteQueueOpts, ensureSuperThis, LedgerOpts, toStoreURIRuntime, rt } 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";
|
@@ -12,7 +12,13 @@ describe("Fresh crdt", function () {
|
|
12
12
|
});
|
13
13
|
beforeEach(async function () {
|
14
14
|
await sthis.start();
|
15
|
-
|
15
|
+
const dbOpts: LedgerOpts = {
|
16
|
+
writeQueue: defaultWriteQueueOpts({}),
|
17
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
18
|
+
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
19
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
20
|
+
};
|
21
|
+
crdt = new CRDT(sthis, dbOpts);
|
16
22
|
});
|
17
23
|
it("should have an empty head", async function () {
|
18
24
|
const head = crdt.clock.head;
|
@@ -49,7 +55,13 @@ describe("CRDT with one record", function () {
|
|
49
55
|
|
50
56
|
beforeEach(async function () {
|
51
57
|
await sthis.start();
|
52
|
-
|
58
|
+
const dbOpts: LedgerOpts = {
|
59
|
+
writeQueue: defaultWriteQueueOpts({}),
|
60
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
61
|
+
storeUrls: toStoreURIRuntime(sthis, `test@${sthis.nextId().str}`),
|
62
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
63
|
+
};
|
64
|
+
crdt = new CRDT(sthis, dbOpts);
|
53
65
|
firstPut = await crdt.bulk([{ id: "hello", value: { hello: "world" } }]);
|
54
66
|
});
|
55
67
|
it("should have a one-element head", async function () {
|
@@ -99,7 +111,13 @@ describe("CRDT with a multi-write", function () {
|
|
99
111
|
});
|
100
112
|
beforeEach(async function () {
|
101
113
|
await sthis.start();
|
102
|
-
|
114
|
+
const dbOpts: LedgerOpts = {
|
115
|
+
writeQueue: defaultWriteQueueOpts({}),
|
116
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
117
|
+
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
118
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
119
|
+
};
|
120
|
+
crdt = new CRDT(sthis, dbOpts);
|
103
121
|
firstPut = await crdt.bulk([
|
104
122
|
{ id: "ace", value: { points: 11 } },
|
105
123
|
{ id: "king", value: { points: 10 } },
|
@@ -164,7 +182,13 @@ describe("CRDT with two multi-writes", function () {
|
|
164
182
|
});
|
165
183
|
beforeEach(async () => {
|
166
184
|
await sthis.start();
|
167
|
-
|
185
|
+
const dbOpts: LedgerOpts = {
|
186
|
+
writeQueue: defaultWriteQueueOpts({}),
|
187
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
188
|
+
storeUrls: toStoreURIRuntime(sthis, `test-multiple-writes@${sthis.nextId().str}`),
|
189
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
190
|
+
};
|
191
|
+
crdt = new CRDT(sthis, dbOpts);
|
168
192
|
firstPut = await crdt.bulk([
|
169
193
|
{ id: "ace", value: { points: 11 } },
|
170
194
|
{ id: "king", value: { points: 10 } },
|
@@ -212,7 +236,13 @@ describe("Compact a named CRDT with writes", function () {
|
|
212
236
|
});
|
213
237
|
beforeEach(async function () {
|
214
238
|
await sthis.start();
|
215
|
-
|
239
|
+
const dbOpts: LedgerOpts = {
|
240
|
+
writeQueue: defaultWriteQueueOpts({}),
|
241
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
242
|
+
storeUrls: toStoreURIRuntime(sthis, `named-crdt-compaction`),
|
243
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
244
|
+
};
|
245
|
+
crdt = new CRDT(sthis, dbOpts);
|
216
246
|
for (let i = 0; i < 10; i++) {
|
217
247
|
const bulk = [
|
218
248
|
{ id: "ace", value: { points: 11 } },
|
@@ -268,12 +298,18 @@ describe("CRDT with an index", function () {
|
|
268
298
|
});
|
269
299
|
beforeEach(async function () {
|
270
300
|
await sthis.start();
|
271
|
-
|
301
|
+
const dbOpts: LedgerOpts = {
|
302
|
+
writeQueue: defaultWriteQueueOpts({}),
|
303
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
304
|
+
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
305
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
306
|
+
};
|
307
|
+
crdt = new CRDT<CRDTTestType>(sthis, dbOpts);
|
272
308
|
await crdt.bulk([
|
273
309
|
{ id: "ace", value: { points: 11 } },
|
274
310
|
{ id: "king", value: { points: 10 } },
|
275
311
|
]);
|
276
|
-
idx = await index<number, CRDTTestType>(
|
312
|
+
idx = await index<number, CRDTTestType>({ crdt: crdt }, "points");
|
277
313
|
});
|
278
314
|
it("should query the data", async function () {
|
279
315
|
const got = await idx.query({ range: [9, 12] });
|
@@ -282,7 +318,7 @@ describe("CRDT with an index", function () {
|
|
282
318
|
expect(got.rows[0].key).toBe(10);
|
283
319
|
});
|
284
320
|
it("should register the index", async function () {
|
285
|
-
const rIdx = await index<number, CRDTTestType>(
|
321
|
+
const rIdx = await index<number, CRDTTestType>({ crdt: crdt }, "points");
|
286
322
|
expect(rIdx).toBeTruthy();
|
287
323
|
expect(rIdx.name).toBe("points");
|
288
324
|
const got = await rIdx.query({ range: [9, 12] });
|
@@ -291,7 +327,7 @@ describe("CRDT with an index", function () {
|
|
291
327
|
expect(got.rows[0].key).toBe(10);
|
292
328
|
});
|
293
329
|
it("creating a different index with same name should not work", async function () {
|
294
|
-
const e = await index(
|
330
|
+
const e = await index({ crdt: crdt }, "points", (doc) => doc._id)
|
295
331
|
.query()
|
296
332
|
.catch((err) => err);
|
297
333
|
expect(e.message).toMatch(/cannot apply/);
|
@@ -314,15 +350,26 @@ describe("Loader with a committed transaction", function () {
|
|
314
350
|
});
|
315
351
|
beforeEach(async function () {
|
316
352
|
await sthis.start();
|
317
|
-
|
353
|
+
const dbOpts: LedgerOpts = {
|
354
|
+
writeQueue: defaultWriteQueueOpts({}),
|
355
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
356
|
+
storeUrls: toStoreURIRuntime(sthis, dbname),
|
357
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
358
|
+
};
|
359
|
+
crdt = new CRDT(sthis, dbOpts);
|
318
360
|
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
|
319
361
|
expect(blockstore.loader).toBeTruthy();
|
320
|
-
loader = blockstore.loader;
|
362
|
+
loader = blockstore.loader as bs.Loader;
|
321
363
|
done = await crdt.bulk([{ id: "foo", value: { foo: "bar" } }]);
|
322
364
|
});
|
323
|
-
it("should have a name", function () {
|
324
|
-
|
325
|
-
|
365
|
+
// it("should have a name", function () {
|
366
|
+
// expect(loader.ebOpts.storeUrls).toEqual({
|
367
|
+
// data: "file://./dist/fp-dir-file?name=test-loader&store=data&storekey=%40test-loader-data%40&suffix=.car&urlGen=fromEnv",
|
368
|
+
// file: "file://./dist/fp-dir-file?name=test-loader&store=data&storekey=%40test-loader-data%40&urlGen=fromEnv",
|
369
|
+
// meta: "file://./dist/fp-dir-file?name=test-loader&store=meta&storekey=%40test-loader-meta%40&urlGen=fromEnv",
|
370
|
+
// wal: "file://./dist/fp-dir-file?name=test-loader&store=wal&storekey=%40test-loader-wal%40&urlGen=fromEnv",
|
371
|
+
// });
|
372
|
+
// });
|
326
373
|
it("should commit a transaction", function () {
|
327
374
|
expect(done.head).toBeTruthy();
|
328
375
|
// expect(done.cars).toBeTruthy();
|
@@ -357,10 +404,16 @@ describe("Loader with two committed transactions", function () {
|
|
357
404
|
});
|
358
405
|
beforeEach(async function () {
|
359
406
|
await sthis.start();
|
360
|
-
|
407
|
+
const dbOpts: LedgerOpts = {
|
408
|
+
writeQueue: defaultWriteQueueOpts({}),
|
409
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
410
|
+
storeUrls: toStoreURIRuntime(sthis, "test-loader"),
|
411
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
412
|
+
};
|
413
|
+
crdt = new CRDT(sthis, dbOpts);
|
361
414
|
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
|
362
415
|
expect(blockstore.loader).toBeTruthy();
|
363
|
-
loader = blockstore.loader;
|
416
|
+
loader = blockstore.loader as bs.Loader;
|
364
417
|
done1 = await crdt.bulk([{ id: "apple", value: { foo: "bar" } }]);
|
365
418
|
done2 = await crdt.bulk([{ id: "orange", value: { foo: "bar" } }]);
|
366
419
|
});
|
@@ -407,10 +460,16 @@ describe("Loader with many committed transactions", function () {
|
|
407
460
|
});
|
408
461
|
beforeEach(async function () {
|
409
462
|
await sthis.start();
|
410
|
-
|
463
|
+
const dbOpts: LedgerOpts = {
|
464
|
+
writeQueue: defaultWriteQueueOpts({}),
|
465
|
+
keyBag: rt.defaultKeyBagOpts(sthis),
|
466
|
+
storeUrls: toStoreURIRuntime(sthis, "test-loader-many"),
|
467
|
+
storeEnDe: bs.ensureStoreEnDeFile({}),
|
468
|
+
};
|
469
|
+
crdt = new CRDT(sthis, dbOpts);
|
411
470
|
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
|
412
471
|
expect(blockstore.loader).toBeTruthy();
|
413
|
-
loader = blockstore.loader;
|
472
|
+
loader = blockstore.loader as bs.Loader;
|
414
473
|
dones = [];
|
415
474
|
for (let i = 0; i < count; i++) {
|
416
475
|
const did = await crdt.bulk([{ id: `apple${i}`, value: { foo: "bar" } }]);
|