@fireproof/core 0.19.8-dev-getcon → 0.19.9-dev-frag

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/README.md +7 -0
  2. package/chunk-7EWIAXTM.js +7 -0
  3. package/chunk-7EWIAXTM.js.map +1 -0
  4. package/chunk-JO5AVWG7.js +67 -0
  5. package/chunk-JO5AVWG7.js.map +1 -0
  6. package/chunk-PB4BKL4O.js +7 -0
  7. package/chunk-PB4BKL4O.js.map +1 -0
  8. package/chunk-YS4GL6OK.js +266 -0
  9. package/chunk-YS4GL6OK.js.map +1 -0
  10. package/{store-indexdb-WLRSICCB.js → gateway-IZRHJWPE.js} +48 -80
  11. package/gateway-IZRHJWPE.js.map +1 -0
  12. package/gateway-YSNUK2L3.js +145 -0
  13. package/gateway-YSNUK2L3.js.map +1 -0
  14. package/index.cjs +2132 -1783
  15. package/index.cjs.map +1 -1
  16. package/index.d.cts +613 -513
  17. package/index.d.ts +613 -513
  18. package/index.global.js +19367 -20108
  19. package/index.global.js.map +1 -1
  20. package/index.js +1512 -1022
  21. package/index.js.map +1 -1
  22. package/key-bag-file-NMEBFSPM.js +54 -0
  23. package/key-bag-file-NMEBFSPM.js.map +1 -0
  24. package/key-bag-indexdb-X5V6GNBZ.js +50 -0
  25. package/key-bag-indexdb-X5V6GNBZ.js.map +1 -0
  26. package/mem-filesystem-B6C6QOIP.js +41 -0
  27. package/mem-filesystem-B6C6QOIP.js.map +1 -0
  28. package/metafile-cjs.json +1 -1
  29. package/metafile-esm.json +1 -1
  30. package/metafile-iife.json +1 -1
  31. package/node-filesystem-5JLBSHKQ.js +41 -0
  32. package/node-filesystem-5JLBSHKQ.js.map +1 -0
  33. package/package.json +8 -7
  34. package/tests/blockstore/fragment-gateway.test.ts +107 -0
  35. package/tests/blockstore/keyed-crypto.test.ts +302 -0
  36. package/tests/blockstore/loader.test.ts +24 -19
  37. package/tests/blockstore/store.test.ts +34 -28
  38. package/tests/blockstore/transaction.test.ts +19 -15
  39. package/tests/fireproof/config.test.ts +94 -78
  40. package/tests/fireproof/crdt.test.ts +34 -28
  41. package/tests/fireproof/database.test.ts +22 -14
  42. package/tests/fireproof/fireproof.test.fixture.ts +133 -0
  43. package/tests/fireproof/fireproof.test.ts +331 -219
  44. package/tests/fireproof/hello.test.ts +6 -4
  45. package/tests/fireproof/indexer.test.ts +34 -27
  46. package/tests/fireproof/utils.test.ts +65 -0
  47. package/tests/helpers.ts +25 -57
  48. package/utils-IZPK4QS7.js +14 -0
  49. package/utils-IZPK4QS7.js.map +1 -0
  50. package/chunk-BNL4PVBF.js +0 -314
  51. package/chunk-BNL4PVBF.js.map +0 -1
  52. package/chunk-JW2QT6BF.js +0 -184
  53. package/chunk-JW2QT6BF.js.map +0 -1
  54. package/node-sys-container-MIEX6ELJ.js +0 -29
  55. package/node-sys-container-MIEX6ELJ.js.map +0 -1
  56. package/store-file-VJ6BI4II.js +0 -191
  57. package/store-file-VJ6BI4II.js.map +0 -1
  58. package/store-indexdb-WLRSICCB.js.map +0 -1
@@ -1,16 +1,16 @@
1
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";
2
+ import { bs, NotFoundError, SuperThis } from "@fireproof/core";
3
+ import { mockSuperThis } from "../helpers";
5
4
 
6
5
  const decoder = new TextDecoder("utf-8");
7
6
 
8
- function runtime() {
9
- return bs.toStoreRuntime({}, MockLogger().logger);
7
+ function runtime(sthis: SuperThis) {
8
+ return bs.toStoreRuntime({}, sthis);
10
9
  }
11
10
 
12
- function mockLoader(name: string): bs.Loadable {
11
+ function mockLoader(sthis: SuperThis, name: string): bs.Loadable {
13
12
  return {
13
+ sthis,
14
14
  name,
15
15
  ebOpts: {
16
16
  store: {},
@@ -20,18 +20,19 @@ function mockLoader(name: string): bs.Loadable {
20
20
 
21
21
  describe("DataStore", function () {
22
22
  let store: bs.DataStore;
23
- let raw: bs.TestStore;
23
+ let raw: bs.TestGateway;
24
24
 
25
+ const sthis = mockSuperThis();
25
26
  afterEach(async () => {
26
27
  await store.close();
27
28
  await store.destroy();
28
29
  });
29
30
 
30
31
  beforeEach(async () => {
31
- await rt.SysContainer.start();
32
- store = await runtime().makeDataStore(mockLoader("test"));
32
+ await sthis.start();
33
+ store = await runtime(sthis).makeDataStore(mockLoader(sthis, "test"));
33
34
  await store.start();
34
- raw = await bs.testStoreFactory(store.url);
35
+ raw = await bs.testStoreFactory(store.url(), sthis);
35
36
  });
36
37
 
37
38
  it("should have a name", function () {
@@ -44,26 +45,28 @@ describe("DataStore", function () {
44
45
  bytes: new Uint8Array([55, 56, 57]),
45
46
  };
46
47
  await store.save(car);
47
- const data = await raw.get(store.url, car.cid.toString());
48
+ const data = await raw.get(store.url(), car.cid.toString());
48
49
  expect(decoder.decode(data)).toEqual(decoder.decode(car.bytes));
49
50
  });
50
51
  });
51
52
 
52
53
  describe("DataStore with a saved car", function () {
53
54
  let store: bs.DataStore;
54
- let raw: bs.TestStore;
55
+ let raw: bs.TestGateway;
55
56
  let car: bs.AnyBlock;
56
57
 
58
+ const sthis = mockSuperThis();
59
+
57
60
  afterEach(async () => {
58
61
  await store.close();
59
62
  await store.destroy();
60
63
  });
61
64
 
62
65
  beforeEach(async function () {
63
- await rt.SysContainer.start();
64
- store = await runtime().makeDataStore(mockLoader("test2"));
66
+ await sthis.start();
67
+ store = await runtime(sthis).makeDataStore(mockLoader(sthis, "test2"));
65
68
  await store.start();
66
- raw = await bs.testStoreFactory(store.url);
69
+ raw = await bs.testStoreFactory(store.url(), sthis);
67
70
  car = {
68
71
  cid: "cid" as unknown as CID,
69
72
  bytes: new Uint8Array([55, 56, 57, 80]),
@@ -72,7 +75,7 @@ describe("DataStore with a saved car", function () {
72
75
  });
73
76
 
74
77
  it("should have a car", async function () {
75
- const data = await raw.get(store.url, car.cid.toString());
78
+ const data = await raw.get(store.url(), car.cid.toString());
76
79
  expect(decoder.decode(data)).toEqual(decoder.decode(car.bytes));
77
80
  });
78
81
 
@@ -93,7 +96,9 @@ describe("DataStore with a saved car", function () {
93
96
 
94
97
  describe("MetaStore", function () {
95
98
  let store: bs.MetaStore;
96
- let raw: bs.TestStore;
99
+ let raw: bs.TestGateway;
100
+
101
+ const sthis = mockSuperThis();
97
102
 
98
103
  afterEach(async () => {
99
104
  await store.close();
@@ -101,10 +106,10 @@ describe("MetaStore", function () {
101
106
  });
102
107
 
103
108
  beforeEach(async function () {
104
- await rt.SysContainer.start();
105
- store = await runtime().makeMetaStore(mockLoader("test"));
109
+ await sthis.start();
110
+ store = await runtime(sthis).makeMetaStore(mockLoader(sthis, "test"));
106
111
  await store.start();
107
- raw = await bs.testStoreFactory(store.url);
112
+ raw = await bs.testStoreFactory(store.url(), sthis);
108
113
  });
109
114
 
110
115
  it("should have a name", function () {
@@ -115,10 +120,10 @@ describe("MetaStore", function () {
115
120
  const cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
116
121
  const h: bs.DbMeta = {
117
122
  cars: [cid],
118
- key: undefined,
123
+ // key: undefined,
119
124
  };
120
125
  await store.save(h);
121
- const file = await raw.get(store.url, "main");
126
+ const file = await raw.get(store.url(), "main");
122
127
  const header = JSON.parse(decoder.decode(file));
123
128
  expect(header).toBeTruthy();
124
129
  expect(header.cars).toBeTruthy();
@@ -128,8 +133,9 @@ describe("MetaStore", function () {
128
133
 
129
134
  describe("MetaStore with a saved header", function () {
130
135
  let store: bs.MetaStore;
131
- let raw: bs.TestStore;
136
+ let raw: bs.TestGateway;
132
137
  let cid: CID;
138
+ const sthis = mockSuperThis();
133
139
 
134
140
  afterEach(async () => {
135
141
  await store.close();
@@ -137,16 +143,16 @@ describe("MetaStore with a saved header", function () {
137
143
  });
138
144
 
139
145
  beforeEach(async function () {
140
- await rt.SysContainer.start();
141
- store = await runtime().makeMetaStore(mockLoader("test-saved-header"));
146
+ await sthis.start();
147
+ store = await runtime(sthis).makeMetaStore(mockLoader(sthis, "test-saved-header"));
142
148
  await store.start();
143
- raw = await bs.testStoreFactory(store.url);
149
+ raw = await bs.testStoreFactory(store.url(), sthis);
144
150
  cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
145
- await store.save({ cars: [cid], key: undefined });
151
+ await store.save({ cars: [cid] /*, key: undefined */ });
146
152
  });
147
153
 
148
154
  it("should have a header", async function () {
149
- const data = decoder.decode(await raw.get(store.url, "main"));
155
+ const data = decoder.decode(await raw.get(store.url(), "main"));
150
156
  expect(data).toMatch(/car/);
151
157
  const header = JSON.parse(data);
152
158
  expect(header).toBeTruthy();
@@ -1,9 +1,10 @@
1
1
  import { CID } from "multiformats";
2
- // import { matches, equalsJSON } from "../helpers.js";
3
- import { bs } from "@fireproof/core";
2
+ import { bs, SuperThis } from "@fireproof/core";
3
+ import { mockSuperThis } from "../helpers";
4
4
 
5
5
  describe("Fresh TransactionBlockstore", function () {
6
6
  let blocks: bs.BaseBlockstore;
7
+ const sthis = mockSuperThis();
7
8
  beforeEach(function () {
8
9
  blocks = new bs.BaseBlockstore();
9
10
  });
@@ -14,7 +15,7 @@ describe("Fresh TransactionBlockstore", function () {
14
15
  expect(blocks.loader).toBeFalsy();
15
16
  });
16
17
  it("should not put", async function () {
17
- const value = new TextEncoder().encode("value");
18
+ const value = sthis.txt.encode("value");
18
19
  const e = await blocks.put("key" as unknown as bs.AnyLink, value).catch((e) => e);
19
20
  expect(e.message).toMatch(/transaction/g);
20
21
  });
@@ -32,8 +33,9 @@ describe("Fresh TransactionBlockstore", function () {
32
33
 
33
34
  describe("TransactionBlockstore with name", function () {
34
35
  let blocks: bs.EncryptedBlockstore;
36
+ const sthis = mockSuperThis();
35
37
  beforeEach(function () {
36
- blocks = new bs.EncryptedBlockstore({ name: "test" });
38
+ blocks = new bs.EncryptedBlockstore(sthis, { name: "test" });
37
39
  });
38
40
  it("should have a name", function () {
39
41
  expect(blocks.name).toEqual("test");
@@ -42,7 +44,7 @@ describe("TransactionBlockstore with name", function () {
42
44
  expect(blocks.loader).toBeTruthy();
43
45
  });
44
46
  it("should get from loader", async function () {
45
- const bytes = new TextEncoder().encode("bytes");
47
+ const bytes = sthis.txt.encode("bytes");
46
48
  expect(blocks.loader).toBeTruthy();
47
49
  blocks.loader.getBlock = async (cid) => {
48
50
  return { cid, bytes };
@@ -55,14 +57,15 @@ describe("TransactionBlockstore with name", function () {
55
57
  describe("A transaction", function () {
56
58
  let tblocks: bs.CarTransaction;
57
59
  let blocks: bs.EncryptedBlockstore;
60
+ const sthis = mockSuperThis();
58
61
  beforeEach(async function () {
59
- blocks = new bs.EncryptedBlockstore({ name: "test" });
62
+ blocks = new bs.EncryptedBlockstore(sthis, { name: "test" });
60
63
  tblocks = new bs.CarTransaction(blocks);
61
64
  blocks.transactions.add(tblocks);
62
65
  });
63
66
  it("should put and get", async function () {
64
67
  const cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
65
- const bytes = new TextEncoder().encode("bytes");
68
+ const bytes = sthis.txt.encode("bytes");
66
69
  await tblocks.put(cid, bytes);
67
70
  expect(blocks.transactions.has(tblocks)).toBeTruthy();
68
71
  const got = await tblocks.get(cid);
@@ -72,14 +75,15 @@ describe("A transaction", function () {
72
75
  });
73
76
  });
74
77
 
75
- function asUInt8Array(str: string) {
76
- return new TextEncoder().encode(str);
78
+ function asUInt8Array(str: string, sthis: SuperThis) {
79
+ return sthis.txt.encode(str);
77
80
  }
78
81
 
79
82
  describe("TransactionBlockstore with a completed transaction", function () {
80
83
  let blocks: bs.BaseBlockstore;
81
84
  let cid: CID;
82
85
  let cid2: CID;
86
+ const sthis = mockSuperThis();
83
87
 
84
88
  beforeEach(async function () {
85
89
  cid = CID.parse("bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4");
@@ -87,13 +91,13 @@ describe("TransactionBlockstore with a completed transaction", function () {
87
91
 
88
92
  blocks = new bs.BaseBlockstore();
89
93
  await blocks.transaction(async (tblocks) => {
90
- await tblocks.put(cid, asUInt8Array("value"));
91
- await tblocks.put(cid2, asUInt8Array("value2"));
94
+ await tblocks.put(cid, asUInt8Array("value", sthis));
95
+ await tblocks.put(cid, asUInt8Array("value", sthis));
92
96
  return { head: [] };
93
97
  });
94
98
  await blocks.transaction(async (tblocks) => {
95
- await tblocks.put(cid, asUInt8Array("value"));
96
- await tblocks.put(cid2, asUInt8Array("value2"));
99
+ await tblocks.put(cid, asUInt8Array("value", sthis));
100
+ await tblocks.put(cid2, asUInt8Array("value2", sthis));
97
101
  return { head: [] };
98
102
  });
99
103
  });
@@ -104,10 +108,10 @@ describe("TransactionBlockstore with a completed transaction", function () {
104
108
  it("should get", async function () {
105
109
  const value = (await blocks.get(cid)) as bs.AnyBlock;
106
110
  expect(value.cid).toEqual(cid);
107
- expect(value.bytes.toString()).toEqual(asUInt8Array("value").toString());
111
+ expect(value.bytes.toString()).toEqual(asUInt8Array("value", sthis).toString());
108
112
 
109
113
  const value2 = (await blocks.get(cid2)) as bs.AnyBlock;
110
- expect(value2.bytes.toString()).toEqual(asUInt8Array("value2").toString());
114
+ expect(value2.bytes.toString()).toEqual(asUInt8Array("value2", sthis).toString());
111
115
  });
112
116
  it("should yield entries", async function () {
113
117
  const blz = [];
@@ -1,10 +1,12 @@
1
1
  import { describe, it, expect, beforeAll } from "vitest";
2
- import { fireproof, rt } from "@fireproof/core";
2
+ import { dataDir, fireproof, rt } from "@fireproof/core";
3
+ import { runtimeFn, URI } from "@adviser/cement";
4
+ import { mockSuperThis } from "../helpers";
3
5
 
4
6
  describe("runtime", () => {
5
7
  it("runtime", () => {
6
8
  const isNode = !!(typeof process === "object" && process.versions?.node);
7
- expect(rt.SysContainer.runtime()).toEqual({
9
+ expect(runtimeFn()).toEqual({
8
10
  isBrowser: !isNode,
9
11
  isDeno: false,
10
12
  isNodeIsh: isNode,
@@ -18,46 +20,58 @@ describe("fireproof/config", () => {
18
20
  function my_app() {
19
21
  return _my_app;
20
22
  }
23
+ function params(store: string) {
24
+ return Object.entries({
25
+ store,
26
+ name: my_app(),
27
+ storekey: `@${my_app()}:${store}@`,
28
+ version: rt.FILESTORE_VERSION,
29
+ });
30
+ }
31
+ const sthis = mockSuperThis();
21
32
  beforeAll(async () => {
22
- await rt.SysContainer.start();
23
- if (rt.SysContainer.runtime().isNodeIsh) {
24
- const fpStorageUrl = rt.SysContainer.env.get("FP_STORAGE_URL");
33
+ await sthis.start();
34
+ if (runtimeFn().isNodeIsh) {
35
+ const fpStorageUrl = sthis.env.get("FP_STORAGE_URL");
25
36
  if (fpStorageUrl) {
26
- let url: URL;
27
- try {
28
- url = new URL(fpStorageUrl);
29
- } catch (e) {
30
- url = new URL(`file://${fpStorageUrl}`);
31
- }
32
- _my_app = `my-app-${url.protocol.replace(/:$/, "")}`;
37
+ const url = URI.from(fpStorageUrl);
38
+ _my_app = `my-app-${url.protocol.replace(/:$/, "")}:${url.getParam("fs") || "fs"}`;
33
39
  }
34
40
  }
35
41
  });
36
42
 
37
- if (!rt.SysContainer.runtime().isNodeIsh) {
43
+ if (!runtimeFn().isNodeIsh) {
38
44
  it("default", async () => {
39
45
  const db = fireproof(my_app());
40
46
  await db.put({ name: "my-app" });
41
47
  expect(db.name).toBe(my_app());
42
- const carStore = await db.blockstore.loader?.carStore();
43
- expect(carStore?.url.toString()).toMatch(new RegExp(`indexdb://fp\\?name=my-app&store=data&version=${rt.INDEXDB_VERSION}`));
48
+
44
49
  const fileStore = await db.blockstore.loader?.fileStore();
45
- expect(fileStore?.url.toString()).toMatch(new RegExp(`indexdb://fp\\?name=my-app&store=data&version=${rt.INDEXDB_VERSION}`));
50
+ expect(fileStore?.url().toString()).toMatch(
51
+ new RegExp(`indexdb://fp\\?name=my-app&store=data&storekey=%40my-app%3Adata%40&version=${rt.INDEXDB_VERSION}`),
52
+ );
46
53
  const metaStore = await db.blockstore.loader?.metaStore();
47
- expect(metaStore?.url.toString()).toMatch(new RegExp(`indexdb://fp\\?name=my-app&store=meta&version=${rt.INDEXDB_VERSION}`));
54
+ expect(metaStore?.url().toString()).toMatch(
55
+ new RegExp(`indexdb://fp\\?name=my-app&store=meta&storekey=%40my-app%3Ameta%40&version=${rt.INDEXDB_VERSION}`),
56
+ );
57
+
58
+ const carStore = await db.blockstore.loader?.carStore();
59
+ expect(carStore?.url().toString()).toMatch(
60
+ new RegExp(`indexdb://fp\\?name=my-app&store=data&storekey=%40my-app%3Adata%40&version=${rt.INDEXDB_VERSION}`),
61
+ );
62
+
48
63
  await db.close();
49
64
  });
50
65
  return;
51
66
  }
52
67
  it("node default", async () => {
53
- const old = rt.SysContainer.env.get("FP_STORAGE_URL");
54
- rt.SysContainer.env.del("FP_STORAGE_URL");
55
- let baseDir = rt
56
- .dataDir(my_app())
57
- .replace(/\?.*$/, "")
58
- .replace(/^file:\/\//, "");
59
- baseDir = rt.SysContainer.join(baseDir, rt.FILESTORE_VERSION, my_app());
60
- await rt.SysContainer.rm(baseDir, { recursive: true }).catch(() => {
68
+ const old = sthis.env.get("FP_STORAGE_URL");
69
+ sthis.env.delete("FP_STORAGE_URL");
70
+ let baseDir = dataDir(sthis, my_app()).pathname;
71
+ baseDir = sthis.pathOps.join(baseDir, rt.FILESTORE_VERSION, my_app());
72
+
73
+ const sysfs = await rt.getFileSystem(URI.from(baseDir));
74
+ await sysfs.rm(baseDir, { recursive: true }).catch(() => {
61
75
  /* */
62
76
  });
63
77
 
@@ -68,34 +82,39 @@ describe("fireproof/config", () => {
68
82
  expect(db.name).toBe(my_app());
69
83
  const carStore = await db.blockstore.loader?.carStore();
70
84
 
71
- expect(carStore?.url.toString()).toMatch(
72
- new RegExp(`file:.*\\/\\.fireproof\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
73
- );
74
- expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "data"))).isDirectory()).toBeTruthy();
85
+ for (const [param, value] of Object.entries({
86
+ store: "data",
87
+ name: my_app(),
88
+ storekey: `@${my_app()}:data@`,
89
+ version: rt.FILESTORE_VERSION,
90
+ })) {
91
+ expect(carStore?.url().getParam(param)).toBe(value);
92
+ }
93
+ expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
75
94
 
76
95
  const fileStore = await db.blockstore.loader?.fileStore();
77
- expect(fileStore?.url.toString()).toMatch(
78
- new RegExp(`file:.*\\/\\.fireproof\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
79
- );
96
+ for (const [param, value] of params("data")) {
97
+ expect(fileStore?.url().getParam(param)).toBe(value);
98
+ }
80
99
  const metaStore = await db.blockstore.loader?.metaStore();
81
- expect(metaStore?.url.toString()).toMatch(
82
- new RegExp(`file:.*\\/\\.fireproof\\?name=${my_app()}&store=meta&version=${rt.FILESTORE_VERSION}`),
83
- );
84
- expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
85
- rt.SysContainer.env.set("FP_STORAGE_URL", old);
100
+ for (const [param, value] of params("meta")) {
101
+ expect(metaStore?.url().getParam(param)).toBe(value);
102
+ }
103
+ expect((await sysfs.stat(sthis.pathOps.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
104
+ sthis.env.set("FP_STORAGE_URL", old);
86
105
  await db.close();
87
106
  });
88
107
 
89
108
  it("set by env", async () => {
90
- const old = rt.SysContainer.env.get("FP_STORAGE_URL");
91
- rt.SysContainer.env.set("FP_STORAGE_URL", "./dist/env");
92
-
93
- let baseDir = rt
94
- .dataDir(my_app())
95
- .replace(/\?.*$/, "")
96
- .replace(/^file:\/\//, "");
97
- baseDir = rt.SysContainer.join(baseDir, rt.FILESTORE_VERSION, my_app());
98
- await rt.SysContainer.rm(baseDir, { recursive: true }).catch(() => {
109
+ const old = sthis.env.get("FP_STORAGE_URL");
110
+ const testUrl = URI.merge(`./dist/env`, old);
111
+ sthis.env.set("FP_STORAGE_URL", testUrl.toString());
112
+
113
+ let baseDir = dataDir(sthis, my_app()).pathname;
114
+ baseDir = sthis.pathOps.join(baseDir, rt.FILESTORE_VERSION, my_app());
115
+
116
+ const sysfs = await rt.getFileSystem(testUrl);
117
+ await sysfs.rm(baseDir, { recursive: true }).catch(() => {
99
118
  /* */
100
119
  });
101
120
 
@@ -103,54 +122,51 @@ describe("fireproof/config", () => {
103
122
  await db.put({ name: "my-app" });
104
123
  expect(db.name).toBe(my_app());
105
124
  const carStore = await db.blockstore.loader?.carStore();
106
- expect(carStore?.url.toString()).toMatch(
107
- new RegExp(`file://\\./dist/env\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
108
- );
109
- expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "data"))).isDirectory()).toBeTruthy();
125
+ for (const [param, value] of params("data")) {
126
+ expect(carStore?.url().getParam(param)).toBe(value);
127
+ }
128
+ expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
110
129
  const fileStore = await db.blockstore.loader?.fileStore();
111
- expect(fileStore?.url.toString()).toMatch(
112
- new RegExp(`file://\\./dist/env\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
113
- );
130
+ for (const [param, value] of params("data")) {
131
+ expect(fileStore?.url().getParam(param)).toBe(value);
132
+ }
114
133
  const metaStore = await db.blockstore.loader?.metaStore();
115
- expect(metaStore?.url.toString()).toMatch(
116
- new RegExp(`file://\\./dist/env\\?name=${my_app()}&store=meta&version=${rt.FILESTORE_VERSION}`),
117
- );
118
- expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
134
+ for (const [param, value] of params("meta")) {
135
+ expect(metaStore?.url().getParam(param)).toBe(value);
136
+ }
137
+ expect((await sysfs.stat(sthis.pathOps.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
119
138
  await db.close();
120
- rt.SysContainer.env.set("FP_STORAGE_URL", old);
139
+ sthis.env.set("FP_STORAGE_URL", old);
121
140
  });
122
141
 
123
142
  it("file path", async () => {
124
143
  let baseDir = "./dist/data".replace(/\?.*$/, "").replace(/^file:\/\//, "");
125
- baseDir = rt.SysContainer.join(baseDir, rt.FILESTORE_VERSION, my_app());
126
- await rt.SysContainer.rm(baseDir, { recursive: true }).catch(() => {
144
+ baseDir = sthis.pathOps.join(baseDir, rt.FILESTORE_VERSION, my_app());
145
+
146
+ const base = "./dist/data";
147
+ const sysfs = await rt.getFileSystem(URI.from(base));
148
+ await sysfs.rm(baseDir, { recursive: true }).catch(() => {
127
149
  /* */
128
150
  });
129
151
 
130
- const db = fireproof(my_app(), {
131
- store: {
132
- stores: {
133
- base: "./dist/data",
134
- },
135
- },
136
- });
152
+ const db = fireproof(my_app(), { store: { stores: { base } } });
137
153
  // console.log(`>>>>>>>>>>>>>>>file-path`)
138
154
  await db.put({ name: "my-app" });
139
155
  expect(db.name).toBe(my_app());
140
156
  const carStore = await db.blockstore.loader?.carStore();
141
- expect(carStore?.url.toString()).toMatch(
142
- new RegExp(`file://.\\/dist\\/data\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
143
- );
157
+ for (const [param, value] of params("data")) {
158
+ expect(carStore?.url().getParam(param)).toBe(value);
159
+ }
144
160
  const fileStore = await db.blockstore.loader?.fileStore();
145
- expect(fileStore?.url.toString()).toMatch(
146
- new RegExp(`file://.\\/dist\\/data\\?name=${my_app()}&store=data&version=${rt.FILESTORE_VERSION}`),
147
- );
148
- expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "data"))).isDirectory()).toBeTruthy();
161
+ for (const [param, value] of params("data")) {
162
+ expect(fileStore?.url().getParam(param)).toBe(value);
163
+ }
164
+ expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
149
165
  const metaStore = await db.blockstore.loader?.metaStore();
150
- expect(metaStore?.url.toString()).toMatch(
151
- new RegExp(`file://.\\/dist\\/data\\?name=${my_app()}&store=meta&version=${rt.FILESTORE_VERSION}`),
152
- );
153
- expect((await rt.SysContainer.stat(rt.SysContainer.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
166
+ for (const [param, value] of params("meta")) {
167
+ expect(metaStore?.url().getParam(param)).toBe(value);
168
+ }
169
+ expect((await sysfs.stat(sthis.pathOps.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
154
170
  await db.close();
155
171
  });
156
172
  });