@duckdb/node-api 1.2.1-alpha.16 → 1.2.2-alpha.18
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 +223 -28
- 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/duckdb.d.ts +8 -3
- package/lib/duckdb.js +10 -5
- 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/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
|
@@ -13,4 +13,4 @@ export declare class DuckDBDateValue implements Date_ {
|
|
|
13
13
|
static readonly PosInf: DuckDBDateValue;
|
|
14
14
|
static readonly NegInf: DuckDBDateValue;
|
|
15
15
|
}
|
|
16
|
-
export declare function dateValue(
|
|
16
|
+
export declare function dateValue(daysOrParts: number | DateParts): DuckDBDateValue;
|
|
@@ -31,6 +31,9 @@ class DuckDBDateValue {
|
|
|
31
31
|
static NegInf = new DuckDBDateValue(-(2 ** 31 - 1));
|
|
32
32
|
}
|
|
33
33
|
exports.DuckDBDateValue = DuckDBDateValue;
|
|
34
|
-
function dateValue(
|
|
35
|
-
|
|
34
|
+
function dateValue(daysOrParts) {
|
|
35
|
+
if (typeof daysOrParts === 'number') {
|
|
36
|
+
return new DuckDBDateValue(daysOrParts);
|
|
37
|
+
}
|
|
38
|
+
return DuckDBDateValue.fromParts(daysOrParts);
|
|
36
39
|
}
|
|
@@ -16,4 +16,4 @@ export declare class DuckDBDecimalValue implements Decimal {
|
|
|
16
16
|
toDouble(): number;
|
|
17
17
|
static fromDouble(double: number, width: number, scale: number): DuckDBDecimalValue;
|
|
18
18
|
}
|
|
19
|
-
export declare function decimalValue(value: bigint, width: number, scale: number): DuckDBDecimalValue;
|
|
19
|
+
export declare function decimalValue(value: bigint | number, width: number, scale: number): DuckDBDecimalValue;
|
|
@@ -37,5 +37,8 @@ class DuckDBDecimalValue {
|
|
|
37
37
|
}
|
|
38
38
|
exports.DuckDBDecimalValue = DuckDBDecimalValue;
|
|
39
39
|
function decimalValue(value, width, scale) {
|
|
40
|
+
if (typeof value === 'number') {
|
|
41
|
+
return DuckDBDecimalValue.fromDouble(value, width, scale);
|
|
42
|
+
}
|
|
40
43
|
return new DuckDBDecimalValue(value, width, scale);
|
|
41
44
|
}
|
|
@@ -9,4 +9,4 @@ export declare class DuckDBTimeValue implements Time {
|
|
|
9
9
|
static readonly Max: DuckDBTimeValue;
|
|
10
10
|
static readonly Min: DuckDBTimeValue;
|
|
11
11
|
}
|
|
12
|
-
export declare function timeValue(
|
|
12
|
+
export declare function timeValue(microsOrParts: bigint | TimeParts): DuckDBTimeValue;
|
|
@@ -25,6 +25,9 @@ class DuckDBTimeValue {
|
|
|
25
25
|
static Min = new DuckDBTimeValue(0n);
|
|
26
26
|
}
|
|
27
27
|
exports.DuckDBTimeValue = DuckDBTimeValue;
|
|
28
|
-
function timeValue(
|
|
29
|
-
|
|
28
|
+
function timeValue(microsOrParts) {
|
|
29
|
+
if (typeof microsOrParts === 'bigint') {
|
|
30
|
+
return new DuckDBTimeValue(microsOrParts);
|
|
31
|
+
}
|
|
32
|
+
return DuckDBTimeValue.fromParts(microsOrParts);
|
|
30
33
|
}
|
|
@@ -13,4 +13,4 @@ export declare class DuckDBTimestampTZValue implements Timestamp {
|
|
|
13
13
|
static readonly PosInf: DuckDBTimestampTZValue;
|
|
14
14
|
static readonly NegInf: DuckDBTimestampTZValue;
|
|
15
15
|
}
|
|
16
|
-
export declare function timestampTZValue(
|
|
16
|
+
export declare function timestampTZValue(microsOrParts: bigint | TimestampParts): DuckDBTimestampTZValue;
|
|
@@ -33,6 +33,9 @@ class DuckDBTimestampTZValue {
|
|
|
33
33
|
static NegInf = new DuckDBTimestampTZValue(DuckDBTimestampValue_1.DuckDBTimestampValue.NegInf.micros);
|
|
34
34
|
}
|
|
35
35
|
exports.DuckDBTimestampTZValue = DuckDBTimestampTZValue;
|
|
36
|
-
function timestampTZValue(
|
|
37
|
-
|
|
36
|
+
function timestampTZValue(microsOrParts) {
|
|
37
|
+
if (typeof microsOrParts === 'bigint') {
|
|
38
|
+
return new DuckDBTimestampTZValue(microsOrParts);
|
|
39
|
+
}
|
|
40
|
+
return DuckDBTimestampTZValue.fromParts(microsOrParts);
|
|
38
41
|
}
|
|
@@ -15,4 +15,4 @@ export declare class DuckDBTimestampValue implements Timestamp {
|
|
|
15
15
|
}
|
|
16
16
|
export type DuckDBTimestampMicrosecondsValue = DuckDBTimestampValue;
|
|
17
17
|
export declare const DuckDBTimestampMicrosecondsValue: typeof DuckDBTimestampValue;
|
|
18
|
-
export declare function timestampValue(
|
|
18
|
+
export declare function timestampValue(microsOrParts: bigint | TimestampParts): DuckDBTimestampValue;
|
|
@@ -33,6 +33,9 @@ class DuckDBTimestampValue {
|
|
|
33
33
|
}
|
|
34
34
|
exports.DuckDBTimestampValue = DuckDBTimestampValue;
|
|
35
35
|
exports.DuckDBTimestampMicrosecondsValue = DuckDBTimestampValue;
|
|
36
|
-
function timestampValue(
|
|
37
|
-
|
|
36
|
+
function timestampValue(microsOrParts) {
|
|
37
|
+
if (typeof microsOrParts === 'bigint') {
|
|
38
|
+
return new DuckDBTimestampValue(microsOrParts);
|
|
39
|
+
}
|
|
40
|
+
return DuckDBTimestampValue.fromParts(microsOrParts);
|
|
38
41
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckdb/node-api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2-alpha.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@duckdb/node-bindings": "1.2.
|
|
8
|
+
"@duckdb/node-bindings": "1.2.2-alpha.18"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { DuckDBType } from './DuckDBType';
|
|
2
|
-
import { DuckDBValueConverter } from './DuckDBValueConverter';
|
|
3
|
-
import { DuckDBValue } from './values';
|
|
4
|
-
export type Json = null | boolean | number | string | Json[] | {
|
|
5
|
-
[key: string]: Json;
|
|
6
|
-
};
|
|
7
|
-
export declare class DuckDBValueToJsonConverter implements DuckDBValueConverter<Json> {
|
|
8
|
-
static readonly default: DuckDBValueToJsonConverter;
|
|
9
|
-
convertValue(value: DuckDBValue, type: DuckDBType): Json;
|
|
10
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DuckDBValueToJsonConverter = void 0;
|
|
4
|
-
const DuckDBTypeId_1 = require("./DuckDBTypeId");
|
|
5
|
-
const values_1 = require("./values");
|
|
6
|
-
class DuckDBValueToJsonConverter {
|
|
7
|
-
static default = new DuckDBValueToJsonConverter();
|
|
8
|
-
convertValue(value, type) {
|
|
9
|
-
if (value == null) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
switch (type.typeId) {
|
|
13
|
-
case DuckDBTypeId_1.DuckDBTypeId.BOOLEAN:
|
|
14
|
-
return Boolean(value);
|
|
15
|
-
case DuckDBTypeId_1.DuckDBTypeId.TINYINT:
|
|
16
|
-
case DuckDBTypeId_1.DuckDBTypeId.SMALLINT:
|
|
17
|
-
case DuckDBTypeId_1.DuckDBTypeId.INTEGER:
|
|
18
|
-
case DuckDBTypeId_1.DuckDBTypeId.UTINYINT:
|
|
19
|
-
case DuckDBTypeId_1.DuckDBTypeId.USMALLINT:
|
|
20
|
-
case DuckDBTypeId_1.DuckDBTypeId.UINTEGER:
|
|
21
|
-
return Number(value);
|
|
22
|
-
case DuckDBTypeId_1.DuckDBTypeId.FLOAT:
|
|
23
|
-
case DuckDBTypeId_1.DuckDBTypeId.DOUBLE:
|
|
24
|
-
if (Number.isFinite(value)) {
|
|
25
|
-
return Number(value);
|
|
26
|
-
}
|
|
27
|
-
return String(value);
|
|
28
|
-
case DuckDBTypeId_1.DuckDBTypeId.BIGINT:
|
|
29
|
-
case DuckDBTypeId_1.DuckDBTypeId.UBIGINT:
|
|
30
|
-
case DuckDBTypeId_1.DuckDBTypeId.HUGEINT:
|
|
31
|
-
case DuckDBTypeId_1.DuckDBTypeId.UHUGEINT:
|
|
32
|
-
return String(value);
|
|
33
|
-
case DuckDBTypeId_1.DuckDBTypeId.DATE:
|
|
34
|
-
case DuckDBTypeId_1.DuckDBTypeId.TIME:
|
|
35
|
-
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP:
|
|
36
|
-
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S:
|
|
37
|
-
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS:
|
|
38
|
-
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS:
|
|
39
|
-
case DuckDBTypeId_1.DuckDBTypeId.TIME_TZ:
|
|
40
|
-
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ:
|
|
41
|
-
return String(value);
|
|
42
|
-
case DuckDBTypeId_1.DuckDBTypeId.INTERVAL:
|
|
43
|
-
if (value instanceof values_1.DuckDBIntervalValue) {
|
|
44
|
-
return {
|
|
45
|
-
months: value.months,
|
|
46
|
-
days: value.days,
|
|
47
|
-
micros: String(value.micros),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
51
|
-
case DuckDBTypeId_1.DuckDBTypeId.VARCHAR:
|
|
52
|
-
case DuckDBTypeId_1.DuckDBTypeId.BLOB:
|
|
53
|
-
case DuckDBTypeId_1.DuckDBTypeId.BIT:
|
|
54
|
-
return String(value);
|
|
55
|
-
case DuckDBTypeId_1.DuckDBTypeId.DECIMAL:
|
|
56
|
-
case DuckDBTypeId_1.DuckDBTypeId.VARINT:
|
|
57
|
-
return String(value);
|
|
58
|
-
case DuckDBTypeId_1.DuckDBTypeId.ENUM:
|
|
59
|
-
return String(value);
|
|
60
|
-
case DuckDBTypeId_1.DuckDBTypeId.LIST:
|
|
61
|
-
if (value instanceof values_1.DuckDBListValue) {
|
|
62
|
-
return value.items.map((v) => this.convertValue(v, type.valueType));
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
case DuckDBTypeId_1.DuckDBTypeId.STRUCT:
|
|
66
|
-
if (value instanceof values_1.DuckDBStructValue) {
|
|
67
|
-
const result = {};
|
|
68
|
-
for (const key in value.entries) {
|
|
69
|
-
result[key] = this.convertValue(value.entries[key], type.typeForEntry(key));
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
case DuckDBTypeId_1.DuckDBTypeId.MAP:
|
|
75
|
-
if (value instanceof values_1.DuckDBMapValue) {
|
|
76
|
-
return value.entries.map((entry) => ({
|
|
77
|
-
key: this.convertValue(entry.key, type.keyType),
|
|
78
|
-
value: this.convertValue(entry.value, type.valueType),
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
82
|
-
case DuckDBTypeId_1.DuckDBTypeId.ARRAY:
|
|
83
|
-
if (value instanceof values_1.DuckDBArrayValue) {
|
|
84
|
-
return value.items.map((v) => this.convertValue(v, type.valueType));
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
case DuckDBTypeId_1.DuckDBTypeId.UNION:
|
|
88
|
-
if (value instanceof values_1.DuckDBUnionValue) {
|
|
89
|
-
return {
|
|
90
|
-
tag: value.tag,
|
|
91
|
-
value: this.convertValue(value.value, type.memberTypeForTag(value.tag)),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
case DuckDBTypeId_1.DuckDBTypeId.UUID:
|
|
96
|
-
return String(value);
|
|
97
|
-
}
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.DuckDBValueToJsonConverter = DuckDBValueToJsonConverter;
|