@haybarn/node-api 1.5.5-rc1 → 2.0.0-rc3
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 +315 -20
- package/lib/DuckDBAppender.d.ts +8 -2
- package/lib/DuckDBAppender.js +19 -1
- package/lib/DuckDBConnection.d.ts +2 -0
- package/lib/DuckDBConnection.js +4 -1
- package/lib/DuckDBDataChunk.d.ts +30 -0
- package/lib/DuckDBDataChunk.js +94 -1
- package/lib/DuckDBDataChunkWriter.d.ts +74 -0
- package/lib/DuckDBDataChunkWriter.js +109 -0
- package/lib/DuckDBLogicalType.d.ts +5 -1
- package/lib/DuckDBLogicalType.js +18 -1
- package/lib/DuckDBMaterializedResult.d.ts +8 -1
- package/lib/DuckDBMaterializedResult.js +22 -2
- package/lib/DuckDBPendingResult.d.ts +16 -1
- package/lib/DuckDBPendingResult.js +19 -2
- package/lib/DuckDBPreparedStatement.d.ts +4 -1
- package/lib/DuckDBPreparedStatement.js +17 -4
- package/lib/DuckDBResult.d.ts +21 -1
- package/lib/DuckDBResult.js +87 -5
- package/lib/DuckDBResultReader.d.ts +5 -0
- package/lib/DuckDBResultReader.js +9 -2
- package/lib/DuckDBScalarFunction.d.ts +9 -5
- package/lib/DuckDBScalarFunction.js +14 -5
- package/lib/DuckDBScalarFunctionBindInfo.d.ts +16 -0
- package/lib/{DuckDBBindInfo.js → DuckDBScalarFunctionBindInfo.js} +5 -3
- package/lib/DuckDBScalarFunctionInfo.d.ts +16 -0
- package/lib/{DuckDBFunctionInfo.js → DuckDBScalarFunctionInfo.js} +11 -3
- package/lib/{DuckDBBindInfo.d.ts → DuckDBScalarFunctionInitInfo.d.ts} +6 -4
- package/lib/DuckDBScalarFunctionInitInfo.js +39 -0
- package/lib/DuckDBTableFunction.d.ts +41 -0
- package/lib/DuckDBTableFunction.js +83 -0
- package/lib/DuckDBTableFunctionBindInfo.d.ts +21 -0
- package/lib/DuckDBTableFunctionBindInfo.js +54 -0
- package/lib/DuckDBTableFunctionInfo.d.ts +15 -0
- package/lib/DuckDBTableFunctionInfo.js +42 -0
- package/lib/DuckDBTableFunctionInitInfo.d.ts +22 -0
- package/lib/DuckDBTableFunctionInitInfo.js +58 -0
- package/lib/DuckDBType.d.ts +1 -373
- package/lib/DuckDBType.js +14 -927
- package/lib/DuckDBTypeId.d.ts +4 -1
- package/lib/DuckDBTypeId.js +3 -0
- package/lib/DuckDBValueConverter.d.ts +10 -0
- package/lib/DuckDBValueConverters.d.ts +27 -0
- package/lib/DuckDBValueConverters.js +128 -1
- package/lib/DuckDBVector.d.ts +1 -596
- package/lib/DuckDBVector.js +14 -2522
- package/lib/JSDuckDBValueConverter.d.ts +1 -2
- package/lib/JSDuckDBValueConverter.js +5 -2
- package/lib/JSInputTypeForTypeId.d.ts +104 -0
- package/lib/JSInputTypeForTypeId.js +3 -0
- package/lib/JSToDuckDBValueConverter.d.ts +30 -0
- package/lib/JSToDuckDBValueConverter.js +83 -0
- package/lib/JSTypeForTypeId.d.ts +91 -0
- package/lib/JSTypeForTypeId.js +3 -0
- package/lib/JsonDuckDBValueConverter.d.ts +1 -2
- package/lib/JsonDuckDBValueConverter.js +4 -1
- package/lib/JsonTypeForTypeId.d.ts +96 -0
- package/lib/JsonTypeForTypeId.js +3 -0
- package/lib/ToDuckDBValueConverter.d.ts +41 -0
- package/lib/ToDuckDBValueConverter.js +27 -0
- package/lib/ToDuckDBValueConverters.d.ts +54 -0
- package/lib/ToDuckDBValueConverters.js +199 -0
- package/lib/conversion/dateTimeStringConversion.d.ts +2 -2
- package/lib/conversion/dateTimeStringConversion.js +20 -7
- package/lib/conversion/varintDecode.d.ts +18 -0
- package/lib/conversion/varintDecode.js +42 -0
- package/lib/convertColumnsFromChunks.d.ts +1 -1
- package/lib/convertColumnsFromChunks.js +2 -2
- package/lib/createResult.d.ts +2 -1
- package/lib/createResult.js +3 -3
- package/lib/createValue.js +63 -5
- package/lib/duckdb.d.ts +15 -2
- package/lib/duckdb.js +15 -2
- package/lib/getColumnsFromChunks.d.ts +1 -1
- package/lib/getColumnsFromChunks.js +2 -2
- package/lib/getColumnsObjectFromChunks.js +3 -0
- package/lib/readValue.d.ts +22 -0
- package/lib/readValue.js +35 -0
- package/lib/typeForValue.js +21 -2
- package/lib/types/BaseDuckDBType.d.ts +11 -0
- package/lib/types/BaseDuckDBType.js +34 -0
- package/lib/types/DuckDBAnyType.d.ts +8 -0
- package/lib/types/DuckDBAnyType.js +16 -0
- package/lib/types/DuckDBArrayType.d.ts +14 -0
- package/lib/types/DuckDBArrayType.js +38 -0
- package/lib/types/DuckDBBigIntType.d.ts +12 -0
- package/lib/types/DuckDBBigIntType.js +24 -0
- package/lib/types/DuckDBBigNumType.d.ts +12 -0
- package/lib/types/DuckDBBigNumType.js +24 -0
- package/lib/types/DuckDBBitType.d.ts +8 -0
- package/lib/types/DuckDBBitType.js +16 -0
- package/lib/types/DuckDBBlobType.d.ts +8 -0
- package/lib/types/DuckDBBlobType.js +16 -0
- package/lib/types/DuckDBBooleanType.d.ts +8 -0
- package/lib/types/DuckDBBooleanType.js +16 -0
- package/lib/types/DuckDBDateType.d.ts +14 -0
- package/lib/types/DuckDBDateType.js +32 -0
- package/lib/types/DuckDBDecimalType.d.ts +14 -0
- package/lib/types/DuckDBDecimalType.js +45 -0
- package/lib/types/DuckDBDoubleType.d.ts +12 -0
- package/lib/types/DuckDBDoubleType.js +24 -0
- package/lib/types/DuckDBEnumType.d.ts +29 -0
- package/lib/types/DuckDBEnumType.js +100 -0
- package/lib/types/DuckDBFloatType.d.ts +12 -0
- package/lib/types/DuckDBFloatType.js +24 -0
- package/lib/types/DuckDBGeometryType.d.ts +19 -0
- package/lib/types/DuckDBGeometryType.js +38 -0
- package/lib/types/DuckDBHugeIntType.d.ts +12 -0
- package/lib/types/DuckDBHugeIntType.js +24 -0
- package/lib/types/DuckDBIntegerLiteralType.d.ts +8 -0
- package/lib/types/DuckDBIntegerLiteralType.js +16 -0
- package/lib/types/DuckDBIntegerType.d.ts +12 -0
- package/lib/types/DuckDBIntegerType.js +24 -0
- package/lib/types/DuckDBIntervalType.d.ts +8 -0
- package/lib/types/DuckDBIntervalType.js +16 -0
- package/lib/types/DuckDBListType.d.ts +13 -0
- package/lib/types/DuckDBListType.js +35 -0
- package/lib/types/DuckDBMapType.d.ts +14 -0
- package/lib/types/DuckDBMapType.js +38 -0
- package/lib/types/DuckDBSQLNullType.d.ts +10 -0
- package/lib/types/DuckDBSQLNullType.js +20 -0
- package/lib/types/DuckDBSmallIntType.d.ts +12 -0
- package/lib/types/DuckDBSmallIntType.js +24 -0
- package/lib/types/DuckDBStringLiteralType.d.ts +8 -0
- package/lib/types/DuckDBStringLiteralType.js +16 -0
- package/lib/types/DuckDBStructType.d.ts +29 -0
- package/lib/types/DuckDBStructType.js +86 -0
- package/lib/types/DuckDBTimeNSType.d.ts +11 -0
- package/lib/types/DuckDBTimeNSType.js +23 -0
- package/lib/types/DuckDBTimeTZType.d.ts +12 -0
- package/lib/types/DuckDBTimeTZType.js +26 -0
- package/lib/types/DuckDBTimeType.d.ts +11 -0
- package/lib/types/DuckDBTimeType.js +23 -0
- package/lib/types/DuckDBTimestampMillisecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampMillisecondsType.js +32 -0
- package/lib/types/DuckDBTimestampNanosecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampNanosecondsType.js +32 -0
- package/lib/types/DuckDBTimestampSecondsType.d.ts +14 -0
- package/lib/types/DuckDBTimestampSecondsType.js +32 -0
- package/lib/types/DuckDBTimestampTZNanosecondsType.d.ts +15 -0
- package/lib/types/DuckDBTimestampTZNanosecondsType.js +35 -0
- package/lib/types/DuckDBTimestampTZType.d.ts +15 -0
- package/lib/types/DuckDBTimestampTZType.js +35 -0
- package/lib/types/DuckDBTimestampType.d.ts +16 -0
- package/lib/types/DuckDBTimestampType.js +33 -0
- package/lib/types/DuckDBTinyIntType.d.ts +12 -0
- package/lib/types/DuckDBTinyIntType.js +24 -0
- package/lib/types/DuckDBType.d.ts +43 -0
- package/lib/types/DuckDBType.js +2 -0
- package/lib/types/DuckDBUBigIntType.d.ts +12 -0
- package/lib/types/DuckDBUBigIntType.js +24 -0
- package/lib/types/DuckDBUHugeIntType.d.ts +12 -0
- package/lib/types/DuckDBUHugeIntType.js +24 -0
- package/lib/types/DuckDBUIntegerType.d.ts +12 -0
- package/lib/types/DuckDBUIntegerType.js +24 -0
- package/lib/types/DuckDBUSmallIntType.d.ts +12 -0
- package/lib/types/DuckDBUSmallIntType.js +24 -0
- package/lib/types/DuckDBUTinyIntType.d.ts +12 -0
- package/lib/types/DuckDBUTinyIntType.js +24 -0
- package/lib/types/DuckDBUUIDType.d.ts +11 -0
- package/lib/types/DuckDBUUIDType.js +23 -0
- package/lib/types/DuckDBUnionType.d.ts +18 -0
- package/lib/types/DuckDBUnionType.js +64 -0
- package/lib/types/DuckDBVarCharType.d.ts +8 -0
- package/lib/types/DuckDBVarCharType.js +16 -0
- package/lib/types/DuckDBVariantType.d.ts +8 -0
- package/lib/types/DuckDBVariantType.js +16 -0
- package/lib/types/index.d.ts +44 -0
- package/lib/types/index.js +60 -0
- package/lib/values/DuckDBGeometryValue.d.ts +12 -0
- package/lib/values/DuckDBGeometryValue.js +30 -0
- package/lib/values/DuckDBTimestampTZNanosecondsValue.d.ts +14 -0
- package/lib/values/DuckDBTimestampTZNanosecondsValue.js +33 -0
- package/lib/values/DuckDBTupleValue.d.ts +11 -0
- package/lib/values/DuckDBTupleValue.js +22 -0
- package/lib/values/DuckDBUUIDValue.js +5 -1
- package/lib/values/DuckDBValue.d.ts +5 -1
- package/lib/values/DuckDBVariantValue.d.ts +19 -0
- package/lib/values/DuckDBVariantValue.js +30 -0
- package/lib/values/index.d.ts +4 -0
- package/lib/values/index.js +4 -0
- package/lib/vectors/DuckDBArrayVector.d.ts +21 -0
- package/lib/vectors/DuckDBArrayVector.js +79 -0
- package/lib/vectors/DuckDBBigIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBBigIntVector.js +58 -0
- package/lib/vectors/DuckDBBigNumVector.d.ts +21 -0
- package/lib/vectors/DuckDBBigNumVector.js +70 -0
- package/lib/vectors/DuckDBBitVector.d.ts +22 -0
- package/lib/vectors/DuckDBBitVector.js +74 -0
- package/lib/vectors/DuckDBBlobVector.d.ts +32 -0
- package/lib/vectors/DuckDBBlobVector.js +83 -0
- package/lib/vectors/DuckDBBooleanVector.d.ts +18 -0
- package/lib/vectors/DuckDBBooleanVector.js +58 -0
- package/lib/vectors/DuckDBDateVector.d.ts +18 -0
- package/lib/vectors/DuckDBDateVector.js +64 -0
- package/lib/vectors/DuckDBDecimal128Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal128Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal16Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal16Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal32Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal32Vector.js +64 -0
- package/lib/vectors/DuckDBDecimal64Vector.d.ts +21 -0
- package/lib/vectors/DuckDBDecimal64Vector.js +64 -0
- package/lib/vectors/DuckDBDoubleVector.d.ts +17 -0
- package/lib/vectors/DuckDBDoubleVector.js +54 -0
- package/lib/vectors/DuckDBEnum16Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum16Vector.js +57 -0
- package/lib/vectors/DuckDBEnum32Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum32Vector.js +57 -0
- package/lib/vectors/DuckDBEnum8Vector.d.ts +18 -0
- package/lib/vectors/DuckDBEnum8Vector.js +57 -0
- package/lib/vectors/DuckDBFloatVector.d.ts +17 -0
- package/lib/vectors/DuckDBFloatVector.js +54 -0
- package/lib/vectors/DuckDBGeometryVector.d.ts +22 -0
- package/lib/vectors/DuckDBGeometryVector.js +69 -0
- package/lib/vectors/DuckDBHugeIntVector.d.ts +19 -0
- package/lib/vectors/DuckDBHugeIntVector.js +63 -0
- package/lib/vectors/DuckDBIntegerVector.d.ts +17 -0
- package/lib/vectors/DuckDBIntegerVector.js +61 -0
- package/lib/vectors/DuckDBIntervalVector.d.ts +19 -0
- package/lib/vectors/DuckDBIntervalVector.js +67 -0
- package/lib/vectors/DuckDBListVector.d.ts +35 -0
- package/lib/vectors/DuckDBListVector.js +151 -0
- package/lib/vectors/DuckDBMapVector.d.ts +17 -0
- package/lib/vectors/DuckDBMapVector.js +60 -0
- package/lib/vectors/DuckDBSQLNullVector.d.ts +18 -0
- package/lib/vectors/DuckDBSQLNullVector.js +44 -0
- package/lib/vectors/DuckDBSmallIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBSmallIntVector.js +61 -0
- package/lib/vectors/DuckDBStructVector.d.ts +35 -0
- package/lib/vectors/DuckDBStructVector.js +105 -0
- package/lib/vectors/DuckDBTimeNSVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeNSVector.js +61 -0
- package/lib/vectors/DuckDBTimeTZVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeTZVector.js +61 -0
- package/lib/vectors/DuckDBTimeVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimeVector.js +61 -0
- package/lib/vectors/DuckDBTimestampMillisecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampMillisecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampNanosecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampNanosecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampSecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampSecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampTZNanosecondsVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampTZNanosecondsVector.js +61 -0
- package/lib/vectors/DuckDBTimestampTZVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampTZVector.js +61 -0
- package/lib/vectors/DuckDBTimestampVector.d.ts +18 -0
- package/lib/vectors/DuckDBTimestampVector.js +61 -0
- package/lib/vectors/DuckDBTinyIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBTinyIntVector.js +61 -0
- package/lib/vectors/DuckDBTupleVector.d.ts +26 -0
- package/lib/vectors/DuckDBTupleVector.js +91 -0
- package/lib/vectors/DuckDBUBigIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUBigIntVector.js +58 -0
- package/lib/vectors/DuckDBUHugeIntVector.d.ts +19 -0
- package/lib/vectors/DuckDBUHugeIntVector.js +63 -0
- package/lib/vectors/DuckDBUIntegerVector.d.ts +17 -0
- package/lib/vectors/DuckDBUIntegerVector.js +61 -0
- package/lib/vectors/DuckDBUSmallIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUSmallIntVector.js +61 -0
- package/lib/vectors/DuckDBUTinyIntVector.d.ts +17 -0
- package/lib/vectors/DuckDBUTinyIntVector.js +61 -0
- package/lib/vectors/DuckDBUUIDVector.d.ts +19 -0
- package/lib/vectors/DuckDBUUIDVector.js +59 -0
- package/lib/vectors/DuckDBUnionVector.d.ts +17 -0
- package/lib/vectors/DuckDBUnionVector.js +70 -0
- package/lib/vectors/DuckDBValidity.d.ts +12 -0
- package/lib/vectors/DuckDBValidity.js +91 -0
- package/lib/vectors/DuckDBVarCharVector.d.ts +21 -0
- package/lib/vectors/DuckDBVarCharVector.js +74 -0
- package/lib/vectors/DuckDBVariantVector.d.ts +42 -0
- package/lib/vectors/DuckDBVariantVector.js +461 -0
- package/lib/vectors/DuckDBVector.d.ts +14 -0
- package/lib/vectors/DuckDBVector.js +27 -0
- package/lib/vectors/createVector.d.ts +1 -0
- package/lib/vectors/createVector.js +201 -0
- package/lib/vectors/dataAccessors.d.ts +45 -0
- package/lib/vectors/dataAccessors.js +344 -0
- package/lib/vectors/index.d.ts +47 -0
- package/lib/vectors/index.js +65 -0
- package/lib/vectors/vectorRegistry.d.ts +20 -0
- package/lib/vectors/vectorRegistry.js +16 -0
- package/package.json +3 -2
- package/lib/DuckDBFunctionInfo.d.ts +0 -10
package/lib/DuckDBTypeId.d.ts
CHANGED
package/lib/DuckDBTypeId.js
CHANGED
|
@@ -44,4 +44,7 @@ var DuckDBTypeId;
|
|
|
44
44
|
DuckDBTypeId[DuckDBTypeId["STRING_LITERAL"] = 37] = "STRING_LITERAL";
|
|
45
45
|
DuckDBTypeId[DuckDBTypeId["INTEGER_LITERAL"] = 38] = "INTEGER_LITERAL";
|
|
46
46
|
DuckDBTypeId[DuckDBTypeId["TIME_NS"] = 39] = "TIME_NS";
|
|
47
|
+
DuckDBTypeId[DuckDBTypeId["GEOMETRY"] = 40] = "GEOMETRY";
|
|
48
|
+
DuckDBTypeId[DuckDBTypeId["VARIANT"] = 41] = "VARIANT";
|
|
49
|
+
DuckDBTypeId[DuckDBTypeId["TIMESTAMP_TZ_NS"] = 42] = "TIMESTAMP_TZ_NS";
|
|
47
50
|
})(DuckDBTypeId || (exports.DuckDBTypeId = DuckDBTypeId = {}));
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import { DuckDBType } from './DuckDBType';
|
|
2
2
|
import { DuckDBValue } from './values';
|
|
3
3
|
export type DuckDBValueConverter<T> = (value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>) => T | null;
|
|
4
|
+
/**
|
|
5
|
+
* A converter for a single DuckDB type id, whose output type is narrower than
|
|
6
|
+
* the output type of the top-level converter it recurses through.
|
|
7
|
+
*
|
|
8
|
+
* `DuckDBValueConverter<T>` ties both the return type and the recursion hook
|
|
9
|
+
* to the same `T`. In a per-type-id converter map, only the return type varies
|
|
10
|
+
* by id: the `converter` argument is always the map's top-level converter, so
|
|
11
|
+
* `Nested` stays fixed while `Out` narrows.
|
|
12
|
+
*/
|
|
13
|
+
export type DuckDBValueConverterFor<Out, Nested> = (value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<Nested>) => Out | null;
|
|
@@ -10,8 +10,10 @@ export declare function bigintFromBigIntValue(value: DuckDBValue, type: DuckDBTy
|
|
|
10
10
|
export declare function stringFromValue(value: DuckDBValue): string;
|
|
11
11
|
export declare function bytesFromBlobValue(value: DuckDBValue): Uint8Array;
|
|
12
12
|
export declare function bytesFromBitValue(value: DuckDBValue): Uint8Array;
|
|
13
|
+
export declare function bytesFromGeometryValue(value: DuckDBValue): Uint8Array;
|
|
13
14
|
export declare function dateFromDateValue(value: DuckDBValue): Date;
|
|
14
15
|
export declare function bigintFromTimeValue(value: DuckDBValue): bigint;
|
|
16
|
+
export declare function bigintFromTimeNSValue(value: DuckDBValue): bigint;
|
|
15
17
|
export declare function dateFromTimestampValue(value: DuckDBValue): Date;
|
|
16
18
|
export declare function dateFromTimestampSecondsValue(value: DuckDBValue): Date;
|
|
17
19
|
export declare function dateFromTimestampMillisecondsValue(value: DuckDBValue): Date;
|
|
@@ -21,6 +23,7 @@ export declare function objectFromTimeTZValue(value: DuckDBValue): {
|
|
|
21
23
|
offset: number;
|
|
22
24
|
};
|
|
23
25
|
export declare function dateFromTimestampTZValue(value: DuckDBValue): Date;
|
|
26
|
+
export declare function dateFromTimestampTZNanosecondsValue(value: DuckDBValue): Date;
|
|
24
27
|
export declare function objectFromIntervalValue(value: DuckDBValue): {
|
|
25
28
|
months: number;
|
|
26
29
|
days: number;
|
|
@@ -36,6 +39,14 @@ export declare function arrayFromListValue<T>(value: DuckDBValue, type: DuckDBTy
|
|
|
36
39
|
export declare function objectFromStructValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): {
|
|
37
40
|
[key: string]: T | null;
|
|
38
41
|
};
|
|
42
|
+
export declare function arrayFromTupleValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): (T | null)[];
|
|
43
|
+
/**
|
|
44
|
+
* Converts a STRUCT value: a tuple (see `DuckDBStructType.isTuple`) to an
|
|
45
|
+
* array of its items, and a named struct to an object keyed by entry name.
|
|
46
|
+
*/
|
|
47
|
+
export declare function objectOrArrayFromStructValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): {
|
|
48
|
+
[key: string]: T | null;
|
|
49
|
+
} | (T | null)[];
|
|
39
50
|
export declare function objectArrayFromMapValue<T>(value: DuckDBValue, type: DuckDBType, converter: DuckDBValueConverter<T>): {
|
|
40
51
|
key: T | null;
|
|
41
52
|
value: T | null;
|
|
@@ -45,3 +56,19 @@ export declare function objectFromUnionValue<T>(value: DuckDBValue, type: DuckDB
|
|
|
45
56
|
tag: string;
|
|
46
57
|
value: T | null;
|
|
47
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Converter for VARIANT values: unwraps the `DuckDBVariantValue` wrapper
|
|
61
|
+
* and recursively walks the inner value, re-dispatching each scalar leaf
|
|
62
|
+
* through the supplied converter.
|
|
63
|
+
*
|
|
64
|
+
* A walker is needed (rather than just dispatching through the converter)
|
|
65
|
+
* because VARIANT containers are *heterogeneous* — items in a list or
|
|
66
|
+
* fields in a struct can have different types — while
|
|
67
|
+
* `arrayFromListValue` / `objectFromStructValue` / `objectArrayFromMapValue`
|
|
68
|
+
* assume a homogeneous element type pulled from the enclosing
|
|
69
|
+
* `DuckDBListType` / `DuckDBStructType` / `DuckDBMapType`. The walker
|
|
70
|
+
* emits the same output shape those converters do, and prefers the
|
|
71
|
+
* `DuckDBVariantValue.type` recorded by the decoder over `typeForValue`
|
|
72
|
+
* inference whenever a wrapper is encountered.
|
|
73
|
+
*/
|
|
74
|
+
export declare function fromVariantValue<T>(value: DuckDBValue, _type: DuckDBType, converter: DuckDBValueConverter<T>): T | null;
|
|
@@ -9,29 +9,42 @@ exports.bigintFromBigIntValue = bigintFromBigIntValue;
|
|
|
9
9
|
exports.stringFromValue = stringFromValue;
|
|
10
10
|
exports.bytesFromBlobValue = bytesFromBlobValue;
|
|
11
11
|
exports.bytesFromBitValue = bytesFromBitValue;
|
|
12
|
+
exports.bytesFromGeometryValue = bytesFromGeometryValue;
|
|
12
13
|
exports.dateFromDateValue = dateFromDateValue;
|
|
13
14
|
exports.bigintFromTimeValue = bigintFromTimeValue;
|
|
15
|
+
exports.bigintFromTimeNSValue = bigintFromTimeNSValue;
|
|
14
16
|
exports.dateFromTimestampValue = dateFromTimestampValue;
|
|
15
17
|
exports.dateFromTimestampSecondsValue = dateFromTimestampSecondsValue;
|
|
16
18
|
exports.dateFromTimestampMillisecondsValue = dateFromTimestampMillisecondsValue;
|
|
17
19
|
exports.dateFromTimestampNanosecondsValue = dateFromTimestampNanosecondsValue;
|
|
18
20
|
exports.objectFromTimeTZValue = objectFromTimeTZValue;
|
|
19
21
|
exports.dateFromTimestampTZValue = dateFromTimestampTZValue;
|
|
22
|
+
exports.dateFromTimestampTZNanosecondsValue = dateFromTimestampTZNanosecondsValue;
|
|
20
23
|
exports.objectFromIntervalValue = objectFromIntervalValue;
|
|
21
24
|
exports.jsonObjectFromIntervalValue = jsonObjectFromIntervalValue;
|
|
22
25
|
exports.doubleFromDecimalValue = doubleFromDecimalValue;
|
|
23
26
|
exports.arrayFromListValue = arrayFromListValue;
|
|
24
27
|
exports.objectFromStructValue = objectFromStructValue;
|
|
28
|
+
exports.arrayFromTupleValue = arrayFromTupleValue;
|
|
29
|
+
exports.objectOrArrayFromStructValue = objectOrArrayFromStructValue;
|
|
25
30
|
exports.objectArrayFromMapValue = objectArrayFromMapValue;
|
|
26
31
|
exports.arrayFromArrayValue = arrayFromArrayValue;
|
|
27
32
|
exports.objectFromUnionValue = objectFromUnionValue;
|
|
33
|
+
exports.fromVariantValue = fromVariantValue;
|
|
28
34
|
const DuckDBType_1 = require("./DuckDBType");
|
|
35
|
+
const DuckDBTypeId_1 = require("./DuckDBTypeId");
|
|
36
|
+
const typeForValue_1 = require("./typeForValue");
|
|
29
37
|
const values_1 = require("./values");
|
|
30
38
|
const MIN_DATE_DAYS = -100000000;
|
|
31
39
|
const MAX_DATE_DAYS = 100000000;
|
|
32
40
|
// -8640000000000
|
|
33
41
|
const MIN_DATE_MILLIS = -8640000000000000;
|
|
34
42
|
const MAX_DATE_MILLIS = 8640000000000000;
|
|
43
|
+
/** Whether a TIMESTAMP_NS or TIMESTAMPTZ_NS value is not +/-infinity. */
|
|
44
|
+
function isFiniteNanos(nanos) {
|
|
45
|
+
return (nanos !== values_1.DuckDBTimestampNanosecondsValue.PosInf.nanos &&
|
|
46
|
+
nanos !== values_1.DuckDBTimestampNanosecondsValue.NegInf.nanos);
|
|
47
|
+
}
|
|
35
48
|
const MILLS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
36
49
|
function unsupportedConverter(_, type) {
|
|
37
50
|
throw new Error(`Unsupported type: ${type}`);
|
|
@@ -72,6 +85,12 @@ function bytesFromBitValue(value) {
|
|
|
72
85
|
}
|
|
73
86
|
throw new Error(`Expected DuckDBBitValue`);
|
|
74
87
|
}
|
|
88
|
+
function bytesFromGeometryValue(value) {
|
|
89
|
+
if (value instanceof values_1.DuckDBGeometryValue) {
|
|
90
|
+
return value.bytes;
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Expected DuckDBGeometryValue`);
|
|
93
|
+
}
|
|
75
94
|
function dateFromDateValue(value) {
|
|
76
95
|
if (value instanceof values_1.DuckDBDateValue) {
|
|
77
96
|
if (MIN_DATE_DAYS <= value.days && value.days <= MAX_DATE_DAYS) {
|
|
@@ -87,6 +106,12 @@ function bigintFromTimeValue(value) {
|
|
|
87
106
|
}
|
|
88
107
|
throw new Error(`Expected DuckDBTimeValue`);
|
|
89
108
|
}
|
|
109
|
+
function bigintFromTimeNSValue(value) {
|
|
110
|
+
if (value instanceof values_1.DuckDBTimeNSValue) {
|
|
111
|
+
return value.nanos;
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`Expected DuckDBTimeNSValue`);
|
|
114
|
+
}
|
|
90
115
|
function dateFromTimestampValue(value) {
|
|
91
116
|
if (value instanceof values_1.DuckDBTimestampValue) {
|
|
92
117
|
const millis = value.micros / 1000n;
|
|
@@ -120,7 +145,9 @@ function dateFromTimestampMillisecondsValue(value) {
|
|
|
120
145
|
function dateFromTimestampNanosecondsValue(value) {
|
|
121
146
|
if (value instanceof values_1.DuckDBTimestampNanosecondsValue) {
|
|
122
147
|
const millis = value.nanos / 1000000n;
|
|
123
|
-
if (
|
|
148
|
+
if (isFiniteNanos(value.nanos) &&
|
|
149
|
+
MIN_DATE_MILLIS <= millis &&
|
|
150
|
+
millis <= MAX_DATE_MILLIS) {
|
|
124
151
|
return new Date(Number(millis));
|
|
125
152
|
}
|
|
126
153
|
throw new Error(`TIMESTAMP_NS value out of range for JS Date: ${value.nanos} nanos`);
|
|
@@ -146,6 +173,18 @@ function dateFromTimestampTZValue(value) {
|
|
|
146
173
|
}
|
|
147
174
|
throw new Error(`Expected DuckDBTimestampTZValue`);
|
|
148
175
|
}
|
|
176
|
+
function dateFromTimestampTZNanosecondsValue(value) {
|
|
177
|
+
if (value instanceof values_1.DuckDBTimestampTZNanosecondsValue) {
|
|
178
|
+
const millis = value.nanos / 1000000n;
|
|
179
|
+
if (isFiniteNanos(value.nanos) &&
|
|
180
|
+
MIN_DATE_MILLIS <= millis &&
|
|
181
|
+
millis <= MAX_DATE_MILLIS) {
|
|
182
|
+
return new Date(Number(millis));
|
|
183
|
+
}
|
|
184
|
+
throw new Error(`TIMESTAMP_TZ_NS value out of range for JS Date: ${value.nanos} nanos`);
|
|
185
|
+
}
|
|
186
|
+
throw new Error(`Expected DuckDBTimestampTZNanosecondsValue`);
|
|
187
|
+
}
|
|
149
188
|
function objectFromIntervalValue(value) {
|
|
150
189
|
if (value instanceof values_1.DuckDBIntervalValue) {
|
|
151
190
|
return {
|
|
@@ -188,6 +227,24 @@ function objectFromStructValue(value, type, converter) {
|
|
|
188
227
|
}
|
|
189
228
|
throw new Error(`Expected DuckDBStructValue and DuckDBStructType`);
|
|
190
229
|
}
|
|
230
|
+
function arrayFromTupleValue(value, type, converter) {
|
|
231
|
+
if (value instanceof values_1.DuckDBTupleValue &&
|
|
232
|
+
type instanceof DuckDBType_1.DuckDBStructType &&
|
|
233
|
+
type.isTuple) {
|
|
234
|
+
return value.items.map((item, i) => converter(item, type.entryTypes[i], converter));
|
|
235
|
+
}
|
|
236
|
+
throw new Error(`Expected DuckDBTupleValue and tuple DuckDBStructType`);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Converts a STRUCT value: a tuple (see `DuckDBStructType.isTuple`) to an
|
|
240
|
+
* array of its items, and a named struct to an object keyed by entry name.
|
|
241
|
+
*/
|
|
242
|
+
function objectOrArrayFromStructValue(value, type, converter) {
|
|
243
|
+
if (value instanceof values_1.DuckDBTupleValue) {
|
|
244
|
+
return arrayFromTupleValue(value, type, converter);
|
|
245
|
+
}
|
|
246
|
+
return objectFromStructValue(value, type, converter);
|
|
247
|
+
}
|
|
191
248
|
function objectArrayFromMapValue(value, type, converter) {
|
|
192
249
|
if (value instanceof values_1.DuckDBMapValue && type instanceof DuckDBType_1.DuckDBMapType) {
|
|
193
250
|
return value.entries.map((entry) => ({
|
|
@@ -212,3 +269,73 @@ function objectFromUnionValue(value, type, converter) {
|
|
|
212
269
|
}
|
|
213
270
|
throw new Error(`Expected DuckDBUnionValue and DuckDBUnionType`);
|
|
214
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Converter for VARIANT values: unwraps the `DuckDBVariantValue` wrapper
|
|
274
|
+
* and recursively walks the inner value, re-dispatching each scalar leaf
|
|
275
|
+
* through the supplied converter.
|
|
276
|
+
*
|
|
277
|
+
* A walker is needed (rather than just dispatching through the converter)
|
|
278
|
+
* because VARIANT containers are *heterogeneous* — items in a list or
|
|
279
|
+
* fields in a struct can have different types — while
|
|
280
|
+
* `arrayFromListValue` / `objectFromStructValue` / `objectArrayFromMapValue`
|
|
281
|
+
* assume a homogeneous element type pulled from the enclosing
|
|
282
|
+
* `DuckDBListType` / `DuckDBStructType` / `DuckDBMapType`. The walker
|
|
283
|
+
* emits the same output shape those converters do, and prefers the
|
|
284
|
+
* `DuckDBVariantValue.type` recorded by the decoder over `typeForValue`
|
|
285
|
+
* inference whenever a wrapper is encountered.
|
|
286
|
+
*/
|
|
287
|
+
function fromVariantValue(value, _type, converter) {
|
|
288
|
+
if (!(value instanceof values_1.DuckDBVariantValue)) {
|
|
289
|
+
throw new Error(`Expected DuckDBVariantValue`);
|
|
290
|
+
}
|
|
291
|
+
return convertVariantInner(value.value, converter, value.type);
|
|
292
|
+
}
|
|
293
|
+
function convertVariantInner(value, converter, typeHint) {
|
|
294
|
+
if (value === null) {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
if (value instanceof values_1.DuckDBVariantValue) {
|
|
298
|
+
// Variant-of-variant (or a wrapped child inside a LIST(VARIANT)).
|
|
299
|
+
// Prefer the wrapper's exact type as the hint for further walking.
|
|
300
|
+
return convertVariantInner(value.value, converter, value.type ?? typeHint);
|
|
301
|
+
}
|
|
302
|
+
if (value instanceof values_1.DuckDBListValue || value instanceof values_1.DuckDBArrayValue) {
|
|
303
|
+
return value.items.map((item) => convertVariantInner(item, converter));
|
|
304
|
+
}
|
|
305
|
+
if (value instanceof values_1.DuckDBStructValue) {
|
|
306
|
+
const result = {};
|
|
307
|
+
for (const key in value.entries) {
|
|
308
|
+
result[key] = convertVariantInner(value.entries[key], converter);
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
if (value instanceof values_1.DuckDBTupleValue) {
|
|
313
|
+
return value.items.map((item) => convertVariantInner(item, converter));
|
|
314
|
+
}
|
|
315
|
+
if (value instanceof values_1.DuckDBMapValue) {
|
|
316
|
+
return value.entries.map((entry) => ({
|
|
317
|
+
key: convertVariantInner(entry.key, converter),
|
|
318
|
+
value: convertVariantInner(entry.value, converter),
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
if (value instanceof values_1.DuckDBUnionValue) {
|
|
322
|
+
return {
|
|
323
|
+
tag: value.tag,
|
|
324
|
+
value: convertVariantInner(value.value, converter),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
// Scalar (or non-recursable rich value like DECIMAL, BLOB, DATE, etc.):
|
|
328
|
+
// dispatch through the regular converter. Use `typeHint` (carried in
|
|
329
|
+
// from a wrapper) for type fidelity when available; fall back to
|
|
330
|
+
// `typeForValue` otherwise.
|
|
331
|
+
const inferredType = typeHint ?? (0, typeForValue_1.typeForValue)(value);
|
|
332
|
+
// `typeForValue` infers BIGINT for any JS integer number outside INT32
|
|
333
|
+
// range (e.g. a UINT32 VARIANT payload of 4_294_967_295). The BIGINT
|
|
334
|
+
// converters expect a `bigint`, not a `number`, and would otherwise
|
|
335
|
+
// throw. Coerce to bigint so the dispatch lands on a compatible reader.
|
|
336
|
+
if (typeof value === 'number' &&
|
|
337
|
+
inferredType.typeId === DuckDBTypeId_1.DuckDBTypeId.BIGINT) {
|
|
338
|
+
return converter(BigInt(value), inferredType, converter);
|
|
339
|
+
}
|
|
340
|
+
return converter(value, inferredType, converter);
|
|
341
|
+
}
|