@clickhouse/client-common 0.4.0 → 0.100.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.
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export { SimpleColumnTypes, parseColumnType, defaultJSONHandling, } from './pars
14
14
  /** For implementation usage only - should not be re-exported */
15
15
  export { formatQuerySettings, formatQueryParams, encodeJSON, isSupportedRawFormat, isStreamableJSONFamily, isNotStreamableJSONFamily, validateStreamFormat, } from './data_formatter';
16
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';
17
+ export { EXCEPTION_TAG_HEADER_NAME, isSuccessfulResponse, sleep, toSearchParams, transformUrl, withCompressionHeaders, withHttpSettings, isCredentialsAuth, isJWTAuth, extractErrorAtTheEndOfChunk, CARET_RETURN, } from './utils';
18
18
  export { LogWriter, DefaultLogger, type LogWriterParams } from './logger';
19
19
  export { getCurrentStackTrace, enhanceStackTrace } from './error';
20
20
  export type { CompressionSettings, Connection, ConnectionParams, ConnInsertResult, ConnExecParams, ConnExecResult, ConnQueryResult, ConnBaseQueryParams, ConnBaseResult, ConnInsertParams, ConnPingResult, ConnCommandResult, ConnOperation, ConnPingParams, } from './connection';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.enhanceStackTrace = exports.getCurrentStackTrace = exports.DefaultLogger = exports.LogWriter = exports.CARET_RETURN = exports.extractErrorAtTheEndOfChunk = 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; } });
@@ -45,7 +45,8 @@ Object.defineProperty(exports, "withCompressionHeaders", { enumerable: true, get
45
45
  Object.defineProperty(exports, "withHttpSettings", { enumerable: true, get: function () { return utils_1.withHttpSettings; } });
46
46
  Object.defineProperty(exports, "isCredentialsAuth", { enumerable: true, get: function () { return utils_1.isCredentialsAuth; } });
47
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; } });
48
+ Object.defineProperty(exports, "extractErrorAtTheEndOfChunk", { enumerable: true, get: function () { return utils_1.extractErrorAtTheEndOfChunk; } });
49
+ Object.defineProperty(exports, "CARET_RETURN", { enumerable: true, get: function () { return utils_1.CARET_RETURN; } });
49
50
  var logger_2 = require("./logger");
50
51
  Object.defineProperty(exports, "LogWriter", { enumerable: true, get: function () { return logger_2.LogWriter; } });
51
52
  Object.defineProperty(exports, "DefaultLogger", { enumerable: true, get: function () { return logger_2.DefaultLogger; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAkD;AAClD,mCAeiB;AATf,0GAAA,gBAAgB,OAAA;AAiClB,mDAA6C;AAApC,4GAAA,UAAU,OAAA;AACnB,iCAAqD;AAA5C,wGAAA,eAAe,OAAA;AAAE,mGAAA,UAAU,OAAA;AACpC,mCAMiB;AALf,4GAAA,kBAAkB,OAAA;AAoBpB,uDAAsE;AAA7D,iHAAA,aAAa,OAAA;AAAE,yGAAA,KAAK,OAAA;AAAE,+GAAA,WAAW,OAAA;AAC1C,uCAImB;AADjB,uGAAA,WAAW,OAAA;AAiBb,iCAIgB;AAHd,0GAAA,iBAAiB,OAAA;AACjB,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AAGrB,gEAAgE;AAChE,mDAQyB;AAPvB,qHAAA,mBAAmB,OAAA;AACnB,mHAAA,iBAAiB,OAAA;AACjB,4GAAA,UAAU,OAAA;AACV,sHAAA,oBAAoB,OAAA;AACpB,wHAAA,sBAAsB,OAAA;AACtB,2HAAA,yBAAyB,OAAA;AACzB,sHAAA,oBAAoB,OAAA;AAEtB,m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,sHAAA,oBAAoB,OAAA;AAEtB,mCAUiB;AAJf,+GAAA,qBAAqB,OAAA;AACrB,4GAAA,kBAAkB,OAAA;AAClB,6GAAA,mBAAmB,OAAA;AACnB,8GAAA,oBAAoB,OAAA;AAEtB,iCAYgB;AAXd,kHAAA,yBAAyB,OAAA;AACzB,6GAAA,oBAAoB,OAAA;AACpB,8FAAA,KAAK,OAAA;AACL,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,mCAAyE;AAAhE,mGAAA,SAAS,OAAA;AAAE,uGAAA,aAAa,OAAA;AACjC,iCAAiE;AAAxD,6GAAA,oBAAoB,OAAA;AAAE,0GAAA,iBAAiB,OAAA"}
@@ -1,3 +1,4 @@
1
+ export declare const CARET_RETURN: 13;
1
2
  /**
2
3
  * After 25.11, a newline error character is preceded by a caret return
3
4
  * this is a strong indication that we have an exception in the stream.
@@ -11,4 +12,4 @@
11
12
  * In this case, the exception length is 5 (including the newline character),
12
13
  * and the exception message is "boom".
13
14
  */
14
- export declare function checkErrorInChunkAtIndex(chunk: Uint8Array, newLineIdx: number, exceptionTag: string | undefined): Error | undefined;
15
+ export declare function extractErrorAtTheEndOfChunk(chunk: Uint8Array, exceptionTag: string): Error;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkErrorInChunkAtIndex = checkErrorInChunkAtIndex;
3
+ exports.CARET_RETURN = void 0;
4
+ exports.extractErrorAtTheEndOfChunk = extractErrorAtTheEndOfChunk;
4
5
  const error_1 = require("../error");
5
6
  const EXCEPTION_MARKER = '__exception__';
6
7
  const NEWLINE = 0x0a;
7
- const CARET_RETURN = 0x0d;
8
+ exports.CARET_RETURN = 0x0d;
8
9
  /**
9
10
  * After 25.11, a newline error character is preceded by a caret return
10
11
  * this is a strong indication that we have an exception in the stream.
@@ -18,36 +19,32 @@ const CARET_RETURN = 0x0d;
18
19
  * In this case, the exception length is 5 (including the newline character),
19
20
  * and the exception message is "boom".
20
21
  */
21
- function checkErrorInChunkAtIndex(chunk, newLineIdx, exceptionTag) {
22
- if (newLineIdx > 0 &&
23
- chunk[newLineIdx - 1] === CARET_RETURN &&
24
- exceptionTag !== undefined) {
25
- try {
26
- const textDecoder = new TextDecoder('utf-8');
27
- const bytesCountAfterErrLenHint = 1 + // space
28
- EXCEPTION_MARKER.length + // __exception__
29
- 2 + // \r\n
30
- exceptionTag.length + // <value taken from the header>
31
- 2; // \r\n
32
- let errMsgLenStartIdx = chunk.length - bytesCountAfterErrLenHint;
33
- if (errMsgLenStartIdx < 1) {
34
- return new Error('there was an error in the stream, but the last chunk is malformed');
35
- }
36
- do {
37
- --errMsgLenStartIdx;
38
- } while (chunk[errMsgLenStartIdx] !== NEWLINE);
39
- const errMsgLen = parseInt(textDecoder.decode(chunk.subarray(errMsgLenStartIdx, -bytesCountAfterErrLenHint)));
40
- if (isNaN(errMsgLen) || errMsgLen <= 0) {
41
- return new Error('there was an error in the stream; failed to parse the message length');
42
- }
43
- const errMsg = textDecoder.decode(chunk.subarray(errMsgLenStartIdx - errMsgLen + 1, // skipping the newline character
44
- errMsgLenStartIdx));
45
- return (0, error_1.parseError)(errMsg);
22
+ function extractErrorAtTheEndOfChunk(chunk, exceptionTag) {
23
+ try {
24
+ const bytesCountAfterErrLenHint = 1 + // space
25
+ EXCEPTION_MARKER.length + // __exception__
26
+ 2 + // \r\n
27
+ exceptionTag.length + // <value taken from the header>
28
+ 2; // \r\n
29
+ let errMsgLenStartIdx = chunk.length - bytesCountAfterErrLenHint;
30
+ if (errMsgLenStartIdx < 1) {
31
+ return new Error('there was an error in the stream, but the last chunk is malformed');
46
32
  }
47
- catch (err) {
48
- // theoretically, it can happen if a proxy cuts the last chunk
49
- return err;
33
+ do {
34
+ --errMsgLenStartIdx;
35
+ } while (chunk[errMsgLenStartIdx] !== NEWLINE);
36
+ const textDecoder = new TextDecoder('utf-8');
37
+ const errMsgLen = parseInt(textDecoder.decode(chunk.subarray(errMsgLenStartIdx, -bytesCountAfterErrLenHint)));
38
+ if (isNaN(errMsgLen) || errMsgLen <= 0) {
39
+ return new Error('there was an error in the stream; failed to parse the message length');
50
40
  }
41
+ const errMsg = textDecoder.decode(chunk.subarray(errMsgLenStartIdx - errMsgLen + 1, // skipping the newline character
42
+ errMsgLenStartIdx));
43
+ return (0, error_1.parseError)(errMsg);
44
+ }
45
+ catch (err) {
46
+ // theoretically, it can happen if a proxy cuts the last chunk
47
+ return err;
51
48
  }
52
49
  }
53
50
  //# sourceMappingURL=stream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":";;AAoBA,4DAwDC;AA5ED,oCAAqC;AAErC,MAAM,gBAAgB,GAAG,eAAe,CAAA;AAExC,MAAM,OAAO,GAAG,IAAa,CAAA;AAC7B,MAAM,YAAY,GAAG,IAAa,CAAA;AAElC;;;;;;;;;;;;GAYG;AACH,SAAgB,wBAAwB,CACtC,KAAiB,EACjB,UAAkB,EAClB,YAAgC;IAEhC,IACE,UAAU,GAAG,CAAC;QACd,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,YAAY;QACtC,YAAY,KAAK,SAAS,EAC1B,CAAC;QACD,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;YAE5C,MAAM,yBAAyB,GAC7B,CAAC,GAAG,QAAQ;gBACZ,gBAAgB,CAAC,MAAM,GAAG,gBAAgB;gBAC1C,CAAC,GAAG,OAAO;gBACX,YAAY,CAAC,MAAM,GAAG,gCAAgC;gBACtD,CAAC,CAAA,CAAC,OAAO;YAEX,IAAI,iBAAiB,GAAG,KAAK,CAAC,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C,GAAG,OAAO;YACX,YAAY,CAAC,MAAM,GAAG,gCAAgC;YACtD,CAAC,CAAA,CAAC,OAAO;QAEX,IAAI,iBAAiB,GAAG,KAAK,CAAC,MAAM,GAAG,yBAAyB,CAAA;QAChE,IAAI,iBAAiB,GAAG,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,KAAK,CACd,mEAAmE,CACpE,CAAA;QACH,CAAC;QAED,GAAG,CAAC;YACF,EAAE,iBAAiB,CAAA;QACrB,CAAC,QAAQ,KAAK,CAAC,iBAAiB,CAAC,KAAK,OAAO,EAAC;QAE9C,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;QAE5C,MAAM,SAAS,GAAG,QAAQ,CACxB,WAAW,CAAC,MAAM,CAChB,KAAK,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,yBAAyB,CAAC,CAC9D,CACF,CAAA;QAED,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;YACvC,OAAO,IAAI,KAAK,CACd,sEAAsE,CACvE,CAAA;QACH,CAAC;QAED,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAC/B,KAAK,CAAC,QAAQ,CACZ,iBAAiB,GAAG,SAAS,GAAG,CAAC,EAAE,iCAAiC;QACpE,iBAAiB,CAClB,CACF,CAAA;QAED,OAAO,IAAA,kBAAU,EAAC,MAAM,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,8DAA8D;QAC9D,OAAO,GAAY,CAAA;IACrB,CAAC;AACH,CAAC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.15.0";
1
+ declare const _default: "0.100.1";
2
2
  export default _default;
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '1.15.0';
3
+ exports.default = '0.100.1';
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,SAAS,CAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@clickhouse/client-common",
3
3
  "description": "Official JS client for ClickHouse DB - common types",
4
4
  "homepage": "https://clickhouse.com",
5
- "version": "0.4.0",
5
+ "version": "0.100.1",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
8
8
  "clickhouse",