@clickhouse/client-common 0.3.0 → 0.4.0

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 (79) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +14 -0
  3. package/dist/clickhouse_types.d.ts +59 -1
  4. package/dist/clickhouse_types.js +27 -0
  5. package/dist/clickhouse_types.js.map +1 -1
  6. package/dist/client.d.ts +126 -95
  7. package/dist/client.js +119 -76
  8. package/dist/client.js.map +1 -1
  9. package/dist/config.d.ts +173 -0
  10. package/dist/config.js +309 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/connection.d.ts +44 -13
  13. package/dist/connection.js.map +1 -1
  14. package/dist/data_formatter/format_query_params.d.ts +11 -1
  15. package/dist/data_formatter/format_query_params.js +102 -16
  16. package/dist/data_formatter/format_query_params.js.map +1 -1
  17. package/dist/data_formatter/format_query_settings.js +1 -2
  18. package/dist/data_formatter/format_query_settings.js.map +1 -1
  19. package/dist/data_formatter/formatter.d.ts +32 -14
  20. package/dist/data_formatter/formatter.js +27 -46
  21. package/dist/data_formatter/formatter.js.map +1 -1
  22. package/dist/data_formatter/index.d.ts +1 -1
  23. package/dist/data_formatter/index.js +2 -1
  24. package/dist/data_formatter/index.js.map +1 -1
  25. package/dist/error/error.d.ts +20 -0
  26. package/dist/error/error.js +69 -0
  27. package/dist/error/error.js.map +1 -0
  28. package/dist/error/index.d.ts +1 -1
  29. package/dist/error/index.js +1 -1
  30. package/dist/error/index.js.map +1 -1
  31. package/dist/index.d.ts +18 -12
  32. package/dist/index.js +34 -12
  33. package/dist/index.js.map +1 -1
  34. package/dist/logger.js +8 -8
  35. package/dist/logger.js.map +1 -1
  36. package/dist/parse/column_types.d.ts +127 -0
  37. package/dist/parse/column_types.js +540 -0
  38. package/dist/parse/column_types.js.map +1 -0
  39. package/dist/parse/index.d.ts +2 -0
  40. package/dist/parse/index.js +19 -0
  41. package/dist/parse/index.js.map +1 -0
  42. package/dist/parse/json_handling.d.ts +19 -0
  43. package/dist/parse/json_handling.js +8 -0
  44. package/dist/parse/json_handling.js.map +1 -0
  45. package/dist/result.d.ts +52 -8
  46. package/dist/result.js.map +1 -1
  47. package/dist/settings.d.ts +38 -2
  48. package/dist/settings.js.map +1 -1
  49. package/dist/ts_utils.d.ts +4 -0
  50. package/dist/ts_utils.js +3 -0
  51. package/dist/ts_utils.js.map +1 -0
  52. package/dist/utils/connection.d.ts +11 -3
  53. package/dist/utils/connection.js +19 -7
  54. package/dist/utils/connection.js.map +1 -1
  55. package/dist/utils/index.d.ts +2 -2
  56. package/dist/utils/index.js +2 -2
  57. package/dist/utils/index.js.map +1 -1
  58. package/dist/utils/sleep.d.ts +1 -0
  59. package/dist/utils/sleep.js +9 -0
  60. package/dist/utils/sleep.js.map +1 -0
  61. package/dist/utils/stream.d.ts +14 -0
  62. package/dist/utils/stream.js +53 -0
  63. package/dist/utils/stream.js.map +1 -0
  64. package/dist/utils/url.d.ts +5 -4
  65. package/dist/utils/url.js +22 -13
  66. package/dist/utils/url.js.map +1 -1
  67. package/dist/version.d.ts +1 -1
  68. package/dist/version.js +1 -1
  69. package/dist/version.js.map +1 -1
  70. package/package.json +6 -2
  71. package/dist/error/parse_error.d.ts +0 -12
  72. package/dist/error/parse_error.js +0 -41
  73. package/dist/error/parse_error.js.map +0 -1
  74. package/dist/utils/permutations.d.ts +0 -1
  75. package/dist/utils/permutations.js +0 -12
  76. package/dist/utils/permutations.js.map +0 -1
  77. package/dist/utils/string.d.ts +0 -1
  78. package/dist/utils/string.js +0 -8
  79. package/dist/utils/string.js.map +0 -1
@@ -1,23 +1,41 @@
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", "Parquet"];
3
- export type JSONDataFormat = (typeof supportedJSONFormats)[number];
4
- export type RawDataFormat = (typeof supportedRawFormats)[number];
1
+ import type { JSONHandling } from '../parse';
2
+ export declare const StreamableJSONFormats: readonly ["JSONEachRow", "JSONStringsEachRow", "JSONCompactEachRow", "JSONCompactStringsEachRow", "JSONCompactEachRowWithNames", "JSONCompactEachRowWithNamesAndTypes", "JSONCompactStringsEachRowWithNames", "JSONCompactStringsEachRowWithNamesAndTypes", "JSONEachRowWithProgress"];
3
+ export declare const RecordsJSONFormats: readonly ["JSONObjectEachRow"];
4
+ export declare const SingleDocumentJSONFormats: readonly ["JSON", "JSONStrings", "JSONCompact", "JSONCompactStrings", "JSONColumnsWithMetadata"];
5
+ export declare const SupportedJSONFormats: readonly ["JSONObjectEachRow", "JSON", "JSONStrings", "JSONCompact", "JSONCompactStrings", "JSONColumnsWithMetadata", "JSONEachRow", "JSONStringsEachRow", "JSONCompactEachRow", "JSONCompactStringsEachRow", "JSONCompactEachRowWithNames", "JSONCompactEachRowWithNamesAndTypes", "JSONCompactStringsEachRowWithNames", "JSONCompactStringsEachRowWithNamesAndTypes", "JSONEachRowWithProgress"];
6
+ export declare const SupportedRawFormats: readonly ["CSV", "CSVWithNames", "CSVWithNamesAndTypes", "TabSeparated", "TabSeparatedRaw", "TabSeparatedWithNames", "TabSeparatedWithNamesAndTypes", "CustomSeparated", "CustomSeparatedWithNames", "CustomSeparatedWithNamesAndTypes", "Parquet"];
7
+ export declare const StreamableFormats: readonly ["JSONEachRow", "JSONStringsEachRow", "JSONCompactEachRow", "JSONCompactStringsEachRow", "JSONCompactEachRowWithNames", "JSONCompactEachRowWithNamesAndTypes", "JSONCompactStringsEachRowWithNames", "JSONCompactStringsEachRowWithNamesAndTypes", "JSONEachRowWithProgress", "CSV", "CSVWithNames", "CSVWithNamesAndTypes", "TabSeparated", "TabSeparatedRaw", "TabSeparatedWithNames", "TabSeparatedWithNamesAndTypes", "CustomSeparated", "CustomSeparatedWithNames", "CustomSeparatedWithNamesAndTypes", "Parquet"];
8
+ /** CSV, TSV, etc. - can be streamed, but cannot be decoded as JSON. */
9
+ export type RawDataFormat = (typeof SupportedRawFormats)[number];
10
+ /** Each row is returned as a separate JSON object or an array, and these formats can be streamed. */
11
+ export type StreamableJSONDataFormat = (typeof StreamableJSONFormats)[number];
12
+ /** Returned as a single {@link ResponseJSON} object, cannot be streamed. */
13
+ export type SingleDocumentJSONFormat = (typeof SingleDocumentJSONFormats)[number];
14
+ /** Returned as a single object { row_1: T, row_2: T, ...} <br/>
15
+ * (i.e. Record<string, T>), cannot be streamed. */
16
+ export type RecordsJSONFormat = (typeof RecordsJSONFormats)[number];
17
+ /** All allowed JSON formats, whether streamable or not. */
18
+ export type JSONDataFormat = StreamableJSONDataFormat | SingleDocumentJSONFormat | RecordsJSONFormat;
19
+ /** Data formats that are currently supported by the client. <br/>
20
+ * This is a union of the following types:<br/>
21
+ * * {@link JSONDataFormat}
22
+ * * {@link RawDataFormat}
23
+ * * {@link StreamableDataFormat}
24
+ * * {@link StreamableJSONDataFormat}
25
+ * * {@link SingleDocumentJSONFormat}
26
+ * * {@link RecordsJSONFormat}
27
+ * @see https://clickhouse.com/docs/en/interfaces/formats */
5
28
  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", "Parquet"];
7
- type StreamableDataFormat = (typeof streamableFormat)[number];
29
+ /** All data formats that can be streamed, whether it can be decoded as JSON or not. */
30
+ export type StreamableDataFormat = (typeof StreamableFormats)[number];
31
+ export declare function isNotStreamableJSONFamily(format: DataFormat): format is SingleDocumentJSONFormat;
32
+ export declare function isStreamableJSONFamily(format: DataFormat): format is StreamableJSONDataFormat;
8
33
  export declare function isSupportedRawFormat(dataFormat: DataFormat): boolean;
9
34
  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
35
  /**
17
36
  * Encodes a single row of values into a string in a JSON format acceptable by ClickHouse.
18
37
  * @param value a single value to encode.
19
38
  * @param format One of the supported JSON formats: https://clickhouse.com/docs/en/interfaces/formats/
20
39
  * @returns string
21
40
  */
22
- export declare function encodeJSON(value: any, format: DataFormat): string;
23
- export {};
41
+ export declare function encodeJSON(value: any, format: DataFormat, stringifyFn: JSONHandling['stringify']): string;
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodeJSON = exports.decode = exports.validateStreamFormat = exports.isSupportedRawFormat = void 0;
4
- const streamableJSONFormats = [
3
+ exports.StreamableFormats = exports.SupportedRawFormats = exports.SupportedJSONFormats = exports.SingleDocumentJSONFormats = exports.RecordsJSONFormats = exports.StreamableJSONFormats = void 0;
4
+ exports.isNotStreamableJSONFamily = isNotStreamableJSONFamily;
5
+ exports.isStreamableJSONFamily = isStreamableJSONFamily;
6
+ exports.isSupportedRawFormat = isSupportedRawFormat;
7
+ exports.validateStreamFormat = validateStreamFormat;
8
+ exports.encodeJSON = encodeJSON;
9
+ exports.StreamableJSONFormats = [
5
10
  'JSONEachRow',
6
11
  'JSONStringsEachRow',
7
12
  'JSONCompactEachRow',
@@ -10,20 +15,22 @@ const streamableJSONFormats = [
10
15
  'JSONCompactEachRowWithNamesAndTypes',
11
16
  'JSONCompactStringsEachRowWithNames',
12
17
  'JSONCompactStringsEachRowWithNamesAndTypes',
18
+ 'JSONEachRowWithProgress',
13
19
  ];
14
- const singleDocumentJSONFormats = [
20
+ exports.RecordsJSONFormats = ['JSONObjectEachRow'];
21
+ exports.SingleDocumentJSONFormats = [
15
22
  'JSON',
16
23
  'JSONStrings',
17
24
  'JSONCompact',
18
25
  'JSONCompactStrings',
19
26
  'JSONColumnsWithMetadata',
20
- 'JSONObjectEachRow',
21
27
  ];
22
- const supportedJSONFormats = [
23
- ...singleDocumentJSONFormats,
24
- ...streamableJSONFormats,
28
+ exports.SupportedJSONFormats = [
29
+ ...exports.RecordsJSONFormats,
30
+ ...exports.SingleDocumentJSONFormats,
31
+ ...exports.StreamableJSONFormats,
25
32
  ];
26
- const supportedRawFormats = [
33
+ exports.SupportedRawFormats = [
27
34
  'CSV',
28
35
  'CSVWithNames',
29
36
  'CSVWithNamesAndTypes',
@@ -36,62 +43,36 @@ const supportedRawFormats = [
36
43
  'CustomSeparatedWithNamesAndTypes',
37
44
  'Parquet',
38
45
  ];
39
- // TODO add others formats
40
- const streamableFormat = [
41
- ...streamableJSONFormats,
42
- ...supportedRawFormats,
46
+ exports.StreamableFormats = [
47
+ ...exports.StreamableJSONFormats,
48
+ ...exports.SupportedRawFormats,
43
49
  ];
44
50
  function isNotStreamableJSONFamily(format) {
45
- // @ts-expect-error JSON is not assignable to notStreamableJSONFormats
46
- return singleDocumentJSONFormats.includes(format);
51
+ return (exports.SingleDocumentJSONFormats.includes(format) ||
52
+ exports.RecordsJSONFormats.includes(format));
47
53
  }
48
54
  function isStreamableJSONFamily(format) {
49
- // @ts-expect-error JSON is not assignable to streamableJSONFormats
50
- return streamableJSONFormats.includes(format);
55
+ return exports.StreamableJSONFormats.includes(format);
51
56
  }
52
57
  function isSupportedRawFormat(dataFormat) {
53
- return supportedRawFormats.includes(dataFormat);
58
+ return exports.SupportedRawFormats.includes(dataFormat);
54
59
  }
55
- exports.isSupportedRawFormat = isSupportedRawFormat;
56
60
  function validateStreamFormat(format) {
57
- if (!streamableFormat.includes(format)) {
58
- throw new Error(`${format} format is not streamable. Streamable formats: ${streamableFormat.join(',')}`);
61
+ if (!exports.StreamableFormats.includes(format)) {
62
+ throw new Error(`${format} format is not streamable. Streamable formats: ${exports.StreamableFormats.join(',')}`);
59
63
  }
60
64
  return true;
61
65
  }
62
- exports.validateStreamFormat = validateStreamFormat;
63
- /**
64
- * Decodes a string in a ClickHouse format into a plain JavaScript object or an array of objects.
65
- * @param text a string in a ClickHouse data format
66
- * @param format One of the supported formats: https://clickhouse.com/docs/en/interfaces/formats/
67
- */
68
- function decode(text, format) {
69
- if (isNotStreamableJSONFamily(format)) {
70
- return JSON.parse(text);
71
- }
72
- if (isStreamableJSONFamily(format)) {
73
- return text
74
- .split('\n')
75
- .filter(Boolean)
76
- .map((l) => decode(l, 'JSON'));
77
- }
78
- if (isSupportedRawFormat(format)) {
79
- throw new Error(`Cannot decode ${format} to JSON`);
80
- }
81
- throw new Error(`The client does not support [${format}] format decoding.`);
82
- }
83
- exports.decode = decode;
84
66
  /**
85
67
  * Encodes a single row of values into a string in a JSON format acceptable by ClickHouse.
86
68
  * @param value a single value to encode.
87
69
  * @param format One of the supported JSON formats: https://clickhouse.com/docs/en/interfaces/formats/
88
70
  * @returns string
89
71
  */
90
- function encodeJSON(value, format) {
91
- if (supportedJSONFormats.includes(format)) {
92
- return JSON.stringify(value) + '\n';
72
+ function encodeJSON(value, format, stringifyFn) {
73
+ if (exports.SupportedJSONFormats.includes(format)) {
74
+ return stringifyFn(value) + '\n';
93
75
  }
94
76
  throw new Error(`The client does not support JSON encoding in [${format}] format.`);
95
77
  }
96
- exports.encodeJSON = encodeJSON;
97
78
  //# sourceMappingURL=formatter.js.map
@@ -1 +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;IAClC,SAAS;CACD,CAAA;AAUV,0BAA0B;AAC1B,MAAM,gBAAgB,GAAG;IACvB,GAAG,qBAAqB;IACxB,GAAG,mBAAmB;CACd,CAAA;AAGV,SAAS,yBAAyB,CAChC,MAAkB;IAElB,sEAAsE;IACtE,OAAO,yBAAyB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACnD,CAAC;AAED,SAAS,sBAAsB,CAC7B,MAAkB;IAElB,mEAAmE;IACnE,OAAO,qBAAqB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC/C,CAAC;AAED,SAAgB,oBAAoB,CAAC,UAAsB;IACzD,OAAQ,mBAAyC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;AACxE,CAAC;AAFD,oDAEC;AAED,SAAgB,oBAAoB,CAClC,MAAW;IAEX,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,kDAAkD,gBAAgB,CAAC,IAAI,CAC9E,GAAG,CACJ,EAAE,CACJ,CAAA;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAXD,oDAWC;AAED;;;;GAIG;AACH,SAAgB,MAAM,CAAC,IAAY,EAAE,MAAkB;IACrD,IAAI,yBAAyB,CAAC,MAAM,CAAC,EAAE;QACrC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;KACxB;IACD,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAE;QAClC,OAAO,IAAI;aACR,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,OAAO,CAAC;aACf,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;KACjC;IACD,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE;QAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,MAAM,UAAU,CAAC,CAAA;KACnD;IACD,MAAM,IAAI,KAAK,CAAC,gCAAgC,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"}
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/data_formatter/formatter.ts"],"names":[],"mappings":";;;AA8EA,8DAOC;AAED,wDAIC;AAED,oDAEC;AAED,oDAWC;AAQD,gCAWC;AA7HY,QAAA,qBAAqB,GAAG;IACnC,aAAa;IACb,oBAAoB;IACpB,oBAAoB;IACpB,2BAA2B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ED;;;;;GAKG;AACH,SAAgB,UAAU,CACxB,KAAU,EACV,MAAkB,EAClB,WAAsC;IAEtC,IAAK,4BAA0C,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA;IAClC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,iDAAiD,MAAM,WAAW,CACnE,CAAA;AACH,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export * from './formatter';
2
- export { formatQueryParams } from './format_query_params';
2
+ export { TupleParam, formatQueryParams } from './format_query_params';
3
3
  export { formatQuerySettings } from './format_query_settings';
@@ -14,9 +14,10 @@ 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
- exports.formatQuerySettings = exports.formatQueryParams = void 0;
17
+ exports.formatQuerySettings = exports.formatQueryParams = exports.TupleParam = void 0;
18
18
  __exportStar(require("./formatter"), exports);
19
19
  var format_query_params_1 = require("./format_query_params");
20
+ Object.defineProperty(exports, "TupleParam", { enumerable: true, get: function () { return format_query_params_1.TupleParam; } });
20
21
  Object.defineProperty(exports, "formatQueryParams", { enumerable: true, get: function () { return format_query_params_1.formatQueryParams; } });
21
22
  var format_query_settings_1 = require("./format_query_settings");
22
23
  Object.defineProperty(exports, "formatQuerySettings", { enumerable: true, get: function () { return format_query_settings_1.formatQuerySettings; } });
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data_formatter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,6DAAqE;AAA5D,iHAAA,UAAU,OAAA;AAAE,wHAAA,iBAAiB,OAAA;AACtC,iEAA6D;AAApD,4HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,20 @@
1
+ interface ParsedClickHouseError {
2
+ message: string;
3
+ code: string;
4
+ type?: string;
5
+ }
6
+ /** An error that is thrown by the ClickHouse server. */
7
+ export declare class ClickHouseError extends Error {
8
+ readonly code: string;
9
+ readonly type: string | undefined;
10
+ constructor({ message, code, type }: ParsedClickHouseError);
11
+ }
12
+ export declare function parseError(input: string | Error): ClickHouseError | Error;
13
+ /** Captures the current stack trace from the sync context before going async.
14
+ * It is necessary since the majority of the stack trace is lost when an async callback is called. */
15
+ export declare function getCurrentStackTrace(): string;
16
+ /** Having the stack trace produced by the {@link getCurrentStackTrace} function,
17
+ * add it to an arbitrary error stack trace. No-op if there is no additional stack trace to add.
18
+ * It could happen if this feature was disabled due to its performance overhead. */
19
+ export declare function enhanceStackTrace<E extends Error>(err: E, stackTrace: string | undefined): E;
20
+ export {};
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClickHouseError = void 0;
4
+ exports.parseError = parseError;
5
+ exports.getCurrentStackTrace = getCurrentStackTrace;
6
+ exports.enhanceStackTrace = enhanceStackTrace;
7
+ const errorRe = /(Code|Error): (?<code>\d+).*Exception: (?<message>.+)\((?<type>(?=.+[A-Z]{3})[A-Z0-9_]+?)\)/s;
8
+ /** An error that is thrown by the ClickHouse server. */
9
+ class ClickHouseError extends Error {
10
+ constructor({ message, code, type }) {
11
+ super(message);
12
+ Object.defineProperty(this, "code", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "type", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ this.code = code;
25
+ this.type = type;
26
+ // Set the prototype explicitly, see:
27
+ // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
28
+ Object.setPrototypeOf(this, ClickHouseError.prototype);
29
+ }
30
+ }
31
+ exports.ClickHouseError = ClickHouseError;
32
+ function parseError(input) {
33
+ const inputIsError = input instanceof Error;
34
+ const message = inputIsError ? input.message : input;
35
+ const match = message.match(errorRe);
36
+ const groups = match?.groups;
37
+ if (groups) {
38
+ return new ClickHouseError(groups);
39
+ }
40
+ else {
41
+ return inputIsError ? input : new Error(input);
42
+ }
43
+ }
44
+ /** Captures the current stack trace from the sync context before going async.
45
+ * It is necessary since the majority of the stack trace is lost when an async callback is called. */
46
+ function getCurrentStackTrace() {
47
+ const stack = new Error().stack;
48
+ if (!stack)
49
+ return '';
50
+ // Skip the first three lines of the stack trace, containing useless information
51
+ // - Text `Error`
52
+ // - Info about this function call
53
+ // - Info about the originator of this function call, e.g., `request`
54
+ // Additionally, the original stack trace is, in fact, reversed.
55
+ return stack.split('\n').slice(3).reverse().join('\n');
56
+ }
57
+ /** Having the stack trace produced by the {@link getCurrentStackTrace} function,
58
+ * add it to an arbitrary error stack trace. No-op if there is no additional stack trace to add.
59
+ * It could happen if this feature was disabled due to its performance overhead. */
60
+ function enhanceStackTrace(err, stackTrace) {
61
+ if (err.stack && stackTrace) {
62
+ const firstNewlineIndex = err.stack.indexOf('\n');
63
+ const firstLine = err.stack.substring(0, firstNewlineIndex);
64
+ const errStack = err.stack.substring(firstNewlineIndex + 1);
65
+ err.stack = `${firstLine}\n${stackTrace}\n${errStack}`;
66
+ }
67
+ return err;
68
+ }
69
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error/error.ts"],"names":[],"mappings":";;;AAwBA,gCAUC;AAID,oDAUC;AAKD,8CAWC;AAhED,MAAM,OAAO,GACX,8FAA8F,CAAA;AAQhG,wDAAwD;AAC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AA;AACxD,CAAC;AAED;;oFAEoF;AACpF,SAAgB,iBAAiB,CAC/B,GAAM,EACN,UAA8B;IAE9B,IAAI,GAAG,CAAC,KAAK,IAAI,UAAU,EAAE,CAAC;QAC5B,MAAM,iBAAiB,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACjD,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;QAC3D,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAA;QAC3D,GAAG,CAAC,KAAK,GAAG,GAAG,SAAS,KAAK,UAAU,KAAK,QAAQ,EAAE,CAAA;IACxD,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -1 +1 @@
1
- export * from './parse_error';
1
+ export * from './error';
@@ -14,5 +14,5 @@ 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("./parse_error"), exports);
17
+ __exportStar(require("./error"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/client-common/src/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB"}
package/dist/index.d.ts CHANGED
@@ -1,16 +1,22 @@
1
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, type PingResult, } from './client';
3
- export type { Row, BaseResultSet } from './result';
4
- export { type DataFormat } from './data_formatter';
5
- export { ClickHouseError } from './error';
2
+ export { type BaseQueryParams, type QueryParams, type QueryResult, type ExecParams, type InsertParams, ClickHouseClient, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type PingResult, type PingParams, type PingParamsWithSelectQuery, type PingParamsWithEndpoint, } from './client';
3
+ export { type BaseClickHouseClientConfigOptions } from './config';
4
+ export type { Row, RowOrProgress, BaseResultSet, ResultJSONType, RowJSONType, ResultStream, } from './result';
5
+ export type { DataFormat, RawDataFormat, JSONDataFormat, StreamableDataFormat, StreamableJSONDataFormat, SingleDocumentJSONFormat, SupportedJSONFormats, SupportedRawFormats, StreamableFormats, StreamableJSONFormats, SingleDocumentJSONFormats, RecordsJSONFormats, } from './data_formatter';
6
+ export { TupleParam } from './data_formatter';
7
+ export { ClickHouseError, parseError } from './error';
6
8
  export { ClickHouseLogLevel, type ErrorLogParams, type WarnLogParams, type Logger, type LogParams, } from './logger';
7
- export type { ClickHouseSummary, WithClickHouseSummary, ResponseJSON, InputJSON, InputJSONObjectEachRow, } from './clickhouse_types';
9
+ export type { ClickHouseSummary, InputJSON, InputJSONObjectEachRow, ResponseJSON, ResponseHeaders, WithClickHouseSummary, WithResponseHeaders, ProgressRow, InsertValues, ClickHouseAuth, ClickHouseJWTAuth, ClickHouseCredentialsAuth, } from './clickhouse_types';
10
+ export { isProgressRow, isRow, isException } from './clickhouse_types';
8
11
  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';
12
+ export type { SimpleColumnType, ParsedColumnSimple, ParsedColumnEnum, ParsedColumnFixedString, ParsedColumnNullable, ParsedColumnDecimal, ParsedColumnDateTime, ParsedColumnDateTime64, ParsedColumnArray, ParsedColumnTuple, ParsedColumnMap, ParsedColumnType, JSONHandling, } from './parse';
13
+ export { SimpleColumnTypes, parseColumnType, defaultJSONHandling, } from './parse';
14
+ /** For implementation usage only - should not be re-exported */
15
+ export { formatQuerySettings, formatQueryParams, encodeJSON, isSupportedRawFormat, isStreamableJSONFamily, isNotStreamableJSONFamily, validateStreamFormat, } from './data_formatter';
16
+ export { type ValuesEncoder, type MakeResultSet, type MakeConnection, type HandleImplSpecificURLParams, type ImplementationDetails, booleanConfigURLValue, enumConfigURLValue, getConnectionParams, numberConfigURLValue, } from './config';
17
+ export { EXCEPTION_TAG_HEADER_NAME, isSuccessfulResponse, sleep, toSearchParams, transformUrl, withCompressionHeaders, withHttpSettings, isCredentialsAuth, isJWTAuth, checkErrorInChunkAtIndex, } from './utils';
13
18
  export { LogWriter, DefaultLogger, type LogWriterParams } from './logger';
14
- export { parseError } from './error';
15
- export type { Connection, ConnectionParams, ConnInsertResult, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, ConnPingResult, ConnOperation, } from './connection';
16
- export { type RawDataFormat, type JSONDataFormat, formatQuerySettings, formatQueryParams, } from './data_formatter';
19
+ export { getCurrentStackTrace, enhanceStackTrace } from './error';
20
+ export type { CompressionSettings, Connection, ConnectionParams, ConnInsertResult, ConnExecParams, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, ConnPingResult, ConnCommandResult, ConnOperation, ConnPingParams, } from './connection';
21
+ export type { QueryParamsWithFormat } from './client';
22
+ export type { IsSame } from './ts_utils';
package/dist/index.js CHANGED
@@ -1,33 +1,55 @@
1
1
  "use strict";
2
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;
3
+ exports.enhanceStackTrace = exports.getCurrentStackTrace = exports.DefaultLogger = exports.LogWriter = exports.checkErrorInChunkAtIndex = exports.isJWTAuth = exports.isCredentialsAuth = exports.withHttpSettings = exports.withCompressionHeaders = exports.transformUrl = exports.toSearchParams = exports.sleep = exports.isSuccessfulResponse = exports.EXCEPTION_TAG_HEADER_NAME = exports.numberConfigURLValue = exports.getConnectionParams = exports.enumConfigURLValue = exports.booleanConfigURLValue = exports.validateStreamFormat = exports.isNotStreamableJSONFamily = exports.isStreamableJSONFamily = exports.isSupportedRawFormat = exports.encodeJSON = exports.formatQueryParams = exports.formatQuerySettings = exports.defaultJSONHandling = exports.parseColumnType = exports.SimpleColumnTypes = exports.SettingsMap = exports.isException = exports.isRow = exports.isProgressRow = exports.ClickHouseLogLevel = exports.parseError = exports.ClickHouseError = exports.TupleParam = exports.ClickHouseClient = void 0;
4
4
  /** Should be re-exported by the implementation */
5
5
  var client_1 = require("./client");
6
6
  Object.defineProperty(exports, "ClickHouseClient", { enumerable: true, get: function () { return client_1.ClickHouseClient; } });
7
+ var data_formatter_1 = require("./data_formatter");
8
+ Object.defineProperty(exports, "TupleParam", { enumerable: true, get: function () { return data_formatter_1.TupleParam; } });
7
9
  var error_1 = require("./error");
8
10
  Object.defineProperty(exports, "ClickHouseError", { enumerable: true, get: function () { return error_1.ClickHouseError; } });
11
+ Object.defineProperty(exports, "parseError", { enumerable: true, get: function () { return error_1.parseError; } });
9
12
  var logger_1 = require("./logger");
10
13
  Object.defineProperty(exports, "ClickHouseLogLevel", { enumerable: true, get: function () { return logger_1.ClickHouseLogLevel; } });
14
+ var clickhouse_types_1 = require("./clickhouse_types");
15
+ Object.defineProperty(exports, "isProgressRow", { enumerable: true, get: function () { return clickhouse_types_1.isProgressRow; } });
16
+ Object.defineProperty(exports, "isRow", { enumerable: true, get: function () { return clickhouse_types_1.isRow; } });
17
+ Object.defineProperty(exports, "isException", { enumerable: true, get: function () { return clickhouse_types_1.isException; } });
11
18
  var settings_1 = require("./settings");
12
19
  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; } });
20
+ var parse_1 = require("./parse");
21
+ Object.defineProperty(exports, "SimpleColumnTypes", { enumerable: true, get: function () { return parse_1.SimpleColumnTypes; } });
22
+ Object.defineProperty(exports, "parseColumnType", { enumerable: true, get: function () { return parse_1.parseColumnType; } });
23
+ Object.defineProperty(exports, "defaultJSONHandling", { enumerable: true, get: function () { return parse_1.defaultJSONHandling; } });
24
+ /** For implementation usage only - should not be re-exported */
25
+ var data_formatter_2 = require("./data_formatter");
26
+ Object.defineProperty(exports, "formatQuerySettings", { enumerable: true, get: function () { return data_formatter_2.formatQuerySettings; } });
27
+ Object.defineProperty(exports, "formatQueryParams", { enumerable: true, get: function () { return data_formatter_2.formatQueryParams; } });
28
+ Object.defineProperty(exports, "encodeJSON", { enumerable: true, get: function () { return data_formatter_2.encodeJSON; } });
29
+ Object.defineProperty(exports, "isSupportedRawFormat", { enumerable: true, get: function () { return data_formatter_2.isSupportedRawFormat; } });
30
+ Object.defineProperty(exports, "isStreamableJSONFamily", { enumerable: true, get: function () { return data_formatter_2.isStreamableJSONFamily; } });
31
+ Object.defineProperty(exports, "isNotStreamableJSONFamily", { enumerable: true, get: function () { return data_formatter_2.isNotStreamableJSONFamily; } });
32
+ Object.defineProperty(exports, "validateStreamFormat", { enumerable: true, get: function () { return data_formatter_2.validateStreamFormat; } });
33
+ var config_1 = require("./config");
34
+ Object.defineProperty(exports, "booleanConfigURLValue", { enumerable: true, get: function () { return config_1.booleanConfigURLValue; } });
35
+ Object.defineProperty(exports, "enumConfigURLValue", { enumerable: true, get: function () { return config_1.enumConfigURLValue; } });
36
+ Object.defineProperty(exports, "getConnectionParams", { enumerable: true, get: function () { return config_1.getConnectionParams; } });
37
+ Object.defineProperty(exports, "numberConfigURLValue", { enumerable: true, get: function () { return config_1.numberConfigURLValue; } });
19
38
  var utils_1 = require("./utils");
20
- Object.defineProperty(exports, "withCompressionHeaders", { enumerable: true, get: function () { return utils_1.withCompressionHeaders; } });
39
+ Object.defineProperty(exports, "EXCEPTION_TAG_HEADER_NAME", { enumerable: true, get: function () { return utils_1.EXCEPTION_TAG_HEADER_NAME; } });
21
40
  Object.defineProperty(exports, "isSuccessfulResponse", { enumerable: true, get: function () { return utils_1.isSuccessfulResponse; } });
41
+ Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
22
42
  Object.defineProperty(exports, "toSearchParams", { enumerable: true, get: function () { return utils_1.toSearchParams; } });
23
43
  Object.defineProperty(exports, "transformUrl", { enumerable: true, get: function () { return utils_1.transformUrl; } });
44
+ Object.defineProperty(exports, "withCompressionHeaders", { enumerable: true, get: function () { return utils_1.withCompressionHeaders; } });
24
45
  Object.defineProperty(exports, "withHttpSettings", { enumerable: true, get: function () { return utils_1.withHttpSettings; } });
46
+ Object.defineProperty(exports, "isCredentialsAuth", { enumerable: true, get: function () { return utils_1.isCredentialsAuth; } });
47
+ Object.defineProperty(exports, "isJWTAuth", { enumerable: true, get: function () { return utils_1.isJWTAuth; } });
48
+ Object.defineProperty(exports, "checkErrorInChunkAtIndex", { enumerable: true, get: function () { return utils_1.checkErrorInChunkAtIndex; } });
25
49
  var logger_2 = require("./logger");
26
50
  Object.defineProperty(exports, "LogWriter", { enumerable: true, get: function () { return logger_2.LogWriter; } });
27
51
  Object.defineProperty(exports, "DefaultLogger", { enumerable: true, get: function () { return logger_2.DefaultLogger; } });
28
52
  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; } });
53
+ Object.defineProperty(exports, "getCurrentStackTrace", { enumerable: true, get: function () { return error_2.getCurrentStackTrace; } });
54
+ Object.defineProperty(exports, "enhanceStackTrace", { enumerable: true, get: function () { return error_2.enhanceStackTrace; } });
33
55
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/client-common/src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAClD,mCAciB;AANf,0GAAA,gBAAgB,OAAA;AASlB,iCAAyC;AAAhC,wGAAA,eAAe,OAAA;AACxB,mCAMiB;AALf,4GAAA,kBAAkB,OAAA;AAapB,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,mCAAyE;AAAhE,mGAAA,SAAS,OAAA;AAAE,uGAAA,aAAa,OAAA;AACjC,iCAAoC;AAA3B,mGAAA,UAAU,OAAA;AAanB,mDAKyB;AAFvB,qHA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OAAA;AACjC,iCAAiE;AAAxD,6GAAA,oBAAoB,OAAA;AAAE,0GAAA,iBAAiB,OAAA"}
package/dist/logger.js CHANGED
@@ -7,7 +7,7 @@ class DefaultLogger {
7
7
  formatMessage({ module, message, level: 'TRACE' }),
8
8
  ];
9
9
  if (args) {
10
- params.push('Arguments:', args);
10
+ params.push('\nArguments:', args);
11
11
  }
12
12
  console.debug(...params);
13
13
  }
@@ -16,7 +16,7 @@ class DefaultLogger {
16
16
  formatMessage({ module, message, level: 'DEBUG' }),
17
17
  ];
18
18
  if (args) {
19
- params.push('Arguments:', args);
19
+ params.push('\nArguments:', args);
20
20
  }
21
21
  console.debug(...params);
22
22
  }
@@ -25,7 +25,7 @@ class DefaultLogger {
25
25
  formatMessage({ module, message, level: 'INFO' }),
26
26
  ];
27
27
  if (args) {
28
- params.push('Arguments:', args);
28
+ params.push('\nArguments:', args);
29
29
  }
30
30
  console.info(...params);
31
31
  }
@@ -34,10 +34,10 @@ class DefaultLogger {
34
34
  formatMessage({ module, message, level: 'WARN' }),
35
35
  ];
36
36
  if (args) {
37
- params.push('Arguments:', args);
37
+ params.push('\nArguments:', args);
38
38
  }
39
39
  if (err) {
40
- params.push('Caused by:', err);
40
+ params.push('\nCaused by:', err);
41
41
  }
42
42
  console.warn(...params);
43
43
  }
@@ -46,9 +46,9 @@ class DefaultLogger {
46
46
  formatMessage({ module, message, level: 'ERROR' }),
47
47
  ];
48
48
  if (args) {
49
- params.push('Arguments:', args);
49
+ params.push('\nArguments:', args);
50
50
  }
51
- params.push('Caused by:', err);
51
+ params.push('\nCaused by:', err);
52
52
  console.error(...params);
53
53
  }
54
54
  }
@@ -128,7 +128,7 @@ var ClickHouseLogLevel;
128
128
  ClickHouseLogLevel[ClickHouseLogLevel["WARN"] = 3] = "WARN";
129
129
  ClickHouseLogLevel[ClickHouseLogLevel["ERROR"] = 4] = "ERROR";
130
130
  ClickHouseLogLevel[ClickHouseLogLevel["OFF"] = 127] = "OFF";
131
- })(ClickHouseLogLevel = exports.ClickHouseLogLevel || (exports.ClickHouseLogLevel = {}));
131
+ })(ClickHouseLogLevel || (exports.ClickHouseLogLevel = ClickHouseLogLevel = {}));
132
132
  function formatMessage({ level, module, message, }) {
133
133
  const ts = new Date().toISOString();
134
134
  return `[${ts}][${level}][@clickhouse/client][${module}] ${message}`;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../packages/client-common/src/logger.ts"],"names":[],"mappings":";;;AAeA,MAAa,aAAa;IACxB,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAa;QACxC,MAAM,MAAM,GAAc;YACxB,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SACnD,CAAA;QACD,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;SAChC;QACD,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAA;IAC1B,CAAC;IAED,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAa;QACxC,MAAM,MAAM,GAAc;YACxB,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SACnD,CAAA;QACD,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;SAChC;QACD,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAA;IAC1B,CAAC;IAED,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAa;QACvC,MAAM,MAAM,GAAc;YACxB,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;SAClD,CAAA;QACD,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;SAChC;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