@malloydata/db-duckdb 0.0.123-dev240207191052 → 0.0.123-dev240208001444

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.
@@ -2,7 +2,9 @@ import { DuckDBCommon } from './duckdb_common';
2
2
  import { Connection, Database, TableData } from 'duckdb';
3
3
  import { ConnectionConfig, QueryDataRow, QueryOptionsReader, RunSQLOptions } from '@malloydata/malloy';
4
4
  export interface DuckDBConnectionOptions extends ConnectionConfig {
5
+ additionalExtensions?: string[];
5
6
  databasePath?: string;
7
+ motherDuckToken: string | undefined;
6
8
  workingDirectory?: string;
7
9
  readOnly?: boolean;
8
10
  }
@@ -12,8 +14,10 @@ interface ActiveDB {
12
14
  }
13
15
  export declare class DuckDBConnection extends DuckDBCommon {
14
16
  readonly name: string;
17
+ private additionalExtensions;
15
18
  private databasePath;
16
19
  private workingDirectory;
20
+ private motherDuckToken;
17
21
  private readOnly;
18
22
  connecting: Promise<void>;
19
23
  protected connection: Connection | null;
@@ -32,6 +32,7 @@ const duckdb_1 = require("duckdb");
32
32
  class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
33
33
  constructor(arg, arg2, workingDirectory, queryOptions) {
34
34
  super();
35
+ this.additionalExtensions = [];
35
36
  this.databasePath = ':memory:';
36
37
  this.workingDirectory = '.';
37
38
  this.readOnly = false;
@@ -62,6 +63,12 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
62
63
  if (typeof arg.workingDirectory === 'string') {
63
64
  this.workingDirectory = arg.workingDirectory;
64
65
  }
66
+ if (typeof arg.motherDuckToken === 'string') {
67
+ this.motherDuckToken = arg.motherDuckToken;
68
+ }
69
+ if (Array.isArray(arg.additionalExtensions)) {
70
+ this.additionalExtensions = arg.additionalExtensions;
71
+ }
65
72
  }
66
73
  if (this.databasePath === ':memory:') {
67
74
  this.readOnly = false;
@@ -75,6 +82,9 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
75
82
  activeDB = DuckDBConnection.activeDBs[this.databasePath];
76
83
  }
77
84
  else {
85
+ if (this.motherDuckToken) {
86
+ process.env['MOTHERDUCK_TOKEN'] = this.motherDuckToken;
87
+ }
78
88
  const database = new duckdb_1.Database(this.databasePath, this.readOnly ? duckdb_1.OPEN_READONLY : duckdb_1.OPEN_READWRITE, err => {
79
89
  if (err) {
80
90
  reject(err);
@@ -106,7 +116,16 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
106
116
  if (this.workingDirectory) {
107
117
  await this.runDuckDBQuery(`SET FILE_SEARCH_PATH='${this.workingDirectory}'`);
108
118
  }
109
- for (const ext of ['json', 'httpfs', 'icu']) {
119
+ const extensions = [
120
+ 'json',
121
+ 'httpfs',
122
+ 'icu',
123
+ ...this.additionalExtensions,
124
+ ];
125
+ if (this.motherDuckToken) {
126
+ extensions.push('motherduck');
127
+ }
128
+ for (const ext of extensions) {
110
129
  await this.loadExtension(ext);
111
130
  }
112
131
  const setupCmds = ["SET TimeZone='UTC'"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-duckdb",
3
- "version": "0.0.123-dev240207191052",
3
+ "version": "0.0.123-dev240208001444",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@malloydata/duckdb-wasm": "0.0.6",
44
- "@malloydata/malloy": "^0.0.123-dev240207191052",
44
+ "@malloydata/malloy": "^0.0.123-dev240208001444",
45
45
  "apache-arrow": "^13.0.0",
46
46
  "duckdb": "0.9.2",
47
47
  "web-worker": "^1.2.0"