@fireproof/core 0.20.0-dev-preview-05 → 0.20.0-dev-preview-10
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 +1 -1
- package/index.cjs +3211 -3150
- package/index.cjs.map +1 -1
- package/index.d.cts +243 -187
- package/index.d.ts +243 -187
- package/index.js +3199 -3138
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +1 -1
- 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/interceptor-gateway.test.ts +1 -1
- package/tests/blockstore/loader.test.ts +6 -6
- package/tests/blockstore/transaction.test.ts +8 -8
- package/tests/fireproof/all-gateway.test.ts +7 -7
- package/tests/fireproof/crdt.test.ts +26 -36
- package/tests/fireproof/{ledger.test.ts → database.test.ts} +30 -29
- package/tests/fireproof/fireproof.test.ts +66 -68
- package/tests/fireproof/hello.test.ts +9 -9
- package/tests/fireproof/indexer.test.ts +35 -34
- package/tests/fireproof/multiple-ledger.test.ts +3 -3
- package/tests/gateway/file/loader-config.test.ts +21 -21
- package/tests/gateway/indexdb/loader-config.test.ts +6 -6
- package/tests/react/useFireproof.test.tsx +2 -2
@@ -1,16 +1,17 @@
|
|
1
1
|
import {
|
2
2
|
Index,
|
3
3
|
index,
|
4
|
-
Ledger,
|
5
4
|
CRDT,
|
6
5
|
IndexRows,
|
7
6
|
toStoreURIRuntime,
|
8
7
|
bs,
|
9
8
|
rt,
|
10
|
-
LedgerFactory,
|
11
9
|
defaultWriteQueueOpts,
|
12
10
|
ensureSuperThis,
|
13
11
|
LedgerOpts,
|
12
|
+
Database,
|
13
|
+
CRDTImpl,
|
14
|
+
fireproof,
|
14
15
|
} from "@fireproof/core";
|
15
16
|
|
16
17
|
interface TestType {
|
@@ -19,7 +20,7 @@ interface TestType {
|
|
19
20
|
}
|
20
21
|
|
21
22
|
describe("basic Index", () => {
|
22
|
-
let db:
|
23
|
+
let db: Database;
|
23
24
|
let indexer: Index<string, TestType>;
|
24
25
|
let didMap: boolean;
|
25
26
|
const sthis = ensureSuperThis();
|
@@ -31,18 +32,18 @@ describe("basic Index", () => {
|
|
31
32
|
});
|
32
33
|
beforeEach(async function () {
|
33
34
|
await sthis.start();
|
34
|
-
db =
|
35
|
+
db = fireproof.DB("test-indexer");
|
35
36
|
await db.put({ title: "amazing" });
|
36
37
|
await db.put({ title: "creative" });
|
37
38
|
await db.put({ title: "bazillas" });
|
38
|
-
indexer = new Index<string, TestType>(sthis, db.crdt, "hello", (doc) => {
|
39
|
+
indexer = new Index<string, TestType>(sthis, db.ledger.crdt, "hello", (doc) => {
|
39
40
|
didMap = true;
|
40
41
|
return doc.title;
|
41
42
|
});
|
42
43
|
await indexer.ready();
|
43
44
|
});
|
44
45
|
it("should have properties", function () {
|
45
|
-
expect(indexer.crdt).toBe(db.crdt);
|
46
|
+
expect(indexer.crdt).toBe(db.ledger.crdt);
|
46
47
|
// expect(indexer.crdt.name).toBe("test-indexer");
|
47
48
|
expect(indexer.name).toBe("hello");
|
48
49
|
expect(indexer.mapFn).toBeTruthy();
|
@@ -107,7 +108,7 @@ describe("basic Index", () => {
|
|
107
108
|
});
|
108
109
|
|
109
110
|
describe("Index query with compound key", function () {
|
110
|
-
let db:
|
111
|
+
let db: Database;
|
111
112
|
let indexer: Index<[string, number], TestType>;
|
112
113
|
const sthis = ensureSuperThis();
|
113
114
|
afterEach(async function () {
|
@@ -118,12 +119,12 @@ describe("Index query with compound key", function () {
|
|
118
119
|
});
|
119
120
|
beforeEach(async function () {
|
120
121
|
await sthis.start();
|
121
|
-
db =
|
122
|
+
db = fireproof.DB("test-indexer");
|
122
123
|
await db.put({ title: "amazing", score: 1 });
|
123
124
|
await db.put({ title: "creative", score: 2 });
|
124
125
|
await db.put({ title: "creative", score: 20 });
|
125
126
|
await db.put({ title: "bazillas", score: 3 });
|
126
|
-
indexer = new Index<[string, number], TestType>(sthis, db.crdt, "hello", (doc) => {
|
127
|
+
indexer = new Index<[string, number], TestType>(sthis, db.ledger.crdt, "hello", (doc) => {
|
127
128
|
return [doc.title, doc.score];
|
128
129
|
});
|
129
130
|
await indexer.ready();
|
@@ -137,7 +138,7 @@ describe("Index query with compound key", function () {
|
|
137
138
|
});
|
138
139
|
|
139
140
|
describe("basic Index with map fun", function () {
|
140
|
-
let db:
|
141
|
+
let db: Database;
|
141
142
|
let indexer: Index<string, TestType>;
|
142
143
|
const sthis = ensureSuperThis();
|
143
144
|
afterEach(async function () {
|
@@ -148,11 +149,11 @@ describe("basic Index with map fun", function () {
|
|
148
149
|
});
|
149
150
|
beforeEach(async function () {
|
150
151
|
await sthis.start();
|
151
|
-
db =
|
152
|
+
db = fireproof.DB("test-indexer");
|
152
153
|
await db.put({ title: "amazing" });
|
153
154
|
await db.put({ title: "creative" });
|
154
155
|
await db.put({ title: "bazillas" });
|
155
|
-
indexer = new Index<string, TestType>(sthis, db.crdt, "hello", (doc, map) => {
|
156
|
+
indexer = new Index<string, TestType>(sthis, db.ledger.crdt, "hello", (doc, map) => {
|
156
157
|
map(doc.title);
|
157
158
|
});
|
158
159
|
await indexer.ready();
|
@@ -167,7 +168,7 @@ describe("basic Index with map fun", function () {
|
|
167
168
|
});
|
168
169
|
|
169
170
|
describe("basic Index with map fun with value", function () {
|
170
|
-
let db:
|
171
|
+
let db: Database;
|
171
172
|
let indexer: Index<string, TestType, number>;
|
172
173
|
const sthis = ensureSuperThis();
|
173
174
|
afterEach(async function () {
|
@@ -176,11 +177,11 @@ describe("basic Index with map fun with value", function () {
|
|
176
177
|
});
|
177
178
|
beforeEach(async function () {
|
178
179
|
await sthis.start();
|
179
|
-
db =
|
180
|
+
db = fireproof.DB("test-indexer");
|
180
181
|
await db.put({ title: "amazing" });
|
181
182
|
await db.put({ title: "creative" });
|
182
183
|
await db.put({ title: "bazillas" });
|
183
|
-
indexer = new Index<string, TestType, number>(sthis, db.crdt, "hello", (doc, map) => {
|
184
|
+
indexer = new Index<string, TestType, number>(sthis, db.ledger.crdt, "hello", (doc, map) => {
|
184
185
|
map(doc.title, doc.title.length);
|
185
186
|
});
|
186
187
|
});
|
@@ -205,7 +206,7 @@ describe("basic Index with map fun with value", function () {
|
|
205
206
|
});
|
206
207
|
|
207
208
|
describe("Index query with map and compound key", function () {
|
208
|
-
let db:
|
209
|
+
let db: Database;
|
209
210
|
let indexer: Index<[string, number], TestType>;
|
210
211
|
const sthis = ensureSuperThis();
|
211
212
|
afterEach(async function () {
|
@@ -216,12 +217,12 @@ describe("Index query with map and compound key", function () {
|
|
216
217
|
});
|
217
218
|
beforeEach(async function () {
|
218
219
|
await sthis.start();
|
219
|
-
db =
|
220
|
+
db = fireproof.DB("test-indexer");
|
220
221
|
await db.put({ title: "amazing", score: 1 });
|
221
222
|
await db.put({ title: "creative", score: 2 });
|
222
223
|
await db.put({ title: "creative", score: 20 });
|
223
224
|
await db.put({ title: "bazillas", score: 3 });
|
224
|
-
indexer = new Index<[string, number], TestType>(sthis, db.crdt, "hello", (doc, emit) => {
|
225
|
+
indexer = new Index<[string, number], TestType>(sthis, db.ledger.crdt, "hello", (doc, emit) => {
|
225
226
|
emit([doc.title, doc.score]);
|
226
227
|
});
|
227
228
|
await indexer.ready();
|
@@ -235,7 +236,7 @@ describe("Index query with map and compound key", function () {
|
|
235
236
|
});
|
236
237
|
|
237
238
|
describe("basic Index with string fun", function () {
|
238
|
-
let db:
|
239
|
+
let db: Database;
|
239
240
|
let indexer: Index<string, TestType>;
|
240
241
|
const sthis = ensureSuperThis();
|
241
242
|
afterEach(async function () {
|
@@ -246,11 +247,11 @@ describe("basic Index with string fun", function () {
|
|
246
247
|
});
|
247
248
|
beforeEach(async function () {
|
248
249
|
await sthis.start();
|
249
|
-
db =
|
250
|
+
db = fireproof.DB("test-indexer");
|
250
251
|
await db.put({ title: "amazing" });
|
251
252
|
await db.put({ title: "creative" });
|
252
253
|
await db.put({ title: "bazillas" });
|
253
|
-
indexer = new Index(sthis, db.crdt, "title");
|
254
|
+
indexer = new Index<string, TestType>(sthis, db.ledger.crdt, "title");
|
254
255
|
await indexer.ready();
|
255
256
|
});
|
256
257
|
it("should get results", async function () {
|
@@ -271,7 +272,7 @@ describe("basic Index upon cold start", function () {
|
|
271
272
|
title: string;
|
272
273
|
score?: number;
|
273
274
|
}
|
274
|
-
let crdt: CRDT
|
275
|
+
let crdt: CRDT;
|
275
276
|
let indexer: Index<string, TestType>;
|
276
277
|
let didMap: number;
|
277
278
|
let mapFn: (doc: TestType) => string;
|
@@ -295,7 +296,7 @@ describe("basic Index upon cold start", function () {
|
|
295
296
|
storeUrls: toStoreURIRuntime(sthis, "test-indexer-cold"),
|
296
297
|
storeEnDe: bs.ensureStoreEnDeFile({}),
|
297
298
|
};
|
298
|
-
crdt = new
|
299
|
+
crdt = new CRDTImpl(sthis, dbOpts);
|
299
300
|
await crdt.bulk([
|
300
301
|
{ id: "abc1", value: { title: "amazing" } },
|
301
302
|
{ id: "abc2", value: { title: "creative" } },
|
@@ -307,7 +308,7 @@ describe("basic Index upon cold start", function () {
|
|
307
308
|
didMap++;
|
308
309
|
return doc.title;
|
309
310
|
};
|
310
|
-
indexer = await index<string, TestType>(
|
311
|
+
indexer = await index<string, TestType>(crdt, "hello", mapFn);
|
311
312
|
logger.Debug().Msg("post index beforeEach");
|
312
313
|
await indexer.ready();
|
313
314
|
logger.Debug().Msg("post indexer.ready beforeEach");
|
@@ -327,12 +328,12 @@ describe("basic Index upon cold start", function () {
|
|
327
328
|
expect(result.rows.length).toEqual(3);
|
328
329
|
});
|
329
330
|
it("should work on cold load", async function () {
|
330
|
-
const crdt2 = new
|
331
|
+
const crdt2 = new CRDTImpl(sthis, dbOpts);
|
331
332
|
await crdt2.ready();
|
332
333
|
const { result, head } = await crdt2.changes();
|
333
334
|
expect(result).toBeTruthy();
|
334
335
|
await crdt2.ready();
|
335
|
-
const indexer2 = await index<string, TestType>(
|
336
|
+
const indexer2 = await index<string, TestType>(crdt2, "hello", mapFn);
|
336
337
|
await indexer2.ready();
|
337
338
|
const result2 = await indexer2.query();
|
338
339
|
expect(indexer2.indexHead).toEqual(head);
|
@@ -342,8 +343,8 @@ describe("basic Index upon cold start", function () {
|
|
342
343
|
});
|
343
344
|
it.skip("should not rerun the map function on seen changes", async function () {
|
344
345
|
didMap = 0;
|
345
|
-
const crdt2 = new
|
346
|
-
const indexer2 = await index(
|
346
|
+
const crdt2 = new CRDTImpl(sthis, dbOpts);
|
347
|
+
const indexer2 = await index(crdt2, "hello", mapFn);
|
347
348
|
const { result, head } = await crdt2.changes([]);
|
348
349
|
expect(result.length).toEqual(3);
|
349
350
|
expect(head.length).toEqual(1);
|
@@ -367,15 +368,15 @@ describe("basic Index upon cold start", function () {
|
|
367
368
|
expect(didMap).toEqual(1);
|
368
369
|
});
|
369
370
|
it("should ignore meta when map function definiton changes", async function () {
|
370
|
-
const crdt2 = new
|
371
|
-
const result = await index<string, TestType>(
|
371
|
+
const crdt2 = new CRDTImpl(sthis, dbOpts);
|
372
|
+
const result = await index<string, TestType>(crdt2, "hello", (doc) => doc.title.split("").reverse().join("")).query();
|
372
373
|
expect(result.rows.length).toEqual(3);
|
373
374
|
expect(result.rows[0].key).toEqual("evitaerc"); // creative
|
374
375
|
});
|
375
376
|
});
|
376
377
|
|
377
378
|
describe("basic Index with no data", function () {
|
378
|
-
let db:
|
379
|
+
let db: Database;
|
379
380
|
let indexer: Index<string, TestType>;
|
380
381
|
let didMap: boolean;
|
381
382
|
const sthis = ensureSuperThis();
|
@@ -387,15 +388,15 @@ describe("basic Index with no data", function () {
|
|
387
388
|
});
|
388
389
|
beforeEach(async function () {
|
389
390
|
await sthis.start();
|
390
|
-
db =
|
391
|
-
indexer = new Index<string, TestType>(sthis, db.crdt, "hello", (doc) => {
|
391
|
+
db = fireproof.DB("test-indexer");
|
392
|
+
indexer = new Index<string, TestType>(sthis, db.ledger.crdt, "hello", (doc) => {
|
392
393
|
didMap = true;
|
393
394
|
return doc.title;
|
394
395
|
});
|
395
396
|
await indexer.ready();
|
396
397
|
});
|
397
398
|
it("should have properties", function () {
|
398
|
-
expect(indexer.crdt).toEqual(db.crdt);
|
399
|
+
expect(indexer.crdt).toEqual(db.ledger.crdt);
|
399
400
|
expect(indexer.name).toEqual("hello");
|
400
401
|
expect(indexer.mapFn).toBeTruthy();
|
401
402
|
});
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { Database, ensureSuperThis, fireproof } from "@fireproof/core";
|
2
2
|
|
3
3
|
interface DBItem {
|
4
|
-
readonly db:
|
4
|
+
readonly db: Database;
|
5
5
|
readonly name: string;
|
6
6
|
}
|
7
7
|
|
@@ -26,7 +26,7 @@ describe("Multiple Databases", () => {
|
|
26
26
|
.fill(0)
|
27
27
|
.map(async (_, i) => {
|
28
28
|
const name = `db-${group}-${i}`;
|
29
|
-
const db = fireproof(name);
|
29
|
+
const db = fireproof.DB(name);
|
30
30
|
dbs.push({ db, name });
|
31
31
|
for (let i = 0; i < rows; i++) {
|
32
32
|
await db.put({ _id: `${name}-${i}`, hello: "world" });
|
@@ -33,11 +33,11 @@ describe("config file gateway", () => {
|
|
33
33
|
});
|
34
34
|
|
35
35
|
it("loader", async () => {
|
36
|
-
const db = fireproof(my_app());
|
36
|
+
const db = fireproof.DB(my_app());
|
37
37
|
await db.put({ name: "my-app" });
|
38
|
-
expect(db.name).toBe(my_app());
|
38
|
+
expect(db.ledger.name).toBe(my_app());
|
39
39
|
|
40
|
-
const fileStore = await db.crdt.blockstore.loader?.fileStore();
|
40
|
+
const fileStore = await db.ledger.crdt.blockstore.loader?.fileStore();
|
41
41
|
expect(fileStore?.url().asObj()).toEqual({
|
42
42
|
pathname: "./dist/fp-dir-file",
|
43
43
|
protocol: "file:",
|
@@ -52,7 +52,7 @@ describe("config file gateway", () => {
|
|
52
52
|
style: "path",
|
53
53
|
});
|
54
54
|
|
55
|
-
const dataStore = await db.crdt.blockstore.loader?.carStore();
|
55
|
+
const dataStore = await db.ledger.crdt.blockstore.loader?.carStore();
|
56
56
|
expect(dataStore?.url().asObj()).toEqual({
|
57
57
|
pathname: "./dist/fp-dir-file",
|
58
58
|
protocol: "file:",
|
@@ -67,7 +67,7 @@ describe("config file gateway", () => {
|
|
67
67
|
},
|
68
68
|
style: "path",
|
69
69
|
});
|
70
|
-
const metaStore = await db.crdt.blockstore.loader?.metaStore();
|
70
|
+
const metaStore = await db.ledger.crdt.blockstore.loader?.metaStore();
|
71
71
|
expect(metaStore?.url().asObj()).toEqual({
|
72
72
|
pathname: "./dist/fp-dir-file",
|
73
73
|
protocol: "file:",
|
@@ -81,7 +81,7 @@ describe("config file gateway", () => {
|
|
81
81
|
},
|
82
82
|
style: "path",
|
83
83
|
});
|
84
|
-
const WALStore = await db.crdt.blockstore.loader?.WALStore();
|
84
|
+
const WALStore = await db.ledger.crdt.blockstore.loader?.WALStore();
|
85
85
|
expect(WALStore?.url().asObj()).toEqual({
|
86
86
|
pathname: "./dist/fp-dir-file",
|
87
87
|
protocol: "file:",
|
@@ -110,11 +110,11 @@ describe("config file gateway", () => {
|
|
110
110
|
/* */
|
111
111
|
});
|
112
112
|
|
113
|
-
const db = fireproof(my_app(), { storeUrls: { base } });
|
113
|
+
const db = fireproof.DB(my_app(), { storeUrls: { base } });
|
114
114
|
// console.log(`>>>>>>>>>>>>>>>file-path`)
|
115
115
|
await db.put({ name: "my-app" });
|
116
|
-
expect(db.name).toBe(my_app());
|
117
|
-
const carStore = await db.crdt.blockstore.loader?.carStore();
|
116
|
+
expect(db.ledger.name).toBe(my_app());
|
117
|
+
const carStore = await db.ledger.crdt.blockstore.loader?.carStore();
|
118
118
|
expect(carStore?.url().asObj()).toEqual({
|
119
119
|
pathname: "./dist/data",
|
120
120
|
protocol: "file:",
|
@@ -128,7 +128,7 @@ describe("config file gateway", () => {
|
|
128
128
|
},
|
129
129
|
style: "path",
|
130
130
|
});
|
131
|
-
const fileStore = await db.crdt.blockstore.loader?.fileStore();
|
131
|
+
const fileStore = await db.ledger.crdt.blockstore.loader?.fileStore();
|
132
132
|
expect(fileStore?.url().asObj()).toEqual({
|
133
133
|
pathname: "./dist/data",
|
134
134
|
protocol: "file:",
|
@@ -142,7 +142,7 @@ describe("config file gateway", () => {
|
|
142
142
|
style: "path",
|
143
143
|
});
|
144
144
|
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
145
|
-
const metaStore = await db.crdt.blockstore.loader?.metaStore();
|
145
|
+
const metaStore = await db.ledger.crdt.blockstore.loader?.metaStore();
|
146
146
|
expect(metaStore?.url().asObj()).toEqual({
|
147
147
|
pathname: "./dist/data",
|
148
148
|
protocol: "file:",
|
@@ -177,10 +177,10 @@ describe("config file gateway", () => {
|
|
177
177
|
|
178
178
|
expect(baseDir).toMatch(new RegExp(`/\\.fireproof/${rt.FILESTORE_VERSION.replace(/-file/, "")}/${my_app()}`));
|
179
179
|
|
180
|
-
const db = fireproof(my_app());
|
180
|
+
const db = fireproof.DB(my_app());
|
181
181
|
await db.put({ name: "my-app" });
|
182
|
-
expect(db.name).toBe(my_app());
|
183
|
-
const carStore = await db.crdt.blockstore.loader?.carStore();
|
182
|
+
expect(db.ledger.name).toBe(my_app());
|
183
|
+
const carStore = await db.ledger.crdt.blockstore.loader?.carStore();
|
184
184
|
|
185
185
|
expect(carStore?.url().asObj()).toEqual({
|
186
186
|
pathname: `${sthis.env.get("HOME")}/.fireproof/v0.19`,
|
@@ -200,7 +200,7 @@ describe("config file gateway", () => {
|
|
200
200
|
|
201
201
|
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
202
202
|
|
203
|
-
const fileStore = await db.crdt.blockstore.loader?.fileStore();
|
203
|
+
const fileStore = await db.ledger.crdt.blockstore.loader?.fileStore();
|
204
204
|
expect(fileStore?.url().asObj()).toEqual({
|
205
205
|
pathname: `${sthis.env.get("HOME")}/.fireproof/v0.19`,
|
206
206
|
protocol: "file:",
|
@@ -215,7 +215,7 @@ describe("config file gateway", () => {
|
|
215
215
|
version: rt.FILESTORE_VERSION,
|
216
216
|
},
|
217
217
|
});
|
218
|
-
const metaStore = await db.crdt.blockstore.loader?.metaStore();
|
218
|
+
const metaStore = await db.ledger.crdt.blockstore.loader?.metaStore();
|
219
219
|
expect(metaStore?.url().asObj()).toEqual({
|
220
220
|
pathname: `${sthis.env.get("HOME")}/.fireproof/v0.19`,
|
221
221
|
protocol: "file:",
|
@@ -250,10 +250,10 @@ describe("config file gateway", () => {
|
|
250
250
|
/* */
|
251
251
|
});
|
252
252
|
|
253
|
-
const db = fireproof(my_app());
|
253
|
+
const db = fireproof.DB(my_app());
|
254
254
|
await db.put({ name: "my-app" });
|
255
|
-
expect(db.name).toBe(my_app());
|
256
|
-
const carStore = await db.crdt.blockstore.loader.carStore();
|
255
|
+
expect(db.ledger.name).toBe(my_app());
|
256
|
+
const carStore = await db.ledger.crdt.blockstore.loader.carStore();
|
257
257
|
expect(carStore?.url().asObj()).toEqual({
|
258
258
|
pathname: "./dist/fp-dir-file",
|
259
259
|
protocol: "file:",
|
@@ -271,7 +271,7 @@ describe("config file gateway", () => {
|
|
271
271
|
});
|
272
272
|
|
273
273
|
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
274
|
-
const fileStore = await db.crdt.blockstore.loader?.fileStore();
|
274
|
+
const fileStore = await db.ledger.crdt.blockstore.loader?.fileStore();
|
275
275
|
expect(fileStore?.url().asObj()).toEqual({
|
276
276
|
pathname: `./dist/fp-dir-file`,
|
277
277
|
protocol: "file:",
|
@@ -286,7 +286,7 @@ describe("config file gateway", () => {
|
|
286
286
|
},
|
287
287
|
});
|
288
288
|
|
289
|
-
const metaStore = await db.crdt.blockstore.loader?.metaStore();
|
289
|
+
const metaStore = await db.ledger.crdt.blockstore.loader?.metaStore();
|
290
290
|
expect(metaStore?.url().asObj()).toEqual({
|
291
291
|
pathname: `./dist/fp-dir-file`,
|
292
292
|
protocol: "file:",
|
@@ -12,11 +12,11 @@ describe("fireproof config indexdb", () => {
|
|
12
12
|
});
|
13
13
|
|
14
14
|
it("indexdb-loader", async () => {
|
15
|
-
const db = fireproof(my_app());
|
15
|
+
const db = fireproof.DB(my_app());
|
16
16
|
await db.put({ name: "my-app" });
|
17
|
-
expect(db.name).toBe(my_app());
|
17
|
+
expect(db.ledger.name).toBe(my_app());
|
18
18
|
|
19
|
-
const fileStore = await db.crdt.blockstore.loader.fileStore();
|
19
|
+
const fileStore = await db.ledger.crdt.blockstore.loader.fileStore();
|
20
20
|
expect(fileStore?.url().asObj()).toEqual({
|
21
21
|
pathname: "fp",
|
22
22
|
protocol: "indexdb:",
|
@@ -31,7 +31,7 @@ describe("fireproof config indexdb", () => {
|
|
31
31
|
style: "path",
|
32
32
|
});
|
33
33
|
|
34
|
-
const dataStore = await db.crdt.blockstore.loader.carStore();
|
34
|
+
const dataStore = await db.ledger.crdt.blockstore.loader.carStore();
|
35
35
|
expect(dataStore?.url().asObj()).toEqual({
|
36
36
|
pathname: "fp",
|
37
37
|
protocol: "indexdb:",
|
@@ -46,7 +46,7 @@ describe("fireproof config indexdb", () => {
|
|
46
46
|
},
|
47
47
|
style: "path",
|
48
48
|
});
|
49
|
-
const metaStore = await db.crdt.blockstore.loader.metaStore();
|
49
|
+
const metaStore = await db.ledger.crdt.blockstore.loader.metaStore();
|
50
50
|
expect(metaStore?.url().asObj()).toEqual({
|
51
51
|
pathname: "fp",
|
52
52
|
protocol: "indexdb:",
|
@@ -60,7 +60,7 @@ describe("fireproof config indexdb", () => {
|
|
60
60
|
},
|
61
61
|
style: "path",
|
62
62
|
});
|
63
|
-
const WALStore = await db.crdt.blockstore.loader.WALStore();
|
63
|
+
const WALStore = await db.ledger.crdt.blockstore.loader.WALStore();
|
64
64
|
expect(WALStore?.url().asObj()).toEqual({
|
65
65
|
pathname: "fp",
|
66
66
|
protocol: "indexdb:",
|
@@ -10,10 +10,10 @@ describe("HOOK: useFireproof", () => {
|
|
10
10
|
|
11
11
|
it("renders the hook correctly and checks types", () => {
|
12
12
|
renderHook(() => {
|
13
|
-
const {
|
13
|
+
const { database, useLiveQuery, useDocument } = useFireproof("dbname");
|
14
14
|
expect(typeof useLiveQuery).toBe("function");
|
15
15
|
expect(typeof useDocument).toBe("function");
|
16
|
-
expect(
|
16
|
+
expect(database?.constructor.name).toMatch(/^Database/);
|
17
17
|
});
|
18
18
|
});
|
19
19
|
});
|