@clickhouse/client 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -6
- package/dist/client.d.ts +12 -141
- package/dist/client.js +39 -229
- package/dist/client.js.map +1 -1
- package/dist/connection/index.d.ts +3 -1
- package/dist/connection/index.js +3 -1
- package/dist/connection/index.js.map +1 -1
- package/dist/connection/node_base_connection.d.ts +50 -0
- package/dist/connection/{adapter/base_http_adapter.js → node_base_connection.js} +81 -117
- package/dist/connection/node_base_connection.js.map +1 -0
- package/dist/connection/node_http_connection.d.ts +11 -0
- package/dist/connection/node_http_connection.js +32 -0
- package/dist/connection/node_http_connection.js.map +1 -0
- package/dist/connection/node_https_connection.d.ts +12 -0
- package/dist/connection/node_https_connection.js +53 -0
- package/dist/connection/node_https_connection.js.map +1 -0
- package/dist/index.d.ts +4 -15
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/dist/result_set.d.ts +13 -0
- package/dist/{result.js → result_set.js} +5 -32
- package/dist/result_set.js.map +1 -0
- package/dist/utils/encoder.d.ts +7 -0
- package/dist/utils/encoder.js +55 -0
- package/dist/utils/encoder.js.map +1 -0
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/process.js.map +1 -1
- package/dist/utils/stream.d.ts +1 -1
- package/dist/utils/stream.js.map +1 -1
- package/dist/utils/user_agent.js +1 -2
- 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 +7 -48
- package/dist/clickhouse_types.d.ts +0 -24
- package/dist/clickhouse_types.js +0 -3
- package/dist/clickhouse_types.js.map +0 -1
- package/dist/connection/adapter/base_http_adapter.d.ts +0 -38
- package/dist/connection/adapter/base_http_adapter.js.map +0 -1
- package/dist/connection/adapter/http_adapter.d.ts +0 -10
- package/dist/connection/adapter/http_adapter.js +0 -27
- package/dist/connection/adapter/http_adapter.js.map +0 -1
- package/dist/connection/adapter/http_search_params.d.ts +0 -11
- package/dist/connection/adapter/http_search_params.js +0 -42
- package/dist/connection/adapter/http_search_params.js.map +0 -1
- package/dist/connection/adapter/https_adapter.d.ts +0 -11
- package/dist/connection/adapter/https_adapter.js +0 -48
- package/dist/connection/adapter/https_adapter.js.map +0 -1
- package/dist/connection/adapter/index.d.ts +0 -2
- package/dist/connection/adapter/index.js +0 -8
- package/dist/connection/adapter/index.js.map +0 -1
- package/dist/connection/adapter/transform_url.d.ts +0 -5
- package/dist/connection/adapter/transform_url.js +0 -15
- package/dist/connection/adapter/transform_url.js.map +0 -1
- package/dist/connection/connection.d.ts +0 -63
- package/dist/connection/connection.js +0 -17
- package/dist/connection/connection.js.map +0 -1
- package/dist/data_formatter/format_query_params.d.ts +0 -1
- package/dist/data_formatter/format_query_params.js +0 -61
- package/dist/data_formatter/format_query_params.js.map +0 -1
- package/dist/data_formatter/format_query_settings.d.ts +0 -2
- package/dist/data_formatter/format_query_settings.js +0 -21
- package/dist/data_formatter/format_query_settings.js.map +0 -1
- package/dist/data_formatter/formatter.d.ts +0 -23
- package/dist/data_formatter/formatter.js +0 -96
- package/dist/data_formatter/formatter.js.map +0 -1
- package/dist/data_formatter/index.d.ts +0 -3
- package/dist/data_formatter/index.js +0 -23
- package/dist/data_formatter/index.js.map +0 -1
- package/dist/error/index.d.ts +0 -1
- package/dist/error/index.js +0 -18
- package/dist/error/index.js.map +0 -1
- package/dist/error/parse_error.d.ts +0 -12
- package/dist/error/parse_error.js +0 -39
- package/dist/error/parse_error.js.map +0 -1
- package/dist/logger.d.ts +0 -33
- package/dist/logger.js +0 -108
- package/dist/logger.js.map +0 -1
- package/dist/result.d.ts +0 -52
- package/dist/result.js.map +0 -1
- package/dist/schema/common.d.ts +0 -8
- package/dist/schema/common.js +0 -3
- package/dist/schema/common.js.map +0 -1
- package/dist/schema/engines.d.ts +0 -40
- package/dist/schema/engines.js +0 -61
- package/dist/schema/engines.js.map +0 -1
- package/dist/schema/index.d.ts +0 -7
- package/dist/schema/index.js +0 -24
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/query_formatter.d.ts +0 -9
- package/dist/schema/query_formatter.js +0 -48
- package/dist/schema/query_formatter.js.map +0 -1
- package/dist/schema/result.d.ts +0 -13
- package/dist/schema/result.js +0 -3
- package/dist/schema/result.js.map +0 -1
- package/dist/schema/schema.d.ts +0 -6
- package/dist/schema/schema.js +0 -20
- package/dist/schema/schema.js.map +0 -1
- package/dist/schema/stream.d.ts +0 -11
- package/dist/schema/stream.js +0 -25
- package/dist/schema/stream.js.map +0 -1
- package/dist/schema/table.d.ts +0 -44
- package/dist/schema/table.js +0 -73
- package/dist/schema/table.js.map +0 -1
- package/dist/schema/types.d.ts +0 -201
- package/dist/schema/types.js +0 -268
- package/dist/schema/types.js.map +0 -1
- package/dist/schema/where.d.ts +0 -8
- package/dist/schema/where.js +0 -43
- package/dist/schema/where.js.map +0 -1
- package/dist/settings.d.ts +0 -1453
- package/dist/settings.js +0 -28
- package/dist/settings.js.map +0 -1
- package/dist/utils/string.d.ts +0 -1
- package/dist/utils/string.js +0 -9
- package/dist/utils/string.js.map +0 -1
|
@@ -1,96 +1,36 @@
|
|
|
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
6
|
+
exports.NodeBaseConnection = void 0;
|
|
7
|
+
const client_common_1 = require("@clickhouse/client-common");
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
30
9
|
const stream_1 = __importDefault(require("stream"));
|
|
31
10
|
const zlib_1 = __importDefault(require("zlib"));
|
|
32
|
-
const
|
|
33
|
-
const http_search_params_1 = require("./http_search_params");
|
|
34
|
-
const transform_url_1 = require("./transform_url");
|
|
35
|
-
const utils_1 = require("../../utils");
|
|
36
|
-
const user_agent_1 = require("../../utils/user_agent");
|
|
37
|
-
const uuid = __importStar(require("uuid"));
|
|
38
|
-
function isSuccessfulResponse(statusCode) {
|
|
39
|
-
return Boolean(statusCode && 200 <= statusCode && statusCode < 300);
|
|
40
|
-
}
|
|
41
|
-
function withHttpSettings(clickhouse_settings, compression) {
|
|
42
|
-
return {
|
|
43
|
-
...(compression
|
|
44
|
-
? {
|
|
45
|
-
enable_http_compression: 1,
|
|
46
|
-
}
|
|
47
|
-
: {}),
|
|
48
|
-
...clickhouse_settings,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function decompressResponse(response) {
|
|
52
|
-
const encoding = response.headers['content-encoding'];
|
|
53
|
-
if (encoding === 'gzip') {
|
|
54
|
-
return {
|
|
55
|
-
response: stream_1.default.pipeline(response, zlib_1.default.createGunzip(), function pipelineCb(err) {
|
|
56
|
-
if (err) {
|
|
57
|
-
console.error(err);
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
else if (encoding !== undefined) {
|
|
63
|
-
return {
|
|
64
|
-
error: new Error(`Unexpected encoding: ${encoding}`),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return { response };
|
|
68
|
-
}
|
|
69
|
-
function isDecompressionError(result) {
|
|
70
|
-
return result.error !== undefined;
|
|
71
|
-
}
|
|
11
|
+
const utils_1 = require("../utils");
|
|
72
12
|
const expiredSocketMessage = 'expired socket';
|
|
73
|
-
class
|
|
74
|
-
constructor(
|
|
75
|
-
Object.defineProperty(this, "
|
|
13
|
+
class NodeBaseConnection {
|
|
14
|
+
constructor(params, agent) {
|
|
15
|
+
Object.defineProperty(this, "params", {
|
|
76
16
|
enumerable: true,
|
|
77
17
|
configurable: true,
|
|
78
18
|
writable: true,
|
|
79
|
-
value:
|
|
19
|
+
value: params
|
|
80
20
|
});
|
|
81
|
-
Object.defineProperty(this, "
|
|
21
|
+
Object.defineProperty(this, "agent", {
|
|
82
22
|
enumerable: true,
|
|
83
23
|
configurable: true,
|
|
84
24
|
writable: true,
|
|
85
|
-
value:
|
|
25
|
+
value: agent
|
|
86
26
|
});
|
|
87
|
-
Object.defineProperty(this, "
|
|
27
|
+
Object.defineProperty(this, "headers", {
|
|
88
28
|
enumerable: true,
|
|
89
29
|
configurable: true,
|
|
90
30
|
writable: true,
|
|
91
|
-
value:
|
|
31
|
+
value: void 0
|
|
92
32
|
});
|
|
93
|
-
Object.defineProperty(this, "
|
|
33
|
+
Object.defineProperty(this, "logger", {
|
|
94
34
|
enumerable: true,
|
|
95
35
|
configurable: true,
|
|
96
36
|
writable: true,
|
|
@@ -108,15 +48,15 @@ class BaseHttpAdapter {
|
|
|
108
48
|
writable: true,
|
|
109
49
|
value: new WeakMap()
|
|
110
50
|
});
|
|
111
|
-
this.
|
|
51
|
+
this.logger = params.logWriter;
|
|
112
52
|
this.retry_expired_sockets =
|
|
113
|
-
|
|
114
|
-
|
|
53
|
+
params.keep_alive.enabled && params.keep_alive.retry_on_expired_socket;
|
|
54
|
+
this.headers = this.buildDefaultHeaders(params.username, params.password);
|
|
115
55
|
}
|
|
116
56
|
buildDefaultHeaders(username, password) {
|
|
117
57
|
return {
|
|
118
58
|
Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
|
|
119
|
-
'User-Agent': (0,
|
|
59
|
+
'User-Agent': (0, utils_1.getUserAgent)(this.params.application_id),
|
|
120
60
|
};
|
|
121
61
|
}
|
|
122
62
|
async request(params, retryCount = 0) {
|
|
@@ -142,7 +82,7 @@ class BaseHttpAdapter {
|
|
|
142
82
|
async _request(params) {
|
|
143
83
|
return new Promise((resolve, reject) => {
|
|
144
84
|
const start = Date.now();
|
|
145
|
-
const request = this.createClientRequest(params
|
|
85
|
+
const request = this.createClientRequest(params);
|
|
146
86
|
function onError(err) {
|
|
147
87
|
removeRequestListeners();
|
|
148
88
|
reject(err);
|
|
@@ -153,11 +93,11 @@ class BaseHttpAdapter {
|
|
|
153
93
|
if (isDecompressionError(decompressionResult)) {
|
|
154
94
|
return reject(decompressionResult.error);
|
|
155
95
|
}
|
|
156
|
-
if (isSuccessfulResponse(_response.statusCode)) {
|
|
96
|
+
if ((0, client_common_1.isSuccessfulResponse)(_response.statusCode)) {
|
|
157
97
|
return resolve(decompressionResult.response);
|
|
158
98
|
}
|
|
159
99
|
else {
|
|
160
|
-
reject((0,
|
|
100
|
+
reject((0, client_common_1.parseError)(await (0, utils_1.getAsText)(decompressionResult.response)));
|
|
161
101
|
}
|
|
162
102
|
};
|
|
163
103
|
function onAbort() {
|
|
@@ -170,7 +110,7 @@ class BaseHttpAdapter {
|
|
|
170
110
|
* see the full sequence of events https://nodejs.org/api/http.html#httprequesturl-options-callback
|
|
171
111
|
* */
|
|
172
112
|
});
|
|
173
|
-
reject(new Error('The
|
|
113
|
+
reject(new Error('The user aborted a request.'));
|
|
174
114
|
}
|
|
175
115
|
function onClose() {
|
|
176
116
|
// Adapter uses 'close' event to clean up listeners after the successful response.
|
|
@@ -211,7 +151,7 @@ class BaseHttpAdapter {
|
|
|
211
151
|
// if a socket was reused at an unfortunate time,
|
|
212
152
|
// and is likely about to expire
|
|
213
153
|
const isPossiblyExpired = Date.now() - socketInfo.last_used_time >
|
|
214
|
-
this.
|
|
154
|
+
this.params.keep_alive.socket_ttl;
|
|
215
155
|
if (isPossiblyExpired) {
|
|
216
156
|
this.logger.trace({
|
|
217
157
|
module: 'Connection',
|
|
@@ -235,7 +175,7 @@ class BaseHttpAdapter {
|
|
|
235
175
|
}
|
|
236
176
|
}
|
|
237
177
|
else {
|
|
238
|
-
const socketId =
|
|
178
|
+
const socketId = crypto_1.default.randomUUID();
|
|
239
179
|
this.logger.trace({
|
|
240
180
|
module: 'Connection',
|
|
241
181
|
message: `Using a new socket ${socketId}`,
|
|
@@ -256,12 +196,12 @@ class BaseHttpAdapter {
|
|
|
256
196
|
// The socket won't be actually destroyed,
|
|
257
197
|
// and it will be returned to the pool.
|
|
258
198
|
// TODO: investigate if can actually remove the idle sockets properly
|
|
259
|
-
socket.setTimeout(this.
|
|
199
|
+
socket.setTimeout(this.params.request_timeout, onTimeout);
|
|
260
200
|
};
|
|
261
201
|
function onTimeout() {
|
|
262
202
|
removeRequestListeners();
|
|
263
203
|
request.destroy();
|
|
264
|
-
reject(new Error('Timeout error'));
|
|
204
|
+
reject(new Error('Timeout error.'));
|
|
265
205
|
}
|
|
266
206
|
function removeRequestListeners() {
|
|
267
207
|
if (request.socket !== null) {
|
|
@@ -288,19 +228,29 @@ class BaseHttpAdapter {
|
|
|
288
228
|
});
|
|
289
229
|
}
|
|
290
230
|
async ping() {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
231
|
+
try {
|
|
232
|
+
const stream = await this.request({
|
|
233
|
+
method: 'GET',
|
|
234
|
+
url: (0, client_common_1.transformUrl)({ url: this.params.url, pathname: '/ping' }),
|
|
235
|
+
});
|
|
236
|
+
stream.destroy();
|
|
237
|
+
return { success: true };
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (error instanceof Error) {
|
|
241
|
+
return {
|
|
242
|
+
success: false,
|
|
243
|
+
error,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
throw error; // should never happen
|
|
247
|
+
}
|
|
298
248
|
}
|
|
299
249
|
async query(params) {
|
|
300
|
-
const query_id =
|
|
301
|
-
const clickhouse_settings = withHttpSettings(params.clickhouse_settings, this.
|
|
302
|
-
const searchParams = (0,
|
|
303
|
-
database: this.
|
|
250
|
+
const query_id = getQueryId(params.query_id);
|
|
251
|
+
const clickhouse_settings = (0, client_common_1.withHttpSettings)(params.clickhouse_settings, this.params.compression.decompress_response);
|
|
252
|
+
const searchParams = (0, client_common_1.toSearchParams)({
|
|
253
|
+
database: this.params.database,
|
|
304
254
|
clickhouse_settings,
|
|
305
255
|
query_params: params.query_params,
|
|
306
256
|
session_id: params.session_id,
|
|
@@ -308,7 +258,7 @@ class BaseHttpAdapter {
|
|
|
308
258
|
});
|
|
309
259
|
const stream = await this.request({
|
|
310
260
|
method: 'POST',
|
|
311
|
-
url: (0,
|
|
261
|
+
url: (0, client_common_1.transformUrl)({ url: this.params.url, pathname: '/', searchParams }),
|
|
312
262
|
body: params.query,
|
|
313
263
|
abort_signal: params.abort_signal,
|
|
314
264
|
decompress_response: clickhouse_settings.enable_http_compression === 1,
|
|
@@ -319,9 +269,9 @@ class BaseHttpAdapter {
|
|
|
319
269
|
};
|
|
320
270
|
}
|
|
321
271
|
async exec(params) {
|
|
322
|
-
const query_id =
|
|
323
|
-
const searchParams = (0,
|
|
324
|
-
database: this.
|
|
272
|
+
const query_id = getQueryId(params.query_id);
|
|
273
|
+
const searchParams = (0, client_common_1.toSearchParams)({
|
|
274
|
+
database: this.params.database,
|
|
325
275
|
clickhouse_settings: params.clickhouse_settings,
|
|
326
276
|
query_params: params.query_params,
|
|
327
277
|
session_id: params.session_id,
|
|
@@ -329,7 +279,7 @@ class BaseHttpAdapter {
|
|
|
329
279
|
});
|
|
330
280
|
const stream = await this.request({
|
|
331
281
|
method: 'POST',
|
|
332
|
-
url: (0,
|
|
282
|
+
url: (0, client_common_1.transformUrl)({ url: this.params.url, pathname: '/', searchParams }),
|
|
333
283
|
body: params.query,
|
|
334
284
|
abort_signal: params.abort_signal,
|
|
335
285
|
});
|
|
@@ -339,9 +289,9 @@ class BaseHttpAdapter {
|
|
|
339
289
|
};
|
|
340
290
|
}
|
|
341
291
|
async insert(params) {
|
|
342
|
-
const query_id =
|
|
343
|
-
const searchParams = (0,
|
|
344
|
-
database: this.
|
|
292
|
+
const query_id = getQueryId(params.query_id);
|
|
293
|
+
const searchParams = (0, client_common_1.toSearchParams)({
|
|
294
|
+
database: this.params.database,
|
|
345
295
|
clickhouse_settings: params.clickhouse_settings,
|
|
346
296
|
query_params: params.query_params,
|
|
347
297
|
query: params.query,
|
|
@@ -350,10 +300,10 @@ class BaseHttpAdapter {
|
|
|
350
300
|
});
|
|
351
301
|
const stream = await this.request({
|
|
352
302
|
method: 'POST',
|
|
353
|
-
url: (0,
|
|
303
|
+
url: (0, client_common_1.transformUrl)({ url: this.params.url, pathname: '/', searchParams }),
|
|
354
304
|
body: params.values,
|
|
355
305
|
abort_signal: params.abort_signal,
|
|
356
|
-
compress_request: this.
|
|
306
|
+
compress_request: this.params.compression.compress_request,
|
|
357
307
|
});
|
|
358
308
|
stream.destroy();
|
|
359
309
|
return { query_id };
|
|
@@ -363,15 +313,12 @@ class BaseHttpAdapter {
|
|
|
363
313
|
this.agent.destroy();
|
|
364
314
|
}
|
|
365
315
|
}
|
|
366
|
-
getQueryId(params) {
|
|
367
|
-
return params.query_id || uuid.v4();
|
|
368
|
-
}
|
|
369
316
|
logResponse(request, params, response, startTimestamp) {
|
|
370
317
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
371
318
|
const { authorization, host, ...headers } = request.getHeaders();
|
|
372
319
|
const duration = Date.now() - startTimestamp;
|
|
373
|
-
this.
|
|
374
|
-
module: '
|
|
320
|
+
this.params.logWriter.debug({
|
|
321
|
+
module: 'HTTP Adapter',
|
|
375
322
|
message: 'Got a response from ClickHouse',
|
|
376
323
|
args: {
|
|
377
324
|
request_method: params.method,
|
|
@@ -384,13 +331,30 @@ class BaseHttpAdapter {
|
|
|
384
331
|
},
|
|
385
332
|
});
|
|
386
333
|
}
|
|
387
|
-
|
|
334
|
+
}
|
|
335
|
+
exports.NodeBaseConnection = NodeBaseConnection;
|
|
336
|
+
function decompressResponse(response) {
|
|
337
|
+
const encoding = response.headers['content-encoding'];
|
|
338
|
+
if (encoding === 'gzip') {
|
|
388
339
|
return {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
340
|
+
response: stream_1.default.pipeline(response, zlib_1.default.createGunzip(), function pipelineCb(err) {
|
|
341
|
+
if (err) {
|
|
342
|
+
console.error(err);
|
|
343
|
+
}
|
|
344
|
+
}),
|
|
392
345
|
};
|
|
393
346
|
}
|
|
347
|
+
else if (encoding !== undefined) {
|
|
348
|
+
return {
|
|
349
|
+
error: new Error(`Unexpected encoding: ${encoding}`),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
return { response };
|
|
353
|
+
}
|
|
354
|
+
function isDecompressionError(result) {
|
|
355
|
+
return result.error !== undefined;
|
|
356
|
+
}
|
|
357
|
+
function getQueryId(query_id) {
|
|
358
|
+
return query_id || crypto_1.default.randomUUID();
|
|
394
359
|
}
|
|
395
|
-
|
|
396
|
-
//# sourceMappingURL=base_http_adapter.js.map
|
|
360
|
+
//# sourceMappingURL=node_base_connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node_base_connection.js","sourceRoot":"","sources":["../../../../packages/client-node/src/connection/node_base_connection.ts"],"names":[],"mappings":";;;;;;AAWA,6DAMkC;AAClC,oDAA2B;AAG3B,oDAA2B;AAC3B,gDAAuB;AACvB,oCAA4D;AAgC5D,MAAM,oBAAoB,GAAG,gBAAgB,CAAA;AAE7C,MAAsB,kBAAkB;IAatC,YACqB,MAA4B,EAC5B,KAAiB;;;;;mBADjB;;;;;;mBACA;;QAZrB;;;;;WAAoD;QACpD;;;;;WAAkC;QAClC;;;;;WAA+C;QAC/C;;;;mBAAiC,IAAI,OAAO,EAMzC;WAAA;QAKD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAA;QAC9B,IAAI,CAAC,qBAAqB;YACxB,MAAM,CAAC,UAAU,CAAC,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAA;QACxE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC3E,CAAC;IAES,mBAAmB,CAC3B,QAAgB,EAChB,QAAgB;QAEhB,OAAO;YACL,aAAa,EAAE,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC,CAAC,QAAQ,CACrE,QAAQ,CACT,EAAE;YACH,YAAY,EAAE,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;SACvD,CAAA;IACH,CAAC;IAMO,KAAK,CAAC,OAAO,CACnB,MAAqB,EACrB,UAAU,GAAG,CAAC;QAEd,IAAI;YACF,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;SACnC;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,KAAK,oBAAoB,EAAE;gBAC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AAE,CAAA;AACrB,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAW;IACvC,OAAO,MAAM,CAAC,KAAK,KAAK,SAAS,CAAA;AACnC,CAAC;AAED,SAAS,UAAU,CAAC,QAA4B;IAC9C,OAAO,QAAQ,IAAI,gBAAM,CAAC,UAAU,EAAE,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { Connection } from '@clickhouse/client-common';
|
|
4
|
+
import Http from 'http';
|
|
5
|
+
import type Stream from 'stream';
|
|
6
|
+
import type { NodeConnectionParams, RequestParams } from './node_base_connection';
|
|
7
|
+
import { NodeBaseConnection } from './node_base_connection';
|
|
8
|
+
export declare class NodeHttpConnection extends NodeBaseConnection implements Connection<Stream.Readable> {
|
|
9
|
+
constructor(params: NodeConnectionParams);
|
|
10
|
+
protected createClientRequest(params: RequestParams): Http.ClientRequest;
|
|
11
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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.NodeHttpConnection = void 0;
|
|
7
|
+
const client_common_1 = require("@clickhouse/client-common");
|
|
8
|
+
const http_1 = __importDefault(require("http"));
|
|
9
|
+
const node_base_connection_1 = require("./node_base_connection");
|
|
10
|
+
class NodeHttpConnection extends node_base_connection_1.NodeBaseConnection {
|
|
11
|
+
constructor(params) {
|
|
12
|
+
const agent = new http_1.default.Agent({
|
|
13
|
+
keepAlive: params.keep_alive.enabled,
|
|
14
|
+
maxSockets: params.max_open_connections,
|
|
15
|
+
});
|
|
16
|
+
super(params, agent);
|
|
17
|
+
}
|
|
18
|
+
createClientRequest(params) {
|
|
19
|
+
return http_1.default.request(params.url, {
|
|
20
|
+
method: params.method,
|
|
21
|
+
agent: this.agent,
|
|
22
|
+
headers: (0, client_common_1.withCompressionHeaders)({
|
|
23
|
+
headers: this.headers,
|
|
24
|
+
compress_request: params.compress_request,
|
|
25
|
+
decompress_response: params.decompress_response,
|
|
26
|
+
}),
|
|
27
|
+
signal: params.abort_signal,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.NodeHttpConnection = NodeHttpConnection;
|
|
32
|
+
//# sourceMappingURL=node_http_connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node_http_connection.js","sourceRoot":"","sources":["../../../../packages/client-node/src/connection/node_http_connection.ts"],"names":[],"mappings":";;;;;;AACA,6DAAkE;AAClE,gDAAuB;AAMvB,iEAA2D;AAE3D,MAAa,kBACX,SAAQ,yCAAkB;IAG1B,YAAY,MAA4B;QACtC,MAAM,KAAK,GAAG,IAAI,cAAI,CAAC,KAAK,CAAC;YAC3B,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO;YACpC,UAAU,EAAE,MAAM,CAAC,oBAAoB;SACxC,CAAC,CAAA;QACF,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IACtB,CAAC;IAES,mBAAmB,CAAC,MAAqB;QACjD,OAAO,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;YAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAA,sCAAsB,EAAC;gBAC9B,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;aAChD,CAAC;YACF,MAAM,EAAE,MAAM,CAAC,YAAY;SAC5B,CAAC,CAAA;IACJ,CAAC;CACF;AAxBD,gDAwBC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { Connection } from '@clickhouse/client-common';
|
|
4
|
+
import type Http from 'http';
|
|
5
|
+
import type Stream from 'stream';
|
|
6
|
+
import type { NodeConnectionParams, RequestParams } from './node_base_connection';
|
|
7
|
+
import { NodeBaseConnection } from './node_base_connection';
|
|
8
|
+
export declare class NodeHttpsConnection extends NodeBaseConnection implements Connection<Stream.Readable> {
|
|
9
|
+
constructor(params: NodeConnectionParams);
|
|
10
|
+
protected buildDefaultHeaders(username: string, password: string): Http.OutgoingHttpHeaders;
|
|
11
|
+
protected createClientRequest(params: RequestParams): Http.ClientRequest;
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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.NodeHttpsConnection = void 0;
|
|
7
|
+
const client_common_1 = require("@clickhouse/client-common");
|
|
8
|
+
const https_1 = __importDefault(require("https"));
|
|
9
|
+
const node_base_connection_1 = require("./node_base_connection");
|
|
10
|
+
class NodeHttpsConnection extends node_base_connection_1.NodeBaseConnection {
|
|
11
|
+
constructor(params) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const agent = new https_1.default.Agent({
|
|
14
|
+
keepAlive: params.keep_alive.enabled,
|
|
15
|
+
maxSockets: params.max_open_connections,
|
|
16
|
+
ca: (_a = params.tls) === null || _a === void 0 ? void 0 : _a.ca_cert,
|
|
17
|
+
key: ((_b = params.tls) === null || _b === void 0 ? void 0 : _b.type) === 'Mutual' ? params.tls.key : undefined,
|
|
18
|
+
cert: ((_c = params.tls) === null || _c === void 0 ? void 0 : _c.type) === 'Mutual' ? params.tls.cert : undefined,
|
|
19
|
+
});
|
|
20
|
+
super(params, agent);
|
|
21
|
+
}
|
|
22
|
+
buildDefaultHeaders(username, password) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
if (((_a = this.params.tls) === null || _a === void 0 ? void 0 : _a.type) === 'Mutual') {
|
|
25
|
+
return {
|
|
26
|
+
'X-ClickHouse-User': username,
|
|
27
|
+
'X-ClickHouse-Key': password,
|
|
28
|
+
'X-ClickHouse-SSL-Certificate-Auth': 'on',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (((_b = this.params.tls) === null || _b === void 0 ? void 0 : _b.type) === 'Basic') {
|
|
32
|
+
return {
|
|
33
|
+
'X-ClickHouse-User': username,
|
|
34
|
+
'X-ClickHouse-Key': password,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return super.buildDefaultHeaders(username, password);
|
|
38
|
+
}
|
|
39
|
+
createClientRequest(params) {
|
|
40
|
+
return https_1.default.request(params.url, {
|
|
41
|
+
method: params.method,
|
|
42
|
+
agent: this.agent,
|
|
43
|
+
headers: (0, client_common_1.withCompressionHeaders)({
|
|
44
|
+
headers: this.headers,
|
|
45
|
+
compress_request: params.compress_request,
|
|
46
|
+
decompress_response: params.decompress_response,
|
|
47
|
+
}),
|
|
48
|
+
signal: params.abort_signal,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.NodeHttpsConnection = NodeHttpsConnection;
|
|
53
|
+
//# sourceMappingURL=node_https_connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node_https_connection.js","sourceRoot":"","sources":["../../../../packages/client-node/src/connection/node_https_connection.ts"],"names":[],"mappings":";;;;;;AACA,6DAAkE;AAElE,kDAAyB;AAMzB,iEAA2D;AAE3D,MAAa,mBACX,SAAQ,yCAAkB;IAG1B,YAAY,MAA4B;;QACtC,MAAM,KAAK,GAAG,IAAI,eAAK,CAAC,KAAK,CAAC;YAC5B,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO;YACpC,UAAU,EAAE,MAAM,CAAC,oBAA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,MAAM,CAAC,mBAAmB;aAChD,CAAC;YACF,MAAM,EAAE,MAAM,CAAC,YAAY;SAC5B,CAAC,CAAA;IACJ,CAAC;CACF;AA/CD,kDA+CC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export default _default;
|
|
7
|
-
export { type ClickHouseClientConfigOptions, type ClickHouseClient, type BaseParams, type QueryParams, type ExecParams, type InsertParams, type CommandParams, type CommandResult, } from './client';
|
|
8
|
-
export { Row, ResultSet } from './result';
|
|
9
|
-
export type { Connection, ExecResult, InsertResult } from './connection';
|
|
10
|
-
export type { DataFormat } from './data_formatter';
|
|
11
|
-
export type { ClickHouseError } from './error';
|
|
12
|
-
export type { Logger } from './logger';
|
|
13
|
-
export type { ResponseJSON, InputJSON, InputJSONObjectEachRow, } from './clickhouse_types';
|
|
14
|
-
export type { ClickHouseSettings } from './settings';
|
|
15
|
-
export { SettingsMap } from './settings';
|
|
1
|
+
export { createConnection, createClient } from './client';
|
|
2
|
+
export { ResultSet } from './result_set';
|
|
3
|
+
/** Re-export @clickhouse/client-common types */
|
|
4
|
+
export { type BaseClickHouseClientConfigOptions, type ClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type ErrorLogParams, type Logger, type LogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, ClickHouseError, ClickHouseLogLevel, ClickHouseClient, SettingsMap, } from '@clickhouse/client-common';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SettingsMap = exports.ResultSet = exports.createClient = void 0;
|
|
4
|
-
|
|
3
|
+
exports.SettingsMap = exports.ClickHouseClient = exports.ClickHouseLogLevel = exports.ClickHouseError = exports.ResultSet = exports.createClient = exports.createConnection = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "createConnection", { enumerable: true, get: function () { return client_1.createConnection; } });
|
|
5
6
|
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
Object.defineProperty(exports, "
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, "
|
|
7
|
+
var result_set_1 = require("./result_set");
|
|
8
|
+
Object.defineProperty(exports, "ResultSet", { enumerable: true, get: function () { return result_set_1.ResultSet; } });
|
|
9
|
+
/** Re-export @clickhouse/client-common types */
|
|
10
|
+
var client_common_1 = require("@clickhouse/client-common");
|
|
11
|
+
Object.defineProperty(exports, "ClickHouseError", { enumerable: true, get: function () { return client_common_1.ClickHouseError; } });
|
|
12
|
+
Object.defineProperty(exports, "ClickHouseLogLevel", { enumerable: true, get: function () { return client_common_1.ClickHouseLogLevel; } });
|
|
13
|
+
Object.defineProperty(exports, "ClickHouseClient", { enumerable: true, get: function () { return client_common_1.ClickHouseClient; } });
|
|
14
|
+
Object.defineProperty(exports, "SettingsMap", { enumerable: true, get: function () { return client_common_1.SettingsMap; } });
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/client-node/src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAyD;AAAhD,0GAAA,gBAAgB,OAAA;AAAE,sGAAA,YAAY,OAAA;AACvC,2CAAwC;AAA/B,uGAAA,SAAS,OAAA;AAElB,gDAAgD;AAChD,2DA4BkC;AAJhC,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,iHAAA,gBAAgB,OAAA;AAChB,4GAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { BaseResultSet, DataFormat } from '@clickhouse/client-common';
|
|
3
|
+
import Stream from 'stream';
|
|
4
|
+
export declare class ResultSet implements BaseResultSet<Stream.Readable> {
|
|
5
|
+
private _stream;
|
|
6
|
+
private readonly format;
|
|
7
|
+
readonly query_id: string;
|
|
8
|
+
constructor(_stream: Stream.Readable, format: DataFormat, query_id: string);
|
|
9
|
+
text(): Promise<string>;
|
|
10
|
+
json<T>(): Promise<T>;
|
|
11
|
+
stream(): Stream.Readable;
|
|
12
|
+
close(): void;
|
|
13
|
+
}
|
|
@@ -24,9 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ResultSet = void 0;
|
|
27
|
+
const client_common_1 = require("@clickhouse/client-common");
|
|
27
28
|
const stream_1 = __importStar(require("stream"));
|
|
28
29
|
const utils_1 = require("./utils");
|
|
29
|
-
const data_formatter_1 = require("./data_formatter");
|
|
30
30
|
class ResultSet {
|
|
31
31
|
constructor(_stream, format, query_id) {
|
|
32
32
|
Object.defineProperty(this, "_stream", {
|
|
@@ -48,45 +48,18 @@ class ResultSet {
|
|
|
48
48
|
value: query_id
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* The method waits for all the rows to be fully loaded
|
|
53
|
-
* and returns the result as a string.
|
|
54
|
-
*
|
|
55
|
-
* The method will throw if the underlying stream was already consumed
|
|
56
|
-
* by calling the other methods.
|
|
57
|
-
*/
|
|
58
51
|
async text() {
|
|
59
52
|
if (this._stream.readableEnded) {
|
|
60
53
|
throw Error(streamAlreadyConsumedMessage);
|
|
61
54
|
}
|
|
62
55
|
return (await (0, utils_1.getAsText)(this._stream)).toString();
|
|
63
56
|
}
|
|
64
|
-
/**
|
|
65
|
-
* The method waits for the all the rows to be fully loaded.
|
|
66
|
-
* When the response is received in full, it will be decoded to return JSON.
|
|
67
|
-
*
|
|
68
|
-
* The method will throw if the underlying stream was already consumed
|
|
69
|
-
* by calling the other methods.
|
|
70
|
-
*/
|
|
71
57
|
async json() {
|
|
72
58
|
if (this._stream.readableEnded) {
|
|
73
59
|
throw Error(streamAlreadyConsumedMessage);
|
|
74
60
|
}
|
|
75
|
-
return (0,
|
|
61
|
+
return (0, client_common_1.decode)(await this.text(), this.format);
|
|
76
62
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Returns a readable stream for responses that can be streamed
|
|
79
|
-
* (i.e. all except JSON).
|
|
80
|
-
*
|
|
81
|
-
* Every iteration provides an array of {@link Row} instances
|
|
82
|
-
* for {@link StreamableDataFormat} format.
|
|
83
|
-
*
|
|
84
|
-
* Should be called only once.
|
|
85
|
-
*
|
|
86
|
-
* The method will throw if called on a response in non-streamable format,
|
|
87
|
-
* and if the underlying stream was already consumed
|
|
88
|
-
* by calling the other methods.
|
|
89
|
-
*/
|
|
90
63
|
stream() {
|
|
91
64
|
// If the underlying stream has already ended by calling `text` or `json`,
|
|
92
65
|
// Stream.pipeline will create a new empty stream
|
|
@@ -94,7 +67,7 @@ class ResultSet {
|
|
|
94
67
|
if (this._stream.readableEnded) {
|
|
95
68
|
throw Error(streamAlreadyConsumedMessage);
|
|
96
69
|
}
|
|
97
|
-
(0,
|
|
70
|
+
(0, client_common_1.validateStreamFormat)(this.format);
|
|
98
71
|
let decodedChunk = '';
|
|
99
72
|
const toRows = new stream_1.Transform({
|
|
100
73
|
transform(chunk, encoding, callback) {
|
|
@@ -109,7 +82,7 @@ class ResultSet {
|
|
|
109
82
|
rows.push({
|
|
110
83
|
text,
|
|
111
84
|
json() {
|
|
112
|
-
return (0,
|
|
85
|
+
return (0, client_common_1.decode)(text, 'JSON');
|
|
113
86
|
},
|
|
114
87
|
});
|
|
115
88
|
}
|
|
@@ -137,4 +110,4 @@ class ResultSet {
|
|
|
137
110
|
}
|
|
138
111
|
exports.ResultSet = ResultSet;
|
|
139
112
|
const streamAlreadyConsumedMessage = 'Stream has been already consumed';
|
|
140
|
-
//# sourceMappingURL=
|
|
113
|
+
//# sourceMappingURL=result_set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result_set.js","sourceRoot":"","sources":["../../../packages/client-node/src/result_set.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAAwE;AAExE,iDAA0C;AAC1C,mCAAmC;AAEnC,MAAa,SAAS;IACpB,YACU,OAAwB,EACf,MAAkB,EACnB,QAAgB;;;;;mBAFxB;;;;;;mBACS;;;;;;mBACD;;IACf,CAAC;IAEJ,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC9B,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC1C;QACD,OAAO,CAAC,MAAM,IAAA,iBAAS,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IACnD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC9B,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC1C;QACD,OAAO,IAAA,sBAAM,EAAC,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IAED,MAAM;QACJ,0EAA0E;QAC1E,iDAAiD;QACjD,+CAA+C;QAC/C,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC9B,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;SAC1C;QAED,IAAA,oCAAoB,EAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEjC,IAAI,YAAY,GAAG,EAAE,CAAA;QACrB,MAAM,MAAM,GAAG,I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