@fireproof/core 0.20.0-dev-preview-23 → 0.20.0-dev-preview-25
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/deno.json +2 -2
- package/index.cjs +414 -175
- package/index.cjs.map +1 -1
- package/index.d.cts +124 -69
- package/index.d.ts +124 -69
- package/index.js +414 -175
- package/index.js.map +1 -1
- package/indexeddb/index.cjs +2 -2
- package/indexeddb/index.cjs.map +1 -1
- package/indexeddb/index.d.cts +2 -2
- package/indexeddb/index.d.ts +2 -2
- package/indexeddb/index.js +2 -2
- package/indexeddb/index.js.map +1 -1
- package/indexeddb/metafile-cjs.json +1 -1
- package/indexeddb/metafile-esm.json +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +4 -4
- package/tests/blockstore/keyed-crypto-indexeddb-file.test.ts +20 -13
- package/tests/blockstore/keyed-crypto.test.ts +100 -27
- package/tests/fireproof/all-gateway.test.ts +19 -15
- package/tests/gateway/fp-envelope-serialize.test.ts +12 -14
@@ -127,7 +127,7 @@ describe("noop Gateway", function () {
|
|
127
127
|
const carUrl = await carGateway.buildUrl(ctx, carStore.url(), fileContent.cid);
|
128
128
|
await carGateway.start(ctx, carStore.url());
|
129
129
|
const carPutResult = await carGateway.put(ctx, carUrl.Ok(), {
|
130
|
-
type: bs.
|
130
|
+
type: bs.FPEnvelopeTypes.CAR,
|
131
131
|
payload: fileContent.block,
|
132
132
|
});
|
133
133
|
expect(carPutResult.isOk()).toBeTruthy();
|
@@ -137,7 +137,7 @@ describe("noop Gateway", function () {
|
|
137
137
|
const carUrl = await carGateway.buildUrl(ctx, carStore.url(), fileContent.cid);
|
138
138
|
await carGateway.start(ctx, carStore.url());
|
139
139
|
await carGateway.put(ctx, carUrl.Ok(), {
|
140
|
-
type: bs.
|
140
|
+
type: bs.FPEnvelopeTypes.CAR,
|
141
141
|
payload: fileContent.block,
|
142
142
|
});
|
143
143
|
const carGetResult = await carGateway.get(ctx, carUrl.Ok());
|
@@ -150,7 +150,7 @@ describe("noop Gateway", function () {
|
|
150
150
|
const carUrl = await carGateway.buildUrl(ctx, carStore.url(), fileContent.cid);
|
151
151
|
await carGateway.start(ctx, carStore.url());
|
152
152
|
await carGateway.put(ctx, carUrl.Ok(), {
|
153
|
-
type: bs.
|
153
|
+
type: bs.FPEnvelopeTypes.CAR,
|
154
154
|
payload: fileContent.block,
|
155
155
|
});
|
156
156
|
const carDeleteResult = await carGateway.delete(ctx, carUrl.Ok());
|
@@ -187,7 +187,7 @@ describe("noop Gateway", function () {
|
|
187
187
|
const fileUrl = await fileGateway.buildUrl(ctx, fileStore.url(), fileContent.cid);
|
188
188
|
await fileGateway.start(ctx, fileStore.url());
|
189
189
|
const filePutResult = await fileGateway.put(ctx, fileUrl.Ok(), {
|
190
|
-
type: bs.
|
190
|
+
type: bs.FPEnvelopeTypes.FILE,
|
191
191
|
payload: fileContent.block,
|
192
192
|
});
|
193
193
|
expect(filePutResult.Ok()).toBeFalsy();
|
@@ -197,7 +197,7 @@ describe("noop Gateway", function () {
|
|
197
197
|
const fileUrl = await fileGateway.buildUrl(ctx, fileStore.url(), fileContent.cid);
|
198
198
|
await fileGateway.start(ctx, fileStore.url());
|
199
199
|
await fileGateway.put(ctx, fileUrl.Ok(), {
|
200
|
-
type: bs.
|
200
|
+
type: bs.FPEnvelopeTypes.FILE,
|
201
201
|
payload: fileContent.block,
|
202
202
|
});
|
203
203
|
const fileGetResult = await fileGateway.get(ctx, fileUrl.Ok());
|
@@ -209,7 +209,7 @@ describe("noop Gateway", function () {
|
|
209
209
|
const fileUrl = await fileGateway.buildUrl(ctx, fileStore.url(), fileContent.cid);
|
210
210
|
await fileGateway.start(ctx, fileStore.url());
|
211
211
|
await fileGateway.put(ctx, fileUrl.Ok(), {
|
212
|
-
type: bs.
|
212
|
+
type: bs.FPEnvelopeTypes.FILE,
|
213
213
|
payload: fileContent.block,
|
214
214
|
});
|
215
215
|
const fileDeleteResult = await fileGateway.delete(ctx, fileUrl.Ok());
|
@@ -236,7 +236,7 @@ describe("noop Gateway", function () {
|
|
236
236
|
// const walTestDataString = JSON.stringify();
|
237
237
|
// const walTestData = sthis.txt.encode(walTestDataString);
|
238
238
|
const walPutResult = await walGateway.put(ctx, walUrl.Ok(), {
|
239
|
-
type: bs.
|
239
|
+
type: bs.FPEnvelopeTypes.WAL,
|
240
240
|
payload: {
|
241
241
|
operations: [],
|
242
242
|
noLoaderOps: [],
|
@@ -275,7 +275,7 @@ describe("noop Gateway", function () {
|
|
275
275
|
// });
|
276
276
|
// const walTestData = sthis.txt.encode(walTestDataString);
|
277
277
|
await walGateway.put(ctx, walUrl.Ok(), {
|
278
|
-
type: bs.
|
278
|
+
type: bs.FPEnvelopeTypes.WAL,
|
279
279
|
payload: ref,
|
280
280
|
});
|
281
281
|
const walGetResult = await walGateway.get(ctx, walUrl.Ok());
|
@@ -308,7 +308,7 @@ describe("noop Gateway", function () {
|
|
308
308
|
],
|
309
309
|
};
|
310
310
|
await walGateway.put(ctx, walUrl.Ok(), {
|
311
|
-
type: bs.
|
311
|
+
type: bs.FPEnvelopeTypes.WAL,
|
312
312
|
payload: ref,
|
313
313
|
});
|
314
314
|
const walDeleteResult = await walGateway.delete(ctx, walUrl.Ok());
|
@@ -394,12 +394,16 @@ describe("noop Gateway subscribe", function () {
|
|
394
394
|
let didCall = false;
|
395
395
|
const p = new Future<void>();
|
396
396
|
|
397
|
-
const metaSubscribeResult = (await metaGateway.subscribe(
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
397
|
+
const metaSubscribeResult = (await metaGateway.subscribe(
|
398
|
+
ctx,
|
399
|
+
metaUrl.Ok().build().setParam(PARAM.SELF_REFLECT, "x").URI(),
|
400
|
+
async (data: bs.FPEnvelopeMeta) => {
|
401
|
+
// const decodedData = sthis.txt.decode(data);
|
402
|
+
expect(Array.isArray(data.payload)).toBeTruthy();
|
403
|
+
didCall = true;
|
404
|
+
p.resolve();
|
405
|
+
},
|
406
|
+
)) as bs.UnsubscribeResult;
|
403
407
|
expect(metaSubscribeResult.isOk()).toBeTruthy();
|
404
408
|
const ok = await db.put({ _id: "key1", hello: "world1" });
|
405
409
|
expect(ok).toBeTruthy();
|
@@ -3,15 +3,13 @@ import { mockSuperThis, simpleCID } from "../helpers.js";
|
|
3
3
|
import { BuildURI, Result } from "@adviser/cement";
|
4
4
|
import { toJSON } from "multiformats/link";
|
5
5
|
|
6
|
-
const FPEnvelopeType = bs.FPEnvelopeType;
|
7
|
-
|
8
6
|
describe("storage-content", () => {
|
9
7
|
const sthis = mockSuperThis();
|
10
8
|
it("car", async () => {
|
11
9
|
const raw = new Uint8Array([55, 56, 57]);
|
12
10
|
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=data&suffix=.car").URI(), Result.Ok(raw));
|
13
11
|
expect(res.isOk()).toBeTruthy();
|
14
|
-
expect(res.unwrap().type).toEqual(
|
12
|
+
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.CAR);
|
15
13
|
expect(res.unwrap().payload).toEqual(raw);
|
16
14
|
});
|
17
15
|
|
@@ -19,7 +17,7 @@ describe("storage-content", () => {
|
|
19
17
|
const raw = new Uint8Array([55, 56, 57]);
|
20
18
|
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=data").URI(), Result.Ok(raw));
|
21
19
|
expect(res.isOk()).toBeTruthy();
|
22
|
-
expect(res.unwrap().type).toEqual(
|
20
|
+
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.FILE);
|
23
21
|
expect(res.unwrap().payload).toEqual(raw);
|
24
22
|
});
|
25
23
|
|
@@ -34,7 +32,7 @@ describe("storage-content", () => {
|
|
34
32
|
const raw = sthis.txt.encode(JSON.stringify(ref));
|
35
33
|
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=meta").URI(), Result.Ok(raw));
|
36
34
|
expect(res.isOk()).toBeTruthy();
|
37
|
-
expect(res.unwrap().type).toEqual(
|
35
|
+
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.META);
|
38
36
|
const dbMetas = res.unwrap().payload as bs.DbMetaEvent[];
|
39
37
|
expect(dbMetas.length).toBe(1);
|
40
38
|
const dbMeta = dbMetas[0];
|
@@ -71,7 +69,7 @@ describe("storage-content", () => {
|
|
71
69
|
const raw = sthis.txt.encode(JSON.stringify(ref));
|
72
70
|
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=wal").URI(), Result.Ok(raw));
|
73
71
|
expect(res.isOk()).toBeTruthy();
|
74
|
-
expect(res.unwrap().type).toEqual(
|
72
|
+
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.WAL);
|
75
73
|
const walstate = res.unwrap().payload as bs.WALState;
|
76
74
|
expect(
|
77
75
|
walstate.fileOperations.map((i) => ({
|
@@ -96,7 +94,7 @@ describe("de-serialize", () => {
|
|
96
94
|
const sthis = mockSuperThis();
|
97
95
|
it("car", async () => {
|
98
96
|
const msg = {
|
99
|
-
type:
|
97
|
+
type: bs.FPEnvelopeTypes.CAR,
|
100
98
|
payload: new Uint8Array([55, 56, 57]),
|
101
99
|
} satisfies bs.FPEnvelopeCar;
|
102
100
|
const res = await rt.gw.fpSerialize(sthis, msg);
|
@@ -105,7 +103,7 @@ describe("de-serialize", () => {
|
|
105
103
|
|
106
104
|
it("file", async () => {
|
107
105
|
const msg = {
|
108
|
-
type:
|
106
|
+
type: bs.FPEnvelopeTypes.FILE,
|
109
107
|
payload: new Uint8Array([55, 56, 57]),
|
110
108
|
} satisfies bs.FPEnvelopeFile;
|
111
109
|
const res = await rt.gw.fpSerialize(sthis, msg);
|
@@ -114,7 +112,7 @@ describe("de-serialize", () => {
|
|
114
112
|
|
115
113
|
it("meta", async () => {
|
116
114
|
const msg = {
|
117
|
-
type:
|
115
|
+
type: bs.FPEnvelopeTypes.META,
|
118
116
|
payload: [
|
119
117
|
await bs.createDbMetaEvent(
|
120
118
|
sthis,
|
@@ -137,7 +135,7 @@ describe("de-serialize", () => {
|
|
137
135
|
|
138
136
|
it("wal", async () => {
|
139
137
|
const msg = {
|
140
|
-
type:
|
138
|
+
type: bs.FPEnvelopeTypes.WAL,
|
141
139
|
payload: {
|
142
140
|
fileOperations: [
|
143
141
|
{
|
@@ -171,7 +169,7 @@ describe("de-serialize", () => {
|
|
171
169
|
const raw = new Uint8Array([55, 56, 57]);
|
172
170
|
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=data&suffix=.car").URI(), Result.Ok(raw));
|
173
171
|
expect(res.isOk()).toBeTruthy();
|
174
|
-
expect(res.unwrap().type).toEqual(
|
172
|
+
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.CAR);
|
175
173
|
expect(res.unwrap().payload).toEqual(raw);
|
176
174
|
});
|
177
175
|
|
@@ -179,7 +177,7 @@ describe("de-serialize", () => {
|
|
179
177
|
const raw = new Uint8Array([55, 56, 57]);
|
180
178
|
const res = await rt.gw.fpDeserialize(sthis, BuildURI.from("http://x.com?store=data&suffix=.car").URI(), Promise.resolve(raw));
|
181
179
|
expect(res.isOk()).toBeTruthy();
|
182
|
-
expect(res.unwrap().type).toEqual(
|
180
|
+
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.CAR);
|
183
181
|
expect(res.unwrap().payload).toEqual(raw);
|
184
182
|
});
|
185
183
|
|
@@ -191,7 +189,7 @@ describe("de-serialize", () => {
|
|
191
189
|
Promise.resolve(Result.Ok(raw)),
|
192
190
|
);
|
193
191
|
expect(res.isOk()).toBeTruthy();
|
194
|
-
expect(res.unwrap().type).toEqual(
|
192
|
+
expect(res.unwrap().type).toEqual(bs.FPEnvelopeTypes.CAR);
|
195
193
|
expect(res.unwrap().payload).toEqual(raw);
|
196
194
|
});
|
197
195
|
|
@@ -218,7 +216,7 @@ describe("de-serialize", () => {
|
|
218
216
|
|
219
217
|
it("attach Key to Meta", async () => {
|
220
218
|
const msg = {
|
221
|
-
type:
|
219
|
+
type: bs.FPEnvelopeTypes.META,
|
222
220
|
payload: [
|
223
221
|
await bs.createDbMetaEvent(
|
224
222
|
sthis,
|