@fireproof/core 0.19.121-dev → 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 +3 -4
- package/index.cjs +1797 -1431
- package/index.cjs.map +1 -1
- package/index.d.cts +760 -381
- package/index.d.ts +760 -381
- package/index.js +1976 -913
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/node/{node-filesystem.cjs → index.cjs} +17 -6
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +7 -0
- package/node/index.d.ts +7 -0
- package/node/{node-filesystem.js → index.js} +25 -5
- package/node/index.js.map +1 -0
- package/node/metafile-cjs.json +1 -1
- package/node/metafile-esm.json +1 -1
- package/package.json +27 -17
- 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 +75 -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 +218 -0
- package/web/index.cjs.map +1 -0
- package/web/index.d.cts +30 -0
- package/web/index.d.ts +30 -0
- package/web/index.js +195 -0
- package/web/index.js.map +1 -0
- package/web/metafile-cjs.json +1 -1
- package/web/metafile-esm.json +1 -1
- package/chunk-7EWIAXTM.js +0 -7
- package/chunk-7EWIAXTM.js.map +0 -1
- package/chunk-F4FC6B2T.js +0 -63
- package/chunk-F4FC6B2T.js.map +0 -1
- package/chunk-PZ5AY32C.js +0 -10
- package/chunk-PZ5AY32C.js.map +0 -1
- package/chunk-RXC4JGJT.js +0 -301
- package/chunk-RXC4JGJT.js.map +0 -1
- package/gateway-C62S56GY.js +0 -66
- package/gateway-C62S56GY.js.map +0 -1
- package/gateway-VVS4QWDA.js +0 -145
- package/gateway-VVS4QWDA.js.map +0 -1
- package/key-bag-file-PWZ3QE7B.js +0 -55
- package/key-bag-file-PWZ3QE7B.js.map +0 -1
- package/key-bag-indexdb-SYG3YD4D.js +0 -51
- package/key-bag-indexdb-SYG3YD4D.js.map +0 -1
- package/node/chunk-4A4RAVNS.js +0 -17
- package/node/chunk-4A4RAVNS.js.map +0 -1
- package/node/mem-filesystem.cjs +0 -72
- package/node/mem-filesystem.cjs.map +0 -1
- package/node/mem-filesystem.d.cts +0 -25
- package/node/mem-filesystem.d.ts +0 -25
- package/node/mem-filesystem.js +0 -40
- package/node/mem-filesystem.js.map +0 -1
- package/node/node-filesystem.cjs.map +0 -1
- package/node/node-filesystem.d.cts +0 -35
- package/node/node-filesystem.d.ts +0 -35
- package/node/node-filesystem.js.map +0 -1
- package/tests/fireproof/config.test.ts +0 -172
- package/utils-ZVVGAXFE.js +0 -13
- package/utils-ZVVGAXFE.js.map +0 -1
- package/web/gateway-impl.cjs +0 -183
- package/web/gateway-impl.cjs.map +0 -1
- package/web/gateway-impl.d.cts +0 -31
- package/web/gateway-impl.d.ts +0 -31
- package/web/gateway-impl.js +0 -162
- package/web/gateway-impl.js.map +0 -1
- /package/tests/blockstore/{fragment-gateway.test.ts → fragment-gateway.test.ts-off} +0 -0
@@ -1,35 +0,0 @@
|
|
1
|
-
import { PathLike, ObjectEncodingOptions, MakeDirectoryOptions, Stats } from 'node:fs';
|
2
|
-
import { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from 'node:fs/promises';
|
3
|
-
import { SysFileSystem } from '@fireproof/core';
|
4
|
-
|
5
|
-
declare class NodeFileSystem implements SysFileSystem {
|
6
|
-
fs?: {
|
7
|
-
mkdir: typeof mkdir;
|
8
|
-
readdir: typeof readdir;
|
9
|
-
rm: typeof rm;
|
10
|
-
copyFile: typeof copyFile;
|
11
|
-
readFile: typeof readFile;
|
12
|
-
stat: typeof stat;
|
13
|
-
unlink: typeof unlink;
|
14
|
-
writeFile: typeof writeFile;
|
15
|
-
};
|
16
|
-
start(): Promise<SysFileSystem>;
|
17
|
-
mkdir(path: PathLike, options?: {
|
18
|
-
recursive: boolean;
|
19
|
-
}): Promise<string | undefined>;
|
20
|
-
readdir(path: PathLike, options?: ObjectEncodingOptions): Promise<string[]>;
|
21
|
-
rm(path: PathLike, options?: MakeDirectoryOptions & {
|
22
|
-
recursive: boolean;
|
23
|
-
}): Promise<void>;
|
24
|
-
copyFile(source: PathLike, destination: PathLike): Promise<void>;
|
25
|
-
readfile(path: PathLike, options?: {
|
26
|
-
encoding: BufferEncoding;
|
27
|
-
flag?: string;
|
28
|
-
}): Promise<Uint8Array>;
|
29
|
-
stat(path: PathLike): Promise<Stats>;
|
30
|
-
unlink(path: PathLike): Promise<void>;
|
31
|
-
writefile(path: PathLike, data: Uint8Array | string): Promise<void>;
|
32
|
-
}
|
33
|
-
|
34
|
-
export { NodeFileSystem };
|
35
|
-
declare module '@fireproof/core/node'
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import { PathLike, ObjectEncodingOptions, MakeDirectoryOptions, Stats } from 'node:fs';
|
2
|
-
import { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from 'node:fs/promises';
|
3
|
-
import { SysFileSystem } from '@fireproof/core';
|
4
|
-
|
5
|
-
declare class NodeFileSystem implements SysFileSystem {
|
6
|
-
fs?: {
|
7
|
-
mkdir: typeof mkdir;
|
8
|
-
readdir: typeof readdir;
|
9
|
-
rm: typeof rm;
|
10
|
-
copyFile: typeof copyFile;
|
11
|
-
readFile: typeof readFile;
|
12
|
-
stat: typeof stat;
|
13
|
-
unlink: typeof unlink;
|
14
|
-
writeFile: typeof writeFile;
|
15
|
-
};
|
16
|
-
start(): Promise<SysFileSystem>;
|
17
|
-
mkdir(path: PathLike, options?: {
|
18
|
-
recursive: boolean;
|
19
|
-
}): Promise<string | undefined>;
|
20
|
-
readdir(path: PathLike, options?: ObjectEncodingOptions): Promise<string[]>;
|
21
|
-
rm(path: PathLike, options?: MakeDirectoryOptions & {
|
22
|
-
recursive: boolean;
|
23
|
-
}): Promise<void>;
|
24
|
-
copyFile(source: PathLike, destination: PathLike): Promise<void>;
|
25
|
-
readfile(path: PathLike, options?: {
|
26
|
-
encoding: BufferEncoding;
|
27
|
-
flag?: string;
|
28
|
-
}): Promise<Uint8Array>;
|
29
|
-
stat(path: PathLike): Promise<Stats>;
|
30
|
-
unlink(path: PathLike): Promise<void>;
|
31
|
-
writefile(path: PathLike, data: Uint8Array | string): Promise<void>;
|
32
|
-
}
|
33
|
-
|
34
|
-
export { NodeFileSystem };
|
35
|
-
declare module '@fireproof/core/node'
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/gateways/file/node/node-filesystem.ts"],"sourcesContent":["import type { PathLike, MakeDirectoryOptions, Stats, ObjectEncodingOptions } from \"node:fs\";\nimport type { mkdir, readdir, rm, copyFile, readFile, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { toArrayBuffer } from \"./to-array-buffer.js\";\nimport type { SysFileSystem } from \"@fireproof/core\";\nimport { runtimeFn } from \"@adviser/cement\";\n\nexport class NodeFileSystem implements SysFileSystem {\n fs?: {\n mkdir: typeof mkdir;\n readdir: typeof readdir;\n rm: typeof rm;\n copyFile: typeof copyFile;\n readFile: typeof readFile;\n stat: typeof stat;\n unlink: typeof unlink;\n writeFile: typeof writeFile;\n };\n\n async start(): Promise<SysFileSystem> {\n this.fs = await import(\"node:fs/promises\");\n return this;\n }\n async mkdir(path: PathLike, options?: { recursive: boolean }): Promise<string | undefined> {\n return this.fs?.mkdir(path, options);\n }\n async readdir(path: PathLike, options?: ObjectEncodingOptions): Promise<string[]> {\n return this.fs?.readdir(path, options) as Promise<string[]>;\n }\n async rm(path: PathLike, options?: MakeDirectoryOptions & { recursive: boolean }): Promise<void> {\n return this.fs?.rm(path, options);\n }\n async copyFile(source: PathLike, destination: PathLike): Promise<void> {\n return this.fs?.copyFile(source, destination);\n }\n async readfile(path: PathLike, options?: { encoding: BufferEncoding; flag?: string }): Promise<Uint8Array> {\n const ret = (await this.fs?.readFile(path, options)) as Buffer;\n return toArrayBuffer(ret);\n }\n stat(path: PathLike): Promise<Stats> {\n return this.fs?.stat(path) as Promise<Stats>;\n }\n async unlink(path: PathLike): Promise<void> {\n return this.fs?.unlink(path);\n }\n async writefile(path: PathLike, data: Uint8Array | string): Promise<void> {\n if (runtimeFn().isDeno) {\n return this.fs?.writeFile(path, data);\n }\n return this.fs?.writeFile(path, Buffer.from(data));\n }\n}\n\n// import { type NodeMap, join } from \"../../sys-container.js\";\n// import type { ObjectEncodingOptions, PathLike } from \"fs\";\n// import * as fs from \"fs/promises\";\n// import * as path from \"path\";\n// import * as os from \"os\";\n// import * as url from \"url\";\n// import { toArrayBuffer } from \"./utils.js\";\n\n// export async function createNodeSysContainer(): Promise<NodeMap> {\n// // const nodePath = \"node:path\";\n// // const nodeOS = \"node:os\";\n// // const nodeURL = \"node:url\";\n// // const nodeFS = \"node:fs\";\n// // const fs = (await import(\"node:fs\")).promises;\n// // const assert = \"assert\";\n// // const path = await import(\"node:path\");\n// return {\n// state: \"node\",\n// ...path,\n// // ...(await import(\"node:os\")),\n// // ...(await import(\"node:url\")),\n// ...os,\n// ...url,\n// ...fs,\n// join,\n// stat: fs.stat as NodeMap[\"stat\"],\n// readdir: fs.readdir as NodeMap[\"readdir\"],\n// readfile: async (path: PathLike, options?: ObjectEncodingOptions): Promise<Uint8Array> => {\n// const rs = await fs.readFile(path, options);\n// return toArrayBuffer(rs);\n// },\n// writefile: fs.writeFile as NodeMap[\"writefile\"],\n// };\n// }\n"],"mappings":";;;;;AAIA,SAAS,iBAAiB;AAEnB,IAAM,iBAAN,MAA8C;AAAA,EAYnD,MAAM,QAAgC;AACpC,SAAK,KAAK,MAAM,OAAO,kBAAkB;AACzC,WAAO;AAAA,EACT;AAAA,EACA,MAAM,MAAM,MAAgB,SAA+D;AACzF,WAAO,KAAK,IAAI,MAAM,MAAM,OAAO;AAAA,EACrC;AAAA,EACA,MAAM,QAAQ,MAAgB,SAAoD;AAChF,WAAO,KAAK,IAAI,QAAQ,MAAM,OAAO;AAAA,EACvC;AAAA,EACA,MAAM,GAAG,MAAgB,SAAwE;AAC/F,WAAO,KAAK,IAAI,GAAG,MAAM,OAAO;AAAA,EAClC;AAAA,EACA,MAAM,SAAS,QAAkB,aAAsC;AACrE,WAAO,KAAK,IAAI,SAAS,QAAQ,WAAW;AAAA,EAC9C;AAAA,EACA,MAAM,SAAS,MAAgB,SAA4E;AACzG,UAAM,MAAO,MAAM,KAAK,IAAI,SAAS,MAAM,OAAO;AAClD,WAAO,cAAc,GAAG;AAAA,EAC1B;AAAA,EACA,KAAK,MAAgC;AACnC,WAAO,KAAK,IAAI,KAAK,IAAI;AAAA,EAC3B;AAAA,EACA,MAAM,OAAO,MAA+B;AAC1C,WAAO,KAAK,IAAI,OAAO,IAAI;AAAA,EAC7B;AAAA,EACA,MAAM,UAAU,MAAgB,MAA0C;AACxE,QAAI,UAAU,EAAE,QAAQ;AACtB,aAAO,KAAK,IAAI,UAAU,MAAM,IAAI;AAAA,IACtC;AACA,WAAO,KAAK,IAAI,UAAU,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,EACnD;AACF;","names":[]}
|
@@ -1,172 +0,0 @@
|
|
1
|
-
import { describe, it, expect, beforeAll } from "vitest";
|
2
|
-
import { dataDir, ensureSuperThis, fireproof, rt } from "@fireproof/core";
|
3
|
-
import { runtimeFn, URI } from "@adviser/cement";
|
4
|
-
|
5
|
-
describe("runtime", () => {
|
6
|
-
it("runtime", () => {
|
7
|
-
const isNode = !!(typeof process === "object" && process.versions?.node);
|
8
|
-
expect(runtimeFn()).toEqual({
|
9
|
-
isBrowser: !isNode,
|
10
|
-
isCFWorker: false,
|
11
|
-
isDeno: false,
|
12
|
-
isNodeIsh: isNode,
|
13
|
-
isReactNative: false,
|
14
|
-
});
|
15
|
-
});
|
16
|
-
});
|
17
|
-
|
18
|
-
describe("fireproof/config", () => {
|
19
|
-
let _my_app = "my-app";
|
20
|
-
function my_app() {
|
21
|
-
return _my_app;
|
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 = ensureSuperThis();
|
32
|
-
beforeAll(async () => {
|
33
|
-
await sthis.start();
|
34
|
-
if (runtimeFn().isNodeIsh) {
|
35
|
-
const fpStorageUrl = sthis.env.get("FP_STORAGE_URL");
|
36
|
-
if (fpStorageUrl) {
|
37
|
-
const url = URI.from(fpStorageUrl);
|
38
|
-
_my_app = `my-app-${url.protocol.replace(/:$/, "")}:${url.getParam("fs") || "fs"}`;
|
39
|
-
}
|
40
|
-
}
|
41
|
-
});
|
42
|
-
|
43
|
-
if (!runtimeFn().isNodeIsh) {
|
44
|
-
it("default", async () => {
|
45
|
-
const db = fireproof(my_app());
|
46
|
-
await db.put({ name: "my-app" });
|
47
|
-
expect(db.name).toBe(my_app());
|
48
|
-
|
49
|
-
const fileStore = await db.blockstore.loader?.fileStore();
|
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
|
-
);
|
53
|
-
const metaStore = await db.blockstore.loader?.metaStore();
|
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
|
-
|
63
|
-
await db.close();
|
64
|
-
});
|
65
|
-
return;
|
66
|
-
}
|
67
|
-
it("node default", async () => {
|
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(() => {
|
75
|
-
/* */
|
76
|
-
});
|
77
|
-
|
78
|
-
expect(baseDir).toMatch(new RegExp(`/\\.fireproof/${rt.FILESTORE_VERSION}/${my_app()}`));
|
79
|
-
|
80
|
-
const db = fireproof(my_app());
|
81
|
-
await db.put({ name: "my-app" });
|
82
|
-
expect(db.name).toBe(my_app());
|
83
|
-
const carStore = await db.blockstore.loader?.carStore();
|
84
|
-
|
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();
|
94
|
-
|
95
|
-
const fileStore = await db.blockstore.loader?.fileStore();
|
96
|
-
for (const [param, value] of params("data")) {
|
97
|
-
expect(fileStore?.url().getParam(param)).toBe(value);
|
98
|
-
}
|
99
|
-
const metaStore = await db.blockstore.loader?.metaStore();
|
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);
|
105
|
-
await db.close();
|
106
|
-
});
|
107
|
-
|
108
|
-
it("set by env", async () => {
|
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(() => {
|
118
|
-
/* */
|
119
|
-
});
|
120
|
-
|
121
|
-
const db = fireproof(my_app());
|
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
|
-
expect((await sysfs.stat(sthis.pathOps.join(baseDir, "data"))).isDirectory()).toBeTruthy();
|
129
|
-
const fileStore = await db.blockstore.loader?.fileStore();
|
130
|
-
for (const [param, value] of params("data")) {
|
131
|
-
expect(fileStore?.url().getParam(param)).toBe(value);
|
132
|
-
}
|
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
|
-
sthis.env.set("FP_STORAGE_URL", old);
|
140
|
-
});
|
141
|
-
|
142
|
-
it("file path", async () => {
|
143
|
-
let baseDir = "./dist/data".replace(/\?.*$/, "").replace(/^file:\/\//, "");
|
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(() => {
|
149
|
-
/* */
|
150
|
-
});
|
151
|
-
|
152
|
-
const db = fireproof(my_app(), { store: { stores: { base } } });
|
153
|
-
// console.log(`>>>>>>>>>>>>>>>file-path`)
|
154
|
-
await db.put({ name: "my-app" });
|
155
|
-
expect(db.name).toBe(my_app());
|
156
|
-
const carStore = await db.blockstore.loader?.carStore();
|
157
|
-
for (const [param, value] of params("data")) {
|
158
|
-
expect(carStore?.url().getParam(param)).toBe(value);
|
159
|
-
}
|
160
|
-
const fileStore = await db.blockstore.loader?.fileStore();
|
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();
|
165
|
-
const metaStore = await db.blockstore.loader?.metaStore();
|
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();
|
170
|
-
await db.close();
|
171
|
-
});
|
172
|
-
});
|
package/utils-ZVVGAXFE.js
DELETED
package/utils-ZVVGAXFE.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/web/gateway-impl.cjs
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
|
20
|
-
// src/runtime/gateways/indexdb/web/gateway-impl.ts
|
21
|
-
var gateway_impl_exports = {};
|
22
|
-
__export(gateway_impl_exports, {
|
23
|
-
IndexDBGatewayImpl: () => IndexDBGatewayImpl,
|
24
|
-
IndexDBTestStore: () => IndexDBTestStore,
|
25
|
-
getIndexDBName: () => getIndexDBName
|
26
|
-
});
|
27
|
-
module.exports = __toCommonJS(gateway_impl_exports);
|
28
|
-
var import_idb = require("idb");
|
29
|
-
var import_cement = require("@adviser/cement");
|
30
|
-
|
31
|
-
// src/runtime/gateways/indexdb/version.ts
|
32
|
-
var INDEXDB_VERSION = "v0.19-indexdb";
|
33
|
-
|
34
|
-
// src/runtime/gateways/indexdb/web/gateway-impl.ts
|
35
|
-
var import_core = require("@fireproof/core");
|
36
|
-
function ensureVersion(url) {
|
37
|
-
return url.build().defParam("version", INDEXDB_VERSION).URI();
|
38
|
-
}
|
39
|
-
function sanitzeKey(key) {
|
40
|
-
if (key.length === 1) {
|
41
|
-
key = key[0];
|
42
|
-
}
|
43
|
-
return key;
|
44
|
-
}
|
45
|
-
var onceConn = new import_cement.KeyedResolvOnce();
|
46
|
-
async function connectIdb(url, sthis) {
|
47
|
-
const dbName = getIndexDBName(url, sthis);
|
48
|
-
const once = await onceConn.get(dbName.fullDb).once(async () => {
|
49
|
-
const db = await (0, import_idb.openDB)(dbName.fullDb, 1, {
|
50
|
-
upgrade(db2) {
|
51
|
-
["version", "data", "wal", "meta", "idx.data", "idx.wal", "idx.meta"].map((store) => {
|
52
|
-
db2.createObjectStore(store, {
|
53
|
-
autoIncrement: false
|
54
|
-
});
|
55
|
-
});
|
56
|
-
}
|
57
|
-
});
|
58
|
-
const found = await db.get("version", "version");
|
59
|
-
const version = ensureVersion(url).getParam("version");
|
60
|
-
if (!found) {
|
61
|
-
await db.put("version", { version }, "version");
|
62
|
-
} else if (found.version !== version) {
|
63
|
-
sthis.logger.Warn().Str("url", url.toString()).Str("version", version).Str("found", found.version).Msg("version mismatch");
|
64
|
-
}
|
65
|
-
return { db, dbName, version, url };
|
66
|
-
});
|
67
|
-
return {
|
68
|
-
...once,
|
69
|
-
url: url.build().setParam("version", once.version).URI()
|
70
|
-
};
|
71
|
-
}
|
72
|
-
function joinDBName(...names) {
|
73
|
-
return names.map((i) => i.replace(/^[^a-zA-Z0-9]+/g, "").replace(/[^a-zA-Z0-9-]+/g, "_")).filter((i) => i.length).join(".");
|
74
|
-
}
|
75
|
-
function getIndexDBName(iurl, sthis) {
|
76
|
-
const url = ensureVersion(iurl);
|
77
|
-
const fullDb = url.pathname.replace(/^\/+/, "").replace(/\?.*$/, "");
|
78
|
-
const dbName = url.getParam("name");
|
79
|
-
if (!dbName) throw sthis.logger.Error().Str("url", url.toString()).Msg(`name not found`).AsError();
|
80
|
-
const result = joinDBName(fullDb, dbName);
|
81
|
-
const objStore = (0, import_core.getStore)(url, sthis, joinDBName).name;
|
82
|
-
const connectionKey = [result, objStore].join(":");
|
83
|
-
return {
|
84
|
-
fullDb: result,
|
85
|
-
objStore,
|
86
|
-
connectionKey,
|
87
|
-
dbName
|
88
|
-
};
|
89
|
-
}
|
90
|
-
var IndexDBGatewayImpl = class {
|
91
|
-
constructor(sthis) {
|
92
|
-
this.logger = (0, import_core.ensureLogger)(sthis, "IndexDBGateway");
|
93
|
-
this.sthis = sthis;
|
94
|
-
}
|
95
|
-
// _db: IDBPDatabase<unknown> = {} as IDBPDatabase<unknown>;
|
96
|
-
async start(baseURL) {
|
97
|
-
return (0, import_cement.exception2Result)(async () => {
|
98
|
-
this.logger.Debug().Url(baseURL).Msg("starting");
|
99
|
-
await this.sthis.start();
|
100
|
-
const ic = await connectIdb(baseURL, this.sthis);
|
101
|
-
this.logger.Debug().Url(ic.url).Msg("started");
|
102
|
-
return ic.url;
|
103
|
-
});
|
104
|
-
}
|
105
|
-
async close() {
|
106
|
-
return import_cement.Result.Ok(void 0);
|
107
|
-
}
|
108
|
-
async destroy(baseUrl) {
|
109
|
-
return (0, import_cement.exception2Result)(async () => {
|
110
|
-
const type = (0, import_core.getStore)(baseUrl, this.sthis, joinDBName).name;
|
111
|
-
const idb = await connectIdb(baseUrl, this.sthis);
|
112
|
-
const trans = idb.db.transaction(type, "readwrite");
|
113
|
-
const object_store = trans.objectStore(type);
|
114
|
-
const toDelete = [];
|
115
|
-
for (let cursor = await object_store.openCursor(); cursor; cursor = await cursor.continue()) {
|
116
|
-
toDelete.push(cursor.primaryKey);
|
117
|
-
}
|
118
|
-
for (const key of toDelete) {
|
119
|
-
await trans.db.delete(type, key);
|
120
|
-
}
|
121
|
-
await trans.done;
|
122
|
-
});
|
123
|
-
}
|
124
|
-
buildUrl(baseUrl, key) {
|
125
|
-
return Promise.resolve(import_cement.Result.Ok(baseUrl.build().setParam("key", key).URI()));
|
126
|
-
}
|
127
|
-
async get(url) {
|
128
|
-
return (0, import_core.exceptionWrapper)(async () => {
|
129
|
-
const key = (0, import_core.getKey)(url, this.logger);
|
130
|
-
const store = (0, import_core.getStore)(url, this.sthis, joinDBName).name;
|
131
|
-
this.logger.Debug().Url(url).Str("key", key).Str("store", store).Msg("getting");
|
132
|
-
const { db } = await connectIdb(url, this.sthis);
|
133
|
-
const tx = db.transaction([store], "readonly");
|
134
|
-
const bytes = await tx.objectStore(store).get(sanitzeKey(key));
|
135
|
-
await tx.done;
|
136
|
-
if (!bytes) {
|
137
|
-
return import_cement.Result.Err(new import_core.NotFoundError(`missing ${key}`));
|
138
|
-
}
|
139
|
-
return import_cement.Result.Ok(bytes);
|
140
|
-
});
|
141
|
-
}
|
142
|
-
async put(url, value) {
|
143
|
-
return (0, import_cement.exception2Result)(async () => {
|
144
|
-
const key = (0, import_core.getKey)(url, this.logger);
|
145
|
-
const store = (0, import_core.getStore)(url, this.sthis, joinDBName).name;
|
146
|
-
this.logger.Debug().Url(url).Str("key", key).Str("store", store).Msg("putting");
|
147
|
-
const { db } = await connectIdb(url, this.sthis);
|
148
|
-
const tx = db.transaction([store], "readwrite");
|
149
|
-
await tx.objectStore(store).put(value, sanitzeKey(key));
|
150
|
-
await tx.done;
|
151
|
-
});
|
152
|
-
}
|
153
|
-
async delete(url) {
|
154
|
-
return (0, import_cement.exception2Result)(async () => {
|
155
|
-
const key = (0, import_core.getKey)(url, this.logger);
|
156
|
-
const store = (0, import_core.getStore)(url, this.sthis, joinDBName).name;
|
157
|
-
this.logger.Debug().Url(url).Str("key", key).Str("store", store).Msg("deleting");
|
158
|
-
const { db } = await connectIdb(url, this.sthis);
|
159
|
-
const tx = db.transaction([store], "readwrite");
|
160
|
-
await tx.objectStore(store).delete(sanitzeKey(key));
|
161
|
-
await tx.done;
|
162
|
-
return import_cement.Result.Ok(void 0);
|
163
|
-
});
|
164
|
-
}
|
165
|
-
};
|
166
|
-
var IndexDBTestStore = class {
|
167
|
-
constructor(sthis) {
|
168
|
-
this.sthis = sthis;
|
169
|
-
this.logger = (0, import_core.ensureLogger)(sthis, "IndexDBTestStore", {});
|
170
|
-
}
|
171
|
-
async get(url, key) {
|
172
|
-
const ic = await connectIdb(url, this.sthis);
|
173
|
-
const store = (0, import_core.getStore)(ic.url, this.sthis, joinDBName).name;
|
174
|
-
this.logger.Debug().Str("key", key).Str("store", store).Msg("getting");
|
175
|
-
let bytes = await ic.db.get(store, sanitzeKey(key));
|
176
|
-
this.logger.Debug().Str("key", key).Str("store", store).Int("len", bytes.length).Msg("got");
|
177
|
-
if (typeof bytes === "string") {
|
178
|
-
bytes = this.sthis.txt.encode(bytes);
|
179
|
-
}
|
180
|
-
return bytes;
|
181
|
-
}
|
182
|
-
};
|
183
|
-
//# sourceMappingURL=gateway-impl.cjs.map
|
package/web/gateway-impl.cjs.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/gateways/indexdb/web/gateway-impl.ts","../../../src/runtime/gateways/indexdb/version.ts"],"sourcesContent":["import { openDB, IDBPDatabase } from \"idb\";\nimport { exception2Result, KeyedResolvOnce, Logger, Result, URI } from \"@adviser/cement\";\n\nimport { INDEXDB_VERSION } from \"../version.js\";\nimport { ensureLogger, exceptionWrapper, getKey, getStore, NotFoundError } from \"@fireproof/core\";\nimport type { bs } from \"@fireproof/core\";\nimport type { SuperThis } from \"@fireproof/core\";\n\nfunction ensureVersion(url: URI): URI {\n return url.build().defParam(\"version\", INDEXDB_VERSION).URI();\n}\n\ninterface IDBConn {\n readonly db: IDBPDatabase<unknown>;\n readonly dbName: DbName;\n readonly version: string;\n readonly url: URI;\n}\n\nfunction sanitzeKey(key: string | string[]): string | string[] {\n if (key.length === 1) {\n key = key[0];\n }\n return key;\n}\n\nconst onceConn = new KeyedResolvOnce<IDBConn>();\nasync function connectIdb(url: URI, sthis: SuperThis): Promise<IDBConn> {\n const dbName = getIndexDBName(url, sthis);\n const once = await onceConn.get(dbName.fullDb).once(async () => {\n const db = await openDB(dbName.fullDb, 1, {\n upgrade(db) {\n [\"version\", \"data\", \"wal\", \"meta\", \"idx.data\", \"idx.wal\", \"idx.meta\"].map((store) => {\n db.createObjectStore(store, {\n autoIncrement: false,\n });\n });\n },\n });\n const found = await db.get(\"version\", \"version\");\n const version = ensureVersion(url).getParam(\"version\") as string;\n if (!found) {\n await db.put(\"version\", { version }, \"version\");\n } else if (found.version !== version) {\n sthis.logger.Warn().Str(\"url\", url.toString()).Str(\"version\", version).Str(\"found\", found.version).Msg(\"version mismatch\");\n }\n return { db, dbName, version, url };\n });\n return {\n ...once,\n url: url.build().setParam(\"version\", once.version).URI(),\n };\n}\n\nexport interface DbName {\n readonly fullDb: string;\n readonly objStore: string;\n readonly connectionKey: string;\n readonly dbName: string;\n}\n\nfunction joinDBName(...names: string[]): string {\n return names\n .map((i) => i.replace(/^[^a-zA-Z0-9]+/g, \"\").replace(/[^a-zA-Z0-9-]+/g, \"_\"))\n .filter((i) => i.length)\n .join(\".\");\n}\n\n// const schemaVersion = new Map<string, number>();\nexport function getIndexDBName(iurl: URI, sthis: SuperThis): DbName {\n const url = ensureVersion(iurl);\n const fullDb = url.pathname.replace(/^\\/+/, \"\").replace(/\\?.*$/, \"\"); // cut leading slashes\n // const type = getStore(url);\n // const storageVersion = url.searchParams.get(\"version\");\n // not nice but we need to pass the version to the db name\n // url.searchParams.set(\"version\", storageVersion);\n // console.log(\"getIndexDBName:\", url.toString(), { fullDb, type, branch });\n // const dbName = fullDb.replace(new RegExp(`^fp.${storageVersion}.`), \"\"); // cut fp prefix\n const dbName = url.getParam(\"name\");\n if (!dbName) throw sthis.logger.Error().Str(\"url\", url.toString()).Msg(`name not found`).AsError();\n const result = joinDBName(fullDb, dbName);\n const objStore = getStore(url, sthis, joinDBName).name;\n const connectionKey = [result, objStore].join(\":\");\n return {\n fullDb: result,\n objStore,\n connectionKey,\n dbName,\n };\n}\n\nexport class IndexDBGatewayImpl implements bs.Gateway {\n readonly logger: Logger;\n readonly sthis: SuperThis;\n constructor(sthis: SuperThis) {\n this.logger = ensureLogger(sthis, \"IndexDBGateway\");\n this.sthis = sthis;\n }\n\n // _db: IDBPDatabase<unknown> = {} as IDBPDatabase<unknown>;\n\n async start(baseURL: URI): Promise<Result<URI>> {\n return exception2Result(async () => {\n this.logger.Debug().Url(baseURL).Msg(\"starting\");\n await this.sthis.start();\n const ic = await connectIdb(baseURL, this.sthis);\n this.logger.Debug().Url(ic.url).Msg(\"started\");\n return ic.url;\n });\n }\n async close(): Promise<Result<void>> {\n return Result.Ok(undefined);\n }\n async destroy(baseUrl: URI): Promise<Result<void>> {\n return exception2Result(async () => {\n // return deleteDB(getIndexDBName(this.url).fullDb);\n const type = getStore(baseUrl, this.sthis, joinDBName).name;\n // console.log(\"IndexDBDataStore:destroy\", type);\n const idb = await connectIdb(baseUrl, this.sthis);\n const trans = idb.db.transaction(type, \"readwrite\");\n const object_store = trans.objectStore(type);\n const toDelete = [];\n for (let cursor = await object_store.openCursor(); cursor; cursor = await cursor.continue()) {\n toDelete.push(cursor.primaryKey);\n }\n for (const key of toDelete) {\n await trans.db.delete(type, key);\n }\n await trans.done;\n });\n }\n\n buildUrl(baseUrl: URI, key: string): Promise<Result<URI>> {\n return Promise.resolve(Result.Ok(baseUrl.build().setParam(\"key\", key).URI()));\n }\n\n async get(url: URI): Promise<bs.GetResult> {\n return exceptionWrapper(async () => {\n const key = getKey(url, this.logger);\n const store = getStore(url, this.sthis, joinDBName).name;\n this.logger.Debug().Url(url).Str(\"key\", key).Str(\"store\", store).Msg(\"getting\");\n const { db } = await connectIdb(url, this.sthis);\n const tx = db.transaction([store], \"readonly\");\n const bytes = await tx.objectStore(store).get(sanitzeKey(key));\n await tx.done;\n if (!bytes) {\n return Result.Err(new NotFoundError(`missing ${key}`));\n }\n return Result.Ok(bytes as Uint8Array);\n });\n }\n async put(url: URI, value: Uint8Array) {\n return exception2Result(async () => {\n const key = getKey(url, this.logger);\n const store = getStore(url, this.sthis, joinDBName).name;\n this.logger.Debug().Url(url).Str(\"key\", key).Str(\"store\", store).Msg(\"putting\");\n const { db } = await connectIdb(url, this.sthis);\n const tx = db.transaction([store], \"readwrite\");\n await tx.objectStore(store).put(value, sanitzeKey(key));\n await tx.done;\n });\n }\n async delete(url: URI) {\n return exception2Result(async () => {\n const key = getKey(url, this.logger);\n const store = getStore(url, this.sthis, joinDBName).name;\n this.logger.Debug().Url(url).Str(\"key\", key).Str(\"store\", store).Msg(\"deleting\");\n const { db } = await connectIdb(url, this.sthis);\n const tx = db.transaction([store], \"readwrite\");\n await tx.objectStore(store).delete(sanitzeKey(key));\n await tx.done;\n return Result.Ok(undefined);\n });\n }\n}\n\n// export class IndexDBDataGateway extends IndexDBGateway {\n// readonly storeType = \"data\";\n// constructor(logger: Logger) {\n// super(ensureLogger(logger, \"IndexDBDataGateway\"));\n// }\n// }\n\n// export class IndexDBWalGateway extends IndexDBGateway {\n// readonly storeType = \"wal\";\n// constructor(logger: Logger) {\n// super(ensureLogger(logger, \"IndexDBWalGateway\"));\n// }\n// }\n// export class IndexDBMetaGateway extends IndexDBGateway {\n// readonly storeType = \"meta\";\n// constructor(logger: Logger) {\n// super(ensureLogger(logger, \"IndexDBMetaGateway\"));\n// }\n// }\n\nexport class IndexDBTestStore implements bs.TestGateway {\n readonly logger: Logger;\n readonly sthis: SuperThis;\n constructor(sthis: SuperThis) {\n this.sthis = sthis;\n this.logger = ensureLogger(sthis, \"IndexDBTestStore\", {});\n }\n async get(url: URI, key: string) {\n const ic = await connectIdb(url, this.sthis);\n const store = getStore(ic.url, this.sthis, joinDBName).name;\n this.logger.Debug().Str(\"key\", key).Str(\"store\", store).Msg(\"getting\");\n let bytes = await ic.db.get(store, sanitzeKey(key));\n this.logger.Debug().Str(\"key\", key).Str(\"store\", store).Int(\"len\", bytes.length).Msg(\"got\");\n if (typeof bytes === \"string\") {\n bytes = this.sthis.txt.encode(bytes);\n }\n return bytes as Uint8Array;\n }\n}\n","export const INDEXDB_VERSION = \"v0.19-indexdb\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAqC;AACrC,oBAAuE;;;ACDhE,IAAM,kBAAkB;;;ADI/B,kBAAgF;AAIhF,SAAS,cAAc,KAAe;AACpC,SAAO,IAAI,MAAM,EAAE,SAAS,WAAW,eAAe,EAAE,IAAI;AAC9D;AASA,SAAS,WAAW,KAA2C;AAC7D,MAAI,IAAI,WAAW,GAAG;AACpB,UAAM,IAAI,CAAC;AAAA,EACb;AACA,SAAO;AACT;AAEA,IAAM,WAAW,IAAI,8BAAyB;AAC9C,eAAe,WAAW,KAAU,OAAoC;AACtE,QAAM,SAAS,eAAe,KAAK,KAAK;AACxC,QAAM,OAAO,MAAM,SAAS,IAAI,OAAO,MAAM,EAAE,KAAK,YAAY;AAC9D,UAAM,KAAK,UAAM,mBAAO,OAAO,QAAQ,GAAG;AAAA,MACxC,QAAQA,KAAI;AACV,SAAC,WAAW,QAAQ,OAAO,QAAQ,YAAY,WAAW,UAAU,EAAE,IAAI,CAAC,UAAU;AACnF,UAAAA,IAAG,kBAAkB,OAAO;AAAA,YAC1B,eAAe;AAAA,UACjB,CAAC;AAAA,QACH,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AACD,UAAM,QAAQ,MAAM,GAAG,IAAI,WAAW,S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,GAAG,EAAE,IAAI,OAAO,GAAG,EAAE,IAAI,SAAS,KAAK,EAAE,IAAI,UAAU;AAC/E,YAAM,EAAE,GAAG,IAAI,MAAM,WAAW,KAAK,KAAK,KAAK;AAC/C,YAAM,KAAK,GAAG,YAAY,CAAC,KAAK,GAAG,WAAW;AAC9C,YAAM,GAAG,YAAY,KAAK,EAAE,OAAO,WAAW,GAAG,CAAC;AAClD,YAAM,GAAG;AACT,aAAO,qBAAO,GAAG,MAAS;AAAA,IAC5B,CAAC;AAAA,EACH;AACF;AAsBO,IAAM,mBAAN,MAAiD;AAAA,EAGtD,YAAY,OAAkB;AAC5B,SAAK,QAAQ;AACb,SAAK,aAAS,0BAAa,OAAO,oBAAoB,CAAC,CAAC;AAAA,EAC1D;AAAA,EACA,MAAM,IAAI,KAAU,KAAa;AAC/B,UAAM,KAAK,MAAM,WAAW,KAAK,KAAK,KAAK;AAC3C,UAAM,YAAQ,sBAAS,GAAG,KAAK,KAAK,OAAO,UAAU,EAAE;AACvD,SAAK,OAAO,MAAM,EAAE,IAAI,OAAO,GAAG,EAAE,IAAI,SAAS,KAAK,EAAE,IAAI,SAAS;AACrE,QAAI,QAAQ,MAAM,GAAG,GAAG,IAAI,OAAO,WAAW,GAAG,CAAC;AAClD,SAAK,OAAO,MAAM,EAAE,IAAI,OAAO,GAAG,EAAE,IAAI,SAAS,KAAK,EAAE,IAAI,OAAO,MAAM,MAAM,EAAE,IAAI,KAAK;AAC1F,QAAI,OAAO,UAAU,UAAU;AAC7B,cAAQ,KAAK,MAAM,IAAI,OAAO,KAAK;AAAA,IACrC;AACA,WAAO;AAAA,EACT;AACF;","names":["db"]}
|
package/web/gateway-impl.d.cts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import { URI, Logger, Result } from '@adviser/cement';
|
2
|
-
import { SuperThis, bs } from '@fireproof/core';
|
3
|
-
|
4
|
-
interface DbName {
|
5
|
-
readonly fullDb: string;
|
6
|
-
readonly objStore: string;
|
7
|
-
readonly connectionKey: string;
|
8
|
-
readonly dbName: string;
|
9
|
-
}
|
10
|
-
declare function getIndexDBName(iurl: URI, sthis: SuperThis): DbName;
|
11
|
-
declare class IndexDBGatewayImpl implements bs.Gateway {
|
12
|
-
readonly logger: Logger;
|
13
|
-
readonly sthis: SuperThis;
|
14
|
-
constructor(sthis: SuperThis);
|
15
|
-
start(baseURL: URI): Promise<Result<URI>>;
|
16
|
-
close(): Promise<Result<void>>;
|
17
|
-
destroy(baseUrl: URI): Promise<Result<void>>;
|
18
|
-
buildUrl(baseUrl: URI, key: string): Promise<Result<URI>>;
|
19
|
-
get(url: URI): Promise<bs.GetResult>;
|
20
|
-
put(url: URI, value: Uint8Array): Promise<Result<void, Error>>;
|
21
|
-
delete(url: URI): Promise<Result<Result<undefined, Error>, Error>>;
|
22
|
-
}
|
23
|
-
declare class IndexDBTestStore implements bs.TestGateway {
|
24
|
-
readonly logger: Logger;
|
25
|
-
readonly sthis: SuperThis;
|
26
|
-
constructor(sthis: SuperThis);
|
27
|
-
get(url: URI, key: string): Promise<Uint8Array<ArrayBufferLike>>;
|
28
|
-
}
|
29
|
-
|
30
|
-
export { type DbName, IndexDBGatewayImpl, IndexDBTestStore, getIndexDBName };
|
31
|
-
declare module '@fireproof/core/web'
|
package/web/gateway-impl.d.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import { URI, Logger, Result } from '@adviser/cement';
|
2
|
-
import { SuperThis, bs } from '@fireproof/core';
|
3
|
-
|
4
|
-
interface DbName {
|
5
|
-
readonly fullDb: string;
|
6
|
-
readonly objStore: string;
|
7
|
-
readonly connectionKey: string;
|
8
|
-
readonly dbName: string;
|
9
|
-
}
|
10
|
-
declare function getIndexDBName(iurl: URI, sthis: SuperThis): DbName;
|
11
|
-
declare class IndexDBGatewayImpl implements bs.Gateway {
|
12
|
-
readonly logger: Logger;
|
13
|
-
readonly sthis: SuperThis;
|
14
|
-
constructor(sthis: SuperThis);
|
15
|
-
start(baseURL: URI): Promise<Result<URI>>;
|
16
|
-
close(): Promise<Result<void>>;
|
17
|
-
destroy(baseUrl: URI): Promise<Result<void>>;
|
18
|
-
buildUrl(baseUrl: URI, key: string): Promise<Result<URI>>;
|
19
|
-
get(url: URI): Promise<bs.GetResult>;
|
20
|
-
put(url: URI, value: Uint8Array): Promise<Result<void, Error>>;
|
21
|
-
delete(url: URI): Promise<Result<Result<undefined, Error>, Error>>;
|
22
|
-
}
|
23
|
-
declare class IndexDBTestStore implements bs.TestGateway {
|
24
|
-
readonly logger: Logger;
|
25
|
-
readonly sthis: SuperThis;
|
26
|
-
constructor(sthis: SuperThis);
|
27
|
-
get(url: URI, key: string): Promise<Uint8Array<ArrayBufferLike>>;
|
28
|
-
}
|
29
|
-
|
30
|
-
export { type DbName, IndexDBGatewayImpl, IndexDBTestStore, getIndexDBName };
|
31
|
-
declare module '@fireproof/core/web'
|