@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.
- package/LICENSE +7 -0
- package/README.md +1224 -0
- package/lib/DuckDBAppender.d.ts +51 -0
- package/lib/DuckDBAppender.js +149 -0
- package/lib/DuckDBBindInfo.d.ts +12 -0
- package/lib/DuckDBBindInfo.js +33 -0
- package/lib/DuckDBClientContext.d.ts +6 -0
- package/lib/DuckDBClientContext.js +17 -0
- package/lib/DuckDBConnection.d.ts +49 -0
- package/lib/DuckDBConnection.js +208 -0
- package/lib/DuckDBDataChunk.d.ts +41 -0
- package/lib/DuckDBDataChunk.js +223 -0
- package/lib/DuckDBExtractedStatements.d.ts +12 -0
- package/lib/DuckDBExtractedStatements.js +31 -0
- package/lib/DuckDBFunctionInfo.d.ts +10 -0
- package/lib/DuckDBFunctionInfo.js +29 -0
- package/lib/DuckDBInstance.d.ts +10 -0
- package/lib/DuckDBInstance.js +30 -0
- package/lib/DuckDBInstanceCache.d.ts +8 -0
- package/lib/DuckDBInstanceCache.js +28 -0
- package/lib/DuckDBLogicalType.d.ts +66 -0
- package/lib/DuckDBLogicalType.js +328 -0
- package/lib/DuckDBMaterializedResult.d.ts +9 -0
- package/lib/DuckDBMaterializedResult.js +24 -0
- package/lib/DuckDBPendingResult.d.ts +18 -0
- package/lib/DuckDBPendingResult.js +60 -0
- package/lib/DuckDBPreparedStatement.d.ts +72 -0
- package/lib/DuckDBPreparedStatement.js +219 -0
- package/lib/DuckDBPreparedStatementCollection.d.ts +4 -0
- package/lib/DuckDBPreparedStatementCollection.js +2 -0
- package/lib/DuckDBPreparedStatementWeakRefCollection.d.ts +9 -0
- package/lib/DuckDBPreparedStatementWeakRefCollection.js +28 -0
- package/lib/DuckDBResult.d.ts +57 -0
- package/lib/DuckDBResult.js +229 -0
- package/lib/DuckDBResultReader.d.ts +68 -0
- package/lib/DuckDBResultReader.js +203 -0
- package/lib/DuckDBScalarFunction.d.ts +33 -0
- package/lib/DuckDBScalarFunction.js +83 -0
- package/lib/DuckDBType.d.ts +373 -0
- package/lib/DuckDBType.js +930 -0
- package/lib/DuckDBTypeId.d.ts +42 -0
- package/lib/DuckDBTypeId.js +47 -0
- package/lib/DuckDBValueConverter.d.ts +3 -0
- package/lib/DuckDBValueConverter.js +2 -0
- package/lib/DuckDBValueConverters.d.ts +47 -0
- package/lib/DuckDBValueConverters.js +214 -0
- package/lib/DuckDBVector.d.ts +596 -0
- package/lib/DuckDBVector.js +2525 -0
- package/lib/JS.d.ts +3 -0
- package/lib/JS.js +2 -0
- package/lib/JSDuckDBValueConverter.d.ts +3 -0
- package/lib/JSDuckDBValueConverter.js +49 -0
- package/lib/Json.d.ts +3 -0
- package/lib/Json.js +2 -0
- package/lib/JsonDuckDBValueConverter.d.ts +3 -0
- package/lib/JsonDuckDBValueConverter.js +49 -0
- package/lib/configurationOptionDescriptions.d.ts +1 -0
- package/lib/configurationOptionDescriptions.js +16 -0
- package/lib/conversion/bytesFromString.d.ts +1 -0
- package/lib/conversion/bytesFromString.js +7 -0
- package/lib/conversion/dateTimeStringConversion.d.ts +20 -0
- package/lib/conversion/dateTimeStringConversion.js +238 -0
- package/lib/conversion/displayStringForDuckDBValue.d.ts +2 -0
- package/lib/conversion/displayStringForDuckDBValue.js +13 -0
- package/lib/conversion/stringFromBlob.d.ts +4 -0
- package/lib/conversion/stringFromBlob.js +45 -0
- package/lib/conversion/stringFromDecimal.d.ts +18 -0
- package/lib/conversion/stringFromDecimal.js +80 -0
- package/lib/convertColumnsFromChunks.d.ts +3 -0
- package/lib/convertColumnsFromChunks.js +16 -0
- package/lib/convertColumnsObjectFromChunks.d.ts +3 -0
- package/lib/convertColumnsObjectFromChunks.js +19 -0
- package/lib/convertRowObjectsFromChunks.d.ts +3 -0
- package/lib/convertRowObjectsFromChunks.js +17 -0
- package/lib/convertRowsFromChunks.d.ts +3 -0
- package/lib/convertRowsFromChunks.js +13 -0
- package/lib/createConfig.d.ts +2 -0
- package/lib/createConfig.js +19 -0
- package/lib/createDuckDBValueConverter.d.ts +3 -0
- package/lib/createDuckDBValueConverter.js +15 -0
- package/lib/createResult.d.ts +3 -0
- package/lib/createResult.js +17 -0
- package/lib/createValue.d.ts +4 -0
- package/lib/createValue.js +222 -0
- package/lib/duckdb.d.ts +33 -0
- package/lib/duckdb.js +54 -0
- package/lib/enums.d.ts +5 -0
- package/lib/enums.js +9 -0
- package/lib/getColumnsFromChunks.d.ts +3 -0
- package/lib/getColumnsFromChunks.js +10 -0
- package/lib/getColumnsObjectFromChunks.d.ts +3 -0
- package/lib/getColumnsObjectFromChunks.js +10 -0
- package/lib/getRowObjectsFromChunks.d.ts +3 -0
- package/lib/getRowObjectsFromChunks.js +10 -0
- package/lib/getRowsFromChunks.d.ts +3 -0
- package/lib/getRowsFromChunks.js +10 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +41 -0
- package/lib/sleep.d.ts +1 -0
- package/lib/sleep.js +8 -0
- package/lib/sql.d.ts +2 -0
- package/lib/sql.js +10 -0
- package/lib/typeForValue.d.ts +3 -0
- package/lib/typeForValue.js +91 -0
- package/lib/values/DuckDBArrayValue.d.ts +7 -0
- package/lib/values/DuckDBArrayValue.js +18 -0
- package/lib/values/DuckDBBitValue.d.ts +16 -0
- package/lib/values/DuckDBBitValue.js +103 -0
- package/lib/values/DuckDBBlobValue.d.ts +8 -0
- package/lib/values/DuckDBBlobValue.js +26 -0
- package/lib/values/DuckDBDateValue.d.ts +16 -0
- package/lib/values/DuckDBDateValue.js +39 -0
- package/lib/values/DuckDBDecimalValue.d.ts +19 -0
- package/lib/values/DuckDBDecimalValue.js +44 -0
- package/lib/values/DuckDBIntervalValue.d.ts +9 -0
- package/lib/values/DuckDBIntervalValue.js +22 -0
- package/lib/values/DuckDBListValue.d.ts +7 -0
- package/lib/values/DuckDBListValue.js +18 -0
- package/lib/values/DuckDBMapValue.d.ts +11 -0
- package/lib/values/DuckDBMapValue.js +18 -0
- package/lib/values/DuckDBStructValue.d.ts +7 -0
- package/lib/values/DuckDBStructValue.js +22 -0
- package/lib/values/DuckDBTimeNSValue.d.ts +9 -0
- package/lib/values/DuckDBTimeNSValue.js +20 -0
- package/lib/values/DuckDBTimeTZValue.d.ts +35 -0
- package/lib/values/DuckDBTimeTZValue.js +65 -0
- package/lib/values/DuckDBTimeValue.d.ts +12 -0
- package/lib/values/DuckDBTimeValue.js +33 -0
- package/lib/values/DuckDBTimestampMillisecondsValue.d.ts +13 -0
- package/lib/values/DuckDBTimestampMillisecondsValue.js +31 -0
- package/lib/values/DuckDBTimestampNanosecondsValue.d.ts +13 -0
- package/lib/values/DuckDBTimestampNanosecondsValue.js +30 -0
- package/lib/values/DuckDBTimestampSecondsValue.d.ts +13 -0
- package/lib/values/DuckDBTimestampSecondsValue.js +30 -0
- package/lib/values/DuckDBTimestampTZValue.d.ts +16 -0
- package/lib/values/DuckDBTimestampTZValue.js +41 -0
- package/lib/values/DuckDBTimestampValue.d.ts +18 -0
- package/lib/values/DuckDBTimestampValue.js +41 -0
- package/lib/values/DuckDBUUIDValue.d.ts +19 -0
- package/lib/values/DuckDBUUIDValue.js +40 -0
- package/lib/values/DuckDBUnionValue.d.ts +8 -0
- package/lib/values/DuckDBUnionValue.js +22 -0
- package/lib/values/DuckDBValue.d.ts +20 -0
- package/lib/values/DuckDBValue.js +2 -0
- package/lib/values/index.d.ts +20 -0
- package/lib/values/index.js +36 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +10 -0
- package/package.json +15 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertRowObjectsFromChunks = convertRowObjectsFromChunks;
|
|
4
|
+
function convertRowObjectsFromChunks(chunks, columnNames, converter) {
|
|
5
|
+
const rowObjects = [];
|
|
6
|
+
for (const chunk of chunks) {
|
|
7
|
+
const rowCount = chunk.rowCount;
|
|
8
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
9
|
+
const rowObject = {};
|
|
10
|
+
chunk.visitRowValues(rowIndex, (value, _rowIndex, columnIndex, type) => {
|
|
11
|
+
rowObject[columnNames[columnIndex]] = converter(value, type, converter);
|
|
12
|
+
});
|
|
13
|
+
rowObjects.push(rowObject);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return rowObjects;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertRowsFromChunks = convertRowsFromChunks;
|
|
4
|
+
function convertRowsFromChunks(chunks, converter) {
|
|
5
|
+
const rows = [];
|
|
6
|
+
for (const chunk of chunks) {
|
|
7
|
+
const rowCount = chunk.rowCount;
|
|
8
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
9
|
+
rows.push(chunk.convertRowValues(rowIndex, converter));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return rows;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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.createConfig = createConfig;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
function createConfig(options) {
|
|
9
|
+
const config = node_bindings_1.default.create_config();
|
|
10
|
+
// Set the default duckdb_api value for the api. Can be overridden.
|
|
11
|
+
node_bindings_1.default.set_config(config, 'duckdb_api', 'node-neo-api');
|
|
12
|
+
if (options) {
|
|
13
|
+
for (const optionName in options) {
|
|
14
|
+
const optionValue = String(options[optionName]);
|
|
15
|
+
node_bindings_1.default.set_config(config, optionName, optionValue);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return config;
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDuckDBValueConverter = createDuckDBValueConverter;
|
|
4
|
+
function createDuckDBValueConverter(convertersByTypeId) {
|
|
5
|
+
return (value, type, converter) => {
|
|
6
|
+
if (value == null) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const converterForTypeId = convertersByTypeId[type.typeId];
|
|
10
|
+
if (!converterForTypeId) {
|
|
11
|
+
throw new Error(`No converter for typeId: ${type.typeId}`);
|
|
12
|
+
}
|
|
13
|
+
return converterForTypeId(value, type, converter);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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.createResult = createResult;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBMaterializedResult_1 = require("./DuckDBMaterializedResult");
|
|
9
|
+
const DuckDBResult_1 = require("./DuckDBResult");
|
|
10
|
+
function createResult(result) {
|
|
11
|
+
if (node_bindings_1.default.result_is_streaming(result)) {
|
|
12
|
+
return new DuckDBResult_1.DuckDBResult(result);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return new DuckDBMaterializedResult_1.DuckDBMaterializedResult(result);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
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.createValue = createValue;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
const DuckDBTypeId_1 = require("./DuckDBTypeId");
|
|
9
|
+
const values_1 = require("./values");
|
|
10
|
+
function createValue(type, input) {
|
|
11
|
+
if (input === null) {
|
|
12
|
+
return node_bindings_1.default.create_null_value();
|
|
13
|
+
}
|
|
14
|
+
const { typeId } = type;
|
|
15
|
+
switch (typeId) {
|
|
16
|
+
case DuckDBTypeId_1.DuckDBTypeId.BOOLEAN:
|
|
17
|
+
if (typeof input === 'boolean') {
|
|
18
|
+
return node_bindings_1.default.create_bool(input);
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`input is not a boolean`);
|
|
21
|
+
case DuckDBTypeId_1.DuckDBTypeId.TINYINT:
|
|
22
|
+
if (typeof input === 'number') {
|
|
23
|
+
return node_bindings_1.default.create_int8(input);
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`input is not a number`);
|
|
26
|
+
case DuckDBTypeId_1.DuckDBTypeId.SMALLINT:
|
|
27
|
+
if (typeof input === 'number') {
|
|
28
|
+
return node_bindings_1.default.create_int16(input);
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`input is not a number`);
|
|
31
|
+
case DuckDBTypeId_1.DuckDBTypeId.INTEGER:
|
|
32
|
+
if (typeof input === 'number') {
|
|
33
|
+
return node_bindings_1.default.create_int32(input);
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`input is not a number`);
|
|
36
|
+
case DuckDBTypeId_1.DuckDBTypeId.BIGINT:
|
|
37
|
+
if (typeof input === 'bigint') {
|
|
38
|
+
return node_bindings_1.default.create_int64(input);
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`input is not a bigint`);
|
|
41
|
+
case DuckDBTypeId_1.DuckDBTypeId.UTINYINT:
|
|
42
|
+
if (typeof input === 'number') {
|
|
43
|
+
return node_bindings_1.default.create_uint8(input);
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`input is not a number`);
|
|
46
|
+
case DuckDBTypeId_1.DuckDBTypeId.USMALLINT:
|
|
47
|
+
if (typeof input === 'number') {
|
|
48
|
+
return node_bindings_1.default.create_uint16(input);
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`input is not a number`);
|
|
51
|
+
case DuckDBTypeId_1.DuckDBTypeId.UINTEGER:
|
|
52
|
+
if (typeof input === 'number') {
|
|
53
|
+
return node_bindings_1.default.create_uint32(input);
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`input is not a number`);
|
|
56
|
+
case DuckDBTypeId_1.DuckDBTypeId.UBIGINT:
|
|
57
|
+
if (typeof input === 'bigint') {
|
|
58
|
+
return node_bindings_1.default.create_uint64(input);
|
|
59
|
+
}
|
|
60
|
+
throw new Error(`input is not a bigint`);
|
|
61
|
+
case DuckDBTypeId_1.DuckDBTypeId.FLOAT:
|
|
62
|
+
if (typeof input === 'number') {
|
|
63
|
+
return node_bindings_1.default.create_float(input);
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`input is not a number`);
|
|
66
|
+
case DuckDBTypeId_1.DuckDBTypeId.DOUBLE:
|
|
67
|
+
if (typeof input === 'number') {
|
|
68
|
+
return node_bindings_1.default.create_double(input);
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`input is not a number`);
|
|
71
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP:
|
|
72
|
+
if (input instanceof values_1.DuckDBTimestampValue) {
|
|
73
|
+
return node_bindings_1.default.create_timestamp(input);
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`input is not a DuckDBTimestampValue`);
|
|
76
|
+
case DuckDBTypeId_1.DuckDBTypeId.DATE:
|
|
77
|
+
if (input instanceof values_1.DuckDBDateValue) {
|
|
78
|
+
return node_bindings_1.default.create_date(input);
|
|
79
|
+
}
|
|
80
|
+
throw new Error(`input is not a DuckDBDateValue`);
|
|
81
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIME:
|
|
82
|
+
if (input instanceof values_1.DuckDBTimeValue) {
|
|
83
|
+
return node_bindings_1.default.create_time(input);
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`input is not a DuckDBTimeValue`);
|
|
86
|
+
case DuckDBTypeId_1.DuckDBTypeId.INTERVAL:
|
|
87
|
+
if (input instanceof values_1.DuckDBIntervalValue) {
|
|
88
|
+
return node_bindings_1.default.create_interval(input);
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`input is not a DuckDBIntervalValue`);
|
|
91
|
+
case DuckDBTypeId_1.DuckDBTypeId.HUGEINT:
|
|
92
|
+
if (typeof input === 'bigint') {
|
|
93
|
+
return node_bindings_1.default.create_hugeint(input);
|
|
94
|
+
}
|
|
95
|
+
throw new Error(`input is not a bigint`);
|
|
96
|
+
case DuckDBTypeId_1.DuckDBTypeId.UHUGEINT:
|
|
97
|
+
if (typeof input === 'bigint') {
|
|
98
|
+
return node_bindings_1.default.create_uhugeint(input);
|
|
99
|
+
}
|
|
100
|
+
throw new Error(`input is not a bigint`);
|
|
101
|
+
case DuckDBTypeId_1.DuckDBTypeId.VARCHAR:
|
|
102
|
+
if (typeof input === 'string') {
|
|
103
|
+
return node_bindings_1.default.create_varchar(input);
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`input is not a string`);
|
|
106
|
+
case DuckDBTypeId_1.DuckDBTypeId.BLOB:
|
|
107
|
+
if (input instanceof values_1.DuckDBBlobValue) {
|
|
108
|
+
return node_bindings_1.default.create_blob(input.bytes);
|
|
109
|
+
}
|
|
110
|
+
throw new Error(`input is not a DuckDBBlobValue`);
|
|
111
|
+
case DuckDBTypeId_1.DuckDBTypeId.DECIMAL:
|
|
112
|
+
if (input instanceof values_1.DuckDBDecimalValue) {
|
|
113
|
+
return node_bindings_1.default.create_decimal(input);
|
|
114
|
+
}
|
|
115
|
+
throw new Error(`input is not a DuckDBDecimalValue`);
|
|
116
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_S:
|
|
117
|
+
if (input instanceof values_1.DuckDBTimestampSecondsValue) {
|
|
118
|
+
return node_bindings_1.default.create_timestamp_s(input);
|
|
119
|
+
}
|
|
120
|
+
throw new Error(`input is not a DuckDBTimestampSecondsValue`);
|
|
121
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_MS:
|
|
122
|
+
if (input instanceof values_1.DuckDBTimestampMillisecondsValue) {
|
|
123
|
+
return node_bindings_1.default.create_timestamp_ms(input);
|
|
124
|
+
}
|
|
125
|
+
throw new Error(`input is not a DuckDBTimestampMillisecondsValue`);
|
|
126
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_NS:
|
|
127
|
+
if (input instanceof values_1.DuckDBTimestampNanosecondsValue) {
|
|
128
|
+
return node_bindings_1.default.create_timestamp_ns(input);
|
|
129
|
+
}
|
|
130
|
+
throw new Error(`input is not a DuckDBTimestampNanosecondsValue`);
|
|
131
|
+
case DuckDBTypeId_1.DuckDBTypeId.ENUM:
|
|
132
|
+
if (typeof input === 'string') {
|
|
133
|
+
return node_bindings_1.default.create_enum_value(type.toLogicalType().logical_type, type.indexForValue(input));
|
|
134
|
+
}
|
|
135
|
+
throw new Error(`input is not a string`);
|
|
136
|
+
case DuckDBTypeId_1.DuckDBTypeId.LIST:
|
|
137
|
+
if (input instanceof values_1.DuckDBListValue) {
|
|
138
|
+
if (type.valueType.typeId === DuckDBTypeId_1.DuckDBTypeId.ANY) {
|
|
139
|
+
throw new Error('Cannot create lists with item type of ANY. Specify a specific type.');
|
|
140
|
+
}
|
|
141
|
+
return node_bindings_1.default.create_list_value(type.valueType.toLogicalType().logical_type, input.items.map((item) => createValue(type.valueType, item)));
|
|
142
|
+
}
|
|
143
|
+
throw new Error(`input is not a DuckDBListValue`);
|
|
144
|
+
case DuckDBTypeId_1.DuckDBTypeId.STRUCT:
|
|
145
|
+
if (input instanceof values_1.DuckDBStructValue) {
|
|
146
|
+
if (type.entryTypes.find((entryType) => entryType.typeId === DuckDBTypeId_1.DuckDBTypeId.ANY)) {
|
|
147
|
+
throw new Error('Cannot create structs with an entry type of ANY. Specify a specific type.');
|
|
148
|
+
}
|
|
149
|
+
return node_bindings_1.default.create_struct_value(type.toLogicalType().logical_type, Object.values(input.entries).map((value, i) => createValue(type.entryTypes[i], value)));
|
|
150
|
+
}
|
|
151
|
+
throw new Error(`input is not a DuckDBStructValue`);
|
|
152
|
+
case DuckDBTypeId_1.DuckDBTypeId.MAP:
|
|
153
|
+
if (input instanceof values_1.DuckDBMapValue) {
|
|
154
|
+
if (type.keyType.typeId === DuckDBTypeId_1.DuckDBTypeId.ANY) {
|
|
155
|
+
throw new Error('Cannot create maps with key type of ANY. Specify a specific type.');
|
|
156
|
+
}
|
|
157
|
+
if (type.valueType.typeId === DuckDBTypeId_1.DuckDBTypeId.ANY) {
|
|
158
|
+
throw new Error('Cannot create maps with value type of ANY. Specify a specific type.');
|
|
159
|
+
}
|
|
160
|
+
return node_bindings_1.default.create_map_value(type.toLogicalType().logical_type, input.entries.map((entry) => createValue(type.keyType, entry.key)), input.entries.map((entry) => createValue(type.valueType, entry.value)));
|
|
161
|
+
}
|
|
162
|
+
throw new Error(`input is not a DuckDBMapValue`);
|
|
163
|
+
case DuckDBTypeId_1.DuckDBTypeId.ARRAY:
|
|
164
|
+
if (input instanceof values_1.DuckDBArrayValue) {
|
|
165
|
+
if (type.valueType.typeId === DuckDBTypeId_1.DuckDBTypeId.ANY) {
|
|
166
|
+
throw new Error('Cannot create arrays with item type of ANY. Specify a specific type.');
|
|
167
|
+
}
|
|
168
|
+
return node_bindings_1.default.create_array_value(type.valueType.toLogicalType().logical_type, input.items.map((item) => createValue(type.valueType, item)));
|
|
169
|
+
}
|
|
170
|
+
throw new Error(`input is not a DuckDBArrayValue`);
|
|
171
|
+
case DuckDBTypeId_1.DuckDBTypeId.UUID:
|
|
172
|
+
if (input instanceof values_1.DuckDBUUIDValue) {
|
|
173
|
+
return node_bindings_1.default.create_uuid(input.toUint128());
|
|
174
|
+
}
|
|
175
|
+
throw new Error(`input is not a bigint`);
|
|
176
|
+
case DuckDBTypeId_1.DuckDBTypeId.UNION:
|
|
177
|
+
if (input instanceof values_1.DuckDBUnionValue) {
|
|
178
|
+
const tagIndex = type.memberIndexForTag(input.tag);
|
|
179
|
+
const memberType = type.memberTypes[tagIndex];
|
|
180
|
+
if (memberType.typeId === DuckDBTypeId_1.DuckDBTypeId.ANY) {
|
|
181
|
+
throw new Error('Cannot create union values with type of ANY.');
|
|
182
|
+
}
|
|
183
|
+
return node_bindings_1.default.create_union_value(type.toLogicalType().logical_type, tagIndex, createValue(memberType, input.value));
|
|
184
|
+
}
|
|
185
|
+
throw new Error(`input is not a DuckDBUnionValue`);
|
|
186
|
+
case DuckDBTypeId_1.DuckDBTypeId.BIT:
|
|
187
|
+
if (input instanceof values_1.DuckDBBitValue) {
|
|
188
|
+
return node_bindings_1.default.create_bit(input.data);
|
|
189
|
+
}
|
|
190
|
+
throw new Error(`input is not a DuckDBBitValue`);
|
|
191
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIME_TZ:
|
|
192
|
+
if (input instanceof values_1.DuckDBTimeTZValue) {
|
|
193
|
+
return node_bindings_1.default.create_time_tz_value(input);
|
|
194
|
+
}
|
|
195
|
+
throw new Error(`input is not a DuckDBTimeTZValue`);
|
|
196
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIMESTAMP_TZ:
|
|
197
|
+
if (input instanceof values_1.DuckDBTimestampTZValue) {
|
|
198
|
+
return node_bindings_1.default.create_timestamp_tz(input);
|
|
199
|
+
}
|
|
200
|
+
throw new Error(`input is not a DuckDBTimestampTZValue`);
|
|
201
|
+
case DuckDBTypeId_1.DuckDBTypeId.ANY:
|
|
202
|
+
throw new Error(`Cannot create values of type ANY. Specify a specific type.`);
|
|
203
|
+
case DuckDBTypeId_1.DuckDBTypeId.BIGNUM:
|
|
204
|
+
if (typeof input === 'bigint') {
|
|
205
|
+
return node_bindings_1.default.create_bignum(input);
|
|
206
|
+
}
|
|
207
|
+
throw new Error(`input is not a bigint`);
|
|
208
|
+
case DuckDBTypeId_1.DuckDBTypeId.SQLNULL:
|
|
209
|
+
return node_bindings_1.default.create_null_value();
|
|
210
|
+
case DuckDBTypeId_1.DuckDBTypeId.STRING_LITERAL:
|
|
211
|
+
throw new Error(`Cannot create values of type STRING_LITERAL.`);
|
|
212
|
+
case DuckDBTypeId_1.DuckDBTypeId.INTEGER_LITERAL:
|
|
213
|
+
throw new Error(`Cannot create values of type INTEGER_LITERAL.`);
|
|
214
|
+
case DuckDBTypeId_1.DuckDBTypeId.TIME_NS:
|
|
215
|
+
if (input instanceof values_1.DuckDBTimeNSValue) {
|
|
216
|
+
return node_bindings_1.default.create_time_ns(input);
|
|
217
|
+
}
|
|
218
|
+
throw new Error(`input is not a DuckDBTimeNSValue`);
|
|
219
|
+
default:
|
|
220
|
+
throw new Error(`unrecognized type id ${typeId}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
package/lib/duckdb.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { double_to_hugeint, double_to_uhugeint, hugeint_to_double, uhugeint_to_double } from '@haybarn/node-bindings';
|
|
2
|
+
export * from './configurationOptionDescriptions';
|
|
3
|
+
export * from './createDuckDBValueConverter';
|
|
4
|
+
export * from './DuckDBAppender';
|
|
5
|
+
export * from './DuckDBBindInfo';
|
|
6
|
+
export * from './DuckDBClientContext';
|
|
7
|
+
export * from './DuckDBConnection';
|
|
8
|
+
export * from './DuckDBDataChunk';
|
|
9
|
+
export * from './DuckDBExtractedStatements';
|
|
10
|
+
export * from './DuckDBFunctionInfo';
|
|
11
|
+
export * from './DuckDBInstance';
|
|
12
|
+
export * from './DuckDBInstanceCache';
|
|
13
|
+
export * from './DuckDBLogicalType';
|
|
14
|
+
export * from './DuckDBMaterializedResult';
|
|
15
|
+
export * from './DuckDBPendingResult';
|
|
16
|
+
export * from './DuckDBPreparedStatement';
|
|
17
|
+
export * from './DuckDBPreparedStatementCollection';
|
|
18
|
+
export * from './DuckDBResult';
|
|
19
|
+
export * from './DuckDBResultReader';
|
|
20
|
+
export * from './DuckDBScalarFunction';
|
|
21
|
+
export * from './DuckDBType';
|
|
22
|
+
export * from './DuckDBTypeId';
|
|
23
|
+
export * from './DuckDBValueConverter';
|
|
24
|
+
export * from './DuckDBValueConverters';
|
|
25
|
+
export * from './DuckDBVector';
|
|
26
|
+
export * from './enums';
|
|
27
|
+
export * from './JS';
|
|
28
|
+
export * from './JSDuckDBValueConverter';
|
|
29
|
+
export * from './Json';
|
|
30
|
+
export * from './JsonDuckDBValueConverter';
|
|
31
|
+
export * from './sql';
|
|
32
|
+
export * from './values';
|
|
33
|
+
export * from './version';
|
package/lib/duckdb.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
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);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.uhugeint_to_double = exports.hugeint_to_double = exports.double_to_uhugeint = exports.double_to_hugeint = void 0;
|
|
18
|
+
var node_bindings_1 = require("@haybarn/node-bindings");
|
|
19
|
+
Object.defineProperty(exports, "double_to_hugeint", { enumerable: true, get: function () { return node_bindings_1.double_to_hugeint; } });
|
|
20
|
+
Object.defineProperty(exports, "double_to_uhugeint", { enumerable: true, get: function () { return node_bindings_1.double_to_uhugeint; } });
|
|
21
|
+
Object.defineProperty(exports, "hugeint_to_double", { enumerable: true, get: function () { return node_bindings_1.hugeint_to_double; } });
|
|
22
|
+
Object.defineProperty(exports, "uhugeint_to_double", { enumerable: true, get: function () { return node_bindings_1.uhugeint_to_double; } });
|
|
23
|
+
__exportStar(require("./configurationOptionDescriptions"), exports);
|
|
24
|
+
__exportStar(require("./createDuckDBValueConverter"), exports);
|
|
25
|
+
__exportStar(require("./DuckDBAppender"), exports);
|
|
26
|
+
__exportStar(require("./DuckDBBindInfo"), exports);
|
|
27
|
+
__exportStar(require("./DuckDBClientContext"), exports);
|
|
28
|
+
__exportStar(require("./DuckDBConnection"), exports);
|
|
29
|
+
__exportStar(require("./DuckDBDataChunk"), exports);
|
|
30
|
+
__exportStar(require("./DuckDBExtractedStatements"), exports);
|
|
31
|
+
__exportStar(require("./DuckDBFunctionInfo"), exports);
|
|
32
|
+
__exportStar(require("./DuckDBInstance"), exports);
|
|
33
|
+
__exportStar(require("./DuckDBInstanceCache"), exports);
|
|
34
|
+
__exportStar(require("./DuckDBLogicalType"), exports);
|
|
35
|
+
__exportStar(require("./DuckDBMaterializedResult"), exports);
|
|
36
|
+
__exportStar(require("./DuckDBPendingResult"), exports);
|
|
37
|
+
__exportStar(require("./DuckDBPreparedStatement"), exports);
|
|
38
|
+
__exportStar(require("./DuckDBPreparedStatementCollection"), exports);
|
|
39
|
+
__exportStar(require("./DuckDBResult"), exports);
|
|
40
|
+
__exportStar(require("./DuckDBResultReader"), exports);
|
|
41
|
+
__exportStar(require("./DuckDBScalarFunction"), exports);
|
|
42
|
+
__exportStar(require("./DuckDBType"), exports);
|
|
43
|
+
__exportStar(require("./DuckDBTypeId"), exports);
|
|
44
|
+
__exportStar(require("./DuckDBValueConverter"), exports);
|
|
45
|
+
__exportStar(require("./DuckDBValueConverters"), exports);
|
|
46
|
+
__exportStar(require("./DuckDBVector"), exports);
|
|
47
|
+
__exportStar(require("./enums"), exports);
|
|
48
|
+
__exportStar(require("./JS"), exports);
|
|
49
|
+
__exportStar(require("./JSDuckDBValueConverter"), exports);
|
|
50
|
+
__exportStar(require("./Json"), exports);
|
|
51
|
+
__exportStar(require("./JsonDuckDBValueConverter"), exports);
|
|
52
|
+
__exportStar(require("./sql"), exports);
|
|
53
|
+
__exportStar(require("./values"), exports);
|
|
54
|
+
__exportStar(require("./version"), exports);
|
package/lib/enums.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import duckdb from '@haybarn/node-bindings';
|
|
2
|
+
export type ResultReturnType = duckdb.ResultType;
|
|
3
|
+
export declare const ResultReturnType: typeof duckdb.ResultType;
|
|
4
|
+
export type StatementType = duckdb.StatementType;
|
|
5
|
+
export declare const StatementType: typeof duckdb.StatementType;
|
package/lib/enums.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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.StatementType = exports.ResultReturnType = void 0;
|
|
7
|
+
const node_bindings_1 = __importDefault(require("@haybarn/node-bindings"));
|
|
8
|
+
exports.ResultReturnType = node_bindings_1.default.ResultType;
|
|
9
|
+
exports.StatementType = node_bindings_1.default.StatementType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getColumnsFromChunks = getColumnsFromChunks;
|
|
4
|
+
function getColumnsFromChunks(chunks) {
|
|
5
|
+
const columns = [];
|
|
6
|
+
for (const chunk of chunks) {
|
|
7
|
+
chunk.appendToColumns(columns);
|
|
8
|
+
}
|
|
9
|
+
return columns;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getColumnsObjectFromChunks = getColumnsObjectFromChunks;
|
|
4
|
+
function getColumnsObjectFromChunks(chunks, columnNames) {
|
|
5
|
+
const columnsObject = {};
|
|
6
|
+
for (const chunk of chunks) {
|
|
7
|
+
chunk.appendToColumnsObject(columnNames, columnsObject);
|
|
8
|
+
}
|
|
9
|
+
return columnsObject;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRowObjectsFromChunks = getRowObjectsFromChunks;
|
|
4
|
+
function getRowObjectsFromChunks(chunks, columnNames) {
|
|
5
|
+
const rowObjects = [];
|
|
6
|
+
for (const chunk of chunks) {
|
|
7
|
+
chunk.appendToRowObjects(columnNames, rowObjects);
|
|
8
|
+
}
|
|
9
|
+
return rowObjects;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRowsFromChunks = getRowsFromChunks;
|
|
4
|
+
function getRowsFromChunks(chunks) {
|
|
5
|
+
const rows = [];
|
|
6
|
+
for (const chunk of chunks) {
|
|
7
|
+
chunk.appendToRows(rows);
|
|
8
|
+
}
|
|
9
|
+
return rows;
|
|
10
|
+
}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const duckdb = __importStar(require("./duckdb"));
|
|
40
|
+
exports.default = duckdb;
|
|
41
|
+
__exportStar(require("./duckdb"), exports);
|
package/lib/sleep.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(ms: number): Promise<unknown>;
|
package/lib/sleep.js
ADDED
package/lib/sql.d.ts
ADDED
package/lib/sql.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quotedString = quotedString;
|
|
4
|
+
exports.quotedIdentifier = quotedIdentifier;
|
|
5
|
+
function quotedString(input) {
|
|
6
|
+
return `'${input.replaceAll(`'`, `''`)}'`;
|
|
7
|
+
}
|
|
8
|
+
function quotedIdentifier(input) {
|
|
9
|
+
return `"${input.replaceAll(`"`, `""`)}"`;
|
|
10
|
+
}
|