@fireproof/core 0.19.8-dev-global → 0.19.11-dev-dryrun

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/README.md +34 -0
  2. package/chunk-7EWIAXTM.js +7 -0
  3. package/chunk-7EWIAXTM.js.map +1 -0
  4. package/chunk-MAK4D54P.js +280 -0
  5. package/chunk-MAK4D54P.js.map +1 -0
  6. package/chunk-PB4BKL4O.js +7 -0
  7. package/chunk-PB4BKL4O.js.map +1 -0
  8. package/chunk-XINRLWR3.js +75 -0
  9. package/chunk-XINRLWR3.js.map +1 -0
  10. package/deno.json +20 -0
  11. package/{store-indexdb-WLRSICCB.js → gateway-7OM6OSYK.js} +49 -82
  12. package/gateway-7OM6OSYK.js.map +1 -0
  13. package/gateway-VWWKLHUI.js +144 -0
  14. package/gateway-VWWKLHUI.js.map +1 -0
  15. package/index.cjs +2351 -1825
  16. package/index.cjs.map +1 -1
  17. package/index.d.cts +659 -535
  18. package/index.d.ts +659 -535
  19. package/index.global.js +26315 -20709
  20. package/index.global.js.map +1 -1
  21. package/index.js +1700 -1058
  22. package/index.js.map +1 -1
  23. package/key-bag-file-DFMW6ZM6.js +54 -0
  24. package/key-bag-file-DFMW6ZM6.js.map +1 -0
  25. package/key-bag-indexdb-R2RWGSQ4.js +50 -0
  26. package/key-bag-indexdb-R2RWGSQ4.js.map +1 -0
  27. package/mem-filesystem-BZQZLUR6.js +41 -0
  28. package/mem-filesystem-BZQZLUR6.js.map +1 -0
  29. package/metafile-cjs.json +1 -1
  30. package/metafile-esm.json +1 -1
  31. package/metafile-iife.json +1 -1
  32. package/node-filesystem-7YZR3POJ.js +45 -0
  33. package/node-filesystem-7YZR3POJ.js.map +1 -0
  34. package/package.json +12 -8
  35. package/tests/blockstore/fragment-gateway.test.ts +107 -0
  36. package/tests/blockstore/keyed-crypto.test.ts +332 -0
  37. package/tests/blockstore/loader.test.ts +24 -19
  38. package/tests/blockstore/store.test.ts +51 -40
  39. package/tests/blockstore/transaction.test.ts +19 -15
  40. package/tests/fireproof/all-gateway.test.ts +395 -0
  41. package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.car +0 -0
  42. package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.js +316 -0
  43. package/tests/fireproof/config.test.ts +94 -78
  44. package/tests/fireproof/convert_uint8.py +27 -0
  45. package/tests/fireproof/crdt.test.ts +34 -28
  46. package/tests/fireproof/database.test.ts +22 -14
  47. package/tests/fireproof/fireproof.test.fixture.ts +133 -0
  48. package/tests/fireproof/fireproof.test.ts +331 -219
  49. package/tests/fireproof/hello.test.ts +34 -18
  50. package/tests/fireproof/indexer.test.ts +34 -27
  51. package/tests/fireproof/utils.test.ts +65 -0
  52. package/tests/helpers.ts +28 -57
  53. package/utils-AISQB3PB.js +14 -0
  54. package/utils-AISQB3PB.js.map +1 -0
  55. package/chunk-BNL4PVBF.js +0 -314
  56. package/chunk-BNL4PVBF.js.map +0 -1
  57. package/chunk-JW2QT6BF.js +0 -184
  58. package/chunk-JW2QT6BF.js.map +0 -1
  59. package/node-sys-container-MIEX6ELJ.js +0 -29
  60. package/node-sys-container-MIEX6ELJ.js.map +0 -1
  61. package/store-file-VJ6BI4II.js +0 -191
  62. package/store-file-VJ6BI4II.js.map +0 -1
  63. package/store-indexdb-WLRSICCB.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { rt, fireproof as database, Database, DocResponse, DocWithId, index, Index, IndexRows } from "@fireproof/core";
1
+ import { fireproof as database, Database, DocResponse, DocWithId } from "@fireproof/core";
2
2
 
3
3
  describe("Hello World Test", function () {
4
4
  it("should pass the hello world test", function () {
@@ -7,37 +7,26 @@ describe("Hello World Test", function () {
7
7
  });
8
8
  });
9
9
 
10
- describe("public API", function () {
10
+ describe("hello public API", function () {
11
11
  interface TestDoc {
12
12
  foo: string;
13
13
  }
14
14
  let db: Database;
15
- let idx: Index<string, TestDoc>;
16
15
  let ok: DocResponse;
17
16
  let doc: DocWithId<TestDoc>;
18
- let query: IndexRows<string, TestDoc>;
19
17
  afterEach(async function () {
20
18
  await db.close();
21
19
  await db.destroy();
22
- await idx.close();
23
- await idx.destroy();
24
20
  });
25
21
  beforeEach(async function () {
26
- await rt.SysContainer.start();
27
22
  db = database("test-public-api");
28
- idx = index<string, TestDoc>(db, "test-index", (doc) => doc.foo);
29
23
  ok = await db.put({ _id: "test", foo: "bar" });
30
24
  doc = await db.get("test");
31
- query = await idx.query();
32
25
  });
33
26
  it("should have a database", function () {
34
27
  expect(db).toBeTruthy();
35
28
  expect(db instanceof Database).toBeTruthy();
36
29
  });
37
- it("should have an index", function () {
38
- expect(idx).toBeTruthy();
39
- expect(idx instanceof Index).toBeTruthy();
40
- });
41
30
  it("should put", function () {
42
31
  expect(ok).toBeTruthy();
43
32
  expect(ok.id).toBe("test");
@@ -45,10 +34,37 @@ describe("public API", function () {
45
34
  it("should get", function () {
46
35
  expect(doc.foo).toBe("bar");
47
36
  });
48
- it("should query", function () {
49
- expect(query).toBeTruthy();
50
- expect(query.rows).toBeTruthy();
51
- expect(query.rows.length).toBe(1);
52
- expect(query.rows[0].key).toBe("bar");
37
+ it("should get when you open it again", async function () {
38
+ await db.close();
39
+ await db.destroy();
40
+ const db2 = database("test-public-api");
41
+ doc = await db2.get("test");
42
+ expect(doc.foo).toBe("bar");
43
+ });
44
+ });
45
+
46
+ describe("Simplified Reopening a database", function () {
47
+ let db: Database;
48
+ afterEach(async function () {
49
+ await db.close();
50
+ await db.destroy();
51
+ });
52
+ beforeEach(async function () {
53
+ db = new Database("test-reopen-simple");
54
+ const ok = await db.put({ _id: "test", foo: "bar" });
55
+ expect(ok).toBeTruthy();
56
+ expect(ok.id).toBe("test");
57
+ });
58
+
59
+ it("should persist data", async function () {
60
+ const doc = await db.get<{ foo: string }>("test");
61
+ expect(doc.foo).toBe("bar");
62
+ });
63
+
64
+ it("should have the same data on reopen", async function () {
65
+ const db2 = new Database("test-reopen-simple");
66
+ const doc = await db2.get<{ foo: string }>("test");
67
+ expect(doc.foo).toBe("bar");
68
+ await db2.close();
53
69
  });
54
70
  });
@@ -1,6 +1,5 @@
1
- import { itSkip } from "../helpers.js";
2
-
3
- import { rt, Index, index, Database, CRDT, IndexRows } from "@fireproof/core";
1
+ import { Index, index, Database, CRDT, IndexRows } from "@fireproof/core";
2
+ import { mockSuperThis } from "../helpers";
4
3
 
5
4
  interface TestType {
6
5
  readonly title: string;
@@ -11,6 +10,7 @@ describe("basic Index", () => {
11
10
  let db: Database<TestType>;
12
11
  let indexer: Index<string, TestType>;
13
12
  let didMap: boolean;
13
+ const sthis = mockSuperThis();
14
14
  afterEach(async function () {
15
15
  await db.close();
16
16
  await db.destroy();
@@ -18,12 +18,12 @@ describe("basic Index", () => {
18
18
  await indexer.destroy();
19
19
  });
20
20
  beforeEach(async function () {
21
- await rt.SysContainer.start();
21
+ await sthis.start();
22
22
  db = new Database("test-indexer");
23
23
  await db.put({ title: "amazing" });
24
24
  await db.put({ title: "creative" });
25
25
  await db.put({ title: "bazillas" });
26
- indexer = new Index<string, TestType>(db._crdt, "hello", (doc) => {
26
+ indexer = new Index<string, TestType>(sthis, db._crdt, "hello", (doc) => {
27
27
  didMap = true;
28
28
  return doc.title;
29
29
  });
@@ -97,6 +97,7 @@ describe("basic Index", () => {
97
97
  describe("Index query with compound key", function () {
98
98
  let db: Database<TestType>;
99
99
  let indexer: Index<[string, number], TestType>;
100
+ const sthis = mockSuperThis();
100
101
  afterEach(async function () {
101
102
  await db.close();
102
103
  await db.destroy();
@@ -104,13 +105,13 @@ describe("Index query with compound key", function () {
104
105
  await indexer.destroy();
105
106
  });
106
107
  beforeEach(async function () {
107
- await rt.SysContainer.start();
108
+ await sthis.start();
108
109
  db = new Database("test-indexer");
109
110
  await db.put({ title: "amazing", score: 1 });
110
111
  await db.put({ title: "creative", score: 2 });
111
112
  await db.put({ title: "creative", score: 20 });
112
113
  await db.put({ title: "bazillas", score: 3 });
113
- indexer = new Index<[string, number], TestType>(db._crdt, "hello", (doc) => {
114
+ indexer = new Index<[string, number], TestType>(sthis, db._crdt, "hello", (doc) => {
114
115
  return [doc.title, doc.score];
115
116
  });
116
117
  await indexer.ready();
@@ -126,6 +127,7 @@ describe("Index query with compound key", function () {
126
127
  describe("basic Index with map fun", function () {
127
128
  let db: Database<TestType>;
128
129
  let indexer: Index<string, TestType>;
130
+ const sthis = mockSuperThis();
129
131
  afterEach(async function () {
130
132
  await db.close();
131
133
  await db.destroy();
@@ -133,12 +135,12 @@ describe("basic Index with map fun", function () {
133
135
  await indexer.destroy();
134
136
  });
135
137
  beforeEach(async function () {
136
- await rt.SysContainer.start();
138
+ await sthis.start();
137
139
  db = new Database("test-indexer");
138
140
  await db.put({ title: "amazing" });
139
141
  await db.put({ title: "creative" });
140
142
  await db.put({ title: "bazillas" });
141
- indexer = new Index<string, TestType>(db._crdt, "hello", (doc, map) => {
143
+ indexer = new Index<string, TestType>(sthis, db._crdt, "hello", (doc, map) => {
142
144
  map(doc.title);
143
145
  });
144
146
  await indexer.ready();
@@ -155,17 +157,18 @@ describe("basic Index with map fun", function () {
155
157
  describe("basic Index with map fun with value", function () {
156
158
  let db: Database<TestType>;
157
159
  let indexer: Index<string, TestType, number>;
160
+ const sthis = mockSuperThis();
158
161
  afterEach(async function () {
159
162
  await db.close();
160
163
  await db.destroy();
161
164
  });
162
165
  beforeEach(async function () {
163
- await rt.SysContainer.start();
166
+ await sthis.start();
164
167
  db = new Database("test-indexer");
165
168
  await db.put({ title: "amazing" });
166
169
  await db.put({ title: "creative" });
167
170
  await db.put({ title: "bazillas" });
168
- indexer = new Index<string, TestType, number>(db._crdt, "hello", (doc, map) => {
171
+ indexer = new Index<string, TestType, number>(sthis, db._crdt, "hello", (doc, map) => {
169
172
  map(doc.title, doc.title.length);
170
173
  });
171
174
  });
@@ -192,6 +195,7 @@ describe("basic Index with map fun with value", function () {
192
195
  describe("Index query with map and compound key", function () {
193
196
  let db: Database<TestType>;
194
197
  let indexer: Index<[string, number], TestType>;
198
+ const sthis = mockSuperThis();
195
199
  afterEach(async function () {
196
200
  await db.close();
197
201
  await db.destroy();
@@ -199,13 +203,13 @@ describe("Index query with map and compound key", function () {
199
203
  await indexer.destroy();
200
204
  });
201
205
  beforeEach(async function () {
202
- await rt.SysContainer.start();
206
+ await sthis.start();
203
207
  db = new Database("test-indexer");
204
208
  await db.put({ title: "amazing", score: 1 });
205
209
  await db.put({ title: "creative", score: 2 });
206
210
  await db.put({ title: "creative", score: 20 });
207
211
  await db.put({ title: "bazillas", score: 3 });
208
- indexer = new Index<[string, number], TestType>(db._crdt, "hello", (doc, emit) => {
212
+ indexer = new Index<[string, number], TestType>(sthis, db._crdt, "hello", (doc, emit) => {
209
213
  emit([doc.title, doc.score]);
210
214
  });
211
215
  await indexer.ready();
@@ -221,6 +225,7 @@ describe("Index query with map and compound key", function () {
221
225
  describe("basic Index with string fun", function () {
222
226
  let db: Database<TestType>;
223
227
  let indexer: Index<string, TestType>;
228
+ const sthis = mockSuperThis();
224
229
  afterEach(async function () {
225
230
  await db.close();
226
231
  await db.destroy();
@@ -228,12 +233,12 @@ describe("basic Index with string fun", function () {
228
233
  await indexer.destroy();
229
234
  });
230
235
  beforeEach(async function () {
231
- await rt.SysContainer.start();
236
+ await sthis.start();
232
237
  db = new Database("test-indexer");
233
238
  await db.put({ title: "amazing" });
234
239
  await db.put({ title: "creative" });
235
240
  await db.put({ title: "bazillas" });
236
- indexer = new Index(db._crdt, "title");
241
+ indexer = new Index(sthis, db._crdt, "title");
237
242
  await indexer.ready();
238
243
  });
239
244
  it("should get results", async function () {
@@ -259,6 +264,7 @@ describe("basic Index upon cold start", function () {
259
264
  let didMap: number;
260
265
  let mapFn: (doc: TestType) => string;
261
266
  let result: IndexRows<string, TestType>;
267
+ const sthis = mockSuperThis();
262
268
  // result, mapFn;
263
269
  afterEach(async function () {
264
270
  await crdt.close();
@@ -267,9 +273,9 @@ describe("basic Index upon cold start", function () {
267
273
  await indexer.destroy();
268
274
  });
269
275
  beforeEach(async function () {
270
- await rt.SysContainer.start();
276
+ await sthis.start();
271
277
  // db = database()
272
- crdt = new CRDT<TestType>("test-indexer-cold", { persistIndexes: true });
278
+ crdt = new CRDT<TestType>(sthis, "test-indexer-cold", { persistIndexes: true });
273
279
  await crdt.bulk([
274
280
  { id: "abc1", value: { title: "amazing" } },
275
281
  { id: "abc2", value: { title: "creative" } },
@@ -280,7 +286,7 @@ describe("basic Index upon cold start", function () {
280
286
  didMap++;
281
287
  return doc.title;
282
288
  };
283
- indexer = await index<string, TestType>({ _crdt: crdt }, "hello", mapFn);
289
+ indexer = await index<string, TestType>(sthis, { _crdt: crdt }, "hello", mapFn);
284
290
  await indexer.ready();
285
291
  // new Index(db._crdt.indexBlockstore, db._crdt, 'hello', mapFn)
286
292
  result = await indexer.query();
@@ -296,12 +302,12 @@ describe("basic Index upon cold start", function () {
296
302
  expect(result.rows.length).toEqual(3);
297
303
  });
298
304
  it("should work on cold load", async function () {
299
- const crdt2 = new CRDT<TestType>("test-indexer-cold", { persistIndexes: true });
305
+ const crdt2 = new CRDT<TestType>(sthis, "test-indexer-cold", { persistIndexes: true });
300
306
  await crdt2.ready();
301
307
  const { result, head } = await crdt2.changes();
302
308
  expect(result).toBeTruthy();
303
309
  await crdt2.ready();
304
- const indexer2 = await index<string, TestType>({ _crdt: crdt2 }, "hello", mapFn);
310
+ const indexer2 = await index<string, TestType>(sthis, { _crdt: crdt2 }, "hello", mapFn);
305
311
  await indexer2.ready();
306
312
  const result2 = await indexer2.query();
307
313
  expect(indexer2.indexHead).toEqual(head);
@@ -309,10 +315,10 @@ describe("basic Index upon cold start", function () {
309
315
  expect(result2.rows.length).toEqual(3);
310
316
  expect(indexer2.indexHead).toEqual(head);
311
317
  });
312
- itSkip("should not rerun the map function on seen changes", async function () {
318
+ it.skip("should not rerun the map function on seen changes", async function () {
313
319
  didMap = 0;
314
- const crdt2 = new CRDT<TestType>("test-indexer-cold", { persistIndexes: true });
315
- const indexer2 = await index({ _crdt: crdt2 }, "hello", mapFn);
320
+ const crdt2 = new CRDT<TestType>(sthis, "test-indexer-cold", { persistIndexes: true });
321
+ const indexer2 = await index(sthis, { _crdt: crdt2 }, "hello", mapFn);
316
322
  const { result, head } = await crdt2.changes([]);
317
323
  expect(result.length).toEqual(3);
318
324
  expect(head.length).toEqual(1);
@@ -336,8 +342,8 @@ describe("basic Index upon cold start", function () {
336
342
  expect(didMap).toEqual(1);
337
343
  });
338
344
  it("should ignore meta when map function definiton changes", async function () {
339
- const crdt2 = new CRDT<TestType>("test-indexer-cold");
340
- const result = await index<string, TestType>({ _crdt: crdt2 }, "hello", (doc) =>
345
+ const crdt2 = new CRDT<TestType>(sthis, "test-indexer-cold");
346
+ const result = await index<string, TestType>(sthis, { _crdt: crdt2 }, "hello", (doc) =>
341
347
  doc.title.split("").reverse().join(""),
342
348
  ).query();
343
349
  expect(result.rows.length).toEqual(3);
@@ -349,6 +355,7 @@ describe("basic Index with no data", function () {
349
355
  let db: Database<TestType>;
350
356
  let indexer: Index<string, TestType>;
351
357
  let didMap: boolean;
358
+ const sthis = mockSuperThis();
352
359
  afterEach(async function () {
353
360
  await db.close();
354
361
  await db.destroy();
@@ -356,9 +363,9 @@ describe("basic Index with no data", function () {
356
363
  await indexer.destroy();
357
364
  });
358
365
  beforeEach(async function () {
359
- await rt.SysContainer.start();
366
+ await sthis.start();
360
367
  db = new Database("test-indexer");
361
- indexer = new Index<string, TestType>(db._crdt, "hello", (doc) => {
368
+ indexer = new Index<string, TestType>(sthis, db._crdt, "hello", (doc) => {
362
369
  didMap = true;
363
370
  return doc.title;
364
371
  });
@@ -0,0 +1,65 @@
1
+ import { URI } from "@adviser/cement";
2
+ import { rt, getStore, ensureSuperLog } from "@fireproof/core";
3
+ import { mockSuperThis } from "../helpers";
4
+
5
+ describe("utils", () => {
6
+ const sthis = mockSuperThis({});
7
+ const logger = ensureSuperLog(sthis, "getfilename");
8
+
9
+ beforeAll(async () => {
10
+ await sthis.start();
11
+ });
12
+
13
+ it("sorts search params", () => {
14
+ const url = URI.from("http://example.com?z=1&y=2&x=3");
15
+ expect(url.toString()).toEqual("http://example.com/?x=3&y=2&z=1");
16
+ });
17
+
18
+ const storeOpts = [
19
+ {
20
+ type: "data",
21
+ suffix: ".car",
22
+ },
23
+ {
24
+ type: "wal",
25
+ suffix: ".json",
26
+ },
27
+ {
28
+ type: "meta",
29
+ suffix: ".json",
30
+ },
31
+ ];
32
+ it("getfilename plain", () => {
33
+ for (const store of storeOpts) {
34
+ const url = URI.from(`file://./x/path?store=${store.type}&name=name&key=key&version=version`);
35
+ expect(rt.getFileName(url, logger)).toEqual(`${store.type}/key${store.suffix}`);
36
+ }
37
+ });
38
+
39
+ it("getfilename index", () => {
40
+ for (const store of storeOpts) {
41
+ const url = URI.from(`file://./x/path?index=idx&store=${store.type}&name=name&key=key&version=version`);
42
+ expect(rt.getFileName(url, logger)).toEqual(`idx-${store.type}/key${store.suffix}`);
43
+ }
44
+ });
45
+
46
+ it("getstore", () => {
47
+ for (const store of storeOpts) {
48
+ const url = URI.from(`file://./x/path?store=${store.type}&name=name&key=key&version=version`);
49
+ expect(getStore(url, logger, (...toJoin) => toJoin.join("+"))).toEqual({
50
+ name: store.type,
51
+ store: store.type,
52
+ });
53
+ }
54
+ });
55
+
56
+ it("getstore idx", () => {
57
+ for (const store of storeOpts) {
58
+ const url = URI.from(`file://./x/path?index=ix&store=${store.type}&name=name&key=key&version=version`);
59
+ expect(getStore(url, logger, (...toJoin) => toJoin.join("+"))).toEqual({
60
+ name: `ix+${store.type}`,
61
+ store: store.type,
62
+ });
63
+ }
64
+ });
65
+ });
package/tests/helpers.ts CHANGED
@@ -1,66 +1,12 @@
1
- import { rt } from "@fireproof/core";
1
+ import { LogCollector, MockLogger, runtimeFn, toCryptoRuntime, URI } from "@adviser/cement";
2
+ import { dataDir, ensureSuperThis, rt, SuperThis, SuperThisOpts } from "@fireproof/core";
2
3
 
3
- const dataDir = rt.dataDir;
4
4
  export { dataDir };
5
5
 
6
6
  export function sleep(ms: number) {
7
7
  return new Promise((resolve) => setTimeout(resolve, ms));
8
8
  }
9
9
 
10
- export function itSkip(value: string, fn: () => unknown, options?: number) {
11
- if (typeof it !== "function") {
12
- return;
13
- }
14
- const mit = it as unknown as { skip: (value: string, fn: () => unknown, options?: unknown) => unknown };
15
- if (mit && typeof mit.skip === "function") {
16
- mit.skip(value, fn, options);
17
- return;
18
- }
19
- console.warn("itSkip of " + value);
20
- }
21
-
22
- //
23
-
24
- // // Function to copy a directory
25
- // export async function copyDirectory(source: string, destination: string) {
26
- // // Ensure the destination directory exists
27
- // await rt.SysContainer.mkdir(destination, { recursive: true });
28
-
29
- // // Read the source directory
30
- // const entries = await SysContainer.readdirent(source, { withFileTypes: true });
31
-
32
- // // Iterate through each entry in the directory
33
- // for (const entry of entries) {
34
- // const sourcePath = SysContainer.join(source, entry.name);
35
- // const destinationPath = SysContainer.join(destination, entry.name);
36
-
37
- // if (entry.isDirectory()) {
38
- // // If the entry is a directory, copy it recursively
39
- // await copyDirectory(sourcePath, destinationPath);
40
- // } else if (entry.isFile()) {
41
- // // If the entry is a file, copy it
42
- // await SysContainer.copyFile(sourcePath, destinationPath);
43
- // }
44
- // }
45
- // }
46
-
47
- // export function getDirectoryName(url: string) {
48
- // let path: string;
49
- // try {
50
- // path = SysContainer.fileURLToPath(url);
51
- // } catch (e) {
52
- // path = url;
53
- // }
54
- // if (process && typeof process.cwd === "function") {
55
- // const cwd = process.cwd();
56
- // if (cwd.endsWith("dist/esm")) {
57
- // path = "../../" + path;
58
- // }
59
- // }
60
- // const dir_name = SysContainer.dirname(path);
61
- // return dir_name;
62
- // }
63
-
64
10
  async function toFileWithCid(buffer: Uint8Array, name: string, opts: FilePropertyBag): Promise<FileWithCid> {
65
11
  return {
66
12
  file: new File([new Blob([buffer])], name, opts),
@@ -73,9 +19,34 @@ export interface FileWithCid {
73
19
  cid: string;
74
20
  }
75
21
  export async function buildBlobFiles(): Promise<FileWithCid[]> {
76
- const cp = rt.crypto.toCryptoOpts();
22
+ const cp = toCryptoRuntime();
77
23
  return [
78
24
  await toFileWithCid(cp.randomBytes(Math.random() * 51283), `image.jpg`, { type: "image/jpeg" }),
79
25
  await toFileWithCid(cp.randomBytes(Math.random() * 51283), `fireproof.png`, { type: "image/png" }),
80
26
  ];
81
27
  }
28
+
29
+ export function storageURL(sthis: SuperThis): URI {
30
+ const old = sthis.env.get("FP_STORAGE_URL");
31
+ let merged: URI;
32
+ if (runtimeFn().isBrowser) {
33
+ merged = URI.merge(`indexdb://fp`, old, "indexdb:");
34
+ } else {
35
+ merged = URI.merge(`./dist/env`, old);
36
+ }
37
+ return merged;
38
+ }
39
+
40
+ export type MockSuperThis = SuperThis & { logCollector: LogCollector };
41
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
+ export function mockSuperThis(sthis?: Partial<SuperThisOpts>): MockSuperThis {
43
+ const mockLog = MockLogger();
44
+ const ethis = ensureSuperThis({
45
+ logger: mockLog.logger,
46
+ ctx: {
47
+ logCollector: mockLog.logCollector,
48
+ },
49
+ }) as MockSuperThis;
50
+ ethis.logCollector = mockLog.logCollector;
51
+ return ethis;
52
+ }
@@ -0,0 +1,14 @@
1
+ import {
2
+ getFileName,
3
+ getFileSystem,
4
+ getPath,
5
+ toArrayBuffer
6
+ } from "./chunk-XINRLWR3.js";
7
+ import "./chunk-MAK4D54P.js";
8
+ export {
9
+ getFileName,
10
+ getFileSystem,
11
+ getPath,
12
+ toArrayBuffer
13
+ };
14
+ //# sourceMappingURL=utils-AISQB3PB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}