@uwdata/mosaic-duckdb 0.17.0 → 0.19.0

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/LICENSE ADDED
@@ -0,0 +1,47 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023-2025, UW Interactive Data Lab
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ ---
31
+
32
+ Portions of this software are derived from Observable Plot, which is released
33
+ under the ISC license.
34
+
35
+ Copyright 2020-2023 Observable, Inc.
36
+
37
+ Permission to use, copy, modify, and/or distribute this software for any purpose
38
+ with or without fee is hereby granted, provided that the above copyright notice
39
+ and this permission notice appear in all copies.
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
42
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
43
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
44
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
45
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
46
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
47
+ THIS SOFTWARE.
package/README.md CHANGED
@@ -4,6 +4,6 @@
4
4
 
5
5
  A Promise-based Node.js API to DuckDB, along with a data server that supports transfer of [Apache Arrow](https://arrow.apache.org/) and JSON data over either Web Sockets or HTTP.
6
6
 
7
- _Warning_: Due to persistent quality issues involving the Node.js DuckDB client and Arrow extension, we recommend using the Python-based [`duckdb-server`](https://github.com/uwdata/mosaic/tree/main/packages/duckdb-server) package instead. However, we retain this package for both backwards compatibility and potential future use as quality issues improve.
7
+ _Warning_: Due to persistent quality issues involving the Node.js DuckDB client and Arrow extension, we recommend using the Python-based [`duckdb-server`](https://github.com/uwdata/mosaic/tree/main/packages/server/duckdb-server) package instead. However, we retain this package for both backwards compatibility and potential future use as quality issues improve.
8
8
 
9
- _Note:_ This package provides a local DuckDB server for Node.js. To instead use DuckDB-WASM in the browser, use the `wasmConnector` in the [`mosaic-core`](https://github.com/uwdata/mosaic/tree/main/packages/mosaic-core) package.
9
+ _Note:_ This package provides a local DuckDB server for Node.js. To instead use DuckDB-WASM in the browser, use the `wasmConnector` in the [`mosaic-core`](https://github.com/uwdata/mosaic/tree/main/packages/mosaic/mosaic-core) package.
@@ -0,0 +1,22 @@
1
+ export function cacheKey(hashable: any, type: any): string;
2
+ export class Cache {
3
+ constructor({ max, dir, ttl }: {
4
+ max?: number;
5
+ dir?: string;
6
+ ttl?: number;
7
+ });
8
+ cache: Map<any, any>;
9
+ max: number;
10
+ dir: string;
11
+ ttl: number;
12
+ has(key: any): boolean;
13
+ delete(key: any): boolean;
14
+ get(key: any): any;
15
+ set(key: any, data: any, { persist, ttl }?: {
16
+ persist?: boolean;
17
+ ttl?: number;
18
+ }): this;
19
+ shouldEvict(): boolean;
20
+ evict(): void;
21
+ }
22
+ //# sourceMappingURL=Cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../src/Cache.js"],"names":[],"mappings":"AAOA,2DAEC;AAaD;IACE;;;;OAUC;IALC,qBAAoB;IACpB,YAAc;IACd,YAAc;IACd,YAAc;IAIhB,uBAEC;IAED,0BAMC;IAED,mBAEC;IAED;;;aAMC;IAED,uBAEC;IAED,cAyBC;CACF"}
@@ -0,0 +1,22 @@
1
+ export class DuckDB {
2
+ constructor(path?: string, config?: {}, initStatements?: string);
3
+ db: duckdb.Database;
4
+ con: duckdb.Connection;
5
+ _init: Promise<any>;
6
+ close(): Promise<any>;
7
+ prepare(sql: any): DuckDBStatement;
8
+ exec(sql: any): Promise<any>;
9
+ query(sql: any): Promise<any>;
10
+ arrowBuffer(sql: any): Promise<any>;
11
+ }
12
+ export class DuckDBStatement {
13
+ constructor(statement: any);
14
+ statement: any;
15
+ finalize(): void;
16
+ run(params: any): void;
17
+ exec(params: any): Promise<any>;
18
+ query(params: any): Promise<any>;
19
+ arrowBuffer(params: any): Promise<any>;
20
+ }
21
+ import duckdb from 'duckdb';
22
+ //# sourceMappingURL=DuckDB.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DuckDB.d.ts","sourceRoot":"","sources":["../../src/DuckDB.js"],"names":[],"mappings":"AAaA;IACE,iEASC;IAJC,oBAA2C;IAC3C,uBAA4B;IAE5B,oBAAsC;IAGxC,sBAUC;IAED,mCAEC;IAED,6BAUC;IAED,8BAUC;IAED,oCAUC;CACF;AAED;IACE,4BAEC;IADC,eAA0B;IAG5B,iBAEC;IAED,uBAEC;IAED,gCAUC;IAED,iCAUC;IAED,uCAUC;CACF;mBA9HkB,QAAQ"}
@@ -0,0 +1,15 @@
1
+ export function dataServer(db: any, { cache, rest, socket, port }?: {
2
+ cache?: boolean;
3
+ rest?: boolean;
4
+ socket?: boolean;
5
+ port?: number;
6
+ }): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
7
+ export function queryHandler(db: any, queryCache: any): (res: any, data: any) => Promise<void>;
8
+ export function socketResponse(ws: any): {
9
+ arrow(data: any): void;
10
+ json(data: any): void;
11
+ done(): void;
12
+ error(err: any): void;
13
+ };
14
+ import http from 'node:http';
15
+ //# sourceMappingURL=data-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-server.d.ts","sourceRoot":"","sources":["../../src/data-server.js"],"names":[],"mappings":"AAOA;;;;;yEAgBC;AA6CD,yDAqBgB,QAAG,EAAE,SAAI,mBAwCxB;AAwBD;;;;;EAmBC;iBA5KgB,WAAW"}
@@ -0,0 +1,8 @@
1
+ export { DuckDB } from "./DuckDB.js";
2
+ export { Cache } from "./Cache.js";
3
+ export { loadArrow } from "./load/arrow.js";
4
+ export { loadCSV } from "./load/csv.js";
5
+ export { loadJSON } from "./load/json.js";
6
+ export { loadParquet } from "./load/parquet.js";
7
+ export { dataServer, queryHandler, socketResponse } from "./data-server.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export function loadArrow(db: any, tableName: any, buffer: any): Promise<any>;
2
+ //# sourceMappingURL=arrow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrow.d.ts","sourceRoot":"","sources":["../../../src/load/arrow.js"],"names":[],"mappings":"AAEA,8EAWC"}
@@ -0,0 +1,2 @@
1
+ export function loadCSV(db: any, tableName: any, fileName: any, options?: {}): any;
2
+ //# sourceMappingURL=csv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../../src/load/csv.js"],"names":[],"mappings":"AAEA,mFAEC"}
@@ -0,0 +1,2 @@
1
+ export function loadJSON(db: any, tableName: any, fileName: any, options?: {}): any;
2
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/load/json.js"],"names":[],"mappings":"AAEA,oFAEC"}
@@ -0,0 +1,2 @@
1
+ export function loadParquet(db: any, tableName: any, fileName: any, options?: {}): any;
2
+ //# sourceMappingURL=parquet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parquet.d.ts","sourceRoot":"","sources":["../../../src/load/parquet.js"],"names":[],"mappings":"AAEA,uFAEC"}
@@ -0,0 +1,2 @@
1
+ export function mergeBuffers(buffers: any): Uint8Array<any>;
2
+ //# sourceMappingURL=merge-buffers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-buffers.d.ts","sourceRoot":"","sources":["../../src/merge-buffers.js"],"names":[],"mappings":"AAAA,4DAYC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uwdata/mosaic-duckdb",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "A Promise-based DuckDB API and Node.js data server.",
5
5
  "keywords": [
6
6
  "duckdb",
@@ -13,8 +13,15 @@
13
13
  "author": "Jeffrey Heer (https://idl.uw.edu)",
14
14
  "type": "module",
15
15
  "exports": {
16
+ "types": "./dist/src/index.d.ts",
16
17
  "default": "./src/index.js"
17
18
  },
19
+ "files": [
20
+ "bin",
21
+ "dist",
22
+ "!dist/tsconfig.tsbuildinfo",
23
+ "src"
24
+ ],
18
25
  "repository": {
19
26
  "type": "git",
20
27
  "url": "https://github.com/uwdata/mosaic.git"
@@ -25,15 +32,16 @@
25
32
  "to-parquet": "./bin/to-parquet.js"
26
33
  },
27
34
  "scripts": {
28
- "prebuild": "rimraf dist && mkdir dist",
35
+ "clean": "rimraf dist && mkdir dist",
29
36
  "lint": "eslint src test",
30
37
  "server": "node bin/run-server.js",
31
- "test": "vitest run && tsc",
32
- "prepublishOnly": "npm run test && npm run lint"
38
+ "test": "vitest run",
39
+ "prepublishOnly": "npm run test && npm run lint && tsc --build"
33
40
  },
34
41
  "dependencies": {
35
- "@uwdata/mosaic-sql": "^0.17.0",
36
- "duckdb": "~1.2.1",
37
- "ws": "^8.18.2"
38
- }
42
+ "@uwdata/mosaic-sql": "^0.19.0",
43
+ "duckdb": "~1.3.4",
44
+ "ws": "^8.18.3"
45
+ },
46
+ "gitHead": "0ba4f2d710ca2fa53da7ff02a370e39a32dc2ce4"
39
47
  }
package/src/Cache.js CHANGED
@@ -93,7 +93,7 @@ async function readEntries(dir, cache) {
93
93
  let files;
94
94
  try {
95
95
  files = await fs.readdir(dir);
96
- } catch (err) { // eslint-disable-line no-unused-vars
96
+ } catch (err) {
97
97
  return; // dir does not exist, nothing to do
98
98
  }
99
99
  await Promise.allSettled(files.map(async file => {
package/src/DuckDB.js CHANGED
@@ -5,9 +5,9 @@ const TEMP_DIR = '.duckdb';
5
5
 
6
6
  const DEFAULT_INIT_STATEMENTS = [
7
7
  `PRAGMA temp_directory='${TEMP_DIR}'`,
8
- `INSTALL arrow`,
8
+ `INSTALL nanoarrow FROM community`,
9
9
  `INSTALL httpfs`,
10
- `LOAD arrow`,
10
+ `LOAD nanoarrow`,
11
11
  `LOAD httpfs`
12
12
  ].join(';\n');
13
13
 
@@ -19,7 +19,8 @@ export class DuckDB {
19
19
  ) {
20
20
  this.db = new duckdb.Database(path, config);
21
21
  this.con = this.db.connect();
22
- this.exec(initStatements);
22
+ // store initialization promise so that we can wait for it
23
+ this._init = this.exec(initStatements);
23
24
  }
24
25
 
25
26
  close() {
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "include": ["src/**/*"],
4
- "compilerOptions": {
5
- "noEmit": true
6
- },
7
- "references": [{ "path": "../sql" }]
8
- }
package/vitest.config.ts DELETED
@@ -1,3 +0,0 @@
1
- import { defineConfig } from 'vite';
2
-
3
- export default defineConfig({});