@fireproof/core 0.19.8-dev-global → 0.19.11-dev-dryrun
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 +34 -0
- package/chunk-7EWIAXTM.js +7 -0
- package/chunk-7EWIAXTM.js.map +1 -0
- package/chunk-MAK4D54P.js +280 -0
- package/chunk-MAK4D54P.js.map +1 -0
- package/chunk-PB4BKL4O.js +7 -0
- package/chunk-PB4BKL4O.js.map +1 -0
- package/chunk-XINRLWR3.js +75 -0
- package/chunk-XINRLWR3.js.map +1 -0
- package/deno.json +20 -0
- package/{store-indexdb-WLRSICCB.js → gateway-7OM6OSYK.js} +49 -82
- package/gateway-7OM6OSYK.js.map +1 -0
- package/gateway-VWWKLHUI.js +144 -0
- package/gateway-VWWKLHUI.js.map +1 -0
- package/index.cjs +2351 -1825
- package/index.cjs.map +1 -1
- package/index.d.cts +659 -535
- package/index.d.ts +659 -535
- package/index.global.js +26315 -20709
- package/index.global.js.map +1 -1
- package/index.js +1700 -1058
- package/index.js.map +1 -1
- package/key-bag-file-DFMW6ZM6.js +54 -0
- package/key-bag-file-DFMW6ZM6.js.map +1 -0
- package/key-bag-indexdb-R2RWGSQ4.js +50 -0
- package/key-bag-indexdb-R2RWGSQ4.js.map +1 -0
- package/mem-filesystem-BZQZLUR6.js +41 -0
- package/mem-filesystem-BZQZLUR6.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-7YZR3POJ.js +45 -0
- package/node-filesystem-7YZR3POJ.js.map +1 -0
- package/package.json +12 -8
- package/tests/blockstore/fragment-gateway.test.ts +107 -0
- package/tests/blockstore/keyed-crypto.test.ts +332 -0
- package/tests/blockstore/loader.test.ts +24 -19
- package/tests/blockstore/store.test.ts +51 -40
- package/tests/blockstore/transaction.test.ts +19 -15
- package/tests/fireproof/all-gateway.test.ts +395 -0
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.car +0 -0
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.js +316 -0
- package/tests/fireproof/config.test.ts +94 -78
- package/tests/fireproof/convert_uint8.py +27 -0
- package/tests/fireproof/crdt.test.ts +34 -28
- package/tests/fireproof/database.test.ts +22 -14
- package/tests/fireproof/fireproof.test.fixture.ts +133 -0
- package/tests/fireproof/fireproof.test.ts +331 -219
- package/tests/fireproof/hello.test.ts +34 -18
- package/tests/fireproof/indexer.test.ts +34 -27
- package/tests/fireproof/utils.test.ts +65 -0
- package/tests/helpers.ts +28 -57
- package/utils-AISQB3PB.js +14 -0
- package/utils-AISQB3PB.js.map +1 -0
- package/chunk-BNL4PVBF.js +0 -314
- package/chunk-BNL4PVBF.js.map +0 -1
- package/chunk-JW2QT6BF.js +0 -184
- package/chunk-JW2QT6BF.js.map +0 -1
- package/node-sys-container-MIEX6ELJ.js +0 -29
- package/node-sys-container-MIEX6ELJ.js.map +0 -1
- package/store-file-VJ6BI4II.js +0 -191
- package/store-file-VJ6BI4II.js.map +0 -1
- package/store-indexdb-WLRSICCB.js.map +0 -1
@@ -1,16 +1,16 @@
|
|
1
1
|
import { CID } from "multiformats";
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { NotFoundError } from "../../src/blockstore/gateway";
|
2
|
+
import { bs, NotFoundError, SuperThis } from "@fireproof/core";
|
3
|
+
import { mockSuperThis } from "../helpers";
|
5
4
|
|
6
5
|
const decoder = new TextDecoder("utf-8");
|
7
6
|
|
8
|
-
function runtime() {
|
9
|
-
return bs.toStoreRuntime({},
|
7
|
+
function runtime(sthis: SuperThis) {
|
8
|
+
return bs.toStoreRuntime({}, sthis);
|
10
9
|
}
|
11
10
|
|
12
|
-
function mockLoader(name: string): bs.Loadable {
|
11
|
+
function mockLoader(sthis: SuperThis, name: string): bs.Loadable {
|
13
12
|
return {
|
13
|
+
sthis,
|
14
14
|
name,
|
15
15
|
ebOpts: {
|
16
16
|
store: {},
|
@@ -20,18 +20,19 @@ function mockLoader(name: string): bs.Loadable {
|
|
20
20
|
|
21
21
|
describe("DataStore", function () {
|
22
22
|
let store: bs.DataStore;
|
23
|
-
let raw: bs.
|
23
|
+
let raw: bs.TestGateway;
|
24
24
|
|
25
|
+
const sthis = mockSuperThis();
|
25
26
|
afterEach(async () => {
|
26
27
|
await store.close();
|
27
28
|
await store.destroy();
|
28
29
|
});
|
29
30
|
|
30
31
|
beforeEach(async () => {
|
31
|
-
await
|
32
|
-
store = await runtime().makeDataStore(mockLoader("test"));
|
32
|
+
await sthis.start();
|
33
|
+
store = await runtime(sthis).makeDataStore(mockLoader(sthis, "test"));
|
33
34
|
await store.start();
|
34
|
-
raw = await bs.testStoreFactory(store.url);
|
35
|
+
raw = await bs.testStoreFactory(store.url(), sthis);
|
35
36
|
});
|
36
37
|
|
37
38
|
it("should have a name", function () {
|
@@ -44,26 +45,28 @@ describe("DataStore", function () {
|
|
44
45
|
bytes: new Uint8Array([55, 56, 57]),
|
45
46
|
};
|
46
47
|
await store.save(car);
|
47
|
-
const data = await raw.get(store.url, car.cid.toString());
|
48
|
+
const data = await raw.get(store.url(), car.cid.toString());
|
48
49
|
expect(decoder.decode(data)).toEqual(decoder.decode(car.bytes));
|
49
50
|
});
|
50
51
|
});
|
51
52
|
|
52
53
|
describe("DataStore with a saved car", function () {
|
53
54
|
let store: bs.DataStore;
|
54
|
-
let raw: bs.
|
55
|
+
let raw: bs.TestGateway;
|
55
56
|
let car: bs.AnyBlock;
|
56
57
|
|
58
|
+
const sthis = mockSuperThis();
|
59
|
+
|
57
60
|
afterEach(async () => {
|
58
61
|
await store.close();
|
59
62
|
await store.destroy();
|
60
63
|
});
|
61
64
|
|
62
65
|
beforeEach(async function () {
|
63
|
-
await
|
64
|
-
store = await runtime().makeDataStore(mockLoader("test2"));
|
66
|
+
await sthis.start();
|
67
|
+
store = await runtime(sthis).makeDataStore(mockLoader(sthis, "test2"));
|
65
68
|
await store.start();
|
66
|
-
raw = await bs.testStoreFactory(store.url);
|
69
|
+
raw = await bs.testStoreFactory(store.url(), sthis);
|
67
70
|
car = {
|
68
71
|
cid: "cid" as unknown as CID,
|
69
72
|
bytes: new Uint8Array([55, 56, 57, 80]),
|
@@ -72,7 +75,7 @@ describe("DataStore with a saved car", function () {
|
|
72
75
|
});
|
73
76
|
|
74
77
|
it("should have a car", async function () {
|
75
|
-
const data = await raw.get(store.url, car.cid.toString());
|
78
|
+
const data = await raw.get(store.url(), car.cid.toString());
|
76
79
|
expect(decoder.decode(data)).toEqual(decoder.decode(car.bytes));
|
77
80
|
});
|
78
81
|
|
@@ -85,15 +88,16 @@ describe("DataStore with a saved car", function () {
|
|
85
88
|
|
86
89
|
it("should remove a car", async function () {
|
87
90
|
await store.remove(car.cid);
|
88
|
-
const error = (await store.load(car.cid).catch((e: Error) => e)) as NotFoundError;
|
89
|
-
expect(error
|
90
|
-
// matches(error.message, "ENOENT");
|
91
|
+
const { e: error } = (await store.load(car.cid).catch((e: Error) => ({ e }))) as { e: NotFoundError };
|
92
|
+
expect(error).toBeTruthy();
|
91
93
|
});
|
92
94
|
});
|
93
95
|
|
94
96
|
describe("MetaStore", function () {
|
95
97
|
let store: bs.MetaStore;
|
96
|
-
let raw: bs.
|
98
|
+
let raw: bs.TestGateway;
|
99
|
+
|
100
|
+
const sthis = mockSuperThis();
|
97
101
|
|
98
102
|
afterEach(async () => {
|
99
103
|
await store.close();
|
@@ -101,10 +105,10 @@ describe("MetaStore", function () {
|
|
101
105
|
});
|
102
106
|
|
103
107
|
beforeEach(async function () {
|
104
|
-
await
|
105
|
-
store = await runtime().makeMetaStore(mockLoader("test"));
|
108
|
+
await sthis.start();
|
109
|
+
store = await runtime(sthis).makeMetaStore(mockLoader(sthis, "test"));
|
106
110
|
await store.start();
|
107
|
-
raw = await bs.testStoreFactory(store.url);
|
111
|
+
raw = await bs.testStoreFactory(store.url(), sthis);
|
108
112
|
});
|
109
113
|
|
110
114
|
it("should have a name", function () {
|
@@ -115,21 +119,23 @@ describe("MetaStore", function () {
|
|
115
119
|
const cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
|
116
120
|
const h: bs.DbMeta = {
|
117
121
|
cars: [cid],
|
118
|
-
key: undefined,
|
122
|
+
// key: undefined,
|
119
123
|
};
|
120
124
|
await store.save(h);
|
121
|
-
const file = await raw.get(store.url, "main");
|
122
|
-
const
|
123
|
-
|
124
|
-
expect(
|
125
|
-
expect(
|
125
|
+
const file = await raw.get(store.url(), "main");
|
126
|
+
const [blockMeta] = await store.handleByteHeads(file);
|
127
|
+
const decodedHeader = blockMeta.dbMeta;
|
128
|
+
expect(decodedHeader).toBeTruthy();
|
129
|
+
expect(decodedHeader.cars).toBeTruthy();
|
130
|
+
expect(decodedHeader.cars[0].toString()).toEqual(cid.toString());
|
126
131
|
});
|
127
132
|
});
|
128
133
|
|
129
134
|
describe("MetaStore with a saved header", function () {
|
130
135
|
let store: bs.MetaStore;
|
131
|
-
let raw: bs.
|
136
|
+
let raw: bs.TestGateway;
|
132
137
|
let cid: CID;
|
138
|
+
const sthis = mockSuperThis();
|
133
139
|
|
134
140
|
afterEach(async () => {
|
135
141
|
await store.close();
|
@@ -137,21 +143,26 @@ describe("MetaStore with a saved header", function () {
|
|
137
143
|
});
|
138
144
|
|
139
145
|
beforeEach(async function () {
|
140
|
-
await
|
141
|
-
store = await runtime().makeMetaStore(mockLoader("test-saved-header"));
|
146
|
+
await sthis.start();
|
147
|
+
store = await runtime(sthis).makeMetaStore(mockLoader(sthis, "test-saved-header"));
|
142
148
|
await store.start();
|
143
|
-
raw = await bs.testStoreFactory(store.url);
|
149
|
+
raw = await bs.testStoreFactory(store.url(), sthis);
|
144
150
|
cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
|
145
|
-
await store.save({ cars: [cid]
|
151
|
+
await store.save({ cars: [cid] /*, key: undefined */ });
|
146
152
|
});
|
147
153
|
|
148
154
|
it("should have a header", async function () {
|
149
|
-
const
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
expect(header
|
154
|
-
expect(header.
|
155
|
+
const bytes = await raw.get(store.url(), "main");
|
156
|
+
const data = decoder.decode(bytes);
|
157
|
+
expect(data).toMatch(/parents/);
|
158
|
+
const header = JSON.parse(data)[0];
|
159
|
+
expect(header).toBeDefined();
|
160
|
+
expect(header.parents).toBeDefined();
|
161
|
+
const [blockMeta] = await store.handleByteHeads(bytes);
|
162
|
+
const decodedHeader = blockMeta.dbMeta;
|
163
|
+
expect(decodedHeader).toBeDefined();
|
164
|
+
expect(decodedHeader.cars).toBeDefined();
|
165
|
+
expect(decodedHeader.cars[0].toString()).toEqual(cid.toString());
|
155
166
|
});
|
156
167
|
|
157
168
|
it("should load a header", async function () {
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { CID } from "multiformats";
|
2
|
-
|
3
|
-
import {
|
2
|
+
import { bs, SuperThis } from "@fireproof/core";
|
3
|
+
import { mockSuperThis } from "../helpers";
|
4
4
|
|
5
5
|
describe("Fresh TransactionBlockstore", function () {
|
6
6
|
let blocks: bs.BaseBlockstore;
|
7
|
+
const sthis = mockSuperThis();
|
7
8
|
beforeEach(function () {
|
8
9
|
blocks = new bs.BaseBlockstore();
|
9
10
|
});
|
@@ -14,7 +15,7 @@ describe("Fresh TransactionBlockstore", function () {
|
|
14
15
|
expect(blocks.loader).toBeFalsy();
|
15
16
|
});
|
16
17
|
it("should not put", async function () {
|
17
|
-
const value =
|
18
|
+
const value = sthis.txt.encode("value");
|
18
19
|
const e = await blocks.put("key" as unknown as bs.AnyLink, value).catch((e) => e);
|
19
20
|
expect(e.message).toMatch(/transaction/g);
|
20
21
|
});
|
@@ -32,8 +33,9 @@ describe("Fresh TransactionBlockstore", function () {
|
|
32
33
|
|
33
34
|
describe("TransactionBlockstore with name", function () {
|
34
35
|
let blocks: bs.EncryptedBlockstore;
|
36
|
+
const sthis = mockSuperThis();
|
35
37
|
beforeEach(function () {
|
36
|
-
blocks = new bs.EncryptedBlockstore({ name: "test" });
|
38
|
+
blocks = new bs.EncryptedBlockstore(sthis, { name: "test" });
|
37
39
|
});
|
38
40
|
it("should have a name", function () {
|
39
41
|
expect(blocks.name).toEqual("test");
|
@@ -42,7 +44,7 @@ describe("TransactionBlockstore with name", function () {
|
|
42
44
|
expect(blocks.loader).toBeTruthy();
|
43
45
|
});
|
44
46
|
it("should get from loader", async function () {
|
45
|
-
const bytes =
|
47
|
+
const bytes = sthis.txt.encode("bytes");
|
46
48
|
expect(blocks.loader).toBeTruthy();
|
47
49
|
blocks.loader.getBlock = async (cid) => {
|
48
50
|
return { cid, bytes };
|
@@ -55,14 +57,15 @@ describe("TransactionBlockstore with name", function () {
|
|
55
57
|
describe("A transaction", function () {
|
56
58
|
let tblocks: bs.CarTransaction;
|
57
59
|
let blocks: bs.EncryptedBlockstore;
|
60
|
+
const sthis = mockSuperThis();
|
58
61
|
beforeEach(async function () {
|
59
|
-
blocks = new bs.EncryptedBlockstore({ name: "test" });
|
62
|
+
blocks = new bs.EncryptedBlockstore(sthis, { name: "test" });
|
60
63
|
tblocks = new bs.CarTransaction(blocks);
|
61
64
|
blocks.transactions.add(tblocks);
|
62
65
|
});
|
63
66
|
it("should put and get", async function () {
|
64
67
|
const cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
|
65
|
-
const bytes =
|
68
|
+
const bytes = sthis.txt.encode("bytes");
|
66
69
|
await tblocks.put(cid, bytes);
|
67
70
|
expect(blocks.transactions.has(tblocks)).toBeTruthy();
|
68
71
|
const got = await tblocks.get(cid);
|
@@ -72,14 +75,15 @@ describe("A transaction", function () {
|
|
72
75
|
});
|
73
76
|
});
|
74
77
|
|
75
|
-
function asUInt8Array(str: string) {
|
76
|
-
return
|
78
|
+
function asUInt8Array(str: string, sthis: SuperThis) {
|
79
|
+
return sthis.txt.encode(str);
|
77
80
|
}
|
78
81
|
|
79
82
|
describe("TransactionBlockstore with a completed transaction", function () {
|
80
83
|
let blocks: bs.BaseBlockstore;
|
81
84
|
let cid: CID;
|
82
85
|
let cid2: CID;
|
86
|
+
const sthis = mockSuperThis();
|
83
87
|
|
84
88
|
beforeEach(async function () {
|
85
89
|
cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
|
@@ -87,13 +91,13 @@ describe("TransactionBlockstore with a completed transaction", function () {
|
|
87
91
|
|
88
92
|
blocks = new bs.BaseBlockstore();
|
89
93
|
await blocks.transaction(async (tblocks) => {
|
90
|
-
await tblocks.put(cid, asUInt8Array("value"));
|
91
|
-
await tblocks.put(
|
94
|
+
await tblocks.put(cid, asUInt8Array("value", sthis));
|
95
|
+
await tblocks.put(cid, asUInt8Array("value", sthis));
|
92
96
|
return { head: [] };
|
93
97
|
});
|
94
98
|
await blocks.transaction(async (tblocks) => {
|
95
|
-
await tblocks.put(cid, asUInt8Array("value"));
|
96
|
-
await tblocks.put(cid2, asUInt8Array("value2"));
|
99
|
+
await tblocks.put(cid, asUInt8Array("value", sthis));
|
100
|
+
await tblocks.put(cid2, asUInt8Array("value2", sthis));
|
97
101
|
return { head: [] };
|
98
102
|
});
|
99
103
|
});
|
@@ -104,10 +108,10 @@ describe("TransactionBlockstore with a completed transaction", function () {
|
|
104
108
|
it("should get", async function () {
|
105
109
|
const value = (await blocks.get(cid)) as bs.AnyBlock;
|
106
110
|
expect(value.cid).toEqual(cid);
|
107
|
-
expect(value.bytes.toString()).toEqual(asUInt8Array("value").toString());
|
111
|
+
expect(value.bytes.toString()).toEqual(asUInt8Array("value", sthis).toString());
|
108
112
|
|
109
113
|
const value2 = (await blocks.get(cid2)) as bs.AnyBlock;
|
110
|
-
expect(value2.bytes.toString()).toEqual(asUInt8Array("value2").toString());
|
114
|
+
expect(value2.bytes.toString()).toEqual(asUInt8Array("value2", sthis).toString());
|
111
115
|
});
|
112
116
|
it("should yield entries", async function () {
|
113
117
|
const blz = [];
|