hyperdb-wasm 0.0.26862-dev.wasm.g42f1012b → 0.0.26862-dev.wasm.g89537caa
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 +2 -26
- package/dist/browser.d.ts +3 -1
- package/dist/browser.js +12 -147
- package/dist/browser_worker.js +29 -81
- package/dist/client.d.ts +1 -10
- 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/index.node.d.ts +1 -1
- package/dist/node.d.ts +1 -0
- package/dist/node.js +12 -147
- package/dist/node_worker.js +11 -69
- package/dist/protocol.d.ts +1 -41
- package/dist/raw.browser.js +11 -80
- package/dist/raw.node.js +8 -78
- package/dist/wasm_bindings.d.ts +2 -10
- package/examples/node-attached-databases.mjs +10 -9
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -985,36 +985,12 @@ var init_client = __esm({
|
|
|
985
985
|
disconnect(connection) {
|
|
986
986
|
return this.request({ id: this.nextId++, type: "disconnect", connection });
|
|
987
987
|
}
|
|
988
|
-
createDatabase(databaseName, persistent) {
|
|
989
|
-
return this.request({ id: this.nextId++, type: "createDatabase", databaseName, persistent });
|
|
990
|
-
}
|
|
991
|
-
openDatabase(databaseName) {
|
|
992
|
-
return this.request({ id: this.nextId++, type: "openDatabase", databaseName });
|
|
993
|
-
}
|
|
994
|
-
listDatabases() {
|
|
995
|
-
return this.request({ id: this.nextId++, type: "listDatabases" });
|
|
996
|
-
}
|
|
997
|
-
checkpointDatabase(databaseName) {
|
|
998
|
-
return this.request({ id: this.nextId++, type: "checkpointDatabase", databaseName });
|
|
999
|
-
}
|
|
1000
|
-
dropDatabase(databaseName) {
|
|
1001
|
-
return this.request({ id: this.nextId++, type: "dropDatabase", databaseName });
|
|
1002
|
-
}
|
|
1003
|
-
attachDatabase(connection, databaseName, alias) {
|
|
1004
|
-
return this.request({ id: this.nextId++, type: "attachDatabase", connection, databaseName, alias });
|
|
1005
|
-
}
|
|
1006
|
-
detachDatabase(connection, alias) {
|
|
1007
|
-
return this.request({ id: this.nextId++, type: "detachDatabase", connection, alias });
|
|
1008
|
-
}
|
|
1009
988
|
shutdown() {
|
|
1010
989
|
return this.request({ id: this.nextId++, type: "shutdown" });
|
|
1011
990
|
}
|
|
1012
991
|
startQuery(connection, sql, sqlTestMode = false) {
|
|
1013
992
|
return this.request({ id: this.nextId++, type: "startQuery", connection, sql, ...sqlTestMode && { sqlTestMode } });
|
|
1014
993
|
}
|
|
1015
|
-
startQueryWithInfo(connection, sql) {
|
|
1016
|
-
return this.request({ id: this.nextId++, type: "startQueryWithInfo", connection, sql });
|
|
1017
|
-
}
|
|
1018
994
|
insertArrowIPCFromPath(connection, path, name, schema, create, internal = false) {
|
|
1019
995
|
return this.request({ id: this.nextId++, type: "insertArrowIPCFromPath", connection, path, name, schema, create, internal });
|
|
1020
996
|
}
|
|
@@ -1040,11 +1016,8 @@ var init_client = __esm({
|
|
|
1040
1016
|
cancelQuery(query) {
|
|
1041
1017
|
return this.request({ id: this.nextId++, type: "cancelQuery", query });
|
|
1042
1018
|
}
|
|
1043
|
-
|
|
1044
|
-
return this.request({ id: this.nextId++, type: "
|
|
1045
|
-
}
|
|
1046
|
-
releaseQueryWithInfo(query) {
|
|
1047
|
-
return this.request({ id: this.nextId++, type: "releaseQueryWithInfo", query });
|
|
1019
|
+
finishQuery(query) {
|
|
1020
|
+
return this.request({ id: this.nextId++, type: "finishQuery", query });
|
|
1048
1021
|
}
|
|
1049
1022
|
async terminate() {
|
|
1050
1023
|
await this.transport.terminate();
|
|
@@ -1137,10 +1110,11 @@ function assertBrowserSupport(environment = globalThis) {
|
|
|
1137
1110
|
throw new Error("HyperDB cannot initialize because this browser does not support the origin-private file system");
|
|
1138
1111
|
}
|
|
1139
1112
|
}
|
|
1140
|
-
function resolveBrowserWorkerUrl(workerUrl, engineUrl, wasmUrl) {
|
|
1113
|
+
function resolveBrowserWorkerUrl(workerUrl, engineUrl, wasmUrl, storagePath) {
|
|
1141
1114
|
const resolved = new URL(workerUrl);
|
|
1142
1115
|
resolved.searchParams.set("engineUrl", new URL(engineUrl).href);
|
|
1143
1116
|
if (wasmUrl != null) resolved.searchParams.set("wasmUrl", new URL(wasmUrl).href);
|
|
1117
|
+
if (storagePath != null) resolved.searchParams.set("storagePath", storagePath);
|
|
1144
1118
|
return resolved;
|
|
1145
1119
|
}
|
|
1146
1120
|
function createBrowserClient(options = {}) {
|
|
@@ -1148,7 +1122,7 @@ function createBrowserClient(options = {}) {
|
|
|
1148
1122
|
const workerUrl = options.workerUrl ?? new URL("./browser_worker.js", import.meta.url);
|
|
1149
1123
|
const engineUrl = options.engineUrl ?? new URL("./hyperdb-wasm.js", import.meta.url);
|
|
1150
1124
|
return new HyperDBEngineClient(
|
|
1151
|
-
new BrowserWorker(new Worker(resolveBrowserWorkerUrl(workerUrl, engineUrl, options.wasmUrl), { type: "classic" })),
|
|
1125
|
+
new BrowserWorker(new Worker(resolveBrowserWorkerUrl(workerUrl, engineUrl, options.wasmUrl, options.storagePath), { type: "classic" })),
|
|
1152
1126
|
options.onSetupProgress
|
|
1153
1127
|
);
|
|
1154
1128
|
}
|
|
@@ -12335,7 +12309,6 @@ var HyperDBError = class extends Error {
|
|
|
12335
12309
|
this.hint = hint;
|
|
12336
12310
|
}
|
|
12337
12311
|
};
|
|
12338
|
-
var maxPersistentDatabaseNameLength = 200;
|
|
12339
12312
|
function deferred() {
|
|
12340
12313
|
let resolve;
|
|
12341
12314
|
let reject;
|
|
@@ -12391,26 +12364,6 @@ function normalizeArrowInsertOptions(options) {
|
|
|
12391
12364
|
if (!options.name) throw new Error("Arrow insert table name must not be empty");
|
|
12392
12365
|
return { name: options.name, schema: options.schema ?? null, create: options.create ?? true };
|
|
12393
12366
|
}
|
|
12394
|
-
function validateDatabaseName(databaseName) {
|
|
12395
|
-
if (!databaseName) throw new Error("Database name must not be empty");
|
|
12396
|
-
if (databaseName.includes("\0")) throw new Error("Database name must not contain NUL");
|
|
12397
|
-
}
|
|
12398
|
-
function validatePersistentDatabaseName(databaseName) {
|
|
12399
|
-
validateDatabaseName(databaseName);
|
|
12400
|
-
if (databaseName.length > maxPersistentDatabaseNameLength) {
|
|
12401
|
-
throw new Error(`Persistent database name must be at most ${maxPersistentDatabaseNameLength} characters`);
|
|
12402
|
-
}
|
|
12403
|
-
if (!/^[a-z0-9][a-z0-9_-]*$/.test(databaseName)) {
|
|
12404
|
-
throw new Error("Persistent database name must start with a lowercase ASCII letter or digit and contain only lowercase ASCII letters, digits, hyphens, and underscores");
|
|
12405
|
-
}
|
|
12406
|
-
if (/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(databaseName)) {
|
|
12407
|
-
throw new Error("Persistent database name is reserved by Windows");
|
|
12408
|
-
}
|
|
12409
|
-
}
|
|
12410
|
-
function validateDatabaseAlias(alias) {
|
|
12411
|
-
if (!alias) throw new Error("Database alias must not be empty");
|
|
12412
|
-
if (alias.includes("\0")) throw new Error("Database alias must not contain NUL");
|
|
12413
|
-
}
|
|
12414
12367
|
function materializeDictionaryColumns(table) {
|
|
12415
12368
|
const dictionaryColumns = table.schema.fields.map((field, index) => DataType.isDictionary(field.type) ? index : -1).filter((index) => index !== -1);
|
|
12416
12369
|
if (dictionaryColumns.length === 0) return table;
|
|
@@ -12451,34 +12404,6 @@ async function initializeHyperDB(client, settings) {
|
|
|
12451
12404
|
if (serialized === void 0) throw new Error("HyperDB settings must be JSON-serializable");
|
|
12452
12405
|
expectOk(await client.initialize(serialized), "initialize HyperDB settings");
|
|
12453
12406
|
}
|
|
12454
|
-
function readDatabasesFromResult(result) {
|
|
12455
|
-
expectOk(result, "list databases");
|
|
12456
|
-
const invalidResult = () => new Error("list databases returned invalid metadata");
|
|
12457
|
-
if (result.payload.byteLength < 4) throw invalidResult();
|
|
12458
|
-
const view = new DataView(result.payload.buffer, result.payload.byteOffset, result.payload.byteLength);
|
|
12459
|
-
const count = view.getUint32(0, true);
|
|
12460
|
-
let offset = 4;
|
|
12461
|
-
const databases = [];
|
|
12462
|
-
const decoder2 = new TextDecoder("utf-8", { fatal: true });
|
|
12463
|
-
for (let index = 0; index < count; ++index) {
|
|
12464
|
-
if (offset + 8 > result.payload.byteLength) throw invalidResult();
|
|
12465
|
-
const rawStorage = view.getUint32(offset, true);
|
|
12466
|
-
const nameLength = view.getUint32(offset + 4, true);
|
|
12467
|
-
offset += 8;
|
|
12468
|
-
if (nameLength > result.payload.byteLength - offset) throw invalidResult();
|
|
12469
|
-
let name;
|
|
12470
|
-
try {
|
|
12471
|
-
name = decoder2.decode(result.payload.subarray(offset, offset + nameLength));
|
|
12472
|
-
} catch {
|
|
12473
|
-
throw invalidResult();
|
|
12474
|
-
}
|
|
12475
|
-
if (!name || name.includes("\0") || rawStorage !== 0 && rawStorage !== 1) throw invalidResult();
|
|
12476
|
-
databases.push({ name, storage: rawStorage === 0 ? "transient" : "persistent" });
|
|
12477
|
-
offset += nameLength;
|
|
12478
|
-
}
|
|
12479
|
-
if (offset !== result.payload.byteLength) throw invalidResult();
|
|
12480
|
-
return databases;
|
|
12481
|
-
}
|
|
12482
12407
|
function yieldToEventLoop() {
|
|
12483
12408
|
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
12484
12409
|
}
|
|
@@ -12518,25 +12443,6 @@ var HyperDB = class _HyperDB {
|
|
|
12518
12443
|
this.connections.add(result);
|
|
12519
12444
|
return result;
|
|
12520
12445
|
}
|
|
12521
|
-
async createDatabase(databaseName, options = {}) {
|
|
12522
|
-
validateDatabaseName(databaseName);
|
|
12523
|
-
if (options.storage !== void 0 && options.storage !== "transient" && options.storage !== "persistent") {
|
|
12524
|
-
throw new Error(`Unsupported database storage: ${String(options.storage)}`);
|
|
12525
|
-
}
|
|
12526
|
-
if (options.storage === "persistent") validatePersistentDatabaseName(databaseName);
|
|
12527
|
-
await this.runDatabaseOperation(async () => {
|
|
12528
|
-
expectOk(await this.client.createDatabase(databaseName, options.storage === "persistent"), "create database");
|
|
12529
|
-
});
|
|
12530
|
-
}
|
|
12531
|
-
async openDatabase(databaseName) {
|
|
12532
|
-
validatePersistentDatabaseName(databaseName);
|
|
12533
|
-
await this.runDatabaseOperation(async () => {
|
|
12534
|
-
expectOk(await this.client.openDatabase(databaseName), "open database");
|
|
12535
|
-
});
|
|
12536
|
-
}
|
|
12537
|
-
listDatabases() {
|
|
12538
|
-
return this.runDatabaseOperation(async () => readDatabasesFromResult(await this.client.listDatabases()));
|
|
12539
|
-
}
|
|
12540
12446
|
async registerExternalFile(...args) {
|
|
12541
12447
|
if (args.length === 1) {
|
|
12542
12448
|
const [sourcePath] = args;
|
|
@@ -12588,18 +12494,6 @@ var HyperDB = class _HyperDB {
|
|
|
12588
12494
|
return path;
|
|
12589
12495
|
});
|
|
12590
12496
|
}
|
|
12591
|
-
async checkpointDatabase(databaseName) {
|
|
12592
|
-
validateDatabaseName(databaseName);
|
|
12593
|
-
await this.runDatabaseOperation(async () => {
|
|
12594
|
-
expectOk(await this.client.checkpointDatabase(databaseName), "checkpoint database");
|
|
12595
|
-
});
|
|
12596
|
-
}
|
|
12597
|
-
async dropDatabase(databaseName) {
|
|
12598
|
-
validateDatabaseName(databaseName);
|
|
12599
|
-
await this.runDatabaseOperation(async () => {
|
|
12600
|
-
expectOk(await this.client.dropDatabase(databaseName), "drop database");
|
|
12601
|
-
});
|
|
12602
|
-
}
|
|
12603
12497
|
async terminate() {
|
|
12604
12498
|
if (this.terminated) return;
|
|
12605
12499
|
if (this.activeDatabaseOperations !== 0) throw new Error("database has an active operation");
|
|
@@ -12671,25 +12565,6 @@ var HyperDBConnection = class {
|
|
|
12671
12565
|
}
|
|
12672
12566
|
await this.closing;
|
|
12673
12567
|
}
|
|
12674
|
-
async attachDatabase(databaseName, alias = databaseName) {
|
|
12675
|
-
validateDatabaseName(databaseName);
|
|
12676
|
-
validateDatabaseAlias(alias);
|
|
12677
|
-
this.ensureAvailable();
|
|
12678
|
-
try {
|
|
12679
|
-
expectOk(await this.client.attachDatabase(this.connection, databaseName, alias), "attach database");
|
|
12680
|
-
} finally {
|
|
12681
|
-
this.active = false;
|
|
12682
|
-
}
|
|
12683
|
-
}
|
|
12684
|
-
async detachDatabase(alias) {
|
|
12685
|
-
validateDatabaseAlias(alias);
|
|
12686
|
-
this.ensureAvailable();
|
|
12687
|
-
try {
|
|
12688
|
-
expectOk(await this.client.detachDatabase(this.connection, alias), "detach database");
|
|
12689
|
-
} finally {
|
|
12690
|
-
this.active = false;
|
|
12691
|
-
}
|
|
12692
|
-
}
|
|
12693
12568
|
sendIPC(sql) {
|
|
12694
12569
|
const connection = this;
|
|
12695
12570
|
const queryInfo = deferred();
|
|
@@ -12701,7 +12576,7 @@ var HyperDBConnection = class {
|
|
|
12701
12576
|
try {
|
|
12702
12577
|
connection.ensureAvailable();
|
|
12703
12578
|
acquired = true;
|
|
12704
|
-
query = readHandleFromResult(await connection.client.
|
|
12579
|
+
query = readHandleFromResult(await connection.client.startQuery(connection.connection, sql), "start query");
|
|
12705
12580
|
for (; ; ) {
|
|
12706
12581
|
let result2 = prefetched ? await prefetched : await connection.client.pollQuery(query);
|
|
12707
12582
|
prefetched = void 0;
|
|
@@ -12743,7 +12618,7 @@ var HyperDBConnection = class {
|
|
|
12743
12618
|
}
|
|
12744
12619
|
}
|
|
12745
12620
|
try {
|
|
12746
|
-
info = await connection.
|
|
12621
|
+
info = decodeQueryInfo(await connection.finishQuery(query));
|
|
12747
12622
|
} catch (error) {
|
|
12748
12623
|
cleanupError ??= error;
|
|
12749
12624
|
}
|
|
@@ -12836,7 +12711,7 @@ var HyperDBConnection = class {
|
|
|
12836
12711
|
}
|
|
12837
12712
|
} finally {
|
|
12838
12713
|
try {
|
|
12839
|
-
if (query !== void 0) await this.
|
|
12714
|
+
if (query !== void 0) await this.finishQuery(query);
|
|
12840
12715
|
} finally {
|
|
12841
12716
|
if (acquire) this.active = false;
|
|
12842
12717
|
}
|
|
@@ -12850,22 +12725,12 @@ var HyperDBConnection = class {
|
|
|
12850
12725
|
}
|
|
12851
12726
|
this.active = true;
|
|
12852
12727
|
}
|
|
12853
|
-
async
|
|
12854
|
-
let delay = 1;
|
|
12855
|
-
for (; ; ) {
|
|
12856
|
-
const result = await this.client.releaseQuery(query);
|
|
12857
|
-
if (result.state === "ok") return;
|
|
12858
|
-
if (result.state !== "pending") throw readErrorFromResult(result, "release query");
|
|
12859
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
12860
|
-
delay = Math.min(delay * 2, 32);
|
|
12861
|
-
}
|
|
12862
|
-
}
|
|
12863
|
-
async releaseWithInfo(query) {
|
|
12728
|
+
async finishQuery(query) {
|
|
12864
12729
|
let delay = 1;
|
|
12865
12730
|
for (; ; ) {
|
|
12866
|
-
const result = await this.client.
|
|
12867
|
-
if (result.state === "ok") return
|
|
12868
|
-
if (result.state !== "pending") throw readErrorFromResult(result, "
|
|
12731
|
+
const result = await this.client.finishQuery(query);
|
|
12732
|
+
if (result.state === "ok") return result.payload;
|
|
12733
|
+
if (result.state !== "pending") throw readErrorFromResult(result, "finish query");
|
|
12869
12734
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
12870
12735
|
delay = Math.min(delay * 2, 32);
|
|
12871
12736
|
}
|
package/dist/node_worker.js
CHANGED
|
@@ -57,51 +57,33 @@ var HyperDBBindings = class {
|
|
|
57
57
|
initialize;
|
|
58
58
|
connect;
|
|
59
59
|
disconnect;
|
|
60
|
-
createDatabase;
|
|
61
|
-
openDatabase;
|
|
62
|
-
listDatabases;
|
|
63
|
-
checkpointDatabase;
|
|
64
|
-
dropDatabase;
|
|
65
60
|
shutdown;
|
|
66
61
|
registerExternalFile;
|
|
67
62
|
registerExternalDirectory;
|
|
68
63
|
removeExternalRegistration;
|
|
69
|
-
attachDatabase;
|
|
70
|
-
detachDatabase;
|
|
71
64
|
startQuery;
|
|
72
|
-
startQueryWithInfo;
|
|
73
65
|
insertArrowIPCFromPath;
|
|
74
66
|
pollQuery;
|
|
75
67
|
cancelQuery;
|
|
76
|
-
|
|
77
|
-
releaseQueryWithInfo;
|
|
68
|
+
finishQuery;
|
|
78
69
|
resultState;
|
|
79
70
|
resultPayloadLength;
|
|
80
71
|
free;
|
|
81
72
|
nextTemporaryFile = 1;
|
|
82
73
|
constructor(module2) {
|
|
83
74
|
this.module = module2;
|
|
84
|
-
this.initialize = module2.cwrap("hyperdb_wasm_initialize", "pointer", ["string"]);
|
|
75
|
+
this.initialize = module2.cwrap("hyperdb_wasm_initialize", "pointer", ["string", "string"]);
|
|
85
76
|
this.connect = module2.cwrap("hyperdb_wasm_connect", "pointer", []);
|
|
86
77
|
this.disconnect = module2.cwrap("hyperdb_wasm_disconnect", "pointer", ["number"]);
|
|
87
|
-
this.createDatabase = module2.cwrap("hyperdb_wasm_create_database", "pointer", ["string", "number"]);
|
|
88
|
-
this.openDatabase = module2.cwrap("hyperdb_wasm_open_database", "pointer", ["string"]);
|
|
89
|
-
this.listDatabases = module2.cwrap("hyperdb_wasm_list_databases", "pointer", []);
|
|
90
|
-
this.checkpointDatabase = module2.cwrap("hyperdb_wasm_checkpoint_database", "pointer", ["string"]);
|
|
91
|
-
this.dropDatabase = module2.cwrap("hyperdb_wasm_drop_database", "pointer", ["string"]);
|
|
92
78
|
this.shutdown = module2.cwrap("hyperdb_wasm_shutdown", "pointer", []);
|
|
93
79
|
this.registerExternalFile = module2.cwrap("hyperdb_wasm_register_external_file", "pointer", ["string", "string", "number"]);
|
|
94
80
|
this.registerExternalDirectory = module2.cwrap("hyperdb_wasm_register_external_directory", "pointer", ["string", "string", "number"]);
|
|
95
81
|
this.removeExternalRegistration = module2.cwrap("hyperdb_wasm_remove_external_registration", "pointer", ["string"]);
|
|
96
|
-
this.attachDatabase = module2.cwrap("hyperdb_wasm_attach_database", "pointer", ["number", "string", "string"]);
|
|
97
|
-
this.detachDatabase = module2.cwrap("hyperdb_wasm_detach_database", "pointer", ["number", "string"]);
|
|
98
82
|
this.startQuery = module2.cwrap("hyperdb_wasm_query_start", "pointer", ["number", "string", "number"]);
|
|
99
|
-
this.startQueryWithInfo = module2.cwrap("hyperdb_wasm_query_start_with_info", "pointer", ["number", "string"]);
|
|
100
83
|
this.insertArrowIPCFromPath = module2.cwrap("hyperdb_wasm_arrow_insert_from_path", "pointer", ["number", "string", "string", "string", "number"]);
|
|
101
84
|
this.pollQuery = module2.cwrap("hyperdb_wasm_query_poll", "pointer", ["number"]);
|
|
102
85
|
this.cancelQuery = module2.cwrap("hyperdb_wasm_query_cancel", "pointer", ["number"]);
|
|
103
|
-
this.
|
|
104
|
-
this.releaseQueryWithInfo = module2.cwrap("hyperdb_wasm_query_release_with_info", "pointer", ["number"]);
|
|
86
|
+
this.finishQuery = module2.cwrap("hyperdb_wasm_query_finish", "pointer", ["number"]);
|
|
105
87
|
this.resultState = module2.cwrap("hyperdb_wasm_result_state", "number", ["number"]);
|
|
106
88
|
this.resultPayloadLength = module2.cwrap("hyperdb_wasm_result_payload_len", "number", ["number"]);
|
|
107
89
|
this.free = module2.cwrap("hyperdb_wasm_free", null, ["pointer"]);
|
|
@@ -210,32 +192,11 @@ var HyperDBBindings = class {
|
|
|
210
192
|
switch (request.type) {
|
|
211
193
|
case "initialize":
|
|
212
194
|
validateCString(request.settings, "settings");
|
|
213
|
-
return this.initialize(request.settings);
|
|
195
|
+
return this.initialize(request.settings, this.module.hyperdbWasmStoragePath ?? "");
|
|
214
196
|
case "connect":
|
|
215
197
|
return this.connect();
|
|
216
198
|
case "disconnect":
|
|
217
199
|
return this.disconnect(request.connection);
|
|
218
|
-
case "createDatabase":
|
|
219
|
-
validateCString(request.databaseName, "database name");
|
|
220
|
-
return this.createDatabase(request.databaseName, Number(request.persistent));
|
|
221
|
-
case "openDatabase":
|
|
222
|
-
validateCString(request.databaseName, "database name");
|
|
223
|
-
return this.openDatabase(request.databaseName);
|
|
224
|
-
case "listDatabases":
|
|
225
|
-
return this.listDatabases();
|
|
226
|
-
case "checkpointDatabase":
|
|
227
|
-
validateCString(request.databaseName, "database name");
|
|
228
|
-
return this.checkpointDatabase(request.databaseName);
|
|
229
|
-
case "dropDatabase":
|
|
230
|
-
validateCString(request.databaseName, "database name");
|
|
231
|
-
return this.dropDatabase(request.databaseName);
|
|
232
|
-
case "attachDatabase":
|
|
233
|
-
validateCString(request.databaseName, "database name");
|
|
234
|
-
validateCString(request.alias, "database alias");
|
|
235
|
-
return this.attachDatabase(request.connection, request.databaseName, request.alias);
|
|
236
|
-
case "detachDatabase":
|
|
237
|
-
validateCString(request.alias, "database alias");
|
|
238
|
-
return this.detachDatabase(request.connection, request.alias);
|
|
239
200
|
case "shutdown":
|
|
240
201
|
return this.shutdown();
|
|
241
202
|
case "registerExternalFile":
|
|
@@ -250,8 +211,6 @@ var HyperDBBindings = class {
|
|
|
250
211
|
return this.removeExternalRegistration(request.path);
|
|
251
212
|
case "startQuery":
|
|
252
213
|
return this.startQuery(request.connection, request.sql, Number(request.sqlTestMode ?? false));
|
|
253
|
-
case "startQueryWithInfo":
|
|
254
|
-
return this.startQueryWithInfo(request.connection, request.sql);
|
|
255
214
|
case "insertArrowIPCFromPath": {
|
|
256
215
|
const path = request.internal ? request.path : this.module.resolveHyperDBPath?.(request.path) ?? request.path;
|
|
257
216
|
return this.insertArrowIPCFromPath(request.connection, path, request.name, request.schema ?? "", Number(request.create));
|
|
@@ -260,10 +219,8 @@ var HyperDBBindings = class {
|
|
|
260
219
|
return this.pollQuery(request.query);
|
|
261
220
|
case "cancelQuery":
|
|
262
221
|
return this.cancelQuery(request.query);
|
|
263
|
-
case "
|
|
264
|
-
return this.
|
|
265
|
-
case "releaseQueryWithInfo":
|
|
266
|
-
return this.releaseQueryWithInfo(request.query);
|
|
222
|
+
case "finishQuery":
|
|
223
|
+
return this.finishQuery(request.query);
|
|
267
224
|
}
|
|
268
225
|
}
|
|
269
226
|
decodeResult(pointer) {
|
|
@@ -317,26 +274,13 @@ function isEngineRequest(value) {
|
|
|
317
274
|
case "initialize":
|
|
318
275
|
return hasKeys(value, ["id", "type", "settings"]) && typeof value.settings === "string";
|
|
319
276
|
case "connect":
|
|
320
|
-
case "listDatabases":
|
|
321
277
|
return hasKeys(value, ["id", "type"]);
|
|
322
278
|
case "disconnect":
|
|
323
279
|
return hasKeys(value, ["id", "type", "connection"]) && Number.isSafeInteger(value.connection);
|
|
324
|
-
case "createDatabase":
|
|
325
|
-
return hasKeys(value, ["id", "type", "databaseName", "persistent"]) && typeof value.databaseName === "string" && typeof value.persistent === "boolean";
|
|
326
|
-
case "openDatabase":
|
|
327
|
-
case "checkpointDatabase":
|
|
328
|
-
case "dropDatabase":
|
|
329
|
-
return hasKeys(value, ["id", "type", "databaseName"]) && typeof value.databaseName === "string";
|
|
330
280
|
case "shutdown":
|
|
331
281
|
return hasKeys(value, ["id", "type"]);
|
|
332
|
-
case "attachDatabase":
|
|
333
|
-
return hasKeys(value, ["id", "type", "connection", "databaseName", "alias"]) && Number.isSafeInteger(value.connection) && typeof value.databaseName === "string" && typeof value.alias === "string";
|
|
334
|
-
case "detachDatabase":
|
|
335
|
-
return hasKeys(value, ["id", "type", "connection", "alias"]) && Number.isSafeInteger(value.connection) && typeof value.alias === "string";
|
|
336
282
|
case "startQuery":
|
|
337
283
|
return (hasKeys(value, ["id", "type", "connection", "sql"]) || hasKeys(value, ["id", "type", "connection", "sql", "sqlTestMode"])) && Number.isSafeInteger(value.connection) && typeof value.sql === "string" && (value.sqlTestMode === void 0 || typeof value.sqlTestMode === "boolean");
|
|
338
|
-
case "startQueryWithInfo":
|
|
339
|
-
return hasKeys(value, ["id", "type", "connection", "sql"]) && Number.isSafeInteger(value.connection) && typeof value.sql === "string";
|
|
340
284
|
case "insertArrowIPCFromPath":
|
|
341
285
|
return hasKeys(value, ["id", "type", "connection", "path", "name", "schema", "create", "internal"]) && Number.isSafeInteger(value.connection) && typeof value.path === "string" && typeof value.name === "string" && (typeof value.schema === "string" || value.schema === null) && typeof value.create === "boolean" && typeof value.internal === "boolean";
|
|
342
286
|
case "createTemporaryFile":
|
|
@@ -351,8 +295,7 @@ function isEngineRequest(value) {
|
|
|
351
295
|
return hasKeys(value, ["id", "type", "path"]) && typeof value.path === "string";
|
|
352
296
|
case "pollQuery":
|
|
353
297
|
case "cancelQuery":
|
|
354
|
-
case "
|
|
355
|
-
case "releaseQueryWithInfo":
|
|
298
|
+
case "finishQuery":
|
|
356
299
|
return hasKeys(value, ["id", "type", "query"]) && Number.isSafeInteger(value.query);
|
|
357
300
|
default:
|
|
358
301
|
return false;
|
|
@@ -934,10 +877,9 @@ configureWorker(module, transport, (runtime) => {
|
|
|
934
877
|
if (!runtime.NODEFS) throw new Error("Node filesystem backend is unavailable");
|
|
935
878
|
const nodeFS = runtime.NODEFS;
|
|
936
879
|
runtime.FS.mkdirTree("/host");
|
|
937
|
-
runtime.FS.mkdirTree("/
|
|
938
|
-
runtime.FS.mount(nodeFS, { root: storagePath }, "/
|
|
939
|
-
runtime.FS.mkdirTree("/
|
|
940
|
-
runtime.FS.mkdirTree("/hyperdb-persistent/logs");
|
|
880
|
+
runtime.FS.mkdirTree("/mnt/fs");
|
|
881
|
+
runtime.FS.mount(nodeFS, { root: storagePath }, "/mnt/fs");
|
|
882
|
+
runtime.FS.mkdirTree("/mnt/fs/logs");
|
|
941
883
|
const nodeRuntimeFS = runtime.FS;
|
|
942
884
|
const shouldAccessHostPath = (path) => isAbsolute2(path) && !nodeRuntimeFS.analyzePath(path).exists;
|
|
943
885
|
runtime.hyperdbWasmShouldOpenHostFile = shouldAccessHostPath;
|
|
@@ -1047,7 +989,7 @@ configureWorker(module, transport, (runtime) => {
|
|
|
1047
989
|
const directory = dirname(absolute);
|
|
1048
990
|
let mount = hostDirectories.get(directory);
|
|
1049
991
|
if (mount === void 0) {
|
|
1050
|
-
mount = `/host/${hostDirectories.size}`;
|
|
992
|
+
mount = `/mnt/host/${hostDirectories.size}`;
|
|
1051
993
|
runtime.FS.mkdirTree(mount);
|
|
1052
994
|
runtime.FS.mount(nodeFS, { root: directory }, mount);
|
|
1053
995
|
hostDirectories.set(directory, mount);
|
package/dist/protocol.d.ts
CHANGED
|
@@ -18,51 +18,15 @@ export type EngineRequest = {
|
|
|
18
18
|
id: RequestId;
|
|
19
19
|
type: 'disconnect';
|
|
20
20
|
connection: number;
|
|
21
|
-
} | {
|
|
22
|
-
id: RequestId;
|
|
23
|
-
type: 'createDatabase';
|
|
24
|
-
databaseName: string;
|
|
25
|
-
persistent: boolean;
|
|
26
|
-
} | {
|
|
27
|
-
id: RequestId;
|
|
28
|
-
type: 'openDatabase';
|
|
29
|
-
databaseName: string;
|
|
30
|
-
} | {
|
|
31
|
-
id: RequestId;
|
|
32
|
-
type: 'listDatabases';
|
|
33
|
-
} | {
|
|
34
|
-
id: RequestId;
|
|
35
|
-
type: 'checkpointDatabase';
|
|
36
|
-
databaseName: string;
|
|
37
|
-
} | {
|
|
38
|
-
id: RequestId;
|
|
39
|
-
type: 'dropDatabase';
|
|
40
|
-
databaseName: string;
|
|
41
21
|
} | {
|
|
42
22
|
id: RequestId;
|
|
43
23
|
type: 'shutdown';
|
|
44
|
-
} | {
|
|
45
|
-
id: RequestId;
|
|
46
|
-
type: 'attachDatabase';
|
|
47
|
-
connection: number;
|
|
48
|
-
databaseName: string;
|
|
49
|
-
alias: string;
|
|
50
|
-
} | {
|
|
51
|
-
id: RequestId;
|
|
52
|
-
type: 'detachDatabase';
|
|
53
|
-
connection: number;
|
|
54
|
-
alias: string;
|
|
55
24
|
} | {
|
|
56
25
|
id: RequestId;
|
|
57
26
|
type: 'startQuery';
|
|
58
27
|
connection: number;
|
|
59
28
|
sql: string;
|
|
60
29
|
sqlTestMode?: boolean;
|
|
61
|
-
} | {
|
|
62
|
-
id: RequestId;
|
|
63
|
-
type: 'startQueryWithInfo';
|
|
64
|
-
connection: number;
|
|
65
|
-
sql: string;
|
|
66
30
|
} | {
|
|
67
31
|
id: RequestId;
|
|
68
32
|
type: 'insertArrowIPCFromPath';
|
|
@@ -114,11 +78,7 @@ export type EngineRequest = {
|
|
|
114
78
|
query: number;
|
|
115
79
|
} | {
|
|
116
80
|
id: RequestId;
|
|
117
|
-
type: '
|
|
118
|
-
query: number;
|
|
119
|
-
} | {
|
|
120
|
-
id: RequestId;
|
|
121
|
-
type: 'releaseQueryWithInfo';
|
|
81
|
+
type: 'finishQuery';
|
|
122
82
|
query: number;
|
|
123
83
|
};
|
|
124
84
|
export type WasmResult = {
|