@fireproof/core 0.19.5-dev → 0.19.8-dev-alldocs
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/{chunk-QHSXUST7.js → chunk-5UFCF36O.js} +3 -3
 - package/{chunk-HCXR2M5B.js → chunk-DG6XSV44.js} +175 -7
 - package/chunk-DG6XSV44.js.map +1 -0
 - package/{chunk-H3A2HMMM.js → chunk-OWQAHX2V.js} +2 -2
 - package/chunk-OWQAHX2V.js.map +1 -0
 - package/{chunk-7OGPZSGT.js → chunk-PRQHQG4I.js} +2 -2
 - package/index.cjs +248 -191
 - package/index.cjs.map +1 -1
 - package/index.d.cts +174 -68
 - package/index.d.ts +174 -68
 - package/index.global.js +24688 -0
 - package/index.global.js.map +1 -0
 - package/index.js +60 -127
 - package/index.js.map +1 -1
 - package/metafile-cjs.json +1 -1
 - package/metafile-esm.json +1 -1
 - package/metafile-iife.json +1 -0
 - package/{node-sys-container-E7LADX2Z.js → node-sys-container-TTGEC66A.js} +2 -2
 - package/package.json +1 -1
 - package/{sqlite-data-store-YS4U7AQ4.js → sqlite-data-store-MA55LVQE.js} +4 -4
 - package/{sqlite-meta-store-FJZSZG4R.js → sqlite-meta-store-UNQKVYRM.js} +4 -4
 - package/{sqlite-wal-store-6JZ4URNS.js → sqlite-wal-store-KVUOC4PO.js} +4 -4
 - package/{store-file-HMHPQTUV.js → store-file-WD746RSY.js} +3 -3
 - package/{store-indexdb-MRVZG4OG.js → store-indexdb-NG45BU3Q.js} +4 -4
 - package/{store-sql-5XMJ5OWJ.js → store-sql-QVFNIGND.js} +7 -69
 - package/store-sql-QVFNIGND.js.map +1 -0
 - package/tests/blockstore/loader.test.ts +265 -0
 - package/tests/blockstore/store.test.ts +164 -0
 - package/tests/blockstore/transaction.test.ts +121 -0
 - package/tests/fireproof/config.test.ts +212 -0
 - package/tests/fireproof/crdt.test.ts +434 -0
 - package/tests/fireproof/database.test.ts +466 -0
 - package/tests/fireproof/fireproof.test.ts +602 -0
 - package/tests/fireproof/hello.test.ts +54 -0
 - package/tests/fireproof/indexer.test.ts +389 -0
 - package/tests/helpers.ts +81 -0
 - package/tests/react/useFireproof.test.tsx +19 -0
 - package/tests/www/gallery.html +132 -0
 - package/tests/www/iife.html +42 -0
 - package/tests/www/todo-aws.html +232 -0
 - package/tests/www/todo-ipfs.html +213 -0
 - package/tests/www/todo-local.html +214 -0
 - package/tests/www/todo-netlify.html +227 -0
 - package/tests/www/todo.html +236 -0
 - package/chunk-H3A2HMMM.js.map +0 -1
 - package/chunk-HCXR2M5B.js.map +0 -1
 - package/store-sql-5XMJ5OWJ.js.map +0 -1
 - /package/{chunk-QHSXUST7.js.map → chunk-5UFCF36O.js.map} +0 -0
 - /package/{chunk-7OGPZSGT.js.map → chunk-PRQHQG4I.js.map} +0 -0
 - /package/{node-sys-container-E7LADX2Z.js.map → node-sys-container-TTGEC66A.js.map} +0 -0
 - /package/{sqlite-data-store-YS4U7AQ4.js.map → sqlite-data-store-MA55LVQE.js.map} +0 -0
 - /package/{sqlite-meta-store-FJZSZG4R.js.map → sqlite-meta-store-UNQKVYRM.js.map} +0 -0
 - /package/{sqlite-wal-store-6JZ4URNS.js.map → sqlite-wal-store-KVUOC4PO.js.map} +0 -0
 - /package/{store-file-HMHPQTUV.js.map → store-file-WD746RSY.js.map} +0 -0
 - /package/{store-indexdb-MRVZG4OG.js.map → store-indexdb-NG45BU3Q.js.map} +0 -0
 
| 
         @@ -0,0 +1,164 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import { CID } from "multiformats";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import { rt, bs } from "@fireproof/core";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import { MockLogger } from "@adviser/cement";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import { NotFoundError } from "../../src/blockstore/gateway";
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            const decoder = new TextDecoder("utf-8");
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            function runtime() {
         
     | 
| 
      
 9 
     | 
    
         
            +
              return bs.toStoreRuntime({}, MockLogger().logger);
         
     | 
| 
      
 10 
     | 
    
         
            +
            }
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            function mockLoader(name: string): bs.Loadable {
         
     | 
| 
      
 13 
     | 
    
         
            +
              return {
         
     | 
| 
      
 14 
     | 
    
         
            +
                name,
         
     | 
| 
      
 15 
     | 
    
         
            +
                ebOpts: {
         
     | 
| 
      
 16 
     | 
    
         
            +
                  store: {},
         
     | 
| 
      
 17 
     | 
    
         
            +
                },
         
     | 
| 
      
 18 
     | 
    
         
            +
              } as bs.Loadable;
         
     | 
| 
      
 19 
     | 
    
         
            +
            }
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            describe("DataStore", function () {
         
     | 
| 
      
 22 
     | 
    
         
            +
              let store: bs.DataStore;
         
     | 
| 
      
 23 
     | 
    
         
            +
              let raw: bs.TestStore;
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              afterEach(async () => {
         
     | 
| 
      
 26 
     | 
    
         
            +
                await store.close();
         
     | 
| 
      
 27 
     | 
    
         
            +
                await store.destroy();
         
     | 
| 
      
 28 
     | 
    
         
            +
              });
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              beforeEach(async () => {
         
     | 
| 
      
 31 
     | 
    
         
            +
                await rt.SysContainer.start();
         
     | 
| 
      
 32 
     | 
    
         
            +
                store = await runtime().makeDataStore(mockLoader("test"));
         
     | 
| 
      
 33 
     | 
    
         
            +
                await store.start();
         
     | 
| 
      
 34 
     | 
    
         
            +
                raw = await bs.testStoreFactory(store.url);
         
     | 
| 
      
 35 
     | 
    
         
            +
              });
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              it("should have a name", function () {
         
     | 
| 
      
 38 
     | 
    
         
            +
                expect(store.name).toEqual("test");
         
     | 
| 
      
 39 
     | 
    
         
            +
              });
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              it("should save a car", async function () {
         
     | 
| 
      
 42 
     | 
    
         
            +
                const car: bs.AnyBlock = {
         
     | 
| 
      
 43 
     | 
    
         
            +
                  cid: "cidKey" as unknown as CID,
         
     | 
| 
      
 44 
     | 
    
         
            +
                  bytes: new Uint8Array([55, 56, 57]),
         
     | 
| 
      
 45 
     | 
    
         
            +
                };
         
     | 
| 
      
 46 
     | 
    
         
            +
                await store.save(car);
         
     | 
| 
      
 47 
     | 
    
         
            +
                const data = await raw.get(store.url, car.cid.toString());
         
     | 
| 
      
 48 
     | 
    
         
            +
                expect(decoder.decode(data)).toEqual(decoder.decode(car.bytes));
         
     | 
| 
      
 49 
     | 
    
         
            +
              });
         
     | 
| 
      
 50 
     | 
    
         
            +
            });
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            describe("DataStore with a saved car", function () {
         
     | 
| 
      
 53 
     | 
    
         
            +
              let store: bs.DataStore;
         
     | 
| 
      
 54 
     | 
    
         
            +
              let raw: bs.TestStore;
         
     | 
| 
      
 55 
     | 
    
         
            +
              let car: bs.AnyBlock;
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              afterEach(async () => {
         
     | 
| 
      
 58 
     | 
    
         
            +
                await store.close();
         
     | 
| 
      
 59 
     | 
    
         
            +
                await store.destroy();
         
     | 
| 
      
 60 
     | 
    
         
            +
              });
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              beforeEach(async function () {
         
     | 
| 
      
 63 
     | 
    
         
            +
                await rt.SysContainer.start();
         
     | 
| 
      
 64 
     | 
    
         
            +
                store = await runtime().makeDataStore(mockLoader("test2"));
         
     | 
| 
      
 65 
     | 
    
         
            +
                await store.start();
         
     | 
| 
      
 66 
     | 
    
         
            +
                raw = await bs.testStoreFactory(store.url);
         
     | 
| 
      
 67 
     | 
    
         
            +
                car = {
         
     | 
| 
      
 68 
     | 
    
         
            +
                  cid: "cid" as unknown as CID,
         
     | 
| 
      
 69 
     | 
    
         
            +
                  bytes: new Uint8Array([55, 56, 57, 80]),
         
     | 
| 
      
 70 
     | 
    
         
            +
                };
         
     | 
| 
      
 71 
     | 
    
         
            +
                await store.save(car);
         
     | 
| 
      
 72 
     | 
    
         
            +
              });
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              it("should have a car", async function () {
         
     | 
| 
      
 75 
     | 
    
         
            +
                const data = await raw.get(store.url, car.cid.toString());
         
     | 
| 
      
 76 
     | 
    
         
            +
                expect(decoder.decode(data)).toEqual(decoder.decode(car.bytes));
         
     | 
| 
      
 77 
     | 
    
         
            +
              });
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              it("should load a car", async function () {
         
     | 
| 
      
 80 
     | 
    
         
            +
                const loaded = await store.load(car.cid);
         
     | 
| 
      
 81 
     | 
    
         
            +
                expect(loaded.cid).toEqual(car.cid);
         
     | 
| 
      
 82 
     | 
    
         
            +
                expect(loaded.bytes.constructor.name).toEqual("Uint8Array");
         
     | 
| 
      
 83 
     | 
    
         
            +
                expect(loaded.bytes.toString()).toEqual(car.bytes.toString());
         
     | 
| 
      
 84 
     | 
    
         
            +
              });
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              it("should remove a car", async function () {
         
     | 
| 
      
 87 
     | 
    
         
            +
                await store.remove(car.cid);
         
     | 
| 
      
 88 
     | 
    
         
            +
                const error = (await store.load(car.cid).catch((e: Error) => e)) as NotFoundError;
         
     | 
| 
      
 89 
     | 
    
         
            +
                expect(error.code).toMatch("ENOENT");
         
     | 
| 
      
 90 
     | 
    
         
            +
                // matches(error.message, "ENOENT");
         
     | 
| 
      
 91 
     | 
    
         
            +
              });
         
     | 
| 
      
 92 
     | 
    
         
            +
            });
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            describe("MetaStore", function () {
         
     | 
| 
      
 95 
     | 
    
         
            +
              let store: bs.MetaStore;
         
     | 
| 
      
 96 
     | 
    
         
            +
              let raw: bs.TestStore;
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              afterEach(async () => {
         
     | 
| 
      
 99 
     | 
    
         
            +
                await store.close();
         
     | 
| 
      
 100 
     | 
    
         
            +
                await store.destroy();
         
     | 
| 
      
 101 
     | 
    
         
            +
              });
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              beforeEach(async function () {
         
     | 
| 
      
 104 
     | 
    
         
            +
                await rt.SysContainer.start();
         
     | 
| 
      
 105 
     | 
    
         
            +
                store = await runtime().makeMetaStore(mockLoader("test"));
         
     | 
| 
      
 106 
     | 
    
         
            +
                await store.start();
         
     | 
| 
      
 107 
     | 
    
         
            +
                raw = await bs.testStoreFactory(store.url);
         
     | 
| 
      
 108 
     | 
    
         
            +
              });
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              it("should have a name", function () {
         
     | 
| 
      
 111 
     | 
    
         
            +
                expect(store.name).toEqual("test");
         
     | 
| 
      
 112 
     | 
    
         
            +
              });
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
              it("should save a header", async function () {
         
     | 
| 
      
 115 
     | 
    
         
            +
                const cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
         
     | 
| 
      
 116 
     | 
    
         
            +
                const h: bs.DbMeta = {
         
     | 
| 
      
 117 
     | 
    
         
            +
                  cars: [cid],
         
     | 
| 
      
 118 
     | 
    
         
            +
                  key: undefined,
         
     | 
| 
      
 119 
     | 
    
         
            +
                };
         
     | 
| 
      
 120 
     | 
    
         
            +
                await store.save(h);
         
     | 
| 
      
 121 
     | 
    
         
            +
                const file = await raw.get(store.url, "main");
         
     | 
| 
      
 122 
     | 
    
         
            +
                const header = JSON.parse(decoder.decode(file));
         
     | 
| 
      
 123 
     | 
    
         
            +
                expect(header).toBeTruthy();
         
     | 
| 
      
 124 
     | 
    
         
            +
                expect(header.cars).toBeTruthy();
         
     | 
| 
      
 125 
     | 
    
         
            +
                expect(header.cars[0]["/"]).toEqual(cid.toString());
         
     | 
| 
      
 126 
     | 
    
         
            +
              });
         
     | 
| 
      
 127 
     | 
    
         
            +
            });
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            describe("MetaStore with a saved header", function () {
         
     | 
| 
      
 130 
     | 
    
         
            +
              let store: bs.MetaStore;
         
     | 
| 
      
 131 
     | 
    
         
            +
              let raw: bs.TestStore;
         
     | 
| 
      
 132 
     | 
    
         
            +
              let cid: CID;
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
              afterEach(async () => {
         
     | 
| 
      
 135 
     | 
    
         
            +
                await store.close();
         
     | 
| 
      
 136 
     | 
    
         
            +
                await store.destroy();
         
     | 
| 
      
 137 
     | 
    
         
            +
              });
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
              beforeEach(async function () {
         
     | 
| 
      
 140 
     | 
    
         
            +
                await rt.SysContainer.start();
         
     | 
| 
      
 141 
     | 
    
         
            +
                store = await runtime().makeMetaStore(mockLoader("test-saved-header"));
         
     | 
| 
      
 142 
     | 
    
         
            +
                await store.start();
         
     | 
| 
      
 143 
     | 
    
         
            +
                raw = await bs.testStoreFactory(store.url);
         
     | 
| 
      
 144 
     | 
    
         
            +
                cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
         
     | 
| 
      
 145 
     | 
    
         
            +
                await store.save({ cars: [cid], key: undefined });
         
     | 
| 
      
 146 
     | 
    
         
            +
              });
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
              it("should have a header", async function () {
         
     | 
| 
      
 149 
     | 
    
         
            +
                const data = decoder.decode(await raw.get(store.url, "main"));
         
     | 
| 
      
 150 
     | 
    
         
            +
                expect(data).toMatch(/car/);
         
     | 
| 
      
 151 
     | 
    
         
            +
                const header = JSON.parse(data);
         
     | 
| 
      
 152 
     | 
    
         
            +
                expect(header).toBeTruthy();
         
     | 
| 
      
 153 
     | 
    
         
            +
                expect(header.cars).toBeTruthy();
         
     | 
| 
      
 154 
     | 
    
         
            +
                expect(header.cars[0]["/"]).toEqual(cid.toString());
         
     | 
| 
      
 155 
     | 
    
         
            +
              });
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
              it("should load a header", async function () {
         
     | 
| 
      
 158 
     | 
    
         
            +
                const loadeds = (await store.load()) as bs.DbMeta[];
         
     | 
| 
      
 159 
     | 
    
         
            +
                const loaded = loadeds[0];
         
     | 
| 
      
 160 
     | 
    
         
            +
                expect(loaded).toBeTruthy();
         
     | 
| 
      
 161 
     | 
    
         
            +
                expect(loaded.cars).toBeTruthy();
         
     | 
| 
      
 162 
     | 
    
         
            +
                expect(loaded.cars.toString()).toEqual(cid.toString());
         
     | 
| 
      
 163 
     | 
    
         
            +
              });
         
     | 
| 
      
 164 
     | 
    
         
            +
            });
         
     | 
| 
         @@ -0,0 +1,121 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import { CID } from "multiformats";
         
     | 
| 
      
 2 
     | 
    
         
            +
            // import { matches, equalsJSON } from "../helpers.js";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import { bs } from "@fireproof/core";
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe("Fresh TransactionBlockstore", function () {
         
     | 
| 
      
 6 
     | 
    
         
            +
              let blocks: bs.BaseBlockstore;
         
     | 
| 
      
 7 
     | 
    
         
            +
              beforeEach(function () {
         
     | 
| 
      
 8 
     | 
    
         
            +
                blocks = new bs.BaseBlockstore();
         
     | 
| 
      
 9 
     | 
    
         
            +
              });
         
     | 
| 
      
 10 
     | 
    
         
            +
              it("should not have a name", function () {
         
     | 
| 
      
 11 
     | 
    
         
            +
                expect(blocks.name).toBeFalsy();
         
     | 
| 
      
 12 
     | 
    
         
            +
              });
         
     | 
| 
      
 13 
     | 
    
         
            +
              it("should not have a loader", function () {
         
     | 
| 
      
 14 
     | 
    
         
            +
                expect(blocks.loader).toBeFalsy();
         
     | 
| 
      
 15 
     | 
    
         
            +
              });
         
     | 
| 
      
 16 
     | 
    
         
            +
              it("should not put", async function () {
         
     | 
| 
      
 17 
     | 
    
         
            +
                const value = new TextEncoder().encode("value");
         
     | 
| 
      
 18 
     | 
    
         
            +
                const e = await blocks.put("key" as unknown as bs.AnyLink, value).catch((e) => e);
         
     | 
| 
      
 19 
     | 
    
         
            +
                expect(e.message).toMatch(/transaction/g);
         
     | 
| 
      
 20 
     | 
    
         
            +
              });
         
     | 
| 
      
 21 
     | 
    
         
            +
              it("should yield a transaction", async function () {
         
     | 
| 
      
 22 
     | 
    
         
            +
                const txR = await blocks.transaction(async (tblocks) => {
         
     | 
| 
      
 23 
     | 
    
         
            +
                  expect(tblocks).toBeTruthy();
         
     | 
| 
      
 24 
     | 
    
         
            +
                  expect(tblocks instanceof bs.CarTransaction).toBeTruthy();
         
     | 
| 
      
 25 
     | 
    
         
            +
                  return { head: [] };
         
     | 
| 
      
 26 
     | 
    
         
            +
                });
         
     | 
| 
      
 27 
     | 
    
         
            +
                expect(txR).toBeTruthy();
         
     | 
| 
      
 28 
     | 
    
         
            +
                expect(txR.t).toBeTruthy();
         
     | 
| 
      
 29 
     | 
    
         
            +
                expect(txR.meta).toEqual({ head: [] });
         
     | 
| 
      
 30 
     | 
    
         
            +
              });
         
     | 
| 
      
 31 
     | 
    
         
            +
            });
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            describe("TransactionBlockstore with name", function () {
         
     | 
| 
      
 34 
     | 
    
         
            +
              let blocks: bs.EncryptedBlockstore;
         
     | 
| 
      
 35 
     | 
    
         
            +
              beforeEach(function () {
         
     | 
| 
      
 36 
     | 
    
         
            +
                blocks = new bs.EncryptedBlockstore({ name: "test" });
         
     | 
| 
      
 37 
     | 
    
         
            +
              });
         
     | 
| 
      
 38 
     | 
    
         
            +
              it("should have a name", function () {
         
     | 
| 
      
 39 
     | 
    
         
            +
                expect(blocks.name).toEqual("test");
         
     | 
| 
      
 40 
     | 
    
         
            +
              });
         
     | 
| 
      
 41 
     | 
    
         
            +
              it("should have a loader", function () {
         
     | 
| 
      
 42 
     | 
    
         
            +
                expect(blocks.loader).toBeTruthy();
         
     | 
| 
      
 43 
     | 
    
         
            +
              });
         
     | 
| 
      
 44 
     | 
    
         
            +
              it("should get from loader", async function () {
         
     | 
| 
      
 45 
     | 
    
         
            +
                const bytes = new TextEncoder().encode("bytes");
         
     | 
| 
      
 46 
     | 
    
         
            +
                expect(blocks.loader).toBeTruthy();
         
     | 
| 
      
 47 
     | 
    
         
            +
                blocks.loader.getBlock = async (cid) => {
         
     | 
| 
      
 48 
     | 
    
         
            +
                  return { cid, bytes };
         
     | 
| 
      
 49 
     | 
    
         
            +
                };
         
     | 
| 
      
 50 
     | 
    
         
            +
                const value = await blocks.get("key" as unknown as bs.AnyAnyLink);
         
     | 
| 
      
 51 
     | 
    
         
            +
                expect(value).toEqual({ cid: "key" as unknown as bs.AnyAnyLink, bytes });
         
     | 
| 
      
 52 
     | 
    
         
            +
              });
         
     | 
| 
      
 53 
     | 
    
         
            +
            });
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            describe("A transaction", function () {
         
     | 
| 
      
 56 
     | 
    
         
            +
              let tblocks: bs.CarTransaction;
         
     | 
| 
      
 57 
     | 
    
         
            +
              let blocks: bs.EncryptedBlockstore;
         
     | 
| 
      
 58 
     | 
    
         
            +
              beforeEach(async function () {
         
     | 
| 
      
 59 
     | 
    
         
            +
                blocks = new bs.EncryptedBlockstore({ name: "test" });
         
     | 
| 
      
 60 
     | 
    
         
            +
                tblocks = new bs.CarTransaction(blocks);
         
     | 
| 
      
 61 
     | 
    
         
            +
                blocks.transactions.add(tblocks);
         
     | 
| 
      
 62 
     | 
    
         
            +
              });
         
     | 
| 
      
 63 
     | 
    
         
            +
              it("should put and get", async function () {
         
     | 
| 
      
 64 
     | 
    
         
            +
                const cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
         
     | 
| 
      
 65 
     | 
    
         
            +
                const bytes = new TextEncoder().encode("bytes");
         
     | 
| 
      
 66 
     | 
    
         
            +
                await tblocks.put(cid, bytes);
         
     | 
| 
      
 67 
     | 
    
         
            +
                expect(blocks.transactions.has(tblocks)).toBeTruthy();
         
     | 
| 
      
 68 
     | 
    
         
            +
                const got = await tblocks.get(cid);
         
     | 
| 
      
 69 
     | 
    
         
            +
                expect(got).toBeTruthy();
         
     | 
| 
      
 70 
     | 
    
         
            +
                expect(got?.cid).toEqual(cid);
         
     | 
| 
      
 71 
     | 
    
         
            +
                expect(got?.bytes).toEqual(bytes);
         
     | 
| 
      
 72 
     | 
    
         
            +
              });
         
     | 
| 
      
 73 
     | 
    
         
            +
            });
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            function asUInt8Array(str: string) {
         
     | 
| 
      
 76 
     | 
    
         
            +
              return new TextEncoder().encode(str);
         
     | 
| 
      
 77 
     | 
    
         
            +
            }
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            describe("TransactionBlockstore with a completed transaction", function () {
         
     | 
| 
      
 80 
     | 
    
         
            +
              let blocks: bs.BaseBlockstore;
         
     | 
| 
      
 81 
     | 
    
         
            +
              let cid: CID;
         
     | 
| 
      
 82 
     | 
    
         
            +
              let cid2: CID;
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              beforeEach(async function () {
         
     | 
| 
      
 85 
     | 
    
         
            +
                cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
         
     | 
| 
      
 86 
     | 
    
         
            +
                cid2 = CID.parse("bafybeibgouhn5ktecpjuovt52zamzvm4dlve5ak7x6d5smms3itkhplnhm");
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                blocks = new bs.BaseBlockstore();
         
     | 
| 
      
 89 
     | 
    
         
            +
                await blocks.transaction(async (tblocks) => {
         
     | 
| 
      
 90 
     | 
    
         
            +
                  await tblocks.put(cid, asUInt8Array("value"));
         
     | 
| 
      
 91 
     | 
    
         
            +
                  await tblocks.put(cid2, asUInt8Array("value2"));
         
     | 
| 
      
 92 
     | 
    
         
            +
                  return { head: [] };
         
     | 
| 
      
 93 
     | 
    
         
            +
                });
         
     | 
| 
      
 94 
     | 
    
         
            +
                await blocks.transaction(async (tblocks) => {
         
     | 
| 
      
 95 
     | 
    
         
            +
                  await tblocks.put(cid, asUInt8Array("value"));
         
     | 
| 
      
 96 
     | 
    
         
            +
                  await tblocks.put(cid2, asUInt8Array("value2"));
         
     | 
| 
      
 97 
     | 
    
         
            +
                  return { head: [] };
         
     | 
| 
      
 98 
     | 
    
         
            +
                });
         
     | 
| 
      
 99 
     | 
    
         
            +
              });
         
     | 
| 
      
 100 
     | 
    
         
            +
              it("should have transactions", async function () {
         
     | 
| 
      
 101 
     | 
    
         
            +
                const ts = blocks.transactions;
         
     | 
| 
      
 102 
     | 
    
         
            +
                expect(ts.size).toEqual(2);
         
     | 
| 
      
 103 
     | 
    
         
            +
              });
         
     | 
| 
      
 104 
     | 
    
         
            +
              it("should get", async function () {
         
     | 
| 
      
 105 
     | 
    
         
            +
                const value = (await blocks.get(cid)) as bs.AnyBlock;
         
     | 
| 
      
 106 
     | 
    
         
            +
                expect(value.cid).toEqual(cid);
         
     | 
| 
      
 107 
     | 
    
         
            +
                expect(value.bytes.toString()).toEqual(asUInt8Array("value").toString());
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                const value2 = (await blocks.get(cid2)) as bs.AnyBlock;
         
     | 
| 
      
 110 
     | 
    
         
            +
                expect(value2.bytes.toString()).toEqual(asUInt8Array("value2").toString());
         
     | 
| 
      
 111 
     | 
    
         
            +
              });
         
     | 
| 
      
 112 
     | 
    
         
            +
              it("should yield entries", async function () {
         
     | 
| 
      
 113 
     | 
    
         
            +
                const blz = [];
         
     | 
| 
      
 114 
     | 
    
         
            +
                for await (const blk of blocks.entries()) {
         
     | 
| 
      
 115 
     | 
    
         
            +
                  blz.push(blk);
         
     | 
| 
      
 116 
     | 
    
         
            +
                }
         
     | 
| 
      
 117 
     | 
    
         
            +
                expect(blz.length).toEqual(2);
         
     | 
| 
      
 118 
     | 
    
         
            +
              });
         
     | 
| 
      
 119 
     | 
    
         
            +
            });
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            // test compact
         
     | 
| 
         @@ -0,0 +1,212 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import { describe, it, expect, beforeAll } from "vitest";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import { fireproof, rt } from "@fireproof/core";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import { isNode } from "std-env";
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe("fireproof/config", () => {
         
     | 
| 
      
 6 
     | 
    
         
            +
              let _my_app = "my-app";
         
     | 
| 
      
 7 
     | 
    
         
            +
              function my_app() {
         
     | 
| 
      
 8 
     | 
    
         
            +
                return _my_app;
         
     | 
| 
      
 9 
     | 
    
         
            +
              }
         
     | 
| 
      
 10 
     | 
    
         
            +
              beforeAll(async () => {
         
     | 
| 
      
 11 
     | 
    
         
            +
                await rt.SysContainer.start();
         
     | 
| 
      
 12 
     | 
    
         
            +
                if (isNode) {
         
     | 
| 
      
 13 
     | 
    
         
            +
                  const fpStorageUrl = rt.SysContainer.env.get("FP_STORAGE_URL");
         
     | 
| 
      
 14 
     | 
    
         
            +
                  if (fpStorageUrl) {
         
     | 
| 
      
 15 
     | 
    
         
            +
                    let url: URL;
         
     | 
| 
      
 16 
     | 
    
         
            +
                    try {
         
     | 
| 
      
 17 
     | 
    
         
            +
                      url = new URL(fpStorageUrl);
         
     | 
| 
      
 18 
     | 
    
         
            +
                    } catch (e) {
         
     | 
| 
      
 19 
     | 
    
         
            +
                      url = new URL(`file://${fpStorageUrl}`);
         
     | 
| 
      
 20 
     | 
    
         
            +
                    }
         
     | 
| 
      
 21 
     | 
    
         
            +
                    _my_app = `my-app-${url.protocol.replace(/:$/, "")}`;
         
     | 
| 
      
 22 
     | 
    
         
            +
                  }
         
     | 
| 
      
 23 
     | 
    
         
            +
                }
         
     | 
| 
      
 24 
     | 
    
         
            +
              });
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              if (!isNode) {
         
     | 
| 
      
 27 
     | 
    
         
            +
                it("default", async () => {
         
     | 
| 
      
 28 
     | 
    
         
            +
                  const db = fireproof(my_app());
         
     | 
| 
      
 29 
     | 
    
         
            +
                  await db.put({ name: "my-app" });
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(db.name).toBe(my_app());
         
     | 
| 
      
 31 
     | 
    
         
            +
                  const carStore = await db.blockstore.loader?.carStore();
         
     | 
| 
      
 32 
     | 
    
         
            +
                  expect(carStore?.url.toString()).toMatch(new RegExp(`indexdb://fp\\?name=my-app&store=data&version=${rt.INDEXDB_VERSION}`));
         
     | 
| 
      
 33 
     | 
    
         
            +
                  const fileStore = await db.blockstore.loader?.fileStore();
         
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(fileStore?.url.toString()).toMatch(new RegExp(`indexdb://fp\\?name=my-app&store=data&version=${rt.INDEXDB_VERSION}`));
         
     | 
| 
      
 35 
     | 
    
         
            +
                  const metaStore = await db.blockstore.loader?.metaStore();
         
     | 
| 
      
 36 
     | 
    
         
            +
                  expect(metaStore?.url.toString()).toMatch(new RegExp(`indexdb://fp\\?name=my-app&store=meta&version=${rt.INDEXDB_VERSION}`));
         
     | 
| 
      
 37 
     | 
    
         
            +
                  await db.close();
         
     | 
| 
      
 38 
     | 
    
         
            +
                });
         
     | 
| 
      
 39 
     | 
    
         
            +
                return;
         
     | 
| 
      
 40 
     | 
    
         
            +
              }
         
     | 
| 
      
 41 
     | 
    
         
            +
              it("node default", async () => {
         
     | 
| 
      
 42 
     | 
    
         
            +
                const old = rt.SysContainer.env.get("FP_STORAGE_URL");
         
     | 
| 
      
 43 
     | 
    
         
            +
                rt.SysContainer.env.del("FP_STORAGE_URL");
         
     | 
| 
      
 44 
     | 
    
         
            +
                let baseDir = rt
         
     | 
| 
      
 45 
     | 
    
         
            +
                  .dataDir(my_app())
         
     | 
| 
      
 46 
     | 
    
         
            +
                  .replace(/\?.*$/, "")
         
     | 
| 
      
 47 
     | 
    
         
            +
                  .replace(/^file:\/\//, "");
         
     | 
| 
      
 48 
     | 
    
         
            +
                baseDir = rt.SysContainer.join(baseDir, rt.FILESTORE_VERSION, my_app());
         
     | 
| 
      
 49 
     | 
    
         
            +
                await rt.SysContainer.rm(baseDir, { recursive: true }).catch(() => {
         
     | 
| 
      
 50 
     | 
    
         
            +
                  /* */
         
     | 
| 
      
 51 
     | 
    
         
            +
                });
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                expect(baseDir).toMatch(new RegExp(`/\\.fireproof/${rt.FILESTORE_VERSION}/${my_app()}`));
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                const db = fireproof(my_app());
         
     | 
| 
      
 56 
     | 
    
         
            +
                await db.put({ name: "my-app" });
         
     | 
| 
      
 57 
     | 
    
         
            +
                expect(db.name).toBe(my_app());
         
     | 
| 
      
 58 
     | 
    
         
            +
                const carStore = await db.blockstore.loader?.carStore();
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                expect(carStore?.url.toString()).toMatch(
         
     | 
| 
      
 61 
     | 
    
         
            +
                  new RegExp(`file:.*\\/\\.fireproof\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 62 
     | 
    
         
            +
                );
         
     | 
| 
      
 63 
     | 
    
         
            +
                expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "data"))).isDirectory()).toBeTruthy();
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                const fileStore = await db.blockstore.loader?.fileStore();
         
     | 
| 
      
 66 
     | 
    
         
            +
                expect(fileStore?.url.toString()).toMatch(
         
     | 
| 
      
 67 
     | 
    
         
            +
                  new RegExp(`file:.*\\/\\.fireproof\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 68 
     | 
    
         
            +
                );
         
     | 
| 
      
 69 
     | 
    
         
            +
                const metaStore = await db.blockstore.loader?.metaStore();
         
     | 
| 
      
 70 
     | 
    
         
            +
                expect(metaStore?.url.toString()).toMatch(
         
     | 
| 
      
 71 
     | 
    
         
            +
                  new RegExp(`file:.*\\/\\.fireproof\\?name=${my_app()}&store=meta&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 72 
     | 
    
         
            +
                );
         
     | 
| 
      
 73 
     | 
    
         
            +
                expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
         
     | 
| 
      
 74 
     | 
    
         
            +
                rt.SysContainer.env.set("FP_STORAGE_URL", old);
         
     | 
| 
      
 75 
     | 
    
         
            +
                await db.close();
         
     | 
| 
      
 76 
     | 
    
         
            +
              });
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              it("set by env", async () => {
         
     | 
| 
      
 79 
     | 
    
         
            +
                const old = rt.SysContainer.env.get("FP_STORAGE_URL");
         
     | 
| 
      
 80 
     | 
    
         
            +
                rt.SysContainer.env.set("FP_STORAGE_URL", "./dist/env");
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                let baseDir = rt
         
     | 
| 
      
 83 
     | 
    
         
            +
                  .dataDir(my_app())
         
     | 
| 
      
 84 
     | 
    
         
            +
                  .replace(/\?.*$/, "")
         
     | 
| 
      
 85 
     | 
    
         
            +
                  .replace(/^file:\/\//, "");
         
     | 
| 
      
 86 
     | 
    
         
            +
                baseDir = rt.SysContainer.join(baseDir, rt.FILESTORE_VERSION, my_app());
         
     | 
| 
      
 87 
     | 
    
         
            +
                await rt.SysContainer.rm(baseDir, { recursive: true }).catch(() => {
         
     | 
| 
      
 88 
     | 
    
         
            +
                  /* */
         
     | 
| 
      
 89 
     | 
    
         
            +
                });
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                const db = fireproof(my_app());
         
     | 
| 
      
 92 
     | 
    
         
            +
                await db.put({ name: "my-app" });
         
     | 
| 
      
 93 
     | 
    
         
            +
                expect(db.name).toBe(my_app());
         
     | 
| 
      
 94 
     | 
    
         
            +
                const carStore = await db.blockstore.loader?.carStore();
         
     | 
| 
      
 95 
     | 
    
         
            +
                expect(carStore?.url.toString()).toMatch(
         
     | 
| 
      
 96 
     | 
    
         
            +
                  new RegExp(`file://\\./dist/env\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 97 
     | 
    
         
            +
                );
         
     | 
| 
      
 98 
     | 
    
         
            +
                expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "data"))).isDirectory()).toBeTruthy();
         
     | 
| 
      
 99 
     | 
    
         
            +
                const fileStore = await db.blockstore.loader?.fileStore();
         
     | 
| 
      
 100 
     | 
    
         
            +
                expect(fileStore?.url.toString()).toMatch(
         
     | 
| 
      
 101 
     | 
    
         
            +
                  new RegExp(`file://\\./dist/env\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 102 
     | 
    
         
            +
                );
         
     | 
| 
      
 103 
     | 
    
         
            +
                const metaStore = await db.blockstore.loader?.metaStore();
         
     | 
| 
      
 104 
     | 
    
         
            +
                expect(metaStore?.url.toString()).toMatch(
         
     | 
| 
      
 105 
     | 
    
         
            +
                  new RegExp(`file://\\./dist/env\\?name=${my_app()}&store=meta&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 106 
     | 
    
         
            +
                );
         
     | 
| 
      
 107 
     | 
    
         
            +
                expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
         
     | 
| 
      
 108 
     | 
    
         
            +
                await db.close();
         
     | 
| 
      
 109 
     | 
    
         
            +
                rt.SysContainer.env.set("FP_STORAGE_URL", old);
         
     | 
| 
      
 110 
     | 
    
         
            +
              });
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
              it("file path", async () => {
         
     | 
| 
      
 113 
     | 
    
         
            +
                let baseDir = "./dist/data".replace(/\?.*$/, "").replace(/^file:\/\//, "");
         
     | 
| 
      
 114 
     | 
    
         
            +
                baseDir = rt.SysContainer.join(baseDir, rt.FILESTORE_VERSION, my_app());
         
     | 
| 
      
 115 
     | 
    
         
            +
                await rt.SysContainer.rm(baseDir, { recursive: true }).catch(() => {
         
     | 
| 
      
 116 
     | 
    
         
            +
                  /* */
         
     | 
| 
      
 117 
     | 
    
         
            +
                });
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                const db = fireproof(my_app(), {
         
     | 
| 
      
 120 
     | 
    
         
            +
                  store: {
         
     | 
| 
      
 121 
     | 
    
         
            +
                    stores: {
         
     | 
| 
      
 122 
     | 
    
         
            +
                      base: "./dist/data",
         
     | 
| 
      
 123 
     | 
    
         
            +
                    },
         
     | 
| 
      
 124 
     | 
    
         
            +
                  },
         
     | 
| 
      
 125 
     | 
    
         
            +
                });
         
     | 
| 
      
 126 
     | 
    
         
            +
                // console.log(`>>>>>>>>>>>>>>>file-path`)
         
     | 
| 
      
 127 
     | 
    
         
            +
                await db.put({ name: "my-app" });
         
     | 
| 
      
 128 
     | 
    
         
            +
                expect(db.name).toBe(my_app());
         
     | 
| 
      
 129 
     | 
    
         
            +
                const carStore = await db.blockstore.loader?.carStore();
         
     | 
| 
      
 130 
     | 
    
         
            +
                expect(carStore?.url.toString()).toMatch(
         
     | 
| 
      
 131 
     | 
    
         
            +
                  new RegExp(`file://.\\/dist\\/data\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 132 
     | 
    
         
            +
                );
         
     | 
| 
      
 133 
     | 
    
         
            +
                const fileStore = await db.blockstore.loader?.fileStore();
         
     | 
| 
      
 134 
     | 
    
         
            +
                expect(fileStore?.url.toString()).toMatch(
         
     | 
| 
      
 135 
     | 
    
         
            +
                  new RegExp(`file://.\\/dist\\/data\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 136 
     | 
    
         
            +
                );
         
     | 
| 
      
 137 
     | 
    
         
            +
                expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "data"))).isDirectory()).toBeTruthy();
         
     | 
| 
      
 138 
     | 
    
         
            +
                const metaStore = await db.blockstore.loader?.metaStore();
         
     | 
| 
      
 139 
     | 
    
         
            +
                expect(metaStore?.url.toString()).toMatch(
         
     | 
| 
      
 140 
     | 
    
         
            +
                  new RegExp(`file://.\\/dist\\/data\\?name=${my_app()}&store=meta&version=${rt.FILESTORE_VERSION}`),
         
     | 
| 
      
 141 
     | 
    
         
            +
                );
         
     | 
| 
      
 142 
     | 
    
         
            +
                expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
         
     | 
| 
      
 143 
     | 
    
         
            +
                await db.close();
         
     | 
| 
      
 144 
     | 
    
         
            +
              });
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
              it("sqlite path", async () => {
         
     | 
| 
      
 147 
     | 
    
         
            +
                let dbFile = "sqlite://./dist/sqlite".replace(/\?.*$/, "").replace(/^sqlite:\/\//, "");
         
     | 
| 
      
 148 
     | 
    
         
            +
                dbFile = rt.SysContainer.join(dbFile, `${my_app()}.sqlite`);
         
     | 
| 
      
 149 
     | 
    
         
            +
                await rt.SysContainer.rm(dbFile, { recursive: true }).catch(() => {
         
     | 
| 
      
 150 
     | 
    
         
            +
                  /* */
         
     | 
| 
      
 151 
     | 
    
         
            +
                });
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                const db = fireproof(my_app(), {
         
     | 
| 
      
 154 
     | 
    
         
            +
                  store: {
         
     | 
| 
      
 155 
     | 
    
         
            +
                    stores: {
         
     | 
| 
      
 156 
     | 
    
         
            +
                      base: "sqlite://./dist/sqlite",
         
     | 
| 
      
 157 
     | 
    
         
            +
                    },
         
     | 
| 
      
 158 
     | 
    
         
            +
                  },
         
     | 
| 
      
 159 
     | 
    
         
            +
                });
         
     | 
| 
      
 160 
     | 
    
         
            +
                // console.log(`>>>>>>>>>>>>>>>file-path`)
         
     | 
| 
      
 161 
     | 
    
         
            +
                await db.put({ name: "my-app" });
         
     | 
| 
      
 162 
     | 
    
         
            +
                expect((await rt.SysContainer.stat(dbFile)).isFile()).toBeTruthy();
         
     | 
| 
      
 163 
     | 
    
         
            +
                expect(db.name).toBe(my_app());
         
     | 
| 
      
 164 
     | 
    
         
            +
                const carStore = await db.blockstore.loader?.carStore();
         
     | 
| 
      
 165 
     | 
    
         
            +
                expect(carStore?.url.toString()).toMatch(
         
     | 
| 
      
 166 
     | 
    
         
            +
                  new RegExp(`sqlite://./dist/sqlite\\?name=${my_app()}&store=data&version=${rt.SQLITE_VERSION}`),
         
     | 
| 
      
 167 
     | 
    
         
            +
                );
         
     | 
| 
      
 168 
     | 
    
         
            +
                const fileStore = await db.blockstore.loader?.fileStore();
         
     | 
| 
      
 169 
     | 
    
         
            +
                expect(fileStore?.url.toString()).toMatch(
         
     | 
| 
      
 170 
     | 
    
         
            +
                  new RegExp(`sqlite://./dist/sqlite\\?name=${my_app()}&store=data&version=${rt.SQLITE_VERSION}`),
         
     | 
| 
      
 171 
     | 
    
         
            +
                );
         
     | 
| 
      
 172 
     | 
    
         
            +
                const metaStore = await db.blockstore.loader?.metaStore();
         
     | 
| 
      
 173 
     | 
    
         
            +
                expect(metaStore?.url.toString()).toMatch(
         
     | 
| 
      
 174 
     | 
    
         
            +
                  new RegExp(`sqlite://./dist/sqlite\\?name=${my_app()}&store=meta&version=${rt.SQLITE_VERSION}`),
         
     | 
| 
      
 175 
     | 
    
         
            +
                );
         
     | 
| 
      
 176 
     | 
    
         
            +
                await db.close();
         
     | 
| 
      
 177 
     | 
    
         
            +
              });
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
              it("full config path", async () => {
         
     | 
| 
      
 180 
     | 
    
         
            +
                const db = fireproof(my_app(), {
         
     | 
| 
      
 181 
     | 
    
         
            +
                  store: {
         
     | 
| 
      
 182 
     | 
    
         
            +
                    stores: {
         
     | 
| 
      
 183 
     | 
    
         
            +
                      base: "sqlite://./dist/sqlite",
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                      meta: "sqlite://./dist/sqlite/meta",
         
     | 
| 
      
 186 
     | 
    
         
            +
                      data: "sqlite://./dist/sqlite/data",
         
     | 
| 
      
 187 
     | 
    
         
            +
                      index: "sqlite://./dist/sqlite/index",
         
     | 
| 
      
 188 
     | 
    
         
            +
                      remoteWAL: "sqlite://./dist/sqlite/wal",
         
     | 
| 
      
 189 
     | 
    
         
            +
                    },
         
     | 
| 
      
 190 
     | 
    
         
            +
                  },
         
     | 
| 
      
 191 
     | 
    
         
            +
                });
         
     | 
| 
      
 192 
     | 
    
         
            +
                // console.log(`>>>>>>>>>>>>>>>file-path`)
         
     | 
| 
      
 193 
     | 
    
         
            +
                await db.put({ name: my_app() });
         
     | 
| 
      
 194 
     | 
    
         
            +
                expect(db.name).toBe(my_app());
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
                const carStore = await db.blockstore.loader?.carStore();
         
     | 
| 
      
 197 
     | 
    
         
            +
                expect(carStore?.url.toString()).toMatch(
         
     | 
| 
      
 198 
     | 
    
         
            +
                  // sqlite://./dist/sqlite/data?store=data&version=v0.19-sqlite
         
     | 
| 
      
 199 
     | 
    
         
            +
                  new RegExp(`sqlite://./dist/sqlite/data\\?name=${my_app()}&store=data&version=${rt.SQLITE_VERSION}`),
         
     | 
| 
      
 200 
     | 
    
         
            +
                );
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                const fileStore = await db.blockstore.loader?.fileStore();
         
     | 
| 
      
 203 
     | 
    
         
            +
                expect(fileStore?.url.toString()).toMatch(
         
     | 
| 
      
 204 
     | 
    
         
            +
                  new RegExp(`sqlite://./dist/sqlite/data\\?name=${my_app()}&store=data&version=${rt.SQLITE_VERSION}`),
         
     | 
| 
      
 205 
     | 
    
         
            +
                );
         
     | 
| 
      
 206 
     | 
    
         
            +
                const metaStore = await db.blockstore.loader?.metaStore();
         
     | 
| 
      
 207 
     | 
    
         
            +
                expect(metaStore?.url.toString()).toMatch(
         
     | 
| 
      
 208 
     | 
    
         
            +
                  new RegExp(`sqlite://./dist/sqlite/meta\\?name=${my_app()}&store=meta&version=${rt.SQLITE_VERSION}`),
         
     | 
| 
      
 209 
     | 
    
         
            +
                );
         
     | 
| 
      
 210 
     | 
    
         
            +
                await db.close();
         
     | 
| 
      
 211 
     | 
    
         
            +
              });
         
     | 
| 
      
 212 
     | 
    
         
            +
            });
         
     |