@motherduck/wasm-client 0.4.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.
Files changed (53) hide show
  1. package/README.md +218 -0
  2. package/index.js +1 -0
  3. package/index.js.map +7 -0
  4. package/index_with_arrow.js +20 -0
  5. package/package.json +21 -0
  6. package/types/LogSink.d.ts +6 -0
  7. package/types/MaterializedQueryTask.d.ts +15 -0
  8. package/types/QueryTypes.d.ts +48 -0
  9. package/types/StreamingQueryTask.d.ts +14 -0
  10. package/types/TaskSequencer.d.ts +56 -0
  11. package/types/api.d.ts +32 -0
  12. package/types/arrow/AsyncDuckDBRecordBatchIterator.d.ts +13 -0
  13. package/types/arrow/DuckDBRecordBatch.d.ts +14 -0
  14. package/types/arrow/TypedTypeMap.d.ts +2 -0
  15. package/types/arrow/duckDBTypeFromArrowType.d.ts +4 -0
  16. package/types/arrow/duckDBValueFromArrowData.d.ts +8 -0
  17. package/types/createDeferred.d.ts +6 -0
  18. package/types/createHRTime.d.ts +1 -0
  19. package/types/duckdb/AsyncDuckDBDataBatchIterator.d.ts +3 -0
  20. package/types/duckdb/DuckDBData.d.ts +56 -0
  21. package/types/duckdb/DuckDBDataReader.d.ts +68 -0
  22. package/types/duckdb/DuckDBRow.d.ts +4 -0
  23. package/types/duckdb/conversion/dateTimeStringConversion.d.ts +12 -0
  24. package/types/duckdb/conversion/displayStringForDuckDBValue.d.ts +2 -0
  25. package/types/duckdb/conversion/stringFromBlob.d.ts +2 -0
  26. package/types/duckdb/conversion/stringFromDecimal.d.ts +18 -0
  27. package/types/duckdb/files.d.ts +13 -0
  28. package/types/duckdb/types/DuckDBType.d.ts +110 -0
  29. package/types/duckdb/types/DuckDBTypes.d.ts +39 -0
  30. package/types/duckdb/types/index.d.ts +2 -0
  31. package/types/duckdb/values/DuckDBBlob.d.ts +6 -0
  32. package/types/duckdb/values/DuckDBDate.d.ts +6 -0
  33. package/types/duckdb/values/DuckDBDecimal.d.ts +10 -0
  34. package/types/duckdb/values/DuckDBInterval.d.ts +8 -0
  35. package/types/duckdb/values/DuckDBList.d.ts +7 -0
  36. package/types/duckdb/values/DuckDBMap.d.ts +7 -0
  37. package/types/duckdb/values/DuckDBMapEntry.d.ts +5 -0
  38. package/types/duckdb/values/DuckDBStruct.d.ts +7 -0
  39. package/types/duckdb/values/DuckDBStructEntry.d.ts +5 -0
  40. package/types/duckdb/values/DuckDBTime.d.ts +6 -0
  41. package/types/duckdb/values/DuckDBTimestampMicroseconds.d.ts +8 -0
  42. package/types/duckdb/values/DuckDBTimestampMilliseconds.d.ts +6 -0
  43. package/types/duckdb/values/DuckDBTimestampNanoseconds.d.ts +6 -0
  44. package/types/duckdb/values/DuckDBTimestampSeconds.d.ts +6 -0
  45. package/types/duckdb/values/DuckDBValue.d.ts +2 -0
  46. package/types/duckdb/values/SpecialDuckDBValue.d.ts +4 -0
  47. package/types/duckdb/values/index.d.ts +16 -0
  48. package/types/duckdb/worker_factory.d.ts +13 -0
  49. package/types/extractWrappedErrorMessage.d.ts +17 -0
  50. package/types/getErrorMessage.d.ts +1 -0
  51. package/types/index.d.ts +12 -0
  52. package/types/nowMicroSec.d.ts +1 -0
  53. package/types/observability.d.ts +26 -0
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@motherduck/wasm-client",
3
+ "version": "0.4.0",
4
+ "description": "Client library for MotherDuck-enabled DuckDB powered by WebAssembly (WASM)",
5
+ "browser": "index.js",
6
+ "types": "types/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./types/index.d.ts",
10
+ "default": "./index.js"
11
+ },
12
+ "./with-arrow": {
13
+ "types": "./types/index.d.ts",
14
+ "default": "./index_with_arrow.js"
15
+ }
16
+ },
17
+ "peerDependencies": {
18
+ "apache-arrow": "^14.0.x"
19
+ },
20
+ "scripts": {}
21
+ }
@@ -0,0 +1,6 @@
1
+ export interface LogSink {
2
+ debug(message?: any, ...optionalParams: any[]): void;
3
+ log(message?: any, ...optionalParams: any[]): void;
4
+ warn(message?: any, ...optionalParams: any[]): void;
5
+ error(message?: any, ...optionalParams: any[]): void;
6
+ }
@@ -0,0 +1,15 @@
1
+ import { AsyncDuckDBConnection } from '@duckdb/duckdb-wasm';
2
+ import { MaterializedQueryResult } from './QueryTypes';
3
+ import { Task } from './TaskSequencer';
4
+ export declare class MaterializedQueryTask implements Task<MaterializedQueryResult> {
5
+ private connection;
6
+ private deferredConnection;
7
+ private query;
8
+ private args?;
9
+ private creationTime;
10
+ constructor(connection: Promise<AsyncDuckDBConnection>, query: string, args?: any[]);
11
+ run(initialQueuePosition?: number): Promise<MaterializedQueryResult>;
12
+ cancel(): Promise<boolean>;
13
+ private getConnection;
14
+ private sendQuery;
15
+ }
@@ -0,0 +1,48 @@
1
+ import { AsyncRecordBatchStreamReader } from 'apache-arrow';
2
+ import { TypedTypeMap } from './arrow/TypedTypeMap';
3
+ import { AsyncDuckDBDataBatchIterator } from './duckdb/AsyncDuckDBDataBatchIterator';
4
+ import { DuckDBData } from './duckdb/DuckDBData';
5
+ import { DuckDBDataReader } from './duckdb/DuckDBDataReader';
6
+ export interface MaterializedQueryResult {
7
+ type: 'materialized';
8
+ initialQueuePosition?: number;
9
+ queueTime?: [number, number];
10
+ executionTime: [number, number];
11
+ /**
12
+ * Full result set.
13
+ *
14
+ * Includes column metadata, such as types. Supports duplicate column names without renaming.
15
+ *
16
+ * See the `DuckDBData` interface for details.
17
+ */
18
+ data: DuckDBData;
19
+ }
20
+ export interface StreamingQueryResult {
21
+ type: 'streaming';
22
+ /**
23
+ * Stream of underlying Arrow RecordBatches. Useful if you need results in Arrow format, but note that the conversion
24
+ * of some value types, especially dates, times, and decimals, to JavaScript types is lossy in some cases, and also
25
+ * the conversion of several types to string does not match DuckDB's format.
26
+ */
27
+ arrowStream: AsyncRecordBatchStreamReader<TypedTypeMap>;
28
+ /**
29
+ * Async iterator of DuckDB data batches. DuckDB data batches are similar to Arrow RecordBatches, but expose DuckDB
30
+ * types and values, preserving full range and precision, and matching DuckDB's format when converted to strings.
31
+ */
32
+ dataStream: AsyncDuckDBDataBatchIterator;
33
+ /**
34
+ * Convenience wrapper around dataStream. Enables reading DuckDB data up to some row count, and exposes the DuckDBData
35
+ * interface for accessing all rows read so far (not just one batch).
36
+ */
37
+ dataReader: DuckDBDataReader;
38
+ }
39
+ export type QueryResult = MaterializedQueryResult | StreamingQueryResult;
40
+ export interface QuerySuccess<T extends QueryResult> {
41
+ status: 'success';
42
+ result: T;
43
+ }
44
+ export interface QueryError {
45
+ status: 'error';
46
+ err: Error;
47
+ }
48
+ export type SafeQueryResult<T extends QueryResult> = QuerySuccess<T> | QueryError;
@@ -0,0 +1,14 @@
1
+ import { AsyncDuckDBConnection } from '@duckdb/duckdb-wasm';
2
+ import { StreamingQueryResult } from './QueryTypes';
3
+ import { Task } from './TaskSequencer';
4
+ export declare class StreamingQueryTask implements Task<StreamingQueryResult> {
5
+ private connection;
6
+ private deferredConnection;
7
+ private query;
8
+ private args?;
9
+ constructor(connection: Promise<AsyncDuckDBConnection>, query: string, args?: any[]);
10
+ run(): Promise<StreamingQueryResult>;
11
+ cancel(): Promise<boolean>;
12
+ private getConnection;
13
+ private sendQuery;
14
+ }
@@ -0,0 +1,56 @@
1
+ import { LogSink } from './LogSink';
2
+ /**
3
+ * Represents a task that can be sequenced by TaskSequencer.
4
+ *
5
+ * Implemented by users of TaskSequencer.
6
+ */
7
+ export interface Task<T> {
8
+ /**
9
+ * Run the task and return a promise for the results.
10
+ *
11
+ * The argument `initialQueuePosition` indicates the initial index of this task on the queue when it was first enqueued.
12
+ * This can be useful for determining whether a task was pending for a significant amount of time.
13
+ */
14
+ run: (initialQueuePosition?: number) => Promise<T>;
15
+ /**
16
+ * Attempt to cancel a running task, and return a boolean promise indicating whether the attempt was successful.
17
+ */
18
+ cancel: () => Promise<boolean>;
19
+ }
20
+ /**
21
+ * Sequences user-defined Tasks, ensuring only one is running at a given time.
22
+ * Supports cancellation.
23
+ */
24
+ export declare class TaskSequencer<T> {
25
+ private nextTaskId;
26
+ private queuedTaskIds;
27
+ private queuedTasksById;
28
+ private processingQueue;
29
+ private logSink?;
30
+ constructor(logSink?: LogSink);
31
+ /**
32
+ * Append a task to the queue, and return its unique id.
33
+ *
34
+ * The id can be used to get the result (using `taskResult`) or cancel (using `cancelTask`).
35
+ */
36
+ enqueueTask(task: Task<T>): string;
37
+ /**
38
+ * Attempt to cancel a previously enqueued task.
39
+ * Returns a boolean promise indicating whether the attempt succeeded.
40
+ *
41
+ * In addition to the `taskId` to cancel, takes an optional `errorMessage` to supply to the rejected task promise, if a pending task is cancelled.
42
+ * If a running task is cancelled, then the task implementation controls the error message in the rejected task promise.
43
+ */
44
+ cancelTask(taskId: string, errorMessage?: string): Promise<boolean>;
45
+ /**
46
+ * Returns a promise for the result of previously-enqueue task.
47
+ */
48
+ taskResult(taskId: string): Promise<T>;
49
+ private logDebug;
50
+ private logWarn;
51
+ private createTaskId;
52
+ private addQueuedTask;
53
+ private scheduleProcessQueueIfNeeded;
54
+ private processQueue;
55
+ private processFirstQueuedTask;
56
+ }
package/types/api.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { ScriptTokens, /*StreamToTableOptions,*/ TokenType } from '@duckdb/duckdb-wasm';
2
+ import { MaterializedQueryResult, SafeQueryResult, StreamingQueryResult } from './QueryTypes';
3
+ import { MDConnectionParams } from './duckdb/worker_factory';
4
+ export { ScriptTokens, /*StreamToTableOptions,*/ TokenType };
5
+ export declare class MDConnection {
6
+ readonly params: MDConnectionParams;
7
+ private deferredDdbConnection;
8
+ private sequencer;
9
+ readonly id: string;
10
+ static idMap: {
11
+ [id: string]: MDConnection;
12
+ };
13
+ private constructor();
14
+ static create(params: MDConnectionParams): MDConnection;
15
+ isInitialized(): Promise<boolean>;
16
+ static getById(id: string): MDConnection | undefined;
17
+ tokenize(text: string): Promise<ScriptTokens>;
18
+ enqueueQuery(query: string, args?: any[]): string;
19
+ safeEvaluateQuery(query: string): Promise<SafeQueryResult<MaterializedQueryResult>>;
20
+ safeEvaluatePreparedStatement(query: string, ...args: any[]): Promise<SafeQueryResult<MaterializedQueryResult>>;
21
+ safeEvaluateStreamingQuery(query: string): Promise<SafeQueryResult<StreamingQueryResult>>;
22
+ safeEvaluateStreamingPreparedStatement(query: string, args: any[]): Promise<SafeQueryResult<StreamingQueryResult>>;
23
+ safeEvaluateQueuedQuery(queryId: string): Promise<SafeQueryResult<MaterializedQueryResult>>;
24
+ evaluateQuery(query: string): Promise<MaterializedQueryResult>;
25
+ evaluatePreparedStatement(query: string, args: any[]): Promise<MaterializedQueryResult>;
26
+ evaluateStreamingQuery(query: string): Promise<StreamingQueryResult>;
27
+ evaluateStreamingPreparedStatement(query: string, args: any[]): Promise<StreamingQueryResult>;
28
+ private evaluateExclusive;
29
+ evaluateQueuedQuery(queryId: string): Promise<MaterializedQueryResult>;
30
+ cancelQuery(queryId: string, errorMessage?: string): Promise<boolean>;
31
+ close(): Promise<void>;
32
+ }
@@ -0,0 +1,13 @@
1
+ import { RecordBatch } from 'apache-arrow';
2
+ import { AsyncDuckDBDataBatchIterator, DuckDBDataBatchIteratorResult } from '../duckdb/AsyncDuckDBDataBatchIterator';
3
+ import { DuckDBData } from '../duckdb/DuckDBData';
4
+ import { TypedTypeMap } from './TypedTypeMap';
5
+ export type AsyncRecordBatchIterator = AsyncIterator<RecordBatch<TypedTypeMap>, RecordBatch<TypedTypeMap> | undefined>;
6
+ export declare class AsyncDuckDBRecordBatchIterator implements AsyncDuckDBDataBatchIterator {
7
+ private recordBatchIterator;
8
+ constructor(recordBatchIterator: AsyncRecordBatchIterator);
9
+ next(): Promise<DuckDBDataBatchIteratorResult>;
10
+ return(value?: DuckDBData): Promise<DuckDBDataBatchIteratorResult>;
11
+ throw(e?: any): Promise<DuckDBDataBatchIteratorResult>;
12
+ [Symbol.asyncIterator](): AsyncDuckDBDataBatchIterator;
13
+ }
@@ -0,0 +1,14 @@
1
+ import { RecordBatch } from 'apache-arrow';
2
+ import { DuckDBData } from '../duckdb/DuckDBData';
3
+ import { DuckDBType } from '../duckdb/types';
4
+ import { DuckDBValue } from '../duckdb/values';
5
+ import { TypedTypeMap } from './TypedTypeMap';
6
+ export declare class DuckDBRecordBatch extends DuckDBData {
7
+ private recordBatch;
8
+ constructor(recordBatch: RecordBatch<TypedTypeMap>);
9
+ get columnCount(): number;
10
+ get rowCount(): number;
11
+ columnName(columnIndex: number): string;
12
+ columnType(columnIndex: number): DuckDBType;
13
+ value(columnIndex: number, rowIndex: number): DuckDBValue;
14
+ }
@@ -0,0 +1,2 @@
1
+ import { DataType, Type } from 'apache-arrow';
2
+ export type TypedTypeMap = Record<string | number | symbol, DataType<Type, TypedTypeMap>>;
@@ -0,0 +1,4 @@
1
+ import { DataType, Type } from 'apache-arrow';
2
+ import { DuckDBType } from '../duckdb/types';
3
+ import { TypedTypeMap } from './TypedTypeMap';
4
+ export declare function duckDBTypeFromArrowType(type: DataType<Type, TypedTypeMap>): DuckDBType;
@@ -0,0 +1,8 @@
1
+ import { Data, DataType, Type } from 'apache-arrow';
2
+ import { DuckDBValue } from '../duckdb/values';
3
+ import { TypedTypeMap } from './TypedTypeMap';
4
+ type ArrowDataType = DataType<Type, TypedTypeMap>;
5
+ type ArrowData = Data<ArrowDataType>;
6
+ export declare function duckDBValueFromArrowData(data: ArrowData, rowIndex: number): DuckDBValue;
7
+ export declare function duckDBValuesFromArrowData(data: ArrowData, begin: number, end: number): readonly DuckDBValue[];
8
+ export {};
@@ -0,0 +1,6 @@
1
+ export interface Deferred<T> {
2
+ readonly promise: Promise<T>;
3
+ readonly resolve: (value: T | PromiseLike<T>) => void;
4
+ readonly reject: (reason?: any) => void;
5
+ }
6
+ export declare function createDeferred<T = unknown>(): Deferred<T>;
@@ -0,0 +1 @@
1
+ export declare function createHRTime(startMicroSec: number, endMicroSec: number): [number, number];
@@ -0,0 +1,3 @@
1
+ import { DuckDBData } from './DuckDBData';
2
+ export type DuckDBDataBatchIteratorResult = IteratorResult<DuckDBData, DuckDBData | undefined>;
3
+ export type AsyncDuckDBDataBatchIterator = AsyncIterator<DuckDBData, DuckDBData | undefined>;
@@ -0,0 +1,56 @@
1
+ import { DuckDBRow } from './DuckDBRow';
2
+ import { DuckDBType } from './types/DuckDBType';
3
+ import { DuckDBValue } from './values';
4
+ /**
5
+ * A two-dimensional table of data along with column metadata.
6
+ *
7
+ * May represent either a partial or full result set, or a batch of rows read from a result stream.
8
+ * */
9
+ export declare abstract class DuckDBData {
10
+ /**
11
+ * Number of columns.
12
+ *
13
+ * May be zero until the first part of the result is read. Will not change after the initial read.
14
+ */
15
+ abstract get columnCount(): number;
16
+ /**
17
+ * Current number of rows.
18
+ *
19
+ * For a partial result set, this may change as more rows are read.
20
+ * For a full result, or a batch, this will not change.
21
+ */
22
+ abstract get rowCount(): number;
23
+ /**
24
+ * Returns the name of column at the given index (starting at zero).
25
+ *
26
+ * Note that duplicate column names are possible.
27
+ */
28
+ abstract columnName(columnIndex: number): string;
29
+ /**
30
+ * Returns the type of the column at the given index (starting at zero).
31
+ */
32
+ abstract columnType(columnIndex: number): DuckDBType;
33
+ /**
34
+ * Returns the value for the given column and row. Both are zero-indexed.
35
+ */
36
+ abstract value(columnIndex: number, rowIndex: number): DuckDBValue;
37
+ /**
38
+ * Returns the single value, assuming exactly one column and row. Throws otherwise.
39
+ */
40
+ singleValue(): DuckDBValue;
41
+ /**
42
+ * Returns the column names as an array.
43
+ */
44
+ columnNames(): readonly string[];
45
+ /**
46
+ * Returns the column names as an array, deduplicated following DuckDB's "Auto-Increment Duplicate Column Names"
47
+ * behavior.
48
+ */
49
+ deduplicatedColumnNames(): readonly string[];
50
+ /**
51
+ * Returns the data as an array of row objects, keyed by column names.
52
+ *
53
+ * The column names are deduplicated following DuckDB's "Auto-Increment Duplicate Column Names" behavior.
54
+ */
55
+ toRows(): readonly DuckDBRow[];
56
+ }
@@ -0,0 +1,68 @@
1
+ import { AsyncDuckDBDataBatchIterator } from './AsyncDuckDBDataBatchIterator';
2
+ import { DuckDBData } from './DuckDBData';
3
+ import { DuckDBType } from './types';
4
+ import { DuckDBValue } from './values';
5
+ /**
6
+ * A result set that can be read incrementally.
7
+ *
8
+ * Represents either a partial or full result.
9
+ * For full results, the `done` property will be true.
10
+ * To read more rows into a partial result, use the `readUntil` or `readAll` methods.
11
+ */
12
+ export declare class DuckDBDataReader extends DuckDBData {
13
+ private readonly iterator;
14
+ private iteratorDone;
15
+ private totalRowsRead;
16
+ private readonly batches;
17
+ private readonly batchSizeRuns;
18
+ constructor(iterator: AsyncDuckDBDataBatchIterator);
19
+ /**
20
+ * Number of columns.
21
+ *
22
+ * Will be zero until the first part of the result is read. Will not change after the initial read.
23
+ */
24
+ get columnCount(): number;
25
+ /**
26
+ * Current number of rows.
27
+ *
28
+ * For a partial result set, with `done` false, this may change as more rows are read.
29
+ * For a full result, with `done` true, this will not change.
30
+ */
31
+ get rowCount(): number;
32
+ /**
33
+ * Returns the name of column at the given index (starting at zero).
34
+ *
35
+ * Note that duplicate column names are possible.
36
+ *
37
+ * Will return an error if no part of the result has been read yet.
38
+ */
39
+ columnName(columnIndex: number): string;
40
+ /**
41
+ * Returns the type of the column at the given index (starting at zero).
42
+ *
43
+ * Will return an error if no part of the result has been read yet.
44
+ */
45
+ columnType(columnIndex: number): DuckDBType;
46
+ /**
47
+ * Returns the value for the given column and row. Both are zero-indexed.
48
+ *
49
+ * Will return an error if `rowIndex` is not less than the current `rowCount`.
50
+ */
51
+ value(columnIndex: number, rowIndex: number): DuckDBValue;
52
+ /**
53
+ * Returns true if all rows have been read.
54
+ */
55
+ get done(): boolean;
56
+ /**
57
+ * Read all rows.
58
+ */
59
+ readAll(): Promise<void>;
60
+ /**
61
+ * Read rows until at least the given target row count has been met.
62
+ *
63
+ * Note that the resulting row count could be greater than the target, since rows are read in batches, typically of 2048 rows each.
64
+ */
65
+ readUntil(targetRowCount: number): Promise<void>;
66
+ private read;
67
+ private updateBatchSizeRuns;
68
+ }
@@ -0,0 +1,4 @@
1
+ import { DuckDBValue } from './values/DuckDBValue';
2
+ export interface DuckDBRow {
3
+ readonly [columnName: string]: DuckDBValue;
4
+ }
@@ -0,0 +1,12 @@
1
+ export declare function getDuckDBDateStringFromYearMonthDay(year: number, month: number, dayOfMonth: number): string;
2
+ export declare function getDuckDBDateStringFromDays(days: number): string;
3
+ export declare function getDuckDBTimeStringFromParts(hoursPart: bigint, minutesPart: bigint, secondsPart: bigint, microsecondsPart: bigint): string;
4
+ export declare function getDuckDBTimeStringFromPositiveMicroseconds(positiveMicroseconds: bigint): string;
5
+ export declare function getDuckDBTimeStringFromMicrosecondsInDay(microsecondsInDay: bigint): string;
6
+ export declare function getDuckDBTimeStringFromMicroseconds(microseconds: bigint): string;
7
+ export declare function getDuckDBTimestampStringFromDaysAndMicroseconds(days: bigint, microsecondsInDay: bigint, timezone?: string | null): string;
8
+ export declare function getDuckDBTimestampStringFromMicroseconds(microseconds: bigint, timezone?: string | null): string;
9
+ export declare function getDuckDBTimestampStringFromSeconds(seconds: bigint, timezone?: string | null): string;
10
+ export declare function getDuckDBTimestampStringFromMilliseconds(milliseconds: bigint, timezone?: string | null): string;
11
+ export declare function getDuckDBTimestampStringFromNanoseconds(nanoseconds: bigint, timezone?: string | null): string;
12
+ export declare function getDuckDBIntervalString(months: number, days: number, microseconds: bigint): string;
@@ -0,0 +1,2 @@
1
+ import { DuckDBValue } from '../values/DuckDBValue';
2
+ export declare function displayStringForDuckDBValue(value: DuckDBValue): string;
@@ -0,0 +1,2 @@
1
+ /** Matches BLOB-to-VARCHAR conversion behavior of DuckDB. */
2
+ export declare function stringFromBlob(bytes: Uint8Array): string;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Decimal string formatting.
3
+ *
4
+ * Supports a subset of the functionality of `BigInt.prototype.toLocaleString` for locale-specific formatting.
5
+ */
6
+ export interface DuckDBDecimalFormatOptions {
7
+ useGrouping?: boolean;
8
+ minimumFractionDigits?: number;
9
+ maximumFractionDigits?: number;
10
+ }
11
+ export interface LocaleOptions {
12
+ locales?: string | string[];
13
+ options?: DuckDBDecimalFormatOptions;
14
+ }
15
+ /**
16
+ * Convert a scaled decimal value to a string, possibly using locale-specific formatting.
17
+ */
18
+ export declare function stringFromDecimal(scaledValue: bigint, scale: number, localeOptions?: LocaleOptions): string;
@@ -0,0 +1,13 @@
1
+ import { WebFile } from '@duckdb/duckdb-wasm';
2
+ import { MDConnectionParams } from './worker_factory';
3
+ /**
4
+ * Register the files within DuckDB WASM
5
+ */
6
+ export declare function registerFiles(params: MDConnectionParams, files: FileList): Promise<void>;
7
+ /**
8
+ * Read local data files from wasm db
9
+ *
10
+ * @returns Local data files list.
11
+ */
12
+ export declare function readLocalFS(params: MDConnectionParams): Promise<WebFile[]>;
13
+ export { WebFile };
@@ -0,0 +1,110 @@
1
+ export type StructEntry = {
2
+ readonly key: string;
3
+ readonly valueType: DuckDBType;
4
+ };
5
+ export type UnionAlternative = {
6
+ readonly tag: string;
7
+ readonly valueType: DuckDBType;
8
+ };
9
+ export type BigIntDuckDBType = {
10
+ readonly name: 'BIGINT';
11
+ };
12
+ export type BitDuckDBType = {
13
+ readonly name: 'BIT';
14
+ };
15
+ export type BooleanDuckDBType = {
16
+ readonly name: 'BOOLEAN';
17
+ };
18
+ export type BlobDuckDBType = {
19
+ readonly name: 'BLOB';
20
+ };
21
+ export type DateDuckDBType = {
22
+ readonly name: 'DATE';
23
+ };
24
+ export type DoubleDuckDBType = {
25
+ readonly name: 'DOUBLE';
26
+ };
27
+ export type DecimalDuckDBType = {
28
+ readonly name: 'DECIMAL';
29
+ readonly width?: number;
30
+ readonly scale?: number;
31
+ };
32
+ export type EnumDuckDBType = {
33
+ readonly name: 'ENUM';
34
+ };
35
+ export type HugeIntDuckDBType = {
36
+ readonly name: 'HUGEINT';
37
+ };
38
+ export type IntegerDuckDBType = {
39
+ readonly name: 'INTEGER';
40
+ };
41
+ export type IntervalDuckDBType = {
42
+ readonly name: 'INTERVAL';
43
+ };
44
+ export type ListDuckDBType = {
45
+ readonly name: 'LIST';
46
+ readonly valueType: DuckDBType;
47
+ };
48
+ export type MapDuckDBType = {
49
+ readonly name: 'MAP';
50
+ readonly keyType: DuckDBType;
51
+ readonly valueType: DuckDBType;
52
+ };
53
+ export type RealDuckDBType = {
54
+ readonly name: 'REAL';
55
+ };
56
+ export type SmallIntDuckDBType = {
57
+ readonly name: 'SMALLINT';
58
+ };
59
+ export type SQLNullDuckDBType = {
60
+ readonly name: 'SQLNULL';
61
+ };
62
+ export type StructDuckDBType = {
63
+ readonly name: 'STRUCT';
64
+ readonly entries: readonly StructEntry[];
65
+ };
66
+ export type TimeDuckDBType = {
67
+ readonly name: 'TIME';
68
+ };
69
+ export type TimestampDuckDBType = {
70
+ readonly name: 'TIMESTAMP';
71
+ };
72
+ export type TimestampSecondsDuckDBType = {
73
+ readonly name: 'TIMESTAMP_S';
74
+ };
75
+ export type TimestampMillisecondsDuckDBType = {
76
+ readonly name: 'TIMESTAMP_MS';
77
+ };
78
+ export type TimestampNanosecondsDuckDBType = {
79
+ readonly name: 'TIMESTAMP_NS';
80
+ };
81
+ export type TimestampWithTimeZoneDuckDBType = {
82
+ readonly name: 'TIMESTAMP_TZ';
83
+ };
84
+ export type TinyIntDuckDBType = {
85
+ readonly name: 'TINYINT';
86
+ };
87
+ export type UBigIntDuckDBType = {
88
+ readonly name: 'UBIGINT';
89
+ };
90
+ export type UIntegerDuckDBType = {
91
+ readonly name: 'UINTEGER';
92
+ };
93
+ export type USmallIntDuckDBType = {
94
+ readonly name: 'USMALLINT';
95
+ };
96
+ export type UTinyIntDuckDBType = {
97
+ readonly name: 'UTINYINT';
98
+ };
99
+ export type UUIDDuckDBType = {
100
+ readonly name: 'UUID';
101
+ };
102
+ export type UnionDuckDBType = {
103
+ readonly name: 'UNION';
104
+ readonly alternatives: readonly UnionAlternative[];
105
+ };
106
+ export type VarCharDuckDBType = {
107
+ readonly name: 'VARCHAR';
108
+ readonly length?: number;
109
+ };
110
+ export type DuckDBType = BigIntDuckDBType | BitDuckDBType | BooleanDuckDBType | BlobDuckDBType | DateDuckDBType | DoubleDuckDBType | DecimalDuckDBType | EnumDuckDBType | HugeIntDuckDBType | IntegerDuckDBType | IntervalDuckDBType | ListDuckDBType | MapDuckDBType | RealDuckDBType | SmallIntDuckDBType | SQLNullDuckDBType | StructDuckDBType | TimeDuckDBType | TimestampDuckDBType | TimestampSecondsDuckDBType | TimestampMillisecondsDuckDBType | TimestampNanosecondsDuckDBType | TimestampWithTimeZoneDuckDBType | TinyIntDuckDBType | UBigIntDuckDBType | UIntegerDuckDBType | USmallIntDuckDBType | UTinyIntDuckDBType | UUIDDuckDBType | UnionDuckDBType | VarCharDuckDBType;
@@ -0,0 +1,39 @@
1
+ import { BigIntDuckDBType, BitDuckDBType, BlobDuckDBType, BooleanDuckDBType, DateDuckDBType, DecimalDuckDBType, DoubleDuckDBType, DuckDBType, EnumDuckDBType, HugeIntDuckDBType, IntegerDuckDBType, IntervalDuckDBType, ListDuckDBType, MapDuckDBType, RealDuckDBType, SQLNullDuckDBType, SmallIntDuckDBType, StructDuckDBType, StructEntry, TimeDuckDBType, TimestampDuckDBType, TimestampMillisecondsDuckDBType, TimestampNanosecondsDuckDBType, TimestampSecondsDuckDBType, TimestampWithTimeZoneDuckDBType, TinyIntDuckDBType, UBigIntDuckDBType, UIntegerDuckDBType, USmallIntDuckDBType, UTinyIntDuckDBType, UUIDDuckDBType, UnionAlternative, UnionDuckDBType, VarCharDuckDBType } from './DuckDBType';
2
+ export declare class DuckDBTypes {
3
+ private constructor();
4
+ static BIGINT: BigIntDuckDBType;
5
+ static BIT: BitDuckDBType;
6
+ static BOOLEAN: BooleanDuckDBType;
7
+ static BLOB: BlobDuckDBType;
8
+ static DATE: DateDuckDBType;
9
+ static DOUBLE: DoubleDuckDBType;
10
+ private static default_DECIMAL;
11
+ static DECIMAL(width?: number, scale?: number): DecimalDuckDBType;
12
+ static ENUM: EnumDuckDBType;
13
+ static HUGEINT: HugeIntDuckDBType;
14
+ static INTEGER: IntegerDuckDBType;
15
+ static INTERVAL: IntervalDuckDBType;
16
+ static LIST(valueType: DuckDBType): ListDuckDBType;
17
+ static MAP(keyType: DuckDBType, valueType: DuckDBType): MapDuckDBType;
18
+ static REAL: RealDuckDBType;
19
+ static SMALLINT: SmallIntDuckDBType;
20
+ static SQLNULL: SQLNullDuckDBType;
21
+ static STRUCT(entries: readonly StructEntry[]): StructDuckDBType;
22
+ static STRUCT_entry(key: string, valueType: DuckDBType): StructEntry;
23
+ static TIME: TimeDuckDBType;
24
+ static TIMESTAMP: TimestampDuckDBType;
25
+ static TIMESTAMP_S: TimestampSecondsDuckDBType;
26
+ static TIMESTAMP_MS: TimestampMillisecondsDuckDBType;
27
+ static TIMESTAMP_NS: TimestampNanosecondsDuckDBType;
28
+ static TIMESTAMP_TZ: TimestampWithTimeZoneDuckDBType;
29
+ static TINYINT: TinyIntDuckDBType;
30
+ static UBIGINT: UBigIntDuckDBType;
31
+ static UINTEGER: UIntegerDuckDBType;
32
+ static USMALLINT: USmallIntDuckDBType;
33
+ static UTINYINT: UTinyIntDuckDBType;
34
+ static UUID: UUIDDuckDBType;
35
+ static UNION(alternatives: readonly UnionAlternative[]): UnionDuckDBType;
36
+ static UNION_alternative(tag: string, valueType: DuckDBType): UnionAlternative;
37
+ static VARCHAR: VarCharDuckDBType;
38
+ static VARCHAR_withLength(length: number): VarCharDuckDBType;
39
+ }
@@ -0,0 +1,2 @@
1
+ export * from './DuckDBType';
2
+ export { DuckDBTypes } from './DuckDBTypes';
@@ -0,0 +1,6 @@
1
+ import { SpecialDuckDBValue } from './SpecialDuckDBValue';
2
+ export declare class DuckDBBlob extends SpecialDuckDBValue {
3
+ readonly bytes: Uint8Array;
4
+ constructor(bytes: Uint8Array);
5
+ toDuckDBString(): string;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { SpecialDuckDBValue } from './SpecialDuckDBValue';
2
+ export declare class DuckDBDate extends SpecialDuckDBValue {
3
+ readonly days: number;
4
+ constructor(days: number);
5
+ toDuckDBString(): string;
6
+ }
@@ -0,0 +1,10 @@
1
+ import { DuckDBDecimalFormatOptions } from '../conversion/stringFromDecimal';
2
+ import { SpecialDuckDBValue } from './SpecialDuckDBValue';
3
+ export declare class DuckDBDecimal extends SpecialDuckDBValue {
4
+ readonly scaledValue: bigint;
5
+ readonly scale: number;
6
+ constructor(scaledValue: bigint, scale: number);
7
+ toDuckDBString(): string;
8
+ /** Returns a string representation appropriate to the host environment's current locale. */
9
+ toLocaleString(locales?: string | string[], options?: DuckDBDecimalFormatOptions): string;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { SpecialDuckDBValue } from './SpecialDuckDBValue';
2
+ export declare class DuckDBInterval extends SpecialDuckDBValue {
3
+ readonly months: number;
4
+ readonly days: number;
5
+ readonly microseconds: bigint;
6
+ constructor(months: number, days: number, microseconds: bigint);
7
+ toDuckDBString(): string;
8
+ }
@@ -0,0 +1,7 @@
1
+ import { DuckDBValue } from './DuckDBValue';
2
+ import { SpecialDuckDBValue } from './SpecialDuckDBValue';
3
+ export declare class DuckDBList extends SpecialDuckDBValue {
4
+ readonly values: readonly DuckDBValue[];
5
+ constructor(values: readonly DuckDBValue[]);
6
+ toDuckDBString(): string;
7
+ }