Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clickhouse/client-web

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clickhouse/client-web - npm Package Compare versions

Comparing version 0.3.1 to 1.0.0

dist/config.d.ts

26

dist/client.d.ts

@@ -1,15 +0,23 @@

import type { BaseClickHouseClientConfigOptions, BaseResultSet, InputJSON, InputJSONObjectEachRow, InsertParams, InsertResult, QueryParams, Row } from '@clickhouse/client-common';
import type { DataFormat, InputJSON, InputJSONObjectEachRow, InsertParams, InsertResult, IsSame, QueryParamsWithFormat } from '@clickhouse/client-common';
import { ClickHouseClient } from '@clickhouse/client-common';
export type WebClickHouseClientConfigOptions = BaseClickHouseClientConfigOptions<ReadableStream> & {
keep_alive?: {
/** Enable or disable HTTP Keep-Alive mechanism. Default: true */
enabled: boolean;
};
};
export type WebClickHouseClient = Omit<ClickHouseClient<ReadableStream>, 'insert' | 'query'> & {
import type { WebClickHouseClientConfigOptions } from './config';
import type { ResultSet } from './result_set';
/** If the Format is not a literal type, fall back to the default behavior of the ResultSet,
* allowing to call all methods with all data shapes variants,
* and avoiding generated types that include all possible DataFormat literal values. */
export type QueryResult<Format extends DataFormat> = IsSame<Format, DataFormat> extends true ? ResultSet<unknown> : ResultSet<Format>;
export type WebClickHouseClient = Omit<WebClickHouseClientImpl, 'insert'> & {
/** See {@link ClickHouseClient.insert}.
*
* ReadableStream is removed from possible insert values
* until it is supported by all major web platforms. */
insert<T>(params: Omit<InsertParams<ReadableStream, T>, 'values'> & {
values: ReadonlyArray<T> | InputJSON<T> | InputJSONObjectEachRow<T>;
}): Promise<InsertResult>;
query(params: QueryParams): Promise<BaseResultSet<ReadableStream<Row[]>>>;
};
declare class WebClickHouseClientImpl extends ClickHouseClient<ReadableStream> {
/** See {@link ClickHouseClient.query}. */
query<Format extends DataFormat>(params: QueryParamsWithFormat<Format>): Promise<QueryResult<Format>>;
}
export declare function createClient(config?: WebClickHouseClientConfigOptions): WebClickHouseClient;
export {};

@@ -5,16 +5,12 @@ "use strict";

const client_common_1 = require("@clickhouse/client-common");
const connection_1 = require("./connection");
const result_set_1 = require("./result_set");
const utils_1 = require("./utils");
const config_1 = require("./config");
class WebClickHouseClientImpl extends client_common_1.ClickHouseClient {
/** See {@link ClickHouseClient.query}. */
query(params) {
return super.query(params);
}
}
function createClient(config) {
const keep_alive = {
enabled: config?.keep_alive?.enabled ?? true,
};
return new client_common_1.ClickHouseClient({
impl: {
make_connection: (params) => new connection_1.WebConnection({ ...params, keep_alive }),
make_result_set: (stream, format, query_id) => new result_set_1.ResultSet(stream, format, query_id),
values_encoder: new utils_1.WebValuesEncoder(),
close_stream: (stream) => stream.cancel(),
},
return new WebClickHouseClientImpl({
impl: config_1.WebImpl,
...(config || {}),

@@ -21,0 +17,0 @@ });

@@ -5,7 +5,3 @@ import type { ConnBaseQueryParams, Connection, ConnectionParams, ConnInsertParams, ConnInsertResult, ConnPingResult, ConnQueryResult } from '@clickhouse/client-common';

};
export type WebConnectionParams = ConnectionParams & {
keep_alive: {
enabled: boolean;
};
};
export type WebConnectionParams = ConnectionParams;
export declare class WebConnection implements Connection<ReadableStream> {

@@ -12,0 +8,0 @@ private readonly params;

@@ -22,3 +22,3 @@ "use strict";

Authorization: `Basic ${btoa(`${params.username}:${params.password}`)}`,
...params?.additional_headers,
...params?.http_headers,
};

@@ -25,0 +25,0 @@ }

@@ -0,4 +1,6 @@

export type { WebClickHouseClient as ClickHouseClient, QueryResult, } from './client';
export { createClient } from './client';
export { type WebClickHouseClientConfigOptions as ClickHouseClientConfigOptions } from './config';
export { ResultSet } from './result_set';
/** Re-export @clickhouse/client-common types */
export { type BaseClickHouseClientConfigOptions, type ClickHouseClientConfigOptions, type BaseQueryParams, type QueryParams, type ExecParams, type InsertParams, type InsertValues, type CommandParams, type CommandResult, type ExecResult, type InsertResult, type DataFormat, type Logger, type LogParams, type ErrorLogParams, type WarnLogParams, type ClickHouseSettings, type MergeTreeSettings, type Row, type ResponseJSON, type InputJSON, type InputJSONObjectEachRow, type BaseResultSet, type PingResult, ClickHouseError, ClickHouseLogLevel, ClickHouseClient, SettingsMap, } from '@clickhouse/client-common';
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, ClickHouseError, ClickHouseLogLevel, SettingsMap, } from '@clickhouse/client-common';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SettingsMap = exports.ClickHouseClient = exports.ClickHouseLogLevel = exports.ClickHouseError = exports.ResultSet = exports.createClient = void 0;
exports.SettingsMap = exports.ClickHouseLogLevel = exports.ClickHouseError = exports.ResultSet = exports.createClient = void 0;
var client_1 = require("./client");

@@ -12,4 +12,3 @@ Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });

Object.defineProperty(exports, "ClickHouseLogLevel", { enumerable: true, get: function () { return client_common_1.ClickHouseLogLevel; } });
Object.defineProperty(exports, "ClickHouseClient", { enumerable: true, get: function () { return client_common_1.ClickHouseClient; } });
Object.defineProperty(exports, "SettingsMap", { enumerable: true, get: function () { return client_common_1.SettingsMap; } });
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import type { BaseResultSet, DataFormat, Row } from '@clickhouse/client-common';
export declare class ResultSet implements BaseResultSet<ReadableStream<Row[]>> {
import type { BaseResultSet, DataFormat, ResultJSONType, ResultStream, Row } from '@clickhouse/client-common';
export declare class ResultSet<Format extends DataFormat | unknown> implements BaseResultSet<ReadableStream<Row[]>, Format> {
private _stream;

@@ -7,8 +7,11 @@ private readonly format;

private isAlreadyConsumed;
constructor(_stream: ReadableStream, format: DataFormat, query_id: string);
constructor(_stream: ReadableStream, format: Format, query_id: string);
/** See {@link BaseResultSet.text} */
text(): Promise<string>;
json<T>(): Promise<T>;
stream(): ReadableStream<Row[]>;
/** See {@link BaseResultSet.json} */
json<T>(): Promise<ResultJSONType<T, Format>>;
/** See {@link BaseResultSet.stream} */
stream<T>(): ResultStream<Format, ReadableStream<Row<T, Format>[]>>;
close(): Promise<void>;
private markAsConsumed;
}

@@ -5,2 +5,3 @@ "use strict";

const client_common_1 = require("@clickhouse/client-common");
const client_common_2 = require("@clickhouse/client-common");
const utils_1 = require("./utils");

@@ -34,2 +35,3 @@ class ResultSet {

}
/** See {@link BaseResultSet.text} */
async text() {

@@ -39,9 +41,32 @@ this.markAsConsumed();

}
/** See {@link BaseResultSet.json} */
async json() {
const text = await this.text();
return (0, client_common_1.decode)(text, this.format);
// JSONEachRow, etc.
if ((0, client_common_1.isStreamableJSONFamily)(this.format)) {
const result = [];
const reader = this.stream().getReader();
// eslint-disable-next-line no-constant-condition
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
for (const row of value) {
result.push(row.json());
}
}
return result;
}
// JSON, JSONObjectEachRow, etc.
if ((0, client_common_1.isNotStreamableJSONFamily)(this.format)) {
const text = await (0, utils_1.getAsText)(this._stream);
return JSON.parse(text);
}
// should not be called for CSV, etc.
throw new Error(`Cannot decode ${this.format} as JSON`);
}
/** See {@link BaseResultSet.stream} */
stream() {
this.markAsConsumed();
(0, client_common_1.validateStreamFormat)(this.format);
(0, client_common_2.validateStreamFormat)(this.format);
let decodedChunk = '';

@@ -68,3 +93,3 @@ const decoder = new TextDecoder('utf-8');

json() {
return (0, client_common_1.decode)(text, 'JSON');
return JSON.parse(text);
},

@@ -85,3 +110,3 @@ });

});
return this._stream.pipeThrough(transform, {
const pipeline = this._stream.pipeThrough(transform, {
preventClose: false,

@@ -91,2 +116,3 @@ preventAbort: false,

});
return pipeline;
}

@@ -93,0 +119,0 @@ async close() {

@@ -1,2 +0,2 @@

declare const _default: "0.3.1";
declare const _default: "1.0.0";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = '0.3.1';
exports.default = '1.0.0';
//# sourceMappingURL=version.js.map

@@ -5,3 +5,3 @@ {

"homepage": "https://clickhouse.com",
"version": "0.3.1",
"version": "1.0.0",
"license": "Apache-2.0",

@@ -24,4 +24,4 @@ "keywords": [

"dependencies": {
"@clickhouse/client-common": "0.3.1"
"@clickhouse/client-common": "1.0.0"
}
}

@@ -7,5 +7,17 @@ <p align="center">

<p align="center">
<a href="https://www.npmjs.com/package/@clickhouse/client">
<img alt="NPM Version" src="https://img.shields.io/npm/v/%40clickhouse%2Fclient?color=%233178C6&logo=npm">
</a>
<a href="https://www.npmjs.com/package/@clickhouse/client">
<img alt="NPM Downloads" src="https://img.shields.io/npm/dw/%40clickhouse%2Fclient?color=%233178C6&logo=npm">
</a>
<a href="https://github.com/ClickHouse/clickhouse-js/actions/workflows/tests.yml">
<img src="https://github.com/ClickHouse/clickhouse-js/actions/workflows/tests.yml/badge.svg?branch=main">
</a>
<img src="https://sonarcloud.io/api/project_badges/measure?project=ClickHouse_clickhouse-js&metric=alert_status">
<img src="https://sonarcloud.io/api/project_badges/measure?project=ClickHouse_clickhouse-js&metric=coverage">
</p>

@@ -12,0 +24,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc