Socket
Socket
Sign inDemoInstall

@clickhouse/client-common

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clickhouse/client-common - npm Package Compare versions

Comparing version 0.2.0-beta1 to 0.2.0

7

dist/client.d.ts
import type { ClickHouseLogLevel, ClickHouseSettings, Connection, ConnectionParams, ConnInsertResult, ConnQueryResult, Logger } from '@clickhouse/client-common';
import { type DataFormat } from '@clickhouse/client-common';
import type { InputJSON, InputJSONObjectEachRow } from './clickhouse_types';
import type { ConnPingResult } from './connection';
import type { BaseResultSet } from './result';

@@ -92,2 +93,3 @@ export type MakeConnection<Stream> = (params: ConnectionParams) => Connection<Stream>;

export type ExecResult<Stream> = ConnQueryResult<Stream>;
export type PingResult = ConnPingResult;
export type InsertValues<Stream, T = unknown> = ReadonlyArray<T> | Stream | InputJSON<T> | InputJSONObjectEachRow<T>;

@@ -141,5 +143,6 @@ export interface InsertParams<Stream = unknown, T = unknown> extends BaseQueryParams {

/**
* Health-check request. Can throw an error if the connection is refused.
* Health-check request. It does not throw if an error occurs -
* the error is returned inside the result object.
*/
ping(): Promise<boolean>;
ping(): Promise<PingResult>;
/**

@@ -146,0 +149,0 @@ * Shuts down the underlying connection.

@@ -5,35 +5,2 @@ "use strict";

const client_common_1 = require("@clickhouse/client-common");
function validateConnectionParams({ url }) {
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
throw new Error(`Only http(s) protocol is supported, but given: [${url.protocol}]`);
}
}
function createUrl(host) {
try {
return new URL(host);
}
catch (err) {
throw new Error('Configuration parameter "host" contains malformed url.');
}
}
function getConnectionParams(config) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
return {
application_id: config.application,
url: createUrl((_a = config.host) !== null && _a !== void 0 ? _a : 'http://localhost:8123'),
request_timeout: (_b = config.request_timeout) !== null && _b !== void 0 ? _b : 300000,
max_open_connections: (_c = config.max_open_connections) !== null && _c !== void 0 ? _c : Infinity,
compression: {
decompress_response: (_e = (_d = config.compression) === null || _d === void 0 ? void 0 : _d.response) !== null && _e !== void 0 ? _e : true,
compress_request: (_g = (_f = config.compression) === null || _f === void 0 ? void 0 : _f.request) !== null && _g !== void 0 ? _g : false,
},
username: (_h = config.username) !== null && _h !== void 0 ? _h : 'default',
password: (_j = config.password) !== null && _j !== void 0 ? _j : '',
database: (_k = config.database) !== null && _k !== void 0 ? _k : 'default',
clickhouse_settings: (_l = config.clickhouse_settings) !== null && _l !== void 0 ? _l : {},
logWriter: new client_common_1.LogWriter(((_m = config === null || config === void 0 ? void 0 : config.log) === null || _m === void 0 ? void 0 : _m.LoggerClass)
? new config.log.LoggerClass()
: new client_common_1.DefaultLogger(), (_o = config.log) === null || _o === void 0 ? void 0 : _o.level),
};
}
class ClickHouseClient {

@@ -155,3 +122,4 @@ constructor(config) {

/**
* Health-check request. Can throw an error if the connection is refused.
* Health-check request. It does not throw if an error occurs -
* the error is returned inside the result object.
*/

@@ -189,2 +157,35 @@ async ping() {

}
function validateConnectionParams({ url }) {
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
throw new Error(`Only http(s) protocol is supported, but given: [${url.protocol}]`);
}
}
function createUrl(host) {
try {
return new URL(host);
}
catch (err) {
throw new Error('Configuration parameter "host" contains malformed url.');
}
}
function getConnectionParams(config) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
return {
application_id: config.application,
url: createUrl((_a = config.host) !== null && _a !== void 0 ? _a : 'http://localhost:8123'),
request_timeout: (_b = config.request_timeout) !== null && _b !== void 0 ? _b : 300000,
max_open_connections: (_c = config.max_open_connections) !== null && _c !== void 0 ? _c : Infinity,
compression: {
decompress_response: (_e = (_d = config.compression) === null || _d === void 0 ? void 0 : _d.response) !== null && _e !== void 0 ? _e : true,
compress_request: (_g = (_f = config.compression) === null || _f === void 0 ? void 0 : _f.request) !== null && _g !== void 0 ? _g : false,
},
username: (_h = config.username) !== null && _h !== void 0 ? _h : 'default',
password: (_j = config.password) !== null && _j !== void 0 ? _j : '',
database: (_k = config.database) !== null && _k !== void 0 ? _k : 'default',
clickhouse_settings: (_l = config.clickhouse_settings) !== null && _l !== void 0 ? _l : {},
logWriter: new client_common_1.LogWriter(((_m = config === null || config === void 0 ? void 0 : config.log) === null || _m === void 0 ? void 0 : _m.LoggerClass)
? new config.log.LoggerClass()
: new client_common_1.DefaultLogger(), (_o = config.log) === null || _o === void 0 ? void 0 : _o.level),
};
}
//# sourceMappingURL=client.js.map

@@ -38,4 +38,10 @@ import type { LogWriter } from './logger';

export type ConnExecResult<Stream> = ConnQueryResult<Stream>;
export type ConnPingResult = {
success: true;
} | {
success: false;
error: Error;
};
export interface Connection<Stream> {
ping(): Promise<boolean>;
ping(): Promise<ConnPingResult>;
close(): Promise<void>;

@@ -42,0 +48,0 @@ query(params: ConnBaseQueryParams): Promise<ConnQueryResult<Stream>>;

/** Should be re-exported by the implementation */
export { type BaseClickHouseClientConfigOptions, type ClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, ClickHouseClient, type CommandParams, type CommandResult, type ExecResult, type InsertResult, } from './client';
export { type BaseClickHouseClientConfigOptions, type ClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, ClickHouseClient, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type PingResult, } from './client';
export type { Row, BaseResultSet } from './result';

@@ -15,3 +15,3 @@ export { type DataFormat } from './data_formatter';

export { parseError } from './error';
export type { Connection, ConnectionParams, ConnInsertResult, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, } from './connection';
export type { Connection, ConnectionParams, ConnInsertResult, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, ConnPingResult, } from './connection';
export { type RawDataFormat, type JSONDataFormat, formatQuerySettings, formatQueryParams, } from './data_formatter';
"use strict";
/**
* @see {@link https://github.com/ClickHouse/ClickHouse/blob/46ed4f6cdf68fbbdc59fbe0f0bfa9a361cc0dec1/src/Core/Settings.h}
* @see {@link https://github.com/ClickHouse/ClickHouse/blob/5f84f06d6d26672da3d97d0b236ebb46b5080989/src/Core/Defines.h}
* @see {@link https://github.com/ClickHouse/ClickHouse/blob/eae2667a1c29565c801be0ffd465f8bfcffe77ef/src/Storages/MergeTree/MergeTreeSettings.h}

@@ -6,0 +5,0 @@ */

@@ -1,2 +0,2 @@

declare const _default: "0.2.0-beta1";
declare const _default: "0.2.0";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = '0.2.0-beta1';
exports.default = '0.2.0';
//# sourceMappingURL=version.js.map

@@ -5,3 +5,3 @@ {

"homepage": "https://clickhouse.com",
"version": "0.2.0-beta1",
"version": "0.2.0",
"license": "Apache-2.0",

@@ -8,0 +8,0 @@ "keywords": [

@@ -19,7 +19,8 @@ <p align="center">

- `@clickhouse/client` - Node.js client, built on top of [HTTP](https://nodejs.org/api/http.html)
- `@clickhouse/client` - a version of the client designed for Node.js platform only. It is built on top of [HTTP](https://nodejs.org/api/http.html)
and [Stream](https://nodejs.org/api/stream.html) APIs; supports streaming for both selects and inserts.
- `@clickhouse/client-browser` - browser client, built on top of [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
- `@clickhouse/client-web` - a version of the client built on top of [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
and [Web Streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) APIs; supports streaming for selects.
- `@clickhouse/common` - shared common types and the base framework for building a custom client implementation.
Compatible with Chrome/Firefox browsers and CloudFlare workers.
- `@clickhouse/client-common` - shared common types and the base framework for building a custom client implementation.

@@ -26,0 +27,0 @@ ## Documentation

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc