@clickhouse/client-web 1.20.0 → 1.21.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.
- package/README.md +11 -11
- package/dist/client.d.ts +8 -8
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/connection/index.d.ts +1 -1
- package/dist/connection/index.js.map +1 -1
- package/dist/connection/web_connection.d.ts +3 -3
- package/dist/connection/web_connection.js +46 -12
- package/dist/connection/web_connection.js.map +1 -1
- package/dist/index.d.ts +40 -7
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/result_set.d.ts +27 -5
- package/dist/result_set.js +117 -20
- package/dist/result_set.js.map +1 -1
- package/dist/utils/encoder.d.ts +2 -2
- package/dist/utils/encoder.js +4 -4
- package/dist/utils/encoder.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/stream.js +4 -4
- 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 +2 -2
package/README.md
CHANGED
|
@@ -84,23 +84,23 @@ The client may work with older versions too; however, this is best-effort suppor
|
|
|
84
84
|
## Quick start
|
|
85
85
|
|
|
86
86
|
```ts
|
|
87
|
-
import { createClient } from
|
|
87
|
+
import { createClient } from "@clickhouse/client"; // or '@clickhouse/client-web'
|
|
88
88
|
|
|
89
89
|
const client = createClient({
|
|
90
|
-
url: process.env.CLICKHOUSE_URL ??
|
|
91
|
-
username: process.env.CLICKHOUSE_USER ??
|
|
92
|
-
password: process.env.CLICKHOUSE_PASSWORD ??
|
|
93
|
-
})
|
|
90
|
+
url: process.env.CLICKHOUSE_URL ?? "http://localhost:8123",
|
|
91
|
+
username: process.env.CLICKHOUSE_USER ?? "default",
|
|
92
|
+
password: process.env.CLICKHOUSE_PASSWORD ?? "",
|
|
93
|
+
});
|
|
94
94
|
|
|
95
95
|
const resultSet = await client.query({
|
|
96
|
-
query:
|
|
97
|
-
format:
|
|
98
|
-
})
|
|
96
|
+
query: "SELECT * FROM system.tables",
|
|
97
|
+
format: "JSONEachRow",
|
|
98
|
+
});
|
|
99
99
|
|
|
100
|
-
const tables = await resultSet.json()
|
|
101
|
-
console.log(tables)
|
|
100
|
+
const tables = await resultSet.json();
|
|
101
|
+
console.log(tables);
|
|
102
102
|
|
|
103
|
-
await client.close()
|
|
103
|
+
await client.close();
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
See more examples in the [examples directory](./examples).
|
package/dist/client.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import type { CommandParams, CommandResult, DataFormat, ExecParams, ExecResult, InputJSON, InputJSONObjectEachRow, InsertParams, InsertResult, IsSame, QueryParamsWithFormat } from
|
|
2
|
-
import { ClickHouseClient } from
|
|
3
|
-
import type { WebClickHouseClientConfigOptions } from
|
|
4
|
-
import type { ResultSet } from
|
|
1
|
+
import type { CommandParams, CommandResult, DataFormat, ExecParams, ExecResult, InputJSON, InputJSONObjectEachRow, InsertParams, InsertResult, IsSame, QueryParamsWithFormat } from "@clickhouse/client-common";
|
|
2
|
+
import { ClickHouseClient } from "@clickhouse/client-common";
|
|
3
|
+
import type { WebClickHouseClientConfigOptions } from "./config";
|
|
4
|
+
import type { ResultSet } from "./result_set";
|
|
5
5
|
/** If the Format is not a literal type, fall back to the default behavior of the ResultSet,
|
|
6
6
|
* allowing to call all methods with all data shapes variants,
|
|
7
7
|
* and avoiding generated types that include all possible DataFormat literal values. */
|
|
8
8
|
export type QueryResult<Format extends DataFormat> = IsSame<Format, DataFormat> extends true ? ResultSet<unknown> : ResultSet<Format>;
|
|
9
|
-
export type WebClickHouseClient = Omit<WebClickHouseClientImpl,
|
|
9
|
+
export type WebClickHouseClient = Omit<WebClickHouseClientImpl, "insert" | "exec" | "command"> & {
|
|
10
10
|
/** See {@link ClickHouseClient.insert}.
|
|
11
11
|
*
|
|
12
12
|
* ReadableStream is removed from possible insert values
|
|
13
13
|
* until it is supported by all major web platforms. */
|
|
14
|
-
insert<T>(params: Omit<InsertParams<ReadableStream, T>,
|
|
14
|
+
insert<T>(params: Omit<InsertParams<ReadableStream, T>, "values"> & {
|
|
15
15
|
values: ReadonlyArray<T> | InputJSON<T> | InputJSONObjectEachRow<T>;
|
|
16
16
|
}): Promise<InsertResult>;
|
|
17
17
|
/** See {@link ClickHouseClient.exec}.
|
|
18
18
|
*
|
|
19
19
|
* Custom values are currently not supported in the web versions.
|
|
20
20
|
* The `ignore_error_response` parameter is not supported in the Web version. */
|
|
21
|
-
exec(params: Omit<ExecParams,
|
|
21
|
+
exec(params: Omit<ExecParams, "ignore_error_response">): Promise<ExecResult<ReadableStream>>;
|
|
22
22
|
/** See {@link ClickHouseClient.command}.
|
|
23
23
|
*
|
|
24
24
|
* The `ignore_error_response` parameter is not supported in the Web version. */
|
|
25
|
-
command(params: Omit<CommandParams,
|
|
25
|
+
command(params: Omit<CommandParams, "ignore_error_response">): Promise<CommandResult>;
|
|
26
26
|
};
|
|
27
27
|
declare class WebClickHouseClientImpl extends ClickHouseClient<ReadableStream> {
|
|
28
28
|
/** See {@link ClickHouseClient.query}. */
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;AA+DA,oCAOC;AAzDD,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;AA+DA,oCAOC;AAzDD,6DAA6D;AAE7D,qCAAmC;AAuCnC,MAAM,uBAAwB,SAAQ,gCAAgC;IACpE,0CAA0C;IACjC,KAAK,CACZ,MAAqC;QAErC,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAA+B,CAAC;IAC3D,CAAC;CACF;AAED,SAAgB,YAAY,CAC1B,MAAyC;IAEzC,OAAO,IAAI,uBAAuB,CAAC;QACjC,IAAI,EAAE,gBAAO;QACb,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;KAClB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BaseClickHouseClientConfigOptions, ImplementationDetails } from
|
|
1
|
+
import type { BaseClickHouseClientConfigOptions, ImplementationDetails } from "@clickhouse/client-common";
|
|
2
2
|
export type WebClickHouseClientConfigOptions = BaseClickHouseClientConfigOptions & {
|
|
3
3
|
/** A custom implementation or wrapper over the global `fetch` method that will be used by the client internally.
|
|
4
4
|
* This might be helpful if you want to configure mTLS or change other default `fetch` settings. */
|
|
5
5
|
fetch?: typeof fetch;
|
|
6
6
|
};
|
|
7
|
-
export declare const WebImpl: ImplementationDetails<ReadableStream>[
|
|
7
|
+
export declare const WebImpl: ImplementationDetails<ReadableStream>["impl"];
|
package/dist/config.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.WebImpl = {
|
|
|
9
9
|
...params,
|
|
10
10
|
fetch: config.fetch,
|
|
11
11
|
}),
|
|
12
|
-
make_result_set: ((stream, format, query_id, _log_error, response_headers) => new result_set_1.ResultSet(stream, format, query_id, response_headers)),
|
|
12
|
+
make_result_set: ((stream, format, query_id, _log_error, response_headers, jsonHandling, span) => new result_set_1.ResultSet(stream, format, query_id, response_headers, jsonHandling, span)),
|
|
13
13
|
values_encoder: (jsonHandling) => new utils_1.WebValuesEncoder(jsonHandling),
|
|
14
14
|
};
|
|
15
15
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AASA,6CAA6C;AAC7C,6CAAyC;AACzC,mCAA2C;AAS9B,QAAA,OAAO,GAAkD;IACpE,eAAe,EAAE,CACf,MAAwC,EACxC,MAAwB,EACxB,EAAE,CACF,IAAI,0BAAa,CAAC;QAChB,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;IACJ,eAAe,EAAE,CAAC,CAChB,MAAsB,EACtB,MAAkB,EAClB,QAAgB,EAChB,UAAgC,EAChC,gBAAiC,EACjC,YAA0B,EAC1B,IAAqB,EACrB,EAAE,CACF,IAAI,sBAAS,CACX,MAAM,EACN,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,IAAI,CACL,CAAQ;IACX,cAAc,EAAE,CAAC,YAA0B,EAAE,EAAE,CAC7C,IAAI,wBAAgB,CAAC,YAAY,CAAC;CACrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./web_connection";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { ConnBaseQueryParams, ConnCommandResult, Connection, ConnectionParams, ConnInsertParams, ConnInsertResult, ConnPingResult, ConnQueryResult } from
|
|
2
|
-
type WebInsertParams<T> = Omit<ConnInsertParams<ReadableStream<T>>,
|
|
1
|
+
import type { ConnBaseQueryParams, ConnCommandResult, Connection, ConnectionParams, ConnInsertParams, ConnInsertResult, ConnPingResult, ConnQueryResult } from "@clickhouse/client-common";
|
|
2
|
+
type WebInsertParams<T> = Omit<ConnInsertParams<ReadableStream<T>>, "values"> & {
|
|
3
3
|
values: string;
|
|
4
4
|
};
|
|
5
5
|
export type WebConnectionParams = ConnectionParams & {
|
|
6
6
|
fetch?: typeof fetch;
|
|
7
7
|
};
|
|
8
8
|
export declare class WebConnection implements Connection<ReadableStream> {
|
|
9
|
-
private readonly params;
|
|
10
9
|
private readonly defaultAuthHeader;
|
|
10
|
+
private readonly params;
|
|
11
11
|
constructor(params: WebConnectionParams);
|
|
12
12
|
query(params: ConnBaseQueryParams): Promise<ConnQueryResult<ReadableStream<Uint8Array>>>;
|
|
13
13
|
exec(params: ConnBaseQueryParams): Promise<ConnQueryResult<ReadableStream<Uint8Array>>>;
|
|
@@ -4,14 +4,14 @@ exports.WebConnection = void 0;
|
|
|
4
4
|
const client_common_1 = require("@clickhouse/client-common");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
class WebConnection {
|
|
7
|
-
params;
|
|
8
7
|
defaultAuthHeader;
|
|
8
|
+
params;
|
|
9
9
|
constructor(params) {
|
|
10
10
|
this.params = params;
|
|
11
|
-
if (params.auth.type ===
|
|
11
|
+
if (params.auth.type === "JWT") {
|
|
12
12
|
this.defaultAuthHeader = `Bearer ${params.auth.access_token}`;
|
|
13
13
|
}
|
|
14
|
-
else if (params.auth.type ===
|
|
14
|
+
else if (params.auth.type === "Credentials") {
|
|
15
15
|
this.defaultAuthHeader = `Basic ${btoa(`${params.auth.username}:${params.auth.password}`)}`;
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
@@ -21,18 +21,51 @@ class WebConnection {
|
|
|
21
21
|
async query(params) {
|
|
22
22
|
const query_id = getQueryId(params.query_id);
|
|
23
23
|
const clickhouse_settings = (0, client_common_1.withHttpSettings)(params.clickhouse_settings, this.params.compression.decompress_response);
|
|
24
|
+
const queryParams = params.query_params;
|
|
25
|
+
const hasQueryParams = queryParams !== undefined && Object.keys(queryParams).length > 0;
|
|
26
|
+
let useMultipart = hasQueryParams &&
|
|
27
|
+
(params.use_multipart_params ?? this.params.use_multipart_params);
|
|
28
|
+
// In auto mode, serialize the params for the URL once with an early
|
|
29
|
+
// return: a null result means they exceed the URL budget and should be
|
|
30
|
+
// promoted to a multipart body; otherwise the entries are reused below.
|
|
31
|
+
let urlParamEntries;
|
|
32
|
+
if (hasQueryParams &&
|
|
33
|
+
!useMultipart &&
|
|
34
|
+
(params.use_multipart_params_auto ??
|
|
35
|
+
this.params.use_multipart_params_auto)) {
|
|
36
|
+
const entries = (0, client_common_1.serializeQueryParamsForUrl)(queryParams);
|
|
37
|
+
if (entries === null) {
|
|
38
|
+
useMultipart = true;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
urlParamEntries = entries;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
24
44
|
const searchParams = (0, client_common_1.toSearchParams)({
|
|
25
45
|
database: this.params.database,
|
|
26
46
|
clickhouse_settings,
|
|
27
|
-
query_params: params.query_params,
|
|
47
|
+
query_params: useMultipart ? undefined : params.query_params,
|
|
48
|
+
param_entries: urlParamEntries,
|
|
28
49
|
session_id: params.session_id,
|
|
29
50
|
role: params.role,
|
|
30
51
|
query_id,
|
|
31
52
|
});
|
|
53
|
+
let body = params.query;
|
|
54
|
+
const headers = this.defaultHeadersWithOverride(params);
|
|
55
|
+
if (useMultipart && params.query_params !== undefined) {
|
|
56
|
+
const boundary = `----clickhouse-js-${crypto.randomUUID()}`;
|
|
57
|
+
const multipartParts = { query: params.query };
|
|
58
|
+
for (const [key, value] of Object.entries(params.query_params)) {
|
|
59
|
+
multipartParts[`param_${key}`] = (0, client_common_1.formatQueryParams)({ value });
|
|
60
|
+
}
|
|
61
|
+
body = (0, client_common_1.buildMultipartBody)(multipartParts, boundary);
|
|
62
|
+
headers["Content-Type"] = `multipart/form-data; boundary=${boundary}`;
|
|
63
|
+
}
|
|
32
64
|
const response = await this.request({
|
|
33
|
-
body
|
|
65
|
+
body,
|
|
34
66
|
params,
|
|
35
67
|
searchParams,
|
|
68
|
+
headers,
|
|
36
69
|
});
|
|
37
70
|
return {
|
|
38
71
|
query_id,
|
|
@@ -93,7 +126,7 @@ class WebConnection {
|
|
|
93
126
|
query: `SELECT 'ping'`,
|
|
94
127
|
query_id: getQueryId(undefined),
|
|
95
128
|
}),
|
|
96
|
-
method:
|
|
129
|
+
method: "GET",
|
|
97
130
|
});
|
|
98
131
|
if (response.body !== null) {
|
|
99
132
|
await response.body.cancel();
|
|
@@ -113,7 +146,7 @@ class WebConnection {
|
|
|
113
146
|
async close() {
|
|
114
147
|
return;
|
|
115
148
|
}
|
|
116
|
-
async request({ body, params, searchParams, pathname, method, }) {
|
|
149
|
+
async request({ body, params, searchParams, pathname, method, headers: prebuiltHeaders, }) {
|
|
117
150
|
const url = (0, client_common_1.transformUrl)({
|
|
118
151
|
url: this.params.url,
|
|
119
152
|
pathname,
|
|
@@ -134,7 +167,7 @@ class WebConnection {
|
|
|
134
167
|
}
|
|
135
168
|
try {
|
|
136
169
|
const headers = (0, client_common_1.withCompressionHeaders)({
|
|
137
|
-
headers: this.defaultHeadersWithOverride(params),
|
|
170
|
+
headers: prebuiltHeaders ?? this.defaultHeadersWithOverride(params),
|
|
138
171
|
// It is not currently working as expected in all major browsers
|
|
139
172
|
enable_request_compression: false,
|
|
140
173
|
enable_response_compression: this.params.compression.decompress_response,
|
|
@@ -145,11 +178,12 @@ class WebConnection {
|
|
|
145
178
|
body,
|
|
146
179
|
headers,
|
|
147
180
|
keepalive: this.params.keep_alive.enabled,
|
|
148
|
-
method: method ??
|
|
181
|
+
method: method ?? "POST",
|
|
149
182
|
signal: abortController.signal,
|
|
150
183
|
});
|
|
151
184
|
clearTimeout(timeout);
|
|
152
|
-
if ((0, client_common_1.isSuccessfulResponse)(response.status)
|
|
185
|
+
if ((0, client_common_1.isSuccessfulResponse)(response.status) &&
|
|
186
|
+
!response.headers.has("x-clickhouse-exception-code")) {
|
|
153
187
|
return response;
|
|
154
188
|
}
|
|
155
189
|
else {
|
|
@@ -159,10 +193,10 @@ class WebConnection {
|
|
|
159
193
|
catch (err) {
|
|
160
194
|
clearTimeout(timeout);
|
|
161
195
|
if (isAborted) {
|
|
162
|
-
return Promise.reject(new Error(
|
|
196
|
+
return Promise.reject(new Error("The user aborted a request."));
|
|
163
197
|
}
|
|
164
198
|
if (isTimedOut) {
|
|
165
|
-
return Promise.reject(new Error(
|
|
199
|
+
return Promise.reject(new Error("Timeout error."));
|
|
166
200
|
}
|
|
167
201
|
if (err instanceof Error) {
|
|
168
202
|
// maybe it's a ClickHouse error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web_connection.js","sourceRoot":"","sources":["../../src/connection/web_connection.ts"],"names":[],"mappings":";;;AAWA,
|
|
1
|
+
{"version":3,"file":"web_connection.js","sourceRoot":"","sources":["../../src/connection/web_connection.ts"],"names":[],"mappings":";;;AAWA,6DAYmC;AACnC,oCAAqC;AAarC,MAAa,aAAa;IACP,iBAAiB,CAAS;IAC1B,MAAM,CAAsB;IAC7C,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YAC/B,IAAI,CAAC,iBAAiB,GAAG,UAAU,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAChE,CAAC;aAAM,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YAC9C,IAAI,CAAC,iBAAiB,GAAG,SAAS,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;QAC9F,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,sBAAuB,MAAM,CAAC,IAAY,CAAC,IAAI,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK,CACT,MAA2B;QAE3B,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7C,MAAM,mBAAmB,GAAG,IAAA,gCAAgB,EAC1C,MAAM,CAAC,mBAAmB,EAC1B,IAAI,CA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UAAU,GAAG,UAAU,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;QACrD,CAAC;aAAM,IAAI,IAAA,iCAAiB,EAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;YAC3C,UAAU,GAAG,SAAS,IAAI,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,QAAQ,IAAI,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;QACpF,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACtC,CAAC;QACD,OAAO;YACL,oDAAoD;YACpD,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;YACnC,gHAAgH;YAChH,GAAG,CAAC,MAAM,EAAE,YAAY,IAAI,EAAE,CAAC;YAC/B,aAAa,EAAE,UAAU;SAC1B,CAAC;IACJ,CAAC;CACF;AAnSD,sCAmSC;AAED,SAAS,UAAU,CAAC,QAA4B;IAC9C,OAAO,QAAQ,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;AACzC,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAkB;IAC5C,MAAM,OAAO,GAAoB,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { type WebClickHouseClient as ClickHouseClient, type QueryResult, } from
|
|
2
|
-
export { createClient } from
|
|
3
|
-
export { type WebClickHouseClientConfigOptions as ClickHouseClientConfigOptions } from
|
|
4
|
-
export { ResultSet } from
|
|
1
|
+
export { type WebClickHouseClient as ClickHouseClient, type QueryResult, } from "./client";
|
|
2
|
+
export { createClient } from "./client";
|
|
3
|
+
export { type WebClickHouseClientConfigOptions as ClickHouseClientConfigOptions } from "./config";
|
|
4
|
+
export { ResultSet } from "./result_set";
|
|
5
5
|
/** Re-export @clickhouse/client-common types */
|
|
6
|
-
export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type RawDataFormat, type JSONDataFormat, type StreamableDataFormat, type StreamableJSONDataFormat, type SingleDocumentJSONFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, type ResponseHeaders, type SimpleColumnType, type ParsedColumnSimple, type ParsedColumnEnum, type ParsedColumnFixedString, type ParsedColumnNullable, type ParsedColumnDecimal, type ParsedColumnDateTime, type ParsedColumnDateTime64, type ParsedColumnArray, type ParsedColumnTuple, type ParsedColumnMap, type ParsedColumnType, type ProgressRow, type RowOrProgress, type ClickHouseAuth, type ClickHouseJWTAuth, type ClickHouseCredentialsAuth, } from
|
|
6
|
+
export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type RawDataFormat, type JSONDataFormat, type StreamableDataFormat, type StreamableJSONDataFormat, type SingleDocumentJSONFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, type ResponseHeaders, type SimpleColumnType, type ParsedColumnSimple, type ParsedColumnEnum, type ParsedColumnFixedString, type ParsedColumnNullable, type ParsedColumnDecimal, type ParsedColumnDateTime, type ParsedColumnDateTime64, type ParsedColumnArray, type ParsedColumnTuple, type ParsedColumnMap, type ParsedColumnType, type ProgressRow, type RowOrProgress, type ClickHouseAuth, type ClickHouseJWTAuth, type ClickHouseCredentialsAuth, type ClickHouseTracer, type ClickHouseSpan, type ClickHouseSpanOptions, type ClickHouseSpanAttributes, type ClickHouseSpanStatus, type ClickHouseSpanName, } from "@clickhouse/client-common";
|
|
7
7
|
/**
|
|
8
8
|
* Re-export @clickhouse/client-common runtime values.
|
|
9
9
|
*
|
|
@@ -12,11 +12,24 @@ export { type BaseClickHouseClientConfigOptions, type BaseQueryParams, type Quer
|
|
|
12
12
|
* applied to them in `@clickhouse/client-common` are NOT propagated to consumers of this package.
|
|
13
13
|
* Importing these values from `@clickhouse/client-web` is the recommended, non-deprecated path.
|
|
14
14
|
*/
|
|
15
|
-
import { ClickHouseError as ClickHouseError_, parseError as parseError_, ClickHouseLogLevel as ClickHouseLogLevel_, SettingsMap as SettingsMap_, parseColumnType as parseColumnType_, isProgressRow as isProgressRow_, isRow as isRow_, isException as isException_, TupleParam as TupleParam_ } from
|
|
15
|
+
import { ClickHouseError as ClickHouseError_, parseError as parseError_, ClickHouseLogLevel as ClickHouseLogLevel_, SettingsMap as SettingsMap_, parseColumnType as parseColumnType_, isProgressRow as isProgressRow_, isRow as isRow_, isException as isException_, TupleParam as TupleParam_ } from "@clickhouse/client-common";
|
|
16
16
|
export declare const ClickHouseError: typeof ClickHouseError_;
|
|
17
17
|
export type ClickHouseError = ClickHouseError_;
|
|
18
18
|
export declare const parseError: typeof parseError_;
|
|
19
|
-
export declare const ClickHouseLogLevel:
|
|
19
|
+
export declare const ClickHouseLogLevel: {
|
|
20
|
+
readonly TRACE: 0;
|
|
21
|
+
readonly DEBUG: 1;
|
|
22
|
+
readonly INFO: 2;
|
|
23
|
+
readonly WARN: 3;
|
|
24
|
+
readonly ERROR: 4;
|
|
25
|
+
readonly OFF: 127;
|
|
26
|
+
readonly 0: "TRACE";
|
|
27
|
+
readonly 1: "DEBUG";
|
|
28
|
+
readonly 2: "INFO";
|
|
29
|
+
readonly 3: "WARN";
|
|
30
|
+
readonly 4: "ERROR";
|
|
31
|
+
readonly 127: "OFF";
|
|
32
|
+
};
|
|
20
33
|
export type ClickHouseLogLevel = ClickHouseLogLevel_;
|
|
21
34
|
export declare const SettingsMap: typeof SettingsMap_;
|
|
22
35
|
export type SettingsMap = SettingsMap_;
|
|
@@ -33,4 +46,24 @@ export declare const isRow: typeof isRow_;
|
|
|
33
46
|
export declare const isException: typeof isException_;
|
|
34
47
|
export declare const TupleParam: typeof TupleParam_;
|
|
35
48
|
export type TupleParam = TupleParam_;
|
|
49
|
+
export declare const ClickHouseSpanNames: {
|
|
50
|
+
readonly query: "clickhouse.query";
|
|
51
|
+
readonly query_stream: "clickhouse.query.stream";
|
|
52
|
+
readonly command: "clickhouse.command";
|
|
53
|
+
readonly exec: "clickhouse.exec";
|
|
54
|
+
readonly insert: "clickhouse.insert";
|
|
55
|
+
readonly ping: "clickhouse.ping";
|
|
56
|
+
};
|
|
57
|
+
export declare const ClickHouseSpanStatusCode: {
|
|
58
|
+
readonly UNSET: 0;
|
|
59
|
+
readonly OK: 1;
|
|
60
|
+
readonly ERROR: 2;
|
|
61
|
+
};
|
|
62
|
+
export declare const ClickHouseSpanKind: {
|
|
63
|
+
readonly INTERNAL: 0;
|
|
64
|
+
readonly SERVER: 1;
|
|
65
|
+
readonly CLIENT: 2;
|
|
66
|
+
readonly PRODUCER: 3;
|
|
67
|
+
readonly CONSUMER: 4;
|
|
68
|
+
};
|
|
36
69
|
export declare const defaultJSONHandling: import("@clickhouse/client-common").JSONHandling;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultJSONHandling = exports.TupleParam = exports.isException = exports.isRow = exports.isProgressRow = exports.SimpleColumnTypes = exports.parseColumnType = exports.RecordsJSONFormats = exports.SingleDocumentJSONFormats = exports.StreamableJSONFormats = exports.StreamableFormats = exports.SupportedRawFormats = exports.SupportedJSONFormats = exports.SettingsMap = exports.ClickHouseLogLevel = exports.parseError = exports.ClickHouseError = exports.ResultSet = exports.createClient = void 0;
|
|
3
|
+
exports.defaultJSONHandling = exports.ClickHouseSpanKind = exports.ClickHouseSpanStatusCode = exports.ClickHouseSpanNames = exports.TupleParam = exports.isException = exports.isRow = exports.isProgressRow = exports.SimpleColumnTypes = exports.parseColumnType = exports.RecordsJSONFormats = exports.SingleDocumentJSONFormats = exports.StreamableJSONFormats = exports.StreamableFormats = exports.SupportedRawFormats = exports.SupportedJSONFormats = exports.SettingsMap = exports.ClickHouseLogLevel = exports.parseError = exports.ClickHouseError = exports.ResultSet = exports.createClient = void 0;
|
|
4
4
|
var client_1 = require("./client");
|
|
5
5
|
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });
|
|
6
6
|
var result_set_1 = require("./result_set");
|
|
@@ -30,5 +30,8 @@ exports.isProgressRow = client_common_1.isProgressRow;
|
|
|
30
30
|
exports.isRow = client_common_1.isRow;
|
|
31
31
|
exports.isException = client_common_1.isException;
|
|
32
32
|
exports.TupleParam = client_common_1.TupleParam;
|
|
33
|
+
exports.ClickHouseSpanNames = client_common_1.ClickHouseSpanNames;
|
|
34
|
+
exports.ClickHouseSpanStatusCode = client_common_1.ClickHouseSpanStatusCode;
|
|
35
|
+
exports.ClickHouseSpanKind = client_common_1.ClickHouseSpanKind;
|
|
33
36
|
exports.defaultJSONHandling = client_common_1.defaultJSONHandling;
|
|
34
37
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AAErB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AA0DlB;;;;;;;GAOG;AACH,6DAqBmC;AAEtB,QAAA,eAAe,GAAG,+BAAgB,CAAC;AAEnC,QAAA,UAAU,GAAG,0BAAW,CAAC;AACzB,QAAA,kBAAkB,GAAG,kCAAmB,CAAC;AAEzC,QAAA,WAAW,GAAG,2BAAY,CAAC;AAE3B,QAAA,oBAAoB,GAAG,oCAAqB,CAAC;AAC7C,QAAA,mBAAmB,GAAG,mCAAoB,CAAC;AAC3C,QAAA,iBAAiB,GAAG,iCAAkB,CAAC;AACvC,QAAA,qBAAqB,GAAG,qCAAsB,CAAC;AAC/C,QAAA,yBAAyB,GAAG,yCAA0B,CAAC;AACvD,QAAA,kBAAkB,GAAG,kCAAmB,CAAC;AACzC,QAAA,eAAe,GAAG,+BAAgB,CAAC;AACnC,QAAA,iBAAiB,GAAG,iCAAkB,CAAC;AACvC,QAAA,aAAa,GAAG,6BAAc,CAAC;AAC/B,QAAA,KAAK,GAAG,qBAAM,CAAC;AACf,QAAA,WAAW,GAAG,2BAAY,CAAC;AAC3B,QAAA,UAAU,GAAG,0BAAW,CAAC;AAEzB,QAAA,mBAAmB,GAAG,mCAAoB,CAAC;AAC3C,QAAA,wBAAwB,GAAG,wCAAyB,CAAC;AACrD,QAAA,kBAAkB,GAAG,kCAAmB,CAAC;AACzC,QAAA,mBAAmB,GAAG,mCAAoB,CAAC"}
|
package/dist/result_set.d.ts
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import type { BaseResultSet, DataFormat, JSONHandling, ResponseHeaders, ResultJSONType, ResultStream, Row } from
|
|
1
|
+
import type { BaseResultSet, ClickHouseSpan, DataFormat, JSONHandling, ResponseHeaders, ResultJSONType, ResultStream, Row } from "@clickhouse/client-common";
|
|
2
2
|
export declare class ResultSet<Format extends DataFormat | unknown> implements BaseResultSet<ReadableStream<Row[]>, Format> {
|
|
3
|
-
private _stream;
|
|
4
|
-
private readonly format;
|
|
5
|
-
readonly query_id: string;
|
|
6
3
|
readonly response_headers: ResponseHeaders;
|
|
7
4
|
private readonly exceptionTag;
|
|
8
5
|
private isAlreadyConsumed;
|
|
9
6
|
private readonly jsonHandling;
|
|
10
|
-
|
|
7
|
+
private _stream;
|
|
8
|
+
private readonly format;
|
|
9
|
+
/** The `clickhouse.query.stream` span owned by this result set (if the
|
|
10
|
+
* client was configured with a tracer); it ends via {@link finishSpan}
|
|
11
|
+
* when the response stream is fully consumed, closed, or fails. */
|
|
12
|
+
private readonly span;
|
|
13
|
+
/** Decoded (decompressed) bytes received from the server so far. */
|
|
14
|
+
private span_bytes;
|
|
15
|
+
/** Rows decoded from the response stream so far. */
|
|
16
|
+
private span_rows;
|
|
17
|
+
private span_rows_counted;
|
|
18
|
+
/** UTF-16 code-unit length of the response body, recorded by {@link text}
|
|
19
|
+
* instead of {@link span_bytes} to avoid the `TextEncoder` allocation that
|
|
20
|
+
* accurate byte counting would require. */
|
|
21
|
+
private span_text_length;
|
|
22
|
+
private span_finished;
|
|
23
|
+
readonly query_id: string;
|
|
24
|
+
constructor(_stream: ReadableStream, format: Format, query_id: string, _response_headers?: ResponseHeaders, jsonHandling?: JSONHandling, span?: ClickHouseSpan);
|
|
11
25
|
/** See {@link BaseResultSet.text} */
|
|
12
26
|
text(): Promise<string>;
|
|
13
27
|
/** See {@link BaseResultSet.json} */
|
|
@@ -24,4 +38,12 @@ export declare class ResultSet<Format extends DataFormat | unknown> implements B
|
|
|
24
38
|
*/
|
|
25
39
|
[Symbol.asyncDispose](): Promise<void>;
|
|
26
40
|
private markAsConsumed;
|
|
41
|
+
/** Add the number of rows decoded from the response stream. */
|
|
42
|
+
private addSpanRows;
|
|
43
|
+
/** Record the final response metrics (`clickhouse.response.decoded_bytes`,
|
|
44
|
+
* `clickhouse.response.text_length` when called from {@link text}, and
|
|
45
|
+
* `db.response.returned_rows` when rows were counted) and the error
|
|
46
|
+
* (if any) on the span, and end it. Safe to call multiple times - only
|
|
47
|
+
* the first call wins. */
|
|
48
|
+
private finishSpan;
|
|
27
49
|
}
|
package/dist/result_set.js
CHANGED
|
@@ -6,51 +6,96 @@ const client_common_2 = require("@clickhouse/client-common");
|
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
const NEWLINE = 0x0a;
|
|
8
8
|
class ResultSet {
|
|
9
|
-
_stream;
|
|
10
|
-
format;
|
|
11
|
-
query_id;
|
|
12
9
|
response_headers;
|
|
13
10
|
exceptionTag = undefined;
|
|
14
11
|
isAlreadyConsumed = false;
|
|
15
12
|
jsonHandling;
|
|
13
|
+
_stream;
|
|
14
|
+
format;
|
|
15
|
+
/** The `clickhouse.query.stream` span owned by this result set (if the
|
|
16
|
+
* client was configured with a tracer); it ends via {@link finishSpan}
|
|
17
|
+
* when the response stream is fully consumed, closed, or fails. */
|
|
18
|
+
span;
|
|
19
|
+
/** Decoded (decompressed) bytes received from the server so far. */
|
|
20
|
+
span_bytes = 0;
|
|
21
|
+
/** Rows decoded from the response stream so far. */
|
|
22
|
+
span_rows = 0;
|
|
23
|
+
span_rows_counted = false;
|
|
24
|
+
/** UTF-16 code-unit length of the response body, recorded by {@link text}
|
|
25
|
+
* instead of {@link span_bytes} to avoid the `TextEncoder` allocation that
|
|
26
|
+
* accurate byte counting would require. */
|
|
27
|
+
span_text_length;
|
|
28
|
+
span_finished = false;
|
|
29
|
+
query_id;
|
|
16
30
|
constructor(_stream, format, query_id, _response_headers, jsonHandling = {
|
|
17
31
|
parse: JSON.parse,
|
|
18
32
|
stringify: JSON.stringify,
|
|
19
|
-
}) {
|
|
33
|
+
}, span) {
|
|
20
34
|
this._stream = _stream;
|
|
21
35
|
this.format = format;
|
|
22
36
|
this.query_id = query_id;
|
|
37
|
+
this.span = span;
|
|
23
38
|
this.response_headers =
|
|
24
39
|
_response_headers !== undefined ? Object.freeze(_response_headers) : {};
|
|
25
|
-
this.exceptionTag = this.response_headers[
|
|
40
|
+
this.exceptionTag = this.response_headers["x-clickhouse-exception-tag"];
|
|
26
41
|
this.jsonHandling = jsonHandling;
|
|
27
42
|
}
|
|
28
43
|
/** See {@link BaseResultSet.text} */
|
|
29
44
|
async text() {
|
|
30
45
|
this.markAsConsumed();
|
|
31
|
-
|
|
46
|
+
try {
|
|
47
|
+
const text = await (0, utils_1.getAsText)(this._stream);
|
|
48
|
+
// text.length is the UTF-16 code-unit count of the response body, not a
|
|
49
|
+
// byte count. We record it as `clickhouse.response.text_length` rather
|
|
50
|
+
// than `span_bytes` (`clickhouse.response.decoded_bytes`) to avoid the
|
|
51
|
+
// `TextEncoder` allocation that accurate byte counting would require here.
|
|
52
|
+
this.span_text_length = text.length;
|
|
53
|
+
this.finishSpan();
|
|
54
|
+
return text;
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
this.finishSpan(err);
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
32
60
|
}
|
|
33
61
|
/** See {@link BaseResultSet.json} */
|
|
34
62
|
async json() {
|
|
35
63
|
// JSONEachRow, etc.
|
|
36
64
|
if ((0, client_common_2.isStreamableJSONFamily)(this.format)) {
|
|
37
65
|
const result = [];
|
|
66
|
+
// The span progress is updated and the span is finished by the stream() pipeline.
|
|
38
67
|
const reader = this.stream().getReader();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
try {
|
|
69
|
+
while (true) {
|
|
70
|
+
const { done, value } = await reader.read();
|
|
71
|
+
if (done) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
for (const row of value) {
|
|
75
|
+
result.push(row.json());
|
|
76
|
+
}
|
|
46
77
|
}
|
|
47
78
|
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
this.finishSpan(err);
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
48
83
|
return result;
|
|
49
84
|
}
|
|
50
85
|
// JSON, JSONObjectEachRow, etc.
|
|
51
86
|
if ((0, client_common_2.isNotStreamableJSONFamily)(this.format)) {
|
|
52
|
-
|
|
53
|
-
|
|
87
|
+
try {
|
|
88
|
+
const text = await (0, utils_1.getAsText)(this._stream);
|
|
89
|
+
// Same as text(): record text.length (UTF-16 code-unit count) rather
|
|
90
|
+
// than span_bytes to avoid the TextEncoder allocation.
|
|
91
|
+
this.span_text_length = text.length;
|
|
92
|
+
this.finishSpan();
|
|
93
|
+
return this.jsonHandling.parse(text);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
this.finishSpan(err);
|
|
97
|
+
throw err;
|
|
98
|
+
}
|
|
54
99
|
}
|
|
55
100
|
// should not be called for CSV, etc.
|
|
56
101
|
throw new Error(`Cannot decode ${this.format} as JSON`);
|
|
@@ -63,8 +108,8 @@ class ResultSet {
|
|
|
63
108
|
let totalIncompleteLength = 0;
|
|
64
109
|
const exceptionTag = this.exceptionTag;
|
|
65
110
|
const jsonHandling = this.jsonHandling;
|
|
66
|
-
const decoder = new TextDecoder(
|
|
67
|
-
const
|
|
111
|
+
const decoder = new TextDecoder("utf-8");
|
|
112
|
+
const transformerOptions = {
|
|
68
113
|
start() {
|
|
69
114
|
//
|
|
70
115
|
},
|
|
@@ -72,6 +117,7 @@ class ResultSet {
|
|
|
72
117
|
if (chunk === null) {
|
|
73
118
|
controller.terminate();
|
|
74
119
|
}
|
|
120
|
+
this.span_bytes += chunk.length;
|
|
75
121
|
const rows = [];
|
|
76
122
|
let idx;
|
|
77
123
|
let lastIdx = 0;
|
|
@@ -87,6 +133,7 @@ class ResultSet {
|
|
|
87
133
|
totalIncompleteLength += incompleteChunk.length;
|
|
88
134
|
// send the extracted rows to the consumer, if any
|
|
89
135
|
if (rows.length > 0) {
|
|
136
|
+
this.addSpanRows(rows.length);
|
|
90
137
|
controller.enqueue(rows);
|
|
91
138
|
}
|
|
92
139
|
break;
|
|
@@ -97,7 +144,10 @@ class ResultSet {
|
|
|
97
144
|
if (exceptionTag !== undefined &&
|
|
98
145
|
idx >= 1 &&
|
|
99
146
|
chunk[idx - 1] === client_common_1.CARET_RETURN) {
|
|
100
|
-
|
|
147
|
+
const err = (0, client_common_1.extractErrorAtTheEndOfChunk)(chunk, exceptionTag);
|
|
148
|
+
this.finishSpan(err);
|
|
149
|
+
controller.error(err);
|
|
150
|
+
return; // stop further processing once the stream is errored
|
|
101
151
|
}
|
|
102
152
|
// using the incomplete chunks from the previous iterations
|
|
103
153
|
if (incompleteChunks.length > 0) {
|
|
@@ -131,7 +181,19 @@ class ResultSet {
|
|
|
131
181
|
}
|
|
132
182
|
}
|
|
133
183
|
},
|
|
134
|
-
|
|
184
|
+
flush: () => {
|
|
185
|
+
// The readable side of the transform completes when the source
|
|
186
|
+
// stream is fully consumed - finalize the query span.
|
|
187
|
+
this.finishSpan();
|
|
188
|
+
},
|
|
189
|
+
cancel: (reason) => {
|
|
190
|
+
// Called when the readable side is cancelled by the consumer, or
|
|
191
|
+
// when the writable side is aborted (e.g. source stream network
|
|
192
|
+
// error). Either way, the span must be properly ended.
|
|
193
|
+
this.finishSpan(reason);
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
const transform = new TransformStream(transformerOptions);
|
|
135
197
|
const pipeline = this._stream.pipeThrough(transform, {
|
|
136
198
|
preventClose: false,
|
|
137
199
|
preventAbort: false,
|
|
@@ -142,6 +204,7 @@ class ResultSet {
|
|
|
142
204
|
async close() {
|
|
143
205
|
this.markAsConsumed();
|
|
144
206
|
await this._stream.cancel();
|
|
207
|
+
this.finishSpan();
|
|
145
208
|
}
|
|
146
209
|
/**
|
|
147
210
|
* Closes the `ResultSet`.
|
|
@@ -159,7 +222,41 @@ class ResultSet {
|
|
|
159
222
|
}
|
|
160
223
|
this.isAlreadyConsumed = true;
|
|
161
224
|
}
|
|
225
|
+
/** Add the number of rows decoded from the response stream. */
|
|
226
|
+
addSpanRows(count) {
|
|
227
|
+
this.span_rows_counted = true;
|
|
228
|
+
this.span_rows += count;
|
|
229
|
+
}
|
|
230
|
+
/** Record the final response metrics (`clickhouse.response.decoded_bytes`,
|
|
231
|
+
* `clickhouse.response.text_length` when called from {@link text}, and
|
|
232
|
+
* `db.response.returned_rows` when rows were counted) and the error
|
|
233
|
+
* (if any) on the span, and end it. Safe to call multiple times - only
|
|
234
|
+
* the first call wins. */
|
|
235
|
+
finishSpan(err) {
|
|
236
|
+
if (this.span === undefined || this.span_finished) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
this.span_finished = true;
|
|
240
|
+
const attributes = {};
|
|
241
|
+
if (this.span_text_length !== undefined) {
|
|
242
|
+
// Recorded by text(): UTF-16 code-unit count, not a byte count.
|
|
243
|
+
attributes["clickhouse.response.text_length"] = this.span_text_length;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
// Recorded by stream() / json() streamable path: actual decoded bytes
|
|
247
|
+
// accumulated from raw Uint8Array chunks.
|
|
248
|
+
attributes["clickhouse.response.decoded_bytes"] = this.span_bytes;
|
|
249
|
+
}
|
|
250
|
+
if (this.span_rows_counted) {
|
|
251
|
+
attributes["db.response.returned_rows"] = this.span_rows;
|
|
252
|
+
}
|
|
253
|
+
this.span.setAttributes(attributes);
|
|
254
|
+
if (err !== undefined && err !== null) {
|
|
255
|
+
(0, client_common_1.recordSpanError)(this.span, err);
|
|
256
|
+
}
|
|
257
|
+
this.span.end();
|
|
258
|
+
}
|
|
162
259
|
}
|
|
163
260
|
exports.ResultSet = ResultSet;
|
|
164
|
-
const streamAlreadyConsumedMessage =
|
|
261
|
+
const streamAlreadyConsumedMessage = "Stream has been already consumed";
|
|
165
262
|
//# sourceMappingURL=result_set.js.map
|
package/dist/result_set.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result_set.js","sourceRoot":"","sources":["../src/result_set.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"result_set.js","sourceRoot":"","sources":["../src/result_set.ts"],"names":[],"mappings":";;;AAWA,6DAImC;AACnC,6DAImC;AACnC,mCAAoC;AAEpC,MAAM,OAAO,GAAG,IAAa,CAAC;AAS9B,MAAa,SAAS;IAGJ,gBAAgB,CAAkB;IAEjC,YAAY,GAAuB,SA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,aAAa,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACtC,IAAA,+BAAe,EAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IAClB,CAAC;CACF;AA/RD,8BA+RC;AAED,MAAM,4BAA4B,GAAG,kCAAkC,CAAC"}
|
package/dist/utils/encoder.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DataFormat, InsertValues, ValuesEncoder } from
|
|
2
|
-
import { type JSONHandling } from
|
|
1
|
+
import type { DataFormat, InsertValues, ValuesEncoder } from "@clickhouse/client-common";
|
|
2
|
+
import { type JSONHandling } from "@clickhouse/client-common";
|
|
3
3
|
export declare class WebValuesEncoder implements ValuesEncoder<ReadableStream> {
|
|
4
4
|
private readonly json;
|
|
5
5
|
constructor(jsonHandling?: JSONHandling);
|
package/dist/utils/encoder.js
CHANGED
|
@@ -17,17 +17,17 @@ class WebValuesEncoder {
|
|
|
17
17
|
if (Array.isArray(values)) {
|
|
18
18
|
return values
|
|
19
19
|
.map((value) => (0, client_common_1.encodeJSON)(value, format, this.json.stringify))
|
|
20
|
-
.join(
|
|
20
|
+
.join("");
|
|
21
21
|
}
|
|
22
22
|
// JSON & JSONObjectEachRow format input
|
|
23
|
-
if (typeof values ===
|
|
23
|
+
if (typeof values === "object") {
|
|
24
24
|
return (0, client_common_1.encodeJSON)(values, format, this.json.stringify);
|
|
25
25
|
}
|
|
26
26
|
throw new Error(`Cannot encode values of type ${typeof values} with ${format} format`);
|
|
27
27
|
}
|
|
28
28
|
validateInsertValues(values) {
|
|
29
29
|
throwIfStream(values);
|
|
30
|
-
if (!Array.isArray(values) && typeof values !==
|
|
30
|
+
if (!Array.isArray(values) && typeof values !== "object") {
|
|
31
31
|
throw new Error('Insert expected "values" to be an array or a JSON object, ' +
|
|
32
32
|
`got: ${typeof values}`);
|
|
33
33
|
}
|
|
@@ -36,7 +36,7 @@ class WebValuesEncoder {
|
|
|
36
36
|
exports.WebValuesEncoder = WebValuesEncoder;
|
|
37
37
|
function throwIfStream(values) {
|
|
38
38
|
if ((0, stream_1.isStream)(values)) {
|
|
39
|
-
throw new Error(
|
|
39
|
+
throw new Error("Streaming is not supported for inserts in the web version of the client");
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
//# sourceMappingURL=encoder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/utils/encoder.ts"],"names":[],"mappings":";;;AAKA,
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/utils/encoder.ts"],"names":[],"mappings":";;;AAKA,6DAA0E;AAC1E,qCAAoC;AAEpC,MAAa,gBAAgB;IACV,IAAI,CAAe;IAEpC,YACE,eAA6B;QAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B;QAED,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;IAED,YAAY,CACV,MAAuB,EACvB,MAAkB;QAElB,aAAa,CAAC,MAAM,CAAC,CAAC;QACtB,eAAe;QACf,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,MAAM;iBACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,0BAAU,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBAC9D,IAAI,CAAC,EAAE,CAAC,CAAC;QACd,CAAC;QACD,wCAAwC;QACxC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,IAAA,0BAAU,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,gCAAgC,OAAO,MAAM,SAAS,MAAM,SAAS,CACtE,CAAC;IACJ,CAAC;IAED,oBAAoB,CAAc,MAAuB;QACvD,aAAa,CAAC,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CACb,4DAA4D;gBAC1D,QAAQ,OAAO,MAAM,EAAE,CAC1B,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAzCD,4CAyCC;AAED,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,IAAA,iBAAQ,EAAC,MAAM,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./stream";
|
|
2
|
+
export * from "./encoder";
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B"}
|
package/dist/utils/stream.js
CHANGED
|
@@ -5,10 +5,10 @@ exports.getAsText = getAsText;
|
|
|
5
5
|
// See https://github.com/v8/v8/commit/ea56bf5513d0cbd2a35a9035c5c2996272b8b728
|
|
6
6
|
const MaxStringLength = Math.pow(2, 29) - 24;
|
|
7
7
|
function isStream(obj) {
|
|
8
|
-
return (obj !== null && obj !== undefined && typeof obj.pipeThrough ===
|
|
8
|
+
return (obj !== null && obj !== undefined && typeof obj.pipeThrough === "function");
|
|
9
9
|
}
|
|
10
10
|
async function getAsText(stream) {
|
|
11
|
-
let text =
|
|
11
|
+
let text = "";
|
|
12
12
|
const textDecoder = new TextDecoder();
|
|
13
13
|
const reader = stream.getReader();
|
|
14
14
|
while (true) {
|
|
@@ -21,7 +21,7 @@ async function getAsText(stream) {
|
|
|
21
21
|
// in tests. Somehow using manual length checks seems to be the only way to reliably
|
|
22
22
|
// detect this condition across browsers.
|
|
23
23
|
// Also, Vitest crashes while running the try/catch implementatioin in Firefox.
|
|
24
|
-
throw new Error(
|
|
24
|
+
throw new Error("The response length exceeds the maximum allowed size of V8 String: " +
|
|
25
25
|
`${MaxStringLength}; consider limiting the amount of requested rows.`);
|
|
26
26
|
}
|
|
27
27
|
text += decoded;
|
|
@@ -31,7 +31,7 @@ async function getAsText(stream) {
|
|
|
31
31
|
// flush unfinished multi-byte characters
|
|
32
32
|
const decoded = textDecoder.decode();
|
|
33
33
|
if (decoded.length + text.length > MaxStringLength) {
|
|
34
|
-
throw new Error(
|
|
34
|
+
throw new Error("The response length exceeds the maximum allowed size of V8 String: " +
|
|
35
35
|
`${MaxStringLength}; consider limiting the amount of requested rows.`);
|
|
36
36
|
}
|
|
37
37
|
text += decoded;
|
package/dist/utils/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":";;AAGA,4BAIC;AAED,8BAoCC;AA7CD,+EAA+E;AAC/E,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/utils/stream.ts"],"names":[],"mappings":";;AAGA,4BAIC;AAED,8BAoCC;AA7CD,+EAA+E;AAC/E,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,CAA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|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.21.0";
|
|
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,QAAQ,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;AAAA,kBAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@clickhouse/client-web",
|
|
3
3
|
"description": "Official JS client for ClickHouse DB - Web API implementation",
|
|
4
4
|
"homepage": "https://clickhouse.com",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.21.0",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"clickhouse",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"build": "rm -rf dist; tsc"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@clickhouse/client-common": "1.
|
|
34
|
+
"@clickhouse/client-common": "1.21.0"
|
|
35
35
|
}
|
|
36
36
|
}
|