@haybarn/node-api 1.5.6-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
package/lib/DuckDBType.js CHANGED
@@ -1,930 +1,17 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DuckDBStructType = exports.DuckDBListType = exports.DuckDBEnumType = exports.TIMESTAMP_NS = exports.DuckDBTimestampNanosecondsType = exports.TIMESTAMP_MS = exports.DuckDBTimestampMillisecondsType = exports.TIMESTAMP_S = exports.DuckDBTimestampSecondsType = exports.DuckDBDecimalType = exports.BLOB = exports.DuckDBBlobType = exports.VARCHAR = exports.DuckDBVarCharType = exports.UHUGEINT = exports.DuckDBUHugeIntType = exports.HUGEINT = exports.DuckDBHugeIntType = exports.INTERVAL = exports.DuckDBIntervalType = exports.TIME = exports.DuckDBTimeType = exports.DATE = exports.DuckDBDateType = exports.DuckDBTimestampMicrosecondsType = exports.TIMESTAMP = exports.DuckDBTimestampType = exports.DOUBLE = exports.DuckDBDoubleType = exports.FLOAT = exports.DuckDBFloatType = exports.UBIGINT = exports.DuckDBUBigIntType = exports.UINTEGER = exports.DuckDBUIntegerType = exports.USMALLINT = exports.DuckDBUSmallIntType = exports.UTINYINT = exports.DuckDBUTinyIntType = exports.BIGINT = exports.DuckDBBigIntType = exports.INTEGER = exports.DuckDBIntegerType = exports.SMALLINT = exports.DuckDBSmallIntType = exports.TINYINT = exports.DuckDBTinyIntType = exports.BOOLEAN = exports.DuckDBBooleanType = exports.BaseDuckDBType = void 0;
7
- exports.TIME_NS = exports.DuckDBTimeNSType = exports.INTEGER_LITERAL = exports.DuckDBIntegerLiteralType = exports.STRING_LITERAL = exports.DuckDBStringLiteralType = exports.SQLNULL = exports.DuckDBSQLNullType = exports.BIGNUM = exports.DuckDBBigNumType = exports.ANY = exports.DuckDBAnyType = exports.TIMESTAMPTZ = exports.DuckDBTimestampTZType = exports.TIMETZ = exports.DuckDBTimeTZType = exports.BIT = exports.DuckDBBitType = exports.DuckDBUnionType = exports.UUID = exports.DuckDBUUIDType = exports.DuckDBArrayType = exports.DuckDBMapType = void 0;
8
- exports.DECIMAL = DECIMAL;
9
- exports.ENUM8 = ENUM8;
10
- exports.ENUM16 = ENUM16;
11
- exports.ENUM32 = ENUM32;
12
- exports.ENUM = ENUM;
13
- exports.LIST = LIST;
14
- exports.STRUCT = STRUCT;
15
- exports.MAP = MAP;
16
- exports.ARRAY = ARRAY;
17
- exports.UNION = UNION;
18
- const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
19
- const DuckDBLogicalType_1 = require("./DuckDBLogicalType");
20
- const DuckDBTypeId_1 = require("./DuckDBTypeId");
21
- const sql_1 = require("./sql");
22
- const values_1 = require("./values");
23
- class BaseDuckDBType {
24
- typeId;
25
- alias;
26
- constructor(typeId, alias) {
27
- this.typeId = typeId;
28
- this.alias = alias;
29
- }
30
- toString() {
31
- return DuckDBTypeId_1.DuckDBTypeId[this.typeId];
32
- }
33
- toLogicalType() {
34
- const logicalType = DuckDBLogicalType_1.DuckDBLogicalType.create(node_bindings_1.default.create_logical_type(this.typeId));
35
- if (this.alias) {
36
- logicalType.alias = this.alias;
37
- }
38
- return logicalType;
39
- }
40
- toJson() {
41
- return {
42
- typeId: this.typeId,
43
- ...(this.alias ? { alias: this.alias } : {}),
44
- };
45
- }
46
- }
47
- exports.BaseDuckDBType = BaseDuckDBType;
48
- class DuckDBBooleanType extends BaseDuckDBType {
49
- constructor(alias) {
50
- super(DuckDBTypeId_1.DuckDBTypeId.BOOLEAN, alias);
51
- }
52
- static instance = new DuckDBBooleanType();
53
- static create(alias) {
54
- return alias ? new DuckDBBooleanType(alias) : DuckDBBooleanType.instance;
55
- }
56
- }
57
- exports.DuckDBBooleanType = DuckDBBooleanType;
58
- exports.BOOLEAN = DuckDBBooleanType.instance;
59
- class DuckDBTinyIntType extends BaseDuckDBType {
60
- constructor(alias) {
61
- super(DuckDBTypeId_1.DuckDBTypeId.TINYINT, alias);
62
- }
63
- static instance = new DuckDBTinyIntType();
64
- static create(alias) {
65
- return alias ? new DuckDBTinyIntType(alias) : DuckDBTinyIntType.instance;
66
- }
67
- static Max = 2 ** 7 - 1;
68
- static Min = -(2 ** 7);
69
- get max() {
70
- return DuckDBTinyIntType.Max;
71
- }
72
- get min() {
73
- return DuckDBTinyIntType.Min;
74
- }
75
- }
76
- exports.DuckDBTinyIntType = DuckDBTinyIntType;
77
- exports.TINYINT = DuckDBTinyIntType.instance;
78
- class DuckDBSmallIntType extends BaseDuckDBType {
79
- constructor(alias) {
80
- super(DuckDBTypeId_1.DuckDBTypeId.SMALLINT, alias);
81
- }
82
- static instance = new DuckDBSmallIntType();
83
- static create(alias) {
84
- return alias ? new DuckDBSmallIntType(alias) : DuckDBSmallIntType.instance;
85
- }
86
- static Max = 2 ** 15 - 1;
87
- static Min = -(2 ** 15);
88
- get max() {
89
- return DuckDBSmallIntType.Max;
90
- }
91
- get min() {
92
- return DuckDBSmallIntType.Min;
93
- }
94
- }
95
- exports.DuckDBSmallIntType = DuckDBSmallIntType;
96
- exports.SMALLINT = DuckDBSmallIntType.instance;
97
- class DuckDBIntegerType extends BaseDuckDBType {
98
- constructor(alias) {
99
- super(DuckDBTypeId_1.DuckDBTypeId.INTEGER, alias);
100
- }
101
- static instance = new DuckDBIntegerType();
102
- static create(alias) {
103
- return alias ? new DuckDBIntegerType(alias) : DuckDBIntegerType.instance;
104
- }
105
- static Max = 2 ** 31 - 1;
106
- static Min = -(2 ** 31);
107
- get max() {
108
- return DuckDBIntegerType.Max;
109
- }
110
- get min() {
111
- return DuckDBIntegerType.Min;
112
- }
113
- }
114
- exports.DuckDBIntegerType = DuckDBIntegerType;
115
- exports.INTEGER = DuckDBIntegerType.instance;
116
- class DuckDBBigIntType extends BaseDuckDBType {
117
- constructor(alias) {
118
- super(DuckDBTypeId_1.DuckDBTypeId.BIGINT, alias);
119
- }
120
- static instance = new DuckDBBigIntType();
121
- static create(alias) {
122
- return alias ? new DuckDBBigIntType(alias) : DuckDBBigIntType.instance;
123
- }
124
- static Max = 2n ** 63n - 1n;
125
- static Min = -(2n ** 63n);
126
- get max() {
127
- return DuckDBBigIntType.Max;
128
- }
129
- get min() {
130
- return DuckDBBigIntType.Min;
131
- }
132
- }
133
- exports.DuckDBBigIntType = DuckDBBigIntType;
134
- exports.BIGINT = DuckDBBigIntType.instance;
135
- class DuckDBUTinyIntType extends BaseDuckDBType {
136
- constructor(alias) {
137
- super(DuckDBTypeId_1.DuckDBTypeId.UTINYINT, alias);
138
- }
139
- static instance = new DuckDBUTinyIntType();
140
- static create(alias) {
141
- return alias ? new DuckDBUTinyIntType(alias) : DuckDBUTinyIntType.instance;
142
- }
143
- static Max = 2 ** 8 - 1;
144
- static Min = 0;
145
- get max() {
146
- return DuckDBUTinyIntType.Max;
147
- }
148
- get min() {
149
- return DuckDBUTinyIntType.Min;
150
- }
151
- }
152
- exports.DuckDBUTinyIntType = DuckDBUTinyIntType;
153
- exports.UTINYINT = DuckDBUTinyIntType.instance;
154
- class DuckDBUSmallIntType extends BaseDuckDBType {
155
- constructor(alias) {
156
- super(DuckDBTypeId_1.DuckDBTypeId.USMALLINT, alias);
157
- }
158
- static instance = new DuckDBUSmallIntType();
159
- static create(alias) {
160
- return alias
161
- ? new DuckDBUSmallIntType(alias)
162
- : DuckDBUSmallIntType.instance;
163
- }
164
- static Max = 2 ** 16 - 1;
165
- static Min = 0;
166
- get max() {
167
- return DuckDBUSmallIntType.Max;
168
- }
169
- get min() {
170
- return DuckDBUSmallIntType.Min;
171
- }
172
- }
173
- exports.DuckDBUSmallIntType = DuckDBUSmallIntType;
174
- exports.USMALLINT = DuckDBUSmallIntType.instance;
175
- class DuckDBUIntegerType extends BaseDuckDBType {
176
- constructor(alias) {
177
- super(DuckDBTypeId_1.DuckDBTypeId.UINTEGER, alias);
178
- }
179
- static instance = new DuckDBUIntegerType();
180
- static create(alias) {
181
- return alias ? new DuckDBUIntegerType(alias) : DuckDBUIntegerType.instance;
182
- }
183
- static Max = 2 ** 32 - 1;
184
- static Min = 0;
185
- get max() {
186
- return DuckDBUIntegerType.Max;
187
- }
188
- get min() {
189
- return DuckDBUIntegerType.Min;
190
- }
191
- }
192
- exports.DuckDBUIntegerType = DuckDBUIntegerType;
193
- exports.UINTEGER = DuckDBUIntegerType.instance;
194
- class DuckDBUBigIntType extends BaseDuckDBType {
195
- constructor(alias) {
196
- super(DuckDBTypeId_1.DuckDBTypeId.UBIGINT, alias);
197
- }
198
- static instance = new DuckDBUBigIntType();
199
- static create(alias) {
200
- return alias ? new DuckDBUBigIntType(alias) : DuckDBUBigIntType.instance;
201
- }
202
- static Max = 2n ** 64n - 1n;
203
- static Min = 0n;
204
- get max() {
205
- return DuckDBUBigIntType.Max;
206
- }
207
- get min() {
208
- return DuckDBUBigIntType.Min;
209
- }
210
- }
211
- exports.DuckDBUBigIntType = DuckDBUBigIntType;
212
- exports.UBIGINT = DuckDBUBigIntType.instance;
213
- class DuckDBFloatType extends BaseDuckDBType {
214
- constructor(alias) {
215
- super(DuckDBTypeId_1.DuckDBTypeId.FLOAT, alias);
216
- }
217
- static instance = new DuckDBFloatType();
218
- static create(alias) {
219
- return alias ? new DuckDBFloatType(alias) : DuckDBFloatType.instance;
220
- }
221
- static Max = Math.fround(3.4028235e38);
222
- static Min = Math.fround(-3.4028235e38);
223
- get max() {
224
- return DuckDBFloatType.Max;
225
- }
226
- get min() {
227
- return DuckDBFloatType.Min;
228
- }
229
- }
230
- exports.DuckDBFloatType = DuckDBFloatType;
231
- exports.FLOAT = DuckDBFloatType.instance;
232
- class DuckDBDoubleType extends BaseDuckDBType {
233
- constructor(alias) {
234
- super(DuckDBTypeId_1.DuckDBTypeId.DOUBLE, alias);
235
- }
236
- static instance = new DuckDBDoubleType();
237
- static create(alias) {
238
- return alias ? new DuckDBDoubleType(alias) : DuckDBDoubleType.instance;
239
- }
240
- static Max = Number.MAX_VALUE;
241
- static Min = -Number.MAX_VALUE;
242
- get max() {
243
- return DuckDBDoubleType.Max;
244
- }
245
- get min() {
246
- return DuckDBDoubleType.Min;
247
- }
248
- }
249
- exports.DuckDBDoubleType = DuckDBDoubleType;
250
- exports.DOUBLE = DuckDBDoubleType.instance;
251
- class DuckDBTimestampType extends BaseDuckDBType {
252
- constructor(alias) {
253
- super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP, alias);
254
- }
255
- static instance = new DuckDBTimestampType();
256
- static create(alias) {
257
- return alias
258
- ? new DuckDBTimestampType(alias)
259
- : DuckDBTimestampType.instance;
260
- }
261
- get epoch() {
262
- return values_1.DuckDBTimestampValue.Epoch;
263
- }
264
- get max() {
265
- return values_1.DuckDBTimestampValue.Max;
266
- }
267
- get min() {
268
- return values_1.DuckDBTimestampValue.Min;
269
- }
270
- get posInf() {
271
- return values_1.DuckDBTimestampValue.PosInf;
272
- }
273
- get negInf() {
274
- return values_1.DuckDBTimestampValue.NegInf;
275
- }
276
- }
277
- exports.DuckDBTimestampType = DuckDBTimestampType;
278
- exports.TIMESTAMP = DuckDBTimestampType.instance;
279
- exports.DuckDBTimestampMicrosecondsType = DuckDBTimestampType;
280
- class DuckDBDateType extends BaseDuckDBType {
281
- constructor(alias) {
282
- super(DuckDBTypeId_1.DuckDBTypeId.DATE, alias);
283
- }
284
- static instance = new DuckDBDateType();
285
- static create(alias) {
286
- return alias ? new DuckDBDateType(alias) : DuckDBDateType.instance;
287
- }
288
- get epoch() {
289
- return values_1.DuckDBDateValue.Epoch;
290
- }
291
- get max() {
292
- return values_1.DuckDBDateValue.Max;
293
- }
294
- get min() {
295
- return values_1.DuckDBDateValue.Min;
296
- }
297
- get posInf() {
298
- return values_1.DuckDBDateValue.PosInf;
299
- }
300
- get negInf() {
301
- return values_1.DuckDBDateValue.NegInf;
302
- }
303
- }
304
- exports.DuckDBDateType = DuckDBDateType;
305
- exports.DATE = DuckDBDateType.instance;
306
- class DuckDBTimeType extends BaseDuckDBType {
307
- constructor(alias) {
308
- super(DuckDBTypeId_1.DuckDBTypeId.TIME, alias);
309
- }
310
- static instance = new DuckDBTimeType();
311
- static create(alias) {
312
- return alias ? new DuckDBTimeType(alias) : DuckDBTimeType.instance;
313
- }
314
- get max() {
315
- return values_1.DuckDBTimeValue.Max;
316
- }
317
- get min() {
318
- return values_1.DuckDBTimeValue.Min;
319
- }
320
- }
321
- exports.DuckDBTimeType = DuckDBTimeType;
322
- exports.TIME = DuckDBTimeType.instance;
323
- class DuckDBIntervalType extends BaseDuckDBType {
324
- constructor(alias) {
325
- super(DuckDBTypeId_1.DuckDBTypeId.INTERVAL, alias);
326
- }
327
- static instance = new DuckDBIntervalType();
328
- static create(alias) {
329
- return alias ? new DuckDBIntervalType(alias) : DuckDBIntervalType.instance;
330
- }
331
- }
332
- exports.DuckDBIntervalType = DuckDBIntervalType;
333
- exports.INTERVAL = DuckDBIntervalType.instance;
334
- class DuckDBHugeIntType extends BaseDuckDBType {
335
- constructor(alias) {
336
- super(DuckDBTypeId_1.DuckDBTypeId.HUGEINT, alias);
337
- }
338
- static instance = new DuckDBHugeIntType();
339
- static create(alias) {
340
- return alias ? new DuckDBHugeIntType(alias) : DuckDBHugeIntType.instance;
341
- }
342
- static Max = 2n ** 127n - 1n;
343
- static Min = -(2n ** 127n);
344
- get max() {
345
- return DuckDBHugeIntType.Max;
346
- }
347
- get min() {
348
- return DuckDBHugeIntType.Min;
349
- }
350
- }
351
- exports.DuckDBHugeIntType = DuckDBHugeIntType;
352
- exports.HUGEINT = DuckDBHugeIntType.instance;
353
- class DuckDBUHugeIntType extends BaseDuckDBType {
354
- constructor(alias) {
355
- super(DuckDBTypeId_1.DuckDBTypeId.UHUGEINT, alias);
356
- }
357
- static instance = new DuckDBUHugeIntType();
358
- static create(alias) {
359
- return alias ? new DuckDBUHugeIntType(alias) : DuckDBUHugeIntType.instance;
360
- }
361
- static Max = 2n ** 128n - 1n;
362
- static Min = 0n;
363
- get max() {
364
- return DuckDBUHugeIntType.Max;
365
- }
366
- get min() {
367
- return DuckDBUHugeIntType.Min;
368
- }
369
- }
370
- exports.DuckDBUHugeIntType = DuckDBUHugeIntType;
371
- exports.UHUGEINT = DuckDBUHugeIntType.instance;
372
- class DuckDBVarCharType extends BaseDuckDBType {
373
- constructor(alias) {
374
- super(DuckDBTypeId_1.DuckDBTypeId.VARCHAR, alias);
375
- }
376
- static instance = new DuckDBVarCharType();
377
- static create(alias) {
378
- return alias ? new DuckDBVarCharType(alias) : DuckDBVarCharType.instance;
379
- }
380
- }
381
- exports.DuckDBVarCharType = DuckDBVarCharType;
382
- exports.VARCHAR = DuckDBVarCharType.instance;
383
- class DuckDBBlobType extends BaseDuckDBType {
384
- constructor(alias) {
385
- super(DuckDBTypeId_1.DuckDBTypeId.BLOB, alias);
386
- }
387
- static instance = new DuckDBBlobType();
388
- static create(alias) {
389
- return alias ? new DuckDBBlobType(alias) : DuckDBBlobType.instance;
390
- }
391
- }
392
- exports.DuckDBBlobType = DuckDBBlobType;
393
- exports.BLOB = DuckDBBlobType.instance;
394
- class DuckDBDecimalType extends BaseDuckDBType {
395
- width;
396
- scale;
397
- constructor(width, scale, alias) {
398
- super(DuckDBTypeId_1.DuckDBTypeId.DECIMAL, alias);
399
- this.width = width;
400
- this.scale = scale;
401
- }
402
- toString() {
403
- return `DECIMAL(${this.width},${this.scale})`;
404
- }
405
- toLogicalType() {
406
- const logicalType = DuckDBLogicalType_1.DuckDBLogicalType.createDecimal(this.width, this.scale);
407
- if (this.alias) {
408
- logicalType.alias = this.alias;
409
- }
410
- return logicalType;
411
- }
412
- toJson() {
413
- return {
414
- typeId: this.typeId,
415
- width: this.width,
416
- scale: this.scale,
417
- ...(this.alias ? { alias: this.alias } : {}),
418
- };
419
- }
420
- static default = new DuckDBDecimalType(18, 3);
421
- }
422
- exports.DuckDBDecimalType = DuckDBDecimalType;
423
- function DECIMAL(width, scale, alias) {
424
- if (width === undefined) {
425
- return DuckDBDecimalType.default;
426
- }
427
- if (scale === undefined) {
428
- return new DuckDBDecimalType(width, 0);
429
- }
430
- return new DuckDBDecimalType(width, scale, alias);
431
- }
432
- class DuckDBTimestampSecondsType extends BaseDuckDBType {
433
- constructor(alias) {
434
- super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S, alias);
435
- }
436
- static instance = new DuckDBTimestampSecondsType();
437
- static create(alias) {
438
- return alias
439
- ? new DuckDBTimestampSecondsType(alias)
440
- : DuckDBTimestampSecondsType.instance;
441
- }
442
- get epoch() {
443
- return values_1.DuckDBTimestampSecondsValue.Epoch;
444
- }
445
- get max() {
446
- return values_1.DuckDBTimestampSecondsValue.Max;
447
- }
448
- get min() {
449
- return values_1.DuckDBTimestampSecondsValue.Min;
450
- }
451
- get posInf() {
452
- return values_1.DuckDBTimestampSecondsValue.PosInf;
453
- }
454
- get negInf() {
455
- return values_1.DuckDBTimestampSecondsValue.NegInf;
456
- }
457
- }
458
- exports.DuckDBTimestampSecondsType = DuckDBTimestampSecondsType;
459
- exports.TIMESTAMP_S = DuckDBTimestampSecondsType.instance;
460
- class DuckDBTimestampMillisecondsType extends BaseDuckDBType {
461
- constructor(alias) {
462
- super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS, alias);
463
- }
464
- static instance = new DuckDBTimestampMillisecondsType();
465
- static create(alias) {
466
- return alias
467
- ? new DuckDBTimestampMillisecondsType(alias)
468
- : DuckDBTimestampMillisecondsType.instance;
469
- }
470
- get epoch() {
471
- return values_1.DuckDBTimestampMillisecondsValue.Epoch;
472
- }
473
- get max() {
474
- return values_1.DuckDBTimestampMillisecondsValue.Max;
475
- }
476
- get min() {
477
- return values_1.DuckDBTimestampMillisecondsValue.Min;
478
- }
479
- get posInf() {
480
- return values_1.DuckDBTimestampMillisecondsValue.PosInf;
481
- }
482
- get negInf() {
483
- return values_1.DuckDBTimestampMillisecondsValue.NegInf;
484
- }
485
- }
486
- exports.DuckDBTimestampMillisecondsType = DuckDBTimestampMillisecondsType;
487
- exports.TIMESTAMP_MS = DuckDBTimestampMillisecondsType.instance;
488
- class DuckDBTimestampNanosecondsType extends BaseDuckDBType {
489
- constructor(alias) {
490
- super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS, alias);
491
- }
492
- static instance = new DuckDBTimestampNanosecondsType();
493
- static create(alias) {
494
- return alias
495
- ? new DuckDBTimestampNanosecondsType(alias)
496
- : DuckDBTimestampNanosecondsType.instance;
497
- }
498
- get epoch() {
499
- return values_1.DuckDBTimestampNanosecondsValue.Epoch;
500
- }
501
- get max() {
502
- return values_1.DuckDBTimestampNanosecondsValue.Max;
503
- }
504
- get min() {
505
- return values_1.DuckDBTimestampNanosecondsValue.Min;
506
- }
507
- get posInf() {
508
- return values_1.DuckDBTimestampNanosecondsValue.PosInf;
509
- }
510
- get negInf() {
511
- return values_1.DuckDBTimestampNanosecondsValue.NegInf;
512
- }
513
- }
514
- exports.DuckDBTimestampNanosecondsType = DuckDBTimestampNanosecondsType;
515
- exports.TIMESTAMP_NS = DuckDBTimestampNanosecondsType.instance;
516
- class DuckDBEnumType extends BaseDuckDBType {
517
- values;
518
- valueIndexes;
519
- internalTypeId;
520
- constructor(values, internalTypeId, alias) {
521
- super(DuckDBTypeId_1.DuckDBTypeId.ENUM, alias);
522
- this.values = values;
523
- const valueIndexes = {};
524
- for (let i = 0; i < values.length; i++) {
525
- valueIndexes[values[i]] = i;
526
- }
527
- this.valueIndexes = valueIndexes;
528
- this.internalTypeId = internalTypeId;
529
- }
530
- indexForValue(value) {
531
- return this.valueIndexes[value];
532
- }
533
- toString() {
534
- return `ENUM(${this.values.map(sql_1.quotedString).join(', ')})`;
535
- }
536
- toLogicalType() {
537
- const logicalType = DuckDBLogicalType_1.DuckDBLogicalType.createEnum(this.values);
538
- if (this.alias) {
539
- logicalType.alias = this.alias;
540
- }
541
- return logicalType;
542
- }
543
- toJson() {
544
- return {
545
- typeId: this.typeId,
546
- values: [...this.values],
547
- internalTypeId: this.internalTypeId,
548
- ...(this.alias ? { alias: this.alias } : {}),
549
- };
550
- }
551
- }
552
- exports.DuckDBEnumType = DuckDBEnumType;
553
- function ENUM8(values, alias) {
554
- return new DuckDBEnumType(values, DuckDBTypeId_1.DuckDBTypeId.UTINYINT, alias);
555
- }
556
- function ENUM16(values, alias) {
557
- return new DuckDBEnumType(values, DuckDBTypeId_1.DuckDBTypeId.USMALLINT, alias);
558
- }
559
- function ENUM32(values, alias) {
560
- return new DuckDBEnumType(values, DuckDBTypeId_1.DuckDBTypeId.UINTEGER, alias);
561
- }
562
- function ENUM(values, alias) {
563
- if (values.length < 256) {
564
- return ENUM8(values, alias);
565
- }
566
- else if (values.length < 65536) {
567
- return ENUM16(values, alias);
568
- }
569
- else if (values.length < 4294967296) {
570
- return ENUM32(values, alias);
571
- }
572
- else {
573
- throw new Error(`ENUM types cannot have more than 4294967295 values; received ${values.length}`);
574
- }
575
- }
576
- class DuckDBListType extends BaseDuckDBType {
577
- valueType;
578
- constructor(valueType, alias) {
579
- super(DuckDBTypeId_1.DuckDBTypeId.LIST, alias);
580
- this.valueType = valueType;
581
- }
582
- toString() {
583
- return `${this.valueType}[]`;
584
- }
585
- toLogicalType() {
586
- const logicalType = DuckDBLogicalType_1.DuckDBLogicalType.createList(this.valueType.toLogicalType());
587
- if (this.alias) {
588
- logicalType.alias = this.alias;
589
- }
590
- return logicalType;
591
- }
592
- toJson() {
593
- return {
594
- typeId: this.typeId,
595
- valueType: this.valueType.toJson(),
596
- ...(this.alias ? { alias: this.alias } : {}),
597
- };
598
- }
599
- }
600
- exports.DuckDBListType = DuckDBListType;
601
- function LIST(valueType, alias) {
602
- return new DuckDBListType(valueType, alias);
603
- }
604
- class DuckDBStructType extends BaseDuckDBType {
605
- entryNames;
606
- entryTypes;
607
- entryIndexes;
608
- constructor(entryNames, entryTypes, alias) {
609
- super(DuckDBTypeId_1.DuckDBTypeId.STRUCT, alias);
610
- if (entryNames.length !== entryTypes.length) {
611
- throw new Error(`Could not create DuckDBStructType: \
612
- entryNames length (${entryNames.length}) does not match entryTypes length (${entryTypes.length})`);
613
- }
614
- this.entryNames = entryNames;
615
- this.entryTypes = entryTypes;
616
- const entryIndexes = {};
617
- for (let i = 0; i < entryNames.length; i++) {
618
- entryIndexes[entryNames[i]] = i;
619
- }
620
- this.entryIndexes = entryIndexes;
621
- }
622
- get entryCount() {
623
- return this.entryNames.length;
624
- }
625
- indexForEntry(entryName) {
626
- return this.entryIndexes[entryName];
627
- }
628
- typeForEntry(entryName) {
629
- return this.entryTypes[this.entryIndexes[entryName]];
630
- }
631
- toString() {
632
- const parts = [];
633
- for (let i = 0; i < this.entryNames.length; i++) {
634
- parts.push(`${(0, sql_1.quotedIdentifier)(this.entryNames[i])} ${this.entryTypes[i]}`);
635
- }
636
- return `STRUCT(${parts.join(', ')})`;
637
- }
638
- toLogicalType() {
639
- const logicalType = DuckDBLogicalType_1.DuckDBLogicalType.createStruct(this.entryNames, this.entryTypes.map((t) => t.toLogicalType()));
640
- if (this.alias) {
641
- logicalType.alias = this.alias;
642
- }
643
- return logicalType;
644
- }
645
- toJson() {
646
- return {
647
- typeId: this.typeId,
648
- entryNames: [...this.entryNames],
649
- entryTypes: this.entryTypes.map(t => t.toJson()),
650
- ...(this.alias ? { alias: this.alias } : {}),
651
- };
652
- }
653
- }
654
- exports.DuckDBStructType = DuckDBStructType;
655
- function STRUCT(entries, alias) {
656
- const entryNames = Object.keys(entries);
657
- const entryTypes = Object.values(entries);
658
- return new DuckDBStructType(entryNames, entryTypes, alias);
659
- }
660
- class DuckDBMapType extends BaseDuckDBType {
661
- keyType;
662
- valueType;
663
- constructor(keyType, valueType, alias) {
664
- super(DuckDBTypeId_1.DuckDBTypeId.MAP, alias);
665
- this.keyType = keyType;
666
- this.valueType = valueType;
667
- }
668
- toString() {
669
- return `MAP(${this.keyType}, ${this.valueType})`;
670
- }
671
- toLogicalType() {
672
- const logicalType = DuckDBLogicalType_1.DuckDBLogicalType.createMap(this.keyType.toLogicalType(), this.valueType.toLogicalType());
673
- if (this.alias) {
674
- logicalType.alias = this.alias;
675
- }
676
- return logicalType;
677
- }
678
- toJson() {
679
- return {
680
- typeId: this.typeId,
681
- keyType: this.keyType.toJson(),
682
- valueType: this.valueType.toJson(),
683
- ...(this.alias ? { alias: this.alias } : {}),
684
- };
685
- }
686
- }
687
- exports.DuckDBMapType = DuckDBMapType;
688
- function MAP(keyType, valueType, alias) {
689
- return new DuckDBMapType(keyType, valueType, alias);
690
- }
691
- class DuckDBArrayType extends BaseDuckDBType {
692
- valueType;
693
- length;
694
- constructor(valueType, length, alias) {
695
- super(DuckDBTypeId_1.DuckDBTypeId.ARRAY, alias);
696
- this.valueType = valueType;
697
- this.length = length;
698
- }
699
- toString() {
700
- return `${this.valueType}[${this.length}]`;
701
- }
702
- toLogicalType() {
703
- const logicalType = DuckDBLogicalType_1.DuckDBLogicalType.createArray(this.valueType.toLogicalType(), this.length);
704
- if (this.alias) {
705
- logicalType.alias = this.alias;
706
- }
707
- return logicalType;
708
- }
709
- toJson() {
710
- return {
711
- typeId: this.typeId,
712
- valueType: this.valueType.toJson(),
713
- length: this.length,
714
- ...(this.alias ? { alias: this.alias } : {}),
715
- };
716
- }
717
- }
718
- exports.DuckDBArrayType = DuckDBArrayType;
719
- function ARRAY(valueType, length, alias) {
720
- return new DuckDBArrayType(valueType, length, alias);
721
- }
722
- class DuckDBUUIDType extends BaseDuckDBType {
723
- constructor(alias) {
724
- super(DuckDBTypeId_1.DuckDBTypeId.UUID, alias);
725
- }
726
- static instance = new DuckDBUUIDType();
727
- static create(alias) {
728
- return alias ? new DuckDBUUIDType(alias) : DuckDBUUIDType.instance;
729
- }
730
- get max() {
731
- return values_1.DuckDBUUIDValue.Max;
732
- }
733
- get min() {
734
- return values_1.DuckDBUUIDValue.Min;
735
- }
736
- }
737
- exports.DuckDBUUIDType = DuckDBUUIDType;
738
- exports.UUID = DuckDBUUIDType.instance;
739
- class DuckDBUnionType extends BaseDuckDBType {
740
- memberTags;
741
- tagMemberIndexes;
742
- memberTypes;
743
- constructor(memberTags, memberTypes, alias) {
744
- super(DuckDBTypeId_1.DuckDBTypeId.UNION, alias);
745
- if (memberTags.length !== memberTypes.length) {
746
- throw new Error(`Could not create DuckDBUnionType: \
747
- tags length (${memberTags.length}) does not match valueTypes length (${memberTypes.length})`);
748
- }
749
- this.memberTags = memberTags;
750
- const tagMemberIndexes = {};
751
- for (let i = 0; i < memberTags.length; i++) {
752
- tagMemberIndexes[memberTags[i]] = i;
753
- }
754
- this.tagMemberIndexes = tagMemberIndexes;
755
- this.memberTypes = memberTypes;
756
- }
757
- memberIndexForTag(tag) {
758
- return this.tagMemberIndexes[tag];
759
- }
760
- memberTypeForTag(tag) {
761
- return this.memberTypes[this.tagMemberIndexes[tag]];
762
- }
763
- get memberCount() {
764
- return this.memberTags.length;
765
- }
766
- toString() {
767
- const parts = [];
768
- for (let i = 0; i < this.memberTags.length; i++) {
769
- parts.push(`${(0, sql_1.quotedIdentifier)(this.memberTags[i])} ${this.memberTypes[i]}`);
770
- }
771
- return `UNION(${parts.join(', ')})`;
772
- }
773
- toLogicalType() {
774
- const logicalType = DuckDBLogicalType_1.DuckDBLogicalType.createUnion(this.memberTags, this.memberTypes.map((t) => t.toLogicalType()));
775
- if (this.alias) {
776
- logicalType.alias = this.alias;
777
- }
778
- return logicalType;
779
- }
780
- toJson() {
781
- return {
782
- typeId: this.typeId,
783
- memberTags: [...this.memberTags],
784
- memberTypes: this.memberTypes.map(t => t.toJson()),
785
- ...(this.alias ? { alias: this.alias } : {}),
786
- };
787
- }
788
- }
789
- exports.DuckDBUnionType = DuckDBUnionType;
790
- function UNION(members, alias) {
791
- const memberTags = Object.keys(members);
792
- const memberTypes = Object.values(members);
793
- return new DuckDBUnionType(memberTags, memberTypes, alias);
794
- }
795
- class DuckDBBitType extends BaseDuckDBType {
796
- constructor(alias) {
797
- super(DuckDBTypeId_1.DuckDBTypeId.BIT, alias);
798
- }
799
- static instance = new DuckDBBitType();
800
- static create(alias) {
801
- return alias ? new DuckDBBitType(alias) : DuckDBBitType.instance;
802
- }
803
- }
804
- exports.DuckDBBitType = DuckDBBitType;
805
- exports.BIT = DuckDBBitType.instance;
806
- class DuckDBTimeTZType extends BaseDuckDBType {
807
- constructor(alias) {
808
- super(DuckDBTypeId_1.DuckDBTypeId.TIME_TZ, alias);
809
- }
810
- toString() {
811
- return 'TIME WITH TIME ZONE';
812
- }
813
- static instance = new DuckDBTimeTZType();
814
- static create(alias) {
815
- return alias ? new DuckDBTimeTZType(alias) : DuckDBTimeTZType.instance;
816
- }
817
- get max() {
818
- return values_1.DuckDBTimeTZValue.Max;
819
- }
820
- get min() {
821
- return values_1.DuckDBTimeTZValue.Min;
822
- }
823
- }
824
- exports.DuckDBTimeTZType = DuckDBTimeTZType;
825
- exports.TIMETZ = DuckDBTimeTZType.instance;
826
- class DuckDBTimestampTZType extends BaseDuckDBType {
827
- constructor(alias) {
828
- super(DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ, alias);
829
- }
830
- toString() {
831
- return 'TIMESTAMP WITH TIME ZONE';
832
- }
833
- static instance = new DuckDBTimestampTZType();
834
- static create(alias) {
835
- return alias
836
- ? new DuckDBTimestampTZType(alias)
837
- : DuckDBTimestampTZType.instance;
838
- }
839
- get epoch() {
840
- return values_1.DuckDBTimestampTZValue.Epoch;
841
- }
842
- get max() {
843
- return values_1.DuckDBTimestampTZValue.Max;
844
- }
845
- get min() {
846
- return values_1.DuckDBTimestampTZValue.Min;
847
- }
848
- get posInf() {
849
- return values_1.DuckDBTimestampTZValue.PosInf;
850
- }
851
- get negInf() {
852
- return values_1.DuckDBTimestampTZValue.NegInf;
853
- }
854
- }
855
- exports.DuckDBTimestampTZType = DuckDBTimestampTZType;
856
- exports.TIMESTAMPTZ = DuckDBTimestampTZType.instance;
857
- class DuckDBAnyType extends BaseDuckDBType {
858
- constructor(alias) {
859
- super(DuckDBTypeId_1.DuckDBTypeId.ANY, alias);
860
- }
861
- static instance = new DuckDBAnyType();
862
- static create(alias) {
863
- return alias ? new DuckDBAnyType(alias) : DuckDBAnyType.instance;
864
- }
865
- }
866
- exports.DuckDBAnyType = DuckDBAnyType;
867
- exports.ANY = DuckDBAnyType.instance;
868
- class DuckDBBigNumType extends BaseDuckDBType {
869
- constructor(alias) {
870
- super(DuckDBTypeId_1.DuckDBTypeId.BIGNUM, alias);
871
- }
872
- static instance = new DuckDBBigNumType();
873
- static create(alias) {
874
- return alias ? new DuckDBBigNumType(alias) : DuckDBBigNumType.instance;
875
- }
876
- static Max = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n;
877
- static Min = -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n;
878
- get max() {
879
- return DuckDBBigNumType.Max;
880
- }
881
- get min() {
882
- return DuckDBBigNumType.Min;
883
- }
884
- }
885
- exports.DuckDBBigNumType = DuckDBBigNumType;
886
- exports.BIGNUM = DuckDBBigNumType.instance;
887
- class DuckDBSQLNullType extends BaseDuckDBType {
888
- constructor(alias) {
889
- super(DuckDBTypeId_1.DuckDBTypeId.SQLNULL, alias);
890
- }
891
- static instance = new DuckDBSQLNullType();
892
- static create(alias) {
893
- return alias ? new DuckDBSQLNullType(alias) : DuckDBSQLNullType.instance;
894
- }
895
- }
896
- exports.DuckDBSQLNullType = DuckDBSQLNullType;
897
- exports.SQLNULL = DuckDBSQLNullType.instance;
898
- class DuckDBStringLiteralType extends BaseDuckDBType {
899
- constructor(alias) {
900
- super(DuckDBTypeId_1.DuckDBTypeId.STRING_LITERAL, alias);
901
- }
902
- static instance = new DuckDBStringLiteralType();
903
- static create(alias) {
904
- return alias ? new DuckDBStringLiteralType(alias) : DuckDBStringLiteralType.instance;
905
- }
906
- }
907
- exports.DuckDBStringLiteralType = DuckDBStringLiteralType;
908
- exports.STRING_LITERAL = DuckDBStringLiteralType.instance;
909
- class DuckDBIntegerLiteralType extends BaseDuckDBType {
910
- constructor(alias) {
911
- super(DuckDBTypeId_1.DuckDBTypeId.INTEGER_LITERAL, alias);
912
- }
913
- static instance = new DuckDBIntegerLiteralType();
914
- static create(alias) {
915
- return alias ? new DuckDBIntegerLiteralType(alias) : DuckDBIntegerLiteralType.instance;
916
- }
917
- }
918
- exports.DuckDBIntegerLiteralType = DuckDBIntegerLiteralType;
919
- exports.INTEGER_LITERAL = DuckDBIntegerLiteralType.instance;
920
- class DuckDBTimeNSType extends BaseDuckDBType {
921
- constructor(alias) {
922
- super(DuckDBTypeId_1.DuckDBTypeId.TIME_NS, alias);
923
- }
924
- static instance = new DuckDBTimeNSType();
925
- static create(alias) {
926
- return alias ? new DuckDBTimeNSType(alias) : DuckDBTimeNSType.instance;
927
- }
928
- }
929
- exports.DuckDBTimeNSType = DuckDBTimeNSType;
930
- exports.TIME_NS = DuckDBTimeNSType.instance;
17
+ __exportStar(require("./types"), exports);