@duckdb/node-api 1.2.0-alpha.15 → 1.2.1-alpha.17
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/README.md +211 -16
- package/lib/DuckDBAppender.d.ts +2 -2
- package/lib/DuckDBAppender.js +4 -4
- package/lib/DuckDBConnection.d.ts +4 -4
- package/lib/DuckDBConnection.js +10 -6
- package/lib/DuckDBDataChunk.d.ts +12 -4
- package/lib/DuckDBDataChunk.js +64 -6
- package/lib/DuckDBInstance.d.ts +2 -0
- package/lib/DuckDBInstance.js +9 -9
- package/lib/DuckDBInstanceCache.d.ts +8 -0
- package/lib/DuckDBInstanceCache.js +28 -0
- package/lib/DuckDBResult.d.ts +15 -1
- package/lib/DuckDBResult.js +62 -9
- package/lib/DuckDBResultReader.d.ts +15 -1
- package/lib/DuckDBResultReader.js +42 -5
- package/lib/DuckDBType.d.ts +9 -0
- package/lib/DuckDBType.js +61 -0
- package/lib/DuckDBValueConverter.d.ts +1 -3
- package/lib/DuckDBValueConverters.d.ts +47 -0
- package/lib/DuckDBValueConverters.js +214 -0
- package/lib/JS.d.ts +3 -0
- package/lib/JS.js +2 -0
- package/lib/JSDuckDBValueConverter.d.ts +3 -0
- package/lib/JSDuckDBValueConverter.js +46 -0
- package/lib/Json.d.ts +3 -0
- package/lib/Json.js +2 -0
- package/lib/JsonDuckDBValueConverter.d.ts +3 -0
- package/lib/JsonDuckDBValueConverter.js +46 -0
- package/lib/conversion/stringFromBlob.d.ts +2 -0
- package/lib/conversion/stringFromBlob.js +28 -2
- package/lib/convertColumnsFromChunks.d.ts +1 -1
- package/lib/convertColumnsFromChunks.js +1 -1
- package/lib/convertColumnsObjectFromChunks.d.ts +1 -1
- package/lib/convertColumnsObjectFromChunks.js +1 -1
- package/lib/convertRowObjectsFromChunks.d.ts +1 -1
- package/lib/convertRowObjectsFromChunks.js +1 -1
- package/lib/convertRowsFromChunks.d.ts +1 -1
- package/lib/createConfig.d.ts +2 -0
- package/lib/createConfig.js +19 -0
- package/lib/createDuckDBValueConverter.d.ts +3 -0
- package/lib/createDuckDBValueConverter.js +15 -0
- package/lib/createValue.js +2 -2
- package/lib/duckdb.d.ts +26 -0
- package/lib/duckdb.js +47 -0
- package/lib/getColumnsFromChunks.js +2 -8
- package/lib/getColumnsObjectFromChunks.js +2 -11
- package/lib/getRowObjectsFromChunks.js +1 -8
- package/lib/getRowsFromChunks.js +1 -1
- package/lib/index.d.ts +3 -21
- package/lib/index.js +25 -26
- package/lib/values/DuckDBBitValue.d.ts +1 -1
- package/lib/values/DuckDBBitValue.js +13 -2
- package/lib/values/DuckDBDateValue.d.ts +1 -1
- package/lib/values/DuckDBDateValue.js +5 -2
- package/lib/values/DuckDBDecimalValue.d.ts +1 -1
- package/lib/values/DuckDBDecimalValue.js +3 -0
- package/lib/values/DuckDBTimeValue.d.ts +1 -1
- package/lib/values/DuckDBTimeValue.js +5 -2
- package/lib/values/DuckDBTimestampTZValue.d.ts +1 -1
- package/lib/values/DuckDBTimestampTZValue.js +5 -2
- package/lib/values/DuckDBTimestampValue.d.ts +1 -1
- package/lib/values/DuckDBTimestampValue.js +5 -2
- package/package.json +2 -2
- package/lib/DuckDBValueToJsonConverter.d.ts +0 -10
- package/lib/DuckDBValueToJsonConverter.js +0 -101
package/lib/DuckDBResult.js
CHANGED
|
@@ -7,7 +7,8 @@ exports.DuckDBResult = void 0;
|
|
|
7
7
|
const node_bindings_1 = __importDefault(require("@duckdb/node-bindings"));
|
|
8
8
|
const DuckDBDataChunk_1 = require("./DuckDBDataChunk");
|
|
9
9
|
const DuckDBLogicalType_1 = require("./DuckDBLogicalType");
|
|
10
|
-
const
|
|
10
|
+
const JSDuckDBValueConverter_1 = require("./JSDuckDBValueConverter");
|
|
11
|
+
const JsonDuckDBValueConverter_1 = require("./JsonDuckDBValueConverter");
|
|
11
12
|
const convertColumnsFromChunks_1 = require("./convertColumnsFromChunks");
|
|
12
13
|
const convertColumnsObjectFromChunks_1 = require("./convertColumnsObjectFromChunks");
|
|
13
14
|
const convertRowObjectsFromChunks_1 = require("./convertRowObjectsFromChunks");
|
|
@@ -67,6 +68,9 @@ class DuckDBResult {
|
|
|
67
68
|
columnType(columnIndex) {
|
|
68
69
|
return DuckDBLogicalType_1.DuckDBLogicalType.create(node_bindings_1.default.column_logical_type(this.result, columnIndex)).asType();
|
|
69
70
|
}
|
|
71
|
+
columnTypeJson(columnIndex) {
|
|
72
|
+
return this.columnType(columnIndex).toJson();
|
|
73
|
+
}
|
|
70
74
|
columnTypes() {
|
|
71
75
|
const columnTypes = [];
|
|
72
76
|
const columnCount = this.columnCount;
|
|
@@ -75,6 +79,31 @@ class DuckDBResult {
|
|
|
75
79
|
}
|
|
76
80
|
return columnTypes;
|
|
77
81
|
}
|
|
82
|
+
columnTypesJson() {
|
|
83
|
+
const columnTypesJson = [];
|
|
84
|
+
const columnCount = this.columnCount;
|
|
85
|
+
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
86
|
+
columnTypesJson.push(this.columnTypeJson(columnIndex));
|
|
87
|
+
}
|
|
88
|
+
return columnTypesJson;
|
|
89
|
+
}
|
|
90
|
+
columnNamesAndTypesJson() {
|
|
91
|
+
return {
|
|
92
|
+
columnNames: this.columnNames(),
|
|
93
|
+
columnTypes: this.columnTypesJson(),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
columnNameAndTypeObjectsJson() {
|
|
97
|
+
const columnNameAndTypeObjects = [];
|
|
98
|
+
const columnCount = this.columnCount;
|
|
99
|
+
for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {
|
|
100
|
+
columnNameAndTypeObjects.push({
|
|
101
|
+
columnName: this.columnName(columnIndex),
|
|
102
|
+
columnType: this.columnTypeJson(columnIndex),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return columnNameAndTypeObjects;
|
|
106
|
+
}
|
|
78
107
|
get isStreaming() {
|
|
79
108
|
return node_bindings_1.default.result_is_streaming(this.result);
|
|
80
109
|
}
|
|
@@ -99,33 +128,57 @@ class DuckDBResult {
|
|
|
99
128
|
const chunks = await this.fetchAllChunks();
|
|
100
129
|
return (0, getColumnsFromChunks_1.getColumnsFromChunks)(chunks);
|
|
101
130
|
}
|
|
102
|
-
async
|
|
131
|
+
async convertColumns(converter) {
|
|
103
132
|
const chunks = await this.fetchAllChunks();
|
|
104
|
-
return (0, convertColumnsFromChunks_1.convertColumnsFromChunks)(chunks,
|
|
133
|
+
return (0, convertColumnsFromChunks_1.convertColumnsFromChunks)(chunks, converter);
|
|
134
|
+
}
|
|
135
|
+
async getColumnsJS() {
|
|
136
|
+
return this.convertColumns(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
137
|
+
}
|
|
138
|
+
async getColumnsJson() {
|
|
139
|
+
return this.convertColumns(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
105
140
|
}
|
|
106
141
|
async getColumnsObject() {
|
|
107
142
|
const chunks = await this.fetchAllChunks();
|
|
108
143
|
return (0, getColumnsObjectFromChunks_1.getColumnsObjectFromChunks)(chunks, this.deduplicatedColumnNames());
|
|
109
144
|
}
|
|
110
|
-
async
|
|
145
|
+
async convertColumnsObject(converter) {
|
|
111
146
|
const chunks = await this.fetchAllChunks();
|
|
112
|
-
return (0, convertColumnsObjectFromChunks_1.convertColumnsObjectFromChunks)(chunks, this.deduplicatedColumnNames(),
|
|
147
|
+
return (0, convertColumnsObjectFromChunks_1.convertColumnsObjectFromChunks)(chunks, this.deduplicatedColumnNames(), converter);
|
|
148
|
+
}
|
|
149
|
+
async getColumnsObjectJS() {
|
|
150
|
+
return this.convertColumnsObject(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
151
|
+
}
|
|
152
|
+
async getColumnsObjectJson() {
|
|
153
|
+
return this.convertColumnsObject(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
113
154
|
}
|
|
114
155
|
async getRows() {
|
|
115
156
|
const chunks = await this.fetchAllChunks();
|
|
116
157
|
return (0, getRowsFromChunks_1.getRowsFromChunks)(chunks);
|
|
117
158
|
}
|
|
118
|
-
async
|
|
159
|
+
async convertRows(converter) {
|
|
119
160
|
const chunks = await this.fetchAllChunks();
|
|
120
|
-
return (0, convertRowsFromChunks_1.convertRowsFromChunks)(chunks,
|
|
161
|
+
return (0, convertRowsFromChunks_1.convertRowsFromChunks)(chunks, converter);
|
|
162
|
+
}
|
|
163
|
+
async getRowsJS() {
|
|
164
|
+
return this.convertRows(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
165
|
+
}
|
|
166
|
+
async getRowsJson() {
|
|
167
|
+
return this.convertRows(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
121
168
|
}
|
|
122
169
|
async getRowObjects() {
|
|
123
170
|
const chunks = await this.fetchAllChunks();
|
|
124
171
|
return (0, getRowObjectsFromChunks_1.getRowObjectsFromChunks)(chunks, this.deduplicatedColumnNames());
|
|
125
172
|
}
|
|
126
|
-
async
|
|
173
|
+
async convertRowObjects(converter) {
|
|
127
174
|
const chunks = await this.fetchAllChunks();
|
|
128
|
-
return (0, convertRowObjectsFromChunks_1.convertRowObjectsFromChunks)(chunks, this.deduplicatedColumnNames(),
|
|
175
|
+
return (0, convertRowObjectsFromChunks_1.convertRowObjectsFromChunks)(chunks, this.deduplicatedColumnNames(), converter);
|
|
176
|
+
}
|
|
177
|
+
async getRowObjectsJS() {
|
|
178
|
+
return this.convertRowObjects(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
179
|
+
}
|
|
180
|
+
async getRowObjectsJson() {
|
|
181
|
+
return this.convertRowObjects(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
129
182
|
}
|
|
130
183
|
}
|
|
131
184
|
exports.DuckDBResult = DuckDBResult;
|
|
@@ -2,8 +2,10 @@ import { DuckDBLogicalType } from './DuckDBLogicalType';
|
|
|
2
2
|
import { DuckDBResult } from './DuckDBResult';
|
|
3
3
|
import { DuckDBType } from './DuckDBType';
|
|
4
4
|
import { DuckDBTypeId } from './DuckDBTypeId';
|
|
5
|
-
import {
|
|
5
|
+
import { DuckDBValueConverter } from './DuckDBValueConverter';
|
|
6
6
|
import { ResultReturnType, StatementType } from './enums';
|
|
7
|
+
import { JS } from './JS';
|
|
8
|
+
import { Json } from './Json';
|
|
7
9
|
import { DuckDBValue } from './values';
|
|
8
10
|
export declare class DuckDBResultReader {
|
|
9
11
|
private readonly result;
|
|
@@ -21,7 +23,11 @@ export declare class DuckDBResultReader {
|
|
|
21
23
|
columnTypeId(columnIndex: number): DuckDBTypeId;
|
|
22
24
|
columnLogicalType(columnIndex: number): DuckDBLogicalType;
|
|
23
25
|
columnType(columnIndex: number): DuckDBType;
|
|
26
|
+
columnTypeJson(columnIndex: number): Json;
|
|
24
27
|
columnTypes(): DuckDBType[];
|
|
28
|
+
columnTypesJson(): Json;
|
|
29
|
+
columnNamesAndTypesJson(): Json;
|
|
30
|
+
columnNameAndTypeObjectsJson(): Json;
|
|
25
31
|
get rowsChanged(): number;
|
|
26
32
|
/** Total number of rows read so far. Call `readAll` or `readUntil` to read rows. */
|
|
27
33
|
get currentRowCount(): number;
|
|
@@ -44,11 +50,19 @@ export declare class DuckDBResultReader {
|
|
|
44
50
|
private fetchChunks;
|
|
45
51
|
private updateChunkSizeRuns;
|
|
46
52
|
getColumns(): DuckDBValue[][];
|
|
53
|
+
convertColumns<T>(converter: DuckDBValueConverter<T>): (T | null)[][];
|
|
54
|
+
getColumnsJS(): JS[][];
|
|
47
55
|
getColumnsJson(): Json[][];
|
|
48
56
|
getColumnsObject(): Record<string, DuckDBValue[]>;
|
|
57
|
+
convertColumnsObject<T>(converter: DuckDBValueConverter<T>): Record<string, (T | null)[]>;
|
|
58
|
+
getColumnsObjectJS(): Record<string, JS[]>;
|
|
49
59
|
getColumnsObjectJson(): Record<string, Json[]>;
|
|
50
60
|
getRows(): DuckDBValue[][];
|
|
61
|
+
convertRows<T>(converter: DuckDBValueConverter<T>): (T | null)[][];
|
|
62
|
+
getRowsJS(): JS[][];
|
|
51
63
|
getRowsJson(): Json[][];
|
|
52
64
|
getRowObjects(): Record<string, DuckDBValue>[];
|
|
65
|
+
convertRowObjects<T>(converter: DuckDBValueConverter<T>): Record<string, T | null>[];
|
|
66
|
+
getRowObjectsJS(): Record<string, JS>[];
|
|
53
67
|
getRowObjectsJson(): Record<string, Json>[];
|
|
54
68
|
}
|
|
@@ -5,11 +5,12 @@ const convertColumnsFromChunks_1 = require("./convertColumnsFromChunks");
|
|
|
5
5
|
const convertColumnsObjectFromChunks_1 = require("./convertColumnsObjectFromChunks");
|
|
6
6
|
const convertRowObjectsFromChunks_1 = require("./convertRowObjectsFromChunks");
|
|
7
7
|
const convertRowsFromChunks_1 = require("./convertRowsFromChunks");
|
|
8
|
-
const DuckDBValueToJsonConverter_1 = require("./DuckDBValueToJsonConverter");
|
|
9
8
|
const getColumnsFromChunks_1 = require("./getColumnsFromChunks");
|
|
10
9
|
const getColumnsObjectFromChunks_1 = require("./getColumnsObjectFromChunks");
|
|
11
10
|
const getRowObjectsFromChunks_1 = require("./getRowObjectsFromChunks");
|
|
12
11
|
const getRowsFromChunks_1 = require("./getRowsFromChunks");
|
|
12
|
+
const JSDuckDBValueConverter_1 = require("./JSDuckDBValueConverter");
|
|
13
|
+
const JsonDuckDBValueConverter_1 = require("./JsonDuckDBValueConverter");
|
|
13
14
|
class DuckDBResultReader {
|
|
14
15
|
result;
|
|
15
16
|
chunks;
|
|
@@ -50,9 +51,21 @@ class DuckDBResultReader {
|
|
|
50
51
|
columnType(columnIndex) {
|
|
51
52
|
return this.result.columnType(columnIndex);
|
|
52
53
|
}
|
|
54
|
+
columnTypeJson(columnIndex) {
|
|
55
|
+
return this.result.columnTypeJson(columnIndex);
|
|
56
|
+
}
|
|
53
57
|
columnTypes() {
|
|
54
58
|
return this.result.columnTypes();
|
|
55
59
|
}
|
|
60
|
+
columnTypesJson() {
|
|
61
|
+
return this.result.columnTypesJson();
|
|
62
|
+
}
|
|
63
|
+
columnNamesAndTypesJson() {
|
|
64
|
+
return this.result.columnNamesAndTypesJson();
|
|
65
|
+
}
|
|
66
|
+
columnNameAndTypeObjectsJson() {
|
|
67
|
+
return this.result.columnNameAndTypeObjectsJson();
|
|
68
|
+
}
|
|
56
69
|
get rowsChanged() {
|
|
57
70
|
return this.result.rowsChanged;
|
|
58
71
|
}
|
|
@@ -141,26 +154,50 @@ class DuckDBResultReader {
|
|
|
141
154
|
getColumns() {
|
|
142
155
|
return (0, getColumnsFromChunks_1.getColumnsFromChunks)(this.chunks);
|
|
143
156
|
}
|
|
157
|
+
convertColumns(converter) {
|
|
158
|
+
return (0, convertColumnsFromChunks_1.convertColumnsFromChunks)(this.chunks, converter);
|
|
159
|
+
}
|
|
160
|
+
getColumnsJS() {
|
|
161
|
+
return this.convertColumns(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
162
|
+
}
|
|
144
163
|
getColumnsJson() {
|
|
145
|
-
return
|
|
164
|
+
return this.convertColumns(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
146
165
|
}
|
|
147
166
|
getColumnsObject() {
|
|
148
167
|
return (0, getColumnsObjectFromChunks_1.getColumnsObjectFromChunks)(this.chunks, this.deduplicatedColumnNames());
|
|
149
168
|
}
|
|
169
|
+
convertColumnsObject(converter) {
|
|
170
|
+
return (0, convertColumnsObjectFromChunks_1.convertColumnsObjectFromChunks)(this.chunks, this.deduplicatedColumnNames(), converter);
|
|
171
|
+
}
|
|
172
|
+
getColumnsObjectJS() {
|
|
173
|
+
return this.convertColumnsObject(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
174
|
+
}
|
|
150
175
|
getColumnsObjectJson() {
|
|
151
|
-
return
|
|
176
|
+
return this.convertColumnsObject(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
152
177
|
}
|
|
153
178
|
getRows() {
|
|
154
179
|
return (0, getRowsFromChunks_1.getRowsFromChunks)(this.chunks);
|
|
155
180
|
}
|
|
181
|
+
convertRows(converter) {
|
|
182
|
+
return (0, convertRowsFromChunks_1.convertRowsFromChunks)(this.chunks, converter);
|
|
183
|
+
}
|
|
184
|
+
getRowsJS() {
|
|
185
|
+
return this.convertRows(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
186
|
+
}
|
|
156
187
|
getRowsJson() {
|
|
157
|
-
return
|
|
188
|
+
return this.convertRows(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
158
189
|
}
|
|
159
190
|
getRowObjects() {
|
|
160
191
|
return (0, getRowObjectsFromChunks_1.getRowObjectsFromChunks)(this.chunks, this.deduplicatedColumnNames());
|
|
161
192
|
}
|
|
193
|
+
convertRowObjects(converter) {
|
|
194
|
+
return (0, convertRowObjectsFromChunks_1.convertRowObjectsFromChunks)(this.chunks, this.deduplicatedColumnNames(), converter);
|
|
195
|
+
}
|
|
196
|
+
getRowObjectsJS() {
|
|
197
|
+
return this.convertRowObjects(JSDuckDBValueConverter_1.JSDuckDBValueConverter);
|
|
198
|
+
}
|
|
162
199
|
getRowObjectsJson() {
|
|
163
|
-
return
|
|
200
|
+
return this.convertRowObjects(JsonDuckDBValueConverter_1.JsonDuckDBValueConverter);
|
|
164
201
|
}
|
|
165
202
|
}
|
|
166
203
|
exports.DuckDBResultReader = DuckDBResultReader;
|
package/lib/DuckDBType.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DuckDBLogicalType } from './DuckDBLogicalType';
|
|
2
2
|
import { DuckDBTypeId } from './DuckDBTypeId';
|
|
3
|
+
import { Json } from './Json';
|
|
3
4
|
import { DuckDBDateValue, DuckDBTimestampMillisecondsValue, DuckDBTimestampNanosecondsValue, DuckDBTimestampSecondsValue, DuckDBTimestampTZValue, DuckDBTimestampValue, DuckDBTimeTZValue, DuckDBTimeValue, DuckDBUUIDValue } from './values';
|
|
4
5
|
export declare abstract class BaseDuckDBType<T extends DuckDBTypeId> {
|
|
5
6
|
readonly typeId: T;
|
|
@@ -7,6 +8,7 @@ export declare abstract class BaseDuckDBType<T extends DuckDBTypeId> {
|
|
|
7
8
|
protected constructor(typeId: T, alias?: string);
|
|
8
9
|
toString(): string;
|
|
9
10
|
toLogicalType(): DuckDBLogicalType;
|
|
11
|
+
toJson(): Json;
|
|
10
12
|
}
|
|
11
13
|
export declare class DuckDBBooleanType extends BaseDuckDBType<DuckDBTypeId.BOOLEAN> {
|
|
12
14
|
constructor(alias?: string);
|
|
@@ -190,6 +192,7 @@ export declare class DuckDBDecimalType extends BaseDuckDBType<DuckDBTypeId.DECIM
|
|
|
190
192
|
constructor(width: number, scale: number, alias?: string);
|
|
191
193
|
toString(): string;
|
|
192
194
|
toLogicalType(): DuckDBLogicalType;
|
|
195
|
+
toJson(): Json;
|
|
193
196
|
static readonly default: DuckDBDecimalType;
|
|
194
197
|
}
|
|
195
198
|
export declare function DECIMAL(width?: number, scale?: number, alias?: string): DuckDBDecimalType;
|
|
@@ -234,6 +237,7 @@ export declare class DuckDBEnumType extends BaseDuckDBType<DuckDBTypeId.ENUM> {
|
|
|
234
237
|
indexForValue(value: string): number;
|
|
235
238
|
toString(): string;
|
|
236
239
|
toLogicalType(): DuckDBLogicalType;
|
|
240
|
+
toJson(): Json;
|
|
237
241
|
}
|
|
238
242
|
export declare function ENUM8(values: readonly string[], alias?: string): DuckDBEnumType;
|
|
239
243
|
export declare function ENUM16(values: readonly string[], alias?: string): DuckDBEnumType;
|
|
@@ -244,6 +248,7 @@ export declare class DuckDBListType extends BaseDuckDBType<DuckDBTypeId.LIST> {
|
|
|
244
248
|
constructor(valueType: DuckDBType, alias?: string);
|
|
245
249
|
toString(): string;
|
|
246
250
|
toLogicalType(): DuckDBLogicalType;
|
|
251
|
+
toJson(): Json;
|
|
247
252
|
}
|
|
248
253
|
export declare function LIST(valueType: DuckDBType, alias?: string): DuckDBListType;
|
|
249
254
|
export declare class DuckDBStructType extends BaseDuckDBType<DuckDBTypeId.STRUCT> {
|
|
@@ -256,6 +261,7 @@ export declare class DuckDBStructType extends BaseDuckDBType<DuckDBTypeId.STRUCT
|
|
|
256
261
|
typeForEntry(entryName: string): DuckDBType;
|
|
257
262
|
toString(): string;
|
|
258
263
|
toLogicalType(): DuckDBLogicalType;
|
|
264
|
+
toJson(): Json;
|
|
259
265
|
}
|
|
260
266
|
export declare function STRUCT(entries: Record<string, DuckDBType>, alias?: string): DuckDBStructType;
|
|
261
267
|
export declare class DuckDBMapType extends BaseDuckDBType<DuckDBTypeId.MAP> {
|
|
@@ -264,6 +270,7 @@ export declare class DuckDBMapType extends BaseDuckDBType<DuckDBTypeId.MAP> {
|
|
|
264
270
|
constructor(keyType: DuckDBType, valueType: DuckDBType, alias?: string);
|
|
265
271
|
toString(): string;
|
|
266
272
|
toLogicalType(): DuckDBLogicalType;
|
|
273
|
+
toJson(): Json;
|
|
267
274
|
}
|
|
268
275
|
export declare function MAP(keyType: DuckDBType, valueType: DuckDBType, alias?: string): DuckDBMapType;
|
|
269
276
|
export declare class DuckDBArrayType extends BaseDuckDBType<DuckDBTypeId.ARRAY> {
|
|
@@ -272,6 +279,7 @@ export declare class DuckDBArrayType extends BaseDuckDBType<DuckDBTypeId.ARRAY>
|
|
|
272
279
|
constructor(valueType: DuckDBType, length: number, alias?: string);
|
|
273
280
|
toString(): string;
|
|
274
281
|
toLogicalType(): DuckDBLogicalType;
|
|
282
|
+
toJson(): Json;
|
|
275
283
|
}
|
|
276
284
|
export declare function ARRAY(valueType: DuckDBType, length: number, alias?: string): DuckDBArrayType;
|
|
277
285
|
export declare class DuckDBUUIDType extends BaseDuckDBType<DuckDBTypeId.UUID> {
|
|
@@ -292,6 +300,7 @@ export declare class DuckDBUnionType extends BaseDuckDBType<DuckDBTypeId.UNION>
|
|
|
292
300
|
get memberCount(): number;
|
|
293
301
|
toString(): string;
|
|
294
302
|
toLogicalType(): DuckDBLogicalType;
|
|
303
|
+
toJson(): Json;
|
|
295
304
|
}
|
|
296
305
|
export declare function UNION(members: Record<string, DuckDBType>, alias?: string): DuckDBUnionType;
|
|
297
306
|
export declare class DuckDBBitType extends BaseDuckDBType<DuckDBTypeId.BIT> {
|
package/lib/DuckDBType.js
CHANGED
|
@@ -37,6 +37,12 @@ class BaseDuckDBType {
|
|
|
37
37
|
}
|
|
38
38
|
return logicalType;
|
|
39
39
|
}
|
|
40
|
+
toJson() {
|
|
41
|
+
return {
|
|
42
|
+
typeId: this.typeId,
|
|
43
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
47
|
exports.BaseDuckDBType = BaseDuckDBType;
|
|
42
48
|
class DuckDBBooleanType extends BaseDuckDBType {
|
|
@@ -403,6 +409,14 @@ class DuckDBDecimalType extends BaseDuckDBType {
|
|
|
403
409
|
}
|
|
404
410
|
return logicalType;
|
|
405
411
|
}
|
|
412
|
+
toJson() {
|
|
413
|
+
return {
|
|
414
|
+
typeId: this.typeId,
|
|
415
|
+
width: this.width,
|
|
416
|
+
scale: this.scale,
|
|
417
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
418
|
+
};
|
|
419
|
+
}
|
|
406
420
|
static default = new DuckDBDecimalType(18, 3);
|
|
407
421
|
}
|
|
408
422
|
exports.DuckDBDecimalType = DuckDBDecimalType;
|
|
@@ -526,6 +540,14 @@ class DuckDBEnumType extends BaseDuckDBType {
|
|
|
526
540
|
}
|
|
527
541
|
return logicalType;
|
|
528
542
|
}
|
|
543
|
+
toJson() {
|
|
544
|
+
return {
|
|
545
|
+
typeId: this.typeId,
|
|
546
|
+
values: [...this.values],
|
|
547
|
+
internalTypeId: this.internalTypeId,
|
|
548
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
549
|
+
};
|
|
550
|
+
}
|
|
529
551
|
}
|
|
530
552
|
exports.DuckDBEnumType = DuckDBEnumType;
|
|
531
553
|
function ENUM8(values, alias) {
|
|
@@ -567,6 +589,13 @@ class DuckDBListType extends BaseDuckDBType {
|
|
|
567
589
|
}
|
|
568
590
|
return logicalType;
|
|
569
591
|
}
|
|
592
|
+
toJson() {
|
|
593
|
+
return {
|
|
594
|
+
typeId: this.typeId,
|
|
595
|
+
valueType: this.valueType.toJson(),
|
|
596
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
597
|
+
};
|
|
598
|
+
}
|
|
570
599
|
}
|
|
571
600
|
exports.DuckDBListType = DuckDBListType;
|
|
572
601
|
function LIST(valueType, alias) {
|
|
@@ -613,6 +642,14 @@ class DuckDBStructType extends BaseDuckDBType {
|
|
|
613
642
|
}
|
|
614
643
|
return logicalType;
|
|
615
644
|
}
|
|
645
|
+
toJson() {
|
|
646
|
+
return {
|
|
647
|
+
typeId: this.typeId,
|
|
648
|
+
entryNames: [...this.entryNames],
|
|
649
|
+
entryTypes: this.entryTypes.map(t => t.toJson()),
|
|
650
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
651
|
+
};
|
|
652
|
+
}
|
|
616
653
|
}
|
|
617
654
|
exports.DuckDBStructType = DuckDBStructType;
|
|
618
655
|
function STRUCT(entries, alias) {
|
|
@@ -638,6 +675,14 @@ class DuckDBMapType extends BaseDuckDBType {
|
|
|
638
675
|
}
|
|
639
676
|
return logicalType;
|
|
640
677
|
}
|
|
678
|
+
toJson() {
|
|
679
|
+
return {
|
|
680
|
+
typeId: this.typeId,
|
|
681
|
+
keyType: this.keyType.toJson(),
|
|
682
|
+
valueType: this.valueType.toJson(),
|
|
683
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
684
|
+
};
|
|
685
|
+
}
|
|
641
686
|
}
|
|
642
687
|
exports.DuckDBMapType = DuckDBMapType;
|
|
643
688
|
function MAP(keyType, valueType, alias) {
|
|
@@ -661,6 +706,14 @@ class DuckDBArrayType extends BaseDuckDBType {
|
|
|
661
706
|
}
|
|
662
707
|
return logicalType;
|
|
663
708
|
}
|
|
709
|
+
toJson() {
|
|
710
|
+
return {
|
|
711
|
+
typeId: this.typeId,
|
|
712
|
+
valueType: this.valueType.toJson(),
|
|
713
|
+
length: this.length,
|
|
714
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
715
|
+
};
|
|
716
|
+
}
|
|
664
717
|
}
|
|
665
718
|
exports.DuckDBArrayType = DuckDBArrayType;
|
|
666
719
|
function ARRAY(valueType, length, alias) {
|
|
@@ -724,6 +777,14 @@ class DuckDBUnionType extends BaseDuckDBType {
|
|
|
724
777
|
}
|
|
725
778
|
return logicalType;
|
|
726
779
|
}
|
|
780
|
+
toJson() {
|
|
781
|
+
return {
|
|
782
|
+
typeId: this.typeId,
|
|
783
|
+
memberTags: [...this.memberTags],
|
|
784
|
+
memberTypes: this.memberTypes.map(t => t.toJson()),
|
|
785
|
+
...(this.alias ? { alias: this.alias } : {}),
|
|
786
|
+
};
|
|
787
|
+
}
|
|
727
788
|
}
|
|
728
789
|
exports.DuckDBUnionType = DuckDBUnionType;
|
|
729
790
|
function UNION(members, alias) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { DuckDBType } from './DuckDBType';
|
|
2
2
|
import { DuckDBValue } from './values';
|
|
3
|
-
export
|
|
4
|
-
convertValue(value: DuckDBValue, type: DuckDBType): T;
|
|
5
|
-
}
|
|
3
|
+
export type DuckDBValueConverter<T> = (value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>) => T | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DuckDBType } from './DuckDBType';
|
|
2
|
+
import { DuckDBValueConverter } from './DuckDBValueConverter';
|
|
3
|
+
import { DuckDBValue } from './values';
|
|
4
|
+
export declare function unsupportedConverter(_: DuckDBValue, type: DuckDBType): null;
|
|
5
|
+
export declare function nullConverter(_: DuckDBValue): null;
|
|
6
|
+
export declare function booleanFromValue(value: DuckDBValue): boolean;
|
|
7
|
+
export declare function numberFromValue(value: DuckDBValue): number;
|
|
8
|
+
export declare function jsonNumberFromValue(value: DuckDBValue): number | string;
|
|
9
|
+
export declare function bigintFromBigIntValue(value: DuckDBValue, type: DuckDBType): bigint;
|
|
10
|
+
export declare function stringFromValue(value: DuckDBValue): string;
|
|
11
|
+
export declare function bytesFromBlobValue(value: DuckDBValue): Uint8Array;
|
|
12
|
+
export declare function bytesFromBitValue(value: DuckDBValue): Uint8Array;
|
|
13
|
+
export declare function dateFromDateValue(value: DuckDBValue): Date;
|
|
14
|
+
export declare function bigintFromTimeValue(value: DuckDBValue): bigint;
|
|
15
|
+
export declare function dateFromTimestampValue(value: DuckDBValue): Date;
|
|
16
|
+
export declare function dateFromTimestampSecondsValue(value: DuckDBValue): Date;
|
|
17
|
+
export declare function dateFromTimestampMillisecondsValue(value: DuckDBValue): Date;
|
|
18
|
+
export declare function dateFromTimestampNanosecondsValue(value: DuckDBValue): Date;
|
|
19
|
+
export declare function objectFromTimeTZValue(value: DuckDBValue): {
|
|
20
|
+
micros: bigint;
|
|
21
|
+
offset: number;
|
|
22
|
+
};
|
|
23
|
+
export declare function dateFromTimestampTZValue(value: DuckDBValue): Date;
|
|
24
|
+
export declare function objectFromIntervalValue(value: DuckDBValue): {
|
|
25
|
+
months: number;
|
|
26
|
+
days: number;
|
|
27
|
+
micros: bigint;
|
|
28
|
+
};
|
|
29
|
+
export declare function jsonObjectFromIntervalValue(value: DuckDBValue): {
|
|
30
|
+
months: number;
|
|
31
|
+
days: number;
|
|
32
|
+
micros: string;
|
|
33
|
+
};
|
|
34
|
+
export declare function doubleFromDecimalValue(value: DuckDBValue): number;
|
|
35
|
+
export declare function arrayFromListValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): (T | null)[];
|
|
36
|
+
export declare function objectFromStructValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): {
|
|
37
|
+
[key: string]: T | null;
|
|
38
|
+
};
|
|
39
|
+
export declare function objectArrayFromMapValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): {
|
|
40
|
+
key: T | null;
|
|
41
|
+
value: T | null;
|
|
42
|
+
}[];
|
|
43
|
+
export declare function arrayFromArrayValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): (T | null)[];
|
|
44
|
+
export declare function objectFromUnionValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): {
|
|
45
|
+
tag: string;
|
|
46
|
+
value: T | null;
|
|
47
|
+
};
|