@clickhouse/client 0.3.1 → 0.100.1
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 +2 -2
- package/README.md +14 -0
- package/dist/client.d.ts +11 -26
- package/dist/client.js +11 -53
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +52 -0
- package/dist/config.js +80 -0
- package/dist/config.js.map +1 -0
- package/dist/connection/compression.d.ts +4 -3
- package/dist/connection/compression.js +7 -5
- package/dist/connection/compression.js.map +1 -1
- package/dist/connection/create_connection.d.ts +16 -0
- package/dist/connection/create_connection.js +42 -0
- package/dist/connection/create_connection.js.map +1 -0
- package/dist/connection/index.d.ts +1 -0
- package/dist/connection/index.js +1 -0
- package/dist/connection/index.js.map +1 -1
- package/dist/connection/node_base_connection.d.ts +23 -12
- package/dist/connection/node_base_connection.js +428 -227
- package/dist/connection/node_base_connection.js.map +1 -1
- package/dist/connection/node_custom_agent_connection.d.ts +8 -0
- package/dist/connection/node_custom_agent_connection.js +47 -0
- package/dist/connection/node_custom_agent_connection.js.map +1 -0
- package/dist/connection/node_http_connection.d.ts +1 -5
- package/dist/connection/node_http_connection.js +6 -5
- package/dist/connection/node_http_connection.js.map +1 -1
- package/dist/connection/node_https_connection.d.ts +3 -6
- package/dist/connection/node_https_connection.js +39 -19
- package/dist/connection/node_https_connection.js.map +1 -1
- package/dist/connection/stream.d.ts +3 -2
- package/dist/connection/stream.js +4 -3
- package/dist/connection/stream.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/result_set.d.ts +41 -6
- package/dist/result_set.js +133 -51
- package/dist/result_set.js.map +1 -1
- package/dist/utils/encoder.d.ts +3 -2
- package/dist/utils/encoder.js +16 -3
- package/dist/utils/encoder.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/process.js +1 -2
- package/dist/utils/process.js.map +1 -1
- package/dist/utils/runtime.d.ts +6 -0
- package/dist/utils/runtime.js +65 -0
- package/dist/utils/runtime.js.map +1 -0
- package/dist/utils/stream.d.ts +1 -2
- package/dist/utils/stream.js +23 -9
- package/dist/utils/stream.js.map +1 -1
- package/dist/utils/user_agent.d.ts +4 -0
- package/dist/utils/user_agent.js +7 -31
- package/dist/utils/user_agent.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +10 -3
package/dist/result_set.js
CHANGED
|
@@ -15,22 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
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
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.ResultSet = void 0;
|
|
27
37
|
const client_common_1 = require("@clickhouse/client-common");
|
|
38
|
+
const client_common_2 = require("@clickhouse/client-common");
|
|
28
39
|
const buffer_1 = require("buffer");
|
|
29
40
|
const stream_1 = __importStar(require("stream"));
|
|
30
41
|
const utils_1 = require("./utils");
|
|
31
42
|
const NEWLINE = 0x0a;
|
|
32
43
|
class ResultSet {
|
|
33
|
-
constructor(_stream, format, query_id) {
|
|
44
|
+
constructor(_stream, format, query_id, log_error, _response_headers, jsonHandling) {
|
|
34
45
|
Object.defineProperty(this, "_stream", {
|
|
35
46
|
enumerable: true,
|
|
36
47
|
configurable: true,
|
|
@@ -49,19 +60,73 @@ class ResultSet {
|
|
|
49
60
|
writable: true,
|
|
50
61
|
value: query_id
|
|
51
62
|
});
|
|
63
|
+
Object.defineProperty(this, "response_headers", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: {}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(this, "exceptionTag", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
configurable: true,
|
|
72
|
+
writable: true,
|
|
73
|
+
value: undefined
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(this, "log_error", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
configurable: true,
|
|
78
|
+
writable: true,
|
|
79
|
+
value: void 0
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(this, "jsonHandling", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
configurable: true,
|
|
84
|
+
writable: true,
|
|
85
|
+
value: void 0
|
|
86
|
+
});
|
|
87
|
+
this.jsonHandling = {
|
|
88
|
+
...client_common_1.defaultJSONHandling,
|
|
89
|
+
...jsonHandling,
|
|
90
|
+
};
|
|
91
|
+
// eslint-disable-next-line no-console
|
|
92
|
+
this.log_error = log_error ?? ((err) => console.error(err));
|
|
93
|
+
if (_response_headers !== undefined) {
|
|
94
|
+
this.response_headers = Object.freeze(_response_headers);
|
|
95
|
+
this.exceptionTag = _response_headers[client_common_1.EXCEPTION_TAG_HEADER_NAME];
|
|
96
|
+
}
|
|
52
97
|
}
|
|
98
|
+
/** See {@link BaseResultSet.text}. */
|
|
53
99
|
async text() {
|
|
54
100
|
if (this._stream.readableEnded) {
|
|
55
101
|
throw Error(streamAlreadyConsumedMessage);
|
|
56
102
|
}
|
|
57
103
|
return (await (0, utils_1.getAsText)(this._stream)).toString();
|
|
58
104
|
}
|
|
105
|
+
/** See {@link BaseResultSet.json}. */
|
|
59
106
|
async json() {
|
|
60
107
|
if (this._stream.readableEnded) {
|
|
61
108
|
throw Error(streamAlreadyConsumedMessage);
|
|
62
109
|
}
|
|
63
|
-
|
|
110
|
+
// JSONEachRow, etc.
|
|
111
|
+
if ((0, client_common_2.isStreamableJSONFamily)(this.format)) {
|
|
112
|
+
const result = [];
|
|
113
|
+
const stream = this.stream();
|
|
114
|
+
for await (const rows of stream) {
|
|
115
|
+
for (const row of rows) {
|
|
116
|
+
result.push(row.json());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
// JSON, JSONObjectEachRow, etc.
|
|
122
|
+
if ((0, client_common_2.isNotStreamableJSONFamily)(this.format)) {
|
|
123
|
+
const text = await (0, utils_1.getAsText)(this._stream);
|
|
124
|
+
return this.jsonHandling.parse(text);
|
|
125
|
+
}
|
|
126
|
+
// should not be called for CSV, etc.
|
|
127
|
+
throw new Error(`Cannot decode ${this.format} as JSON`);
|
|
64
128
|
}
|
|
129
|
+
/** See {@link BaseResultSet.stream}. */
|
|
65
130
|
stream() {
|
|
66
131
|
// If the underlying stream has already ended by calling `text` or `json`,
|
|
67
132
|
// Stream.pipeline will create a new empty stream
|
|
@@ -69,70 +134,87 @@ class ResultSet {
|
|
|
69
134
|
if (this._stream.readableEnded) {
|
|
70
135
|
throw Error(streamAlreadyConsumedMessage);
|
|
71
136
|
}
|
|
72
|
-
(0,
|
|
73
|
-
|
|
137
|
+
(0, client_common_2.validateStreamFormat)(this.format);
|
|
138
|
+
const incompleteChunks = [];
|
|
139
|
+
const logError = this.log_error;
|
|
140
|
+
const exceptionTag = this.exceptionTag;
|
|
141
|
+
const jsonHandling = this.jsonHandling;
|
|
74
142
|
const toRows = new stream_1.Transform({
|
|
75
143
|
transform(chunk, _encoding, callback) {
|
|
76
144
|
const rows = [];
|
|
77
145
|
let lastIdx = 0;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
146
|
+
let currentChunkPart;
|
|
147
|
+
while (true) {
|
|
148
|
+
// an unescaped newline character denotes the end of a row,
|
|
149
|
+
// or at least the beginning of the exception marker
|
|
150
|
+
const idx = chunk.indexOf(NEWLINE, lastIdx);
|
|
151
|
+
if (idx === -1) {
|
|
152
|
+
incompleteChunks.push(chunk.subarray(lastIdx));
|
|
153
|
+
if (rows.length > 0) {
|
|
154
|
+
this.push(rows);
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
86
157
|
}
|
|
87
158
|
else {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
idx = chunk.indexOf(NEWLINE, lastIdx);
|
|
101
|
-
if (idx !== -1) {
|
|
102
|
-
const text = chunk.subarray(lastIdx, idx).toString();
|
|
103
|
-
rows.push({
|
|
104
|
-
text,
|
|
105
|
-
json() {
|
|
106
|
-
return JSON.parse(text);
|
|
107
|
-
},
|
|
108
|
-
});
|
|
159
|
+
// Check for exception in the chunk (only after 25.11)
|
|
160
|
+
if (exceptionTag !== undefined &&
|
|
161
|
+
idx >= 1 &&
|
|
162
|
+
chunk[idx - 1] === client_common_1.CARET_RETURN) {
|
|
163
|
+
return callback((0, client_common_1.extractErrorAtTheEndOfChunk)(chunk, exceptionTag));
|
|
164
|
+
}
|
|
165
|
+
if (incompleteChunks.length > 0) {
|
|
166
|
+
incompleteChunks.push(chunk.subarray(lastIdx, idx));
|
|
167
|
+
currentChunkPart = buffer_1.Buffer.concat(incompleteChunks);
|
|
168
|
+
// Removing used buffers and reusing the already allocated memory
|
|
169
|
+
// by setting length to 0
|
|
170
|
+
incompleteChunks.length = 0;
|
|
109
171
|
}
|
|
110
172
|
else {
|
|
111
|
-
|
|
112
|
-
incompleteChunks.push(chunk.subarray(lastIdx));
|
|
113
|
-
this.push(rows);
|
|
173
|
+
currentChunkPart = chunk.subarray(lastIdx, idx);
|
|
114
174
|
}
|
|
175
|
+
const text = currentChunkPart.toString();
|
|
176
|
+
rows.push({
|
|
177
|
+
text,
|
|
178
|
+
json() {
|
|
179
|
+
return jsonHandling.parse(text);
|
|
180
|
+
},
|
|
181
|
+
});
|
|
115
182
|
lastIdx = idx + 1; // skipping newline character
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
incompleteChunks.push(chunk); // this chunk does not contain a full row
|
|
183
|
+
}
|
|
120
184
|
}
|
|
121
185
|
callback();
|
|
122
186
|
},
|
|
123
187
|
autoDestroy: true,
|
|
124
188
|
objectMode: true,
|
|
125
189
|
});
|
|
126
|
-
|
|
127
|
-
if (err
|
|
128
|
-
|
|
190
|
+
const pipeline = stream_1.default.pipeline(this._stream, toRows, function pipelineCb(err) {
|
|
191
|
+
if (err &&
|
|
192
|
+
err.name !== 'AbortError' &&
|
|
193
|
+
err.message !== resultSetClosedMessage) {
|
|
194
|
+
logError(err);
|
|
129
195
|
}
|
|
130
196
|
});
|
|
197
|
+
return pipeline;
|
|
131
198
|
}
|
|
199
|
+
/** See {@link BaseResultSet.close}. */
|
|
132
200
|
close() {
|
|
133
|
-
this._stream.destroy();
|
|
201
|
+
this._stream.destroy(new Error(resultSetClosedMessage));
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Closes the `ResultSet`.
|
|
205
|
+
*
|
|
206
|
+
* Automatically called when using `using` statement in supported environments.
|
|
207
|
+
* @see {@link ResultSet.close}
|
|
208
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using
|
|
209
|
+
*/
|
|
210
|
+
[Symbol.dispose]() {
|
|
211
|
+
this.close();
|
|
212
|
+
}
|
|
213
|
+
static instance({ stream, format, query_id, log_error, response_headers, jsonHandling, }) {
|
|
214
|
+
return new ResultSet(stream, format, query_id, log_error, response_headers, jsonHandling);
|
|
134
215
|
}
|
|
135
216
|
}
|
|
136
217
|
exports.ResultSet = ResultSet;
|
|
137
218
|
const streamAlreadyConsumedMessage = 'Stream has been already consumed';
|
|
219
|
+
const resultSetClosedMessage = 'ResultSet has been closed';
|
|
138
220
|
//# sourceMappingURL=result_set.js.map
|
package/dist/result_set.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result_set.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"result_set.js","sourceRoot":"","sources":["../src/result_set.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,6DAKkC;AAClC,6DAIkC;AAClC,mCAA+B;AAE/B,iDAA0C;AAC1C,mCAAmC;AAEnC,MAAM,OAAO,GAAG,IAAa,CAAA;AAoC7B,MAAa,SAAS;IASpB,YACU,OAAwB,EACf,MAAc,EACf,QAAgB,EAChC,SAAkC,EAClC,iBAAmC,EACnC,YAA2B;QAL3B;;;;mBAAQ,OAAO;WAAiB;QAChC;;;;mBAAiB,MAAM;WAAQ;QAC/B;;;;mBAAgB,QAAQ;WAAQ;QATlB;;;;mBAAoC,EAAE;WAAA;QAErC;;;;mBAAmC,SAAS;WAAA;QAC5C;;;;;WAAiC;QACjC;;;;;WAA0B;QAUzC,IAAI,CAAC,YAAY,GAAG;YAClB,GAAG,mCAAmB;YACtB,GAAG,YAAY;SAChB,CAAA;QACD,sCAAsC;QACtC,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,GAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAA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AG,CAAC,CAAA;YACf,CAAC;QACH,CAAC,CACF,CAAA;QACD,OAAO,QAAe,CAAA;IACxB,CAAC;IAED,uCAAuC;IACvC,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAA;IACzD,CAAC;IAED;;;;;;OAMG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;IAED,MAAM,CAAC,QAAQ,CAA4B,EACzC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,YAAY,GACa;QACzB,OAAO,IAAI,SAAS,CAClB,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,YAAY,CACb,CAAA;IACH,CAAC;CACF;AA1LD,8BA0LC;AAED,MAAM,4BAA4B,GAAG,kCAAkC,CAAA;AACvE,MAAM,sBAAsB,GAAG,2BAA2B,CAAA"}
|
package/dist/utils/encoder.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import type { DataFormat, InsertValues, ValuesEncoder } from '@clickhouse/client-common';
|
|
1
|
+
import type { DataFormat, InsertValues, JSONHandling, ValuesEncoder } from '@clickhouse/client-common';
|
|
3
2
|
import Stream from 'stream';
|
|
4
3
|
export declare class NodeValuesEncoder implements ValuesEncoder<Stream.Readable> {
|
|
4
|
+
private readonly json;
|
|
5
|
+
constructor(customJSONConfig: JSONHandling);
|
|
5
6
|
encodeValues<T>(values: InsertValues<Stream.Readable, T>, format: DataFormat): string | Stream.Readable;
|
|
6
7
|
validateInsertValues<T>(values: InsertValues<Stream.Readable, T>, format: DataFormat): void;
|
|
7
8
|
}
|
package/dist/utils/encoder.js
CHANGED
|
@@ -8,6 +8,15 @@ const client_common_1 = require("@clickhouse/client-common");
|
|
|
8
8
|
const stream_1 = __importDefault(require("stream"));
|
|
9
9
|
const stream_2 = require("./stream");
|
|
10
10
|
class NodeValuesEncoder {
|
|
11
|
+
constructor(customJSONConfig) {
|
|
12
|
+
Object.defineProperty(this, "json", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
this.json = customJSONConfig;
|
|
19
|
+
}
|
|
11
20
|
encodeValues(values, format) {
|
|
12
21
|
if ((0, stream_2.isStream)(values)) {
|
|
13
22
|
// TSV/CSV/CustomSeparated formats don't require additional serialization
|
|
@@ -15,15 +24,17 @@ class NodeValuesEncoder {
|
|
|
15
24
|
return values;
|
|
16
25
|
}
|
|
17
26
|
// JSON* formats streams
|
|
18
|
-
return stream_1.default.pipeline(values, (0, stream_2.mapStream)((value) => (0, client_common_1.encodeJSON)(value, format)), pipelineCb);
|
|
27
|
+
return stream_1.default.pipeline(values, (0, stream_2.mapStream)((value) => (0, client_common_1.encodeJSON)(value, format, this.json.stringify)), pipelineCb);
|
|
19
28
|
}
|
|
20
29
|
// JSON* arrays
|
|
21
30
|
if (Array.isArray(values)) {
|
|
22
|
-
return values
|
|
31
|
+
return values
|
|
32
|
+
.map((value) => (0, client_common_1.encodeJSON)(value, format, this.json.stringify))
|
|
33
|
+
.join('');
|
|
23
34
|
}
|
|
24
35
|
// JSON & JSONObjectEachRow format input
|
|
25
36
|
if (typeof values === 'object') {
|
|
26
|
-
return (0, client_common_1.encodeJSON)(values, format);
|
|
37
|
+
return (0, client_common_1.encodeJSON)(values, format, this.json.stringify);
|
|
27
38
|
}
|
|
28
39
|
throw new Error(`Cannot encode values of type ${typeof values} with ${format} format`);
|
|
29
40
|
}
|
|
@@ -49,6 +60,8 @@ class NodeValuesEncoder {
|
|
|
49
60
|
exports.NodeValuesEncoder = NodeValuesEncoder;
|
|
50
61
|
function pipelineCb(err) {
|
|
51
62
|
if (err) {
|
|
63
|
+
// FIXME: use logger instead
|
|
64
|
+
// eslint-disable-next-line no-console
|
|
52
65
|
console.error(err);
|
|
53
66
|
}
|
|
54
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/utils/encoder.ts"],"names":[],"mappings":";;;;;;AAMA,6DAA4E;AAC5E,oDAA2B;AAC3B,qCAA8C;AAE9C,MAAa,iBAAiB;IAG5B,YAAY,gBAA8B;QAFzB;;;;;WAAkB;QAGjC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;IAED,YAAY,CACV,MAAwC,EACxC,MAAkB;QAElB,IAAI,IAAA,iBAAQ,EAAC,MAAM,CAAC,EAAE,CAAC;YACrB,yEAAyE;YACzE,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;gBAC/B,OAAO,MAAM,CAAA;YACf,CAAC;YACD,wBAAwB;YACxB,OAAO,gBAAM,CAAC,QAAQ,CACpB,MAAM,EACN,IAAA,kBAAS,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,0BAAU,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EACpE,UAAU,CACX,CAAA;QACH,CAAC;QACD,eAAe;QACf,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,MAAM;iBACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,0BAAU,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBAC9D,IAAI,CAAC,EAAE,CAAC,CAAA;QACb,CAAC;QACD,wCAAwC;QACxC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,IAAA,0BAAU,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACxD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,gCAAgC,OAAO,MAAM,SAAS,MAAM,SAAS,CACtE,CAAA;IACH,CAAC;IAED,oBAAoB,CAClB,MAAwC,EACxC,MAAkB;QAElB,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACtB,CAAC,IAAA,iBAAQ,EAAC,MAAM,CAAC;YACjB,OAAO,MAAM,KAAK,QAAQ,EAC1B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,gFAAgF;gBAC9E,QAAQ,OAAO,MAAM,EAAE,CAC1B,CAAA;QACH,CAAC;QAED,IAAI,IAAA,iBAAQ,EAAC,MAAM,CAAC,EAAE,CAAC;YACrB,IAAI,IAAA,oCAAoB,EAAC,MAAM,CAAC,EAAE,CAAC;gBACjC,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;oBAC9B,MAAM,IAAI,KAAK,CACb,cAAc,MAAM,sDAAsD,CAC3E,CAAA;gBACH,CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;gBACtC,MAAM,IAAI,KAAK,CACb,cAAc,MAAM,qDAAqD,CAC1E,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAnED,8CAmEC;AAED,SAAS,UAAU,CAAC,GAAiC;IACnD,IAAI,GAAG,EAAE,CAAC;QACR,4BAA4B;QAC5B,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;AACH,CAAC"}
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,4CAAyB;AACzB,4CAAyB;AACzB,+CAA4B"}
|
package/dist/utils/process.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProcessVersion =
|
|
3
|
+
exports.getProcessVersion = getProcessVersion;
|
|
4
4
|
// for easy mocking in the tests
|
|
5
5
|
function getProcessVersion() {
|
|
6
6
|
return process.version;
|
|
7
7
|
}
|
|
8
|
-
exports.getProcessVersion = getProcessVersion;
|
|
9
8
|
//# sourceMappingURL=process.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":";;AACA,8CAEC;AAHD,gCAAgC;AAChC,SAAgB,iBAAiB;IAC/B,OAAO,OAAO,CAAC,OAAO,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Runtime = void 0;
|
|
40
|
+
const os = __importStar(require("node:os"));
|
|
41
|
+
const version_1 = __importDefault(require("../version"));
|
|
42
|
+
/** Indirect export of package version and node version for easier mocking since Node.js 22.18 */
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
44
|
+
class Runtime {
|
|
45
|
+
}
|
|
46
|
+
exports.Runtime = Runtime;
|
|
47
|
+
Object.defineProperty(Runtime, "package", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: version_1.default
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(Runtime, "node", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: process.version
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(Runtime, "os", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
value: os.platform()
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/utils/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA6B;AAC7B,yDAAuC;AAEvC,iGAAiG;AACjG,kEAAkE;AAClE,MAAa,OAAO;;AAApB,0BAIC;AAHQ;;;;WAAU,iBAAc;GAAA;AACxB;;;;WAAO,OAAO,CAAC,OAAO;GAAA;AACtB;;;;WAAK,EAAE,CAAC,QAAQ,EAAE;GAAA"}
|
package/dist/utils/stream.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import Stream from 'stream';
|
|
3
|
-
export declare function isStream(obj:
|
|
2
|
+
export declare function isStream(obj: unknown): obj is Stream.Readable;
|
|
4
3
|
export declare function getAsText(stream: Stream.Readable): Promise<string>;
|
|
5
4
|
export declare function mapStream(mapper: (input: unknown) => string): Stream.Transform;
|
package/dist/utils/stream.js
CHANGED
|
@@ -3,23 +3,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.isStream = isStream;
|
|
7
|
+
exports.getAsText = getAsText;
|
|
8
|
+
exports.mapStream = mapStream;
|
|
7
9
|
const stream_1 = __importDefault(require("stream"));
|
|
10
|
+
const buffer_1 = require("buffer");
|
|
11
|
+
const { MAX_STRING_LENGTH } = buffer_1.constants;
|
|
8
12
|
function isStream(obj) {
|
|
9
|
-
return
|
|
13
|
+
return (typeof obj === 'object' &&
|
|
14
|
+
obj !== null &&
|
|
15
|
+
'pipe' in obj &&
|
|
16
|
+
typeof obj.pipe === 'function' &&
|
|
17
|
+
'on' in obj &&
|
|
18
|
+
typeof obj.on === 'function');
|
|
10
19
|
}
|
|
11
|
-
exports.isStream = isStream;
|
|
12
20
|
async function getAsText(stream) {
|
|
13
|
-
let
|
|
21
|
+
let text = '';
|
|
14
22
|
const textDecoder = new TextDecoder();
|
|
15
23
|
for await (const chunk of stream) {
|
|
16
|
-
|
|
24
|
+
const decoded = textDecoder.decode(chunk, { stream: true });
|
|
25
|
+
if (decoded.length + text.length > MAX_STRING_LENGTH) {
|
|
26
|
+
throw new Error('The response length exceeds the maximum allowed size of V8 String: ' +
|
|
27
|
+
`${MAX_STRING_LENGTH}; consider limiting the amount of requested rows.`);
|
|
28
|
+
}
|
|
29
|
+
text += decoded;
|
|
17
30
|
}
|
|
18
31
|
// flush
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
const last = textDecoder.decode();
|
|
33
|
+
if (last) {
|
|
34
|
+
text += last;
|
|
35
|
+
}
|
|
36
|
+
return text;
|
|
21
37
|
}
|
|
22
|
-
exports.getAsText = getAsText;
|
|
23
38
|
function mapStream(mapper) {
|
|
24
39
|
return new stream_1.default.Transform({
|
|
25
40
|
objectMode: true,
|
|
@@ -28,5 +43,4 @@ function mapStream(mapper) {
|
|
|
28
43
|
},
|
|
29
44
|
});
|
|
30
45
|
}
|
|
31
|
-
exports.mapStream = mapStream;
|
|
32
46
|
//# sourceMappingURL=stream.js.map
|
package/dist/utils/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":";;;;;AAKA,4BASC;AAED,8BAsBC;AAED,8BASC;AAjDD,oDAA2B;AAC3B,mCAAkC;AAElC,MAAM,EAAE,iBAAiB,EAAE,GAAG,kBAAS,CAAA;AAEvC,SAAgB,QAAQ,CAAC,GAAY;IACnC,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,MAAM,IAAI,GAAG;QACb,OAAO,GAAG,C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
|
5
8
|
* MyApplicationName clickhouse-js/0.0.11 (lv:nodejs/19.0.4; os:linux)
|
|
9
|
+
* ```
|
|
6
10
|
*/
|
|
7
11
|
export declare function getUserAgent(application_id?: string): string;
|
package/dist/utils/user_agent.js
CHANGED
|
@@ -1,45 +1,21 @@
|
|
|
1
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getUserAgent =
|
|
30
|
-
const
|
|
31
|
-
const version_1 = __importDefault(require("../version"));
|
|
3
|
+
exports.getUserAgent = getUserAgent;
|
|
4
|
+
const runtime_1 = require("./runtime");
|
|
32
5
|
/**
|
|
33
6
|
* Generate a user agent string like
|
|
7
|
+
* ```
|
|
34
8
|
* clickhouse-js/0.0.11 (lv:nodejs/19.0.4; os:linux)
|
|
9
|
+
* ```
|
|
35
10
|
* or
|
|
11
|
+
* ```
|
|
36
12
|
* MyApplicationName clickhouse-js/0.0.11 (lv:nodejs/19.0.4; os:linux)
|
|
13
|
+
* ```
|
|
37
14
|
*/
|
|
38
15
|
function getUserAgent(application_id) {
|
|
39
|
-
const defaultUserAgent = `clickhouse-js/${
|
|
16
|
+
const defaultUserAgent = `clickhouse-js/${runtime_1.Runtime.package} (lv:nodejs/${runtime_1.Runtime.node}; os:${runtime_1.Runtime.os})`;
|
|
40
17
|
return application_id
|
|
41
18
|
? `${application_id} ${defaultUserAgent}`
|
|
42
19
|
: defaultUserAgent;
|
|
43
20
|
}
|
|
44
|
-
exports.getUserAgent = getUserAgent;
|
|
45
21
|
//# sourceMappingURL=user_agent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user_agent.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"user_agent.js","sourceRoot":"","sources":["../../src/utils/user_agent.ts"],"names":[],"mappings":";;AAYA,oCAOC;AAnBD,uCAAmC;AAEnC;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAAC,cAAuB;IAClD,MAAM,gBAAgB,GAAG,iBAAiB,iBAAO,CAAC,OAAO,eACvD,iBAAO,CAAC,IACV,QAAQ,iBAAO,CAAC,EAAE,GAAG,CAAA;IACrB,OAAO,cAAc;QACnB,CAAC,CAAC,GAAG,cAAc,IAAI,gBAAgB,EAAE;QACzC,CAAC,CAAC,gBAAgB,CAAA;AACtB,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "0.
|
|
1
|
+
declare const _default: "0.100.1";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,SAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@clickhouse/client",
|
|
3
3
|
"description": "Official JS client for ClickHouse DB - Node.js implementation",
|
|
4
4
|
"homepage": "https://clickhouse.com",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.100.1",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"clickhouse",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/ClickHouse/clickhouse-js.git"
|
|
14
|
+
"url": "git+https://github.com/ClickHouse/clickhouse-js.git"
|
|
15
15
|
},
|
|
16
16
|
"private": false,
|
|
17
17
|
"engines": {
|
|
@@ -22,7 +22,14 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prepack": "cp ../../README.md ../../LICENSE .",
|
|
27
|
+
"build": "rm -rf dist; tsc"
|
|
28
|
+
},
|
|
25
29
|
"dependencies": {
|
|
26
|
-
"@clickhouse/client-common": "0.
|
|
30
|
+
"@clickhouse/client-common": "0.100.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"simdjson": "^0.9.2"
|
|
27
34
|
}
|
|
28
35
|
}
|