@fireproof/core 0.20.0-dev-preview-05 → 0.20.0-dev-preview-06

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.
@@ -1 +1 @@
1
- {"inputs":{"src/react/useFireproof.ts":{"bytes":11322,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/useDocument.ts":{"bytes":1656,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"}],"format":"esm"},"src/react/useLiveQuery.ts":{"bytes":1387,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"}],"format":"esm"},"src/react/useAllDocs.ts":{"bytes":1126,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"}],"format":"esm"},"src/react/useChanges.ts":{"bytes":1171,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"}],"format":"esm"},"src/react/index.ts":{"bytes":971,"imports":[{"path":"src/react/useDocument.ts","kind":"import-statement","original":"./useDocument.js"},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"},{"path":"src/react/useLiveQuery.ts","kind":"import-statement","original":"./useLiveQuery.js"},{"path":"src/react/useAllDocs.ts","kind":"import-statement","original":"./useAllDocs.js"},{"path":"src/react/useChanges.ts","kind":"import-statement","original":"./useChanges.js"}],"format":"esm"}},"outputs":{"dist/fireproof-core/react/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":21356},"dist/fireproof-core/react/index.js":{"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["FireproofCtx","useAllDocs","useChanges","useDocument","useFireproof","useLiveQuery"],"entryPoint":"src/react/index.ts","inputs":{"src/react/useFireproof.ts":{"bytesInOutput":3861},"src/react/useDocument.ts":{"bytesInOutput":216},"src/react/index.ts":{"bytesInOutput":0},"src/react/useLiveQuery.ts":{"bytesInOutput":223},"src/react/useAllDocs.ts":{"bytesInOutput":209},"src/react/useChanges.ts":{"bytesInOutput":209}},"bytes":4964}}}
1
+ {"inputs":{"src/react/useFireproof.ts":{"bytes":11390,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/react/useDocument.ts":{"bytes":1680,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"}],"format":"esm"},"src/react/useLiveQuery.ts":{"bytes":1409,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"}],"format":"esm"},"src/react/useAllDocs.ts":{"bytes":1146,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"}],"format":"esm"},"src/react/useChanges.ts":{"bytes":1191,"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"}],"format":"esm"},"src/react/index.ts":{"bytes":971,"imports":[{"path":"src/react/useDocument.ts","kind":"import-statement","original":"./useDocument.js"},{"path":"src/react/useFireproof.ts","kind":"import-statement","original":"./useFireproof.js"},{"path":"src/react/useLiveQuery.ts","kind":"import-statement","original":"./useLiveQuery.js"},{"path":"src/react/useAllDocs.ts","kind":"import-statement","original":"./useAllDocs.js"},{"path":"src/react/useChanges.ts","kind":"import-statement","original":"./useChanges.js"}],"format":"esm"}},"outputs":{"dist/fireproof-core/react/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":21510},"dist/fireproof-core/react/index.js":{"imports":[{"path":"@fireproof/core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["FireproofCtx","useAllDocs","useChanges","useDocument","useFireproof","useLiveQuery"],"entryPoint":"src/react/index.ts","inputs":{"src/react/useFireproof.ts":{"bytesInOutput":3889},"src/react/useDocument.ts":{"bytesInOutput":222},"src/react/index.ts":{"bytesInOutput":0},"src/react/useLiveQuery.ts":{"bytesInOutput":229},"src/react/useAllDocs.ts":{"bytesInOutput":215},"src/react/useChanges.ts":{"bytesInOutput":215}},"bytes":5016}}}
@@ -1,4 +1,4 @@
1
- import { Ledger, LedgerFactory, PARAM, bs, ensureSuperThis } from "@fireproof/core";
1
+ import { Database, DatabaseFactory, PARAM, bs, ensureSuperThis } from "@fireproof/core";
2
2
 
3
3
  import { fileContent } from "./cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.js";
4
4
  import { simpleCID } from "../helpers.js";
@@ -30,7 +30,7 @@ import { simpleCID } from "../helpers.js";
30
30
  // }
31
31
 
32
32
  describe("noop Gateway", function () {
33
- let db: Ledger;
33
+ let db: Database;
34
34
  let carStore: bs.DataStore;
35
35
  let metaStore: bs.MetaStore;
36
36
  let fileStore: bs.DataStore;
@@ -46,7 +46,7 @@ describe("noop Gateway", function () {
46
46
  await db.destroy();
47
47
  });
48
48
  beforeEach(async function () {
49
- db = LedgerFactory("test-gateway-" + sthis.nextId().str, {
49
+ db = DatabaseFactory("test-gateway-" + sthis.nextId().str, {
50
50
  logger: sthis.logger,
51
51
  });
52
52
 
@@ -363,7 +363,7 @@ describe("noop Gateway", function () {
363
363
  });
364
364
 
365
365
  describe("noop Gateway subscribe", function () {
366
- let db: Ledger;
366
+ let db: Database;
367
367
 
368
368
  let metaStore: bs.MetaStore;
369
369
 
@@ -375,7 +375,7 @@ describe("noop Gateway subscribe", function () {
375
375
  await db.destroy();
376
376
  });
377
377
  beforeEach(async function () {
378
- db = LedgerFactory("test-gateway-" + sthis.nextId().str);
378
+ db = DatabaseFactory("test-gateway-" + sthis.nextId().str);
379
379
 
380
380
  // Extract stores from the loader
381
381
  metaStore = (await db.crdt.blockstore.loader?.metaStore()) as bs.MetaStore;
@@ -409,7 +409,7 @@ describe("noop Gateway subscribe", function () {
409
409
  });
410
410
 
411
411
  describe("Gateway", function () {
412
- let db: Ledger;
412
+ let db: Database;
413
413
  // let carStore: ExtendedStore;
414
414
  let metaStore: bs.MetaStore;
415
415
  // let fileStore: ExtendedStore;
@@ -425,7 +425,7 @@ describe("Gateway", function () {
425
425
  await db.destroy();
426
426
  });
427
427
  beforeEach(async function () {
428
- db = LedgerFactory("test-gateway-" + sthis.nextId().str);
428
+ db = DatabaseFactory("test-gateway-" + sthis.nextId().str);
429
429
  const ok = await db.put({ _id: "test", foo: "bar" });
430
430
  expect(ok).toBeTruthy();
431
431
  expect(ok.id).toBe("test");
@@ -1,4 +1,4 @@
1
- import { CRDT, defaultWriteQueueOpts, ensureSuperThis, LedgerOpts, toStoreURIRuntime, rt } from "@fireproof/core";
1
+ import { CRDT, defaultWriteQueueOpts, ensureSuperThis, DatabaseOpts, toStoreURIRuntime, rt } from "@fireproof/core";
2
2
  import { bs } from "@fireproof/core";
3
3
  import { CRDTMeta, DocValue } from "@fireproof/core";
4
4
  import { Index, index } from "@fireproof/core";
@@ -12,7 +12,7 @@ describe("Fresh crdt", function () {
12
12
  });
13
13
  beforeEach(async function () {
14
14
  await sthis.start();
15
- const dbOpts: LedgerOpts = {
15
+ const dbOpts: DatabaseOpts = {
16
16
  writeQueue: defaultWriteQueueOpts({}),
17
17
  keyBag: rt.defaultKeyBagOpts(sthis),
18
18
  storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
@@ -55,7 +55,7 @@ describe("CRDT with one record", function () {
55
55
 
56
56
  beforeEach(async function () {
57
57
  await sthis.start();
58
- const dbOpts: LedgerOpts = {
58
+ const dbOpts: DatabaseOpts = {
59
59
  writeQueue: defaultWriteQueueOpts({}),
60
60
  keyBag: rt.defaultKeyBagOpts(sthis),
61
61
  storeUrls: toStoreURIRuntime(sthis, `test@${sthis.nextId().str}`),
@@ -111,7 +111,7 @@ describe("CRDT with a multi-write", function () {
111
111
  });
112
112
  beforeEach(async function () {
113
113
  await sthis.start();
114
- const dbOpts: LedgerOpts = {
114
+ const dbOpts: DatabaseOpts = {
115
115
  writeQueue: defaultWriteQueueOpts({}),
116
116
  keyBag: rt.defaultKeyBagOpts(sthis),
117
117
  storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
@@ -182,7 +182,7 @@ describe("CRDT with two multi-writes", function () {
182
182
  });
183
183
  beforeEach(async () => {
184
184
  await sthis.start();
185
- const dbOpts: LedgerOpts = {
185
+ const dbOpts: DatabaseOpts = {
186
186
  writeQueue: defaultWriteQueueOpts({}),
187
187
  keyBag: rt.defaultKeyBagOpts(sthis),
188
188
  storeUrls: toStoreURIRuntime(sthis, `test-multiple-writes@${sthis.nextId().str}`),
@@ -236,7 +236,7 @@ describe("Compact a named CRDT with writes", function () {
236
236
  });
237
237
  beforeEach(async function () {
238
238
  await sthis.start();
239
- const dbOpts: LedgerOpts = {
239
+ const dbOpts: DatabaseOpts = {
240
240
  writeQueue: defaultWriteQueueOpts({}),
241
241
  keyBag: rt.defaultKeyBagOpts(sthis),
242
242
  storeUrls: toStoreURIRuntime(sthis, `named-crdt-compaction`),
@@ -298,7 +298,7 @@ describe("CRDT with an index", function () {
298
298
  });
299
299
  beforeEach(async function () {
300
300
  await sthis.start();
301
- const dbOpts: LedgerOpts = {
301
+ const dbOpts: DatabaseOpts = {
302
302
  writeQueue: defaultWriteQueueOpts({}),
303
303
  keyBag: rt.defaultKeyBagOpts(sthis),
304
304
  storeUrls: toStoreURIRuntime(sthis, "test-crdt-cold"),
@@ -350,7 +350,7 @@ describe("Loader with a committed transaction", function () {
350
350
  });
351
351
  beforeEach(async function () {
352
352
  await sthis.start();
353
- const dbOpts: LedgerOpts = {
353
+ const dbOpts: DatabaseOpts = {
354
354
  writeQueue: defaultWriteQueueOpts({}),
355
355
  keyBag: rt.defaultKeyBagOpts(sthis),
356
356
  storeUrls: toStoreURIRuntime(sthis, dbname),
@@ -404,7 +404,7 @@ describe("Loader with two committed transactions", function () {
404
404
  });
405
405
  beforeEach(async function () {
406
406
  await sthis.start();
407
- const dbOpts: LedgerOpts = {
407
+ const dbOpts: DatabaseOpts = {
408
408
  writeQueue: defaultWriteQueueOpts({}),
409
409
  keyBag: rt.defaultKeyBagOpts(sthis),
410
410
  storeUrls: toStoreURIRuntime(sthis, "test-loader"),
@@ -460,7 +460,7 @@ describe("Loader with many committed transactions", function () {
460
460
  });
461
461
  beforeEach(async function () {
462
462
  await sthis.start();
463
- const dbOpts: LedgerOpts = {
463
+ const dbOpts: DatabaseOpts = {
464
464
  writeQueue: defaultWriteQueueOpts({}),
465
465
  keyBag: rt.defaultKeyBagOpts(sthis),
466
466
  storeUrls: toStoreURIRuntime(sthis, "test-loader-many"),
@@ -2,20 +2,20 @@ import { URI } from "@adviser/cement";
2
2
  import { buildBlobFiles, FileWithCid, mockSuperThis } from "../helpers.js";
3
3
  import {
4
4
  bs,
5
- Ledger,
5
+ Database,
6
6
  DocResponse,
7
7
  DocFileMeta,
8
8
  DocWithId,
9
9
  DocFiles,
10
10
  toStoreURIRuntime,
11
11
  keyConfigOpts,
12
- LedgerFactory,
13
- LedgerShell,
12
+ DatabaseFactory,
13
+ DatabaseShell,
14
14
  ensureSuperThis,
15
15
  } from "@fireproof/core";
16
16
 
17
- describe("basic Ledger", () => {
18
- let db: Ledger;
17
+ describe("basic Database", () => {
18
+ let db: Database;
19
19
  const sthis = mockSuperThis();
20
20
  afterEach(async () => {
21
21
  await db.close();
@@ -23,7 +23,7 @@ describe("basic Ledger", () => {
23
23
  });
24
24
  beforeEach(async () => {
25
25
  await sthis.start();
26
- db = LedgerFactory(undefined, {
26
+ db = DatabaseFactory(undefined, {
27
27
  logger: sthis.logger,
28
28
  });
29
29
  });
@@ -49,11 +49,11 @@ describe("basic Ledger", () => {
49
49
  });
50
50
  });
51
51
 
52
- describe("basic Ledger with record", function () {
52
+ describe("basic Database with record", function () {
53
53
  interface Doc {
54
54
  readonly value: string;
55
55
  }
56
- let db: LedgerShell;
56
+ let db: DatabaseShell;
57
57
  const sthis = ensureSuperThis();
58
58
  afterEach(async () => {
59
59
  await db.close();
@@ -61,7 +61,7 @@ describe("basic Ledger with record", function () {
61
61
  });
62
62
  beforeEach(async function () {
63
63
  await sthis.start();
64
- db = LedgerFactory("factory-name") as LedgerShell;
64
+ db = DatabaseFactory("factory-name") as DatabaseShell;
65
65
  const ok = await db.put<Doc>({ _id: "hello", value: "world" });
66
66
  expect(ok.id).toBe("hello");
67
67
  });
@@ -93,7 +93,7 @@ describe("basic Ledger with record", function () {
93
93
  expect(rows[0].value._id).toBe("hello");
94
94
  });
95
95
  it("is not persisted", async function () {
96
- const db2 = LedgerFactory("factory-name") as LedgerShell;
96
+ const db2 = DatabaseFactory("factory-name") as DatabaseShell;
97
97
  const { rows } = await db2.changes([]);
98
98
  expect(rows.length).toBe(1);
99
99
  expect(db2.ref).toBe(db.ref);
@@ -103,11 +103,11 @@ describe("basic Ledger with record", function () {
103
103
  });
104
104
  });
105
105
 
106
- describe("named Ledger with record", function () {
106
+ describe("named Database with record", function () {
107
107
  interface Doc {
108
108
  readonly value: string;
109
109
  }
110
- let db: Ledger;
110
+ let db: Database;
111
111
  const sthis = ensureSuperThis();
112
112
  afterEach(async () => {
113
113
  await db.close();
@@ -115,7 +115,7 @@ describe("named Ledger with record", function () {
115
115
  });
116
116
  beforeEach(async function () {
117
117
  await sthis.start();
118
- db = LedgerFactory("test-db-name");
118
+ db = DatabaseFactory("test-db-name");
119
119
  /** @type {Doc} */
120
120
  const doc = { _id: "hello", value: "world" };
121
121
  const ok = await db.put(doc);
@@ -217,13 +217,13 @@ describe("named Ledger with record", function () {
217
217
  });
218
218
  });
219
219
 
220
- // describe('basic Ledger parallel writes / public', function () {
221
- // /** @type {Ledger} */
220
+ // describe('basic Database parallel writes / public', function () {
221
+ // /** @type {Database} */
222
222
  // let db
223
223
  // const writes = []
224
224
  // beforeEach(async function () {
225
225
  // await resetDirectory(dataDir, 'test-parallel-writes')
226
- // db = new Ledger('test-parallel-writes', { public: true })
226
+ // db = new Database('test-parallel-writes', { public: true })
227
227
  // /** @type {Doc} */
228
228
  // for (let i = 0; i < 10; i++) {
229
229
  // const doc = { _id: `id-${i}`, hello: 'world' }
@@ -232,8 +232,8 @@ describe("named Ledger with record", function () {
232
232
  // await Promise.all(writes)
233
233
  // })
234
234
 
235
- describe("basic Ledger parallel writes / public ordered", () => {
236
- let db: Ledger;
235
+ describe("basic Database parallel writes / public ordered", () => {
236
+ let db: Database;
237
237
  const writes: Promise<DocResponse>[] = [];
238
238
  const sthis = mockSuperThis();
239
239
  afterEach(async () => {
@@ -242,7 +242,7 @@ describe("basic Ledger parallel writes / public ordered", () => {
242
242
  });
243
243
  beforeEach(async () => {
244
244
  await sthis.start();
245
- db = LedgerFactory("test-parallel-writes-ordered", { writeQueue: { chunkSize: 1 } });
245
+ db = DatabaseFactory("test-parallel-writes-ordered", { writeQueue: { chunkSize: 1 } });
246
246
  for (let i = 0; i < 10; i++) {
247
247
  const doc = { _id: `id-${i}`, hello: "world" };
248
248
  writes.push(db.put(doc));
@@ -266,8 +266,8 @@ describe("basic Ledger parallel writes / public ordered", () => {
266
266
  });
267
267
  });
268
268
 
269
- describe("basic Ledger parallel writes / public", () => {
270
- let db: Ledger;
269
+ describe("basic Database parallel writes / public", () => {
270
+ let db: Database;
271
271
  const writes: Promise<DocResponse>[] = [];
272
272
  const sthis = ensureSuperThis();
273
273
  afterEach(async () => {
@@ -276,7 +276,7 @@ describe("basic Ledger parallel writes / public", () => {
276
276
  });
277
277
  beforeEach(async () => {
278
278
  await sthis.start();
279
- db = LedgerFactory("test-parallel-writes", { writeQueue: { chunkSize: 32 } });
279
+ db = DatabaseFactory("test-parallel-writes", { writeQueue: { chunkSize: 32 } });
280
280
  for (let i = 0; i < 10; i++) {
281
281
  const doc = { _id: `id-${i}`, hello: "world" };
282
282
  writes.push(db.put(doc));
@@ -346,8 +346,8 @@ describe("basic Ledger parallel writes / public", () => {
346
346
  });
347
347
  });
348
348
 
349
- describe("basic Ledger with subscription", function () {
350
- let db: Ledger;
349
+ describe("basic Database with subscription", function () {
350
+ let db: Database;
351
351
  let didRun: number;
352
352
  let unsubscribe: () => void;
353
353
  let lastDoc: DocWithId<NonNullable<unknown>>;
@@ -359,7 +359,7 @@ describe("basic Ledger with subscription", function () {
359
359
  });
360
360
  beforeEach(async function () {
361
361
  await sthis.start();
362
- db = LedgerFactory("factory-name");
362
+ db = DatabaseFactory("factory-name");
363
363
  didRun = 0;
364
364
  waitForSub = new Promise((resolve) => {
365
365
  unsubscribe = db.subscribe((docs) => {
@@ -392,8 +392,8 @@ describe("basic Ledger with subscription", function () {
392
392
  });
393
393
  });
394
394
 
395
- describe("basic Ledger with no update subscription", function () {
396
- let db: Ledger;
395
+ describe("basic Database with no update subscription", function () {
396
+ let db: Database;
397
397
  let didRun: number;
398
398
  let unsubscribe: () => void;
399
399
  const sthis = ensureSuperThis();
@@ -403,7 +403,7 @@ describe("basic Ledger with no update subscription", function () {
403
403
  });
404
404
  beforeEach(async function () {
405
405
  await sthis.start();
406
- db = LedgerFactory("factory-name");
406
+ db = DatabaseFactory("factory-name");
407
407
  didRun = 0;
408
408
  unsubscribe = db.subscribe(() => {
409
409
  didRun++;
@@ -428,8 +428,8 @@ describe("basic Ledger with no update subscription", function () {
428
428
  });
429
429
  });
430
430
 
431
- describe("ledger with files input", () => {
432
- let db: Ledger;
431
+ describe("database with files input", () => {
432
+ let db: Database;
433
433
  let imagefiles: FileWithCid[] = [];
434
434
  let result: DocResponse;
435
435
  const sthis = ensureSuperThis();
@@ -441,7 +441,7 @@ describe("ledger with files input", () => {
441
441
  beforeEach(async function () {
442
442
  await sthis.start();
443
443
  imagefiles = await buildBlobFiles();
444
- db = LedgerFactory("fireproof-with-images");
444
+ db = DatabaseFactory("fireproof-with-images");
445
445
  const doc = {
446
446
  _id: "images-main",
447
447
  type: "files",
@@ -4,8 +4,8 @@ import { CID } from "multiformats/cid";
4
4
 
5
5
  import {
6
6
  ConfigOpts,
7
- Ledger,
8
- LedgerFactory,
7
+ Database,
8
+ DatabaseFactory,
9
9
  DocResponse,
10
10
  DocWithId,
11
11
  Index,
@@ -14,7 +14,7 @@ import {
14
14
  bs,
15
15
  fireproof,
16
16
  index,
17
- isLedger,
17
+ isDatabase,
18
18
  ensureSuperThis,
19
19
  } from "@fireproof/core";
20
20
 
@@ -38,7 +38,7 @@ describe("dreamcode", function () {
38
38
  let ok: DocResponse;
39
39
  let doc: DocWithId<Doc>;
40
40
  let result: IndexRows<string, Doc>;
41
- let db: Ledger;
41
+ let db: Database;
42
42
  const sthis = ensureSuperThis();
43
43
  afterEach(async function () {
44
44
  await db.close();
@@ -77,7 +77,7 @@ describe("public API", function () {
77
77
  interface Doc {
78
78
  foo: string;
79
79
  }
80
- let db: Ledger;
80
+ let db: Database;
81
81
  let ok: DocResponse;
82
82
  let doc: DocWithId<Doc>;
83
83
  let query: IndexRows<string, Doc>;
@@ -96,9 +96,9 @@ describe("public API", function () {
96
96
  doc = await db.get("test");
97
97
  query = await db.query<string, Doc>((doc) => doc.foo);
98
98
  });
99
- it("should be a ledger instance", function () {
99
+ it("should be a database instance", function () {
100
100
  expect(db).toBeTruthy();
101
- expect(isLedger(db)).toBeTruthy();
101
+ expect(isDatabase(db)).toBeTruthy();
102
102
  });
103
103
  it("should put", function () {
104
104
  expect(ok).toBeTruthy();
@@ -115,11 +115,11 @@ describe("public API", function () {
115
115
  });
116
116
  });
117
117
 
118
- describe("basic ledger", function () {
118
+ describe("basic database", function () {
119
119
  interface Doc {
120
120
  foo: string;
121
121
  }
122
- let db: Ledger<Doc>;
122
+ let db: Database<Doc>;
123
123
  const sthis = ensureSuperThis();
124
124
  afterEach(async function () {
125
125
  await db.close();
@@ -127,7 +127,7 @@ describe("basic ledger", function () {
127
127
  });
128
128
  beforeEach(async function () {
129
129
  await sthis.start();
130
- db = LedgerFactory("test-basic");
130
+ db = DatabaseFactory("test-basic");
131
131
  });
132
132
  it("can put with id", async function () {
133
133
  const ok = await db.put({ _id: "test", foo: "bar" });
@@ -192,7 +192,7 @@ describe("basic ledger", function () {
192
192
  });
193
193
 
194
194
  describe("benchmarking with compaction", function () {
195
- let db: Ledger;
195
+ let db: Database;
196
196
  const sthis = ensureSuperThis();
197
197
  afterEach(async function () {
198
198
  await db.close();
@@ -201,7 +201,7 @@ describe("benchmarking with compaction", function () {
201
201
  beforeEach(async function () {
202
202
  // erase the existing test data
203
203
  await sthis.start();
204
- db = LedgerFactory("test-benchmark-compaction", { autoCompact: 3 });
204
+ db = DatabaseFactory("test-benchmark-compaction", { autoCompact: 3 });
205
205
  });
206
206
  it.skip("insert during compaction", async function () {
207
207
  const ok = await db.put({ _id: "test", foo: "fast" });
@@ -245,9 +245,9 @@ describe("benchmarking with compaction", function () {
245
245
  });
246
246
  });
247
247
 
248
- describe("benchmarking a ledger", function () {
249
- /** @type {Ledger} */
250
- let db: Ledger;
248
+ describe("benchmarking a database", function () {
249
+ /** @type {Database} */
250
+ let db: Database;
251
251
  const sthis = ensureSuperThis();
252
252
  afterEach(async function () {
253
253
  await db.close();
@@ -256,8 +256,8 @@ describe("benchmarking a ledger", function () {
256
256
  beforeEach(async function () {
257
257
  await sthis.start();
258
258
  // erase the existing test data
259
- db = LedgerFactory("test-benchmark", { autoCompact: 100000, public: true });
260
- // db = LedgerFactory(null, {autoCompact: 100000})
259
+ db = DatabaseFactory("test-benchmark", { autoCompact: 100000, public: true });
260
+ // db = DatabaseFactory(null, {autoCompact: 100000})
261
261
  });
262
262
 
263
263
  // run benchmarking tests
@@ -307,7 +307,7 @@ describe("benchmarking a ledger", function () {
307
307
  // equals(allDocsResult2.rows.length, numDocs+1)
308
308
 
309
309
  // console.time("open new DB");
310
- const newDb = LedgerFactory("test-benchmark", { autoCompact: 100000, public: true });
310
+ const newDb = DatabaseFactory("test-benchmark", { autoCompact: 100000, public: true });
311
311
  const doc = await newDb.get<{ foo: string }>("test");
312
312
  expect(doc.foo).toBe("fast");
313
313
  // console.timeEnd("open new DB");
@@ -349,7 +349,7 @@ describe("benchmarking a ledger", function () {
349
349
  await sleep(100);
350
350
 
351
351
  // console.time("compacted reopen again");
352
- const newDb2 = LedgerFactory("test-benchmark", { autoCompact: 100000, public: true });
352
+ const newDb2 = DatabaseFactory("test-benchmark", { autoCompact: 100000, public: true });
353
353
  const doc21 = await newDb2.get<FooType>("test");
354
354
  expect(doc21.foo).toBe("fast");
355
355
  const blocks2 = newDb2.crdt.blockstore as bs.EncryptedBlockstore;
@@ -401,11 +401,11 @@ describe("benchmarking a ledger", function () {
401
401
  }, 20000000);
402
402
  });
403
403
 
404
- describe("Reopening a ledger", function () {
404
+ describe("Reopening a database", function () {
405
405
  interface Doc {
406
406
  foo: string;
407
407
  }
408
- let db: Ledger;
408
+ let db: Database;
409
409
  const sthis = ensureSuperThis();
410
410
  afterEach(async function () {
411
411
  await db.close();
@@ -415,7 +415,7 @@ describe("Reopening a ledger", function () {
415
415
  // erase the existing test data
416
416
  await sthis.start();
417
417
 
418
- db = LedgerFactory("test-reopen", { autoCompact: 100000 });
418
+ db = DatabaseFactory("test-reopen", { autoCompact: 100000 });
419
419
  const ok = await db.put({ _id: "test", foo: "bar" });
420
420
  expect(ok).toBeTruthy();
421
421
  expect(ok.id).toBe("test");
@@ -430,7 +430,7 @@ describe("Reopening a ledger", function () {
430
430
  });
431
431
 
432
432
  it("should have the same data on reopen", async function () {
433
- const db2 = LedgerFactory("test-reopen");
433
+ const db2 = DatabaseFactory("test-reopen");
434
434
  const doc = await db2.get<FooType>("test");
435
435
  expect(doc.foo).toBe("bar");
436
436
  expect(db2.crdt.clock.head).toBeDefined();
@@ -449,7 +449,7 @@ describe("Reopening a ledger", function () {
449
449
  });
450
450
 
451
451
  it("should have carlog after reopen", async function () {
452
- const db2 = LedgerFactory("test-reopen");
452
+ const db2 = DatabaseFactory("test-reopen");
453
453
  await db2.crdt.ready();
454
454
  const blocks = db2.crdt.blockstore as bs.EncryptedBlockstore;
455
455
  const loader = blocks.loader;
@@ -462,7 +462,7 @@ describe("Reopening a ledger", function () {
462
462
  it("faster, should have the same data on reopen after reopen and update", async function () {
463
463
  for (let i = 0; i < 4; i++) {
464
464
  // console.log('iteration', i)
465
- const db = LedgerFactory("test-reopen");
465
+ const db = DatabaseFactory("test-reopen");
466
466
  // assert(db._crdt.xready());
467
467
  await db.crdt.ready();
468
468
  const blocks = db.crdt.blockstore as bs.EncryptedBlockstore;
@@ -481,7 +481,7 @@ describe("Reopening a ledger", function () {
481
481
  for (let i = 0; i < 200; i++) {
482
482
  // console.log("iteration", i);
483
483
  // console.time("db open");
484
- const db = LedgerFactory("test-reopen", { autoCompact: 1000 }); // try with 10
484
+ const db = DatabaseFactory("test-reopen", { autoCompact: 1000 }); // try with 10
485
485
  // assert(db._crdt.ready);
486
486
  await db.crdt.ready();
487
487
  // console.timeEnd("db open");
@@ -503,11 +503,11 @@ describe("Reopening a ledger", function () {
503
503
  }, 200000);
504
504
  });
505
505
 
506
- describe("Reopening a ledger with indexes", function () {
506
+ describe("Reopening a database with indexes", function () {
507
507
  interface Doc {
508
508
  foo: string;
509
509
  }
510
- let db: Ledger;
510
+ let db: Database;
511
511
  let idx: Index<string, Doc>;
512
512
  let didMap: boolean;
513
513
  let mapFn: MapFn<Doc>;
@@ -635,8 +635,8 @@ describe("basic js verify", function () {
635
635
  });
636
636
 
637
637
  describe("same workload twice, same CID", function () {
638
- let dbA: Ledger;
639
- let dbB: Ledger;
638
+ let dbA: Database;
639
+ let dbB: Database;
640
640
  let headA: string;
641
641
  let headB: string;
642
642
 
@@ -665,7 +665,7 @@ describe("same workload twice, same CID", function () {
665
665
  beforeEach(async function () {
666
666
  let ok: DocResponse;
667
667
  await sthis.start();
668
- // todo this fails because the test setup doesn't properly configure both ledgers to use the same key
668
+ // todo this fails because the test setup doesn't properly configure both databases to use the same key
669
669
  dbA = fireproof("test-dual-workload-a", configA);
670
670
  for (const doc of docs) {
671
671
  ok = await dbA.put(doc);
@@ -674,7 +674,7 @@ describe("same workload twice, same CID", function () {
674
674
  }
675
675
  headA = dbA.crdt.clock.head.toString();
676
676
 
677
- // todo this fails because the test setup doesn't properly configure both ledgers to use the same key
677
+ // todo this fails because the test setup doesn't properly configure both databases to use the same key
678
678
  dbB = fireproof("test-dual-workload-b", configB);
679
679
  for (const doc of docs) {
680
680
  ok = await dbB.put(doc);
@@ -705,7 +705,7 @@ describe("same workload twice, same CID", function () {
705
705
 
706
706
  expect(logA2.length).toBe(logB2.length);
707
707
 
708
- // todo this fails because the test setup doesn't properly configure both ledgers to use the same key
708
+ // todo this fails because the test setup doesn't properly configure both databases to use the same key
709
709
  // expect(logA2).toEqual(logB2);
710
710
  });
711
711
  it("should have same car log after compact", async function () {
@@ -727,7 +727,7 @@ describe("same workload twice, same CID", function () {
727
727
 
728
728
  expect(cmpLogA2.length).toBe(cmpLogB2.length);
729
729
 
730
- // todo this fails because the test setup doesn't properly configure both ledgers to use the same key
730
+ // todo this fails because the test setup doesn't properly configure both databases to use the same key
731
731
  // expect(cmpLogA2).toEqual(cmpLogB2);
732
732
  });
733
733
  });
@@ -1,4 +1,4 @@
1
- import { fireproof, Ledger, DocResponse, DocWithId, index, isLedger } from "@fireproof/core";
1
+ import { fireproof, Database, DocResponse, DocWithId, index, isDatabase } from "@fireproof/core";
2
2
  import { mockSuperThis } from "../helpers.js";
3
3
 
4
4
  describe("Hello World Test", function () {
@@ -12,7 +12,7 @@ describe("hello public API", () => {
12
12
  interface TestDoc {
13
13
  foo: string;
14
14
  }
15
- let db: Ledger;
15
+ let db: Database;
16
16
  let ok: DocResponse;
17
17
  let doc: DocWithId<TestDoc>;
18
18
  // let idx: Index<string, TestDoc>;
@@ -28,9 +28,9 @@ describe("hello public API", () => {
28
28
  ok = await db.put({ _id: "test", foo: "bar" });
29
29
  doc = await db.get("test");
30
30
  });
31
- it("should have a ledger", function () {
31
+ it("should have a database", function () {
32
32
  expect(db).toBeTruthy();
33
- expect(isLedger(db)).toBeTruthy();
33
+ expect(isDatabase(db)).toBeTruthy();
34
34
  });
35
35
  it("should put", function () {
36
36
  expect(ok).toBeTruthy();
@@ -47,8 +47,8 @@ describe("hello public API", () => {
47
47
  });
48
48
  });
49
49
 
50
- describe("Simplified Reopening a ledger", function () {
51
- let db: Ledger;
50
+ describe("Simplified Reopening a database", function () {
51
+ let db: Database;
52
52
  afterEach(async function () {
53
53
  await db.close();
54
54
  await db.destroy();