@clickhouse/client 1.22.0 → 1.23.0-head.c8dc8d8.1

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 (160) hide show
  1. package/README.md +2 -1
  2. package/dist/client.d.ts +2 -2
  3. package/dist/client.js +3 -3
  4. package/dist/client.js.map +1 -1
  5. package/dist/common/clickhouse_types.d.ts +98 -0
  6. package/dist/common/clickhouse_types.js +30 -0
  7. package/dist/common/clickhouse_types.js.map +1 -0
  8. package/dist/common/client.d.ts +233 -0
  9. package/dist/common/client.js +414 -0
  10. package/dist/common/client.js.map +1 -0
  11. package/dist/common/config.d.ts +234 -0
  12. package/dist/common/config.js +364 -0
  13. package/dist/common/config.js.map +1 -0
  14. package/dist/common/connection.d.ts +124 -0
  15. package/dist/common/connection.js +3 -0
  16. package/dist/common/connection.js.map +1 -0
  17. package/dist/common/data_formatter/format_query_params.d.ts +11 -0
  18. package/dist/common/data_formatter/format_query_params.js +128 -0
  19. package/dist/common/data_formatter/format_query_params.js.map +1 -0
  20. package/dist/common/data_formatter/format_query_settings.d.ts +2 -0
  21. package/dist/common/data_formatter/format_query_settings.js +20 -0
  22. package/dist/common/data_formatter/format_query_settings.js.map +1 -0
  23. package/dist/common/data_formatter/formatter.d.ts +41 -0
  24. package/dist/common/data_formatter/formatter.js +78 -0
  25. package/dist/common/data_formatter/formatter.js.map +1 -0
  26. package/dist/common/data_formatter/index.d.ts +3 -0
  27. package/dist/common/data_formatter/index.js +24 -0
  28. package/dist/common/data_formatter/index.js.map +1 -0
  29. package/dist/common/error/error.d.ts +20 -0
  30. package/dist/common/error/error.js +73 -0
  31. package/dist/common/error/error.js.map +1 -0
  32. package/dist/common/error/index.d.ts +1 -0
  33. package/dist/common/error/index.js +18 -0
  34. package/dist/common/error/index.js.map +1 -0
  35. package/dist/common/index.d.ts +67 -0
  36. package/dist/common/index.js +97 -0
  37. package/dist/common/index.js.map +1 -0
  38. package/dist/common/logger.d.ts +80 -0
  39. package/dist/common/logger.js +154 -0
  40. package/dist/common/logger.js.map +1 -0
  41. package/dist/common/parse/column_types.d.ts +127 -0
  42. package/dist/common/parse/column_types.js +586 -0
  43. package/dist/common/parse/column_types.js.map +1 -0
  44. package/dist/common/parse/index.d.ts +2 -0
  45. package/dist/common/parse/index.js +19 -0
  46. package/dist/common/parse/index.js.map +1 -0
  47. package/dist/common/parse/json_handling.d.ts +19 -0
  48. package/dist/common/parse/json_handling.js +8 -0
  49. package/dist/common/parse/json_handling.js.map +1 -0
  50. package/dist/common/result.d.ts +90 -0
  51. package/dist/common/result.js +3 -0
  52. package/dist/common/result.js.map +1 -0
  53. package/dist/common/settings.d.ts +1990 -0
  54. package/dist/common/settings.js +19 -0
  55. package/dist/common/settings.js.map +1 -0
  56. package/dist/common/tracing.d.ts +146 -0
  57. package/dist/common/tracing.js +76 -0
  58. package/dist/common/tracing.js.map +1 -0
  59. package/dist/common/ts_utils.d.ts +4 -0
  60. package/dist/common/ts_utils.js +3 -0
  61. package/dist/common/ts_utils.js.map +1 -0
  62. package/dist/common/utils/connection.d.ts +21 -0
  63. package/dist/common/utils/connection.js +43 -0
  64. package/dist/common/utils/connection.js.map +1 -0
  65. package/dist/common/utils/index.d.ts +5 -0
  66. package/dist/common/utils/index.js +22 -0
  67. package/dist/common/utils/index.js.map +1 -0
  68. package/dist/common/utils/multipart.d.ts +34 -0
  69. package/dist/common/utils/multipart.js +81 -0
  70. package/dist/common/utils/multipart.js.map +1 -0
  71. package/dist/common/utils/sleep.d.ts +4 -0
  72. package/dist/common/utils/sleep.js +12 -0
  73. package/dist/common/utils/sleep.js.map +1 -0
  74. package/dist/common/utils/stream.d.ts +15 -0
  75. package/dist/common/utils/stream.js +50 -0
  76. package/dist/common/utils/stream.js.map +1 -0
  77. package/dist/common/utils/url.d.ts +20 -0
  78. package/dist/common/utils/url.js +67 -0
  79. package/dist/common/utils/url.js.map +1 -0
  80. package/dist/common/version.d.ts +2 -0
  81. package/dist/common/version.js +4 -0
  82. package/dist/common/version.js.map +1 -0
  83. package/dist/config.d.ts +2 -2
  84. package/dist/config.js +2 -2
  85. package/dist/config.js.map +1 -1
  86. package/dist/connection/compression.d.ts +2 -2
  87. package/dist/connection/compression.js +4 -4
  88. package/dist/connection/compression.js.map +1 -1
  89. package/dist/connection/create_connection.d.ts +1 -1
  90. package/dist/connection/node_base_connection.d.ts +3 -3
  91. package/dist/connection/node_base_connection.js +22 -22
  92. package/dist/connection/node_base_connection.js.map +1 -1
  93. package/dist/connection/node_custom_agent_connection.js +2 -2
  94. package/dist/connection/node_custom_agent_connection.js.map +1 -1
  95. package/dist/connection/node_http_connection.js +2 -2
  96. package/dist/connection/node_http_connection.js.map +1 -1
  97. package/dist/connection/node_https_connection.d.ts +1 -1
  98. package/dist/connection/node_https_connection.js +3 -3
  99. package/dist/connection/node_https_connection.js.map +1 -1
  100. package/dist/connection/socket_pool.d.ts +1 -1
  101. package/dist/connection/socket_pool.js +30 -30
  102. package/dist/connection/socket_pool.js.map +1 -1
  103. package/dist/connection/stream.d.ts +1 -1
  104. package/dist/connection/stream.js +9 -9
  105. package/dist/connection/stream.js.map +1 -1
  106. package/dist/index.d.ts +7 -7
  107. package/dist/index.js +24 -24
  108. package/dist/index.js.map +1 -1
  109. package/dist/result_set.d.ts +1 -1
  110. package/dist/result_set.js +10 -10
  111. package/dist/result_set.js.map +1 -1
  112. package/dist/utils/encoder.d.ts +1 -1
  113. package/dist/utils/encoder.js +5 -5
  114. package/dist/utils/encoder.js.map +1 -1
  115. package/dist/version.d.ts +1 -1
  116. package/dist/version.js +1 -1
  117. package/dist/version.js.map +1 -1
  118. package/package.json +7 -5
  119. package/skills/clickhouse-js-node-rowbinary-parser/EXAMPLES.md +48 -0
  120. package/skills/clickhouse-js-node-rowbinary-parser/README.md +248 -0
  121. package/skills/clickhouse-js-node-rowbinary-parser/SKILL.md +190 -0
  122. package/skills/clickhouse-js-node-rowbinary-parser/case-studies/iot-rowbinary-vs-json.md +83 -0
  123. package/skills/clickhouse-js-node-rowbinary-parser/case-studies/ledger-rowbinary-vs-json.md +103 -0
  124. package/skills/clickhouse-js-node-rowbinary-parser/case-studies/logs-json-wins.md +86 -0
  125. package/skills/clickhouse-js-node-rowbinary-parser/case-studies/wasm-vs-js.md +172 -0
  126. package/skills/clickhouse-js-node-rowbinary-parser/src/aggregateFunction.ts +34 -0
  127. package/skills/clickhouse-js-node-rowbinary-parser/src/bool.ts +10 -0
  128. package/skills/clickhouse-js-node-rowbinary-parser/src/columnar.ts +125 -0
  129. package/skills/clickhouse-js-node-rowbinary-parser/src/composite.ts +181 -0
  130. package/skills/clickhouse-js-node-rowbinary-parser/src/core.ts +77 -0
  131. package/skills/clickhouse-js-node-rowbinary-parser/src/datetime.ts +113 -0
  132. package/skills/clickhouse-js-node-rowbinary-parser/src/decimals.ts +57 -0
  133. package/skills/clickhouse-js-node-rowbinary-parser/src/dynamic.ts +328 -0
  134. package/skills/clickhouse-js-node-rowbinary-parser/src/enums.ts +28 -0
  135. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/carts.ts +71 -0
  136. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/events.ts +51 -0
  137. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/iot.ts +158 -0
  138. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/ledger.ts +98 -0
  139. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/logs.ts +73 -0
  140. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/observability.ts +142 -0
  141. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/orders.ts +65 -0
  142. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/profiles.ts +60 -0
  143. package/skills/clickhouse-js-node-rowbinary-parser/src/examples/telemetry.ts +102 -0
  144. package/skills/clickhouse-js-node-rowbinary-parser/src/floats.ts +32 -0
  145. package/skills/clickhouse-js-node-rowbinary-parser/src/geo.ts +109 -0
  146. package/skills/clickhouse-js-node-rowbinary-parser/src/integers.ts +95 -0
  147. package/skills/clickhouse-js-node-rowbinary-parser/src/interval.ts +54 -0
  148. package/skills/clickhouse-js-node-rowbinary-parser/src/ip.ts +93 -0
  149. package/skills/clickhouse-js-node-rowbinary-parser/src/json.ts +33 -0
  150. package/skills/clickhouse-js-node-rowbinary-parser/src/lowCardinality.ts +18 -0
  151. package/skills/clickhouse-js-node-rowbinary-parser/src/nested.ts +23 -0
  152. package/skills/clickhouse-js-node-rowbinary-parser/src/nothing.ts +29 -0
  153. package/skills/clickhouse-js-node-rowbinary-parser/src/reader.ts +51 -0
  154. package/skills/clickhouse-js-node-rowbinary-parser/src/rows.ts +58 -0
  155. package/skills/clickhouse-js-node-rowbinary-parser/src/simpleAggregateFunction.ts +20 -0
  156. package/skills/clickhouse-js-node-rowbinary-parser/src/stream.ts +276 -0
  157. package/skills/clickhouse-js-node-rowbinary-parser/src/strings.ts +55 -0
  158. package/skills/clickhouse-js-node-rowbinary-parser/src/time.ts +61 -0
  159. package/skills/clickhouse-js-node-rowbinary-parser/src/uuid.ts +153 -0
  160. package/skills/clickhouse-js-node-rowbinary-parser/src/varint.ts +70 -0
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatQuerySettings = formatQuerySettings;
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
+ //# sourceMappingURL=format_query_settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format_query_settings.js","sourceRoot":"","sources":["../../../src/common/data_formatter/format_query_settings.ts"],"names":[],"mappings":";;AAEA,kDAaC;AAfD,0CAA0C;AAE1C,SAAgB,mBAAmB,CACjC,KAA8C;IAE9C,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACzD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,mEAAmE;IACnE,uDAAuD;IACvD,4CAA4C;IAC5C,IAAI,KAAK,YAAY,sBAAW,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,IAAI,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1,41 @@
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 */
28
+ export type DataFormat = JSONDataFormat | RawDataFormat;
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;
33
+ export declare function isSupportedRawFormat(dataFormat: DataFormat): boolean;
34
+ export declare function validateStreamFormat(format: any): format is StreamableDataFormat;
35
+ /**
36
+ * Encodes a single row of values into a string in a JSON format acceptable by ClickHouse.
37
+ * @param value a single value to encode.
38
+ * @param format One of the supported JSON formats: https://clickhouse.com/docs/en/interfaces/formats/
39
+ * @returns string
40
+ */
41
+ export declare function encodeJSON(value: any, format: DataFormat, stringifyFn: JSONHandling["stringify"]): string;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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 = [
10
+ "JSONEachRow",
11
+ "JSONStringsEachRow",
12
+ "JSONCompactEachRow",
13
+ "JSONCompactStringsEachRow",
14
+ "JSONCompactEachRowWithNames",
15
+ "JSONCompactEachRowWithNamesAndTypes",
16
+ "JSONCompactStringsEachRowWithNames",
17
+ "JSONCompactStringsEachRowWithNamesAndTypes",
18
+ "JSONEachRowWithProgress",
19
+ ];
20
+ exports.RecordsJSONFormats = ["JSONObjectEachRow"];
21
+ exports.SingleDocumentJSONFormats = [
22
+ "JSON",
23
+ "JSONStrings",
24
+ "JSONCompact",
25
+ "JSONCompactStrings",
26
+ "JSONColumnsWithMetadata",
27
+ ];
28
+ exports.SupportedJSONFormats = [
29
+ ...exports.RecordsJSONFormats,
30
+ ...exports.SingleDocumentJSONFormats,
31
+ ...exports.StreamableJSONFormats,
32
+ ];
33
+ exports.SupportedRawFormats = [
34
+ "CSV",
35
+ "CSVWithNames",
36
+ "CSVWithNamesAndTypes",
37
+ "TabSeparated",
38
+ "TabSeparatedRaw",
39
+ "TabSeparatedWithNames",
40
+ "TabSeparatedWithNamesAndTypes",
41
+ "CustomSeparated",
42
+ "CustomSeparatedWithNames",
43
+ "CustomSeparatedWithNamesAndTypes",
44
+ "Parquet",
45
+ ];
46
+ exports.StreamableFormats = [
47
+ ...exports.StreamableJSONFormats,
48
+ ...exports.SupportedRawFormats,
49
+ ];
50
+ function isNotStreamableJSONFamily(format) {
51
+ return (exports.SingleDocumentJSONFormats.includes(format) ||
52
+ exports.RecordsJSONFormats.includes(format));
53
+ }
54
+ function isStreamableJSONFamily(format) {
55
+ return exports.StreamableJSONFormats.includes(format);
56
+ }
57
+ function isSupportedRawFormat(dataFormat) {
58
+ return exports.SupportedRawFormats.includes(dataFormat);
59
+ }
60
+ function validateStreamFormat(format) {
61
+ if (!exports.StreamableFormats.includes(format)) {
62
+ throw new Error(`${format} format is not streamable. Streamable formats: ${exports.StreamableFormats.join(",")}`);
63
+ }
64
+ return true;
65
+ }
66
+ /**
67
+ * Encodes a single row of values into a string in a JSON format acceptable by ClickHouse.
68
+ * @param value a single value to encode.
69
+ * @param format One of the supported JSON formats: https://clickhouse.com/docs/en/interfaces/formats/
70
+ * @returns string
71
+ */
72
+ function encodeJSON(value, format, stringifyFn) {
73
+ if (exports.SupportedJSONFormats.includes(format)) {
74
+ return stringifyFn(value) + "\n";
75
+ }
76
+ throw new Error(`The client does not support JSON encoding in [${format}] format.`);
77
+ }
78
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"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,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,kDAAkD,yBAAiB,CAAC,IAAI,CAC/E,GAAG,CACJ,EAAE,CACJ,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;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,CAAC;IACnC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,iDAAiD,MAAM,WAAW,CACnE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./formatter";
2
+ export { TupleParam, formatQueryParams } from "./format_query_params";
3
+ export { formatQuerySettings } from "./format_query_settings";
@@ -0,0 +1,24 @@
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 = exports.TupleParam = void 0;
18
+ __exportStar(require("./formatter"), exports);
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; } });
21
+ Object.defineProperty(exports, "formatQueryParams", { enumerable: true, get: function () { return format_query_params_1.formatQueryParams; } });
22
+ var format_query_settings_1 = require("./format_query_settings");
23
+ Object.defineProperty(exports, "formatQuerySettings", { enumerable: true, get: function () { return format_query_settings_1.formatQuerySettings; } });
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/data_formatter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6DAAsE;AAA7D,iHAAA,UAAU,OAAA;AAAE,wHAAA,iBAAiB,OAAA;AACtC,iEAA8D;AAArD,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,73 @@
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
+ // In cluster mode, the server wraps the original exception, repeating the
8
+ // `Code`/`Exception`/`(TYPE)` markers, e.g.:
9
+ // Code: 57. DB::Exception: There was an error on [host:9000]: Code: 57. DB::Exception: <message>. (TABLE_ALREADY_EXISTS) (version ...). (TABLE_ALREADY_EXISTS) (version ...)
10
+ // The leading `.*Exception: ` is greedy so we anchor on the innermost (last)
11
+ // exception, while `(?<message>.+?)` is lazy so the message stops at the first
12
+ // `(TYPE)` marker rather than swallowing the repeated suffixes. The type
13
+ // lookahead requires at least three consecutive uppercase letters so that
14
+ // parenthesised groups like `(2)` or `(official build)` are not mistaken for it.
15
+ //
16
+ // NOTE: In normal usage, the string fed to `parseError` comes from ClickHouse,
17
+ // but it may still include user-controlled fragments (e.g. parts of a query) or
18
+ // even non-ClickHouse payloads (proxy/HTML errors) when parsing failed requests.
19
+ // Keep this regex simple to avoid excessive backtracking on large/unexpected input.
20
+ // (If this ever becomes a concern, consider a non-regex parser or input length limits.)
21
+ const errorRe = /(Code|Error): (?<code>\d+).*Exception: (?<message>.+?)\((?<type>(?=[A-Z0-9_]*[A-Z]{3})[A-Z0-9_]+)\)/s;
22
+ /** An error that is thrown by the ClickHouse server. */
23
+ class ClickHouseError extends Error {
24
+ code;
25
+ type;
26
+ constructor({ message, code, type }) {
27
+ super(message);
28
+ this.code = code;
29
+ this.type = type;
30
+ // Set the prototype explicitly, see:
31
+ // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
32
+ Object.setPrototypeOf(this, ClickHouseError.prototype);
33
+ }
34
+ }
35
+ exports.ClickHouseError = ClickHouseError;
36
+ function parseError(input) {
37
+ const inputIsError = input instanceof Error;
38
+ const message = inputIsError ? input.message : input;
39
+ const match = message.match(errorRe);
40
+ const groups = match?.groups;
41
+ if (groups) {
42
+ return new ClickHouseError(groups);
43
+ }
44
+ else {
45
+ return inputIsError ? input : new Error(input);
46
+ }
47
+ }
48
+ /** Captures the current stack trace from the sync context before going async.
49
+ * It is necessary since the majority of the stack trace is lost when an async callback is called. */
50
+ function getCurrentStackTrace() {
51
+ const stack = new Error().stack;
52
+ if (!stack)
53
+ return "";
54
+ // Skip the first three lines of the stack trace, containing useless information
55
+ // - Text `Error`
56
+ // - Info about this function call
57
+ // - Info about the originator of this function call, e.g., `request`
58
+ // Additionally, the original stack trace is, in fact, reversed.
59
+ return stack.split("\n").slice(3).reverse().join("\n");
60
+ }
61
+ /** Having the stack trace produced by the {@link getCurrentStackTrace} function,
62
+ * add it to an arbitrary error stack trace. No-op if there is no additional stack trace to add.
63
+ * It could happen if this feature was disabled due to its performance overhead. */
64
+ function enhanceStackTrace(err, stackTrace) {
65
+ if (err.stack && stackTrace) {
66
+ const firstNewlineIndex = err.stack.indexOf("\n");
67
+ const firstLine = err.stack.substring(0, firstNewlineIndex);
68
+ const errStack = err.stack.substring(firstNewlineIndex + 1);
69
+ err.stack = `${firstLine}\n${stackTrace}\n${errStack}`;
70
+ }
71
+ return err;
72
+ }
73
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/common/error/error.ts"],"names":[],"mappings":";;;AAsCA,gCAUC;AAID,oDAUC;AAKD,8CAWC;AA9ED,0EAA0E;AAC1E,6CAA6C;AAC7C,+KAA+K;AAC/K,6EAA6E;AAC7E,+EAA+E;AAC/E,yEAAyE;AACzE,0EAA0E;AAC1E,iFAAiF;AACjF,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,iFAAiF;AACjF,oFAAoF;AACpF,wFAAwF;AACxF,MAAM,OAAO,GACX,sGAAsG,CAAC;AAQzG,wDAAwD;AACxD,MAAa,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAS;IACb,IAAI,CAAqB;IAClC,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAyB;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,qCAAqC;QACrC,gIAAgI;QAChI,MA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AAE,iBAAiB,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC;QAC5D,GAAG,CAAC,KAAK,GAAG,GAAG,SAAS,KAAK,UAAU,KAAK,QAAQ,EAAE,CAAC;IACzD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./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("./error"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @deprecated The `@clickhouse/client-common` package is deprecated. It is no longer used by
3
+ * `@clickhouse/client` or `@clickhouse/client-web`; the shared code is bundled into each client
4
+ * package instead. Import everything from `@clickhouse/client` (Node.js) or
5
+ * `@clickhouse/client-web` (Web) instead.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /** Should be re-exported by the implementation */
10
+ export { type BaseQueryParams, type QueryParams, type QueryResult, type ExecParams, type InsertParams,
11
+ /** @deprecated Import `ClickHouseClient` from `@clickhouse/client` instead. In Web projects, use `import type { ClickHouseClient } from '@clickhouse/client-web'`. Importing it from `@clickhouse/client-common` is deprecated. */
12
+ ClickHouseClient, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type PingResult, type PingParams, type PingParamsWithSelectQuery, type PingParamsWithEndpoint, } from "./client";
13
+ export { type BaseClickHouseClientConfigOptions } from "./config";
14
+ export type { Row, RowOrProgress, BaseResultSet, ResultJSONType, RowJSONType, ResultStream, } from "./result";
15
+ export type { DataFormat, RawDataFormat, JSONDataFormat, StreamableDataFormat, StreamableJSONDataFormat, SingleDocumentJSONFormat, } from "./data_formatter";
16
+ export {
17
+ /** @deprecated Import `SupportedJSONFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
18
+ SupportedJSONFormats,
19
+ /** @deprecated Import `SupportedRawFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
20
+ SupportedRawFormats,
21
+ /** @deprecated Import `StreamableFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
22
+ StreamableFormats,
23
+ /** @deprecated Import `StreamableJSONFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
24
+ StreamableJSONFormats,
25
+ /** @deprecated Import `SingleDocumentJSONFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
26
+ SingleDocumentJSONFormats,
27
+ /** @deprecated Import `RecordsJSONFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
28
+ RecordsJSONFormats,
29
+ /** @deprecated Import `TupleParam` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
30
+ TupleParam, } from "./data_formatter";
31
+ export {
32
+ /** @deprecated Import `ClickHouseError` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
33
+ ClickHouseError,
34
+ /** @deprecated Import `parseError` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
35
+ parseError, } from "./error";
36
+ export {
37
+ /** @deprecated Import `ClickHouseLogLevel` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
38
+ ClickHouseLogLevel, type ErrorLogParams, type WarnLogParams, type Logger, type LogParams, } from "./logger";
39
+ export type { ClickHouseSummary, InputJSON, InputJSONObjectEachRow, ResponseJSON, ResponseHeaders, WithClickHouseSummary, WithResponseHeaders, ProgressRow, InsertValues, ClickHouseAuth, ClickHouseJWTAuth, ClickHouseCredentialsAuth, } from "./clickhouse_types";
40
+ export {
41
+ /** @deprecated Import `isProgressRow` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
42
+ isProgressRow,
43
+ /** @deprecated Import `isRow` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
44
+ isRow,
45
+ /** @deprecated Import `isException` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
46
+ isException, } from "./clickhouse_types";
47
+ export { type ClickHouseSettings, type MergeTreeSettings,
48
+ /** @deprecated Import `SettingsMap` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
49
+ SettingsMap, } from "./settings";
50
+ export type { SimpleColumnType, ParsedColumnSimple, ParsedColumnEnum, ParsedColumnFixedString, ParsedColumnNullable, ParsedColumnDecimal, ParsedColumnDateTime, ParsedColumnDateTime64, ParsedColumnArray, ParsedColumnTuple, ParsedColumnMap, ParsedColumnType, JSONHandling, } from "./parse";
51
+ export {
52
+ /** @deprecated Import `SimpleColumnTypes` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
53
+ SimpleColumnTypes,
54
+ /** @deprecated Import `parseColumnType` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
55
+ parseColumnType,
56
+ /** @deprecated Import `defaultJSONHandling` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
57
+ defaultJSONHandling, } from "./parse";
58
+ export { type ClickHouseTracer, type ClickHouseSpan, type ClickHouseSpanOptions, type ClickHouseSpanAttributes, type ClickHouseSpanStatus, type ClickHouseSpanName, ClickHouseSpanStatusCode, ClickHouseSpanKind, ClickHouseSpanNames, recordSpanError, } from "./tracing";
59
+ /** For implementation usage only - should not be re-exported */
60
+ export { formatQuerySettings, formatQueryParams, encodeJSON, isSupportedRawFormat, isStreamableJSONFamily, isNotStreamableJSONFamily, validateStreamFormat, } from "./data_formatter";
61
+ export { type ValuesEncoder, type MakeResultSet, type MakeConnection, type HandleImplSpecificURLParams, type ImplementationDetails, booleanConfigURLValue, enumConfigURLValue, getConnectionParams, numberConfigURLValue, } from "./config";
62
+ export { EXCEPTION_TAG_HEADER_NAME, isSuccessfulResponse, sleep, buildMultipartBody, MAX_URL_BIND_PARAM_LENGTH, serializeQueryParamsForUrl, toSearchParams, transformUrl, withCompressionHeaders, withHttpSettings, isCredentialsAuth, isJWTAuth, extractErrorAtTheEndOfChunk, CARET_RETURN, } from "./utils";
63
+ export { LogWriter, DefaultLogger, type LogWriterParams } from "./logger";
64
+ export { getCurrentStackTrace, enhanceStackTrace } from "./error";
65
+ export type { CompressionSettings, CompressionMethod, RequestCompression, ResponseCompression, Connection, ConnectionParams, ConnInsertResult, ConnExecParams, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, ConnPingResult, ConnCommandResult, ConnOperation, ConnPingParams, } from "./connection";
66
+ export type { QueryParamsWithFormat } from "./client";
67
+ export type { IsSame } from "./ts_utils";
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /**
3
+ * @deprecated The `@clickhouse/client-common` package is deprecated. It is no longer used by
4
+ * `@clickhouse/client` or `@clickhouse/client-web`; the shared code is bundled into each client
5
+ * package instead. Import everything from `@clickhouse/client` (Node.js) or
6
+ * `@clickhouse/client-web` (Web) instead.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.getCurrentStackTrace = exports.DefaultLogger = exports.LogWriter = exports.CARET_RETURN = exports.extractErrorAtTheEndOfChunk = exports.isJWTAuth = exports.isCredentialsAuth = exports.withHttpSettings = exports.withCompressionHeaders = exports.transformUrl = exports.toSearchParams = exports.serializeQueryParamsForUrl = exports.MAX_URL_BIND_PARAM_LENGTH = exports.buildMultipartBody = 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.recordSpanError = exports.ClickHouseSpanNames = exports.ClickHouseSpanKind = exports.ClickHouseSpanStatusCode = exports.defaultJSONHandling = exports.parseColumnType = exports.SimpleColumnTypes = exports.SettingsMap = exports.isException = exports.isRow = exports.isProgressRow = exports.ClickHouseLogLevel = exports.parseError = exports.ClickHouseError = exports.TupleParam = exports.RecordsJSONFormats = exports.SingleDocumentJSONFormats = exports.StreamableJSONFormats = exports.StreamableFormats = exports.SupportedRawFormats = exports.SupportedJSONFormats = exports.ClickHouseClient = void 0;
12
+ exports.enhanceStackTrace = void 0;
13
+ /** Should be re-exported by the implementation */
14
+ var client_1 = require("./client");
15
+ /** @deprecated Import `ClickHouseClient` from `@clickhouse/client` instead. In Web projects, use `import type { ClickHouseClient } from '@clickhouse/client-web'`. Importing it from `@clickhouse/client-common` is deprecated. */
16
+ Object.defineProperty(exports, "ClickHouseClient", { enumerable: true, get: function () { return client_1.ClickHouseClient; } });
17
+ var data_formatter_1 = require("./data_formatter");
18
+ /** @deprecated Import `SupportedJSONFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
19
+ Object.defineProperty(exports, "SupportedJSONFormats", { enumerable: true, get: function () { return data_formatter_1.SupportedJSONFormats; } });
20
+ /** @deprecated Import `SupportedRawFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
21
+ Object.defineProperty(exports, "SupportedRawFormats", { enumerable: true, get: function () { return data_formatter_1.SupportedRawFormats; } });
22
+ /** @deprecated Import `StreamableFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
23
+ Object.defineProperty(exports, "StreamableFormats", { enumerable: true, get: function () { return data_formatter_1.StreamableFormats; } });
24
+ /** @deprecated Import `StreamableJSONFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
25
+ Object.defineProperty(exports, "StreamableJSONFormats", { enumerable: true, get: function () { return data_formatter_1.StreamableJSONFormats; } });
26
+ /** @deprecated Import `SingleDocumentJSONFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
27
+ Object.defineProperty(exports, "SingleDocumentJSONFormats", { enumerable: true, get: function () { return data_formatter_1.SingleDocumentJSONFormats; } });
28
+ /** @deprecated Import `RecordsJSONFormats` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
29
+ Object.defineProperty(exports, "RecordsJSONFormats", { enumerable: true, get: function () { return data_formatter_1.RecordsJSONFormats; } });
30
+ /** @deprecated Import `TupleParam` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
31
+ Object.defineProperty(exports, "TupleParam", { enumerable: true, get: function () { return data_formatter_1.TupleParam; } });
32
+ var error_1 = require("./error");
33
+ /** @deprecated Import `ClickHouseError` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
34
+ Object.defineProperty(exports, "ClickHouseError", { enumerable: true, get: function () { return error_1.ClickHouseError; } });
35
+ /** @deprecated Import `parseError` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
36
+ Object.defineProperty(exports, "parseError", { enumerable: true, get: function () { return error_1.parseError; } });
37
+ var logger_1 = require("./logger");
38
+ /** @deprecated Import `ClickHouseLogLevel` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
39
+ Object.defineProperty(exports, "ClickHouseLogLevel", { enumerable: true, get: function () { return logger_1.ClickHouseLogLevel; } });
40
+ var clickhouse_types_1 = require("./clickhouse_types");
41
+ /** @deprecated Import `isProgressRow` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
42
+ Object.defineProperty(exports, "isProgressRow", { enumerable: true, get: function () { return clickhouse_types_1.isProgressRow; } });
43
+ /** @deprecated Import `isRow` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
44
+ Object.defineProperty(exports, "isRow", { enumerable: true, get: function () { return clickhouse_types_1.isRow; } });
45
+ /** @deprecated Import `isException` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
46
+ Object.defineProperty(exports, "isException", { enumerable: true, get: function () { return clickhouse_types_1.isException; } });
47
+ var settings_1 = require("./settings");
48
+ /** @deprecated Import `SettingsMap` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
49
+ Object.defineProperty(exports, "SettingsMap", { enumerable: true, get: function () { return settings_1.SettingsMap; } });
50
+ var parse_1 = require("./parse");
51
+ /** @deprecated Import `SimpleColumnTypes` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
52
+ Object.defineProperty(exports, "SimpleColumnTypes", { enumerable: true, get: function () { return parse_1.SimpleColumnTypes; } });
53
+ /** @deprecated Import `parseColumnType` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
54
+ Object.defineProperty(exports, "parseColumnType", { enumerable: true, get: function () { return parse_1.parseColumnType; } });
55
+ /** @deprecated Import `defaultJSONHandling` from `@clickhouse/client` (Node.js) or `@clickhouse/client-web` (Web) instead. Importing it from `@clickhouse/client-common` is deprecated. */
56
+ Object.defineProperty(exports, "defaultJSONHandling", { enumerable: true, get: function () { return parse_1.defaultJSONHandling; } });
57
+ var tracing_1 = require("./tracing");
58
+ Object.defineProperty(exports, "ClickHouseSpanStatusCode", { enumerable: true, get: function () { return tracing_1.ClickHouseSpanStatusCode; } });
59
+ Object.defineProperty(exports, "ClickHouseSpanKind", { enumerable: true, get: function () { return tracing_1.ClickHouseSpanKind; } });
60
+ Object.defineProperty(exports, "ClickHouseSpanNames", { enumerable: true, get: function () { return tracing_1.ClickHouseSpanNames; } });
61
+ Object.defineProperty(exports, "recordSpanError", { enumerable: true, get: function () { return tracing_1.recordSpanError; } });
62
+ /** For implementation usage only - should not be re-exported */
63
+ var data_formatter_2 = require("./data_formatter");
64
+ Object.defineProperty(exports, "formatQuerySettings", { enumerable: true, get: function () { return data_formatter_2.formatQuerySettings; } });
65
+ Object.defineProperty(exports, "formatQueryParams", { enumerable: true, get: function () { return data_formatter_2.formatQueryParams; } });
66
+ Object.defineProperty(exports, "encodeJSON", { enumerable: true, get: function () { return data_formatter_2.encodeJSON; } });
67
+ Object.defineProperty(exports, "isSupportedRawFormat", { enumerable: true, get: function () { return data_formatter_2.isSupportedRawFormat; } });
68
+ Object.defineProperty(exports, "isStreamableJSONFamily", { enumerable: true, get: function () { return data_formatter_2.isStreamableJSONFamily; } });
69
+ Object.defineProperty(exports, "isNotStreamableJSONFamily", { enumerable: true, get: function () { return data_formatter_2.isNotStreamableJSONFamily; } });
70
+ Object.defineProperty(exports, "validateStreamFormat", { enumerable: true, get: function () { return data_formatter_2.validateStreamFormat; } });
71
+ var config_1 = require("./config");
72
+ Object.defineProperty(exports, "booleanConfigURLValue", { enumerable: true, get: function () { return config_1.booleanConfigURLValue; } });
73
+ Object.defineProperty(exports, "enumConfigURLValue", { enumerable: true, get: function () { return config_1.enumConfigURLValue; } });
74
+ Object.defineProperty(exports, "getConnectionParams", { enumerable: true, get: function () { return config_1.getConnectionParams; } });
75
+ Object.defineProperty(exports, "numberConfigURLValue", { enumerable: true, get: function () { return config_1.numberConfigURLValue; } });
76
+ var utils_1 = require("./utils");
77
+ Object.defineProperty(exports, "EXCEPTION_TAG_HEADER_NAME", { enumerable: true, get: function () { return utils_1.EXCEPTION_TAG_HEADER_NAME; } });
78
+ Object.defineProperty(exports, "isSuccessfulResponse", { enumerable: true, get: function () { return utils_1.isSuccessfulResponse; } });
79
+ Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
80
+ Object.defineProperty(exports, "buildMultipartBody", { enumerable: true, get: function () { return utils_1.buildMultipartBody; } });
81
+ Object.defineProperty(exports, "MAX_URL_BIND_PARAM_LENGTH", { enumerable: true, get: function () { return utils_1.MAX_URL_BIND_PARAM_LENGTH; } });
82
+ Object.defineProperty(exports, "serializeQueryParamsForUrl", { enumerable: true, get: function () { return utils_1.serializeQueryParamsForUrl; } });
83
+ Object.defineProperty(exports, "toSearchParams", { enumerable: true, get: function () { return utils_1.toSearchParams; } });
84
+ Object.defineProperty(exports, "transformUrl", { enumerable: true, get: function () { return utils_1.transformUrl; } });
85
+ Object.defineProperty(exports, "withCompressionHeaders", { enumerable: true, get: function () { return utils_1.withCompressionHeaders; } });
86
+ Object.defineProperty(exports, "withHttpSettings", { enumerable: true, get: function () { return utils_1.withHttpSettings; } });
87
+ Object.defineProperty(exports, "isCredentialsAuth", { enumerable: true, get: function () { return utils_1.isCredentialsAuth; } });
88
+ Object.defineProperty(exports, "isJWTAuth", { enumerable: true, get: function () { return utils_1.isJWTAuth; } });
89
+ Object.defineProperty(exports, "extractErrorAtTheEndOfChunk", { enumerable: true, get: function () { return utils_1.extractErrorAtTheEndOfChunk; } });
90
+ Object.defineProperty(exports, "CARET_RETURN", { enumerable: true, get: function () { return utils_1.CARET_RETURN; } });
91
+ var logger_2 = require("./logger");
92
+ Object.defineProperty(exports, "LogWriter", { enumerable: true, get: function () { return logger_2.LogWriter; } });
93
+ Object.defineProperty(exports, "DefaultLogger", { enumerable: true, get: function () { return logger_2.DefaultLogger; } });
94
+ var error_2 = require("./error");
95
+ Object.defineProperty(exports, "getCurrentStackTrace", { enumerable: true, get: function () { return error_2.getCurrentStackTrace; } });
96
+ Object.defineProperty(exports, "enhanceStackTrace", { enumerable: true, get: function () { return error_2.enhanceStackTrace; } });
97
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;AAEH,kDAAkD;AAClD,mCAgBkB;AAVhB,mOAAmO;AACnO,0GAAA,gBAAgB,OAAA;AA2BlB,mDAe0B;AAdxB,4LAA4L;AAC5L,sHAAA,o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CAeiB;AAdf,kHAAA,yBAAyB,OAAA;AACzB,6GAAA,oBAAoB,OAAA;AACpB,8FAAA,KAAK,OAAA;AACL,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,mHAAA,0BAA0B,OAAA;AAC1B,uGAAA,cAAc,OAAA;AACd,qGAAA,YAAY,OAAA;AACZ,+GAAA,sBAAsB,OAAA;AACtB,yGAAA,gBAAgB,OAAA;AAChB,0GAAA,iBAAiB,OAAA;AACjB,kGAAA,SAAS,OAAA;AACT,oHAAA,2BAA2B,OAAA;AAC3B,qGAAA,YAAY,OAAA;AAEd,mCAA0E;AAAjE,mGAAA,SAAS,OAAA;AAAE,uGAAA,aAAa,OAAA;AACjC,iCAAkE;AAAzD,6GAAA,oBAAoB,OAAA;AAAE,0GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,80 @@
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 type WarnLogParams = LogParams & {
10
+ err?: Error;
11
+ };
12
+ export interface Logger {
13
+ trace(params: LogParams): void;
14
+ debug(params: LogParams): void;
15
+ info(params: LogParams): void;
16
+ warn(params: WarnLogParams): void;
17
+ error(params: ErrorLogParams): void;
18
+ }
19
+ export declare class DefaultLogger implements Logger {
20
+ trace({ module, message, args }: LogParams): void;
21
+ debug({ module, message, args }: LogParams): void;
22
+ info({ module, message, args }: LogParams): void;
23
+ warn({ module, message, args, err }: WarnLogParams): void;
24
+ error({ module, message, args, err }: ErrorLogParams): void;
25
+ }
26
+ export type LogWriterParams<Method extends keyof Logger> = Omit<Parameters<Logger[Method]>[0], "module"> & {
27
+ module?: string;
28
+ };
29
+ export declare class LogWriter {
30
+ private readonly logger;
31
+ private readonly module;
32
+ private readonly logLevel;
33
+ constructor(logger: Logger, module: string, logLevel: ClickHouseLogLevel);
34
+ trace(params: LogWriterParams<"trace">): void;
35
+ debug(params: LogWriterParams<"debug">): void;
36
+ info(params: LogWriterParams<"info">): void;
37
+ warn(params: LogWriterParams<"warn">): void;
38
+ error(params: LogWriterParams<"error">): void;
39
+ }
40
+ /**
41
+ * Mimics the runtime shape of a numeric TypeScript `enum`: an object with both
42
+ * forward (`Name -> number`) and reverse (`number -> Name`) mappings. This
43
+ * preserves backwards compatibility with the previous `enum ClickHouseLogLevel`
44
+ * — both `ClickHouseLogLevel.TRACE` (returns `0`) and `ClickHouseLogLevel[0]`
45
+ * (returns `'TRACE'`) continue to work — while staying compatible with the
46
+ * `--erasableSyntaxOnly` TypeScript option (no TS `enum` declaration).
47
+ */
48
+ export declare const ClickHouseLogLevel: {
49
+ /**
50
+ * A fine-grained debugging event. Might produce a lot of logs, so use with caution.
51
+ */
52
+ readonly TRACE: 0;
53
+ /**
54
+ * A debugging event. Useful for debugging, but generally not needed in production. Includes technical values that might require redacting.
55
+ */
56
+ readonly DEBUG: 1;
57
+ /**
58
+ * An informational event. Indicates that an event happened.
59
+ */
60
+ readonly INFO: 2;
61
+ /**
62
+ * A warning event. Not an error, but is likely more important than an informational event. Addressing should help prevent potential issues.
63
+ */
64
+ readonly WARN: 3;
65
+ /**
66
+ * An error event. Something went wrong.
67
+ */
68
+ readonly ERROR: 4;
69
+ /**
70
+ * Logging is turned off.
71
+ */
72
+ readonly OFF: 127;
73
+ readonly 0: "TRACE";
74
+ readonly 1: "DEBUG";
75
+ readonly 2: "INFO";
76
+ readonly 3: "WARN";
77
+ readonly 4: "ERROR";
78
+ readonly 127: "OFF";
79
+ };
80
+ export type ClickHouseLogLevel = 0 | 1 | 2 | 3 | 4 | 127;