@clickhouse/client 0.1.0 → 0.2.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +10 -6
  2. package/dist/client.d.ts +26 -128
  3. package/dist/client.js +39 -225
  4. package/dist/client.js.map +1 -1
  5. package/dist/connection/index.d.ts +3 -1
  6. package/dist/connection/index.js +3 -1
  7. package/dist/connection/index.js.map +1 -1
  8. package/dist/connection/node_base_connection.d.ts +50 -0
  9. package/dist/connection/node_base_connection.js +350 -0
  10. package/dist/connection/node_base_connection.js.map +1 -0
  11. package/dist/connection/node_http_connection.d.ts +11 -0
  12. package/dist/connection/node_http_connection.js +32 -0
  13. package/dist/connection/node_http_connection.js.map +1 -0
  14. package/dist/connection/node_https_connection.d.ts +12 -0
  15. package/dist/connection/node_https_connection.js +53 -0
  16. package/dist/connection/node_https_connection.js.map +1 -0
  17. package/dist/index.d.ts +4 -15
  18. package/dist/index.js +11 -9
  19. package/dist/index.js.map +1 -1
  20. package/dist/result_set.d.ts +13 -0
  21. package/dist/{result.js → result_set.js} +5 -32
  22. package/dist/result_set.js.map +1 -0
  23. package/dist/utils/encoder.d.ts +7 -0
  24. package/dist/utils/encoder.js +55 -0
  25. package/dist/utils/encoder.js.map +1 -0
  26. package/dist/utils/index.d.ts +3 -1
  27. package/dist/utils/index.js +3 -1
  28. package/dist/utils/index.js.map +1 -1
  29. package/dist/utils/process.js.map +1 -1
  30. package/dist/utils/stream.d.ts +1 -1
  31. package/dist/utils/stream.js.map +1 -1
  32. package/dist/utils/user_agent.js +1 -2
  33. package/dist/utils/user_agent.js.map +1 -1
  34. package/dist/version.d.ts +2 -2
  35. package/dist/version.js +2 -1
  36. package/dist/version.js.map +1 -1
  37. package/package.json +7 -48
  38. package/dist/clickhouse_types.d.ts +0 -24
  39. package/dist/clickhouse_types.js +0 -3
  40. package/dist/clickhouse_types.js.map +0 -1
  41. package/dist/connection/adapter/base_http_adapter.d.ts +0 -35
  42. package/dist/connection/adapter/base_http_adapter.js +0 -302
  43. package/dist/connection/adapter/base_http_adapter.js.map +0 -1
  44. package/dist/connection/adapter/http_adapter.d.ts +0 -10
  45. package/dist/connection/adapter/http_adapter.js +0 -27
  46. package/dist/connection/adapter/http_adapter.js.map +0 -1
  47. package/dist/connection/adapter/http_search_params.d.ts +0 -11
  48. package/dist/connection/adapter/http_search_params.js +0 -42
  49. package/dist/connection/adapter/http_search_params.js.map +0 -1
  50. package/dist/connection/adapter/https_adapter.d.ts +0 -11
  51. package/dist/connection/adapter/https_adapter.js +0 -48
  52. package/dist/connection/adapter/https_adapter.js.map +0 -1
  53. package/dist/connection/adapter/index.d.ts +0 -2
  54. package/dist/connection/adapter/index.js +0 -8
  55. package/dist/connection/adapter/index.js.map +0 -1
  56. package/dist/connection/adapter/transform_url.d.ts +0 -5
  57. package/dist/connection/adapter/transform_url.js +0 -15
  58. package/dist/connection/adapter/transform_url.js.map +0 -1
  59. package/dist/connection/connection.d.ts +0 -58
  60. package/dist/connection/connection.js +0 -17
  61. package/dist/connection/connection.js.map +0 -1
  62. package/dist/data_formatter/format_query_params.d.ts +0 -1
  63. package/dist/data_formatter/format_query_params.js +0 -61
  64. package/dist/data_formatter/format_query_params.js.map +0 -1
  65. package/dist/data_formatter/format_query_settings.d.ts +0 -2
  66. package/dist/data_formatter/format_query_settings.js +0 -21
  67. package/dist/data_formatter/format_query_settings.js.map +0 -1
  68. package/dist/data_formatter/formatter.d.ts +0 -23
  69. package/dist/data_formatter/formatter.js +0 -96
  70. package/dist/data_formatter/formatter.js.map +0 -1
  71. package/dist/data_formatter/index.d.ts +0 -3
  72. package/dist/data_formatter/index.js +0 -23
  73. package/dist/data_formatter/index.js.map +0 -1
  74. package/dist/error/index.d.ts +0 -1
  75. package/dist/error/index.js +0 -18
  76. package/dist/error/index.js.map +0 -1
  77. package/dist/error/parse_error.d.ts +0 -12
  78. package/dist/error/parse_error.js +0 -39
  79. package/dist/error/parse_error.js.map +0 -1
  80. package/dist/logger.d.ts +0 -30
  81. package/dist/logger.js +0 -100
  82. package/dist/logger.js.map +0 -1
  83. package/dist/result.d.ts +0 -52
  84. package/dist/result.js.map +0 -1
  85. package/dist/schema/common.d.ts +0 -8
  86. package/dist/schema/common.js +0 -3
  87. package/dist/schema/common.js.map +0 -1
  88. package/dist/schema/engines.d.ts +0 -40
  89. package/dist/schema/engines.js +0 -61
  90. package/dist/schema/engines.js.map +0 -1
  91. package/dist/schema/index.d.ts +0 -7
  92. package/dist/schema/index.js +0 -24
  93. package/dist/schema/index.js.map +0 -1
  94. package/dist/schema/query_formatter.d.ts +0 -9
  95. package/dist/schema/query_formatter.js +0 -48
  96. package/dist/schema/query_formatter.js.map +0 -1
  97. package/dist/schema/result.d.ts +0 -13
  98. package/dist/schema/result.js +0 -3
  99. package/dist/schema/result.js.map +0 -1
  100. package/dist/schema/schema.d.ts +0 -6
  101. package/dist/schema/schema.js +0 -20
  102. package/dist/schema/schema.js.map +0 -1
  103. package/dist/schema/stream.d.ts +0 -11
  104. package/dist/schema/stream.js +0 -25
  105. package/dist/schema/stream.js.map +0 -1
  106. package/dist/schema/table.d.ts +0 -44
  107. package/dist/schema/table.js +0 -73
  108. package/dist/schema/table.js.map +0 -1
  109. package/dist/schema/types.d.ts +0 -201
  110. package/dist/schema/types.js +0 -268
  111. package/dist/schema/types.js.map +0 -1
  112. package/dist/schema/where.d.ts +0 -8
  113. package/dist/schema/where.js +0 -43
  114. package/dist/schema/where.js.map +0 -1
  115. package/dist/settings.d.ts +0 -1453
  116. package/dist/settings.js +0 -28
  117. package/dist/settings.js.map +0 -1
  118. package/dist/utils/string.d.ts +0 -1
  119. package/dist/utils/string.js +0 -9
  120. package/dist/utils/string.js.map +0 -1
package/README.md CHANGED
@@ -1,22 +1,26 @@
1
1
  <p align="center">
2
2
  <img src=".static/logo.png" width="200px" align="center">
3
- <h1 align="center">ClickHouse Node.JS client</h1>
3
+ <h1 align="center">ClickHouse JS client</h1>
4
4
  </p>
5
5
  <br/>
6
6
  <p align="center">
7
7
  <a href="https://github.com/ClickHouse/clickhouse-js/actions/workflows/tests.yml">
8
8
  <img src="https://github.com/ClickHouse/clickhouse-js/actions/workflows/tests.yml/badge.svg?branch=main">
9
9
  </a>
10
- <a href="http://htmlpreview.github.io/?https://github.com/ClickHouse/clickhouse-js/blob/main/coverage/lcov-report/index.html">
11
- <img src="./coverage/badge.svg">
12
- </a>
13
10
  </p>
14
11
 
15
12
  ## About
16
13
 
17
- Official Node.js client for [ClickHouse](https://clickhouse.com/), written purely in TypeScript, thoroughly tested with actual ClickHouse versions.
14
+ Official JS client for [ClickHouse](https://clickhouse.com/), written purely in TypeScript,
15
+ thoroughly tested with actual ClickHouse versions.
16
+
17
+ The repository consists of three packages:
18
18
 
19
- It is focused on data streaming for both inserts and selects using standard [Node.js Streaming API](https://nodejs.org/docs/latest-v14.x/api/stream.html).
19
+ - `@clickhouse/client` - Node.js client, built on top of [HTTP](https://nodejs.org/api/http.html)
20
+ and [Stream](https://nodejs.org/api/stream.html) APIs; supports streaming for both selects and inserts.
21
+ - `@clickhouse/client-browser` - browser client, built on top of [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
22
+ and [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) APIs; supports streaming for selects.
23
+ - `@clickhouse/common` - shared common types and the base framework for building a custom client implementation.
20
24
 
21
25
  ## Documentation
22
26
 
package/dist/client.d.ts CHANGED
@@ -1,42 +1,30 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import Stream from 'stream';
4
- import type { ExecResult, InsertResult } from './connection';
5
- import type { Logger } from './logger';
6
- import { type DataFormat } from './data_formatter';
7
- import { ResultSet } from './result';
8
- import type { ClickHouseSettings } from './settings';
9
- import type { InputJSON, InputJSONObjectEachRow } from './clickhouse_types';
10
- export interface ClickHouseClientConfigOptions {
11
- /** A ClickHouse instance URL. Default value: `http://localhost:8123`. */
12
- host?: string;
13
- /** The request timeout in milliseconds. Default value: `30_000`. */
14
- request_timeout?: number;
15
- /** Maximum number of sockets to allow per host. Default value: `Infinity`. */
16
- max_open_connections?: number;
17
- compression?: {
18
- /** `response: true` instructs ClickHouse server to respond with compressed response body. Default: true. */
19
- response?: boolean;
20
- /** `request: true` enabled compression on the client request body. Default: false. */
21
- request?: boolean;
22
- };
23
- /** The name of the user on whose behalf requests are made. Default: 'default'. */
24
- username?: string;
25
- /** The user password. Default: ''. */
26
- password?: string;
27
- /** The name of the application using the nodejs client. Default: empty. */
28
- application?: string;
29
- /** Database name to use. Default value: `default`. */
30
- database?: string;
31
- /** ClickHouse settings to apply to all requests. Default value: {} */
32
- clickhouse_settings?: ClickHouseSettings;
33
- log?: {
34
- /** A class to instantiate a custom logger implementation. */
35
- LoggerClass?: new () => Logger;
36
- };
3
+ import type { BaseClickHouseClientConfigOptions, Connection } from '@clickhouse/client-common';
4
+ import { ClickHouseClient } from '@clickhouse/client-common';
5
+ import type Stream from 'stream';
6
+ import type { NodeConnectionParams } from './connection';
7
+ export type NodeClickHouseClientConfigOptions = BaseClickHouseClientConfigOptions<Stream.Readable> & {
37
8
  tls?: BasicTLSOptions | MutualTLSOptions;
38
- session_id?: string;
39
- }
9
+ /** HTTP Keep-Alive related settings */
10
+ keep_alive?: {
11
+ /** Enable or disable HTTP Keep-Alive mechanism. Default: true */
12
+ enabled?: boolean;
13
+ /** How long to keep a particular open socket alive
14
+ * on the client side (in milliseconds).
15
+ * Should be less than the server setting
16
+ * (see `keep_alive_timeout` in server's `config.xml`).
17
+ * Currently, has no effect if {@link retry_on_expired_socket}
18
+ * is unset or false. Default value: 2500
19
+ * (based on the default ClickHouse server setting, which is 3000) */
20
+ socket_ttl?: number;
21
+ /** If the client detects a potentially expired socket based on the
22
+ * {@link socket_ttl}, this socket will be immediately destroyed
23
+ * before sending the request, and this request will be retried
24
+ * with a new socket up to 3 times. Default: false (no retries) */
25
+ retry_on_expired_socket?: boolean;
26
+ };
27
+ };
40
28
  interface BasicTLSOptions {
41
29
  ca_cert: Buffer;
42
30
  }
@@ -45,96 +33,6 @@ interface MutualTLSOptions {
45
33
  cert: Buffer;
46
34
  key: Buffer;
47
35
  }
48
- export interface BaseParams {
49
- /** ClickHouse settings that can be applied on query level. */
50
- clickhouse_settings?: ClickHouseSettings;
51
- /** Parameters for query binding. https://clickhouse.com/docs/en/interfaces/http/#cli-queries-with-parameters */
52
- query_params?: Record<string, unknown>;
53
- /** AbortSignal instance to cancel a request in progress. */
54
- abort_signal?: AbortSignal;
55
- /** A specific `query_id` that will be sent with this request.
56
- * If it is not set, a random identifier will be generated automatically by the client. */
57
- query_id?: string;
58
- }
59
- export interface QueryParams extends BaseParams {
60
- /** Statement to execute. */
61
- query: string;
62
- /** Format of the resulting dataset. */
63
- format?: DataFormat;
64
- }
65
- export interface ExecParams extends BaseParams {
66
- /** Statement to execute. */
67
- query: string;
68
- }
69
- export type CommandParams = ExecParams;
70
- export interface CommandResult {
71
- query_id: string;
72
- }
73
- type InsertValues<T> = ReadonlyArray<T> | Stream.Readable | InputJSON<T> | InputJSONObjectEachRow<T>;
74
- export interface InsertParams<T = unknown> extends BaseParams {
75
- /** Name of a table to insert into. */
76
- table: string;
77
- /** A dataset to insert. */
78
- values: InsertValues<T>;
79
- /** Format of the dataset to insert. */
80
- format?: DataFormat;
81
- }
82
- export declare class ClickHouseClient {
83
- private readonly config;
84
- private readonly connection;
85
- private readonly logger;
86
- constructor(config?: ClickHouseClientConfigOptions);
87
- private getBaseParams;
88
- /**
89
- * Used for most statements that can have a response, such as SELECT.
90
- * FORMAT clause should be specified separately via {@link QueryParams.format} (default is JSON)
91
- * Consider using {@link ClickHouseClient.insert} for data insertion,
92
- * or {@link ClickHouseClient.command} for DDLs.
93
- */
94
- query(params: QueryParams): Promise<ResultSet>;
95
- /**
96
- * It should be used for statements that do not have any output,
97
- * when the format clause is not applicable, or when you are not interested in the response at all.
98
- * Response stream is destroyed immediately as we do not expect useful information there.
99
- * Examples of such statements are DDLs or custom inserts.
100
- * If you are interested in the response data, consider using {@link ClickHouseClient.exec}
101
- */
102
- command(params: CommandParams): Promise<CommandResult>;
103
- /**
104
- * Similar to {@link ClickHouseClient.command}, but for the cases where the output is expected,
105
- * but format clause is not applicable. The caller of this method is expected to consume the stream,
106
- * otherwise, the request will eventually be timed out.
107
- */
108
- exec(params: ExecParams): Promise<ExecResult>;
109
- /**
110
- * The primary method for data insertion. It is recommended to avoid arrays in case of large inserts
111
- * to reduce application memory consumption and consider streaming for most of such use cases.
112
- * As the insert operation does not provide any output, the response stream is immediately destroyed.
113
- * In case of a custom insert operation, such as, for example, INSERT FROM SELECT,
114
- * consider using {@link ClickHouseClient.command}, passing the entire raw query there (including FORMAT clause).
115
- */
116
- insert<T>(params: InsertParams<T>): Promise<InsertResult>;
117
- /**
118
- * Health-check request. Can throw an error if the connection is refused.
119
- */
120
- ping(): Promise<boolean>;
121
- /**
122
- * Shuts down the underlying connection.
123
- * This method should ideally be called only once per application lifecycle,
124
- * for example, during the graceful shutdown phase.
125
- */
126
- close(): Promise<void>;
127
- }
128
- export declare function validateInsertValues<T>(values: InsertValues<T>, format: DataFormat): void;
129
- /**
130
- * A function encodes an array or a stream of JSON objects to a format compatible with ClickHouse.
131
- * If values are provided as an array of JSON objects, the function encodes it in place.
132
- * If values are provided as a stream of JSON objects, the function sets up the encoding of each chunk.
133
- * If values are provided as a raw non-object stream, the function does nothing.
134
- *
135
- * @param values a set of values to send to ClickHouse.
136
- * @param format a format to encode value to.
137
- */
138
- export declare function encodeValues<T>(values: InsertValues<T>, format: DataFormat): string | Stream.Readable;
139
- export declare function createClient(config?: ClickHouseClientConfigOptions): ClickHouseClient;
36
+ export declare function createClient(config?: NodeClickHouseClientConfigOptions): ClickHouseClient<Stream.Readable>;
37
+ export declare function createConnection(params: NodeConnectionParams): Connection<Stream.Readable>;
140
38
  export {};
package/dist/client.js CHANGED
@@ -1,33 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createClient = exports.encodeValues = exports.validateInsertValues = exports.ClickHouseClient = void 0;
7
- const stream_1 = __importDefault(require("stream"));
3
+ exports.createConnection = exports.createClient = void 0;
4
+ const client_common_1 = require("@clickhouse/client-common");
8
5
  const connection_1 = require("./connection");
9
- const logger_1 = require("./logger");
6
+ const result_set_1 = require("./result_set");
10
7
  const utils_1 = require("./utils");
11
- const data_formatter_1 = require("./data_formatter");
12
- const result_1 = require("./result");
13
- function validateConfig({ url }) {
14
- if (url.protocol !== 'http:' && url.protocol !== 'https:') {
15
- throw new Error(`Only http(s) protocol is supported, but given: [${url.protocol}]`);
16
- }
17
- // TODO add SSL validation
18
- }
19
- function createUrl(host) {
20
- try {
21
- return new URL(host);
22
- }
23
- catch (err) {
24
- throw new Error('Configuration parameter "host" contains malformed url.');
25
- }
26
- }
27
- function normalizeConfig(config) {
28
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
8
+ function createClient(config) {
9
+ var _a, _b, _c, _d, _e, _f;
29
10
  let tls = undefined;
30
- if (config.tls) {
11
+ if (config === null || config === void 0 ? void 0 : config.tls) {
31
12
  if ('cert' in config.tls && 'key' in config.tls) {
32
13
  tls = {
33
14
  type: 'Mutual',
@@ -41,210 +22,43 @@ function normalizeConfig(config) {
41
22
  };
42
23
  }
43
24
  }
44
- return {
45
- application_id: config.application,
46
- url: createUrl((_a = config.host) !== null && _a !== void 0 ? _a : 'http://localhost:8123'),
47
- request_timeout: (_b = config.request_timeout) !== null && _b !== void 0 ? _b : 300000,
48
- max_open_connections: (_c = config.max_open_connections) !== null && _c !== void 0 ? _c : Infinity,
49
- tls,
50
- compression: {
51
- decompress_response: (_e = (_d = config.compression) === null || _d === void 0 ? void 0 : _d.response) !== null && _e !== void 0 ? _e : true,
52
- compress_request: (_g = (_f = config.compression) === null || _f === void 0 ? void 0 : _f.request) !== null && _g !== void 0 ? _g : false,
53
- },
54
- username: (_h = config.username) !== null && _h !== void 0 ? _h : 'default',
55
- password: (_j = config.password) !== null && _j !== void 0 ? _j : '',
56
- application: (_k = config.application) !== null && _k !== void 0 ? _k : 'clickhouse-js',
57
- database: (_l = config.database) !== null && _l !== void 0 ? _l : 'default',
58
- clickhouse_settings: (_m = config.clickhouse_settings) !== null && _m !== void 0 ? _m : {},
59
- log: {
60
- LoggerClass: (_p = (_o = config.log) === null || _o === void 0 ? void 0 : _o.LoggerClass) !== null && _p !== void 0 ? _p : logger_1.DefaultLogger,
61
- },
62
- session_id: config.session_id,
25
+ const keep_alive = {
26
+ enabled: (_b = (_a = config === null || config === void 0 ? void 0 : config.keep_alive) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true,
27
+ socket_ttl: (_d = (_c = config === null || config === void 0 ? void 0 : config.keep_alive) === null || _c === void 0 ? void 0 : _c.socket_ttl) !== null && _d !== void 0 ? _d : 2500,
28
+ retry_on_expired_socket: (_f = (_e = config === null || config === void 0 ? void 0 : config.keep_alive) === null || _e === void 0 ? void 0 : _e.retry_on_expired_socket) !== null && _f !== void 0 ? _f : false,
63
29
  };
64
- }
65
- class ClickHouseClient {
66
- constructor(config = {}) {
67
- Object.defineProperty(this, "config", {
68
- enumerable: true,
69
- configurable: true,
70
- writable: true,
71
- value: void 0
72
- });
73
- Object.defineProperty(this, "connection", {
74
- enumerable: true,
75
- configurable: true,
76
- writable: true,
77
- value: void 0
78
- });
79
- Object.defineProperty(this, "logger", {
80
- enumerable: true,
81
- configurable: true,
82
- writable: true,
83
- value: void 0
84
- });
85
- this.config = normalizeConfig(config);
86
- validateConfig(this.config);
87
- this.logger = new logger_1.LogWriter(new this.config.log.LoggerClass());
88
- this.connection = (0, connection_1.createConnection)(this.config, this.logger);
89
- }
90
- getBaseParams(params) {
91
- return {
92
- clickhouse_settings: {
93
- ...this.config.clickhouse_settings,
94
- ...params.clickhouse_settings,
30
+ return new client_common_1.ClickHouseClient({
31
+ impl: {
32
+ make_connection: (params) => {
33
+ switch (params.url.protocol) {
34
+ case 'http:':
35
+ return new connection_1.NodeHttpConnection({ ...params, keep_alive });
36
+ case 'https:':
37
+ return new connection_1.NodeHttpsConnection({ ...params, tls, keep_alive });
38
+ default:
39
+ throw new Error('Only HTTP(s) adapters are supported');
40
+ }
95
41
  },
96
- query_params: params.query_params,
97
- abort_signal: params.abort_signal,
98
- session_id: this.config.session_id,
99
- query_id: params.query_id,
100
- };
101
- }
102
- /**
103
- * Used for most statements that can have a response, such as SELECT.
104
- * FORMAT clause should be specified separately via {@link QueryParams.format} (default is JSON)
105
- * Consider using {@link ClickHouseClient.insert} for data insertion,
106
- * or {@link ClickHouseClient.command} for DDLs.
107
- */
108
- async query(params) {
109
- var _a;
110
- const format = (_a = params.format) !== null && _a !== void 0 ? _a : 'JSON';
111
- const query = formatQuery(params.query, format);
112
- const { stream, query_id } = await this.connection.query({
113
- query,
114
- ...this.getBaseParams(params),
115
- });
116
- return new result_1.ResultSet(stream, format, query_id);
117
- }
118
- /**
119
- * It should be used for statements that do not have any output,
120
- * when the format clause is not applicable, or when you are not interested in the response at all.
121
- * Response stream is destroyed immediately as we do not expect useful information there.
122
- * Examples of such statements are DDLs or custom inserts.
123
- * If you are interested in the response data, consider using {@link ClickHouseClient.exec}
124
- */
125
- async command(params) {
126
- const { stream, query_id } = await this.exec(params);
127
- stream.destroy();
128
- return { query_id };
129
- }
130
- /**
131
- * Similar to {@link ClickHouseClient.command}, but for the cases where the output is expected,
132
- * but format clause is not applicable. The caller of this method is expected to consume the stream,
133
- * otherwise, the request will eventually be timed out.
134
- */
135
- async exec(params) {
136
- const query = removeTrailingSemi(params.query.trim());
137
- return await this.connection.exec({
138
- query,
139
- ...this.getBaseParams(params),
140
- });
141
- }
142
- /**
143
- * The primary method for data insertion. It is recommended to avoid arrays in case of large inserts
144
- * to reduce application memory consumption and consider streaming for most of such use cases.
145
- * As the insert operation does not provide any output, the response stream is immediately destroyed.
146
- * In case of a custom insert operation, such as, for example, INSERT FROM SELECT,
147
- * consider using {@link ClickHouseClient.command}, passing the entire raw query there (including FORMAT clause).
148
- */
149
- async insert(params) {
150
- const format = params.format || 'JSONCompactEachRow';
151
- validateInsertValues(params.values, format);
152
- const query = `INSERT INTO ${params.table.trim()} FORMAT ${format}`;
153
- return await this.connection.insert({
154
- query,
155
- values: encodeValues(params.values, format),
156
- ...this.getBaseParams(params),
157
- });
158
- }
159
- /**
160
- * Health-check request. Can throw an error if the connection is refused.
161
- */
162
- async ping() {
163
- return await this.connection.ping();
164
- }
165
- /**
166
- * Shuts down the underlying connection.
167
- * This method should ideally be called only once per application lifecycle,
168
- * for example, during the graceful shutdown phase.
169
- */
170
- async close() {
171
- return await this.connection.close();
172
- }
173
- }
174
- exports.ClickHouseClient = ClickHouseClient;
175
- function formatQuery(query, format) {
176
- query = query.trim();
177
- query = removeTrailingSemi(query);
178
- return query + ' \nFORMAT ' + format;
179
- }
180
- function removeTrailingSemi(query) {
181
- let lastNonSemiIdx = query.length;
182
- for (let i = lastNonSemiIdx; i > 0; i--) {
183
- if (query[i - 1] !== ';') {
184
- lastNonSemiIdx = i;
185
- break;
186
- }
187
- }
188
- if (lastNonSemiIdx !== query.length) {
189
- return query.slice(0, lastNonSemiIdx);
190
- }
191
- return query;
192
- }
193
- function validateInsertValues(values, format) {
194
- if (!Array.isArray(values) &&
195
- !(0, utils_1.isStream)(values) &&
196
- typeof values !== 'object') {
197
- throw new Error('Insert expected "values" to be an array, a stream of values or a JSON object, ' +
198
- `got: ${typeof values}`);
199
- }
200
- if ((0, utils_1.isStream)(values)) {
201
- if ((0, data_formatter_1.isSupportedRawFormat)(format)) {
202
- if (values.readableObjectMode) {
203
- throw new Error(`Insert for ${format} expected Readable Stream with disabled object mode.`);
204
- }
205
- }
206
- else if (!values.readableObjectMode) {
207
- throw new Error(`Insert for ${format} expected Readable Stream with enabled object mode.`);
208
- }
209
- }
210
- }
211
- exports.validateInsertValues = validateInsertValues;
212
- /**
213
- * A function encodes an array or a stream of JSON objects to a format compatible with ClickHouse.
214
- * If values are provided as an array of JSON objects, the function encodes it in place.
215
- * If values are provided as a stream of JSON objects, the function sets up the encoding of each chunk.
216
- * If values are provided as a raw non-object stream, the function does nothing.
217
- *
218
- * @param values a set of values to send to ClickHouse.
219
- * @param format a format to encode value to.
220
- */
221
- function encodeValues(values, format) {
222
- if ((0, utils_1.isStream)(values)) {
223
- // TSV/CSV/CustomSeparated formats don't require additional serialization
224
- if (!values.readableObjectMode) {
225
- return values;
226
- }
227
- // JSON* formats streams
228
- return stream_1.default.pipeline(values, (0, utils_1.mapStream)((value) => (0, data_formatter_1.encodeJSON)(value, format)), pipelineCb);
229
- }
230
- // JSON* arrays
231
- if (Array.isArray(values)) {
232
- return values.map((value) => (0, data_formatter_1.encodeJSON)(value, format)).join('');
233
- }
234
- // JSON & JSONObjectEachRow format input
235
- if (typeof values === 'object') {
236
- return (0, data_formatter_1.encodeJSON)(values, format);
237
- }
238
- throw new Error(`Cannot encode values of type ${typeof values} with ${format} format`);
239
- }
240
- exports.encodeValues = encodeValues;
241
- function createClient(config) {
242
- return new ClickHouseClient(config);
42
+ make_result_set: (stream, format, session_id) => new result_set_1.ResultSet(stream, format, session_id),
43
+ values_encoder: new utils_1.NodeValuesEncoder(),
44
+ close_stream: async (stream) => {
45
+ stream.destroy();
46
+ },
47
+ },
48
+ ...(config || {}),
49
+ });
243
50
  }
244
51
  exports.createClient = createClient;
245
- function pipelineCb(err) {
246
- if (err) {
247
- console.error(err);
52
+ function createConnection(params) {
53
+ // TODO throw ClickHouseClient error
54
+ switch (params.url.protocol) {
55
+ case 'http:':
56
+ return new connection_1.NodeHttpConnection(params);
57
+ case 'https:':
58
+ return new connection_1.NodeHttpsConnection(params);
59
+ default:
60
+ throw new Error('Only HTTP(s) adapters are supported');
248
61
  }
249
62
  }
63
+ exports.createConnection = createConnection;
250
64
  //# sourceMappingURL=client.js.map
@@ -1 +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zD;AACH,CAAC;AAZD,4CAYC"}
@@ -1 +1,3 @@
1
- export * from './connection';
1
+ export * from './node_base_connection';
2
+ export * from './node_http_connection';
3
+ export * from './node_https_connection';
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./connection"), exports);
17
+ __exportStar(require("./node_base_connection"), exports);
18
+ __exportStar(require("./node_http_connection"), exports);
19
+ __exportStar(require("./node_https_connection"), exports);
18
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/client-node/src/connection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAsC;AACtC,yDAAsC;AACtC,0DAAuC"}
@@ -0,0 +1,50 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import type { ConnBaseQueryParams, Connection, ConnectionParams, ConnExecResult, ConnInsertParams, ConnInsertResult, ConnQueryResult } from '@clickhouse/client-common';
5
+ import type Http from 'http';
6
+ import Stream from 'stream';
7
+ export type NodeConnectionParams = ConnectionParams & {
8
+ tls?: TLSParams;
9
+ keep_alive: {
10
+ enabled: boolean;
11
+ socket_ttl: number;
12
+ retry_on_expired_socket: boolean;
13
+ };
14
+ };
15
+ export type TLSParams = {
16
+ ca_cert: Buffer;
17
+ type: 'Basic';
18
+ } | {
19
+ ca_cert: Buffer;
20
+ cert: Buffer;
21
+ key: Buffer;
22
+ type: 'Mutual';
23
+ };
24
+ export interface RequestParams {
25
+ method: 'GET' | 'POST';
26
+ url: URL;
27
+ body?: string | Stream.Readable;
28
+ abort_signal?: AbortSignal;
29
+ decompress_response?: boolean;
30
+ compress_request?: boolean;
31
+ }
32
+ export declare abstract class NodeBaseConnection implements Connection<Stream.Readable> {
33
+ protected readonly params: NodeConnectionParams;
34
+ protected readonly agent: Http.Agent;
35
+ protected readonly headers: Http.OutgoingHttpHeaders;
36
+ private readonly logger;
37
+ private readonly retry_expired_sockets;
38
+ private readonly known_sockets;
39
+ protected constructor(params: NodeConnectionParams, agent: Http.Agent);
40
+ protected buildDefaultHeaders(username: string, password: string): Http.OutgoingHttpHeaders;
41
+ protected abstract createClientRequest(params: RequestParams): Http.ClientRequest;
42
+ private request;
43
+ private _request;
44
+ ping(): Promise<boolean>;
45
+ query(params: ConnBaseQueryParams): Promise<ConnQueryResult<Stream.Readable>>;
46
+ exec(params: ConnBaseQueryParams): Promise<ConnExecResult<Stream.Readable>>;
47
+ insert(params: ConnInsertParams<Stream.Readable>): Promise<ConnInsertResult>;
48
+ close(): Promise<void>;
49
+ private logResponse;
50
+ }