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.
@@ -81,36 +81,12 @@ var HyperDBEngineClient = class {
81
81
  disconnect(connection) {
82
82
  return this.request({ id: this.nextId++, type: "disconnect", connection });
83
83
  }
84
- createDatabase(databaseName, persistent) {
85
- return this.request({ id: this.nextId++, type: "createDatabase", databaseName, persistent });
86
- }
87
- openDatabase(databaseName) {
88
- return this.request({ id: this.nextId++, type: "openDatabase", databaseName });
89
- }
90
- listDatabases() {
91
- return this.request({ id: this.nextId++, type: "listDatabases" });
92
- }
93
- checkpointDatabase(databaseName) {
94
- return this.request({ id: this.nextId++, type: "checkpointDatabase", databaseName });
95
- }
96
- dropDatabase(databaseName) {
97
- return this.request({ id: this.nextId++, type: "dropDatabase", databaseName });
98
- }
99
- attachDatabase(connection, databaseName, alias) {
100
- return this.request({ id: this.nextId++, type: "attachDatabase", connection, databaseName, alias });
101
- }
102
- detachDatabase(connection, alias) {
103
- return this.request({ id: this.nextId++, type: "detachDatabase", connection, alias });
104
- }
105
84
  shutdown() {
106
85
  return this.request({ id: this.nextId++, type: "shutdown" });
107
86
  }
108
87
  startQuery(connection, sql, sqlTestMode = false) {
109
88
  return this.request({ id: this.nextId++, type: "startQuery", connection, sql, ...sqlTestMode && { sqlTestMode } });
110
89
  }
111
- startQueryWithInfo(connection, sql) {
112
- return this.request({ id: this.nextId++, type: "startQueryWithInfo", connection, sql });
113
- }
114
90
  insertArrowIPCFromPath(connection, path, name, schema, create, internal = false) {
115
91
  return this.request({ id: this.nextId++, type: "insertArrowIPCFromPath", connection, path, name, schema, create, internal });
116
92
  }
@@ -136,11 +112,8 @@ var HyperDBEngineClient = class {
136
112
  cancelQuery(query) {
137
113
  return this.request({ id: this.nextId++, type: "cancelQuery", query });
138
114
  }
139
- releaseQuery(query) {
140
- return this.request({ id: this.nextId++, type: "releaseQuery", query });
141
- }
142
- releaseQueryWithInfo(query) {
143
- return this.request({ id: this.nextId++, type: "releaseQueryWithInfo", query });
115
+ finishQuery(query) {
116
+ return this.request({ id: this.nextId++, type: "finishQuery", query });
144
117
  }
145
118
  async terminate() {
146
119
  await this.transport.terminate();
@@ -236,51 +209,33 @@ var HyperDBBindings = class {
236
209
  initialize;
237
210
  connect;
238
211
  disconnect;
239
- createDatabase;
240
- openDatabase;
241
- listDatabases;
242
- checkpointDatabase;
243
- dropDatabase;
244
212
  shutdown;
245
213
  registerExternalFile;
246
214
  registerExternalDirectory;
247
215
  removeExternalRegistration;
248
- attachDatabase;
249
- detachDatabase;
250
216
  startQuery;
251
- startQueryWithInfo;
252
217
  insertArrowIPCFromPath;
253
218
  pollQuery;
254
219
  cancelQuery;
255
- releaseQuery;
256
- releaseQueryWithInfo;
220
+ finishQuery;
257
221
  resultState;
258
222
  resultPayloadLength;
259
223
  free;
260
224
  nextTemporaryFile = 1;
261
225
  constructor(module) {
262
226
  this.module = module;
263
- this.initialize = module.cwrap("hyperdb_wasm_initialize", "pointer", ["string"]);
227
+ this.initialize = module.cwrap("hyperdb_wasm_initialize", "pointer", ["string", "string"]);
264
228
  this.connect = module.cwrap("hyperdb_wasm_connect", "pointer", []);
265
229
  this.disconnect = module.cwrap("hyperdb_wasm_disconnect", "pointer", ["number"]);
266
- this.createDatabase = module.cwrap("hyperdb_wasm_create_database", "pointer", ["string", "number"]);
267
- this.openDatabase = module.cwrap("hyperdb_wasm_open_database", "pointer", ["string"]);
268
- this.listDatabases = module.cwrap("hyperdb_wasm_list_databases", "pointer", []);
269
- this.checkpointDatabase = module.cwrap("hyperdb_wasm_checkpoint_database", "pointer", ["string"]);
270
- this.dropDatabase = module.cwrap("hyperdb_wasm_drop_database", "pointer", ["string"]);
271
230
  this.shutdown = module.cwrap("hyperdb_wasm_shutdown", "pointer", []);
272
231
  this.registerExternalFile = module.cwrap("hyperdb_wasm_register_external_file", "pointer", ["string", "string", "number"]);
273
232
  this.registerExternalDirectory = module.cwrap("hyperdb_wasm_register_external_directory", "pointer", ["string", "string", "number"]);
274
233
  this.removeExternalRegistration = module.cwrap("hyperdb_wasm_remove_external_registration", "pointer", ["string"]);
275
- this.attachDatabase = module.cwrap("hyperdb_wasm_attach_database", "pointer", ["number", "string", "string"]);
276
- this.detachDatabase = module.cwrap("hyperdb_wasm_detach_database", "pointer", ["number", "string"]);
277
234
  this.startQuery = module.cwrap("hyperdb_wasm_query_start", "pointer", ["number", "string", "number"]);
278
- this.startQueryWithInfo = module.cwrap("hyperdb_wasm_query_start_with_info", "pointer", ["number", "string"]);
279
235
  this.insertArrowIPCFromPath = module.cwrap("hyperdb_wasm_arrow_insert_from_path", "pointer", ["number", "string", "string", "string", "number"]);
280
236
  this.pollQuery = module.cwrap("hyperdb_wasm_query_poll", "pointer", ["number"]);
281
237
  this.cancelQuery = module.cwrap("hyperdb_wasm_query_cancel", "pointer", ["number"]);
282
- this.releaseQuery = module.cwrap("hyperdb_wasm_query_release", "pointer", ["number"]);
283
- this.releaseQueryWithInfo = module.cwrap("hyperdb_wasm_query_release_with_info", "pointer", ["number"]);
238
+ this.finishQuery = module.cwrap("hyperdb_wasm_query_finish", "pointer", ["number"]);
284
239
  this.resultState = module.cwrap("hyperdb_wasm_result_state", "number", ["number"]);
285
240
  this.resultPayloadLength = module.cwrap("hyperdb_wasm_result_payload_len", "number", ["number"]);
286
241
  this.free = module.cwrap("hyperdb_wasm_free", null, ["pointer"]);
@@ -389,32 +344,11 @@ var HyperDBBindings = class {
389
344
  switch (request.type) {
390
345
  case "initialize":
391
346
  validateCString(request.settings, "settings");
392
- return this.initialize(request.settings);
347
+ return this.initialize(request.settings, this.module.hyperdbWasmStoragePath ?? "");
393
348
  case "connect":
394
349
  return this.connect();
395
350
  case "disconnect":
396
351
  return this.disconnect(request.connection);
397
- case "createDatabase":
398
- validateCString(request.databaseName, "database name");
399
- return this.createDatabase(request.databaseName, Number(request.persistent));
400
- case "openDatabase":
401
- validateCString(request.databaseName, "database name");
402
- return this.openDatabase(request.databaseName);
403
- case "listDatabases":
404
- return this.listDatabases();
405
- case "checkpointDatabase":
406
- validateCString(request.databaseName, "database name");
407
- return this.checkpointDatabase(request.databaseName);
408
- case "dropDatabase":
409
- validateCString(request.databaseName, "database name");
410
- return this.dropDatabase(request.databaseName);
411
- case "attachDatabase":
412
- validateCString(request.databaseName, "database name");
413
- validateCString(request.alias, "database alias");
414
- return this.attachDatabase(request.connection, request.databaseName, request.alias);
415
- case "detachDatabase":
416
- validateCString(request.alias, "database alias");
417
- return this.detachDatabase(request.connection, request.alias);
418
352
  case "shutdown":
419
353
  return this.shutdown();
420
354
  case "registerExternalFile":
@@ -429,8 +363,6 @@ var HyperDBBindings = class {
429
363
  return this.removeExternalRegistration(request.path);
430
364
  case "startQuery":
431
365
  return this.startQuery(request.connection, request.sql, Number(request.sqlTestMode ?? false));
432
- case "startQueryWithInfo":
433
- return this.startQueryWithInfo(request.connection, request.sql);
434
366
  case "insertArrowIPCFromPath": {
435
367
  const path = request.internal ? request.path : this.module.resolveHyperDBPath?.(request.path) ?? request.path;
436
368
  return this.insertArrowIPCFromPath(request.connection, path, request.name, request.schema ?? "", Number(request.create));
@@ -439,10 +371,8 @@ var HyperDBBindings = class {
439
371
  return this.pollQuery(request.query);
440
372
  case "cancelQuery":
441
373
  return this.cancelQuery(request.query);
442
- case "releaseQuery":
443
- return this.releaseQuery(request.query);
444
- case "releaseQueryWithInfo":
445
- return this.releaseQueryWithInfo(request.query);
374
+ case "finishQuery":
375
+ return this.finishQuery(request.query);
446
376
  }
447
377
  }
448
378
  decodeResult(pointer) {
@@ -546,10 +476,11 @@ var BrowserWorker = class {
546
476
  this.worker.terminate();
547
477
  }
548
478
  };
549
- function resolveBrowserWorkerUrl(workerUrl, engineUrl, wasmUrl) {
479
+ function resolveBrowserWorkerUrl(workerUrl, engineUrl, wasmUrl, storagePath) {
550
480
  const resolved = new URL(workerUrl);
551
481
  resolved.searchParams.set("engineUrl", new URL(engineUrl).href);
552
482
  if (wasmUrl != null) resolved.searchParams.set("wasmUrl", new URL(wasmUrl).href);
483
+ if (storagePath != null) resolved.searchParams.set("storagePath", storagePath);
553
484
  return resolved;
554
485
  }
555
486
  function createBrowserClient(options = {}) {
@@ -557,7 +488,7 @@ function createBrowserClient(options = {}) {
557
488
  const workerUrl = options.workerUrl ?? new URL("./browser_worker.js", import.meta.url);
558
489
  const engineUrl = options.engineUrl ?? new URL("./hyperdb-wasm.js", import.meta.url);
559
490
  return new HyperDBEngineClient(
560
- new BrowserWorker(new Worker(resolveBrowserWorkerUrl(workerUrl, engineUrl, options.wasmUrl), { type: "classic" })),
491
+ new BrowserWorker(new Worker(resolveBrowserWorkerUrl(workerUrl, engineUrl, options.wasmUrl, options.storagePath), { type: "classic" })),
561
492
  options.onSetupProgress
562
493
  );
563
494
  }
package/dist/raw.node.js CHANGED
@@ -81,36 +81,12 @@ var HyperDBEngineClient = class {
81
81
  disconnect(connection) {
82
82
  return this.request({ id: this.nextId++, type: "disconnect", connection });
83
83
  }
84
- createDatabase(databaseName, persistent) {
85
- return this.request({ id: this.nextId++, type: "createDatabase", databaseName, persistent });
86
- }
87
- openDatabase(databaseName) {
88
- return this.request({ id: this.nextId++, type: "openDatabase", databaseName });
89
- }
90
- listDatabases() {
91
- return this.request({ id: this.nextId++, type: "listDatabases" });
92
- }
93
- checkpointDatabase(databaseName) {
94
- return this.request({ id: this.nextId++, type: "checkpointDatabase", databaseName });
95
- }
96
- dropDatabase(databaseName) {
97
- return this.request({ id: this.nextId++, type: "dropDatabase", databaseName });
98
- }
99
- attachDatabase(connection, databaseName, alias) {
100
- return this.request({ id: this.nextId++, type: "attachDatabase", connection, databaseName, alias });
101
- }
102
- detachDatabase(connection, alias) {
103
- return this.request({ id: this.nextId++, type: "detachDatabase", connection, alias });
104
- }
105
84
  shutdown() {
106
85
  return this.request({ id: this.nextId++, type: "shutdown" });
107
86
  }
108
87
  startQuery(connection, sql, sqlTestMode = false) {
109
88
  return this.request({ id: this.nextId++, type: "startQuery", connection, sql, ...sqlTestMode && { sqlTestMode } });
110
89
  }
111
- startQueryWithInfo(connection, sql) {
112
- return this.request({ id: this.nextId++, type: "startQueryWithInfo", connection, sql });
113
- }
114
90
  insertArrowIPCFromPath(connection, path, name, schema, create, internal = false) {
115
91
  return this.request({ id: this.nextId++, type: "insertArrowIPCFromPath", connection, path, name, schema, create, internal });
116
92
  }
@@ -136,11 +112,8 @@ var HyperDBEngineClient = class {
136
112
  cancelQuery(query) {
137
113
  return this.request({ id: this.nextId++, type: "cancelQuery", query });
138
114
  }
139
- releaseQuery(query) {
140
- return this.request({ id: this.nextId++, type: "releaseQuery", query });
141
- }
142
- releaseQueryWithInfo(query) {
143
- return this.request({ id: this.nextId++, type: "releaseQueryWithInfo", query });
115
+ finishQuery(query) {
116
+ return this.request({ id: this.nextId++, type: "finishQuery", query });
144
117
  }
145
118
  async terminate() {
146
119
  await this.transport.terminate();
@@ -236,51 +209,33 @@ var HyperDBBindings = class {
236
209
  initialize;
237
210
  connect;
238
211
  disconnect;
239
- createDatabase;
240
- openDatabase;
241
- listDatabases;
242
- checkpointDatabase;
243
- dropDatabase;
244
212
  shutdown;
245
213
  registerExternalFile;
246
214
  registerExternalDirectory;
247
215
  removeExternalRegistration;
248
- attachDatabase;
249
- detachDatabase;
250
216
  startQuery;
251
- startQueryWithInfo;
252
217
  insertArrowIPCFromPath;
253
218
  pollQuery;
254
219
  cancelQuery;
255
- releaseQuery;
256
- releaseQueryWithInfo;
220
+ finishQuery;
257
221
  resultState;
258
222
  resultPayloadLength;
259
223
  free;
260
224
  nextTemporaryFile = 1;
261
225
  constructor(module) {
262
226
  this.module = module;
263
- this.initialize = module.cwrap("hyperdb_wasm_initialize", "pointer", ["string"]);
227
+ this.initialize = module.cwrap("hyperdb_wasm_initialize", "pointer", ["string", "string"]);
264
228
  this.connect = module.cwrap("hyperdb_wasm_connect", "pointer", []);
265
229
  this.disconnect = module.cwrap("hyperdb_wasm_disconnect", "pointer", ["number"]);
266
- this.createDatabase = module.cwrap("hyperdb_wasm_create_database", "pointer", ["string", "number"]);
267
- this.openDatabase = module.cwrap("hyperdb_wasm_open_database", "pointer", ["string"]);
268
- this.listDatabases = module.cwrap("hyperdb_wasm_list_databases", "pointer", []);
269
- this.checkpointDatabase = module.cwrap("hyperdb_wasm_checkpoint_database", "pointer", ["string"]);
270
- this.dropDatabase = module.cwrap("hyperdb_wasm_drop_database", "pointer", ["string"]);
271
230
  this.shutdown = module.cwrap("hyperdb_wasm_shutdown", "pointer", []);
272
231
  this.registerExternalFile = module.cwrap("hyperdb_wasm_register_external_file", "pointer", ["string", "string", "number"]);
273
232
  this.registerExternalDirectory = module.cwrap("hyperdb_wasm_register_external_directory", "pointer", ["string", "string", "number"]);
274
233
  this.removeExternalRegistration = module.cwrap("hyperdb_wasm_remove_external_registration", "pointer", ["string"]);
275
- this.attachDatabase = module.cwrap("hyperdb_wasm_attach_database", "pointer", ["number", "string", "string"]);
276
- this.detachDatabase = module.cwrap("hyperdb_wasm_detach_database", "pointer", ["number", "string"]);
277
234
  this.startQuery = module.cwrap("hyperdb_wasm_query_start", "pointer", ["number", "string", "number"]);
278
- this.startQueryWithInfo = module.cwrap("hyperdb_wasm_query_start_with_info", "pointer", ["number", "string"]);
279
235
  this.insertArrowIPCFromPath = module.cwrap("hyperdb_wasm_arrow_insert_from_path", "pointer", ["number", "string", "string", "string", "number"]);
280
236
  this.pollQuery = module.cwrap("hyperdb_wasm_query_poll", "pointer", ["number"]);
281
237
  this.cancelQuery = module.cwrap("hyperdb_wasm_query_cancel", "pointer", ["number"]);
282
- this.releaseQuery = module.cwrap("hyperdb_wasm_query_release", "pointer", ["number"]);
283
- this.releaseQueryWithInfo = module.cwrap("hyperdb_wasm_query_release_with_info", "pointer", ["number"]);
238
+ this.finishQuery = module.cwrap("hyperdb_wasm_query_finish", "pointer", ["number"]);
284
239
  this.resultState = module.cwrap("hyperdb_wasm_result_state", "number", ["number"]);
285
240
  this.resultPayloadLength = module.cwrap("hyperdb_wasm_result_payload_len", "number", ["number"]);
286
241
  this.free = module.cwrap("hyperdb_wasm_free", null, ["pointer"]);
@@ -389,32 +344,11 @@ var HyperDBBindings = class {
389
344
  switch (request.type) {
390
345
  case "initialize":
391
346
  validateCString(request.settings, "settings");
392
- return this.initialize(request.settings);
347
+ return this.initialize(request.settings, this.module.hyperdbWasmStoragePath ?? "");
393
348
  case "connect":
394
349
  return this.connect();
395
350
  case "disconnect":
396
351
  return this.disconnect(request.connection);
397
- case "createDatabase":
398
- validateCString(request.databaseName, "database name");
399
- return this.createDatabase(request.databaseName, Number(request.persistent));
400
- case "openDatabase":
401
- validateCString(request.databaseName, "database name");
402
- return this.openDatabase(request.databaseName);
403
- case "listDatabases":
404
- return this.listDatabases();
405
- case "checkpointDatabase":
406
- validateCString(request.databaseName, "database name");
407
- return this.checkpointDatabase(request.databaseName);
408
- case "dropDatabase":
409
- validateCString(request.databaseName, "database name");
410
- return this.dropDatabase(request.databaseName);
411
- case "attachDatabase":
412
- validateCString(request.databaseName, "database name");
413
- validateCString(request.alias, "database alias");
414
- return this.attachDatabase(request.connection, request.databaseName, request.alias);
415
- case "detachDatabase":
416
- validateCString(request.alias, "database alias");
417
- return this.detachDatabase(request.connection, request.alias);
418
352
  case "shutdown":
419
353
  return this.shutdown();
420
354
  case "registerExternalFile":
@@ -429,8 +363,6 @@ var HyperDBBindings = class {
429
363
  return this.removeExternalRegistration(request.path);
430
364
  case "startQuery":
431
365
  return this.startQuery(request.connection, request.sql, Number(request.sqlTestMode ?? false));
432
- case "startQueryWithInfo":
433
- return this.startQueryWithInfo(request.connection, request.sql);
434
366
  case "insertArrowIPCFromPath": {
435
367
  const path = request.internal ? request.path : this.module.resolveHyperDBPath?.(request.path) ?? request.path;
436
368
  return this.insertArrowIPCFromPath(request.connection, path, request.name, request.schema ?? "", Number(request.create));
@@ -439,10 +371,8 @@ var HyperDBBindings = class {
439
371
  return this.pollQuery(request.query);
440
372
  case "cancelQuery":
441
373
  return this.cancelQuery(request.query);
442
- case "releaseQuery":
443
- return this.releaseQuery(request.query);
444
- case "releaseQueryWithInfo":
445
- return this.releaseQueryWithInfo(request.query);
374
+ case "finishQuery":
375
+ return this.finishQuery(request.query);
446
376
  }
447
377
  }
448
378
  decodeResult(pointer) {
@@ -47,6 +47,7 @@ export interface HyperDBWasmModule {
47
47
  unlink(path: string): void;
48
48
  };
49
49
  resolveHyperDBPath?(path: string): string;
50
+ hyperdbWasmStoragePath?: string;
50
51
  externalFileBackendAvailable?: boolean;
51
52
  externalFileBackend?: ExternalFileBackend;
52
53
  externalDirectoryBackend?: ExternalDirectoryBackend;
@@ -63,24 +64,15 @@ export declare class HyperDBBindings {
63
64
  private readonly initialize;
64
65
  private readonly connect;
65
66
  private readonly disconnect;
66
- private readonly createDatabase;
67
- private readonly openDatabase;
68
- private readonly listDatabases;
69
- private readonly checkpointDatabase;
70
- private readonly dropDatabase;
71
67
  private readonly shutdown;
72
68
  private readonly registerExternalFile;
73
69
  private readonly registerExternalDirectory;
74
70
  private readonly removeExternalRegistration;
75
- private readonly attachDatabase;
76
- private readonly detachDatabase;
77
71
  private readonly startQuery;
78
- private readonly startQueryWithInfo;
79
72
  private readonly insertArrowIPCFromPath;
80
73
  private readonly pollQuery;
81
74
  private readonly cancelQuery;
82
- private readonly releaseQuery;
83
- private readonly releaseQueryWithInfo;
75
+ private readonly finishQuery;
84
76
  private readonly resultState;
85
77
  private readonly resultPayloadLength;
86
78
  private readonly free;
@@ -8,14 +8,15 @@ const database = await HyperDB.create({ storagePath });
8
8
  const connection = await database.connect();
9
9
 
10
10
  try {
11
- await database.createDatabase('readings');
12
- await database.createDatabase('sensors', { storage: 'persistent' });
13
- await connection.attachDatabase('readings');
14
- await connection.attachDatabase('sensors');
11
+ await connection.queryIPC('create database "readings.hyper"').result;
12
+ await connection.queryIPC('create database "sensors.hyper"').result;
13
+ await connection.queryIPC('attach database "readings.hyper" as readings').result;
14
+ await connection.queryIPC('attach database "sensors.hyper" as sensors').result;
15
15
 
16
16
  await connection.queryIPC('create table readings.public.values_table(sensor_id integer, reading integer)').result;
17
- await connection.queryIPC('insert into readings.public.values_table values (101, 18), (202, 22)').result;
18
17
  await connection.queryIPC('create table sensors.public.locations(sensor_id integer, location text)').result;
18
+ await connection.queryIPC('begin').result;
19
+ await connection.queryIPC('insert into readings.public.values_table values (101, 18), (202, 22)').result;
19
20
  await connection.queryIPC("insert into sensors.public.locations values (101, 'office'), (202, 'lab')").result;
20
21
 
21
22
  const result = await connection.query(`
@@ -26,11 +27,11 @@ try {
26
27
  `).result;
27
28
  console.table(result.toArray().map((row) => row.toJSON()));
28
29
  } finally {
29
- await connection.detachDatabase('readings');
30
- await connection.detachDatabase('sensors');
30
+ await connection.queryIPC('commit').result;
31
+ await connection.queryIPC('detach database readings, sensors').result;
31
32
  await connection.close();
32
- await database.dropDatabase('readings');
33
- await database.dropDatabase('sensors');
33
+ await connection.queryIPC('drop database "readings.hyper"').result;
34
+ await connection.queryIPC('drop database "sensors.hyper"').result;
34
35
  await database.terminate();
35
36
  await rm(storagePath, { recursive: true, force: true });
36
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperdb-wasm",
3
- "version": "0.0.26862-dev.wasm.g42f1012b",
3
+ "version": "0.0.26862-dev.wasm.g89537caa",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"