@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 +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/stream.d.ts +2 -1
- package/dist/utils/stream.js +27 -30
- package/dist/utils/stream.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
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,
|
|
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.
|
|
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, "
|
|
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,mCAUiB;AAJf,+GAAA,qBAAqB,OAAA;AACrB,4GAAA,kBAAkB,OAAA;AAClB,6GAAA,mBAAmB,OAAA;AACnB,8GAAA,oBAAoB,OAAA;AAEtB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceR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AAAE,0GAAA,iBAAiB,OAAA"}
|
package/dist/utils/stream.d.ts
CHANGED
|
@@ -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
|
|
15
|
+
export declare function extractErrorAtTheEndOfChunk(chunk: Uint8Array, exceptionTag: string): Error;
|
package/dist/utils/stream.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
|
-
|
|
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
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
package/dist/utils/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":";;;AAoBA,kEAiDC;AArED,oCAAqC;AAErC,MAAM,gBAAgB,GAAG,eAAe,CAAA;AAExC,MAAM,OAAO,GAAG,IAAa,CAAA;AAChB,QAAA,YAAY,GAAG,IAAa,CAAA;AAEzC;;;;;;;;;;;;GAYG;AACH,SAAgB,2BAA2B,CACzC,KAAiB,EACjB,YAAoB;IAEpB,IAAI,CAAC;QACH,MAAM,yBAAyB,GAC7B,CAAC,GAAG,QAAQ;YACZ,gBAAgB,CAAC,MAAM,GAAG,gBAAgB;YAC1C,CAAC,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
|
+
declare const _default: "0.100.1";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,SAAS,CAAA"}
|
package/package.json
CHANGED