@motherduck/wasm-client 0.6.2 → 0.6.4
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 +1 -1
- package/types/DuckDBInstance.d.ts +1 -1
- package/types/MDConnection.d.ts +1 -1
- package/types/MaterializedQueryTask.d.ts +1 -1
- package/types/QueryTypes.d.ts +3 -3
- package/types/StreamingQueryTask.d.ts +1 -1
- package/types/createDuckDbConnection.d.ts +1 -1
- package/types/duckdb-wasm/bindings/bindings_base.d.ts +122 -0
- package/types/duckdb-wasm/bindings/bindings_browser_base.d.ts +19 -0
- package/types/duckdb-wasm/bindings/bindings_browser_coi.d.ts +12 -0
- package/types/duckdb-wasm/bindings/bindings_browser_eh.d.ts +12 -0
- package/types/duckdb-wasm/bindings/bindings_browser_mvp.d.ts +11 -0
- package/types/duckdb-wasm/bindings/bindings_interface.d.ts +41 -0
- package/types/duckdb-wasm/bindings/bindings_node_base.d.ts +23 -0
- package/types/duckdb-wasm/bindings/bindings_node_eh.d.ts +12 -0
- package/types/duckdb-wasm/bindings/bindings_node_mvp.d.ts +12 -0
- package/types/duckdb-wasm/bindings/config.d.ts +62 -0
- package/types/duckdb-wasm/bindings/connection.d.ts +74 -0
- package/types/duckdb-wasm/bindings/duckdb_module.d.ts +12 -0
- package/types/duckdb-wasm/bindings/file_stats.d.ts +36 -0
- package/types/duckdb-wasm/bindings/index.d.ts +11 -0
- package/types/duckdb-wasm/bindings/insert_options.d.ts +38 -0
- package/types/duckdb-wasm/bindings/progress.d.ts +9 -0
- package/types/duckdb-wasm/bindings/runtime.d.ts +83 -0
- package/types/duckdb-wasm/bindings/runtime_browser.d.ts +9 -0
- package/types/duckdb-wasm/bindings/runtime_node.d.ts +8 -0
- package/types/duckdb-wasm/bindings/tokens.d.ts +12 -0
- package/types/duckdb-wasm/bindings/udf_function.d.ts +14 -0
- package/types/duckdb-wasm/bindings/udf_runtime.d.ts +3 -0
- package/types/duckdb-wasm/bindings/web_file.d.ts +12 -0
- package/types/duckdb-wasm/index.d.ts +7 -0
- package/types/duckdb-wasm/index_docs.d.ts +1 -0
- package/types/duckdb-wasm/json_typedef.d.ts +17 -0
- package/types/duckdb-wasm/log.d.ts +54 -0
- package/types/duckdb-wasm/parallel/async_bindings.d.ts +122 -0
- package/types/duckdb-wasm/parallel/async_bindings_interface.d.ts +25 -0
- package/types/duckdb-wasm/parallel/async_connection.d.ts +75 -0
- package/types/duckdb-wasm/parallel/index.d.ts +5 -0
- package/types/duckdb-wasm/parallel/worker_dispatcher.d.ts +22 -0
- package/types/duckdb-wasm/parallel/worker_request.d.ts +99 -0
- package/types/duckdb-wasm/platform.d.ts +39 -0
- package/types/duckdb-wasm/status.d.ts +3 -0
- package/types/duckdb-wasm/targets/duckdb-browser-blocking.d.ts +12 -0
- package/types/duckdb-wasm/targets/duckdb-browser-coi.pthread.worker.d.ts +1 -0
- package/types/duckdb-wasm/targets/duckdb-browser-coi.worker.d.ts +2 -0
- package/types/duckdb-wasm/targets/duckdb-browser-eh.worker.d.ts +2 -0
- package/types/duckdb-wasm/targets/duckdb-browser-mvp.worker.d.ts +2 -0
- package/types/duckdb-wasm/targets/duckdb-node-blocking.d.ts +13 -0
- package/types/duckdb-wasm/targets/duckdb-node-eh.worker.d.ts +2 -0
- package/types/duckdb-wasm/targets/duckdb-node-mvp.worker.d.ts +2 -0
- package/types/duckdb-wasm/targets/duckdb.d.ts +9 -0
- package/types/duckdb-wasm/utils/binary_dump.d.ts +1 -0
- package/types/duckdb-wasm/utils/index.d.ts +2 -0
- package/types/duckdb-wasm/utils/s3_helper.d.ts +27 -0
- package/types/duckdb-wasm/version.d.ts +5 -0
- package/types/duckdb-wasm/worker.d.ts +1 -0
- package/types/getAsyncDuckDb.d.ts +1 -1
- package/types/getDuckDBBundlesFromDuckDBAssets.d.ts +1 -1
- package/types/index.d.ts +5 -5
- package/types/instantiateDB.d.ts +1 -1
- package/types/motherduck/duckdb-arrow/AsyncDuckDBRecordBatchIterator.d.ts +12 -0
- package/types/motherduck/duckdb-arrow/DuckDBRecordBatch.d.ts +14 -0
- package/types/motherduck/duckdb-arrow/TypedTypeMap.d.ts +2 -0
- package/types/motherduck/duckdb-arrow/duckDBTypeFromArrowType.d.ts +4 -0
- package/types/motherduck/duckdb-arrow/duckDBValueFromArrowData.d.ts +8 -0
- package/types/motherduck/duckdb-arrow/index.d.ts +2 -0
- package/types/motherduck/duckdb-data/AsyncDuckDBDataBatchIterator.d.ts +3 -0
- package/types/motherduck/duckdb-data/DuckDBData.d.ts +56 -0
- package/types/motherduck/duckdb-data/DuckDBDataReader.d.ts +68 -0
- package/types/motherduck/duckdb-data/DuckDBRow.d.ts +4 -0
- package/types/motherduck/duckdb-data/MemoryDuckDBData.d.ts +16 -0
- package/types/motherduck/duckdb-data/index.d.ts +5 -0
- package/types/motherduck/duckdb-types/DuckDBType.d.ts +124 -0
- package/types/motherduck/duckdb-types/DuckDBTypes.d.ts +43 -0
- package/types/motherduck/duckdb-types/index.d.ts +3 -0
- package/types/motherduck/duckdb-types/parseLogicalTypeString.d.ts +2 -0
- package/types/motherduck/duckdb-values/DuckDBArray.d.ts +7 -0
- package/types/motherduck/duckdb-values/DuckDBBlob.d.ts +6 -0
- package/types/motherduck/duckdb-values/DuckDBDate.d.ts +6 -0
- package/types/motherduck/duckdb-values/DuckDBDecimal.d.ts +10 -0
- package/types/motherduck/duckdb-values/DuckDBInterval.d.ts +8 -0
- package/types/motherduck/duckdb-values/DuckDBList.d.ts +7 -0
- package/types/motherduck/duckdb-values/DuckDBMap.d.ts +7 -0
- package/types/motherduck/duckdb-values/DuckDBMapEntry.d.ts +5 -0
- package/types/motherduck/duckdb-values/DuckDBStruct.d.ts +7 -0
- package/types/motherduck/duckdb-values/DuckDBStructEntry.d.ts +5 -0
- package/types/motherduck/duckdb-values/DuckDBTime.d.ts +6 -0
- package/types/motherduck/duckdb-values/DuckDBTimestampMicroseconds.d.ts +8 -0
- package/types/motherduck/duckdb-values/DuckDBTimestampMilliseconds.d.ts +6 -0
- package/types/motherduck/duckdb-values/DuckDBTimestampNanoseconds.d.ts +6 -0
- package/types/motherduck/duckdb-values/DuckDBTimestampSeconds.d.ts +6 -0
- package/types/motherduck/duckdb-values/DuckDBValue.d.ts +2 -0
- package/types/motherduck/duckdb-values/SpecialDuckDBValue.d.ts +4 -0
- package/types/motherduck/duckdb-values/conversion/dateTimeStringConversion.d.ts +12 -0
- package/types/motherduck/duckdb-values/conversion/displayStringForDuckDBValue.d.ts +2 -0
- package/types/motherduck/duckdb-values/conversion/stringFromBlob.d.ts +2 -0
- package/types/motherduck/duckdb-values/conversion/stringFromDecimal.d.ts +18 -0
- package/types/motherduck/duckdb-values/index.d.ts +17 -0
- package/types/motherduck/wasm-extension/LoadMotherDuckWasmExtensionOptions.d.ts +38 -0
- package/types/motherduck/wasm-extension/MDEvent.d.ts +1 -0
- package/types/motherduck/wasm-extension/MotherDuckEvent.d.ts +11 -0
- package/types/motherduck/wasm-extension/MotherDuckLogLevel.d.ts +7 -0
- package/types/motherduck/wasm-extension/doesBrowserSupportWorkerInWorker.d.ts +1 -0
- package/types/motherduck/wasm-extension/fetchVersion.d.ts +1 -0
- package/types/motherduck/wasm-extension/getExtensionRepository.d.ts +1 -0
- package/types/motherduck/wasm-extension/index.d.ts +4 -0
- package/types/motherduck/wasm-extension/loadMotherDuckWasmExtension.d.ts +2 -0
- package/types/motherduck/wasm-extension/motherDuckEventFromMessageEvent.d.ts +2 -0
- package/types/motherduck/wasm-extension/pathConcat.d.ts +1 -0
- package/types/motherduck/wasm-extension/untilWorkerReady.d.ts +2 -0
- package/types/readLocalFS.d.ts +1 -1
- package/index.js.map +0 -7
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AsyncDuckDB } from '
|
|
1
|
+
import { AsyncDuckDB } from './duckdb-wasm';
|
|
2
2
|
export declare function getDuckDBInstance(): Promise<AsyncDuckDB> | AsyncDuckDB | null;
|
|
3
3
|
export declare function setDuckDBInstance(instance: Promise<AsyncDuckDB> | AsyncDuckDB): void;
|
package/types/MDConnection.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AsyncPreparedStatement, ScriptTokens, TokenType } from '
|
|
1
|
+
import { AsyncPreparedStatement, ScriptTokens, TokenType } from './duckdb-wasm';
|
|
2
2
|
import { MDConnectionParams } from './MDConnectionParams';
|
|
3
3
|
import { MaterializedQueryResult, SafePrepareResult, SafeQueryResult, StreamingQueryResult } from './QueryTypes';
|
|
4
4
|
export { ScriptTokens, TokenType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AsyncDuckDBConnection } from '
|
|
1
|
+
import { AsyncDuckDBConnection } from './duckdb-wasm';
|
|
2
2
|
import { MaterializedQueryResult } from './QueryTypes';
|
|
3
3
|
import { Task } from './TaskSequencer';
|
|
4
4
|
export declare class MaterializedQueryTask implements Task<MaterializedQueryResult> {
|
package/types/QueryTypes.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AsyncPreparedStatement } from '
|
|
2
|
-
import { TypedTypeMap } from '
|
|
3
|
-
import { AsyncDuckDBDataBatchIterator, DuckDBData, DuckDBDataReader } from '
|
|
1
|
+
import { AsyncPreparedStatement } from './duckdb-wasm';
|
|
2
|
+
import { TypedTypeMap } from './motherduck/duckdb-arrow';
|
|
3
|
+
import { AsyncDuckDBDataBatchIterator, DuckDBData, DuckDBDataReader } from './motherduck/duckdb-data';
|
|
4
4
|
import { AsyncRecordBatchStreamReader, DataType } from 'apache-arrow';
|
|
5
5
|
export interface MaterializedQueryResult {
|
|
6
6
|
type: 'materialized';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AsyncDuckDBConnection } from '
|
|
1
|
+
import { AsyncDuckDBConnection } from './duckdb-wasm';
|
|
2
2
|
import { StreamingQueryResult } from './QueryTypes';
|
|
3
3
|
import { Task } from './TaskSequencer';
|
|
4
4
|
export declare class StreamingQueryTask implements Task<StreamingQueryResult> {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { AsyncDuckDBConnection } from '
|
|
1
|
+
import { AsyncDuckDBConnection } from './duckdb-wasm';
|
|
2
2
|
import { MDConnectionParams } from './MDConnectionParams';
|
|
3
3
|
export declare function createDuckDbConnection(params: MDConnectionParams): Promise<AsyncDuckDBConnection>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { DuckDBModule, PThread } from './duckdb_module';
|
|
2
|
+
import { DuckDBConfig } from './config';
|
|
3
|
+
import { Logger } from '../log';
|
|
4
|
+
import { InstantiationProgress } from './progress';
|
|
5
|
+
import { DuckDBBindings } from './bindings_interface';
|
|
6
|
+
import { DuckDBConnection } from './connection';
|
|
7
|
+
import { DuckDBRuntime, DuckDBDataProtocol } from './runtime';
|
|
8
|
+
import { CSVInsertOptions, JSONInsertOptions, ArrowInsertOptions } from './insert_options';
|
|
9
|
+
import { ScriptTokens } from './tokens';
|
|
10
|
+
import { FileStatistics } from './file_stats';
|
|
11
|
+
import { WebFile } from './web_file';
|
|
12
|
+
import * as arrow from 'apache-arrow';
|
|
13
|
+
declare global {
|
|
14
|
+
var DUCKDB_RUNTIME: any;
|
|
15
|
+
}
|
|
16
|
+
/** A DuckDB Feature */
|
|
17
|
+
export declare enum DuckDBFeature {
|
|
18
|
+
WASM_EXCEPTIONS = 1,
|
|
19
|
+
WASM_THREADS = 2,
|
|
20
|
+
WASM_SIMD = 4,
|
|
21
|
+
WASM_BULK_MEMORY = 8,
|
|
22
|
+
EMIT_BIGINT = 16
|
|
23
|
+
}
|
|
24
|
+
/** The proxy for either the browser- order node-based DuckDB API */
|
|
25
|
+
export declare abstract class DuckDBBindingsBase implements DuckDBBindings {
|
|
26
|
+
/** The logger */
|
|
27
|
+
protected readonly _logger: Logger;
|
|
28
|
+
/** Backend-dependent native-glue code for DuckDB */
|
|
29
|
+
protected readonly _runtime: DuckDBRuntime;
|
|
30
|
+
/** The instance */
|
|
31
|
+
protected _instance: DuckDBModule | null;
|
|
32
|
+
/** The loading promise */
|
|
33
|
+
protected _initPromise: Promise<void> | null;
|
|
34
|
+
/** The resolver for the open promise (called by onRuntimeInitialized) */
|
|
35
|
+
protected _initPromiseResolver: () => void;
|
|
36
|
+
/** The next UDF id */
|
|
37
|
+
protected _nextUDFId: number;
|
|
38
|
+
constructor(logger: Logger, runtime: DuckDBRuntime);
|
|
39
|
+
/** Get the logger */
|
|
40
|
+
get logger(): Logger;
|
|
41
|
+
/** Get the instance */
|
|
42
|
+
get mod(): DuckDBModule;
|
|
43
|
+
/** Get the instance */
|
|
44
|
+
get pthread(): PThread | null;
|
|
45
|
+
/** Instantiate the module */
|
|
46
|
+
protected abstract instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
|
|
47
|
+
/** Instantiate the module */
|
|
48
|
+
protected onInstantiationProgress: ((p: InstantiationProgress) => void)[];
|
|
49
|
+
/** Instantiate the database */
|
|
50
|
+
instantiate(onProgress?: (progress: InstantiationProgress) => void): Promise<this>;
|
|
51
|
+
/** Open a database with a config */
|
|
52
|
+
open(config: DuckDBConfig): void;
|
|
53
|
+
/** Reset the database */
|
|
54
|
+
reset(): void;
|
|
55
|
+
/** Get the version */
|
|
56
|
+
getVersion(): string;
|
|
57
|
+
/** Get the feature flags */
|
|
58
|
+
getFeatureFlags(): number;
|
|
59
|
+
/** Tokenize a script */
|
|
60
|
+
tokenize(text: string): ScriptTokens;
|
|
61
|
+
/** Connect to database */
|
|
62
|
+
connect(): DuckDBConnection;
|
|
63
|
+
/** Disconnect from database */
|
|
64
|
+
disconnect(conn: number): void;
|
|
65
|
+
/** Send a query and return the full result */
|
|
66
|
+
runQuery(conn: number, text: string): Uint8Array;
|
|
67
|
+
/**
|
|
68
|
+
* Start a pending query asynchronously.
|
|
69
|
+
* This method returns either the arrow ipc schema or null.
|
|
70
|
+
* On null, the query has to be executed using `pollPendingQuery` until that returns != null.
|
|
71
|
+
* Results can then be fetched using `fetchQueryResults`
|
|
72
|
+
*/
|
|
73
|
+
startPendingQuery(conn: number, text: string): Uint8Array | null;
|
|
74
|
+
/** Poll a pending query */
|
|
75
|
+
pollPendingQuery(conn: number): Uint8Array | null;
|
|
76
|
+
/** Cancel a pending query */
|
|
77
|
+
cancelPendingQuery(conn: number): boolean;
|
|
78
|
+
/** Fetch query results */
|
|
79
|
+
fetchQueryResults(conn: number): Uint8Array;
|
|
80
|
+
/** Get table names */
|
|
81
|
+
getTableNames(conn: number, text: string): string[];
|
|
82
|
+
/** Create a scalar function */
|
|
83
|
+
createScalarFunction(conn: number, name: string, returns: arrow.DataType, func: (...args: any[]) => void): void;
|
|
84
|
+
/** Prepare a statement and return its identifier */
|
|
85
|
+
createPrepared(conn: number, text: string): number;
|
|
86
|
+
/** Close a prepared statement */
|
|
87
|
+
closePrepared(conn: number, statement: number): void;
|
|
88
|
+
/** Execute a prepared statement and return the full result */
|
|
89
|
+
runPrepared(conn: number, statement: number, params: any[]): Uint8Array;
|
|
90
|
+
/** Execute a prepared statement and stream the result */
|
|
91
|
+
sendPrepared(conn: number, statement: number, params: any[]): Uint8Array;
|
|
92
|
+
/** Insert record batches from an arrow ipc stream */
|
|
93
|
+
insertArrowFromIPCStream(conn: number, buffer: Uint8Array, options?: ArrowInsertOptions): void;
|
|
94
|
+
/** Insert csv from path */
|
|
95
|
+
insertCSVFromPath(conn: number, path: string, options: CSVInsertOptions): void;
|
|
96
|
+
/** Insert json from path */
|
|
97
|
+
insertJSONFromPath(conn: number, path: string, options: JSONInsertOptions): void;
|
|
98
|
+
/** Glob file infos */
|
|
99
|
+
globFiles(path: string): WebFile[];
|
|
100
|
+
/** Register a file object URL */
|
|
101
|
+
registerFileURL(name: string, url: string, proto: DuckDBDataProtocol, directIO?: boolean): void;
|
|
102
|
+
/** Register file text */
|
|
103
|
+
registerFileText(name: string, text: string): void;
|
|
104
|
+
/** Register a file buffer */
|
|
105
|
+
registerFileBuffer(name: string, buffer: Uint8Array): void;
|
|
106
|
+
/** Register a file object URL */
|
|
107
|
+
registerFileHandle<HandleType>(name: string, handle: HandleType, protocol: DuckDBDataProtocol, directIO: boolean): void;
|
|
108
|
+
/** Drop file */
|
|
109
|
+
dropFile(name: string): void;
|
|
110
|
+
/** Drop files */
|
|
111
|
+
dropFiles(): void;
|
|
112
|
+
/** Flush all files */
|
|
113
|
+
flushFiles(): void;
|
|
114
|
+
/** Write a file to a path */
|
|
115
|
+
copyFileToPath(name: string, path: string): void;
|
|
116
|
+
/** Write a file to a buffer */
|
|
117
|
+
copyFileToBuffer(name: string): Uint8Array;
|
|
118
|
+
/** Enable tracking of file statistics */
|
|
119
|
+
collectFileStatistics(file: string, enable: boolean): void;
|
|
120
|
+
/** Export file statistics */
|
|
121
|
+
exportFileStatistics(file: string): FileStatistics;
|
|
122
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="emscripten" />
|
|
2
|
+
import { DuckDBModule } from './duckdb_module';
|
|
3
|
+
import { DuckDBBindingsBase } from './bindings_base';
|
|
4
|
+
import { DuckDBRuntime } from './runtime';
|
|
5
|
+
import { Logger } from '../log';
|
|
6
|
+
/** DuckDB bindings for the browser */
|
|
7
|
+
export declare abstract class DuckDBBrowserBindings extends DuckDBBindingsBase {
|
|
8
|
+
/** The path of the wasm module */
|
|
9
|
+
protected readonly mainModuleURL: string;
|
|
10
|
+
/** The path of the pthread worker script */
|
|
11
|
+
protected readonly pthreadWorkerURL: string | null;
|
|
12
|
+
/** Constructor */
|
|
13
|
+
constructor(logger: Logger, runtime: DuckDBRuntime, mainModuleURL: string, pthreadWorkerURL: string | null);
|
|
14
|
+
/** Locate a file */
|
|
15
|
+
protected locateFile(path: string, prefix: string): string;
|
|
16
|
+
/** Instantiate the wasm module */
|
|
17
|
+
protected instantiateWasm(imports: any, success: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void): Emscripten.WebAssemblyExports;
|
|
18
|
+
protected abstract instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DuckDBBrowserBindings } from './bindings_browser_base';
|
|
2
|
+
import { DuckDBModule } from './duckdb_module';
|
|
3
|
+
import { DuckDBRuntime } from './runtime';
|
|
4
|
+
import { Logger } from '../log';
|
|
5
|
+
/** DuckDB bindings for the browser */
|
|
6
|
+
export declare class DuckDB extends DuckDBBrowserBindings {
|
|
7
|
+
/** Constructor */
|
|
8
|
+
constructor(logger: Logger, runtime: DuckDBRuntime, mainModuleURL: string, pthreadWorkerURL?: string | null);
|
|
9
|
+
/** Instantiate the bindings */
|
|
10
|
+
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
|
|
11
|
+
}
|
|
12
|
+
export default DuckDB;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DuckDBBrowserBindings } from './bindings_browser_base';
|
|
2
|
+
import { DuckDBModule } from './duckdb_module';
|
|
3
|
+
import { DuckDBRuntime } from './runtime';
|
|
4
|
+
import { Logger } from '../log';
|
|
5
|
+
/** DuckDB bindings for the browser */
|
|
6
|
+
export declare class DuckDB extends DuckDBBrowserBindings {
|
|
7
|
+
/** Constructor */
|
|
8
|
+
constructor(logger: Logger, runtime: DuckDBRuntime, mainModuleURL: string, pthreadWorkerURL?: string | null);
|
|
9
|
+
/** Instantiate the bindings */
|
|
10
|
+
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
|
|
11
|
+
}
|
|
12
|
+
export default DuckDB;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DuckDBBrowserBindings } from './bindings_browser_base';
|
|
2
|
+
import { DuckDBModule } from './duckdb_module';
|
|
3
|
+
import { DuckDBRuntime } from './runtime';
|
|
4
|
+
import { Logger } from '../log';
|
|
5
|
+
/** DuckDB bindings for the browser */
|
|
6
|
+
export declare class DuckDB extends DuckDBBrowserBindings {
|
|
7
|
+
/** Constructor */
|
|
8
|
+
constructor(logger: Logger, runtime: DuckDBRuntime, mainModuleURL: string, pthreadWorkerURL?: string | null);
|
|
9
|
+
/** Instantiate the bindings */
|
|
10
|
+
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DuckDBConfig, DuckDBConnection, DuckDBDataProtocol, FileStatistics, InstantiationProgress } from '.';
|
|
2
|
+
import { CSVInsertOptions, JSONInsertOptions, ArrowInsertOptions } from './insert_options';
|
|
3
|
+
import { ScriptTokens } from './tokens';
|
|
4
|
+
import { WebFile } from './web_file';
|
|
5
|
+
import * as arrow from 'apache-arrow';
|
|
6
|
+
export interface DuckDBBindings {
|
|
7
|
+
open(config: DuckDBConfig): void;
|
|
8
|
+
reset(): void;
|
|
9
|
+
instantiate(onProgress: (p: InstantiationProgress) => void): Promise<this>;
|
|
10
|
+
getVersion(): string;
|
|
11
|
+
getFeatureFlags(): number;
|
|
12
|
+
tokenize(text: string): ScriptTokens;
|
|
13
|
+
connect(): DuckDBConnection;
|
|
14
|
+
disconnect(conn: number): void;
|
|
15
|
+
runQuery(conn: number, text: string): Uint8Array;
|
|
16
|
+
startPendingQuery(conn: number, text: string): Uint8Array | null;
|
|
17
|
+
pollPendingQuery(conn: number): Uint8Array | null;
|
|
18
|
+
cancelPendingQuery(conn: number): boolean;
|
|
19
|
+
fetchQueryResults(conn: number): Uint8Array;
|
|
20
|
+
getTableNames(conn: number, text: string): string[];
|
|
21
|
+
createPrepared(conn: number, text: string): number;
|
|
22
|
+
closePrepared(conn: number, statement: number): void;
|
|
23
|
+
runPrepared(conn: number, statement: number, params: any[]): Uint8Array;
|
|
24
|
+
sendPrepared(conn: number, statement: number, params: any[]): Uint8Array;
|
|
25
|
+
createScalarFunction(conn: number, name: string, returns: arrow.DataType, func: (...args: any[]) => void): void;
|
|
26
|
+
insertArrowFromIPCStream(conn: number, buffer: Uint8Array, options?: ArrowInsertOptions): void;
|
|
27
|
+
insertCSVFromPath(conn: number, path: string, options: CSVInsertOptions): void;
|
|
28
|
+
insertJSONFromPath(conn: number, path: string, options: JSONInsertOptions): void;
|
|
29
|
+
registerFileURL(name: string, url: string, proto: DuckDBDataProtocol, directIO: boolean): void;
|
|
30
|
+
registerFileText(name: string, text: string): void;
|
|
31
|
+
registerFileBuffer(name: string, buffer: Uint8Array): void;
|
|
32
|
+
registerFileHandle<HandleType>(name: string, handle: HandleType, protocol: DuckDBDataProtocol, directIO: boolean): void;
|
|
33
|
+
globFiles(path: string): WebFile[];
|
|
34
|
+
dropFile(name: string): void;
|
|
35
|
+
dropFiles(): void;
|
|
36
|
+
flushFiles(): void;
|
|
37
|
+
copyFileToPath(name: string, path: string): void;
|
|
38
|
+
copyFileToBuffer(name: string): Uint8Array;
|
|
39
|
+
collectFileStatistics(file: string, enable: boolean): void;
|
|
40
|
+
exportFileStatistics(file: string): FileStatistics;
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="emscripten" />
|
|
2
|
+
import { DuckDBModule } from './duckdb_module';
|
|
3
|
+
import { DuckDBBindingsBase } from './bindings_base';
|
|
4
|
+
import { DuckDBRuntime } from './runtime';
|
|
5
|
+
import { Logger } from '../log';
|
|
6
|
+
declare global {
|
|
7
|
+
var DUCKDB_RUNTIME: any;
|
|
8
|
+
}
|
|
9
|
+
/** DuckDB bindings for node.js */
|
|
10
|
+
export declare class DuckDBNodeBindings extends DuckDBBindingsBase {
|
|
11
|
+
/** The path of the wasm module */
|
|
12
|
+
protected readonly mainModulePath: string;
|
|
13
|
+
/** The path of the pthread worker script */
|
|
14
|
+
protected readonly pthreadWorkerPath: string | null;
|
|
15
|
+
/** Constructor */
|
|
16
|
+
constructor(logger: Logger, runtime: DuckDBRuntime, mainModulePath: string, pthreadWorkerPath: string | null);
|
|
17
|
+
/** Locate a file */
|
|
18
|
+
protected locateFile(path: string, prefix: string): string;
|
|
19
|
+
/** Instantiate the wasm module */
|
|
20
|
+
protected instantiateWasm(imports: any, success: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void): Emscripten.WebAssemblyExports;
|
|
21
|
+
/** Instantiate the bindings */
|
|
22
|
+
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DuckDBModule } from './duckdb_module';
|
|
2
|
+
import { DuckDBNodeBindings } from './bindings_node_base.js';
|
|
3
|
+
import { DuckDBRuntime } from './runtime';
|
|
4
|
+
import { Logger } from '../log';
|
|
5
|
+
/** DuckDB bindings for node.js */
|
|
6
|
+
export declare class DuckDB extends DuckDBNodeBindings {
|
|
7
|
+
/** Constructor */
|
|
8
|
+
constructor(logger: Logger, runtime: DuckDBRuntime, mainModulePath: string, pthreadWorkerPath?: string | null);
|
|
9
|
+
/** Instantiate the bindings */
|
|
10
|
+
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
|
|
11
|
+
}
|
|
12
|
+
export default DuckDB;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DuckDBNodeBindings } from './bindings_node_base.js';
|
|
2
|
+
import { Logger } from '../log.js';
|
|
3
|
+
import { DuckDBModule } from './duckdb_module';
|
|
4
|
+
import { DuckDBRuntime } from './runtime';
|
|
5
|
+
/** DuckDB bindings for node.js */
|
|
6
|
+
export declare class DuckDB extends DuckDBNodeBindings {
|
|
7
|
+
/** Constructor */
|
|
8
|
+
constructor(logger: Logger, runtime: DuckDBRuntime, mainModulePath: string, pthreadWorkerPath?: string | null);
|
|
9
|
+
/** Instantiate the bindings */
|
|
10
|
+
protected instantiateImpl(moduleOverrides: Partial<DuckDBModule>): Promise<DuckDBModule>;
|
|
11
|
+
}
|
|
12
|
+
export default DuckDB;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface DuckDBQueryConfig {
|
|
2
|
+
/**
|
|
3
|
+
* The polling interval for queries
|
|
4
|
+
*/
|
|
5
|
+
queryPollingInterval?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Cast BigInt to Double?
|
|
8
|
+
*/
|
|
9
|
+
castBigIntToDouble?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Cast Timestamp to Date64?
|
|
12
|
+
*/
|
|
13
|
+
castTimestampToDate?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Cast Timestamp to Date64?
|
|
16
|
+
*/
|
|
17
|
+
castDurationToTime64?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Cast Decimal to Double?
|
|
20
|
+
*/
|
|
21
|
+
castDecimalToDouble?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface DuckDBFilesystemConfig {
|
|
24
|
+
/**
|
|
25
|
+
* Allow falling back to full HTTP reads if the server does not support range requests.
|
|
26
|
+
*/
|
|
27
|
+
reliableHeadRequests?: boolean;
|
|
28
|
+
allowFullHTTPReads?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare enum DuckDBAccessMode {
|
|
31
|
+
UNDEFINED = 0,
|
|
32
|
+
AUTOMATIC = 1,
|
|
33
|
+
READ_ONLY = 2,
|
|
34
|
+
READ_WRITE = 3
|
|
35
|
+
}
|
|
36
|
+
export interface DuckDBConfig {
|
|
37
|
+
/**
|
|
38
|
+
* The database path
|
|
39
|
+
*/
|
|
40
|
+
path?: string;
|
|
41
|
+
/**
|
|
42
|
+
* The access mode
|
|
43
|
+
*/
|
|
44
|
+
accessMode?: DuckDBAccessMode;
|
|
45
|
+
/**
|
|
46
|
+
* The maximum number of threads.
|
|
47
|
+
* Note that this will only work with cross-origin isolated sites since it requires SharedArrayBuffers.
|
|
48
|
+
*/
|
|
49
|
+
maximumThreads?: number;
|
|
50
|
+
/**
|
|
51
|
+
* The query config
|
|
52
|
+
*/
|
|
53
|
+
query?: DuckDBQueryConfig;
|
|
54
|
+
/**
|
|
55
|
+
* The filesystem config
|
|
56
|
+
*/
|
|
57
|
+
filesystem?: DuckDBFilesystemConfig;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to allow unsigned extensions
|
|
60
|
+
*/
|
|
61
|
+
allowUnsignedExtensions?: boolean;
|
|
62
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
import { DuckDBBindings } from './bindings_interface';
|
|
3
|
+
import { CSVInsertOptions, JSONInsertOptions, ArrowInsertOptions } from './insert_options';
|
|
4
|
+
/** A thin helper to bind the connection id and talk record batches */
|
|
5
|
+
export declare class DuckDBConnection {
|
|
6
|
+
/** The bindings */
|
|
7
|
+
protected _bindings: DuckDBBindings;
|
|
8
|
+
/** The connection handle */
|
|
9
|
+
protected _conn: number;
|
|
10
|
+
/** Constructor */
|
|
11
|
+
constructor(bindings: DuckDBBindings, conn: number);
|
|
12
|
+
/** Close a connection */
|
|
13
|
+
close(): void;
|
|
14
|
+
/** Brave souls may use this function to consume the underlying connection id */
|
|
15
|
+
useUnsafe<R>(callback: (bindings: DuckDBBindings, conn: number) => R): R;
|
|
16
|
+
/** Run a query */
|
|
17
|
+
query<T extends {
|
|
18
|
+
[key: string]: arrow.DataType;
|
|
19
|
+
} = any>(text: string): arrow.Table<T>;
|
|
20
|
+
/** Send a query */
|
|
21
|
+
send<T extends {
|
|
22
|
+
[key: string]: arrow.DataType;
|
|
23
|
+
} = any>(text: string): Promise<arrow.RecordBatchStreamReader<T>>;
|
|
24
|
+
/** Cancel a query that was sent earlier */
|
|
25
|
+
cancelSent(): boolean;
|
|
26
|
+
/** Get table names */
|
|
27
|
+
getTableNames(query: string): string[];
|
|
28
|
+
/** Create a prepared statement */
|
|
29
|
+
prepare<T extends {
|
|
30
|
+
[key: string]: arrow.DataType;
|
|
31
|
+
} = any>(text: string): PreparedStatement;
|
|
32
|
+
/** Create a scalar function */
|
|
33
|
+
createScalarFunction(name: string, returns: arrow.DataType, func: (...args: any[]) => void): void;
|
|
34
|
+
/** Insert an arrow table */
|
|
35
|
+
insertArrowTable(table: arrow.Table, options: ArrowInsertOptions): void;
|
|
36
|
+
/** Insert an arrow table from an ipc stream */
|
|
37
|
+
insertArrowFromIPCStream(buffer: Uint8Array, options: ArrowInsertOptions): void;
|
|
38
|
+
/** Inesrt csv file from path */
|
|
39
|
+
insertCSVFromPath(path: string, options: CSVInsertOptions): void;
|
|
40
|
+
/** Insert json file from path */
|
|
41
|
+
insertJSONFromPath(path: string, options: JSONInsertOptions): void;
|
|
42
|
+
}
|
|
43
|
+
/** A result stream iterator */
|
|
44
|
+
export declare class ResultStreamIterator implements Iterable<Uint8Array> {
|
|
45
|
+
protected bindings: DuckDBBindings;
|
|
46
|
+
protected conn: number;
|
|
47
|
+
protected header: Uint8Array;
|
|
48
|
+
/** First chunk? */
|
|
49
|
+
_first: boolean;
|
|
50
|
+
/** Reached end of stream? */
|
|
51
|
+
_depleted: boolean;
|
|
52
|
+
constructor(bindings: DuckDBBindings, conn: number, header: Uint8Array);
|
|
53
|
+
next(): IteratorResult<Uint8Array>;
|
|
54
|
+
[Symbol.iterator](): this;
|
|
55
|
+
}
|
|
56
|
+
/** A thin helper to bind the prepared statement id*/
|
|
57
|
+
export declare class PreparedStatement<T extends {
|
|
58
|
+
[key: string]: arrow.DataType;
|
|
59
|
+
} = any> {
|
|
60
|
+
/** The bindings */
|
|
61
|
+
protected readonly bindings: DuckDBBindings;
|
|
62
|
+
/** The connection id */
|
|
63
|
+
protected readonly connectionId: number;
|
|
64
|
+
/** The statement id */
|
|
65
|
+
protected readonly statementId: number;
|
|
66
|
+
/** Constructor */
|
|
67
|
+
constructor(bindings: DuckDBBindings, connectionId: number, statementId: number);
|
|
68
|
+
/** Close a prepared statement */
|
|
69
|
+
close(): void;
|
|
70
|
+
/** Run a prepared statement */
|
|
71
|
+
query(...params: any[]): arrow.Table<T>;
|
|
72
|
+
/** Send a prepared statement */
|
|
73
|
+
send(...params: any[]): arrow.RecordBatchStreamReader<T>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="emscripten" />
|
|
2
|
+
export interface PThread {
|
|
3
|
+
unusedWorkers: Worker[];
|
|
4
|
+
runningWorkers: Worker[];
|
|
5
|
+
}
|
|
6
|
+
export interface DuckDBModule extends EmscriptenModule {
|
|
7
|
+
stackSave: typeof stackSave;
|
|
8
|
+
stackAlloc: typeof stackAlloc;
|
|
9
|
+
stackRestore: typeof stackRestore;
|
|
10
|
+
ccall: typeof ccall;
|
|
11
|
+
PThread: PThread;
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface FileBlockStatistics {
|
|
2
|
+
/** The file reads cold */
|
|
3
|
+
file_reads_cold: number;
|
|
4
|
+
/** The file reads aheads */
|
|
5
|
+
file_reads_ahead: number;
|
|
6
|
+
/** The file reads cached */
|
|
7
|
+
file_reads_cached: number;
|
|
8
|
+
/** The file writes */
|
|
9
|
+
file_writes: number;
|
|
10
|
+
/** The page accesses */
|
|
11
|
+
page_accesses: number;
|
|
12
|
+
/** The page loads */
|
|
13
|
+
page_loads: number;
|
|
14
|
+
}
|
|
15
|
+
/** The file block statistics */
|
|
16
|
+
export declare class FileStatistics {
|
|
17
|
+
/** The cold file reads */
|
|
18
|
+
totalFileReadsCold: number;
|
|
19
|
+
/** The file readaheads */
|
|
20
|
+
totalFileReadsAhead: number;
|
|
21
|
+
/** The cached file reads */
|
|
22
|
+
totalFileReadsCached: number;
|
|
23
|
+
/** The file writes */
|
|
24
|
+
totalFileWrites: number;
|
|
25
|
+
/** The page accesses */
|
|
26
|
+
totalPageAccesses: number;
|
|
27
|
+
/** The page loads */
|
|
28
|
+
totalPageLoads: number;
|
|
29
|
+
/** The blocks */
|
|
30
|
+
blockSize: number;
|
|
31
|
+
/** The blocks */
|
|
32
|
+
blockStats: Uint8Array;
|
|
33
|
+
constructor(u8array: Uint8Array);
|
|
34
|
+
/** The block stats */
|
|
35
|
+
getBlockStats(index: number, out?: FileBlockStatistics): FileBlockStatistics;
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './bindings_interface';
|
|
2
|
+
export * from './bindings_base';
|
|
3
|
+
export * from './config';
|
|
4
|
+
export * from './connection';
|
|
5
|
+
export * from './duckdb_module';
|
|
6
|
+
export * from './file_stats';
|
|
7
|
+
export * from './runtime';
|
|
8
|
+
export * from './insert_options';
|
|
9
|
+
export * from './progress';
|
|
10
|
+
export * from './tokens';
|
|
11
|
+
export * from './web_file';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
import { SQLField } from '../json_typedef';
|
|
3
|
+
export declare enum JSONTableShape {
|
|
4
|
+
ROW_ARRAY = "row-array",
|
|
5
|
+
COLUMN_OBJECT = "column-object"
|
|
6
|
+
}
|
|
7
|
+
export interface JSONInsertOptions {
|
|
8
|
+
name: string;
|
|
9
|
+
schema?: string;
|
|
10
|
+
create?: boolean;
|
|
11
|
+
shape?: JSONTableShape;
|
|
12
|
+
columns?: {
|
|
13
|
+
[key: string]: arrow.DataType;
|
|
14
|
+
};
|
|
15
|
+
columnsFlat?: SQLField[];
|
|
16
|
+
}
|
|
17
|
+
export interface CSVInsertOptions {
|
|
18
|
+
name: string;
|
|
19
|
+
schema?: string;
|
|
20
|
+
create?: boolean;
|
|
21
|
+
header?: boolean;
|
|
22
|
+
delimiter?: string;
|
|
23
|
+
quote?: string;
|
|
24
|
+
escape?: string;
|
|
25
|
+
skip?: number;
|
|
26
|
+
detect?: boolean;
|
|
27
|
+
dateFormat?: string;
|
|
28
|
+
timestampFormat?: string;
|
|
29
|
+
columns?: {
|
|
30
|
+
[key: string]: arrow.DataType;
|
|
31
|
+
};
|
|
32
|
+
columnsFlat?: SQLField[];
|
|
33
|
+
}
|
|
34
|
+
export interface ArrowInsertOptions {
|
|
35
|
+
name: string;
|
|
36
|
+
schema?: string;
|
|
37
|
+
create?: boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** An instantiation progress */
|
|
2
|
+
export interface InstantiationProgress {
|
|
3
|
+
startedAt: Date;
|
|
4
|
+
updatedAt: Date;
|
|
5
|
+
bytesTotal: number;
|
|
6
|
+
bytesLoaded: number;
|
|
7
|
+
}
|
|
8
|
+
/** An instantiation progress handler */
|
|
9
|
+
export type InstantiationProgressHandler = (p: InstantiationProgress) => void;
|