@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatQueryParams(value: any, wrapStringInQuotes?: boolean): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatQueryParams = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function withPadding(value) {
|
|
6
|
+
if (value > 9)
|
|
7
|
+
return String(value);
|
|
8
|
+
return `0${value}`;
|
|
9
|
+
}
|
|
10
|
+
function formatMillis(value) {
|
|
11
|
+
const ms = value.getMilliseconds();
|
|
12
|
+
if (ms === 0) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
if (ms > 99) {
|
|
16
|
+
return `.${ms}`;
|
|
17
|
+
}
|
|
18
|
+
if (ms > 9) {
|
|
19
|
+
return `.0${ms}`;
|
|
20
|
+
}
|
|
21
|
+
return `.00${ms}`;
|
|
22
|
+
}
|
|
23
|
+
function formatQueryParams(value, wrapStringInQuotes = false) {
|
|
24
|
+
if (value === null || value === undefined)
|
|
25
|
+
return '\\N';
|
|
26
|
+
if (Number.isNaN(value))
|
|
27
|
+
return 'nan';
|
|
28
|
+
if (value === Number.POSITIVE_INFINITY)
|
|
29
|
+
return '+inf';
|
|
30
|
+
if (value === Number.NEGATIVE_INFINITY)
|
|
31
|
+
return '-inf';
|
|
32
|
+
if (typeof value === 'number')
|
|
33
|
+
return String(value);
|
|
34
|
+
if (typeof value === 'boolean')
|
|
35
|
+
return value ? '1' : '0';
|
|
36
|
+
if (typeof value === 'string') {
|
|
37
|
+
const escapedValue = (0, utils_1.replaceAll)((0, utils_1.replaceAll)(value, `\\`, `\\\\`), `'`, `\\'`);
|
|
38
|
+
return wrapStringInQuotes ? `'${escapedValue}'` : escapedValue;
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
const formatted = value.map((v) => formatQueryParams(v, true));
|
|
42
|
+
return `[${formatted.join(',')}]`;
|
|
43
|
+
}
|
|
44
|
+
if (value instanceof Date) {
|
|
45
|
+
// TODO add timezone support
|
|
46
|
+
const date = `${value.getFullYear()}-${withPadding(value.getMonth() + 1)}-${withPadding(value.getDate())}`;
|
|
47
|
+
const time = `${withPadding(value.getHours())}:${withPadding(value.getMinutes())}:${withPadding(value.getSeconds())}`;
|
|
48
|
+
const ms = formatMillis(value);
|
|
49
|
+
return `${date} ${time}${ms}`;
|
|
50
|
+
}
|
|
51
|
+
if (typeof value === 'object') {
|
|
52
|
+
const formatted = [];
|
|
53
|
+
for (const [key, val] of Object.entries(value)) {
|
|
54
|
+
formatted.push(`${formatQueryParams(key, true)}:${formatQueryParams(val, true)}`);
|
|
55
|
+
}
|
|
56
|
+
return `{${formatted.join(',')}}`;
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`Unsupported value in query parameters: [${value}].`);
|
|
59
|
+
}
|
|
60
|
+
exports.formatQueryParams = formatQueryParams;
|
|
61
|
+
//# sourceMappingURL=format_query_params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format_query_params.js","sourceRoot":"","sources":["../../../../packages/client-common/src/data_formatter/format_query_params.ts"],"names":[],"mappings":";;;AAAA,oCAAqC;AAErC,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACnC,OAAO,IAAI,KAAK,EAAE,CAAA;AACpB,CAAC;AAED,SAAS,YAAY,CAAC,KAAW;IAC/B,MAAM,EAAE,GAAG,KAAK,CAAC,eAAe,EA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ings = void 0;
|
|
4
|
+
const settings_1 = require("../settings");
|
|
5
|
+
function formatQuerySettings(value) {
|
|
6
|
+
if (typeof value === 'boolean')
|
|
7
|
+
return value ? '1' : '0';
|
|
8
|
+
if (typeof value === 'number')
|
|
9
|
+
return String(value);
|
|
10
|
+
if (typeof value === 'string')
|
|
11
|
+
return value;
|
|
12
|
+
// ClickHouse requires a specific, non-JSON format for passing maps
|
|
13
|
+
// as a setting value - single quotes instead of double
|
|
14
|
+
// Example: {'system.numbers':'number != 3'}
|
|
15
|
+
if (value instanceof settings_1.SettingsMap) {
|
|
16
|
+
return value.toString();
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`Unsupported value in query settings: [${value}].`);
|
|
19
|
+
}
|
|
20
|
+
exports.formatQuerySettings = formatQuerySettings;
|
|
21
|
+
//# sourceMappingURL=format_query_settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format_query_settings.js","sourceRoot":"","sources":["../../../../packages/client-common/src/data_formatter/format_query_settings.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AAEzC,SAAgB,mBAAmB,CACjC,KAA8C;IAE9C,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IACxD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,mEAAmE;IACnE,uDAAuD;IACvD,4CAA4C;IAC5C,IAAI,KAAK,YAAY,sBAAW,EAAE;QAChC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;KACxB;IACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,IAAI,CAAC,CAAA;AACrE,CAAC;AAbD,kDAaC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const supportedJSONFormats: readonly ["JSON", "JSONStrings", "JSONCompact", "JSONCompactStrings", "JSONColumnsWithMetadata", "JSONObjectEachRow", "JSONEachRow", "JSONStringsEachRow", "JSONCompactEachRow", "JSONCompactStringsEachRow", "JSONCompactEachRowWithNames", "JSONCompactEachRowWithNamesAndTypes", "JSONCompactStringsEachRowWithNames", "JSONCompactStringsEachRowWithNamesAndTypes"];
|
|
2
|
+
declare const supportedRawFormats: readonly ["CSV", "CSVWithNames", "CSVWithNamesAndTypes", "TabSeparated", "TabSeparatedRaw", "TabSeparatedWithNames", "TabSeparatedWithNamesAndTypes", "CustomSeparated", "CustomSeparatedWithNames", "CustomSeparatedWithNamesAndTypes"];
|
|
3
|
+
export type JSONDataFormat = (typeof supportedJSONFormats)[number];
|
|
4
|
+
export type RawDataFormat = (typeof supportedRawFormats)[number];
|
|
5
|
+
export type DataFormat = JSONDataFormat | RawDataFormat;
|
|
6
|
+
declare const streamableFormat: readonly ["JSONEachRow", "JSONStringsEachRow", "JSONCompactEachRow", "JSONCompactStringsEachRow", "JSONCompactEachRowWithNames", "JSONCompactEachRowWithNamesAndTypes", "JSONCompactStringsEachRowWithNames", "JSONCompactStringsEachRowWithNamesAndTypes", "CSV", "CSVWithNames", "CSVWithNamesAndTypes", "TabSeparated", "TabSeparatedRaw", "TabSeparatedWithNames", "TabSeparatedWithNamesAndTypes", "CustomSeparated", "CustomSeparatedWithNames", "CustomSeparatedWithNamesAndTypes"];
|
|
7
|
+
type StreamableDataFormat = (typeof streamableFormat)[number];
|
|
8
|
+
export declare function isSupportedRawFormat(dataFormat: DataFormat): boolean;
|
|
9
|
+
export declare function validateStreamFormat(format: any): format is StreamableDataFormat;
|
|
10
|
+
/**
|
|
11
|
+
* Decodes a string in a ClickHouse format into a plain JavaScript object or an array of objects.
|
|
12
|
+
* @param text a string in a ClickHouse data format
|
|
13
|
+
* @param format One of the supported formats: https://clickhouse.com/docs/en/interfaces/formats/
|
|
14
|
+
*/
|
|
15
|
+
export declare function decode(text: string, format: DataFormat): any;
|
|
16
|
+
/**
|
|
17
|
+
* Encodes a single row of values into a string in a JSON format acceptable by ClickHouse.
|
|
18
|
+
* @param value a single value to encode.
|
|
19
|
+
* @param format One of the supported JSON formats: https://clickhouse.com/docs/en/interfaces/formats/
|
|
20
|
+
* @returns string
|
|
21
|
+
*/
|
|
22
|
+
export declare function encodeJSON(value: any, format: DataFormat): string;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeJSON = exports.decode = exports.validateStreamFormat = exports.isSupportedRawFormat = void 0;
|
|
4
|
+
const streamableJSONFormats = [
|
|
5
|
+
'JSONEachRow',
|
|
6
|
+
'JSONStringsEachRow',
|
|
7
|
+
'JSONCompactEachRow',
|
|
8
|
+
'JSONCompactStringsEachRow',
|
|
9
|
+
'JSONCompactEachRowWithNames',
|
|
10
|
+
'JSONCompactEachRowWithNamesAndTypes',
|
|
11
|
+
'JSONCompactStringsEachRowWithNames',
|
|
12
|
+
'JSONCompactStringsEachRowWithNamesAndTypes',
|
|
13
|
+
];
|
|
14
|
+
const singleDocumentJSONFormats = [
|
|
15
|
+
'JSON',
|
|
16
|
+
'JSONStrings',
|
|
17
|
+
'JSONCompact',
|
|
18
|
+
'JSONCompactStrings',
|
|
19
|
+
'JSONColumnsWithMetadata',
|
|
20
|
+
'JSONObjectEachRow',
|
|
21
|
+
];
|
|
22
|
+
const supportedJSONFormats = [
|
|
23
|
+
...singleDocumentJSONFormats,
|
|
24
|
+
...streamableJSONFormats,
|
|
25
|
+
];
|
|
26
|
+
const supportedRawFormats = [
|
|
27
|
+
'CSV',
|
|
28
|
+
'CSVWithNames',
|
|
29
|
+
'CSVWithNamesAndTypes',
|
|
30
|
+
'TabSeparated',
|
|
31
|
+
'TabSeparatedRaw',
|
|
32
|
+
'TabSeparatedWithNames',
|
|
33
|
+
'TabSeparatedWithNamesAndTypes',
|
|
34
|
+
'CustomSeparated',
|
|
35
|
+
'CustomSeparatedWithNames',
|
|
36
|
+
'CustomSeparatedWithNamesAndTypes',
|
|
37
|
+
];
|
|
38
|
+
// TODO add others formats
|
|
39
|
+
const streamableFormat = [
|
|
40
|
+
...streamableJSONFormats,
|
|
41
|
+
...supportedRawFormats,
|
|
42
|
+
];
|
|
43
|
+
function isNotStreamableJSONFamily(format) {
|
|
44
|
+
// @ts-expect-error JSON is not assignable to notStreamableJSONFormats
|
|
45
|
+
return singleDocumentJSONFormats.includes(format);
|
|
46
|
+
}
|
|
47
|
+
function isStreamableJSONFamily(format) {
|
|
48
|
+
// @ts-expect-error JSON is not assignable to streamableJSONFormats
|
|
49
|
+
return streamableJSONFormats.includes(format);
|
|
50
|
+
}
|
|
51
|
+
function isSupportedRawFormat(dataFormat) {
|
|
52
|
+
return supportedRawFormats.includes(dataFormat);
|
|
53
|
+
}
|
|
54
|
+
exports.isSupportedRawFormat = isSupportedRawFormat;
|
|
55
|
+
function validateStreamFormat(format) {
|
|
56
|
+
if (!streamableFormat.includes(format)) {
|
|
57
|
+
throw new Error(`${format} format is not streamable. Streamable formats: ${streamableFormat.join(',')}`);
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
exports.validateStreamFormat = validateStreamFormat;
|
|
62
|
+
/**
|
|
63
|
+
* Decodes a string in a ClickHouse format into a plain JavaScript object or an array of objects.
|
|
64
|
+
* @param text a string in a ClickHouse data format
|
|
65
|
+
* @param format One of the supported formats: https://clickhouse.com/docs/en/interfaces/formats/
|
|
66
|
+
*/
|
|
67
|
+
function decode(text, format) {
|
|
68
|
+
if (isNotStreamableJSONFamily(format)) {
|
|
69
|
+
return JSON.parse(text);
|
|
70
|
+
}
|
|
71
|
+
if (isStreamableJSONFamily(format)) {
|
|
72
|
+
return text
|
|
73
|
+
.split('\n')
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
.map((l) => decode(l, 'JSON'));
|
|
76
|
+
}
|
|
77
|
+
if (isSupportedRawFormat(format)) {
|
|
78
|
+
throw new Error(`Cannot decode ${format} to JSON`);
|
|
79
|
+
}
|
|
80
|
+
throw new Error(`The client does not support [${format}] format decoding.`);
|
|
81
|
+
}
|
|
82
|
+
exports.decode = decode;
|
|
83
|
+
/**
|
|
84
|
+
* Encodes a single row of values into a string in a JSON format acceptable by ClickHouse.
|
|
85
|
+
* @param value a single value to encode.
|
|
86
|
+
* @param format One of the supported JSON formats: https://clickhouse.com/docs/en/interfaces/formats/
|
|
87
|
+
* @returns string
|
|
88
|
+
*/
|
|
89
|
+
function encodeJSON(value, format) {
|
|
90
|
+
if (supportedJSONFormats.includes(format)) {
|
|
91
|
+
return JSON.stringify(value) + '\n';
|
|
92
|
+
}
|
|
93
|
+
throw new Error(`The client does not support JSON encoding in [${format}] format.`);
|
|
94
|
+
}
|
|
95
|
+
exports.encodeJSON = encodeJSON;
|
|
96
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../packages/client-common/src/data_formatter/formatter.ts"],"names":[],"mappings":";;;AAAA,MAAM,qBAAqB,GAAG;IAC5B,aAAa;IACb,oBAAoB;IACpB,oBAAoB;IACpB,2BAA2B;IAC3B,6BAA6B;IAC7B,qCAAqC;IACrC,oCAAoC;IACpC,4CAA4C;CACpC,CAAA;AACV,MAAM,yBAAyB,GAAG;IAChC,MAAM;IACN,aAAa;IACb,aAAa;IACb,oBAAoB;IACpB,yBAAyB;IACzB,mBAAmB;CACX,CAAA;AACV,MAAM,oBAAoB,GAAG;IAC3B,GAAG,yBAAyB;IAC5B,GAAG,qBAAqB;CAChB,CAAA;AACV,MAAM,mBAAmB,GAAG;IAC1B,KAAK;IACL,cAAc;IACd,sBAAsB;IACtB,cAAc;IACd,iBAAiB;IACjB,uBAAuB;IACvB,+BAA+B;IAC/B,iBAAiB;IACjB,0BAA0B;IAC1B,kCAAkC;CAC1B,CAAA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AgC,MAAM,oBAAoB,CAAC,CAAA;AAC7E,CAAC;AAdD,wBAcC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAU,EAAE,MAAkB;IACvD,IAAK,oBAA0C,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;KACpC;IACD,MAAM,IAAI,KAAK,CACb,iDAAiD,MAAM,WAAW,CACnE,CAAA;AACH,CAAC;AAPD,gCAOC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
exports.formatQuerySettings = exports.formatQueryParams = void 0;
|
|
18
|
+
__exportStar(require("./formatter"), exports);
|
|
19
|
+
var format_query_params_1 = require("./format_query_params");
|
|
20
|
+
Object.defineProperty(exports, "formatQueryParams", { enumerable: true, get: function () { return format_query_params_1.formatQueryParams; } });
|
|
21
|
+
var format_query_settings_1 = require("./format_query_settings");
|
|
22
|
+
Object.defineProperty(exports, "formatQuerySettings", { enumerable: true, get: function () { return format_query_settings_1.formatQuerySettings; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/client-common/src/data_formatter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,6DAAyD;AAAhD,wHAAA,iBAAiB,OAAA;AAC1B,iEAA6D;AAApD,4HAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './parse_error';
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./parse_error"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/client-common/src/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface ParsedClickHouseError {
|
|
2
|
+
message: string;
|
|
3
|
+
code: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ClickHouseError extends Error {
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly type: string | undefined;
|
|
9
|
+
constructor({ message, code, type }: ParsedClickHouseError);
|
|
10
|
+
}
|
|
11
|
+
export declare function parseError(input: string | Error): ClickHouseError | Error;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseError = exports.ClickHouseError = void 0;
|
|
4
|
+
const errorRe = /(Code|Error): (?<code>\d+).*Exception: (?<message>.+)\((?<type>(?=.+[A-Z]{3})[A-Z0-9_]+?)\)/s;
|
|
5
|
+
class ClickHouseError extends Error {
|
|
6
|
+
constructor({ message, code, type }) {
|
|
7
|
+
super(message);
|
|
8
|
+
Object.defineProperty(this, "code", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(this, "type", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: void 0
|
|
19
|
+
});
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.type = type;
|
|
22
|
+
// Set the prototype explicitly, see:
|
|
23
|
+
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
24
|
+
Object.setPrototypeOf(this, ClickHouseError.prototype);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.ClickHouseError = ClickHouseError;
|
|
28
|
+
function parseError(input) {
|
|
29
|
+
const inputIsError = input instanceof Error;
|
|
30
|
+
const message = inputIsError ? input.message : input;
|
|
31
|
+
const match = message.match(errorRe);
|
|
32
|
+
const groups = match === null || match === void 0 ? void 0 : match.groups;
|
|
33
|
+
if (groups) {
|
|
34
|
+
return new ClickHouseError(groups);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return inputIsError ? input : new Error(input);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.parseError = parseError;
|
|
41
|
+
//# sourceMappingURL=parse_error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse_error.js","sourceRoot":"","sources":["../../../../packages/client-common/src/error/parse_error.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GACX,8FAA8F,CAAA;AAOhG,MAAa,eAAgB,SAAQ,KAAK;IAGxC,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAyB;QACxD,KAAK,CAAC,OAAO,CAAC,CAAA;QAHhB;;;;;WAAqB;QACrB;;;;;WAAiC;QAG/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAEhB,qCAAqC;QACrC,gIAAgI;QAChI,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACxD,CAAC;CACF;AAZD,0CAYC;AAED,SAAgB,UAAU,CAAC,KAAqB;IAC9C,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAA;IAC3C,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAA;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAA2C,CAAA;IACjE,IAAI,MAAM,EAAE;QACV,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAA;KACnC;SAAM;QACL,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;KAC/C;AACH,CAAC;AAVD,gCAUC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Should be re-exported by the implementation */
|
|
2
|
+
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';
|
|
3
|
+
export type { Row, BaseResultSet } from './result';
|
|
4
|
+
export { type DataFormat } from './data_formatter';
|
|
5
|
+
export { ClickHouseError } from './error';
|
|
6
|
+
export { ClickHouseLogLevel, type ErrorLogParams, type Logger, type LogParams, } from './logger';
|
|
7
|
+
export type { ResponseJSON, InputJSON, InputJSONObjectEachRow, } from './clickhouse_types';
|
|
8
|
+
export { type ClickHouseSettings, type MergeTreeSettings, SettingsMap, } from './settings';
|
|
9
|
+
/** For implementations usage only */
|
|
10
|
+
export { encodeJSON, isSupportedRawFormat, decode, validateStreamFormat, } from './data_formatter';
|
|
11
|
+
export { type ValuesEncoder, type MakeResultSet, type MakeConnection, } from './client';
|
|
12
|
+
export { withCompressionHeaders, isSuccessfulResponse, toSearchParams, transformUrl, withHttpSettings, } from './utils';
|
|
13
|
+
export { LogWriter, DefaultLogger } from './logger';
|
|
14
|
+
export { parseError } from './error';
|
|
15
|
+
export type { Connection, ConnectionParams, ConnInsertResult, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, } from './connection';
|
|
16
|
+
export { type RawDataFormat, type JSONDataFormat, formatQuerySettings, formatQueryParams, } from './data_formatter';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatQueryParams = exports.formatQuerySettings = exports.parseError = exports.DefaultLogger = exports.LogWriter = exports.withHttpSettings = exports.transformUrl = exports.toSearchParams = exports.isSuccessfulResponse = exports.withCompressionHeaders = exports.validateStreamFormat = exports.decode = exports.isSupportedRawFormat = exports.encodeJSON = exports.SettingsMap = exports.ClickHouseLogLevel = exports.ClickHouseError = exports.ClickHouseClient = void 0;
|
|
4
|
+
/** Should be re-exported by the implementation */
|
|
5
|
+
var client_1 = require("./client");
|
|
6
|
+
Object.defineProperty(exports, "ClickHouseClient", { enumerable: true, get: function () { return client_1.ClickHouseClient; } });
|
|
7
|
+
var error_1 = require("./error");
|
|
8
|
+
Object.defineProperty(exports, "ClickHouseError", { enumerable: true, get: function () { return error_1.ClickHouseError; } });
|
|
9
|
+
var logger_1 = require("./logger");
|
|
10
|
+
Object.defineProperty(exports, "ClickHouseLogLevel", { enumerable: true, get: function () { return logger_1.ClickHouseLogLevel; } });
|
|
11
|
+
var settings_1 = require("./settings");
|
|
12
|
+
Object.defineProperty(exports, "SettingsMap", { enumerable: true, get: function () { return settings_1.SettingsMap; } });
|
|
13
|
+
/** For implementations usage only */
|
|
14
|
+
var data_formatter_1 = require("./data_formatter");
|
|
15
|
+
Object.defineProperty(exports, "encodeJSON", { enumerable: true, get: function () { return data_formatter_1.encodeJSON; } });
|
|
16
|
+
Object.defineProperty(exports, "isSupportedRawFormat", { enumerable: true, get: function () { return data_formatter_1.isSupportedRawFormat; } });
|
|
17
|
+
Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return data_formatter_1.decode; } });
|
|
18
|
+
Object.defineProperty(exports, "validateStreamFormat", { enumerable: true, get: function () { return data_formatter_1.validateStreamFormat; } });
|
|
19
|
+
var utils_1 = require("./utils");
|
|
20
|
+
Object.defineProperty(exports, "withCompressionHeaders", { enumerable: true, get: function () { return utils_1.withCompressionHeaders; } });
|
|
21
|
+
Object.defineProperty(exports, "isSuccessfulResponse", { enumerable: true, get: function () { return utils_1.isSuccessfulResponse; } });
|
|
22
|
+
Object.defineProperty(exports, "toSearchParams", { enumerable: true, get: function () { return utils_1.toSearchParams; } });
|
|
23
|
+
Object.defineProperty(exports, "transformUrl", { enumerable: true, get: function () { return utils_1.transformUrl; } });
|
|
24
|
+
Object.defineProperty(exports, "withHttpSettings", { enumerable: true, get: function () { return utils_1.withHttpSettings; } });
|
|
25
|
+
var logger_2 = require("./logger");
|
|
26
|
+
Object.defineProperty(exports, "LogWriter", { enumerable: true, get: function () { return logger_2.LogWriter; } });
|
|
27
|
+
Object.defineProperty(exports, "DefaultLogger", { enumerable: true, get: function () { return logger_2.DefaultLogger; } });
|
|
28
|
+
var error_2 = require("./error");
|
|
29
|
+
Object.defineProperty(exports, "parseError", { enumerable: true, get: function () { return error_2.parseError; } });
|
|
30
|
+
var data_formatter_2 = require("./data_formatter");
|
|
31
|
+
Object.defineProperty(exports, "formatQuerySettings", { enumerable: true, get: function () { return data_formatter_2.formatQuerySettings; } });
|
|
32
|
+
Object.defineProperty(exports, "formatQueryParams", { enumerable: true, get: function () { return data_formatter_2.formatQueryParams; } });
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/client-common/src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAClD,mCAaiB;AALf,0GAAA,gBAAgB,OAAA;AAQlB,iCAAyC;AAAhC,wGAAA,eAAe,OAAA;AACxB,mCAKiB;AAJf,4GAAA,kBAAkB,OAAA;AAUpB,uCAImB;AADjB,uGAAA,WAAW,OAAA;AAGb,qCAAqC;AACrC,mDAKyB;AAJvB,4GAAA,UAAU,OAAA;AACV,sHAAA,oBAAoB,OAAA;AACpB,wGAAA,MAAM,OAAA;AACN,sHAAA,oBAAoB,OAAA;AAOtB,iCAMgB;AALd,+GAAA,sBAAsB,OAAA;AACtB,6GAAA,oBAAoB,OAAA;AACpB,uGAAA,cAAc,OAAA;AACd,qGAAA,YAAY,OAAA;AACZ,yGAAA,gBAAgB,OAAA;AAElB,mCAAmD;AAA1C,mGAAA,SAAS,OAAA;AAAE,uGAAA,aAAa,OAAA;AACjC,iCAAoC;AAA3B,mGAAA,UAAU,OAAA;AAWnB,mDAKyB;AAFvB,qHAAA,mBAAmB,OAAA;AACnB,mHAAA,iBAAiB,OAAA"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface LogParams {
|
|
2
|
+
module: string;
|
|
3
|
+
message: string;
|
|
4
|
+
args?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export type ErrorLogParams = LogParams & {
|
|
7
|
+
err: Error;
|
|
8
|
+
};
|
|
9
|
+
export interface Logger {
|
|
10
|
+
trace(params: LogParams): void;
|
|
11
|
+
debug(params: LogParams): void;
|
|
12
|
+
info(params: LogParams): void;
|
|
13
|
+
warn(params: LogParams): void;
|
|
14
|
+
error(params: ErrorLogParams): void;
|
|
15
|
+
}
|
|
16
|
+
export declare class DefaultLogger implements Logger {
|
|
17
|
+
trace({ module, message, args }: LogParams): void;
|
|
18
|
+
debug({ module, message, args }: LogParams): void;
|
|
19
|
+
info({ module, message, args }: LogParams): void;
|
|
20
|
+
warn({ module, message, args }: LogParams): void;
|
|
21
|
+
error({ module, message, args, err }: ErrorLogParams): void;
|
|
22
|
+
}
|
|
23
|
+
export declare class LogWriter {
|
|
24
|
+
private readonly logger;
|
|
25
|
+
private readonly logLevel;
|
|
26
|
+
constructor(logger: Logger, logLevel?: ClickHouseLogLevel);
|
|
27
|
+
trace(params: LogParams): void;
|
|
28
|
+
debug(params: LogParams): void;
|
|
29
|
+
info(params: LogParams): void;
|
|
30
|
+
warn(params: LogParams): void;
|
|
31
|
+
error(params: ErrorLogParams): void;
|
|
32
|
+
}
|
|
33
|
+
export declare enum ClickHouseLogLevel {
|
|
34
|
+
TRACE = 0,
|
|
35
|
+
DEBUG = 1,
|
|
36
|
+
INFO = 2,
|
|
37
|
+
WARN = 3,
|
|
38
|
+
ERROR = 4,
|
|
39
|
+
OFF = 127
|
|
40
|
+
}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClickHouseLogLevel = exports.LogWriter = exports.DefaultLogger = void 0;
|
|
4
|
+
class DefaultLogger {
|
|
5
|
+
trace({ module, message, args }) {
|
|
6
|
+
console.trace(formatMessage({ module, message }), args);
|
|
7
|
+
}
|
|
8
|
+
debug({ module, message, args }) {
|
|
9
|
+
console.debug(formatMessage({ module, message }), args);
|
|
10
|
+
}
|
|
11
|
+
info({ module, message, args }) {
|
|
12
|
+
console.info(formatMessage({ module, message }), args);
|
|
13
|
+
}
|
|
14
|
+
warn({ module, message, args }) {
|
|
15
|
+
console.warn(formatMessage({ module, message }), args);
|
|
16
|
+
}
|
|
17
|
+
error({ module, message, args, err }) {
|
|
18
|
+
console.error(formatMessage({ module, message }), args, err);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.DefaultLogger = DefaultLogger;
|
|
22
|
+
class LogWriter {
|
|
23
|
+
constructor(logger, logLevel) {
|
|
24
|
+
Object.defineProperty(this, "logger", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: logger
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "logLevel", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
this.logLevel = logLevel !== null && logLevel !== void 0 ? logLevel : ClickHouseLogLevel.OFF;
|
|
37
|
+
this.info({
|
|
38
|
+
module: 'Logger',
|
|
39
|
+
message: `Log level is set to ${ClickHouseLogLevel[this.logLevel]}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
trace(params) {
|
|
43
|
+
if (this.logLevel <= ClickHouseLogLevel.TRACE) {
|
|
44
|
+
this.logger.trace(params);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
debug(params) {
|
|
48
|
+
if (this.logLevel <= ClickHouseLogLevel.DEBUG) {
|
|
49
|
+
this.logger.debug(params);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
info(params) {
|
|
53
|
+
if (this.logLevel <= ClickHouseLogLevel.INFO) {
|
|
54
|
+
this.logger.info(params);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
warn(params) {
|
|
58
|
+
if (this.logLevel <= ClickHouseLogLevel.WARN) {
|
|
59
|
+
this.logger.warn(params);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
error(params) {
|
|
63
|
+
if (this.logLevel <= ClickHouseLogLevel.ERROR) {
|
|
64
|
+
this.logger.error(params);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.LogWriter = LogWriter;
|
|
69
|
+
var ClickHouseLogLevel;
|
|
70
|
+
(function (ClickHouseLogLevel) {
|
|
71
|
+
ClickHouseLogLevel[ClickHouseLogLevel["TRACE"] = 0] = "TRACE";
|
|
72
|
+
ClickHouseLogLevel[ClickHouseLogLevel["DEBUG"] = 1] = "DEBUG";
|
|
73
|
+
ClickHouseLogLevel[ClickHouseLogLevel["INFO"] = 2] = "INFO";
|
|
74
|
+
ClickHouseLogLevel[ClickHouseLogLevel["WARN"] = 3] = "WARN";
|
|
75
|
+
ClickHouseLogLevel[ClickHouseLogLevel["ERROR"] = 4] = "ERROR";
|
|
76
|
+
ClickHouseLogLevel[ClickHouseLogLevel["OFF"] = 127] = "OFF";
|
|
77
|
+
})(ClickHouseLogLevel = exports.ClickHouseLogLevel || (exports.ClickHouseLogLevel = {}));
|
|
78
|
+
function formatMessage({ module, message, }) {
|
|
79
|
+
return `[@clickhouse/client][${module}] ${message}`;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../packages/client-common/src/logger.ts"],"names":[],"mapp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/dist/result.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface Row {
|
|
2
|
+
/** A string representation of a row. */
|
|
3
|
+
text: string;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a JSON representation of a row.
|
|
6
|
+
* The method will throw if called on a response in JSON incompatible format.
|
|
7
|
+
* It is safe to call this method multiple times.
|
|
8
|
+
*/
|
|
9
|
+
json<T>(): T;
|
|
10
|
+
}
|
|
11
|
+
export interface BaseResultSet<Stream> {
|
|
12
|
+
/**
|
|
13
|
+
* The method waits for all the rows to be fully loaded
|
|
14
|
+
* and returns the result as a string.
|
|
15
|
+
*
|
|
16
|
+
* The method should throw if the underlying stream was already consumed
|
|
17
|
+
* by calling the other methods.
|
|
18
|
+
*/
|
|
19
|
+
text(): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* The method waits for the all the rows to be fully loaded.
|
|
22
|
+
* When the response is received in full, it will be decoded to return JSON.
|
|
23
|
+
*
|
|
24
|
+
* The method should throw if the underlying stream was already consumed
|
|
25
|
+
* by calling the other methods.
|
|
26
|
+
*/
|
|
27
|
+
json<T>(): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a readable stream for responses that can be streamed
|
|
30
|
+
* (i.e. all except JSON).
|
|
31
|
+
*
|
|
32
|
+
* Every iteration provides an array of {@link Row} instances
|
|
33
|
+
* for {@link StreamableDataFormat} format.
|
|
34
|
+
*
|
|
35
|
+
* Should be called only once.
|
|
36
|
+
*
|
|
37
|
+
* The method should throw if called on a response in non-streamable format,
|
|
38
|
+
* and if the underlying stream was already consumed
|
|
39
|
+
* by calling the other methods.
|
|
40
|
+
*/
|
|
41
|
+
stream(): Stream;
|
|
42
|
+
/** Close the underlying stream. */
|
|
43
|
+
close(): void;
|
|
44
|
+
/** ClickHouse server QueryID. */
|
|
45
|
+
query_id: string;
|
|
46
|
+
}
|
package/dist/result.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../packages/client-common/src/result.ts"],"names":[],"mappings":""}
|