@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.
Files changed (285) hide show
  1. package/README.md +315 -20
  2. package/lib/DuckDBAppender.d.ts +8 -2
  3. package/lib/DuckDBAppender.js +19 -1
  4. package/lib/DuckDBConnection.d.ts +2 -0
  5. package/lib/DuckDBConnection.js +4 -1
  6. package/lib/DuckDBDataChunk.d.ts +30 -0
  7. package/lib/DuckDBDataChunk.js +94 -1
  8. package/lib/DuckDBDataChunkWriter.d.ts +74 -0
  9. package/lib/DuckDBDataChunkWriter.js +109 -0
  10. package/lib/DuckDBLogicalType.d.ts +5 -1
  11. package/lib/DuckDBLogicalType.js +18 -1
  12. package/lib/DuckDBMaterializedResult.d.ts +8 -1
  13. package/lib/DuckDBMaterializedResult.js +22 -2
  14. package/lib/DuckDBPendingResult.d.ts +16 -1
  15. package/lib/DuckDBPendingResult.js +19 -2
  16. package/lib/DuckDBPreparedStatement.d.ts +4 -1
  17. package/lib/DuckDBPreparedStatement.js +17 -4
  18. package/lib/DuckDBResult.d.ts +21 -1
  19. package/lib/DuckDBResult.js +87 -5
  20. package/lib/DuckDBResultReader.d.ts +5 -0
  21. package/lib/DuckDBResultReader.js +9 -2
  22. package/lib/DuckDBScalarFunction.d.ts +9 -5
  23. package/lib/DuckDBScalarFunction.js +14 -5
  24. package/lib/DuckDBScalarFunctionBindInfo.d.ts +16 -0
  25. package/lib/{DuckDBBindInfo.js → DuckDBScalarFunctionBindInfo.js} +5 -3
  26. package/lib/DuckDBScalarFunctionInfo.d.ts +16 -0
  27. package/lib/{DuckDBFunctionInfo.js → DuckDBScalarFunctionInfo.js} +11 -3
  28. package/lib/{DuckDBBindInfo.d.ts → DuckDBScalarFunctionInitInfo.d.ts} +6 -4
  29. package/lib/DuckDBScalarFunctionInitInfo.js +39 -0
  30. package/lib/DuckDBTableFunction.d.ts +41 -0
  31. package/lib/DuckDBTableFunction.js +83 -0
  32. package/lib/DuckDBTableFunctionBindInfo.d.ts +21 -0
  33. package/lib/DuckDBTableFunctionBindInfo.js +54 -0
  34. package/lib/DuckDBTableFunctionInfo.d.ts +15 -0
  35. package/lib/DuckDBTableFunctionInfo.js +42 -0
  36. package/lib/DuckDBTableFunctionInitInfo.d.ts +22 -0
  37. package/lib/DuckDBTableFunctionInitInfo.js +58 -0
  38. package/lib/DuckDBType.d.ts +1 -373
  39. package/lib/DuckDBType.js +14 -927
  40. package/lib/DuckDBTypeId.d.ts +4 -1
  41. package/lib/DuckDBTypeId.js +3 -0
  42. package/lib/DuckDBValueConverter.d.ts +10 -0
  43. package/lib/DuckDBValueConverters.d.ts +27 -0
  44. package/lib/DuckDBValueConverters.js +128 -1
  45. package/lib/DuckDBVector.d.ts +1 -596
  46. package/lib/DuckDBVector.js +14 -2522
  47. package/lib/JSDuckDBValueConverter.d.ts +1 -2
  48. package/lib/JSDuckDBValueConverter.js +5 -2
  49. package/lib/JSInputTypeForTypeId.d.ts +104 -0
  50. package/lib/JSInputTypeForTypeId.js +3 -0
  51. package/lib/JSToDuckDBValueConverter.d.ts +30 -0
  52. package/lib/JSToDuckDBValueConverter.js +83 -0
  53. package/lib/JSTypeForTypeId.d.ts +91 -0
  54. package/lib/JSTypeForTypeId.js +3 -0
  55. package/lib/JsonDuckDBValueConverter.d.ts +1 -2
  56. package/lib/JsonDuckDBValueConverter.js +4 -1
  57. package/lib/JsonTypeForTypeId.d.ts +96 -0
  58. package/lib/JsonTypeForTypeId.js +3 -0
  59. package/lib/ToDuckDBValueConverter.d.ts +41 -0
  60. package/lib/ToDuckDBValueConverter.js +27 -0
  61. package/lib/ToDuckDBValueConverters.d.ts +54 -0
  62. package/lib/ToDuckDBValueConverters.js +199 -0
  63. package/lib/conversion/dateTimeStringConversion.d.ts +2 -2
  64. package/lib/conversion/dateTimeStringConversion.js +20 -7
  65. package/lib/conversion/varintDecode.d.ts +18 -0
  66. package/lib/conversion/varintDecode.js +42 -0
  67. package/lib/convertColumnsFromChunks.d.ts +1 -1
  68. package/lib/convertColumnsFromChunks.js +2 -2
  69. package/lib/createResult.d.ts +2 -1
  70. package/lib/createResult.js +3 -3
  71. package/lib/createValue.js +63 -5
  72. package/lib/duckdb.d.ts +15 -2
  73. package/lib/duckdb.js +15 -2
  74. package/lib/getColumnsFromChunks.d.ts +1 -1
  75. package/lib/getColumnsFromChunks.js +2 -2
  76. package/lib/getColumnsObjectFromChunks.js +3 -0
  77. package/lib/readValue.d.ts +22 -0
  78. package/lib/readValue.js +35 -0
  79. package/lib/typeForValue.js +21 -2
  80. package/lib/types/BaseDuckDBType.d.ts +11 -0
  81. package/lib/types/BaseDuckDBType.js +34 -0
  82. package/lib/types/DuckDBAnyType.d.ts +8 -0
  83. package/lib/types/DuckDBAnyType.js +16 -0
  84. package/lib/types/DuckDBArrayType.d.ts +14 -0
  85. package/lib/types/DuckDBArrayType.js +38 -0
  86. package/lib/types/DuckDBBigIntType.d.ts +12 -0
  87. package/lib/types/DuckDBBigIntType.js +24 -0
  88. package/lib/types/DuckDBBigNumType.d.ts +12 -0
  89. package/lib/types/DuckDBBigNumType.js +24 -0
  90. package/lib/types/DuckDBBitType.d.ts +8 -0
  91. package/lib/types/DuckDBBitType.js +16 -0
  92. package/lib/types/DuckDBBlobType.d.ts +8 -0
  93. package/lib/types/DuckDBBlobType.js +16 -0
  94. package/lib/types/DuckDBBooleanType.d.ts +8 -0
  95. package/lib/types/DuckDBBooleanType.js +16 -0
  96. package/lib/types/DuckDBDateType.d.ts +14 -0
  97. package/lib/types/DuckDBDateType.js +32 -0
  98. package/lib/types/DuckDBDecimalType.d.ts +14 -0
  99. package/lib/types/DuckDBDecimalType.js +45 -0
  100. package/lib/types/DuckDBDoubleType.d.ts +12 -0
  101. package/lib/types/DuckDBDoubleType.js +24 -0
  102. package/lib/types/DuckDBEnumType.d.ts +29 -0
  103. package/lib/types/DuckDBEnumType.js +100 -0
  104. package/lib/types/DuckDBFloatType.d.ts +12 -0
  105. package/lib/types/DuckDBFloatType.js +24 -0
  106. package/lib/types/DuckDBGeometryType.d.ts +19 -0
  107. package/lib/types/DuckDBGeometryType.js +38 -0
  108. package/lib/types/DuckDBHugeIntType.d.ts +12 -0
  109. package/lib/types/DuckDBHugeIntType.js +24 -0
  110. package/lib/types/DuckDBIntegerLiteralType.d.ts +8 -0
  111. package/lib/types/DuckDBIntegerLiteralType.js +16 -0
  112. package/lib/types/DuckDBIntegerType.d.ts +12 -0
  113. package/lib/types/DuckDBIntegerType.js +24 -0
  114. package/lib/types/DuckDBIntervalType.d.ts +8 -0
  115. package/lib/types/DuckDBIntervalType.js +16 -0
  116. package/lib/types/DuckDBListType.d.ts +13 -0
  117. package/lib/types/DuckDBListType.js +35 -0
  118. package/lib/types/DuckDBMapType.d.ts +14 -0
  119. package/lib/types/DuckDBMapType.js +38 -0
  120. package/lib/types/DuckDBSQLNullType.d.ts +10 -0
  121. package/lib/types/DuckDBSQLNullType.js +20 -0
  122. package/lib/types/DuckDBSmallIntType.d.ts +12 -0
  123. package/lib/types/DuckDBSmallIntType.js +24 -0
  124. package/lib/types/DuckDBStringLiteralType.d.ts +8 -0
  125. package/lib/types/DuckDBStringLiteralType.js +16 -0
  126. package/lib/types/DuckDBStructType.d.ts +29 -0
  127. package/lib/types/DuckDBStructType.js +86 -0
  128. package/lib/types/DuckDBTimeNSType.d.ts +11 -0
  129. package/lib/types/DuckDBTimeNSType.js +23 -0
  130. package/lib/types/DuckDBTimeTZType.d.ts +12 -0
  131. package/lib/types/DuckDBTimeTZType.js +26 -0
  132. package/lib/types/DuckDBTimeType.d.ts +11 -0
  133. package/lib/types/DuckDBTimeType.js +23 -0
  134. package/lib/types/DuckDBTimestampMillisecondsType.d.ts +14 -0
  135. package/lib/types/DuckDBTimestampMillisecondsType.js +32 -0
  136. package/lib/types/DuckDBTimestampNanosecondsType.d.ts +14 -0
  137. package/lib/types/DuckDBTimestampNanosecondsType.js +32 -0
  138. package/lib/types/DuckDBTimestampSecondsType.d.ts +14 -0
  139. package/lib/types/DuckDBTimestampSecondsType.js +32 -0
  140. package/lib/types/DuckDBTimestampTZNanosecondsType.d.ts +15 -0
  141. package/lib/types/DuckDBTimestampTZNanosecondsType.js +35 -0
  142. package/lib/types/DuckDBTimestampTZType.d.ts +15 -0
  143. package/lib/types/DuckDBTimestampTZType.js +35 -0
  144. package/lib/types/DuckDBTimestampType.d.ts +16 -0
  145. package/lib/types/DuckDBTimestampType.js +33 -0
  146. package/lib/types/DuckDBTinyIntType.d.ts +12 -0
  147. package/lib/types/DuckDBTinyIntType.js +24 -0
  148. package/lib/types/DuckDBType.d.ts +43 -0
  149. package/lib/types/DuckDBType.js +2 -0
  150. package/lib/types/DuckDBUBigIntType.d.ts +12 -0
  151. package/lib/types/DuckDBUBigIntType.js +24 -0
  152. package/lib/types/DuckDBUHugeIntType.d.ts +12 -0
  153. package/lib/types/DuckDBUHugeIntType.js +24 -0
  154. package/lib/types/DuckDBUIntegerType.d.ts +12 -0
  155. package/lib/types/DuckDBUIntegerType.js +24 -0
  156. package/lib/types/DuckDBUSmallIntType.d.ts +12 -0
  157. package/lib/types/DuckDBUSmallIntType.js +24 -0
  158. package/lib/types/DuckDBUTinyIntType.d.ts +12 -0
  159. package/lib/types/DuckDBUTinyIntType.js +24 -0
  160. package/lib/types/DuckDBUUIDType.d.ts +11 -0
  161. package/lib/types/DuckDBUUIDType.js +23 -0
  162. package/lib/types/DuckDBUnionType.d.ts +18 -0
  163. package/lib/types/DuckDBUnionType.js +64 -0
  164. package/lib/types/DuckDBVarCharType.d.ts +8 -0
  165. package/lib/types/DuckDBVarCharType.js +16 -0
  166. package/lib/types/DuckDBVariantType.d.ts +8 -0
  167. package/lib/types/DuckDBVariantType.js +16 -0
  168. package/lib/types/index.d.ts +44 -0
  169. package/lib/types/index.js +60 -0
  170. package/lib/values/DuckDBGeometryValue.d.ts +12 -0
  171. package/lib/values/DuckDBGeometryValue.js +30 -0
  172. package/lib/values/DuckDBTimestampTZNanosecondsValue.d.ts +14 -0
  173. package/lib/values/DuckDBTimestampTZNanosecondsValue.js +33 -0
  174. package/lib/values/DuckDBTupleValue.d.ts +11 -0
  175. package/lib/values/DuckDBTupleValue.js +22 -0
  176. package/lib/values/DuckDBUUIDValue.js +5 -1
  177. package/lib/values/DuckDBValue.d.ts +5 -1
  178. package/lib/values/DuckDBVariantValue.d.ts +19 -0
  179. package/lib/values/DuckDBVariantValue.js +30 -0
  180. package/lib/values/index.d.ts +4 -0
  181. package/lib/values/index.js +4 -0
  182. package/lib/vectors/DuckDBArrayVector.d.ts +21 -0
  183. package/lib/vectors/DuckDBArrayVector.js +79 -0
  184. package/lib/vectors/DuckDBBigIntVector.d.ts +17 -0
  185. package/lib/vectors/DuckDBBigIntVector.js +58 -0
  186. package/lib/vectors/DuckDBBigNumVector.d.ts +21 -0
  187. package/lib/vectors/DuckDBBigNumVector.js +70 -0
  188. package/lib/vectors/DuckDBBitVector.d.ts +22 -0
  189. package/lib/vectors/DuckDBBitVector.js +74 -0
  190. package/lib/vectors/DuckDBBlobVector.d.ts +32 -0
  191. package/lib/vectors/DuckDBBlobVector.js +83 -0
  192. package/lib/vectors/DuckDBBooleanVector.d.ts +18 -0
  193. package/lib/vectors/DuckDBBooleanVector.js +58 -0
  194. package/lib/vectors/DuckDBDateVector.d.ts +18 -0
  195. package/lib/vectors/DuckDBDateVector.js +64 -0
  196. package/lib/vectors/DuckDBDecimal128Vector.d.ts +21 -0
  197. package/lib/vectors/DuckDBDecimal128Vector.js +64 -0
  198. package/lib/vectors/DuckDBDecimal16Vector.d.ts +21 -0
  199. package/lib/vectors/DuckDBDecimal16Vector.js +64 -0
  200. package/lib/vectors/DuckDBDecimal32Vector.d.ts +21 -0
  201. package/lib/vectors/DuckDBDecimal32Vector.js +64 -0
  202. package/lib/vectors/DuckDBDecimal64Vector.d.ts +21 -0
  203. package/lib/vectors/DuckDBDecimal64Vector.js +64 -0
  204. package/lib/vectors/DuckDBDoubleVector.d.ts +17 -0
  205. package/lib/vectors/DuckDBDoubleVector.js +54 -0
  206. package/lib/vectors/DuckDBEnum16Vector.d.ts +18 -0
  207. package/lib/vectors/DuckDBEnum16Vector.js +57 -0
  208. package/lib/vectors/DuckDBEnum32Vector.d.ts +18 -0
  209. package/lib/vectors/DuckDBEnum32Vector.js +57 -0
  210. package/lib/vectors/DuckDBEnum8Vector.d.ts +18 -0
  211. package/lib/vectors/DuckDBEnum8Vector.js +57 -0
  212. package/lib/vectors/DuckDBFloatVector.d.ts +17 -0
  213. package/lib/vectors/DuckDBFloatVector.js +54 -0
  214. package/lib/vectors/DuckDBGeometryVector.d.ts +22 -0
  215. package/lib/vectors/DuckDBGeometryVector.js +69 -0
  216. package/lib/vectors/DuckDBHugeIntVector.d.ts +19 -0
  217. package/lib/vectors/DuckDBHugeIntVector.js +63 -0
  218. package/lib/vectors/DuckDBIntegerVector.d.ts +17 -0
  219. package/lib/vectors/DuckDBIntegerVector.js +61 -0
  220. package/lib/vectors/DuckDBIntervalVector.d.ts +19 -0
  221. package/lib/vectors/DuckDBIntervalVector.js +67 -0
  222. package/lib/vectors/DuckDBListVector.d.ts +35 -0
  223. package/lib/vectors/DuckDBListVector.js +151 -0
  224. package/lib/vectors/DuckDBMapVector.d.ts +17 -0
  225. package/lib/vectors/DuckDBMapVector.js +60 -0
  226. package/lib/vectors/DuckDBSQLNullVector.d.ts +18 -0
  227. package/lib/vectors/DuckDBSQLNullVector.js +44 -0
  228. package/lib/vectors/DuckDBSmallIntVector.d.ts +17 -0
  229. package/lib/vectors/DuckDBSmallIntVector.js +61 -0
  230. package/lib/vectors/DuckDBStructVector.d.ts +35 -0
  231. package/lib/vectors/DuckDBStructVector.js +105 -0
  232. package/lib/vectors/DuckDBTimeNSVector.d.ts +18 -0
  233. package/lib/vectors/DuckDBTimeNSVector.js +61 -0
  234. package/lib/vectors/DuckDBTimeTZVector.d.ts +18 -0
  235. package/lib/vectors/DuckDBTimeTZVector.js +61 -0
  236. package/lib/vectors/DuckDBTimeVector.d.ts +18 -0
  237. package/lib/vectors/DuckDBTimeVector.js +61 -0
  238. package/lib/vectors/DuckDBTimestampMillisecondsVector.d.ts +18 -0
  239. package/lib/vectors/DuckDBTimestampMillisecondsVector.js +61 -0
  240. package/lib/vectors/DuckDBTimestampNanosecondsVector.d.ts +18 -0
  241. package/lib/vectors/DuckDBTimestampNanosecondsVector.js +61 -0
  242. package/lib/vectors/DuckDBTimestampSecondsVector.d.ts +18 -0
  243. package/lib/vectors/DuckDBTimestampSecondsVector.js +61 -0
  244. package/lib/vectors/DuckDBTimestampTZNanosecondsVector.d.ts +18 -0
  245. package/lib/vectors/DuckDBTimestampTZNanosecondsVector.js +61 -0
  246. package/lib/vectors/DuckDBTimestampTZVector.d.ts +18 -0
  247. package/lib/vectors/DuckDBTimestampTZVector.js +61 -0
  248. package/lib/vectors/DuckDBTimestampVector.d.ts +18 -0
  249. package/lib/vectors/DuckDBTimestampVector.js +61 -0
  250. package/lib/vectors/DuckDBTinyIntVector.d.ts +17 -0
  251. package/lib/vectors/DuckDBTinyIntVector.js +61 -0
  252. package/lib/vectors/DuckDBTupleVector.d.ts +26 -0
  253. package/lib/vectors/DuckDBTupleVector.js +91 -0
  254. package/lib/vectors/DuckDBUBigIntVector.d.ts +17 -0
  255. package/lib/vectors/DuckDBUBigIntVector.js +58 -0
  256. package/lib/vectors/DuckDBUHugeIntVector.d.ts +19 -0
  257. package/lib/vectors/DuckDBUHugeIntVector.js +63 -0
  258. package/lib/vectors/DuckDBUIntegerVector.d.ts +17 -0
  259. package/lib/vectors/DuckDBUIntegerVector.js +61 -0
  260. package/lib/vectors/DuckDBUSmallIntVector.d.ts +17 -0
  261. package/lib/vectors/DuckDBUSmallIntVector.js +61 -0
  262. package/lib/vectors/DuckDBUTinyIntVector.d.ts +17 -0
  263. package/lib/vectors/DuckDBUTinyIntVector.js +61 -0
  264. package/lib/vectors/DuckDBUUIDVector.d.ts +19 -0
  265. package/lib/vectors/DuckDBUUIDVector.js +59 -0
  266. package/lib/vectors/DuckDBUnionVector.d.ts +17 -0
  267. package/lib/vectors/DuckDBUnionVector.js +70 -0
  268. package/lib/vectors/DuckDBValidity.d.ts +12 -0
  269. package/lib/vectors/DuckDBValidity.js +91 -0
  270. package/lib/vectors/DuckDBVarCharVector.d.ts +21 -0
  271. package/lib/vectors/DuckDBVarCharVector.js +74 -0
  272. package/lib/vectors/DuckDBVariantVector.d.ts +42 -0
  273. package/lib/vectors/DuckDBVariantVector.js +461 -0
  274. package/lib/vectors/DuckDBVector.d.ts +14 -0
  275. package/lib/vectors/DuckDBVector.js +27 -0
  276. package/lib/vectors/createVector.d.ts +1 -0
  277. package/lib/vectors/createVector.js +201 -0
  278. package/lib/vectors/dataAccessors.d.ts +45 -0
  279. package/lib/vectors/dataAccessors.js +344 -0
  280. package/lib/vectors/index.d.ts +47 -0
  281. package/lib/vectors/index.js +65 -0
  282. package/lib/vectors/vectorRegistry.d.ts +20 -0
  283. package/lib/vectors/vectorRegistry.js +16 -0
  284. package/package.json +3 -2
  285. package/lib/DuckDBFunctionInfo.d.ts +0 -10
@@ -38,5 +38,8 @@ export declare enum DuckDBTypeId {
38
38
  SQLNULL = 36,
39
39
  STRING_LITERAL = 37,
40
40
  INTEGER_LITERAL = 38,
41
- TIME_NS = 39
41
+ TIME_NS = 39,
42
+ GEOMETRY = 40,
43
+ VARIANT = 41,
44
+ TIMESTAMP_TZ_NS = 42
42
45
  }
@@ -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 (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
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
+ }