@clickhouse/client 1.8.0 → 1.9.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.
@@ -2,6 +2,7 @@ import Http from 'http';
2
2
  import type { NodeConnectionParams, RequestParams } from './node_base_connection';
3
3
  import { NodeBaseConnection } from './node_base_connection';
4
4
  export declare class NodeCustomAgentConnection extends NodeBaseConnection {
5
+ private readonly httpRequestFn;
5
6
  constructor(params: NodeConnectionParams);
6
7
  protected createClientRequest(params: RequestParams): Http.ClientRequest;
7
8
  }
@@ -4,15 +4,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NodeCustomAgentConnection = void 0;
7
- const client_common_1 = require("@clickhouse/client-common");
8
7
  const http_1 = __importDefault(require("http"));
8
+ const https_1 = __importDefault(require("https"));
9
9
  const node_base_connection_1 = require("./node_base_connection");
10
+ const client_common_1 = require("@clickhouse/client-common");
10
11
  class NodeCustomAgentConnection extends node_base_connection_1.NodeBaseConnection {
11
12
  constructor(params) {
12
13
  if (!params.http_agent) {
13
14
  throw new Error('http_agent is required to create NodeCustomAgentConnection');
14
15
  }
15
16
  super(params, params.http_agent);
17
+ Object.defineProperty(this, "httpRequestFn", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ // See https://github.com/ClickHouse/clickhouse-js/issues/352
24
+ if (params.url.protocol.startsWith('https')) {
25
+ this.httpRequestFn = https_1.default.request;
26
+ }
27
+ else {
28
+ this.httpRequestFn = http_1.default.request;
29
+ }
16
30
  }
17
31
  createClientRequest(params) {
18
32
  const headers = (0, client_common_1.withCompressionHeaders)({
@@ -20,7 +34,7 @@ class NodeCustomAgentConnection extends node_base_connection_1.NodeBaseConnectio
20
34
  enable_request_compression: params.enable_request_compression,
21
35
  enable_response_compression: params.enable_response_compression,
22
36
  });
23
- return http_1.default.request(params.url, {
37
+ return this.httpRequestFn(params.url, {
24
38
  method: params.method,
25
39
  agent: this.agent,
26
40
  timeout: this.params.request_timeout,
@@ -1 +1 @@
1
- {"version":3,"file":"node_custom_agent_connection.js","sourceRoot":"","sources":["../../../../packages/client-node/src/connection/node_custom_agent_connection.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAkE;AAClE,gDAAuB;AAKvB,iEAA2D;AAE3D,MAAa,yBAA0B,SAAQ,yCAAkB;IAC/D,YAAY,MAA4B;QACtC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;QACH,CAAC;QACD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC;IAES,mBAAmB,CAAC,MAAqB;QACjD,MAAM,OAAO,GAAG,IAAA,sCAAsB,EAAC;YACrC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,0BAA0B,EAAE,MAAM,CAAC,0BAA0B;YAC7D,2BAA2B,EAAE,MAAM,CAAC,2BAA2B;SAChE,CAAC,CAAA;QACF,OAAO,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;YAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe;YACpC,MAAM,EAAE,MAAM,CAAC,YAAY;YAC3B,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AAxBD,8DAwBC"}
1
+ {"version":3,"file":"node_custom_agent_connection.js","sourceRoot":"","sources":["../../../../packages/client-node/src/connection/node_custom_agent_connection.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,kDAAyB;AAKzB,iEAA2D;AAC3D,6DAAkE;AAElE,MAAa,yBAA0B,SAAQ,yCAAkB;IAE/D,YAAY,MAA4B;QACtC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;QACH,CAAC;QACD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;QAPjB;;;;;WAAyD;QASxE,6DAA6D;QAC7D,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,aAAa,GAAG,eAAK,CAAC,OAAO,CAAA;QACpC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,aAAa,GAAG,cAAI,CAAC,OAAO,CAAA;QACnC,CAAC;IACH,CAAC;IAES,mBAAmB,CAAC,MAAqB;QACjD,MAAM,OAAO,GAAG,IAAA,sCAAsB,EAAC;YACrC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,0BAA0B,EAAE,MAAM,CAAC,0BAA0B;YAC7D,2BAA2B,EAAE,MAAM,CAAC,2BAA2B;SAChE,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE;YACpC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe;YACpC,MAAM,EAAE,MAAM,CAAC,YAAY;YAC3B,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AAhCD,8DAgCC"}
package/dist/index.d.ts CHANGED
@@ -4,4 +4,4 @@ export { type NodeClickHouseClientConfigOptions as ClickHouseClientConfigOptions
4
4
  export { ResultSet, type StreamReadable } from './result_set';
5
5
  export { drainStream } from './connection/stream';
6
6
  /** Re-export @clickhouse/client-common types */
7
- export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type RawDataFormat, type JSONDataFormat, type StreamableDataFormat, type StreamableJSONDataFormat, type SingleDocumentJSONFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, ClickHouseError, ClickHouseLogLevel, SettingsMap, SupportedJSONFormats, SupportedRawFormats, StreamableFormats, StreamableJSONFormats, SingleDocumentJSONFormats, RecordsJSONFormats, type SimpleColumnType, type ParsedColumnSimple, type ParsedColumnEnum, type ParsedColumnFixedString, type ParsedColumnNullable, type ParsedColumnDecimal, type ParsedColumnDateTime, type ParsedColumnDateTime64, type ParsedColumnArray, type ParsedColumnTuple, type ParsedColumnMap, type ParsedColumnType, parseColumnType, SimpleColumnTypes, type ProgressRow, isProgressRow, type RowOrProgress, } from '@clickhouse/client-common';
7
+ export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type RawDataFormat, type JSONDataFormat, type StreamableDataFormat, type StreamableJSONDataFormat, type SingleDocumentJSONFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, ClickHouseError, ClickHouseLogLevel, SettingsMap, SupportedJSONFormats, SupportedRawFormats, StreamableFormats, StreamableJSONFormats, SingleDocumentJSONFormats, RecordsJSONFormats, type SimpleColumnType, type ParsedColumnSimple, type ParsedColumnEnum, type ParsedColumnFixedString, type ParsedColumnNullable, type ParsedColumnDecimal, type ParsedColumnDateTime, type ParsedColumnDateTime64, type ParsedColumnArray, type ParsedColumnTuple, type ParsedColumnMap, type ParsedColumnType, parseColumnType, SimpleColumnTypes, type ProgressRow, isProgressRow, type RowOrProgress, TupleParam, } from '@clickhouse/client-common';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isProgressRow = exports.SimpleColumnTypes = exports.parseColumnType = exports.SettingsMap = exports.ClickHouseLogLevel = exports.ClickHouseError = exports.drainStream = exports.ResultSet = exports.createClient = exports.ClickHouseClient = void 0;
3
+ exports.TupleParam = exports.isProgressRow = exports.SimpleColumnTypes = exports.parseColumnType = exports.SettingsMap = exports.ClickHouseLogLevel = exports.ClickHouseError = exports.drainStream = exports.ResultSet = exports.createClient = exports.ClickHouseClient = void 0;
4
4
  var client_1 = require("./client");
5
5
  Object.defineProperty(exports, "ClickHouseClient", { enumerable: true, get: function () { return client_1.NodeClickHouseClient; } });
6
6
  var client_2 = require("./client");
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "SettingsMap", { enumerable: true, get: function
17
17
  Object.defineProperty(exports, "parseColumnType", { enumerable: true, get: function () { return client_common_1.parseColumnType; } });
18
18
  Object.defineProperty(exports, "SimpleColumnTypes", { enumerable: true, get: function () { return client_common_1.SimpleColumnTypes; } });
19
19
  Object.defineProperty(exports, "isProgressRow", { enumerable: true, get: function () { return client_common_1.isProgressRow; } });
20
+ Object.defineProperty(exports, "TupleParam", { enumerable: true, get: function () { return client_common_1.TupleParam; } });
20
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/client-node/src/index.ts"],"names":[],"mappings":";;;AAAA,mCAGiB;AAFf,0GAAA,oBAAoB,OAAoB;AAG1C,mCAAuC;AAA9B,sGAAA,YAAY,OAAA;AAErB,2CAA6D;AAApD,uGAAA,SAAS,OAAA;AAClB,8CAAiD;AAAxC,qGAAA,WAAW,OAAA;AAEpB,gDAAgD;AAChD,2DAuDkC;AA1BhC,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,4GAAA,WAAW,OAAA;AAmBX,gHAAA,eAAe,OAAA;AACf,kHAAA,iBAAiB,OAAA;AAEjB,8GAAA,aAAa,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/client-node/src/index.ts"],"names":[],"mappings":";;;AAAA,mCAGiB;AAFf,0GAAA,oBAAoB,OAAoB;AAG1C,mCAAuC;AAA9B,sGAAA,YAAY,OAAA;AAErB,2CAA6D;AAApD,uGAAA,SAAS,OAAA;AAClB,8CAAiD;AAAxC,qGAAA,WAAW,OAAA;AAEpB,gDAAgD;AAChD,2DAwDkC;AA3BhC,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,4GAAA,WAAW,OAAA;AAmBX,gHAAA,eAAe,OAAA;AACf,kHAAA,iBAAiB,OAAA;AAEjB,8GAAA,aAAa,OAAA;AAEb,2GAAA,UAAU,OAAA"}
@@ -7,6 +7,8 @@ exports.isStream = isStream;
7
7
  exports.getAsText = getAsText;
8
8
  exports.mapStream = mapStream;
9
9
  const stream_1 = __importDefault(require("stream"));
10
+ // See https://github.com/v8/v8/commit/ea56bf5513d0cbd2a35a9035c5c2996272b8b728
11
+ const MaxStringLength = Math.pow(2, 29) - 24;
10
12
  function isStream(obj) {
11
13
  return obj !== null && typeof obj.pipe === 'function';
12
14
  }
@@ -14,7 +16,12 @@ async function getAsText(stream) {
14
16
  let text = '';
15
17
  const textDecoder = new TextDecoder();
16
18
  for await (const chunk of stream) {
17
- text += textDecoder.decode(chunk, { stream: true });
19
+ const decoded = textDecoder.decode(chunk, { stream: true });
20
+ if (decoded.length + text.length > MaxStringLength) {
21
+ throw new Error('The response length exceeds the maximum allowed size of V8 String: ' +
22
+ `${MaxStringLength}; consider limiting the amount of requested rows.`);
23
+ }
24
+ text += decoded;
18
25
  }
19
26
  // flush
20
27
  const last = textDecoder.decode();
@@ -1 +1 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../../packages/client-node/src/utils/stream.ts"],"names":[],"mappings":";;;;;AAEA,4BAEC;AAED,8BAeC;AAED,8BASC;AAhCD,oDAA2B;AAE3B,SAAgB,QAAQ,CAAC,GAAQ;IAC/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,GAAG,EAAE,CAAA;IAEb,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAA;IACrC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QAC3D,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CACb,qEAAqE;gBACnE,GAAG,eAAe,mDAAmD,CACxE,CAAA;QACH,CAAC;QACD,IAAI,IAAI,OAAO,CAAA;IACjB,CAAC;IAED,QAAQ;IACR,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,CAAA;IACjC,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,IAAI,IAAI,CAAA;IACd,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAgB,SAAS,CACvB,MAAkC;IAElC,OAAO,IAAI,gBAAM,CAAC,SAAS,CAAC;QAC1B,UAAU,EAAE,IAAI;QAChB,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ;YACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAC/B,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.8.0";
1
+ declare const _default: "1.9.0";
2
2
  export default _default;
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.8.0';
3
+ exports.default = '1.9.0';
4
4
  //# sourceMappingURL=version.js.map
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": "1.8.0",
5
+ "version": "1.9.0",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "clickhouse",
@@ -23,6 +23,6 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@clickhouse/client-common": "1.8.0"
26
+ "@clickhouse/client-common": "1.9.0"
27
27
  }
28
28
  }