@haybarn/node-api 1.5.3-rc2

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 (149) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +1224 -0
  3. package/lib/DuckDBAppender.d.ts +51 -0
  4. package/lib/DuckDBAppender.js +149 -0
  5. package/lib/DuckDBBindInfo.d.ts +12 -0
  6. package/lib/DuckDBBindInfo.js +33 -0
  7. package/lib/DuckDBClientContext.d.ts +6 -0
  8. package/lib/DuckDBClientContext.js +17 -0
  9. package/lib/DuckDBConnection.d.ts +49 -0
  10. package/lib/DuckDBConnection.js +208 -0
  11. package/lib/DuckDBDataChunk.d.ts +41 -0
  12. package/lib/DuckDBDataChunk.js +223 -0
  13. package/lib/DuckDBExtractedStatements.d.ts +12 -0
  14. package/lib/DuckDBExtractedStatements.js +31 -0
  15. package/lib/DuckDBFunctionInfo.d.ts +10 -0
  16. package/lib/DuckDBFunctionInfo.js +29 -0
  17. package/lib/DuckDBInstance.d.ts +10 -0
  18. package/lib/DuckDBInstance.js +30 -0
  19. package/lib/DuckDBInstanceCache.d.ts +8 -0
  20. package/lib/DuckDBInstanceCache.js +28 -0
  21. package/lib/DuckDBLogicalType.d.ts +66 -0
  22. package/lib/DuckDBLogicalType.js +328 -0
  23. package/lib/DuckDBMaterializedResult.d.ts +9 -0
  24. package/lib/DuckDBMaterializedResult.js +24 -0
  25. package/lib/DuckDBPendingResult.d.ts +18 -0
  26. package/lib/DuckDBPendingResult.js +60 -0
  27. package/lib/DuckDBPreparedStatement.d.ts +72 -0
  28. package/lib/DuckDBPreparedStatement.js +219 -0
  29. package/lib/DuckDBPreparedStatementCollection.d.ts +4 -0
  30. package/lib/DuckDBPreparedStatementCollection.js +2 -0
  31. package/lib/DuckDBPreparedStatementWeakRefCollection.d.ts +9 -0
  32. package/lib/DuckDBPreparedStatementWeakRefCollection.js +28 -0
  33. package/lib/DuckDBResult.d.ts +57 -0
  34. package/lib/DuckDBResult.js +229 -0
  35. package/lib/DuckDBResultReader.d.ts +68 -0
  36. package/lib/DuckDBResultReader.js +203 -0
  37. package/lib/DuckDBScalarFunction.d.ts +33 -0
  38. package/lib/DuckDBScalarFunction.js +83 -0
  39. package/lib/DuckDBType.d.ts +373 -0
  40. package/lib/DuckDBType.js +930 -0
  41. package/lib/DuckDBTypeId.d.ts +42 -0
  42. package/lib/DuckDBTypeId.js +47 -0
  43. package/lib/DuckDBValueConverter.d.ts +3 -0
  44. package/lib/DuckDBValueConverter.js +2 -0
  45. package/lib/DuckDBValueConverters.d.ts +47 -0
  46. package/lib/DuckDBValueConverters.js +214 -0
  47. package/lib/DuckDBVector.d.ts +596 -0
  48. package/lib/DuckDBVector.js +2525 -0
  49. package/lib/JS.d.ts +3 -0
  50. package/lib/JS.js +2 -0
  51. package/lib/JSDuckDBValueConverter.d.ts +3 -0
  52. package/lib/JSDuckDBValueConverter.js +49 -0
  53. package/lib/Json.d.ts +3 -0
  54. package/lib/Json.js +2 -0
  55. package/lib/JsonDuckDBValueConverter.d.ts +3 -0
  56. package/lib/JsonDuckDBValueConverter.js +49 -0
  57. package/lib/configurationOptionDescriptions.d.ts +1 -0
  58. package/lib/configurationOptionDescriptions.js +16 -0
  59. package/lib/conversion/bytesFromString.d.ts +1 -0
  60. package/lib/conversion/bytesFromString.js +7 -0
  61. package/lib/conversion/dateTimeStringConversion.d.ts +20 -0
  62. package/lib/conversion/dateTimeStringConversion.js +238 -0
  63. package/lib/conversion/displayStringForDuckDBValue.d.ts +2 -0
  64. package/lib/conversion/displayStringForDuckDBValue.js +13 -0
  65. package/lib/conversion/stringFromBlob.d.ts +4 -0
  66. package/lib/conversion/stringFromBlob.js +45 -0
  67. package/lib/conversion/stringFromDecimal.d.ts +18 -0
  68. package/lib/conversion/stringFromDecimal.js +80 -0
  69. package/lib/convertColumnsFromChunks.d.ts +3 -0
  70. package/lib/convertColumnsFromChunks.js +16 -0
  71. package/lib/convertColumnsObjectFromChunks.d.ts +3 -0
  72. package/lib/convertColumnsObjectFromChunks.js +19 -0
  73. package/lib/convertRowObjectsFromChunks.d.ts +3 -0
  74. package/lib/convertRowObjectsFromChunks.js +17 -0
  75. package/lib/convertRowsFromChunks.d.ts +3 -0
  76. package/lib/convertRowsFromChunks.js +13 -0
  77. package/lib/createConfig.d.ts +2 -0
  78. package/lib/createConfig.js +19 -0
  79. package/lib/createDuckDBValueConverter.d.ts +3 -0
  80. package/lib/createDuckDBValueConverter.js +15 -0
  81. package/lib/createResult.d.ts +3 -0
  82. package/lib/createResult.js +17 -0
  83. package/lib/createValue.d.ts +4 -0
  84. package/lib/createValue.js +222 -0
  85. package/lib/duckdb.d.ts +33 -0
  86. package/lib/duckdb.js +54 -0
  87. package/lib/enums.d.ts +5 -0
  88. package/lib/enums.js +9 -0
  89. package/lib/getColumnsFromChunks.d.ts +3 -0
  90. package/lib/getColumnsFromChunks.js +10 -0
  91. package/lib/getColumnsObjectFromChunks.d.ts +3 -0
  92. package/lib/getColumnsObjectFromChunks.js +10 -0
  93. package/lib/getRowObjectsFromChunks.d.ts +3 -0
  94. package/lib/getRowObjectsFromChunks.js +10 -0
  95. package/lib/getRowsFromChunks.d.ts +3 -0
  96. package/lib/getRowsFromChunks.js +10 -0
  97. package/lib/index.d.ts +3 -0
  98. package/lib/index.js +41 -0
  99. package/lib/sleep.d.ts +1 -0
  100. package/lib/sleep.js +8 -0
  101. package/lib/sql.d.ts +2 -0
  102. package/lib/sql.js +10 -0
  103. package/lib/typeForValue.d.ts +3 -0
  104. package/lib/typeForValue.js +91 -0
  105. package/lib/values/DuckDBArrayValue.d.ts +7 -0
  106. package/lib/values/DuckDBArrayValue.js +18 -0
  107. package/lib/values/DuckDBBitValue.d.ts +16 -0
  108. package/lib/values/DuckDBBitValue.js +103 -0
  109. package/lib/values/DuckDBBlobValue.d.ts +8 -0
  110. package/lib/values/DuckDBBlobValue.js +26 -0
  111. package/lib/values/DuckDBDateValue.d.ts +16 -0
  112. package/lib/values/DuckDBDateValue.js +39 -0
  113. package/lib/values/DuckDBDecimalValue.d.ts +19 -0
  114. package/lib/values/DuckDBDecimalValue.js +44 -0
  115. package/lib/values/DuckDBIntervalValue.d.ts +9 -0
  116. package/lib/values/DuckDBIntervalValue.js +22 -0
  117. package/lib/values/DuckDBListValue.d.ts +7 -0
  118. package/lib/values/DuckDBListValue.js +18 -0
  119. package/lib/values/DuckDBMapValue.d.ts +11 -0
  120. package/lib/values/DuckDBMapValue.js +18 -0
  121. package/lib/values/DuckDBStructValue.d.ts +7 -0
  122. package/lib/values/DuckDBStructValue.js +22 -0
  123. package/lib/values/DuckDBTimeNSValue.d.ts +9 -0
  124. package/lib/values/DuckDBTimeNSValue.js +20 -0
  125. package/lib/values/DuckDBTimeTZValue.d.ts +35 -0
  126. package/lib/values/DuckDBTimeTZValue.js +65 -0
  127. package/lib/values/DuckDBTimeValue.d.ts +12 -0
  128. package/lib/values/DuckDBTimeValue.js +33 -0
  129. package/lib/values/DuckDBTimestampMillisecondsValue.d.ts +13 -0
  130. package/lib/values/DuckDBTimestampMillisecondsValue.js +31 -0
  131. package/lib/values/DuckDBTimestampNanosecondsValue.d.ts +13 -0
  132. package/lib/values/DuckDBTimestampNanosecondsValue.js +30 -0
  133. package/lib/values/DuckDBTimestampSecondsValue.d.ts +13 -0
  134. package/lib/values/DuckDBTimestampSecondsValue.js +30 -0
  135. package/lib/values/DuckDBTimestampTZValue.d.ts +16 -0
  136. package/lib/values/DuckDBTimestampTZValue.js +41 -0
  137. package/lib/values/DuckDBTimestampValue.d.ts +18 -0
  138. package/lib/values/DuckDBTimestampValue.js +41 -0
  139. package/lib/values/DuckDBUUIDValue.d.ts +19 -0
  140. package/lib/values/DuckDBUUIDValue.js +40 -0
  141. package/lib/values/DuckDBUnionValue.d.ts +8 -0
  142. package/lib/values/DuckDBUnionValue.js +22 -0
  143. package/lib/values/DuckDBValue.d.ts +20 -0
  144. package/lib/values/DuckDBValue.js +2 -0
  145. package/lib/values/index.d.ts +20 -0
  146. package/lib/values/index.js +36 -0
  147. package/lib/version.d.ts +1 -0
  148. package/lib/version.js +10 -0
  149. package/package.json +15 -0
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typeForValue = typeForValue;
4
+ const DuckDBType_1 = require("./DuckDBType");
5
+ const values_1 = require("./values");
6
+ function typeForValue(value) {
7
+ if (value === null) {
8
+ return DuckDBType_1.SQLNULL;
9
+ }
10
+ else {
11
+ switch (typeof value) {
12
+ case 'boolean':
13
+ return DuckDBType_1.BOOLEAN;
14
+ case 'number':
15
+ if (Math.round(value) === value) {
16
+ return DuckDBType_1.INTEGER;
17
+ }
18
+ else {
19
+ return DuckDBType_1.DOUBLE;
20
+ }
21
+ case 'bigint':
22
+ return DuckDBType_1.HUGEINT;
23
+ case 'string':
24
+ return DuckDBType_1.VARCHAR;
25
+ case 'object':
26
+ if (value instanceof values_1.DuckDBArrayValue) {
27
+ return (0, DuckDBType_1.ARRAY)(typeForValue(value.items[0]), value.items.length);
28
+ }
29
+ else if (value instanceof values_1.DuckDBBitValue) {
30
+ return DuckDBType_1.BIT;
31
+ }
32
+ else if (value instanceof values_1.DuckDBBlobValue) {
33
+ return DuckDBType_1.BLOB;
34
+ }
35
+ else if (value instanceof values_1.DuckDBDateValue) {
36
+ return DuckDBType_1.DATE;
37
+ }
38
+ else if (value instanceof values_1.DuckDBDecimalValue) {
39
+ return (0, DuckDBType_1.DECIMAL)(value.width, value.scale);
40
+ }
41
+ else if (value instanceof values_1.DuckDBIntervalValue) {
42
+ return DuckDBType_1.INTERVAL;
43
+ }
44
+ else if (value instanceof values_1.DuckDBListValue) {
45
+ return (0, DuckDBType_1.LIST)(typeForValue(value.items[0]));
46
+ }
47
+ else if (value instanceof values_1.DuckDBMapValue) {
48
+ return (0, DuckDBType_1.MAP)(typeForValue(value.entries[0].key), typeForValue(value.entries[0].value));
49
+ }
50
+ else if (value instanceof values_1.DuckDBStructValue) {
51
+ const entryTypes = {};
52
+ for (const key in value.entries) {
53
+ entryTypes[key] = typeForValue(value.entries[key]);
54
+ }
55
+ return (0, DuckDBType_1.STRUCT)(entryTypes);
56
+ }
57
+ else if (value instanceof values_1.DuckDBTimestampMillisecondsValue) {
58
+ return DuckDBType_1.TIMESTAMP_MS;
59
+ }
60
+ else if (value instanceof values_1.DuckDBTimestampNanosecondsValue) {
61
+ return DuckDBType_1.TIMESTAMP_NS;
62
+ }
63
+ else if (value instanceof values_1.DuckDBTimestampSecondsValue) {
64
+ return DuckDBType_1.TIMESTAMP_S;
65
+ }
66
+ else if (value instanceof values_1.DuckDBTimestampTZValue) {
67
+ return DuckDBType_1.TIMESTAMPTZ;
68
+ }
69
+ else if (value instanceof values_1.DuckDBTimestampValue) {
70
+ return DuckDBType_1.TIMESTAMP;
71
+ }
72
+ else if (value instanceof values_1.DuckDBTimeTZValue) {
73
+ return DuckDBType_1.TIMETZ;
74
+ }
75
+ else if (value instanceof values_1.DuckDBTimeValue) {
76
+ return DuckDBType_1.TIME;
77
+ }
78
+ else if (value instanceof values_1.DuckDBTimeNSValue) {
79
+ return DuckDBType_1.TIME_NS;
80
+ }
81
+ else if (value instanceof values_1.DuckDBUnionValue) {
82
+ return (0, DuckDBType_1.UNION)({ [value.tag]: typeForValue(value.value) });
83
+ }
84
+ else if (value instanceof values_1.DuckDBUUIDValue) {
85
+ return DuckDBType_1.UUID;
86
+ }
87
+ break;
88
+ }
89
+ }
90
+ return DuckDBType_1.ANY;
91
+ }
@@ -0,0 +1,7 @@
1
+ import { DuckDBValue } from './DuckDBValue';
2
+ export declare class DuckDBArrayValue {
3
+ readonly items: readonly DuckDBValue[];
4
+ constructor(items: readonly DuckDBValue[]);
5
+ toString(): string;
6
+ }
7
+ export declare function arrayValue(items: readonly DuckDBValue[]): DuckDBArrayValue;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuckDBArrayValue = void 0;
4
+ exports.arrayValue = arrayValue;
5
+ const displayStringForDuckDBValue_1 = require("../conversion/displayStringForDuckDBValue");
6
+ class DuckDBArrayValue {
7
+ items;
8
+ constructor(items) {
9
+ this.items = items;
10
+ }
11
+ toString() {
12
+ return `[${this.items.map(displayStringForDuckDBValue_1.displayStringForDuckDBValue).join(', ')}]`;
13
+ }
14
+ }
15
+ exports.DuckDBArrayValue = DuckDBArrayValue;
16
+ function arrayValue(items) {
17
+ return new DuckDBArrayValue(items);
18
+ }
@@ -0,0 +1,16 @@
1
+ export declare class DuckDBBitValue {
2
+ readonly data: Uint8Array;
3
+ constructor(data: Uint8Array);
4
+ padding(): number;
5
+ get length(): number;
6
+ getBool(index: number): boolean;
7
+ toBools(): boolean[];
8
+ getBit(index: number): 0 | 1;
9
+ toBits(): number[];
10
+ toString(): string;
11
+ static fromString(str: string, on?: string): DuckDBBitValue;
12
+ static fromBits(bits: readonly number[], on?: number): DuckDBBitValue;
13
+ static fromBools(bools: readonly boolean[]): DuckDBBitValue;
14
+ static fromLengthAndPredicate(length: number, predicate: (index: number) => boolean): DuckDBBitValue;
15
+ }
16
+ export declare function bitValue(input: string | readonly boolean[] | readonly number[]): DuckDBBitValue;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuckDBBitValue = void 0;
4
+ exports.bitValue = bitValue;
5
+ class DuckDBBitValue {
6
+ data;
7
+ constructor(data) {
8
+ this.data = data;
9
+ }
10
+ padding() {
11
+ return this.data[0];
12
+ }
13
+ get length() {
14
+ return (this.data.length - 1) * 8 - this.padding();
15
+ }
16
+ getBool(index) {
17
+ const offset = index + this.padding();
18
+ const dataIndex = Math.floor(offset / 8) + 1;
19
+ const byte = this.data[dataIndex] >> (7 - (offset % 8));
20
+ return (byte & 1) !== 0;
21
+ }
22
+ toBools() {
23
+ const bools = [];
24
+ const length = this.length;
25
+ for (let i = 0; i < length; i++) {
26
+ bools.push(this.getBool(i));
27
+ }
28
+ return bools;
29
+ }
30
+ getBit(index) {
31
+ return this.getBool(index) ? 1 : 0;
32
+ }
33
+ toBits() {
34
+ const bits = [];
35
+ const length = this.length;
36
+ for (let i = 0; i < length; i++) {
37
+ bits.push(this.getBit(i));
38
+ }
39
+ return bits;
40
+ }
41
+ toString() {
42
+ const length = this.length;
43
+ const chars = Array.from({ length });
44
+ for (let i = 0; i < length; i++) {
45
+ chars[i] = this.getBool(i) ? '1' : '0';
46
+ }
47
+ return chars.join('');
48
+ }
49
+ static fromString(str, on = '1') {
50
+ return DuckDBBitValue.fromLengthAndPredicate(str.length, i => str[i] === on);
51
+ }
52
+ static fromBits(bits, on = 1) {
53
+ return DuckDBBitValue.fromLengthAndPredicate(bits.length, i => bits[i] === on);
54
+ }
55
+ static fromBools(bools) {
56
+ return DuckDBBitValue.fromLengthAndPredicate(bools.length, i => bools[i]);
57
+ }
58
+ static fromLengthAndPredicate(length, predicate) {
59
+ const byteCount = Math.ceil(length / 8) + 1;
60
+ const paddingBitCount = (8 - (length % 8)) % 8;
61
+ const data = new Uint8Array(byteCount);
62
+ let byteIndex = 0;
63
+ // first byte contains count of padding bits
64
+ data[byteIndex++] = paddingBitCount;
65
+ let byte = 0;
66
+ let byteBit = 0;
67
+ // padding consists of 1s in MSB of second byte
68
+ while (byteBit < paddingBitCount) {
69
+ byte <<= 1;
70
+ byte |= 1;
71
+ byteBit++;
72
+ }
73
+ let bitIndex = 0;
74
+ while (byteIndex < byteCount) {
75
+ while (byteBit < 8) {
76
+ byte <<= 1;
77
+ if (predicate(bitIndex++)) {
78
+ byte |= 1;
79
+ }
80
+ byteBit++;
81
+ }
82
+ data[byteIndex++] = byte;
83
+ byte = 0;
84
+ byteBit = 0;
85
+ }
86
+ return new DuckDBBitValue(data);
87
+ }
88
+ }
89
+ exports.DuckDBBitValue = DuckDBBitValue;
90
+ function bitValue(input) {
91
+ if (typeof input === 'string') {
92
+ return DuckDBBitValue.fromString(input);
93
+ }
94
+ if (input.length > 0) {
95
+ if (typeof input[0] === 'boolean') {
96
+ return DuckDBBitValue.fromBools(input);
97
+ }
98
+ else if (typeof input[0] === 'number') {
99
+ return DuckDBBitValue.fromBits(input);
100
+ }
101
+ }
102
+ return DuckDBBitValue.fromLengthAndPredicate(0, _ => false);
103
+ }
@@ -0,0 +1,8 @@
1
+ export declare class DuckDBBlobValue {
2
+ readonly bytes: Uint8Array;
3
+ constructor(bytes: Uint8Array);
4
+ /** Matches BLOB-to-VARCHAR conversion behavior of DuckDB. */
5
+ toString(): string;
6
+ static fromString(str: string): DuckDBBlobValue;
7
+ }
8
+ export declare function blobValue(input: Uint8Array | string): DuckDBBlobValue;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuckDBBlobValue = void 0;
4
+ exports.blobValue = blobValue;
5
+ const bytesFromString_1 = require("../conversion/bytesFromString");
6
+ const stringFromBlob_1 = require("../conversion/stringFromBlob");
7
+ class DuckDBBlobValue {
8
+ bytes;
9
+ constructor(bytes) {
10
+ this.bytes = bytes;
11
+ }
12
+ /** Matches BLOB-to-VARCHAR conversion behavior of DuckDB. */
13
+ toString() {
14
+ return (0, stringFromBlob_1.stringFromBlob)(this.bytes);
15
+ }
16
+ static fromString(str) {
17
+ return new DuckDBBlobValue(Buffer.from((0, bytesFromString_1.bytesFromString)(str)));
18
+ }
19
+ }
20
+ exports.DuckDBBlobValue = DuckDBBlobValue;
21
+ function blobValue(input) {
22
+ if (typeof input === 'string') {
23
+ return DuckDBBlobValue.fromString(input);
24
+ }
25
+ return new DuckDBBlobValue(input);
26
+ }
@@ -0,0 +1,16 @@
1
+ import { Date_, DateParts } from '@haybarn/node-bindings';
2
+ export type { DateParts };
3
+ export declare class DuckDBDateValue implements Date_ {
4
+ readonly days: number;
5
+ constructor(days: number);
6
+ get isFinite(): boolean;
7
+ toString(): string;
8
+ toParts(): DateParts;
9
+ static fromParts(parts: DateParts): DuckDBDateValue;
10
+ static readonly Epoch: DuckDBDateValue;
11
+ static readonly Max: DuckDBDateValue;
12
+ static readonly Min: DuckDBDateValue;
13
+ static readonly PosInf: DuckDBDateValue;
14
+ static readonly NegInf: DuckDBDateValue;
15
+ }
16
+ export declare function dateValue(daysOrParts: number | DateParts): DuckDBDateValue;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DuckDBDateValue = void 0;
7
+ exports.dateValue = dateValue;
8
+ const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
9
+ const dateTimeStringConversion_1 = require("../conversion/dateTimeStringConversion");
10
+ class DuckDBDateValue {
11
+ days;
12
+ constructor(days) {
13
+ this.days = days;
14
+ }
15
+ get isFinite() {
16
+ return node_bindings_1.default.is_finite_date(this);
17
+ }
18
+ toString() {
19
+ return (0, dateTimeStringConversion_1.getDuckDBDateStringFromDays)(this.days);
20
+ }
21
+ toParts() {
22
+ return node_bindings_1.default.from_date(this);
23
+ }
24
+ static fromParts(parts) {
25
+ return new DuckDBDateValue(node_bindings_1.default.to_date(parts).days);
26
+ }
27
+ static Epoch = new DuckDBDateValue(0);
28
+ static Max = new DuckDBDateValue(2 ** 31 - 2);
29
+ static Min = new DuckDBDateValue(-(2 ** 31 - 2));
30
+ static PosInf = new DuckDBDateValue(2 ** 31 - 1);
31
+ static NegInf = new DuckDBDateValue(-(2 ** 31 - 1));
32
+ }
33
+ exports.DuckDBDateValue = DuckDBDateValue;
34
+ function dateValue(daysOrParts) {
35
+ if (typeof daysOrParts === 'number') {
36
+ return new DuckDBDateValue(daysOrParts);
37
+ }
38
+ return DuckDBDateValue.fromParts(daysOrParts);
39
+ }
@@ -0,0 +1,19 @@
1
+ import { Decimal } from '@haybarn/node-bindings';
2
+ export declare class DuckDBDecimalValue implements Decimal {
3
+ /** Total number of decimal digits (including fractional digits) in represented number. */
4
+ readonly width: number;
5
+ /** Number of fractional digits in represented number. */
6
+ readonly scale: number;
7
+ /** Scaled-up value. Represented number is value/(10^scale). */
8
+ readonly value: bigint;
9
+ /**
10
+ * @param value Scaled-up value. Represented number is value/(10^scale).
11
+ * @param width Total number of decimal digits (including fractional digits) in represented number.
12
+ * @param scale Number of fractional digits in represented number.
13
+ */
14
+ constructor(value: bigint, width: number, scale: number);
15
+ toString(): string;
16
+ toDouble(): number;
17
+ static fromDouble(double: number, width: number, scale: number): DuckDBDecimalValue;
18
+ }
19
+ export declare function decimalValue(value: bigint | number, width: number, scale: number): DuckDBDecimalValue;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DuckDBDecimalValue = void 0;
7
+ exports.decimalValue = decimalValue;
8
+ const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
9
+ const stringFromDecimal_1 = require("../conversion/stringFromDecimal");
10
+ class DuckDBDecimalValue {
11
+ /** Total number of decimal digits (including fractional digits) in represented number. */
12
+ width;
13
+ /** Number of fractional digits in represented number. */
14
+ scale;
15
+ /** Scaled-up value. Represented number is value/(10^scale). */
16
+ value;
17
+ /**
18
+ * @param value Scaled-up value. Represented number is value/(10^scale).
19
+ * @param width Total number of decimal digits (including fractional digits) in represented number.
20
+ * @param scale Number of fractional digits in represented number.
21
+ */
22
+ constructor(value, width, scale) {
23
+ this.width = width;
24
+ this.scale = scale;
25
+ this.value = value;
26
+ }
27
+ toString() {
28
+ return (0, stringFromDecimal_1.stringFromDecimal)(this.value, this.scale);
29
+ }
30
+ toDouble() {
31
+ return node_bindings_1.default.decimal_to_double(this);
32
+ }
33
+ static fromDouble(double, width, scale) {
34
+ const decimal = node_bindings_1.default.double_to_decimal(double, width, scale);
35
+ return new DuckDBDecimalValue(decimal.value, decimal.width, decimal.scale);
36
+ }
37
+ }
38
+ exports.DuckDBDecimalValue = DuckDBDecimalValue;
39
+ function decimalValue(value, width, scale) {
40
+ if (typeof value === 'number') {
41
+ return DuckDBDecimalValue.fromDouble(value, width, scale);
42
+ }
43
+ return new DuckDBDecimalValue(value, width, scale);
44
+ }
@@ -0,0 +1,9 @@
1
+ import { Interval } from '@haybarn/node-bindings';
2
+ export declare class DuckDBIntervalValue implements Interval {
3
+ readonly months: number;
4
+ readonly days: number;
5
+ readonly micros: bigint;
6
+ constructor(months: number, days: number, micros: bigint);
7
+ toString(): string;
8
+ }
9
+ export declare function intervalValue(months: number, days: number, micros: bigint): DuckDBIntervalValue;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuckDBIntervalValue = void 0;
4
+ exports.intervalValue = intervalValue;
5
+ const dateTimeStringConversion_1 = require("../conversion/dateTimeStringConversion");
6
+ class DuckDBIntervalValue {
7
+ months;
8
+ days;
9
+ micros;
10
+ constructor(months, days, micros) {
11
+ this.months = months;
12
+ this.days = days;
13
+ this.micros = micros;
14
+ }
15
+ toString() {
16
+ return (0, dateTimeStringConversion_1.getDuckDBIntervalString)(this.months, this.days, this.micros);
17
+ }
18
+ }
19
+ exports.DuckDBIntervalValue = DuckDBIntervalValue;
20
+ function intervalValue(months, days, micros) {
21
+ return new DuckDBIntervalValue(months, days, micros);
22
+ }
@@ -0,0 +1,7 @@
1
+ import { DuckDBValue } from './DuckDBValue';
2
+ export declare class DuckDBListValue {
3
+ readonly items: readonly DuckDBValue[];
4
+ constructor(items: readonly DuckDBValue[]);
5
+ toString(): string;
6
+ }
7
+ export declare function listValue(items: readonly DuckDBValue[]): DuckDBListValue;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuckDBListValue = void 0;
4
+ exports.listValue = listValue;
5
+ const displayStringForDuckDBValue_1 = require("../conversion/displayStringForDuckDBValue");
6
+ class DuckDBListValue {
7
+ items;
8
+ constructor(items) {
9
+ this.items = items;
10
+ }
11
+ toString() {
12
+ return `[${this.items.map(displayStringForDuckDBValue_1.displayStringForDuckDBValue).join(', ')}]`;
13
+ }
14
+ }
15
+ exports.DuckDBListValue = DuckDBListValue;
16
+ function listValue(items) {
17
+ return new DuckDBListValue(items);
18
+ }
@@ -0,0 +1,11 @@
1
+ import { DuckDBValue } from './DuckDBValue';
2
+ export interface DuckDBMapEntry {
3
+ key: DuckDBValue;
4
+ value: DuckDBValue;
5
+ }
6
+ export declare class DuckDBMapValue {
7
+ readonly entries: DuckDBMapEntry[];
8
+ constructor(entries: DuckDBMapEntry[]);
9
+ toString(): string;
10
+ }
11
+ export declare function mapValue(entries: DuckDBMapEntry[]): DuckDBMapValue;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuckDBMapValue = void 0;
4
+ exports.mapValue = mapValue;
5
+ const displayStringForDuckDBValue_1 = require("../conversion/displayStringForDuckDBValue");
6
+ class DuckDBMapValue {
7
+ entries;
8
+ constructor(entries) {
9
+ this.entries = entries;
10
+ }
11
+ toString() {
12
+ return `{${this.entries.map(({ key, value }) => `${(0, displayStringForDuckDBValue_1.displayStringForDuckDBValue)(key)}: ${(0, displayStringForDuckDBValue_1.displayStringForDuckDBValue)(value)}`).join(', ')}}`;
13
+ }
14
+ }
15
+ exports.DuckDBMapValue = DuckDBMapValue;
16
+ function mapValue(entries) {
17
+ return new DuckDBMapValue(entries);
18
+ }
@@ -0,0 +1,7 @@
1
+ import { DuckDBValue } from './DuckDBValue';
2
+ export declare class DuckDBStructValue {
3
+ readonly entries: Readonly<Record<string, DuckDBValue>>;
4
+ constructor(entries: Readonly<Record<string, DuckDBValue>>);
5
+ toString(): string;
6
+ }
7
+ export declare function structValue(entries: Readonly<Record<string, DuckDBValue>>): DuckDBStructValue;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuckDBStructValue = void 0;
4
+ exports.structValue = structValue;
5
+ const displayStringForDuckDBValue_1 = require("../conversion/displayStringForDuckDBValue");
6
+ class DuckDBStructValue {
7
+ entries;
8
+ constructor(entries) {
9
+ this.entries = entries;
10
+ }
11
+ toString() {
12
+ const parts = [];
13
+ for (const name in this.entries) {
14
+ parts.push(`${(0, displayStringForDuckDBValue_1.displayStringForDuckDBValue)(name)}: ${(0, displayStringForDuckDBValue_1.displayStringForDuckDBValue)(this.entries[name])}`);
15
+ }
16
+ return `{${parts.join(', ')}}`;
17
+ }
18
+ }
19
+ exports.DuckDBStructValue = DuckDBStructValue;
20
+ function structValue(entries) {
21
+ return new DuckDBStructValue(entries);
22
+ }
@@ -0,0 +1,9 @@
1
+ import { TimeNS } from '@haybarn/node-bindings';
2
+ export declare class DuckDBTimeNSValue implements TimeNS {
3
+ readonly nanos: bigint;
4
+ constructor(nanos: bigint);
5
+ toString(): string;
6
+ static readonly Max: DuckDBTimeNSValue;
7
+ static readonly Min: DuckDBTimeNSValue;
8
+ }
9
+ export declare function timeNSValue(nanos: bigint): DuckDBTimeNSValue;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuckDBTimeNSValue = void 0;
4
+ exports.timeNSValue = timeNSValue;
5
+ const dateTimeStringConversion_1 = require("../conversion/dateTimeStringConversion");
6
+ class DuckDBTimeNSValue {
7
+ nanos;
8
+ constructor(nanos) {
9
+ this.nanos = nanos;
10
+ }
11
+ toString() {
12
+ return (0, dateTimeStringConversion_1.getDuckDBTimeStringFromNanosecondsInDay)(this.nanos);
13
+ }
14
+ static Max = new DuckDBTimeNSValue(24n * 60n * 60n * 1000n * 1000n * 1000n);
15
+ static Min = new DuckDBTimeNSValue(0n);
16
+ }
17
+ exports.DuckDBTimeNSValue = DuckDBTimeNSValue;
18
+ function timeNSValue(nanos) {
19
+ return new DuckDBTimeNSValue(nanos);
20
+ }
@@ -0,0 +1,35 @@
1
+ import { TimeTZ, TimeTZParts } from '@haybarn/node-bindings';
2
+ export type { TimeTZParts };
3
+ export declare class DuckDBTimeTZValue implements TimeTZ {
4
+ /**
5
+ * 40 bits for micros, then 24 bits for encoded offset in seconds.
6
+ *
7
+ * Max absolute unencoded offset = 15:59:59 = 60 * (60 * 15 + 59) + 59 = 57599.
8
+ *
9
+ * Encoded offset is unencoded offset inverted then shifted (by +57599) to unsigned.
10
+ *
11
+ * Max unencoded offset = 57599 -> -57599 -> 0 encoded.
12
+ *
13
+ * Min unencoded offset = -57599 -> 57599 -> 115198 encoded.
14
+ */
15
+ readonly bits: bigint;
16
+ /** Ranges from 0 to 86400000000 (= 24 * 60 * 60 * 1000 * 1000) */
17
+ readonly micros: bigint;
18
+ /** In seconds, ranges from -57599 to 57599 (= 16 * 60 * 60 - 1) */
19
+ readonly offset: number;
20
+ constructor(bits: bigint, micros: bigint, offset: number);
21
+ toString(): string;
22
+ toParts(): TimeTZParts;
23
+ static TimeBits: number;
24
+ static OffsetBits: number;
25
+ static MaxOffset: number;
26
+ static MinOffset: number;
27
+ static MaxMicros: bigint;
28
+ static MinMicros: bigint;
29
+ static fromBits(bits: bigint): DuckDBTimeTZValue;
30
+ static fromMicrosAndOffset(micros: bigint, offset: number): DuckDBTimeTZValue;
31
+ static fromParts(parts: TimeTZParts): DuckDBTimeTZValue;
32
+ static readonly Max: DuckDBTimeTZValue;
33
+ static readonly Min: DuckDBTimeTZValue;
34
+ }
35
+ export declare function timeTZValue(micros: bigint, offset: number): DuckDBTimeTZValue;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DuckDBTimeTZValue = void 0;
7
+ exports.timeTZValue = timeTZValue;
8
+ const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
9
+ const dateTimeStringConversion_1 = require("../conversion/dateTimeStringConversion");
10
+ class DuckDBTimeTZValue {
11
+ /**
12
+ * 40 bits for micros, then 24 bits for encoded offset in seconds.
13
+ *
14
+ * Max absolute unencoded offset = 15:59:59 = 60 * (60 * 15 + 59) + 59 = 57599.
15
+ *
16
+ * Encoded offset is unencoded offset inverted then shifted (by +57599) to unsigned.
17
+ *
18
+ * Max unencoded offset = 57599 -> -57599 -> 0 encoded.
19
+ *
20
+ * Min unencoded offset = -57599 -> 57599 -> 115198 encoded.
21
+ */
22
+ bits;
23
+ /** Ranges from 0 to 86400000000 (= 24 * 60 * 60 * 1000 * 1000) */
24
+ micros;
25
+ /** In seconds, ranges from -57599 to 57599 (= 16 * 60 * 60 - 1) */
26
+ offset;
27
+ constructor(bits, micros, offset) {
28
+ this.bits = bits;
29
+ this.micros = micros;
30
+ this.offset = offset;
31
+ }
32
+ toString() {
33
+ return `${(0, dateTimeStringConversion_1.getDuckDBTimeStringFromMicrosecondsInDay)(this.micros)}${(0, dateTimeStringConversion_1.getOffsetStringFromSeconds)(this.offset)}`;
34
+ }
35
+ toParts() {
36
+ return node_bindings_1.default.from_time_tz(this);
37
+ }
38
+ static TimeBits = 40;
39
+ static OffsetBits = 24;
40
+ static MaxOffset = 16 * 60 * 60 - 1; // ±15:59:59 = 57599 seconds
41
+ static MinOffset = -DuckDBTimeTZValue.MaxOffset;
42
+ static MaxMicros = 24n * 60n * 60n * 1000n * 1000n; // 86400000000
43
+ static MinMicros = 0n;
44
+ static fromBits(bits) {
45
+ const micros = BigInt.asUintN(DuckDBTimeTZValue.TimeBits, bits >> BigInt(DuckDBTimeTZValue.OffsetBits));
46
+ const offset = DuckDBTimeTZValue.MaxOffset -
47
+ Number(BigInt.asUintN(DuckDBTimeTZValue.OffsetBits, bits));
48
+ return new DuckDBTimeTZValue(bits, micros, offset);
49
+ }
50
+ static fromMicrosAndOffset(micros, offset) {
51
+ const bits = (BigInt.asUintN(DuckDBTimeTZValue.TimeBits, micros) <<
52
+ BigInt(DuckDBTimeTZValue.OffsetBits)) |
53
+ BigInt.asUintN(DuckDBTimeTZValue.OffsetBits, BigInt(DuckDBTimeTZValue.MaxOffset - offset));
54
+ return new DuckDBTimeTZValue(bits, micros, offset);
55
+ }
56
+ static fromParts(parts) {
57
+ return DuckDBTimeTZValue.fromMicrosAndOffset(node_bindings_1.default.to_time(parts.time).micros, parts.offset);
58
+ }
59
+ static Max = DuckDBTimeTZValue.fromMicrosAndOffset(DuckDBTimeTZValue.MaxMicros, DuckDBTimeTZValue.MinOffset);
60
+ static Min = DuckDBTimeTZValue.fromMicrosAndOffset(DuckDBTimeTZValue.MinMicros, DuckDBTimeTZValue.MaxOffset);
61
+ }
62
+ exports.DuckDBTimeTZValue = DuckDBTimeTZValue;
63
+ function timeTZValue(micros, offset) {
64
+ return DuckDBTimeTZValue.fromMicrosAndOffset(micros, offset);
65
+ }