@fireproof/core 0.20.0-dev-preview-26 → 0.20.0-dev-preview-28
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/index.cjs +19 -26
- package/index.cjs.map +1 -1
- package/index.d.cts +4 -4
- package/index.d.ts +4 -4
- package/index.js +19 -26
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +1 -1
- package/tests/fireproof/crdt.test.ts +9 -0
- package/tests/fireproof/database.test.ts +12 -12
- package/tests/fireproof/fireproof.test.ts +44 -0
- package/tests/fireproof/indexer.test.ts +1 -0
@@ -13,6 +13,7 @@ describe("Fresh crdt", function () {
|
|
13
13
|
beforeEach(async function () {
|
14
14
|
await sthis.start();
|
15
15
|
const dbOpts: LedgerOpts = {
|
16
|
+
name: "test-crdt",
|
16
17
|
writeQueue: defaultWriteQueueOpts({}),
|
17
18
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
18
19
|
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
@@ -56,6 +57,7 @@ describe("CRDT with one record", function () {
|
|
56
57
|
beforeEach(async function () {
|
57
58
|
await sthis.start();
|
58
59
|
const dbOpts: LedgerOpts = {
|
60
|
+
name: "test-crdt",
|
59
61
|
writeQueue: defaultWriteQueueOpts({}),
|
60
62
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
61
63
|
storeUrls: toStoreURIRuntime(sthis, `test@${sthis.nextId().str}`),
|
@@ -112,6 +114,7 @@ describe("CRDT with a multi-write", function () {
|
|
112
114
|
beforeEach(async function () {
|
113
115
|
await sthis.start();
|
114
116
|
const dbOpts: LedgerOpts = {
|
117
|
+
name: "test-crdt",
|
115
118
|
writeQueue: defaultWriteQueueOpts({}),
|
116
119
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
117
120
|
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
@@ -182,6 +185,7 @@ describe("CRDT with two multi-writes", function () {
|
|
182
185
|
beforeEach(async () => {
|
183
186
|
await sthis.start();
|
184
187
|
const dbOpts: LedgerOpts = {
|
188
|
+
name: "test-crdt",
|
185
189
|
writeQueue: defaultWriteQueueOpts({}),
|
186
190
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
187
191
|
storeUrls: toStoreURIRuntime(sthis, `test-multiple-writes@${sthis.nextId().str}`),
|
@@ -236,6 +240,7 @@ describe("Compact a named CRDT with writes", function () {
|
|
236
240
|
beforeEach(async function () {
|
237
241
|
await sthis.start();
|
238
242
|
const dbOpts: LedgerOpts = {
|
243
|
+
name: "test-crdt",
|
239
244
|
writeQueue: defaultWriteQueueOpts({}),
|
240
245
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
241
246
|
storeUrls: toStoreURIRuntime(sthis, `named-crdt-compaction`),
|
@@ -298,6 +303,7 @@ describe("CRDT with an index", function () {
|
|
298
303
|
beforeEach(async function () {
|
299
304
|
await sthis.start();
|
300
305
|
const dbOpts: LedgerOpts = {
|
306
|
+
name: "test-crdt",
|
301
307
|
writeQueue: defaultWriteQueueOpts({}),
|
302
308
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
303
309
|
storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
|
@@ -347,6 +353,7 @@ describe("Loader with a committed transaction", function () {
|
|
347
353
|
beforeEach(async function () {
|
348
354
|
await sthis.start();
|
349
355
|
const dbOpts: LedgerOpts = {
|
356
|
+
name: "test-crdt",
|
350
357
|
writeQueue: defaultWriteQueueOpts({}),
|
351
358
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
352
359
|
storeUrls: toStoreURIRuntime(sthis, dbname),
|
@@ -398,6 +405,7 @@ describe("Loader with two committed transactions", function () {
|
|
398
405
|
beforeEach(async function () {
|
399
406
|
await sthis.start();
|
400
407
|
const dbOpts: LedgerOpts = {
|
408
|
+
name: "test-crdt",
|
401
409
|
writeQueue: defaultWriteQueueOpts({}),
|
402
410
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
403
411
|
storeUrls: toStoreURIRuntime(sthis, "test-loader"),
|
@@ -451,6 +459,7 @@ describe("Loader with many committed transactions", function () {
|
|
451
459
|
beforeEach(async function () {
|
452
460
|
await sthis.start();
|
453
461
|
const dbOpts: LedgerOpts = {
|
462
|
+
name: "test-crdt",
|
454
463
|
writeQueue: defaultWriteQueueOpts({}),
|
455
464
|
keyBag: rt.defaultKeyBagOpts(sthis),
|
456
465
|
storeUrls: toStoreURIRuntime(sthis, "test-loader-many"),
|
@@ -565,19 +565,19 @@ describe("StoreURIRuntime", () => {
|
|
565
565
|
});
|
566
566
|
// keyConfigOpts(sthis: SuperThis, name: string, opts?: ConfigOpts): string {
|
567
567
|
});
|
568
|
-
it("no name toStoreURIRuntime", () => {
|
569
|
-
expect(JSON.parse(JSON.stringify(toStoreURIRuntime(sthis)))).toEqual({
|
568
|
+
it("no name toStoreURIRuntime(not more)", () => {
|
569
|
+
expect(JSON.parse(JSON.stringify(toStoreURIRuntime(sthis, "gogo")))).toEqual({
|
570
570
|
data: {
|
571
|
-
data: "my://bla/storage?name=
|
572
|
-
file: "my://bla/storage?name=
|
573
|
-
meta: "my://bla/storage?name=
|
574
|
-
wal: "my://bla/storage?name=
|
571
|
+
data: "my://bla/storage?name=gogo&store=data&storekey=%40gogo-data%40&suffix=.car&urlGen=fromEnv",
|
572
|
+
file: "my://bla/storage?name=gogo&store=data&storekey=%40gogo-data%40&urlGen=fromEnv",
|
573
|
+
meta: "my://bla/storage?name=gogo&store=meta&storekey=%40gogo-meta%40&urlGen=fromEnv",
|
574
|
+
wal: "my://bla/storage?name=gogo&store=wal&storekey=%40gogo-wal%40&urlGen=fromEnv",
|
575
575
|
},
|
576
576
|
idx: {
|
577
|
-
data: "my://bla/storage?index=idx&name=
|
578
|
-
file: "my://bla/storage?index=idx&name=
|
579
|
-
meta: "my://bla/storage?index=idx&name=
|
580
|
-
wal: "my://bla/storage?index=idx&name=
|
577
|
+
data: "my://bla/storage?index=idx&name=gogo&store=data&storekey=%40gogo-data-idx%40&suffix=.car&urlGen=fromEnv",
|
578
|
+
file: "my://bla/storage?index=idx&name=gogo&store=data&storekey=%40gogo-data-idx%40&urlGen=fromEnv",
|
579
|
+
meta: "my://bla/storage?index=idx&name=gogo&store=meta&storekey=%40gogo-meta-idx%40&urlGen=fromEnv",
|
580
|
+
wal: "my://bla/storage?index=idx&name=gogo&store=wal&storekey=%40gogo-wal-idx%40&urlGen=fromEnv",
|
581
581
|
},
|
582
582
|
});
|
583
583
|
});
|
@@ -603,13 +603,13 @@ describe("StoreURIRuntime", () => {
|
|
603
603
|
data: {
|
604
604
|
data: "my://storage-data?name=yyy&store=data&storekey=%40yyy-data%40&suffix=.car",
|
605
605
|
file: "my://storage-data?name=yyy&store=data&storekey=%40yyy-data%40",
|
606
|
-
meta: "my://storage-meta?name=
|
606
|
+
meta: "my://storage-meta?name=xxx&store=meta&storekey=%40xxx-meta%40",
|
607
607
|
wal: "my://storage-base?name=xxx&store=wal&storekey=%40xxx-wal%40",
|
608
608
|
},
|
609
609
|
idx: {
|
610
610
|
data: "my://storage-idx-data?index=bla&name=yyy&store=data&storekey=%40yyy-data-idx%40&suffix=.car",
|
611
611
|
file: "my://storage-idx-data?index=bla&name=yyy&store=data&storekey=%40yyy-data-idx%40",
|
612
|
-
meta: "my://storage-idx-meta?index=idx&name=
|
612
|
+
meta: "my://storage-idx-meta?index=idx&name=xxx&store=meta&storekey=%40xxx-meta-idx%40",
|
613
613
|
wal: "my://storage-base?index=idx&name=xxx&store=wal&storekey=%40xxx-wal-idx%40",
|
614
614
|
},
|
615
615
|
});
|
@@ -15,7 +15,10 @@ import {
|
|
15
15
|
fireproof,
|
16
16
|
Database,
|
17
17
|
isDatabase,
|
18
|
+
PARAM,
|
18
19
|
} from "@fireproof/core";
|
20
|
+
import { getDefaultURI } from "../../src/blockstore/register-store-protocol.js";
|
21
|
+
import { URI } from "@adviser/cement";
|
19
22
|
|
20
23
|
export function carLogIncludesGroup(list: bs.AnyLink[], cid: CID) {
|
21
24
|
return list.some((c) => c.equals(cid));
|
@@ -114,6 +117,47 @@ describe("public API", function () {
|
|
114
117
|
});
|
115
118
|
});
|
116
119
|
|
120
|
+
describe("database fullconfig", () => {
|
121
|
+
const sthis = ensureSuperThis();
|
122
|
+
it("have the right name", async () => {
|
123
|
+
let protocol: string | undefined;
|
124
|
+
const url = sthis.env.get("FP_STORAGE_URL");
|
125
|
+
if (url) {
|
126
|
+
protocol = URI.from(url).protocol;
|
127
|
+
}
|
128
|
+
const base = getDefaultURI(sthis, protocol);
|
129
|
+
const db = fireproof("my-funky-name", {
|
130
|
+
storeUrls: {
|
131
|
+
base: base,
|
132
|
+
// meta: `${base}/meta?taste=${taste}`,
|
133
|
+
data: {
|
134
|
+
meta: base.build().pathname("dist/full/meta"),
|
135
|
+
data: base.build().pathname("dist/full/data"),
|
136
|
+
wal: base.build().pathname("dist/full/wal"),
|
137
|
+
},
|
138
|
+
idx: {
|
139
|
+
meta: base.build().pathname("dist/full/idx-meta"),
|
140
|
+
data: base.build().pathname("dist/full/idx-data"),
|
141
|
+
wal: base.build().pathname("dist/full/idx-wal"),
|
142
|
+
},
|
143
|
+
// wal: `${base}/wal?taste=${taste}`,
|
144
|
+
},
|
145
|
+
});
|
146
|
+
|
147
|
+
const carStore = await db.ledger.crdt.blockstore.loader?.carStore();
|
148
|
+
expect(carStore.url().getParam(PARAM.NAME)).toBe("my-funky-name");
|
149
|
+
const metaStore = await db.ledger.crdt.blockstore.loader?.metaStore();
|
150
|
+
expect(metaStore.url().getParam(PARAM.NAME)).toBe("my-funky-name");
|
151
|
+
const walStore = await db.ledger.crdt.blockstore.loader?.WALStore();
|
152
|
+
expect(walStore.url().getParam(PARAM.NAME)).toBe("my-funky-name");
|
153
|
+
|
154
|
+
expect(db).toBeTruthy();
|
155
|
+
expect(db.name).toBe("my-funky-name");
|
156
|
+
await db.put({ _id: "test", foo: "bar" });
|
157
|
+
expect(db.name).toBe("my-funky-name");
|
158
|
+
});
|
159
|
+
});
|
160
|
+
|
117
161
|
describe("basic ledger", function () {
|
118
162
|
interface Doc {
|
119
163
|
foo: string;
|
@@ -291,6 +291,7 @@ describe("basic Index upon cold start", function () {
|
|
291
291
|
const logger = sthis.logger.With().Module("IndexerTest").Logger();
|
292
292
|
logger.Debug().Msg("enter beforeEach");
|
293
293
|
dbOpts = {
|
294
|
+
name: "test-indexer-cold",
|
294
295
|
writeQueue: defaultWriteQueueOpts({}),
|
295
296
|
keyBag: rt.kb.defaultKeyBagOpts(sthis),
|
296
297
|
storeUrls: toStoreURIRuntime(sthis, "test-indexer-cold"),
|