@fireproof/core 0.19.99 → 0.19.101
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/{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/deno.json +3 -1
- 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 +2232 -1781
- package/index.cjs.map +1 -1
- package/index.d.cts +261 -117
- package/index.d.ts +261 -117
- package/index.global.js +12776 -11829
- package/index.global.js.map +1 -1
- package/index.js +1936 -1579
- 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 +4 -2
- 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,21 +1,18 @@
|
|
1
1
|
import { CID } from "multiformats";
|
2
|
-
import { bs, NotFoundError, SuperThis } from "@fireproof/core";
|
3
|
-
import { mockSuperThis } from "../helpers";
|
4
|
-
|
5
|
-
const decoder = new TextDecoder("utf-8");
|
2
|
+
import { bs, NotFoundError, SuperThis, rt } from "@fireproof/core";
|
3
|
+
import { mockSuperThis, noopUrl } from "../helpers";
|
6
4
|
|
7
5
|
function runtime(sthis: SuperThis) {
|
8
|
-
return bs.toStoreRuntime(
|
6
|
+
return bs.toStoreRuntime(sthis);
|
9
7
|
}
|
10
8
|
|
11
|
-
function mockLoader(sthis: SuperThis, name
|
9
|
+
async function mockLoader(sthis: SuperThis, name?: string): Promise<bs.StoreFactoryItem> {
|
10
|
+
const url = noopUrl(name);
|
12
11
|
return {
|
13
12
|
sthis,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
},
|
18
|
-
} as bs.Loadable;
|
13
|
+
url: url,
|
14
|
+
keybag: await rt.kb.getKeyBag(sthis),
|
15
|
+
};
|
19
16
|
}
|
20
17
|
|
21
18
|
describe("DataStore", function () {
|
@@ -30,7 +27,7 @@ describe("DataStore", function () {
|
|
30
27
|
|
31
28
|
beforeEach(async () => {
|
32
29
|
await sthis.start();
|
33
|
-
store = await runtime(sthis).makeDataStore(mockLoader(sthis
|
30
|
+
store = await runtime(sthis).makeDataStore(await mockLoader(sthis));
|
34
31
|
await store.start();
|
35
32
|
raw = await bs.testStoreFactory(store.url(), sthis);
|
36
33
|
});
|
@@ -46,7 +43,7 @@ describe("DataStore", function () {
|
|
46
43
|
};
|
47
44
|
await store.save(car);
|
48
45
|
const data = await raw.get(store.url(), car.cid.toString());
|
49
|
-
expect(
|
46
|
+
expect(sthis.txt.decode(data)).toEqual(sthis.txt.decode(car.bytes));
|
50
47
|
});
|
51
48
|
});
|
52
49
|
|
@@ -54,7 +51,6 @@ describe("DataStore with a saved car", function () {
|
|
54
51
|
let store: bs.DataStore;
|
55
52
|
let raw: bs.TestGateway;
|
56
53
|
let car: bs.AnyBlock;
|
57
|
-
|
58
54
|
const sthis = mockSuperThis();
|
59
55
|
|
60
56
|
afterEach(async () => {
|
@@ -64,9 +60,10 @@ describe("DataStore with a saved car", function () {
|
|
64
60
|
|
65
61
|
beforeEach(async function () {
|
66
62
|
await sthis.start();
|
67
|
-
store = await runtime(sthis).makeDataStore(mockLoader(sthis, "test2"));
|
63
|
+
store = await runtime(sthis).makeDataStore(await mockLoader(sthis, "test2"));
|
68
64
|
await store.start();
|
69
65
|
raw = await bs.testStoreFactory(store.url(), sthis);
|
66
|
+
raw = await bs.testStoreFactory(store.url(), sthis);
|
70
67
|
car = {
|
71
68
|
cid: "cid" as unknown as CID,
|
72
69
|
bytes: new Uint8Array([55, 56, 57, 80]),
|
@@ -76,7 +73,7 @@ describe("DataStore with a saved car", function () {
|
|
76
73
|
|
77
74
|
it("should have a car", async function () {
|
78
75
|
const data = await raw.get(store.url(), car.cid.toString());
|
79
|
-
expect(
|
76
|
+
expect(sthis.txt.decode(data)).toEqual(sthis.txt.decode(car.bytes));
|
80
77
|
});
|
81
78
|
|
82
79
|
it("should load a car", async function () {
|
@@ -106,7 +103,7 @@ describe("MetaStore", function () {
|
|
106
103
|
|
107
104
|
beforeEach(async function () {
|
108
105
|
await sthis.start();
|
109
|
-
store = await runtime(sthis).makeMetaStore(mockLoader(sthis, "test"));
|
106
|
+
store = await runtime(sthis).makeMetaStore(await mockLoader(sthis, "test"));
|
110
107
|
await store.start();
|
111
108
|
raw = await bs.testStoreFactory(store.url(), sthis);
|
112
109
|
});
|
@@ -136,6 +133,7 @@ describe("MetaStore with a saved header", function () {
|
|
136
133
|
let raw: bs.TestGateway;
|
137
134
|
let cid: CID;
|
138
135
|
const sthis = mockSuperThis();
|
136
|
+
// let onload: bs.DbMeta[];
|
139
137
|
|
140
138
|
afterEach(async () => {
|
141
139
|
await store.close();
|
@@ -144,16 +142,22 @@ describe("MetaStore with a saved header", function () {
|
|
144
142
|
|
145
143
|
beforeEach(async function () {
|
146
144
|
await sthis.start();
|
147
|
-
store = await runtime(sthis).makeMetaStore(mockLoader(sthis, "test-saved-header"));
|
145
|
+
store = await runtime(sthis).makeMetaStore(await mockLoader(sthis, "test-saved-header"));
|
148
146
|
await store.start();
|
149
147
|
raw = await bs.testStoreFactory(store.url(), sthis);
|
150
148
|
cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
|
151
149
|
await store.save({ cars: [cid] /*, key: undefined */ });
|
152
150
|
});
|
153
151
|
|
152
|
+
// it("should load", async function () {
|
153
|
+
// expect(onload).toBeTruthy();
|
154
|
+
// expect(onload?.length).toEqual(1);
|
155
|
+
// expect(onload?.[0].cars.toString()).toEqual(cid.toString());
|
156
|
+
// });
|
157
|
+
|
154
158
|
it("should have a header", async function () {
|
155
159
|
const bytes = await raw.get(store.url(), "main");
|
156
|
-
const data =
|
160
|
+
const data = sthis.txt.decode(bytes);
|
157
161
|
expect(data).toMatch(/parents/);
|
158
162
|
const header = JSON.parse(data)[0];
|
159
163
|
expect(header).toBeDefined();
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import { CID } from "multiformats";
|
2
2
|
import { bs, SuperThis } from "@fireproof/core";
|
3
|
-
import { mockSuperThis } from "../helpers";
|
3
|
+
import { mockSuperThis, simpleBlockOpts } from "../helpers";
|
4
4
|
|
5
5
|
describe("Fresh TransactionBlockstore", function () {
|
6
6
|
let blocks: bs.BaseBlockstore;
|
7
7
|
const sthis = mockSuperThis();
|
8
8
|
beforeEach(function () {
|
9
|
-
blocks = new bs.BaseBlockstore();
|
10
|
-
});
|
11
|
-
it("should not have a name", function () {
|
12
|
-
expect(blocks.name).toBeFalsy();
|
9
|
+
blocks = new bs.BaseBlockstore(simpleBlockOpts(sthis));
|
13
10
|
});
|
11
|
+
// it("should not have a name", function () {
|
12
|
+
// expect(blocks.name).toBeFalsy();
|
13
|
+
// });
|
14
14
|
it("should not have a loader", function () {
|
15
15
|
expect(blocks.loader).toBeFalsy();
|
16
16
|
});
|
@@ -34,12 +34,12 @@ describe("Fresh TransactionBlockstore", function () {
|
|
34
34
|
describe("TransactionBlockstore with name", function () {
|
35
35
|
let blocks: bs.EncryptedBlockstore;
|
36
36
|
const sthis = mockSuperThis();
|
37
|
-
beforeEach(function () {
|
38
|
-
blocks = new bs.EncryptedBlockstore(sthis,
|
39
|
-
});
|
40
|
-
it("should have a name", function () {
|
41
|
-
expect(blocks.name).toEqual("test");
|
37
|
+
beforeEach(async function () {
|
38
|
+
blocks = new bs.EncryptedBlockstore(sthis, simpleBlockOpts(sthis));
|
42
39
|
});
|
40
|
+
// it("should have a name", function () {
|
41
|
+
// expect(blocks.name).toEqual("test");
|
42
|
+
// });
|
43
43
|
it("should have a loader", function () {
|
44
44
|
expect(blocks.loader).toBeTruthy();
|
45
45
|
});
|
@@ -59,7 +59,7 @@ describe("A transaction", function () {
|
|
59
59
|
let blocks: bs.EncryptedBlockstore;
|
60
60
|
const sthis = mockSuperThis();
|
61
61
|
beforeEach(async function () {
|
62
|
-
blocks = new bs.EncryptedBlockstore(sthis,
|
62
|
+
blocks = new bs.EncryptedBlockstore(sthis, simpleBlockOpts(sthis, "test"));
|
63
63
|
tblocks = new bs.CarTransaction(blocks);
|
64
64
|
blocks.transactions.add(tblocks);
|
65
65
|
});
|
@@ -89,7 +89,7 @@ describe("TransactionBlockstore with a completed transaction", function () {
|
|
89
89
|
cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
|
90
90
|
cid2 = CID.parse("bafybeibgouhn5ktecpjuovt52zamzvm4dlve5ak7x6d5smms3itkhplnhm");
|
91
91
|
|
92
|
-
blocks = new bs.BaseBlockstore();
|
92
|
+
blocks = new bs.BaseBlockstore(simpleBlockOpts(sthis));
|
93
93
|
await blocks.transaction(async (tblocks) => {
|
94
94
|
await tblocks.put(cid, asUInt8Array("value", sthis));
|
95
95
|
await tblocks.put(cid, asUInt8Array("value", sthis));
|