@fireproof/core 0.19.121 → 0.20.0-dev-preview-05
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +13 -12
- package/deno/index.d.ts +7 -0
- package/deno/index.js +66 -0
- package/deno/index.js.map +1 -0
- package/deno/metafile-esm.json +1 -0
- package/deno.json +2 -3
- package/index.cjs +1827 -1059
- package/index.cjs.map +1 -1
- package/index.d.cts +747 -334
- package/index.d.ts +747 -334
- package/index.js +1800 -1034
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/index.cjs +16 -293
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +4 -40
- package/node/index.d.ts +4 -40
- package/node/index.js +22 -237
- package/node/index.js.map +1 -1
- package/node/metafile-cjs.json +1 -1
- package/node/metafile-esm.json +1 -1
- package/package.json +14 -6
- package/react/index.cjs +22 -22
- package/react/index.cjs.map +1 -1
- package/react/index.d.cts +7 -7
- package/react/index.d.ts +7 -7
- package/react/index.js +22 -22
- package/react/index.js.map +1 -1
- package/react/metafile-cjs.json +1 -1
- package/react/metafile-esm.json +1 -1
- package/tests/blockstore/fp-envelope.test.ts-off +65 -0
- package/tests/blockstore/interceptor-gateway.test.ts +122 -0
- package/tests/blockstore/keyed-crypto-indexdb-file.test.ts +130 -0
- package/tests/blockstore/keyed-crypto.test.ts +73 -118
- package/tests/blockstore/loader.test.ts +18 -9
- package/tests/blockstore/store.test.ts +40 -31
- package/tests/blockstore/transaction.test.ts +14 -13
- package/tests/fireproof/all-gateway.test.ts +286 -216
- package/tests/fireproof/cars/bafkreidxwt2nhvbl4fnqfw3ctlt6zbrir4kqwmjo5im6rf4q5si27kgo2i.ts +324 -316
- package/tests/fireproof/crdt.test.ts +78 -19
- package/tests/fireproof/fireproof.test.ts +111 -92
- package/tests/fireproof/hello.test.ts +21 -17
- package/tests/fireproof/indexer.test.ts +74 -50
- package/tests/fireproof/{database.test.ts → ledger.test.ts} +241 -45
- package/tests/fireproof/multiple-ledger.test.ts +2 -2
- package/tests/fireproof/utils.test.ts +47 -6
- package/tests/gateway/file/loader-config.test.ts +307 -0
- package/tests/gateway/fp-envelope-serialize.test.ts +256 -0
- package/tests/gateway/indexdb/loader-config.test.ts +79 -0
- package/tests/helpers.ts +44 -17
- package/tests/react/useFireproof.test.tsx +2 -2
- package/tests/www/gallery.html +2 -2
- package/tests/www/todo-aws.html +1 -1
- package/tests/www/todo-ipfs.html +1 -1
- package/tests/www/todo-local.html +1 -1
- package/tests/www/todo.html +25 -4
- package/web/index.cjs +102 -116
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +15 -29
- package/web/index.d.ts +15 -29
- package/web/index.js +91 -105
- package/web/index.js.map +1 -1
- package/web/metafile-cjs.json +1 -1
- package/web/metafile-esm.json +1 -1
- package/node/chunk-4A4RAVNS.js +0 -17
- package/node/chunk-4A4RAVNS.js.map +0 -1
- package/node/mem-filesystem-LPPT7QV5.js +0 -40
- package/node/mem-filesystem-LPPT7QV5.js.map +0 -1
- package/tests/fireproof/config.test.ts +0 -163
- /package/tests/blockstore/{fragment-gateway.test.ts → fragment-gateway.test.ts-off} +0 -0
@@ -1,163 +0,0 @@
|
|
1
|
-
import { describe, it, expect, beforeAll } from "vitest";
|
2
|
-
import { dataDir, ensureSuperThis, fireproof, rt, SysFileSystem } from "@fireproof/core";
|
3
|
-
import { runtimeFn, URI } from "@adviser/cement";
|
4
|
-
|
5
|
-
let _my_app = "my-app";
|
6
|
-
function my_app() {
|
7
|
-
return _my_app;
|
8
|
-
}
|
9
|
-
|
10
|
-
if (runtimeFn().isNodeIsh) {
|
11
|
-
describe("fireproof/config", () => {
|
12
|
-
function params(store: string) {
|
13
|
-
return Object.entries({
|
14
|
-
store,
|
15
|
-
name: my_app(),
|
16
|
-
storekey: `@${my_app()}:${store}@`,
|
17
|
-
version: rt.FILESTORE_VERSION,
|
18
|
-
});
|
19
|
-
}
|
20
|
-
const sthis = ensureSuperThis();
|
21
|
-
let getFileSystem: (url: URI) => Promise<SysFileSystem>;
|
22
|
-
beforeAll(async () => {
|
23
|
-
await sthis.start();
|
24
|
-
if (runtimeFn().isNodeIsh) {
|
25
|
-
const fpStorageUrl = sthis.env.get("FP_STORAGE_URL");
|
26
|
-
if (fpStorageUrl) {
|
27
|
-
const url = URI.from(fpStorageUrl);
|
28
|
-
_my_app = `my-app-${url.protocol.replace(/:$/, "")}:${url.getParam("fs") || "fs"}`;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
const node = await import("@fireproof/core/node");
|
32
|
-
getFileSystem = node.getFileSystem;
|
33
|
-
});
|
34
|
-
|
35
|
-
it("node default", async () => {
|
36
|
-
const old = sthis.env.get("FP_STORAGE_URL");
|
37
|
-
sthis.env.delete("FP_STORAGE_URL");
|
38
|
-
let baseDir = dataDir(sthis, my_app()).pathname;
|
39
|
-
baseDir = sthis.pathOps.join(baseDir, rt.FILESTORE_VERSION, my_app());
|
40
|
-
|
41
|
-
const sysfs = await getFileSystem(URI.from(baseDir));
|
42
|
-
await sysfs.rm(baseDir, { recursive: true }).catch(() => {
|
43
|
-
/* */
|
44
|
-
});
|
45
|
-
|
46
|
-
expect(baseDir).toMatch(new RegExp(`/\\.fireproof/${rt.FILESTORE_VERSION}/${my_app()}`));
|
47
|
-
|
48
|
-
const db = fireproof(my_app());
|
49
|
-
await db.put({ name: "my-app" });
|
50
|
-
expect(db.name).toBe(my_app());
|
51
|
-
const carStore = await db.blockstore.loader?.carStore();
|
52
|
-
|
53
|
-
for (const [param, value] of Object.entries({
|
54
|
-
store: "data",
|
55
|
-
name: my_app(),
|
56
|
-
storekey: `@${my_app()}:data@`,
|
57
|
-
version: rt.FILESTORE_VERSION,
|
58
|
-
})) {
|
59
|
-
expect(carStore?.url().getParam(param)).toBe(value);
|
60
|
-
}
|
61
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
62
|
-
|
63
|
-
const fileStore = await db.blockstore.loader?.fileStore();
|
64
|
-
for (const [param, value] of params("data")) {
|
65
|
-
expect(fileStore?.url().getParam(param)).toBe(value);
|
66
|
-
}
|
67
|
-
const metaStore = await db.blockstore.loader?.metaStore();
|
68
|
-
for (const [param, value] of params("meta")) {
|
69
|
-
expect(metaStore?.url().getParam(param)).toBe(value);
|
70
|
-
}
|
71
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
|
72
|
-
sthis.env.set("FP_STORAGE_URL", old);
|
73
|
-
await db.close();
|
74
|
-
});
|
75
|
-
|
76
|
-
it("set by env", async () => {
|
77
|
-
const old = sthis.env.get("FP_STORAGE_URL");
|
78
|
-
const testUrl = URI.merge(`./dist/env`, old);
|
79
|
-
sthis.env.set("FP_STORAGE_URL", testUrl.toString());
|
80
|
-
|
81
|
-
let baseDir = dataDir(sthis, my_app()).pathname;
|
82
|
-
baseDir = sthis.pathOps.join(baseDir, rt.FILESTORE_VERSION, my_app());
|
83
|
-
|
84
|
-
const sysfs = await getFileSystem(testUrl);
|
85
|
-
await sysfs.rm(baseDir, { recursive: true }).catch(() => {
|
86
|
-
/* */
|
87
|
-
});
|
88
|
-
|
89
|
-
const db = fireproof(my_app());
|
90
|
-
await db.put({ name: "my-app" });
|
91
|
-
expect(db.name).toBe(my_app());
|
92
|
-
const carStore = await db.blockstore.loader?.carStore();
|
93
|
-
for (const [param, value] of params("data")) {
|
94
|
-
expect(carStore?.url().getParam(param)).toBe(value);
|
95
|
-
}
|
96
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
97
|
-
const fileStore = await db.blockstore.loader?.fileStore();
|
98
|
-
for (const [param, value] of params("data")) {
|
99
|
-
expect(fileStore?.url().getParam(param)).toBe(value);
|
100
|
-
}
|
101
|
-
const metaStore = await db.blockstore.loader?.metaStore();
|
102
|
-
for (const [param, value] of params("meta")) {
|
103
|
-
expect(metaStore?.url().getParam(param)).toBe(value);
|
104
|
-
}
|
105
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "meta"))).isDirectory()).toBeTruthy();
|
106
|
-
await db.close();
|
107
|
-
sthis.env.set("FP_STORAGE_URL", old);
|
108
|
-
});
|
109
|
-
|
110
|
-
it("file path", async () => {
|
111
|
-
let baseDir = "./dist/data".replace(/\?.*$/, "").replace(/^file:\/\//, "");
|
112
|
-
baseDir = sthis.pathOps.join(baseDir, rt.FILESTORE_VERSION, my_app());
|
113
|
-
|
114
|
-
const base = "./dist/data";
|
115
|
-
const sysfs = await getFileSystem(URI.from(base));
|
116
|
-
await sysfs.rm(baseDir, { recursive: true }).catch(() => {
|
117
|
-
/* */
|
118
|
-
});
|
119
|
-
|
120
|
-
const db = fireproof(my_app(), { store: { stores: { base } } });
|
121
|
-
// console.log(`>>>>>>>>>>>>>>>file-path`)
|
122
|
-
await db.put({ name: "my-app" });
|
123
|
-
expect(db.name).toBe(my_app());
|
124
|
-
const carStore = await db.blockstore.loader?.carStore();
|
125
|
-
for (const [param, value] of params("data")) {
|
126
|
-
expect(carStore?.url().getParam(param)).toBe(value);
|
127
|
-
}
|
128
|
-
const fileStore = await db.blockstore.loader?.fileStore();
|
129
|
-
for (const [param, value] of params("data")) {
|
130
|
-
expect(fileStore?.url().getParam(param)).toBe(value);
|
131
|
-
}
|
132
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
133
|
-
const metaStore = await db.blockstore.loader?.metaStore();
|
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();
|
138
|
-
await db.close();
|
139
|
-
});
|
140
|
-
});
|
141
|
-
} else {
|
142
|
-
it("default", async () => {
|
143
|
-
const db = fireproof(my_app());
|
144
|
-
await db.put({ name: "my-app" });
|
145
|
-
expect(db.name).toBe(my_app());
|
146
|
-
|
147
|
-
const fileStore = await db.blockstore.loader?.fileStore();
|
148
|
-
expect(fileStore?.url().toString()).toMatch(
|
149
|
-
new RegExp(`indexdb://fp\\?name=my-app&store=data&storekey=%40my-app%3Adata%40&version=${rt.INDEXDB_VERSION}`),
|
150
|
-
);
|
151
|
-
const metaStore = await db.blockstore.loader?.metaStore();
|
152
|
-
expect(metaStore?.url().toString()).toMatch(
|
153
|
-
new RegExp(`indexdb://fp\\?name=my-app&store=meta&storekey=%40my-app%3Ameta%40&version=${rt.INDEXDB_VERSION}`),
|
154
|
-
);
|
155
|
-
|
156
|
-
const carStore = await db.blockstore.loader?.carStore();
|
157
|
-
expect(carStore?.url().toString()).toMatch(
|
158
|
-
new RegExp(`indexdb://fp\\?name=my-app&store=data&storekey=%40my-app%3Adata%40&version=${rt.INDEXDB_VERSION}`),
|
159
|
-
);
|
160
|
-
|
161
|
-
await db.close();
|
162
|
-
});
|
163
|
-
}
|
File without changes
|