@clickhouse/client
Advanced tools
Comparing version 1.1.0 to 1.2.0
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { ImplementationDetails } from '@clickhouse/client-common'; | ||
import { type BaseClickHouseClientConfigOptions } from '@clickhouse/client-common'; | ||
import type http from 'http'; | ||
import type https from 'node:https'; | ||
import type Stream from 'stream'; | ||
@@ -15,6 +19,17 @@ export type NodeClickHouseClientConfigOptions = BaseClickHouseClientConfigOptions & { | ||
* It is supposed to be a fair bit less that the ClickHouse server KeepAlive timeout, | ||
* which is by default 3000 ms for pre-23.11 versions. | ||
* which is by default 3000 ms for pre-23.11 versions. <br/> | ||
* When set to `0`, the idle socket management feature is disabled. | ||
* @default 2500 */ | ||
idle_socket_ttl?: number; | ||
}; | ||
/** Custom HTTP agent to use for the outgoing HTTP(s) requests. | ||
* If set, {@link BaseClickHouseClientConfigOptions.max_open_connections}, {@link tls} and {@link keep_alive} | ||
* options have no effect, as it is part of the default underlying agent configuration. | ||
* @experimental - unstable API, might be a subject to change in the future; please provide your feedback in the repository. | ||
* @default undefined */ | ||
http_agent?: http.Agent | https.Agent; | ||
/** Enable or disable the `Authorization` header with basic auth for the outgoing HTTP(s) requests. | ||
* @experimental - unstable API, might be a subject to change in the future; please provide your feedback in the repository. | ||
* @default true (enabled) */ | ||
set_basic_auth_header?: boolean; | ||
}; | ||
@@ -21,0 +36,0 @@ interface BasicTLSOptions { |
@@ -61,3 +61,9 @@ "use strict"; | ||
}; | ||
return (0, connection_1.createConnection)(params, tls, keep_alive); | ||
return (0, connection_1.createConnection)({ | ||
connection_params: params, | ||
set_basic_auth_header: nodeConfig.set_basic_auth_header ?? true, | ||
http_agent: nodeConfig.http_agent, | ||
keep_alive, | ||
tls, | ||
}); | ||
}, | ||
@@ -64,0 +70,0 @@ values_encoder: new utils_1.NodeValuesEncoder(), |
@@ -0,3 +1,14 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { ConnectionParams } from '@clickhouse/client-common'; | ||
import type http from 'http'; | ||
import type https from 'node:https'; | ||
import type { NodeBaseConnection, NodeConnectionParams } from './node_base_connection'; | ||
export declare function createConnection(params: ConnectionParams, tls: NodeConnectionParams['tls'], keep_alive: NodeConnectionParams['keep_alive']): NodeBaseConnection; | ||
export interface CreateConnectionParams { | ||
connection_params: ConnectionParams; | ||
tls: NodeConnectionParams['tls']; | ||
keep_alive: NodeConnectionParams['keep_alive']; | ||
http_agent: http.Agent | https.Agent | undefined; | ||
set_basic_auth_header: boolean; | ||
} | ||
export declare function createConnection({ connection_params, tls, keep_alive, http_agent, set_basic_auth_header, }: CreateConnectionParams): NodeBaseConnection; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createConnection = void 0; | ||
const node_custom_agent_connection_1 = require("./node_custom_agent_connection"); | ||
const node_http_connection_1 = require("./node_http_connection"); | ||
const node_https_connection_1 = require("./node_https_connection"); | ||
function createConnection(params, tls, keep_alive) { | ||
switch (params.url.protocol) { | ||
function createConnection({ connection_params, tls, keep_alive, http_agent, set_basic_auth_header, }) { | ||
if (http_agent !== undefined) { | ||
return new node_custom_agent_connection_1.NodeCustomAgentConnection({ | ||
...connection_params, | ||
set_basic_auth_header, | ||
keep_alive, // only used to enforce proper KeepAlive headers | ||
http_agent, | ||
}); | ||
} | ||
switch (connection_params.url.protocol) { | ||
case 'http:': | ||
return new node_http_connection_1.NodeHttpConnection({ ...params, keep_alive }); | ||
return new node_http_connection_1.NodeHttpConnection({ | ||
...connection_params, | ||
set_basic_auth_header, | ||
keep_alive, | ||
}); | ||
case 'https:': | ||
return new node_https_connection_1.NodeHttpsConnection({ ...params, tls, keep_alive }); | ||
return new node_https_connection_1.NodeHttpsConnection({ | ||
...connection_params, | ||
set_basic_auth_header, | ||
keep_alive, | ||
tls, | ||
}); | ||
default: | ||
@@ -13,0 +31,0 @@ throw new Error('Only HTTP and HTTPS protocols are supported'); |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { BaseQueryParams, ConnBaseQueryParams, ConnCommandResult, Connection, ConnectionParams, ConnExecResult, ConnInsertParams, ConnInsertResult, ConnPingResult, ConnQueryResult } from '@clickhouse/client-common'; | ||
import type Http from 'http'; | ||
import type Https from 'node:https'; | ||
import Stream from 'stream'; | ||
export type NodeConnectionParams = ConnectionParams & { | ||
tls?: TLSParams; | ||
http_agent?: Http.Agent | Https.Agent; | ||
set_basic_auth_header: boolean; | ||
keep_alive: { | ||
@@ -10,0 +14,0 @@ enabled: boolean; |
@@ -210,8 +210,15 @@ "use strict"; | ||
buildRequestHeaders(params) { | ||
return { | ||
...this.defaultHeaders, | ||
Authorization: params?.auth !== undefined | ||
? `Basic ${Buffer.from(`${params.auth.username}:${params.auth.password}`).toString('base64')}` | ||
: this.defaultAuthHeader, | ||
}; | ||
if (this.params.set_basic_auth_header) { | ||
return { | ||
...this.defaultHeaders, | ||
Authorization: params?.auth !== undefined | ||
? `Basic ${Buffer.from(`${params.auth.username}:${params.auth.password}`).toString('base64')}` | ||
: this.defaultAuthHeader, | ||
}; | ||
} | ||
else { | ||
return { | ||
...this.defaultHeaders, | ||
}; | ||
} | ||
} | ||
@@ -396,3 +403,4 @@ getQueryId(query_id) { | ||
const onSocket = (socket) => { | ||
if (this.params.keep_alive.enabled) { | ||
if (this.params.keep_alive.enabled && | ||
this.params.keep_alive.idle_socket_ttl > 0) { | ||
const socketInfo = this.knownSockets.get(socket); | ||
@@ -399,0 +407,0 @@ // It is the first time we encounter this socket, |
@@ -1,2 +0,2 @@ | ||
declare const _default: "1.1.0"; | ||
declare const _default: "1.2.0"; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = '1.1.0'; | ||
exports.default = '1.2.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://clickhouse.com", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"license": "Apache-2.0", | ||
@@ -27,4 +27,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@clickhouse/client-common": "1.1.0" | ||
"@clickhouse/client-common": "1.2.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107591
57
1450
3
+ Added@clickhouse/client-common@1.2.0(transitive)
- Removed@clickhouse/client-common@1.1.0(transitive)