@avidian/duckdb-bun 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +284 -2
  3. package/package.json +95 -4
  4. package/src/bindings/api/appender.ts +288 -0
  5. package/src/bindings/api/data-chunk.ts +58 -0
  6. package/src/bindings/api/database.ts +232 -0
  7. package/src/bindings/api/datetime.ts +158 -0
  8. package/src/bindings/api/index.ts +13 -0
  9. package/src/bindings/api/logical-types.ts +227 -0
  10. package/src/bindings/api/query.ts +616 -0
  11. package/src/bindings/api/scalar-function.ts +274 -0
  12. package/src/bindings/api/table-function.ts +339 -0
  13. package/src/bindings/api/values.ts +546 -0
  14. package/src/bindings/api/vector.ts +266 -0
  15. package/src/bindings/generated/capi.ts +695 -0
  16. package/src/bindings/generated/contract.ts +162 -0
  17. package/src/bindings/index.ts +10 -0
  18. package/src/bindings/runtime/convert.ts +307 -0
  19. package/src/bindings/runtime/diagnostics.ts +45 -0
  20. package/src/bindings/runtime/dispatch.ts +200 -0
  21. package/src/bindings/runtime/exception.ts +103 -0
  22. package/src/bindings/runtime/flags.ts +19 -0
  23. package/src/bindings/runtime/handle.ts +217 -0
  24. package/src/bindings/runtime/kinds.ts +53 -0
  25. package/src/bindings/runtime/marshal.ts +190 -0
  26. package/src/bindings/runtime/native.ts +150 -0
  27. package/src/bindings/runtime/ring.ts +54 -0
  28. package/src/bindings/runtime/scope.ts +133 -0
  29. package/src/bindings/runtime/trace.ts +65 -0
  30. package/src/connection.ts +35 -0
  31. package/src/database.ts +27 -0
  32. package/src/errors.ts +30 -0
  33. package/src/file-assets.d.ts +10 -0
  34. package/src/index.ts +17 -0
  35. package/src/library.ts +83 -0
  36. package/src/neo.ts +16 -0
  37. package/src/reader.ts +47 -0
  38. package/src/statement.ts +61 -0
  39. package/src/types.ts +52 -0
  40. package/src/version.ts +6 -0
  41. package/vendor/node-api/LICENSE +7 -0
  42. package/vendor/node-api/PROVENANCE.md +54 -0
  43. package/vendor/node-api/node-bindings.d.ts +1669 -0
  44. package/vendor/node-api/src/DuckDBAppender.ts +237 -0
  45. package/vendor/node-api/src/DuckDBClientContext.ts +13 -0
  46. package/vendor/node-api/src/DuckDBConnection.ts +315 -0
  47. package/vendor/node-api/src/DuckDBDataChunk.ts +412 -0
  48. package/vendor/node-api/src/DuckDBDataChunkWriter.ts +144 -0
  49. package/vendor/node-api/src/DuckDBExtractedStatements.ts +37 -0
  50. package/vendor/node-api/src/DuckDBInstance.ts +35 -0
  51. package/vendor/node-api/src/DuckDBInstanceCache.ts +29 -0
  52. package/vendor/node-api/src/DuckDBLogicalType.ts +446 -0
  53. package/vendor/node-api/src/DuckDBMaterializedResult.ts +39 -0
  54. package/vendor/node-api/src/DuckDBPendingResult.ts +83 -0
  55. package/vendor/node-api/src/DuckDBPreparedStatement.ts +376 -0
  56. package/vendor/node-api/src/DuckDBPreparedStatementCollection.ts +5 -0
  57. package/vendor/node-api/src/DuckDBPreparedStatementWeakRefCollection.ts +31 -0
  58. package/vendor/node-api/src/DuckDBResult.ts +403 -0
  59. package/vendor/node-api/src/DuckDBResultReader.ts +283 -0
  60. package/vendor/node-api/src/DuckDBScalarFunction.ts +149 -0
  61. package/vendor/node-api/src/DuckDBScalarFunctionBindInfo.ts +34 -0
  62. package/vendor/node-api/src/DuckDBScalarFunctionInfo.ts +34 -0
  63. package/vendor/node-api/src/DuckDBScalarFunctionInitInfo.ts +35 -0
  64. package/vendor/node-api/src/DuckDBTableFunction.ts +149 -0
  65. package/vendor/node-api/src/DuckDBTableFunctionBindInfo.ts +56 -0
  66. package/vendor/node-api/src/DuckDBTableFunctionInfo.ts +36 -0
  67. package/vendor/node-api/src/DuckDBTableFunctionInitInfo.ts +52 -0
  68. package/vendor/node-api/src/DuckDBType.ts +1 -0
  69. package/vendor/node-api/src/DuckDBTypeId.ts +46 -0
  70. package/vendor/node-api/src/DuckDBValueConverter.ts +23 -0
  71. package/vendor/node-api/src/DuckDBValueConverters.ts +461 -0
  72. package/vendor/node-api/src/DuckDBVector.ts +1 -0
  73. package/vendor/node-api/src/JS.ts +11 -0
  74. package/vendor/node-api/src/JSDuckDBValueConverter.ts +85 -0
  75. package/vendor/node-api/src/JSInputTypeForTypeId.ts +101 -0
  76. package/vendor/node-api/src/JSToDuckDBValueConverter.ts +136 -0
  77. package/vendor/node-api/src/JSTypeForTypeId.ts +78 -0
  78. package/vendor/node-api/src/Json.ts +7 -0
  79. package/vendor/node-api/src/JsonDuckDBValueConverter.ts +72 -0
  80. package/vendor/node-api/src/JsonTypeForTypeId.ts +86 -0
  81. package/vendor/node-api/src/ToDuckDBValueConverter.ts +68 -0
  82. package/vendor/node-api/src/ToDuckDBValueConverters.ts +303 -0
  83. package/vendor/node-api/src/configurationOptionDescriptions.ts +13 -0
  84. package/vendor/node-api/src/conversion/bytesFromString.ts +5 -0
  85. package/vendor/node-api/src/conversion/dateTimeStringConversion.ts +343 -0
  86. package/vendor/node-api/src/conversion/displayStringForDuckDBValue.ts +12 -0
  87. package/vendor/node-api/src/conversion/stringFromBlob.ts +48 -0
  88. package/vendor/node-api/src/conversion/stringFromDecimal.ts +129 -0
  89. package/vendor/node-api/src/conversion/varintDecode.ts +42 -0
  90. package/vendor/node-api/src/convertColumnsFromChunks.ts +28 -0
  91. package/vendor/node-api/src/convertColumnsObjectFromChunks.ts +29 -0
  92. package/vendor/node-api/src/convertRowObjectsFromChunks.ts +21 -0
  93. package/vendor/node-api/src/convertRowsFromChunks.ts +16 -0
  94. package/vendor/node-api/src/createConfig.ts +14 -0
  95. package/vendor/node-api/src/createDuckDBValueConverter.ts +17 -0
  96. package/vendor/node-api/src/createResult.ts +15 -0
  97. package/vendor/node-api/src/createValue.ts +355 -0
  98. package/vendor/node-api/src/duckdb.ts +51 -0
  99. package/vendor/node-api/src/enums.ts +7 -0
  100. package/vendor/node-api/src/getColumnsFromChunks.ts +13 -0
  101. package/vendor/node-api/src/getColumnsObjectFromChunks.ts +16 -0
  102. package/vendor/node-api/src/getRowObjectsFromChunks.ts +13 -0
  103. package/vendor/node-api/src/getRowsFromChunks.ts +12 -0
  104. package/vendor/node-api/src/index.ts +3 -0
  105. package/vendor/node-api/src/readValue.ts +31 -0
  106. package/vendor/node-api/src/sleep.ts +5 -0
  107. package/vendor/node-api/src/sql.ts +7 -0
  108. package/vendor/node-api/src/tsconfig.json +7 -0
  109. package/vendor/node-api/src/typeForValue.ts +144 -0
  110. package/vendor/node-api/src/types/BaseDuckDBType.ts +31 -0
  111. package/vendor/node-api/src/types/DuckDBAnyType.ts +13 -0
  112. package/vendor/node-api/src/types/DuckDBArrayType.ts +43 -0
  113. package/vendor/node-api/src/types/DuckDBBigIntType.ts +21 -0
  114. package/vendor/node-api/src/types/DuckDBBigNumType.ts +21 -0
  115. package/vendor/node-api/src/types/DuckDBBitType.ts +13 -0
  116. package/vendor/node-api/src/types/DuckDBBlobType.ts +13 -0
  117. package/vendor/node-api/src/types/DuckDBBooleanType.ts +13 -0
  118. package/vendor/node-api/src/types/DuckDBDateType.ts +29 -0
  119. package/vendor/node-api/src/types/DuckDBDecimalType.ts +46 -0
  120. package/vendor/node-api/src/types/DuckDBDoubleType.ts +21 -0
  121. package/vendor/node-api/src/types/DuckDBEnumType.ts +111 -0
  122. package/vendor/node-api/src/types/DuckDBFloatType.ts +21 -0
  123. package/vendor/node-api/src/types/DuckDBGeometryType.ts +36 -0
  124. package/vendor/node-api/src/types/DuckDBHugeIntType.ts +21 -0
  125. package/vendor/node-api/src/types/DuckDBIntegerLiteralType.ts +13 -0
  126. package/vendor/node-api/src/types/DuckDBIntegerType.ts +21 -0
  127. package/vendor/node-api/src/types/DuckDBIntervalType.ts +13 -0
  128. package/vendor/node-api/src/types/DuckDBListType.ts +35 -0
  129. package/vendor/node-api/src/types/DuckDBMapType.ts +47 -0
  130. package/vendor/node-api/src/types/DuckDBSQLNullType.ts +17 -0
  131. package/vendor/node-api/src/types/DuckDBSmallIntType.ts +21 -0
  132. package/vendor/node-api/src/types/DuckDBStringLiteralType.ts +13 -0
  133. package/vendor/node-api/src/types/DuckDBStructType.ts +104 -0
  134. package/vendor/node-api/src/types/DuckDBTimeNSType.ts +20 -0
  135. package/vendor/node-api/src/types/DuckDBTimeTZType.ts +23 -0
  136. package/vendor/node-api/src/types/DuckDBTimeType.ts +20 -0
  137. package/vendor/node-api/src/types/DuckDBTimestampMillisecondsType.ts +29 -0
  138. package/vendor/node-api/src/types/DuckDBTimestampNanosecondsType.ts +29 -0
  139. package/vendor/node-api/src/types/DuckDBTimestampSecondsType.ts +29 -0
  140. package/vendor/node-api/src/types/DuckDBTimestampTZNanosecondsType.ts +32 -0
  141. package/vendor/node-api/src/types/DuckDBTimestampTZType.ts +32 -0
  142. package/vendor/node-api/src/types/DuckDBTimestampType.ts +32 -0
  143. package/vendor/node-api/src/types/DuckDBTinyIntType.ts +21 -0
  144. package/vendor/node-api/src/types/DuckDBType.ts +86 -0
  145. package/vendor/node-api/src/types/DuckDBUBigIntType.ts +21 -0
  146. package/vendor/node-api/src/types/DuckDBUHugeIntType.ts +21 -0
  147. package/vendor/node-api/src/types/DuckDBUIntegerType.ts +21 -0
  148. package/vendor/node-api/src/types/DuckDBUSmallIntType.ts +21 -0
  149. package/vendor/node-api/src/types/DuckDBUTinyIntType.ts +21 -0
  150. package/vendor/node-api/src/types/DuckDBUUIDType.ts +20 -0
  151. package/vendor/node-api/src/types/DuckDBUnionType.ts +74 -0
  152. package/vendor/node-api/src/types/DuckDBVarCharType.ts +13 -0
  153. package/vendor/node-api/src/types/DuckDBVariantType.ts +13 -0
  154. package/vendor/node-api/src/types/index.ts +44 -0
  155. package/vendor/node-api/src/values/DuckDBArrayValue.ts +18 -0
  156. package/vendor/node-api/src/values/DuckDBBitValue.ts +117 -0
  157. package/vendor/node-api/src/values/DuckDBBlobValue.ts +26 -0
  158. package/vendor/node-api/src/values/DuckDBDateValue.ts +43 -0
  159. package/vendor/node-api/src/values/DuckDBDecimalValue.ts +44 -0
  160. package/vendor/node-api/src/values/DuckDBGeometryValue.ts +30 -0
  161. package/vendor/node-api/src/values/DuckDBIntervalValue.ts +22 -0
  162. package/vendor/node-api/src/values/DuckDBListValue.ts +18 -0
  163. package/vendor/node-api/src/values/DuckDBMapValue.ts +25 -0
  164. package/vendor/node-api/src/values/DuckDBStructValue.ts +22 -0
  165. package/vendor/node-api/src/values/DuckDBTimeNSValue.ts +23 -0
  166. package/vendor/node-api/src/values/DuckDBTimeTZValue.ts +96 -0
  167. package/vendor/node-api/src/values/DuckDBTimeValue.ts +34 -0
  168. package/vendor/node-api/src/values/DuckDBTimestampMillisecondsValue.ts +29 -0
  169. package/vendor/node-api/src/values/DuckDBTimestampNanosecondsValue.ts +28 -0
  170. package/vendor/node-api/src/values/DuckDBTimestampSecondsValue.ts +28 -0
  171. package/vendor/node-api/src/values/DuckDBTimestampTZNanosecondsValue.ts +44 -0
  172. package/vendor/node-api/src/values/DuckDBTimestampTZValue.ts +54 -0
  173. package/vendor/node-api/src/values/DuckDBTimestampValue.ts +45 -0
  174. package/vendor/node-api/src/values/DuckDBTupleValue.ts +22 -0
  175. package/vendor/node-api/src/values/DuckDBUUIDValue.ts +48 -0
  176. package/vendor/node-api/src/values/DuckDBUnionValue.ts +22 -0
  177. package/vendor/node-api/src/values/DuckDBValue.ts +53 -0
  178. package/vendor/node-api/src/values/DuckDBVariantValue.ts +34 -0
  179. package/vendor/node-api/src/values/index.ts +24 -0
  180. package/vendor/node-api/src/vectors/DuckDBArrayVector.ts +107 -0
  181. package/vendor/node-api/src/vectors/DuckDBBigIntVector.ts +75 -0
  182. package/vendor/node-api/src/vectors/DuckDBBigNumVector.ts +98 -0
  183. package/vendor/node-api/src/vectors/DuckDBBitVector.ts +102 -0
  184. package/vendor/node-api/src/vectors/DuckDBBlobVector.ts +112 -0
  185. package/vendor/node-api/src/vectors/DuckDBBooleanVector.ts +84 -0
  186. package/vendor/node-api/src/vectors/DuckDBDateVector.ts +80 -0
  187. package/vendor/node-api/src/vectors/DuckDBDecimal128Vector.ts +107 -0
  188. package/vendor/node-api/src/vectors/DuckDBDecimal16Vector.ts +104 -0
  189. package/vendor/node-api/src/vectors/DuckDBDecimal32Vector.ts +104 -0
  190. package/vendor/node-api/src/vectors/DuckDBDecimal64Vector.ts +104 -0
  191. package/vendor/node-api/src/vectors/DuckDBDoubleVector.ts +68 -0
  192. package/vendor/node-api/src/vectors/DuckDBEnum16Vector.ts +75 -0
  193. package/vendor/node-api/src/vectors/DuckDBEnum32Vector.ts +75 -0
  194. package/vendor/node-api/src/vectors/DuckDBEnum8Vector.ts +75 -0
  195. package/vendor/node-api/src/vectors/DuckDBFloatVector.ts +68 -0
  196. package/vendor/node-api/src/vectors/DuckDBGeometryVector.ts +97 -0
  197. package/vendor/node-api/src/vectors/DuckDBHugeIntVector.ts +89 -0
  198. package/vendor/node-api/src/vectors/DuckDBIntegerVector.ts +75 -0
  199. package/vendor/node-api/src/vectors/DuckDBIntervalVector.ts +100 -0
  200. package/vendor/node-api/src/vectors/DuckDBListVector.ts +221 -0
  201. package/vendor/node-api/src/vectors/DuckDBMapVector.ts +88 -0
  202. package/vendor/node-api/src/vectors/DuckDBSQLNullVector.ts +53 -0
  203. package/vendor/node-api/src/vectors/DuckDBSmallIntVector.ts +75 -0
  204. package/vendor/node-api/src/vectors/DuckDBStructVector.ts +138 -0
  205. package/vendor/node-api/src/vectors/DuckDBTimeNSVector.ts +80 -0
  206. package/vendor/node-api/src/vectors/DuckDBTimeTZVector.ts +80 -0
  207. package/vendor/node-api/src/vectors/DuckDBTimeVector.ts +80 -0
  208. package/vendor/node-api/src/vectors/DuckDBTimestampMillisecondsVector.ts +88 -0
  209. package/vendor/node-api/src/vectors/DuckDBTimestampNanosecondsVector.ts +88 -0
  210. package/vendor/node-api/src/vectors/DuckDBTimestampSecondsVector.ts +88 -0
  211. package/vendor/node-api/src/vectors/DuckDBTimestampTZNanosecondsVector.ts +88 -0
  212. package/vendor/node-api/src/vectors/DuckDBTimestampTZVector.ts +86 -0
  213. package/vendor/node-api/src/vectors/DuckDBTimestampVector.ts +83 -0
  214. package/vendor/node-api/src/vectors/DuckDBTinyIntVector.ts +75 -0
  215. package/vendor/node-api/src/vectors/DuckDBTupleVector.ts +125 -0
  216. package/vendor/node-api/src/vectors/DuckDBUBigIntVector.ts +75 -0
  217. package/vendor/node-api/src/vectors/DuckDBUHugeIntVector.ts +89 -0
  218. package/vendor/node-api/src/vectors/DuckDBUIntegerVector.ts +75 -0
  219. package/vendor/node-api/src/vectors/DuckDBUSmallIntVector.ts +75 -0
  220. package/vendor/node-api/src/vectors/DuckDBUTinyIntVector.ts +75 -0
  221. package/vendor/node-api/src/vectors/DuckDBUUIDVector.ts +89 -0
  222. package/vendor/node-api/src/vectors/DuckDBUnionVector.ts +84 -0
  223. package/vendor/node-api/src/vectors/DuckDBValidity.ts +104 -0
  224. package/vendor/node-api/src/vectors/DuckDBVarCharVector.ts +100 -0
  225. package/vendor/node-api/src/vectors/DuckDBVariantVector.ts +609 -0
  226. package/vendor/node-api/src/vectors/DuckDBVector.ts +33 -0
  227. package/vendor/node-api/src/vectors/createVector.ts +269 -0
  228. package/vendor/node-api/src/vectors/dataAccessors.ts +387 -0
  229. package/vendor/node-api/src/vectors/index.ts +50 -0
  230. package/vendor/node-api/src/vectors/vectorRegistry.ts +24 -0
  231. package/vendor/node-api/src/version.ts +5 -0
@@ -0,0 +1,461 @@
1
+ import {
2
+ DuckDBArrayType,
3
+ DuckDBListType,
4
+ DuckDBMapType,
5
+ DuckDBStructType,
6
+ DuckDBType,
7
+ DuckDBUnionType,
8
+ } from './DuckDBType';
9
+ import { DuckDBTypeId } from './DuckDBTypeId';
10
+ import { DuckDBValueConverter } from './DuckDBValueConverter';
11
+ import { typeForValue } from './typeForValue';
12
+ import {
13
+ DuckDBArrayValue,
14
+ DuckDBBitValue,
15
+ DuckDBBlobValue,
16
+ DuckDBDateValue,
17
+ DuckDBDecimalValue,
18
+ DuckDBGeometryValue,
19
+ DuckDBIntervalValue,
20
+ DuckDBListValue,
21
+ DuckDBMapValue,
22
+ DuckDBStructValue,
23
+ DuckDBTimeTZValue,
24
+ DuckDBTimeNSValue,
25
+ DuckDBTimeValue,
26
+ DuckDBTimestampMillisecondsValue,
27
+ DuckDBTimestampNanosecondsValue,
28
+ DuckDBTimestampSecondsValue,
29
+ DuckDBTimestampTZValue,
30
+ DuckDBTimestampTZNanosecondsValue,
31
+ DuckDBTimestampValue,
32
+ DuckDBTupleValue,
33
+ DuckDBUnionValue,
34
+ DuckDBValue,
35
+ DuckDBVariantValue,
36
+ } from './values';
37
+
38
+ const MIN_DATE_DAYS = -100000000;
39
+ const MAX_DATE_DAYS = 100000000;
40
+ // -8640000000000
41
+ const MIN_DATE_MILLIS = -8640000000000000;
42
+ const MAX_DATE_MILLIS = 8640000000000000;
43
+
44
+ /** Whether a TIMESTAMP_NS or TIMESTAMPTZ_NS value is not +/-infinity. */
45
+ function isFiniteNanos(nanos: bigint): boolean {
46
+ return (
47
+ nanos !== DuckDBTimestampNanosecondsValue.PosInf.nanos &&
48
+ nanos !== DuckDBTimestampNanosecondsValue.NegInf.nanos
49
+ );
50
+ }
51
+
52
+ const MILLS_PER_DAY = 24 * 60 * 60 * 1000;
53
+
54
+ export function unsupportedConverter(_: DuckDBValue, type: DuckDBType): null {
55
+ throw new Error(`Unsupported type: ${type}`);
56
+ }
57
+
58
+ export function nullConverter(_: DuckDBValue): null {
59
+ return null;
60
+ }
61
+
62
+ export function booleanFromValue(value: DuckDBValue): boolean {
63
+ return Boolean(value);
64
+ }
65
+
66
+ export function numberFromValue(value: DuckDBValue): number {
67
+ return Number(value);
68
+ }
69
+
70
+ export function jsonNumberFromValue(value: DuckDBValue): number | string {
71
+ if (Number.isFinite(value)) {
72
+ return Number(value);
73
+ }
74
+ return String(value);
75
+ }
76
+
77
+ export function bigintFromBigIntValue(
78
+ value: DuckDBValue,
79
+ type: DuckDBType
80
+ ): bigint {
81
+ if (typeof value === 'bigint') {
82
+ return value;
83
+ }
84
+ throw new Error(`Expected bigint value for type ${type}`);
85
+ }
86
+
87
+ export function stringFromValue(value: DuckDBValue): string {
88
+ return String(value);
89
+ }
90
+
91
+ export function bytesFromBlobValue(value: DuckDBValue): Uint8Array {
92
+ if (value instanceof DuckDBBlobValue) {
93
+ return value.bytes;
94
+ }
95
+ throw new Error(`Expected DuckDBBlobValue`);
96
+ }
97
+
98
+ export function bytesFromBitValue(value: DuckDBValue): Uint8Array {
99
+ if (value instanceof DuckDBBitValue) {
100
+ return value.data;
101
+ }
102
+ throw new Error(`Expected DuckDBBitValue`);
103
+ }
104
+
105
+ export function bytesFromGeometryValue(value: DuckDBValue): Uint8Array {
106
+ if (value instanceof DuckDBGeometryValue) {
107
+ return value.bytes;
108
+ }
109
+ throw new Error(`Expected DuckDBGeometryValue`);
110
+ }
111
+
112
+ export function dateFromDateValue(value: DuckDBValue): Date {
113
+ if (value instanceof DuckDBDateValue) {
114
+ if (MIN_DATE_DAYS <= value.days && value.days <= MAX_DATE_DAYS) {
115
+ return new Date(value.days * MILLS_PER_DAY);
116
+ }
117
+ throw new Error(`DATE value out of range for JS Date: ${value.days} days`);
118
+ }
119
+ throw new Error(`Expected DuckDBDateValue`);
120
+ }
121
+
122
+ export function bigintFromTimeValue(value: DuckDBValue): bigint {
123
+ if (value instanceof DuckDBTimeValue) {
124
+ return value.micros;
125
+ }
126
+ throw new Error(`Expected DuckDBTimeValue`);
127
+ }
128
+
129
+ export function bigintFromTimeNSValue(value: DuckDBValue): bigint {
130
+ if (value instanceof DuckDBTimeNSValue) {
131
+ return value.nanos;
132
+ }
133
+ throw new Error(`Expected DuckDBTimeNSValue`);
134
+ }
135
+
136
+ export function dateFromTimestampValue(value: DuckDBValue): Date {
137
+ if (value instanceof DuckDBTimestampValue) {
138
+ const millis = value.micros / 1000n;
139
+ if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
140
+ return new Date(Number(millis));
141
+ }
142
+ throw new Error(
143
+ `TIMESTAMP value out of range for JS Date: ${value.micros} micros`
144
+ );
145
+ }
146
+ throw new Error(`Expected DuckDBTimestampValue`);
147
+ }
148
+
149
+ export function dateFromTimestampSecondsValue(value: DuckDBValue): Date {
150
+ if (value instanceof DuckDBTimestampSecondsValue) {
151
+ const millis = value.seconds * 1000n;
152
+ if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
153
+ return new Date(Number(millis));
154
+ }
155
+ throw new Error(
156
+ `TIMESTAMP_S value out of range for JS Date: ${value.seconds} seconds`
157
+ );
158
+ }
159
+ throw new Error(`Expected DuckDBTimestampSecondsValue`);
160
+ }
161
+
162
+ export function dateFromTimestampMillisecondsValue(value: DuckDBValue): Date {
163
+ if (value instanceof DuckDBTimestampMillisecondsValue) {
164
+ const millis = value.millis;
165
+ if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
166
+ return new Date(Number(millis));
167
+ }
168
+ throw new Error(
169
+ `TIMESTAMP_MS value out of range for JS Date: ${value.millis} millis`
170
+ );
171
+ }
172
+ throw new Error(`Expected DuckDBTimestampMillisecondsValue`);
173
+ }
174
+
175
+ export function dateFromTimestampNanosecondsValue(value: DuckDBValue): Date {
176
+ if (value instanceof DuckDBTimestampNanosecondsValue) {
177
+ const millis = value.nanos / 1000000n;
178
+ if (
179
+ isFiniteNanos(value.nanos) &&
180
+ MIN_DATE_MILLIS <= millis &&
181
+ millis <= MAX_DATE_MILLIS
182
+ ) {
183
+ return new Date(Number(millis));
184
+ }
185
+ throw new Error(
186
+ `TIMESTAMP_NS value out of range for JS Date: ${value.nanos} nanos`
187
+ );
188
+ }
189
+ throw new Error(`Expected DuckDBTimestampNanosecondsValue`);
190
+ }
191
+
192
+ export function objectFromTimeTZValue(value: DuckDBValue): {
193
+ micros: bigint;
194
+ offset: number;
195
+ } {
196
+ if (value instanceof DuckDBTimeTZValue) {
197
+ return {
198
+ micros: value.micros,
199
+ offset: value.offset,
200
+ };
201
+ }
202
+ throw new Error(`Expected DuckDBTimeTZValue`);
203
+ }
204
+
205
+ export function dateFromTimestampTZValue(value: DuckDBValue): Date {
206
+ if (value instanceof DuckDBTimestampTZValue) {
207
+ const millis = value.micros / 1000n;
208
+ if (MIN_DATE_MILLIS <= millis && millis <= MAX_DATE_MILLIS) {
209
+ return new Date(Number(millis));
210
+ }
211
+ throw new Error(
212
+ `TIMESTAMPTZ value out of range for JS Date: ${value.micros} micros`
213
+ );
214
+ }
215
+ throw new Error(`Expected DuckDBTimestampTZValue`);
216
+ }
217
+
218
+ export function dateFromTimestampTZNanosecondsValue(value: DuckDBValue): Date {
219
+ if (value instanceof DuckDBTimestampTZNanosecondsValue) {
220
+ const millis = value.nanos / 1000000n;
221
+ if (
222
+ isFiniteNanos(value.nanos) &&
223
+ MIN_DATE_MILLIS <= millis &&
224
+ millis <= MAX_DATE_MILLIS
225
+ ) {
226
+ return new Date(Number(millis));
227
+ }
228
+ throw new Error(
229
+ `TIMESTAMP_TZ_NS value out of range for JS Date: ${value.nanos} nanos`
230
+ );
231
+ }
232
+ throw new Error(`Expected DuckDBTimestampTZNanosecondsValue`);
233
+ }
234
+
235
+ export function objectFromIntervalValue(value: DuckDBValue): {
236
+ months: number;
237
+ days: number;
238
+ micros: bigint;
239
+ } {
240
+ if (value instanceof DuckDBIntervalValue) {
241
+ return {
242
+ months: value.months,
243
+ days: value.days,
244
+ micros: value.micros,
245
+ };
246
+ }
247
+ throw new Error(`Expected DuckDBIntervalValue`);
248
+ }
249
+
250
+ export function jsonObjectFromIntervalValue(value: DuckDBValue): {
251
+ months: number;
252
+ days: number;
253
+ micros: string;
254
+ } {
255
+ if (value instanceof DuckDBIntervalValue) {
256
+ return {
257
+ months: value.months,
258
+ days: value.days,
259
+ micros: String(value.micros),
260
+ };
261
+ }
262
+ throw new Error(`Expected DuckDBIntervalValue`);
263
+ }
264
+
265
+ export function doubleFromDecimalValue(value: DuckDBValue): number {
266
+ if (value instanceof DuckDBDecimalValue) {
267
+ return value.toDouble();
268
+ }
269
+ throw new Error(`Expected DuckDBDecimalValue`);
270
+ }
271
+
272
+ export function arrayFromListValue<T>(
273
+ value: DuckDBValue,
274
+ type: DuckDBType,
275
+ converter: DuckDBValueConverter<T>
276
+ ): (T | null)[] {
277
+ if (value instanceof DuckDBListValue && type instanceof DuckDBListType) {
278
+ return value.items.map((v) => converter(v, type.valueType, converter));
279
+ }
280
+ throw new Error(`Expected DuckDBListValue and DuckDBListType`);
281
+ }
282
+
283
+ export function objectFromStructValue<T>(
284
+ value: DuckDBValue,
285
+ type: DuckDBType,
286
+ converter: DuckDBValueConverter<T>
287
+ ): { [key: string]: T | null } {
288
+ if (value instanceof DuckDBStructValue && type instanceof DuckDBStructType) {
289
+ const result: { [key: string]: T | null } = {};
290
+ for (const key in value.entries) {
291
+ result[key] = converter(
292
+ value.entries[key],
293
+ type.typeForEntry(key),
294
+ converter
295
+ );
296
+ }
297
+ return result;
298
+ }
299
+ throw new Error(`Expected DuckDBStructValue and DuckDBStructType`);
300
+ }
301
+
302
+ export function arrayFromTupleValue<T>(
303
+ value: DuckDBValue,
304
+ type: DuckDBType,
305
+ converter: DuckDBValueConverter<T>
306
+ ): (T | null)[] {
307
+ if (
308
+ value instanceof DuckDBTupleValue &&
309
+ type instanceof DuckDBStructType &&
310
+ type.isTuple
311
+ ) {
312
+ return value.items.map((item, i) =>
313
+ converter(item, type.entryTypes[i], converter)
314
+ );
315
+ }
316
+ throw new Error(`Expected DuckDBTupleValue and tuple DuckDBStructType`);
317
+ }
318
+
319
+ /**
320
+ * Converts a STRUCT value: a tuple (see `DuckDBStructType.isTuple`) to an
321
+ * array of its items, and a named struct to an object keyed by entry name.
322
+ */
323
+ export function objectOrArrayFromStructValue<T>(
324
+ value: DuckDBValue,
325
+ type: DuckDBType,
326
+ converter: DuckDBValueConverter<T>
327
+ ): { [key: string]: T | null } | (T | null)[] {
328
+ if (value instanceof DuckDBTupleValue) {
329
+ return arrayFromTupleValue(value, type, converter);
330
+ }
331
+ return objectFromStructValue(value, type, converter);
332
+ }
333
+
334
+ export function objectArrayFromMapValue<T>(
335
+ value: DuckDBValue,
336
+ type: DuckDBType,
337
+ converter: DuckDBValueConverter<T>
338
+ ): { key: T | null; value: T | null }[] {
339
+ if (value instanceof DuckDBMapValue && type instanceof DuckDBMapType) {
340
+ return value.entries.map((entry) => ({
341
+ key: converter(entry.key, type.keyType, converter),
342
+ value: converter(entry.value, type.valueType, converter),
343
+ }));
344
+ }
345
+ throw new Error(`Expected DuckDBMapValue and DuckDBMapType`);
346
+ }
347
+
348
+ export function arrayFromArrayValue<T>(
349
+ value: DuckDBValue,
350
+ type: DuckDBType,
351
+ converter: DuckDBValueConverter<T>
352
+ ): (T | null)[] {
353
+ if (value instanceof DuckDBArrayValue && type instanceof DuckDBArrayType) {
354
+ return value.items.map((v) => converter(v, type.valueType, converter));
355
+ }
356
+ throw new Error(`Expected DuckDBArrayValue and DuckDBArrayType`);
357
+ }
358
+
359
+ export function objectFromUnionValue<T>(
360
+ value: DuckDBValue,
361
+ type: DuckDBType,
362
+ converter: DuckDBValueConverter<T>
363
+ ): { tag: string; value: T | null } {
364
+ if (value instanceof DuckDBUnionValue && type instanceof DuckDBUnionType) {
365
+ return {
366
+ tag: value.tag,
367
+ value: converter(
368
+ value.value,
369
+ type.memberTypeForTag(value.tag),
370
+ converter
371
+ ),
372
+ };
373
+ }
374
+ throw new Error(`Expected DuckDBUnionValue and DuckDBUnionType`);
375
+ }
376
+
377
+ /**
378
+ * Converter for VARIANT values: unwraps the `DuckDBVariantValue` wrapper
379
+ * and recursively walks the inner value, re-dispatching each scalar leaf
380
+ * through the supplied converter.
381
+ *
382
+ * A walker is needed (rather than just dispatching through the converter)
383
+ * because VARIANT containers are *heterogeneous* — items in a list or
384
+ * fields in a struct can have different types — while
385
+ * `arrayFromListValue` / `objectFromStructValue` / `objectArrayFromMapValue`
386
+ * assume a homogeneous element type pulled from the enclosing
387
+ * `DuckDBListType` / `DuckDBStructType` / `DuckDBMapType`. The walker
388
+ * emits the same output shape those converters do, and prefers the
389
+ * `DuckDBVariantValue.type` recorded by the decoder over `typeForValue`
390
+ * inference whenever a wrapper is encountered.
391
+ */
392
+ export function fromVariantValue<T>(
393
+ value: DuckDBValue,
394
+ _type: DuckDBType,
395
+ converter: DuckDBValueConverter<T>
396
+ ): T | null {
397
+ if (!(value instanceof DuckDBVariantValue)) {
398
+ throw new Error(`Expected DuckDBVariantValue`);
399
+ }
400
+ return convertVariantInner(value.value, converter, value.type);
401
+ }
402
+
403
+ function convertVariantInner<T>(
404
+ value: DuckDBValue,
405
+ converter: DuckDBValueConverter<T>,
406
+ typeHint?: DuckDBType
407
+ ): T | null {
408
+ if (value === null) {
409
+ return null;
410
+ }
411
+ if (value instanceof DuckDBVariantValue) {
412
+ // Variant-of-variant (or a wrapped child inside a LIST(VARIANT)).
413
+ // Prefer the wrapper's exact type as the hint for further walking.
414
+ return convertVariantInner(value.value, converter, value.type ?? typeHint);
415
+ }
416
+ if (value instanceof DuckDBListValue || value instanceof DuckDBArrayValue) {
417
+ return value.items.map((item) =>
418
+ convertVariantInner(item, converter)
419
+ ) as unknown as T;
420
+ }
421
+ if (value instanceof DuckDBStructValue) {
422
+ const result: { [key: string]: T | null } = {};
423
+ for (const key in value.entries) {
424
+ result[key] = convertVariantInner(value.entries[key], converter);
425
+ }
426
+ return result as unknown as T;
427
+ }
428
+ if (value instanceof DuckDBTupleValue) {
429
+ return value.items.map((item) =>
430
+ convertVariantInner(item, converter)
431
+ ) as unknown as T;
432
+ }
433
+ if (value instanceof DuckDBMapValue) {
434
+ return value.entries.map((entry) => ({
435
+ key: convertVariantInner(entry.key, converter),
436
+ value: convertVariantInner(entry.value, converter),
437
+ })) as unknown as T;
438
+ }
439
+ if (value instanceof DuckDBUnionValue) {
440
+ return {
441
+ tag: value.tag,
442
+ value: convertVariantInner(value.value, converter),
443
+ } as unknown as T;
444
+ }
445
+ // Scalar (or non-recursable rich value like DECIMAL, BLOB, DATE, etc.):
446
+ // dispatch through the regular converter. Use `typeHint` (carried in
447
+ // from a wrapper) for type fidelity when available; fall back to
448
+ // `typeForValue` otherwise.
449
+ const inferredType = typeHint ?? typeForValue(value);
450
+ // `typeForValue` infers BIGINT for any JS integer number outside INT32
451
+ // range (e.g. a UINT32 VARIANT payload of 4_294_967_295). The BIGINT
452
+ // converters expect a `bigint`, not a `number`, and would otherwise
453
+ // throw. Coerce to bigint so the dispatch lands on a compatible reader.
454
+ if (
455
+ typeof value === 'number' &&
456
+ inferredType.typeId === DuckDBTypeId.BIGINT
457
+ ) {
458
+ return converter(BigInt(value), inferredType, converter);
459
+ }
460
+ return converter(value, inferredType, converter);
461
+ }
@@ -0,0 +1 @@
1
+ export * from './vectors';
@@ -0,0 +1,11 @@
1
+ export type JS =
2
+ | null
3
+ | boolean
4
+ | number
5
+ | bigint
6
+ | string
7
+ | Uint8Array
8
+ | Date
9
+ | JS[]
10
+ | { [key: string]: JS };
11
+
@@ -0,0 +1,85 @@
1
+ import { createDuckDBValueConverter } from './createDuckDBValueConverter';
2
+ import { DuckDBTypeId } from './DuckDBTypeId';
3
+ import { DuckDBValueConverterFor } from './DuckDBValueConverter';
4
+ import {
5
+ arrayFromArrayValue,
6
+ arrayFromListValue,
7
+ bigintFromBigIntValue,
8
+ bigintFromTimeNSValue,
9
+ bigintFromTimeValue,
10
+ booleanFromValue,
11
+ bytesFromBitValue,
12
+ bytesFromBlobValue,
13
+ bytesFromGeometryValue,
14
+ dateFromDateValue,
15
+ dateFromTimestampMillisecondsValue,
16
+ dateFromTimestampNanosecondsValue,
17
+ dateFromTimestampSecondsValue,
18
+ dateFromTimestampTZValue,
19
+ dateFromTimestampTZNanosecondsValue,
20
+ dateFromTimestampValue,
21
+ doubleFromDecimalValue,
22
+ fromVariantValue,
23
+ nullConverter,
24
+ numberFromValue,
25
+ objectArrayFromMapValue,
26
+ objectFromIntervalValue,
27
+ objectOrArrayFromStructValue,
28
+ objectFromTimeTZValue,
29
+ objectFromUnionValue,
30
+ stringFromValue,
31
+ unsupportedConverter,
32
+ } from './DuckDBValueConverters';
33
+ import { JS } from './JS';
34
+ import { JSTypeForTypeId } from './JSTypeForTypeId';
35
+
36
+ const JSConvertersByTypeId: {
37
+ [Id in DuckDBTypeId]: DuckDBValueConverterFor<JSTypeForTypeId[Id], JS>;
38
+ } = {
39
+ [DuckDBTypeId.INVALID]: unsupportedConverter,
40
+ [DuckDBTypeId.BOOLEAN]: booleanFromValue,
41
+ [DuckDBTypeId.TINYINT]: numberFromValue,
42
+ [DuckDBTypeId.SMALLINT]: numberFromValue,
43
+ [DuckDBTypeId.INTEGER]: numberFromValue,
44
+ [DuckDBTypeId.BIGINT]: bigintFromBigIntValue,
45
+ [DuckDBTypeId.UTINYINT]: numberFromValue,
46
+ [DuckDBTypeId.USMALLINT]: numberFromValue,
47
+ [DuckDBTypeId.UINTEGER]: numberFromValue,
48
+ [DuckDBTypeId.UBIGINT]: bigintFromBigIntValue,
49
+ [DuckDBTypeId.FLOAT]: numberFromValue,
50
+ [DuckDBTypeId.DOUBLE]: numberFromValue,
51
+ [DuckDBTypeId.TIMESTAMP]: dateFromTimestampValue,
52
+ [DuckDBTypeId.DATE]: dateFromDateValue,
53
+ [DuckDBTypeId.TIME]: bigintFromTimeValue,
54
+ [DuckDBTypeId.INTERVAL]: objectFromIntervalValue,
55
+ [DuckDBTypeId.HUGEINT]: bigintFromBigIntValue,
56
+ [DuckDBTypeId.UHUGEINT]: bigintFromBigIntValue,
57
+ [DuckDBTypeId.VARCHAR]: stringFromValue,
58
+ [DuckDBTypeId.BLOB]: bytesFromBlobValue,
59
+ [DuckDBTypeId.DECIMAL]: doubleFromDecimalValue,
60
+ [DuckDBTypeId.TIMESTAMP_S]: dateFromTimestampSecondsValue,
61
+ [DuckDBTypeId.TIMESTAMP_MS]: dateFromTimestampMillisecondsValue,
62
+ [DuckDBTypeId.TIMESTAMP_NS]: dateFromTimestampNanosecondsValue,
63
+ [DuckDBTypeId.ENUM]: stringFromValue,
64
+ [DuckDBTypeId.LIST]: arrayFromListValue,
65
+ [DuckDBTypeId.STRUCT]: objectOrArrayFromStructValue,
66
+ [DuckDBTypeId.MAP]: objectArrayFromMapValue,
67
+ [DuckDBTypeId.ARRAY]: arrayFromArrayValue,
68
+ [DuckDBTypeId.UUID]: stringFromValue,
69
+ [DuckDBTypeId.UNION]: objectFromUnionValue,
70
+ [DuckDBTypeId.BIT]: bytesFromBitValue,
71
+ [DuckDBTypeId.TIME_TZ]: objectFromTimeTZValue,
72
+ [DuckDBTypeId.TIMESTAMP_TZ]: dateFromTimestampTZValue,
73
+ [DuckDBTypeId.ANY]: unsupportedConverter,
74
+ [DuckDBTypeId.BIGNUM]: bigintFromBigIntValue,
75
+ [DuckDBTypeId.SQLNULL]: nullConverter,
76
+ [DuckDBTypeId.STRING_LITERAL]: unsupportedConverter,
77
+ [DuckDBTypeId.INTEGER_LITERAL]: unsupportedConverter,
78
+ [DuckDBTypeId.TIME_NS]: bigintFromTimeNSValue,
79
+ [DuckDBTypeId.GEOMETRY]: bytesFromGeometryValue,
80
+ [DuckDBTypeId.VARIANT]: fromVariantValue,
81
+ [DuckDBTypeId.TIMESTAMP_TZ_NS]: dateFromTimestampTZNanosecondsValue,
82
+ };
83
+
84
+ export const JSDuckDBValueConverter =
85
+ createDuckDBValueConverter<JS>(JSConvertersByTypeId);
@@ -0,0 +1,101 @@
1
+ import type { DuckDBType } from './DuckDBType';
2
+ import { DuckDBTypeId } from './DuckDBTypeId';
3
+ import type { JS } from './JS';
4
+ import type { DuckDBVariantValue } from './values';
5
+
6
+ /**
7
+ * The JS type accepted by `jsToDuckDBValue` for each DuckDB type id: the write
8
+ * counterpart of `JSTypeForTypeId`.
9
+ *
10
+ * Everything `JSTypeForTypeId` produces, this table accepts — see the
11
+ * round-trip assertion in `test/js-writes.test.ts` — but not the reverse.
12
+ * Writes are deliberately wider where a second spelling is unambiguous: the
13
+ * 64-bit and wider integers take `number` as well as `bigint`, and DECIMAL
14
+ * takes either a double or a raw scaled `bigint`. VARIANT is the one
15
+ * exception in the other direction; see below.
16
+ *
17
+ * NULL is not in the table: `createToDuckDBValueConverter` maps `null` to
18
+ * `null` for every type, so a nullable value is `JSInputTypeForTypeId[Id] |
19
+ * null`.
20
+ *
21
+ * Type ids that cannot be written map to `never`: `INVALID`, `ANY`,
22
+ * `STRING_LITERAL` and `INTEGER_LITERAL`, none of which can appear in a result
23
+ * either.
24
+ *
25
+ * VARIANT is the one place the write side is *narrower* than the read side. A
26
+ * VARIANT holds its own type, so writing one means saying what that type is.
27
+ * A `DuckDBVariantValue` carries it — either explicitly, as
28
+ * `variantValue(structValue({k: 'n'}), STRUCT({k: VARCHAR}))`, or inferred by
29
+ * `typeForValue` from a wrapped inner value — and a bare boolean, number,
30
+ * bigint or string is unambiguous enough to infer on its own. A bare `Date`,
31
+ * `Uint8Array`, array or object is not: each maps to several DuckDB types, so
32
+ * `typeForValue` yields ANY and the write fails. Wrap those to say which.
33
+ *
34
+ * Reading a VARIANT discards that type, which is why the round-trip
35
+ * containment the other ids satisfy does not hold here: the read table gives
36
+ * `JS | null`, and JS alone is not enough to write back.
37
+ *
38
+ * This interface is exhaustive over `DuckDBTypeId`, and is the annotation
39
+ * source for the converter map in `jsToDuckDBValue`; adding a type id without
40
+ * adding it here is a compile error.
41
+ */
42
+ export interface JSInputTypeForTypeId {
43
+ [DuckDBTypeId.INVALID]: never;
44
+ [DuckDBTypeId.BOOLEAN]: boolean;
45
+ [DuckDBTypeId.TINYINT]: number;
46
+ [DuckDBTypeId.SMALLINT]: number;
47
+ [DuckDBTypeId.INTEGER]: number;
48
+ [DuckDBTypeId.BIGINT]: bigint | number;
49
+ [DuckDBTypeId.UTINYINT]: number;
50
+ [DuckDBTypeId.USMALLINT]: number;
51
+ [DuckDBTypeId.UINTEGER]: number;
52
+ [DuckDBTypeId.UBIGINT]: bigint | number;
53
+ [DuckDBTypeId.FLOAT]: number;
54
+ [DuckDBTypeId.DOUBLE]: number;
55
+ [DuckDBTypeId.TIMESTAMP]: Date;
56
+ [DuckDBTypeId.DATE]: Date;
57
+ [DuckDBTypeId.TIME]: bigint;
58
+ [DuckDBTypeId.INTERVAL]: { months: number; days: number; micros: bigint };
59
+ [DuckDBTypeId.HUGEINT]: bigint | number;
60
+ [DuckDBTypeId.UHUGEINT]: bigint | number;
61
+ [DuckDBTypeId.VARCHAR]: string;
62
+ [DuckDBTypeId.BLOB]: Uint8Array;
63
+ [DuckDBTypeId.DECIMAL]: number | bigint;
64
+ [DuckDBTypeId.TIMESTAMP_S]: Date;
65
+ [DuckDBTypeId.TIMESTAMP_MS]: Date;
66
+ [DuckDBTypeId.TIMESTAMP_NS]: Date;
67
+ [DuckDBTypeId.ENUM]: string;
68
+ [DuckDBTypeId.LIST]: readonly (JS | null)[];
69
+ [DuckDBTypeId.STRUCT]:
70
+ | Readonly<Record<string, JS | null>>
71
+ | readonly (JS | null)[];
72
+ [DuckDBTypeId.MAP]: readonly { key: JS | null; value: JS | null }[];
73
+ [DuckDBTypeId.ARRAY]: readonly (JS | null)[];
74
+ [DuckDBTypeId.UUID]: string;
75
+ [DuckDBTypeId.UNION]: { tag: string; value: JS | null };
76
+ [DuckDBTypeId.BIT]: Uint8Array;
77
+ [DuckDBTypeId.TIME_TZ]: { micros: bigint; offset: number };
78
+ [DuckDBTypeId.TIMESTAMP_TZ]: Date;
79
+ [DuckDBTypeId.ANY]: never;
80
+ [DuckDBTypeId.BIGNUM]: bigint | number;
81
+ [DuckDBTypeId.SQLNULL]: null;
82
+ [DuckDBTypeId.STRING_LITERAL]: never;
83
+ [DuckDBTypeId.INTEGER_LITERAL]: never;
84
+ [DuckDBTypeId.TIME_NS]: bigint;
85
+ [DuckDBTypeId.GEOMETRY]: Uint8Array;
86
+ [DuckDBTypeId.VARIANT]:
87
+ | DuckDBVariantValue
88
+ | boolean
89
+ | number
90
+ | bigint
91
+ | string;
92
+ [DuckDBTypeId.TIMESTAMP_TZ_NS]: Date;
93
+ }
94
+
95
+ /**
96
+ * The JS type accepted by `jsToDuckDBValue` for a given `DuckDBType`.
97
+ *
98
+ * Excludes NULL; use `JSInputTypeFor<T> | null` for a nullable value.
99
+ */
100
+ export type JSInputTypeFor<T extends DuckDBType> =
101
+ JSInputTypeForTypeId[T['typeId']];