@clickhouse/client-common 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.
- package/LICENSE +203 -0
- package/README.md +35 -0
- package/dist/clickhouse_types.d.ts +24 -0
- package/dist/clickhouse_types.js +3 -0
- package/dist/clickhouse_types.js.map +1 -0
- package/dist/client.d.ts +149 -0
- package/dist/client.js +187 -0
- package/dist/client.js.map +1 -0
- package/dist/connection.d.ts +44 -0
- package/dist/connection.js +3 -0
- package/dist/connection.js.map +1 -0
- package/dist/data_formatter/format_query_params.d.ts +1 -0
- package/dist/data_formatter/format_query_params.js +61 -0
- package/dist/data_formatter/format_query_params.js.map +1 -0
- package/dist/data_formatter/format_query_settings.d.ts +2 -0
- package/dist/data_formatter/format_query_settings.js +21 -0
- package/dist/data_formatter/format_query_settings.js.map +1 -0
- package/dist/data_formatter/formatter.d.ts +23 -0
- package/dist/data_formatter/formatter.js +96 -0
- package/dist/data_formatter/formatter.js.map +1 -0
- package/dist/data_formatter/index.d.ts +3 -0
- package/dist/data_formatter/index.js +23 -0
- package/dist/data_formatter/index.js.map +1 -0
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.js +18 -0
- package/dist/error/index.js.map +1 -0
- package/dist/error/parse_error.d.ts +12 -0
- package/dist/error/parse_error.js +41 -0
- package/dist/error/parse_error.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +40 -0
- package/dist/logger.js +81 -0
- package/dist/logger.js.map +1 -0
- package/dist/result.d.ts +46 -0
- package/dist/result.js +3 -0
- package/dist/result.js.map +1 -0
- package/dist/settings.d.ts +1453 -0
- package/dist/settings.js +28 -0
- package/dist/settings.js.map +1 -0
- package/dist/utils/connection.d.ts +10 -0
- package/dist/utils/connection.js +27 -0
- package/dist/utils/connection.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/string.d.ts +1 -0
- package/dist/utils/string.js +8 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/url.d.ts +16 -0
- package/dist/utils/url.js +53 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/package.json +24 -0
package/dist/settings.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @see {@link https://github.com/ClickHouse/ClickHouse/blob/46ed4f6cdf68fbbdc59fbe0f0bfa9a361cc0dec1/src/Core/Settings.h}
|
|
4
|
+
* @see {@link https://github.com/ClickHouse/ClickHouse/blob/5f84f06d6d26672da3d97d0b236ebb46b5080989/src/Core/Defines.h}
|
|
5
|
+
* @see {@link https://github.com/ClickHouse/ClickHouse/blob/eae2667a1c29565c801be0ffd465f8bfcffe77ef/src/Storages/MergeTree/MergeTreeSettings.h}
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.SettingsMap = void 0;
|
|
9
|
+
class SettingsMap {
|
|
10
|
+
constructor(record) {
|
|
11
|
+
Object.defineProperty(this, "record", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: record
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
toString() {
|
|
19
|
+
return `{${Object.entries(this.record)
|
|
20
|
+
.map(([k, v]) => `'${k}':'${v}'`)
|
|
21
|
+
.join(',')}}`;
|
|
22
|
+
}
|
|
23
|
+
static from(record) {
|
|
24
|
+
return new this(record);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.SettingsMap = SettingsMap;
|
|
28
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../packages/client-common/src/settings.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAw5CH,MAAa,WAAW;IACtB,YAAqC,MAA8B;;;;;mBAA9B;;IAAiC,CAAC;IAEvE,QAAQ;QACN,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;aACnC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;aAChC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;IACjB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,MAA8B;QACxC,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAA;IACzB,CAAC;CACF;AAZD,kCAYC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ClickHouseSettings } from '../settings';
|
|
2
|
+
export type HttpHeader = number | string | string[];
|
|
3
|
+
export type HttpHeaders = Record<string, HttpHeader | undefined>;
|
|
4
|
+
export declare function withCompressionHeaders({ headers, compress_request, decompress_response, }: {
|
|
5
|
+
headers: HttpHeaders;
|
|
6
|
+
compress_request: boolean | undefined;
|
|
7
|
+
decompress_response: boolean | undefined;
|
|
8
|
+
}): Record<string, string>;
|
|
9
|
+
export declare function withHttpSettings(clickhouse_settings?: ClickHouseSettings, compression?: boolean): ClickHouseSettings;
|
|
10
|
+
export declare function isSuccessfulResponse(statusCode?: number): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSuccessfulResponse = exports.withHttpSettings = exports.withCompressionHeaders = void 0;
|
|
4
|
+
function withCompressionHeaders({ headers, compress_request, decompress_response, }) {
|
|
5
|
+
return {
|
|
6
|
+
...headers,
|
|
7
|
+
...(decompress_response ? { 'Accept-Encoding': 'gzip' } : {}),
|
|
8
|
+
...(compress_request ? { 'Content-Encoding': 'gzip' } : {}),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.withCompressionHeaders = withCompressionHeaders;
|
|
12
|
+
function withHttpSettings(clickhouse_settings, compression) {
|
|
13
|
+
return {
|
|
14
|
+
...(compression
|
|
15
|
+
? {
|
|
16
|
+
enable_http_compression: 1,
|
|
17
|
+
}
|
|
18
|
+
: {}),
|
|
19
|
+
...clickhouse_settings,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.withHttpSettings = withHttpSettings;
|
|
23
|
+
function isSuccessfulResponse(statusCode) {
|
|
24
|
+
return Boolean(statusCode && 200 <= statusCode && statusCode < 300);
|
|
25
|
+
}
|
|
26
|
+
exports.isSuccessfulResponse = isSuccessfulResponse;
|
|
27
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../../packages/client-common/src/utils/connection.ts"],"names":[],"mappings":";;;AAKA,SAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,gBAAgB,EAChB,mBAAmB,GAKpB;IACC,OAAO;QACL,GAAG,OAAO;QACV,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAA;AACH,CAAC;AAdD,wDAcC;AAED,SAAgB,gBAAgB,CAC9B,mBAAwC,EACxC,WAAqB;IAErB,OAAO;QACL,GAAG,CAAC,WAAW;YACb,CAAC,CAAC;gBACE,uBAAuB,EAAE,CAAC;aAC3B;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,mBAAmB;KACvB,CAAA;AACH,CAAC;AAZD,4CAYC;AAED,SAAgB,oBAAoB,CAAC,UAAmB;IACtD,OAAO,OAAO,CAAC,UAAU,IAAI,GAAG,IAAI,UAAU,IAAI,UAAU,GAAG,GAAG,CAAC,CAAA;AACrE,CAAC;AAFD,oDAEC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./connection"), exports);
|
|
18
|
+
__exportStar(require("./string"), exports);
|
|
19
|
+
__exportStar(require("./url"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/client-common/src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,2CAAwB;AACxB,wCAAqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function replaceAll(input: string, replace_char: string, new_char: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceAll = void 0;
|
|
4
|
+
function replaceAll(input, replace_char, new_char) {
|
|
5
|
+
return input.split(replace_char).join(new_char);
|
|
6
|
+
}
|
|
7
|
+
exports.replaceAll = replaceAll;
|
|
8
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../packages/client-common/src/utils/string.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CACxB,KAAa,EACb,YAAoB,EACpB,QAAgB;IAEhB,OAAO,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AACjD,CAAC;AAND,gCAMC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ClickHouseSettings } from '../settings';
|
|
2
|
+
export declare function transformUrl({ url, pathname, searchParams, }: {
|
|
3
|
+
url: URL;
|
|
4
|
+
pathname?: string;
|
|
5
|
+
searchParams?: URLSearchParams;
|
|
6
|
+
}): URL;
|
|
7
|
+
type ToSearchParamsOptions = {
|
|
8
|
+
database: string;
|
|
9
|
+
clickhouse_settings?: ClickHouseSettings;
|
|
10
|
+
query_params?: Record<string, unknown>;
|
|
11
|
+
query?: string;
|
|
12
|
+
session_id?: string;
|
|
13
|
+
query_id?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function toSearchParams({ database, query, query_params, clickhouse_settings, session_id, query_id, }: ToSearchParamsOptions): URLSearchParams | undefined;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toSearchParams = exports.transformUrl = void 0;
|
|
4
|
+
const data_formatter_1 = require("../data_formatter");
|
|
5
|
+
function transformUrl({ url, pathname, searchParams, }) {
|
|
6
|
+
const newUrl = new URL(url);
|
|
7
|
+
if (pathname) {
|
|
8
|
+
newUrl.pathname = pathname;
|
|
9
|
+
}
|
|
10
|
+
if (searchParams) {
|
|
11
|
+
newUrl.search = searchParams === null || searchParams === void 0 ? void 0 : searchParams.toString();
|
|
12
|
+
}
|
|
13
|
+
return newUrl;
|
|
14
|
+
}
|
|
15
|
+
exports.transformUrl = transformUrl;
|
|
16
|
+
// TODO validate max length of the resulting query
|
|
17
|
+
// https://stackoverflow.com/questions/812925/what-is-the-maximum-possible-length-of-a-query-string
|
|
18
|
+
function toSearchParams({ database, query, query_params, clickhouse_settings, session_id, query_id, }) {
|
|
19
|
+
if (clickhouse_settings === undefined &&
|
|
20
|
+
query_params === undefined &&
|
|
21
|
+
query === undefined &&
|
|
22
|
+
database === 'default') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const params = new URLSearchParams();
|
|
26
|
+
if (query_params !== undefined) {
|
|
27
|
+
for (const [key, value] of Object.entries(query_params)) {
|
|
28
|
+
params.set(`param_${key}`, (0, data_formatter_1.formatQueryParams)(value));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (clickhouse_settings !== undefined) {
|
|
32
|
+
for (const [key, value] of Object.entries(clickhouse_settings)) {
|
|
33
|
+
if (value !== undefined) {
|
|
34
|
+
params.set(key, (0, data_formatter_1.formatQuerySettings)(value));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (database !== 'default') {
|
|
39
|
+
params.set('database', database);
|
|
40
|
+
}
|
|
41
|
+
if (query) {
|
|
42
|
+
params.set('query', query);
|
|
43
|
+
}
|
|
44
|
+
if (session_id) {
|
|
45
|
+
params.set('session_id', session_id);
|
|
46
|
+
}
|
|
47
|
+
if (query_id) {
|
|
48
|
+
params.set('query_id', query_id);
|
|
49
|
+
}
|
|
50
|
+
return params;
|
|
51
|
+
}
|
|
52
|
+
exports.toSearchParams = toSearchParams;
|
|
53
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../../packages/client-common/src/utils/url.ts"],"names":[],"mappings":";;;AACA,sDAA0E;AAE1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;QAC1B,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;KACjC;IAED,IAAI,KAAK,EAAE;QACT,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;KAC3B;IAED,IAAI,UAAU,EAAE;QACd,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;KACrC;IAED,IAAI,QAAQ,EAAE;QACZ,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;KACjC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAlDD,wCAkDC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../packages/client-common/src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,aAAa,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clickhouse/client-common",
|
|
3
|
+
"description": "Official JS client for ClickHouse DB - common types",
|
|
4
|
+
"homepage": "https://clickhouse.com",
|
|
5
|
+
"version": "0.2.0-beta1",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"clickhouse",
|
|
9
|
+
"sql",
|
|
10
|
+
"client"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/ClickHouse/clickhouse-js.git"
|
|
15
|
+
},
|
|
16
|
+
"private": false,
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"devDependencies": {}
|
|
24
|
+
}
|