hyperdb-wasm 0.0.26772-dev.wasm.g94d5c8ef → 0.0.26773-dev.wasm.g25ca5c66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +9 -0
- package/dist/browser.js +34 -0
- package/dist/browser_worker.js +19 -0
- package/dist/client.d.ts +2 -0
- package/dist/hyperdb-wasm.cjs +1 -1
- package/dist/hyperdb-wasm.js +1 -1
- package/dist/hyperdb-wasm.wasm.br +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/node.js +34 -0
- package/dist/node_worker.js +18 -0
- package/dist/protocol.d.ts +10 -0
- package/dist/raw.browser.js +20 -0
- package/dist/raw.node.js +20 -0
- package/dist/wasm_bindings.d.ts +3 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface HyperDBClient {
|
|
|
19
19
|
insertArrowIPCFromPath(connection: number, path: string, name: string, schema: string | null, create: boolean, internal?: boolean): Promise<WasmResult>;
|
|
20
20
|
createTemporaryFile(bytes: Uint8Array): Promise<WasmResult>;
|
|
21
21
|
removeFile(path: string): Promise<WasmResult>;
|
|
22
|
+
registerExternalFile(name: string, url: string, size: number): Promise<WasmResult>;
|
|
23
|
+
removeExternalFile(path: string): Promise<WasmResult>;
|
|
22
24
|
pollQuery(query: number): Promise<WasmResult>;
|
|
23
25
|
cancelQuery(query: number): Promise<WasmResult>;
|
|
24
26
|
releaseQuery(query: number): Promise<WasmResult>;
|
|
@@ -33,6 +35,11 @@ export interface ArrowInsertOptions {
|
|
|
33
35
|
export interface DatabaseCreateOptions {
|
|
34
36
|
readonly storage?: 'memory' | 'persistent';
|
|
35
37
|
}
|
|
38
|
+
export interface ExternalFileRegistration {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly url: string;
|
|
41
|
+
readonly size: number;
|
|
42
|
+
}
|
|
36
43
|
export type HyperDBSettingValue = string | number | boolean | null | readonly HyperDBSettingValue[] | {
|
|
37
44
|
readonly [key: string]: HyperDBSettingValue;
|
|
38
45
|
};
|
|
@@ -59,6 +66,8 @@ export declare class HyperDB {
|
|
|
59
66
|
createDatabase(databaseName: string, options?: DatabaseCreateOptions): Promise<void>;
|
|
60
67
|
openDatabase(databaseName: string): Promise<void>;
|
|
61
68
|
listDatabases(): Promise<DatabaseMetadata[]>;
|
|
69
|
+
registerExternalFile(name: string, url: string, size: number): Promise<string>;
|
|
70
|
+
removeExternalFile(path: string): Promise<void>;
|
|
62
71
|
checkpointDatabase(databaseName: string): Promise<void>;
|
|
63
72
|
dropDatabase(databaseName: string): Promise<void>;
|
|
64
73
|
terminate(): Promise<void>;
|
package/dist/browser.js
CHANGED
|
@@ -139,6 +139,12 @@ var init_client = __esm({
|
|
|
139
139
|
removeFile(path) {
|
|
140
140
|
return this.request({ id: this.nextId++, type: "removeFile", path });
|
|
141
141
|
}
|
|
142
|
+
registerExternalFile(name, url, size) {
|
|
143
|
+
return this.request({ id: this.nextId++, type: "registerExternalFile", name, url, size });
|
|
144
|
+
}
|
|
145
|
+
removeExternalFile(path) {
|
|
146
|
+
return this.request({ id: this.nextId++, type: "removeExternalFile", path });
|
|
147
|
+
}
|
|
142
148
|
pollQuery(query) {
|
|
143
149
|
return this.request({ id: this.nextId++, type: "pollQuery", query });
|
|
144
150
|
}
|
|
@@ -12276,6 +12282,34 @@ var HyperDB = class _HyperDB {
|
|
|
12276
12282
|
listDatabases() {
|
|
12277
12283
|
return this.runDatabaseOperation(async () => readDatabasesFromResult(await this.client.listDatabases()));
|
|
12278
12284
|
}
|
|
12285
|
+
async registerExternalFile(name, url, size) {
|
|
12286
|
+
if (!name) throw new Error("External file name must not be empty");
|
|
12287
|
+
if (name.includes("\0")) throw new Error("External file name must not contain NUL");
|
|
12288
|
+
if (name === "." || name === ".." || name.includes("/") || name.includes("\\")) {
|
|
12289
|
+
throw new Error("External file name must be a basename without path separators");
|
|
12290
|
+
}
|
|
12291
|
+
if (!Number.isSafeInteger(size) || size < 0) throw new Error("External file size must be a nonnegative safe integer");
|
|
12292
|
+
let scheme;
|
|
12293
|
+
try {
|
|
12294
|
+
scheme = new URL(url).protocol;
|
|
12295
|
+
} catch {
|
|
12296
|
+
throw new Error("External file URL must use the blob scheme");
|
|
12297
|
+
}
|
|
12298
|
+
if (scheme !== "blob:") throw new Error("External file URL must use the blob scheme");
|
|
12299
|
+
return this.runDatabaseOperation(async () => {
|
|
12300
|
+
const result = await this.client.registerExternalFile(name, url, size);
|
|
12301
|
+
expectOk(result, "register external file");
|
|
12302
|
+
const path = new TextDecoder("utf-8", { fatal: true }).decode(result.payload);
|
|
12303
|
+
if (!/^\/mnt\/files\/[^/]+\/[^/]+$/.test(path)) throw new Error("register external file returned an invalid path");
|
|
12304
|
+
return path;
|
|
12305
|
+
});
|
|
12306
|
+
}
|
|
12307
|
+
async removeExternalFile(path) {
|
|
12308
|
+
if (!path) throw new Error("External file path must not be empty");
|
|
12309
|
+
await this.runDatabaseOperation(async () => {
|
|
12310
|
+
expectOk(await this.client.removeExternalFile(path), "remove external file");
|
|
12311
|
+
});
|
|
12312
|
+
}
|
|
12279
12313
|
async checkpointDatabase(databaseName) {
|
|
12280
12314
|
validateDatabaseName(databaseName);
|
|
12281
12315
|
await this.runDatabaseOperation(async () => {
|
package/dist/browser_worker.js
CHANGED
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
checkpointDatabase;
|
|
23
23
|
dropDatabase;
|
|
24
24
|
shutdown;
|
|
25
|
+
registerExternalFile;
|
|
26
|
+
removeExternalFile;
|
|
25
27
|
attachDatabase;
|
|
26
28
|
detachDatabase;
|
|
27
29
|
startQuery;
|
|
@@ -44,6 +46,8 @@
|
|
|
44
46
|
this.checkpointDatabase = module.cwrap("hyperdb_wasm_checkpoint_database", "pointer", ["string"]);
|
|
45
47
|
this.dropDatabase = module.cwrap("hyperdb_wasm_drop_database", "pointer", ["string"]);
|
|
46
48
|
this.shutdown = module.cwrap("hyperdb_wasm_shutdown", "pointer", []);
|
|
49
|
+
this.registerExternalFile = module.cwrap("hyperdb_wasm_register_external_file", "pointer", ["string", "string", "number"]);
|
|
50
|
+
this.removeExternalFile = module.cwrap("hyperdb_wasm_remove_external_file", "pointer", ["string"]);
|
|
47
51
|
this.attachDatabase = module.cwrap("hyperdb_wasm_attach_database", "pointer", ["number", "string", "string"]);
|
|
48
52
|
this.detachDatabase = module.cwrap("hyperdb_wasm_detach_database", "pointer", ["number", "string"]);
|
|
49
53
|
this.startQuery = module.cwrap("hyperdb_wasm_query_start", "pointer", ["number", "string"]);
|
|
@@ -66,6 +70,9 @@
|
|
|
66
70
|
this.module.FS.unlink(request.path);
|
|
67
71
|
return { response: { id: request.id, type: "response", result: { state: "ok", payload: new Uint8Array() } }, transfer: [] };
|
|
68
72
|
}
|
|
73
|
+
if ((request.type === "registerExternalFile" || request.type === "removeExternalFile") && !this.module.externalFileBackendAvailable) {
|
|
74
|
+
return { response: { id: request.id, type: "response", result: { state: "error", error: "External files are supported only by the browser client" } }, transfer: [] };
|
|
75
|
+
}
|
|
69
76
|
const pointer = safeInteger(this.invoke(request), "result pointer");
|
|
70
77
|
const result = this.decodeResult(pointer);
|
|
71
78
|
const response = { id: request.id, type: "response", result };
|
|
@@ -103,6 +110,13 @@
|
|
|
103
110
|
return this.detachDatabase(request.connection, request.alias);
|
|
104
111
|
case "shutdown":
|
|
105
112
|
return this.shutdown();
|
|
113
|
+
case "registerExternalFile":
|
|
114
|
+
validateCString(request.name, "external file name");
|
|
115
|
+
validateCString(request.url, "external file URL");
|
|
116
|
+
return this.registerExternalFile(request.name, request.url, safeInteger(request.size, "external file size"));
|
|
117
|
+
case "removeExternalFile":
|
|
118
|
+
validateCString(request.path, "external file path");
|
|
119
|
+
return this.removeExternalFile(request.path);
|
|
106
120
|
case "startQuery":
|
|
107
121
|
return this.startQuery(request.connection, request.sql);
|
|
108
122
|
case "insertArrowIPCFromPath": {
|
|
@@ -190,6 +204,10 @@
|
|
|
190
204
|
return hasKeys(value, ["id", "type", "bytes"]) && value.bytes instanceof Uint8Array;
|
|
191
205
|
case "removeFile":
|
|
192
206
|
return hasKeys(value, ["id", "type", "path"]) && typeof value.path === "string";
|
|
207
|
+
case "registerExternalFile":
|
|
208
|
+
return hasKeys(value, ["id", "type", "name", "url", "size"]) && typeof value.name === "string" && typeof value.url === "string" && typeof value.size === "number" && Number.isSafeInteger(value.size) && value.size >= 0;
|
|
209
|
+
case "removeExternalFile":
|
|
210
|
+
return hasKeys(value, ["id", "type", "path"]) && typeof value.path === "string";
|
|
193
211
|
case "pollQuery":
|
|
194
212
|
case "cancelQuery":
|
|
195
213
|
case "releaseQuery":
|
|
@@ -356,6 +374,7 @@
|
|
|
356
374
|
};
|
|
357
375
|
self.Module = module;
|
|
358
376
|
configureWorker(module, transport, (runtime) => {
|
|
377
|
+
runtime.externalFileBackendAvailable = true;
|
|
359
378
|
if (!runtime.OPFS) throw new Error("OPFS backend is unavailable");
|
|
360
379
|
runtime.FS.mkdirTree("/opfs");
|
|
361
380
|
runtime.FS.mount(runtime.OPFS, {}, "/opfs");
|
package/dist/client.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export declare class HyperDBEngineClient {
|
|
|
26
26
|
insertArrowIPCFromPath(connection: number, path: string, name: string, schema: string | null, create: boolean, internal?: boolean): Promise<WasmResult>;
|
|
27
27
|
createTemporaryFile(bytes: Uint8Array): Promise<WasmResult>;
|
|
28
28
|
removeFile(path: string): Promise<WasmResult>;
|
|
29
|
+
registerExternalFile(name: string, url: string, size: number): Promise<WasmResult>;
|
|
30
|
+
removeExternalFile(path: string): Promise<WasmResult>;
|
|
29
31
|
pollQuery(query: number): Promise<WasmResult>;
|
|
30
32
|
cancelQuery(query: number): Promise<WasmResult>;
|
|
31
33
|
releaseQuery(query: number): Promise<WasmResult>;
|