@uwdata/mosaic-duckdb 0.3.4 → 0.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-duckdb",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "A Promise-based DuckDB API and Node.js data server.",
5
5
  "keywords": [
6
6
  "duckdb",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "duckdb": "~0.8.1",
34
- "ws": "^8.14.2"
34
+ "ws": "^8.16.0"
35
35
  },
36
- "gitHead": "faed78bc6264faa09a20b385601e03a9e1e15979"
36
+ "gitHead": "7cc66d26c687a28036b3c7102045f2196572847b"
37
37
  }
package/src/DuckDB.js CHANGED
@@ -3,19 +3,23 @@ import { mergeBuffers } from './merge-buffers.js';
3
3
 
4
4
  const TEMP_DIR = '.duckdb';
5
5
 
6
- const CONFIG = [
6
+ const DEFAULT_INIT_STATEMENTS = [
7
7
  `PRAGMA temp_directory='${TEMP_DIR}'`,
8
8
  `INSTALL arrow`,
9
9
  `INSTALL httpfs`,
10
10
  `LOAD arrow`,
11
11
  `LOAD httpfs`
12
- ];
12
+ ].join(';\n');
13
13
 
14
14
  export class DuckDB {
15
- constructor(path = ':memory:') {
16
- this.db = new duckdb.Database(path);
15
+ constructor(
16
+ path = ':memory:',
17
+ config = {},
18
+ initStatements = DEFAULT_INIT_STATEMENTS
19
+ ) {
20
+ this.db = new duckdb.Database(path, config);
17
21
  this.con = this.db.connect();
18
- this.exec(CONFIG.join(';\n'));
22
+ this.exec(initStatements);
19
23
  }
20
24
 
21
25
  close() {
@@ -68,7 +68,7 @@ function createSocketServer(server, handleQuery) {
68
68
  });
69
69
  }
70
70
 
71
- function queryHandler(db, queryCache) {
71
+ export function queryHandler(db, queryCache) {
72
72
 
73
73
  // retrieve query result
74
74
  async function retrieve(query, get) {
@@ -166,7 +166,7 @@ function httpResponse(res) {
166
166
  }
167
167
  }
168
168
 
169
- function socketResponse(ws) {
169
+ export function socketResponse(ws) {
170
170
  const STRING = { binary: false, fin: true };
171
171
  const BINARY = { binary: true, fin: true };
172
172
 
package/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { DuckDB } from './DuckDB.js';
2
- export { dataServer } from './data-server.js';
2
+ export { Cache } from './Cache.js';
3
+ export { dataServer, queryHandler, socketResponse } from './data-server.js';
3
4
  export { loadArrow } from './load/arrow.js';
4
5
  export { loadCSV } from './load/csv.js';
5
6
  export { loadJSON } from './load/json.js';