diff --git a/benchmarks/leaks/memory_leak_arrays.ts b/benchmarks/leaks/memory_leak_arrays.ts index d845080b..0b64cfd7 100644 --- a/benchmarks/leaks/memory_leak_arrays.ts +++ b/benchmarks/leaks/memory_leak_arrays.ts @@ -36,7 +36,7 @@ const program = async () => { console.log() console.log( `Batch size: ${BATCH_SIZE}, iterations count: ${ITERATIONS}, ` + - `logging memory usage every ${LOG_INTERVAL} iterations` + `logging memory usage every ${LOG_INTERVAL} iterations`, ) console.log() diff --git a/benchmarks/leaks/memory_leak_brown.ts b/benchmarks/leaks/memory_leak_brown.ts index b346c520..7453f633 100644 --- a/benchmarks/leaks/memory_leak_brown.ts +++ b/benchmarks/leaks/memory_leak_brown.ts @@ -71,7 +71,7 @@ const program = async () => { console.time('insert') const filename = Path.resolve( process.cwd(), - 'benchmarks/leaks/input/mgbench1.csv' + 'benchmarks/leaks/input/mgbench1.csv', ) await client.insert({ table: tableName, diff --git a/benchmarks/leaks/memory_leak_random_integers.ts b/benchmarks/leaks/memory_leak_random_integers.ts index cb875f01..941bb9cf 100644 --- a/benchmarks/leaks/memory_leak_random_integers.ts +++ b/benchmarks/leaks/memory_leak_random_integers.ts @@ -31,7 +31,7 @@ const program = async () => { console.log() console.log( `Batch size: ${BATCH_SIZE}, iterations count: ${ITERATIONS}, ` + - `logging memory usage every ${LOG_INTERVAL} iterations` + `logging memory usage every ${LOG_INTERVAL} iterations`, ) console.log() diff --git a/benchmarks/leaks/shared.ts b/benchmarks/leaks/shared.ts index 1ba7da05..b7cb6629 100644 --- a/benchmarks/leaks/shared.ts +++ b/benchmarks/leaks/shared.ts @@ -47,7 +47,7 @@ export function logMemoryUsageDiff({ const k = key as keyof MemoryUsage const diff = current[k] - previous[k] console.log( - `${k}: ${diff > 0 ? `+${diff.toFixed(2)}` : diff.toFixed(2)} MB` + `${k}: ${diff > 0 ? `+${diff.toFixed(2)}` : diff.toFixed(2)} MB`, ) } } diff --git a/examples/async_insert_without_waiting.ts b/examples/async_insert_without_waiting.ts index cc5df46f..e841d291 100644 --- a/examples/async_insert_without_waiting.ts +++ b/examples/async_insert_without_waiting.ts @@ -102,12 +102,12 @@ void (async () => { 'Rows inserted so far:', `${rowsInserted};`, 'written to the table:', - count + count, ) } catch (err) { console.error( 'Failed to get the number of rows written to the table:', - err + err, ) } }, 1000) diff --git a/examples/node/basic_tls.ts b/examples/node/basic_tls.ts index b9a6b171..4a8b9468 100644 --- a/examples/node/basic_tls.ts +++ b/examples/node/basic_tls.ts @@ -6,7 +6,7 @@ void (async () => { url: 'https://server.clickhouseconnect.test:8443', tls: { ca_cert: fs.readFileSync( - '../.docker/clickhouse/single_node_tls/certificates/ca.crt' + '../.docker/clickhouse/single_node_tls/certificates/ca.crt', ), }, }) diff --git a/examples/node/insert_file_stream_csv.ts b/examples/node/insert_file_stream_csv.ts index 41275205..f7ec798a 100644 --- a/examples/node/insert_file_stream_csv.ts +++ b/examples/node/insert_file_stream_csv.ts @@ -26,6 +26,10 @@ void (async () => { table: tableName, values: Fs.createReadStream(filename), format: 'CSV', + clickhouse_settings: { + /** See also: https://clickhouse.com/docs/en/interfaces/formats#csv-format-settings. + * You could specify these (and other settings) here. */ + }, }) const rs = await client.query({ diff --git a/examples/node/insert_file_stream_ndjson.ts b/examples/node/insert_file_stream_ndjson.ts index 4556a4ae..d0777cdf 100644 --- a/examples/node/insert_file_stream_ndjson.ts +++ b/examples/node/insert_file_stream_ndjson.ts @@ -26,7 +26,7 @@ void (async () => { await client.insert({ table: tableName, values: Fs.createReadStream(filename).pipe( - split((row: string) => JSON.parse(row)) + split((row: string) => JSON.parse(row)), ), format: 'JSONCompactEachRow', }) diff --git a/examples/node/insert_file_stream_parquet.ts b/examples/node/insert_file_stream_parquet.ts index aefb13da..295614bd 100644 --- a/examples/node/insert_file_stream_parquet.ts +++ b/examples/node/insert_file_stream_parquet.ts @@ -4,6 +4,7 @@ import Fs from 'fs' import { cwd } from 'node:process' import Path from 'path' +/** See also: https://clickhouse.com/docs/en/interfaces/formats#parquet-format-settings */ void (async () => { const client = createClient() const tableName = 'insert_file_stream_parquet' @@ -39,6 +40,10 @@ void (async () => { table: tableName, values: Fs.createReadStream(filename), format: 'Parquet', + clickhouse_settings: { + /** See also https://clickhouse.com/docs/en/interfaces/formats#parquet-format-settings. + * You could specify these (and other settings) here. */ + }, }) const rs = await client.query({ diff --git a/examples/node/select_parquet_as_file.ts b/examples/node/select_parquet_as_file.ts index f00dfb10..d8c15914 100644 --- a/examples/node/select_parquet_as_file.ts +++ b/examples/node/select_parquet_as_file.ts @@ -8,6 +8,10 @@ void (async () => { const { stream } = await client.exec({ query: `SELECT * from system.numbers LIMIT 10 FORMAT Parquet`, + clickhouse_settings: { + /** See also https://clickhouse.com/docs/en/interfaces/formats#parquet-format-settings. + * You could specify these (and other settings) here. */ + }, }) const filename = Path.resolve(cwd(), './node/out.parquet') diff --git a/examples/ping.ts b/examples/ping.ts index 5654124d..d159fefe 100644 --- a/examples/ping.ts +++ b/examples/ping.ts @@ -28,7 +28,7 @@ async function existingHostPing() { } else { console.error( '[ExistingHostPing] Ping expected to succeed, but got:', - pingResult + pingResult, ) } await client.close() @@ -46,7 +46,7 @@ async function nonExistingHostPing() { } else { console.error( '[NonExistingHostPing] Ping expected to fail with ECONNREFUSED, but got:', - pingResult + pingResult, ) } await client.close() @@ -70,7 +70,7 @@ async function timeoutPing() { } else { console.error( '[TimeoutPing] Ping expected to fail with a timeout error, but got:', - pingResult + pingResult, ) } await client.close() @@ -87,7 +87,7 @@ function startSlowHTTPServer() { } function hasConnectionRefusedError( - pingResult: PingResult + pingResult: PingResult, ): pingResult is PingResult & { error: { code: 'ECONNREFUSED' } } { return ( !pingResult.success && @@ -97,7 +97,7 @@ function hasConnectionRefusedError( } function hasTimeoutError( - pingResult: PingResult + pingResult: PingResult, ): pingResult is PingResult & { error: Error } { return ( !pingResult.success && diff --git a/examples/read_only_user.ts b/examples/read_only_user.ts index f3399b46..190be6fe 100644 --- a/examples/read_only_user.ts +++ b/examples/read_only_user.ts @@ -33,7 +33,7 @@ void (async () => { }) } console.log( - `Created user ${readOnlyUsername} with restricted access to the system database` + `Created user ${readOnlyUsername} with restricted access to the system database`, ) printSeparator() @@ -79,7 +79,7 @@ void (async () => { .catch((err) => { console.error( '[Expected error] Readonly user cannot insert the data into the table. Cause:\n', - err + err, ) }) printSeparator() @@ -93,7 +93,7 @@ void (async () => { .catch((err) => { console.error( '[Expected error] Cannot query system.users cause it was not granted. Cause:\n', - err + err, ) }) printSeparator() @@ -125,7 +125,7 @@ void (async () => { .catch((err) => { console.error( `[Expected error] Cannot modify 'send_progress_in_http_headers' setting in readonly mode. Cause:\n`, - err + err, ) }) printSeparator() @@ -137,6 +137,6 @@ void (async () => { function printSeparator() { console.log( - '------------------------------------------------------------------------' + '------------------------------------------------------------------------', ) } diff --git a/karma.config.cjs b/karma.config.cjs index 1c5585ca..5c1234d3 100644 --- a/karma.config.cjs +++ b/karma.config.cjs @@ -1,6 +1,6 @@ const webpackConfig = require('./webpack.dev.js') -const TEST_TIMEOUT_MS = 120_000 +const TEST_TIMEOUT_MS = 300_000 module.exports = function (config) { config.set({ diff --git a/package.json b/package.json index 5410af99..9f8c4178 100644 --- a/package.json +++ b/package.json @@ -39,49 +39,49 @@ "test:web:integration:local_cluster": "CLICKHOUSE_TEST_ENVIRONMENT=local_cluster npm run test:web", "test:web:integration:cloud": "CLICKHOUSE_TEST_ENVIRONMENT=cloud npm run test:web", "test:web:integration:cloud_smt": "CLICKHOUSE_TEST_ENVIRONMENT=cloud_smt npm run test:web", - "prepare": "husky install" + "prepare": "husky" }, "devDependencies": { - "@faker-js/faker": "^8.2.0", - "@types/jasmine": "^4.3.2", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.15", - "@types/split2": "^3.2.1", - "@types/uuid": "^9.0.2", - "@typescript-eslint/eslint-plugin": "^5.49.0", - "@typescript-eslint/parser": "^5.49.0", - "apache-arrow": "^14.0.1", - "eslint": "^8.32.0", - "eslint-config-prettier": "^8.6.0", - "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.2", - "jasmine": "^5.0.0", - "jasmine-core": "^5.0.0", + "@faker-js/faker": "^8.4.1", + "@types/jasmine": "^5.1.4", + "@types/node": "^20.11.30", + "@types/sinon": "^17.0.3", + "@types/split2": "^4.2.3", + "@types/uuid": "^9.0.8", + "@typescript-eslint/eslint-plugin": "^7.3.1", + "@typescript-eslint/parser": "^7.3.1", + "apache-arrow": "^15.0.2", + "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", + "husky": "^9.0.11", + "jasmine": "^5.1.0", + "jasmine-core": "^5.1.2", "jasmine-expect": "^5.0.0", - "karma": "^6.4.2", + "karma": "^6.4.3", "karma-chrome-launcher": "^3.2.0", - "karma-firefox-launcher": "^2.1.2", + "karma-firefox-launcher": "^2.1.3", "karma-jasmine": "^5.1.0", "karma-mocha-reporter": "^2.2.5", "karma-sourcemap-loader": "^0.4.0", "karma-typescript": "^5.5.4", - "karma-webpack": "^5.0.0", - "lint-staged": "^13.1.0", - "parquet-wasm": "0.6.0-beta.1", - "prettier": "2.8.3", - "sinon": "^15.2.0", - "split2": "^4.1.0", - "terser-webpack-plugin": "^5.3.9", - "ts-jest": "^29.1.0", - "ts-loader": "^9.4.3", - "ts-node": "^10.9.1", + "karma-webpack": "^5.0.1", + "lint-staged": "^15.2.2", + "parquet-wasm": "0.6.0-beta.2", + "prettier": "3.2.5", + "sinon": "^17.0.1", + "split2": "^4.2.0", + "terser-webpack-plugin": "^5.3.10", + "ts-jest": "^29.1.2", + "ts-loader": "^9.5.1", + "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", - "tsconfig-paths-webpack-plugin": "^4.0.1", - "typescript": "^4.9.4", - "uuid": "^9.0.0", - "webpack": "^5.84.1", + "tsconfig-paths-webpack-plugin": "^4.1.0", + "typescript": "^5.4.3", + "uuid": "^9.0.1", + "webpack": "^5.91.0", "webpack-cli": "^5.1.4", - "webpack-merge": "^5.9.0" + "webpack-merge": "^5.10.0" }, "workspaces": [ "./packages/*" diff --git a/packages/client-common/__tests__/fixtures/read_only_user.ts b/packages/client-common/__tests__/fixtures/read_only_user.ts index 5a5fb772..bcb07a9a 100644 --- a/packages/client-common/__tests__/fixtures/read_only_user.ts +++ b/packages/client-common/__tests__/fixtures/read_only_user.ts @@ -69,7 +69,7 @@ export async function createReadOnlyUser(client: ClickHouseClient) { } console.log( `Created user ${username} with default database ${database} ` + - 'and restricted access to the system database' + 'and restricted access to the system database', ) return { diff --git a/packages/client-common/__tests__/fixtures/simple_table.ts b/packages/client-common/__tests__/fixtures/simple_table.ts index baec5e23..e9894413 100644 --- a/packages/client-common/__tests__/fixtures/simple_table.ts +++ b/packages/client-common/__tests__/fixtures/simple_table.ts @@ -7,7 +7,7 @@ import { createTable, TestEnv } from '../utils' export function createSimpleTable( client: ClickHouseClient, tableName: string, - settings: MergeTreeSettings = {} + settings: MergeTreeSettings = {}, ) { return createTable(client, (env) => { const filteredSettings = filterSettingsBasedOnEnv(settings, env) diff --git a/packages/client-common/__tests__/fixtures/table_with_fields.ts b/packages/client-common/__tests__/fixtures/table_with_fields.ts index bd19dcbd..d19054cd 100644 --- a/packages/client-common/__tests__/fixtures/table_with_fields.ts +++ b/packages/client-common/__tests__/fixtures/table_with_fields.ts @@ -7,7 +7,7 @@ import { createTable, guid, TestEnv } from '../utils' export async function createTableWithFields( client: ClickHouseClient, fields: string, - clickhouse_settings?: ClickHouseSettings + clickhouse_settings?: ClickHouseSettings, ): Promise { const tableName = `test_table__${guid()}` await createTable( @@ -42,7 +42,7 @@ export async function createTableWithFields( ` } }, - clickhouse_settings + clickhouse_settings, ) return tableName } diff --git a/packages/client-common/__tests__/fixtures/test_data.ts b/packages/client-common/__tests__/fixtures/test_data.ts index 448201b1..4d0683a2 100644 --- a/packages/client-common/__tests__/fixtures/test_data.ts +++ b/packages/client-common/__tests__/fixtures/test_data.ts @@ -10,7 +10,7 @@ export const jsonValues = [ export async function assertJsonValues( client: ClickHouseClient, - tableName: string + tableName: string, ) { const result = await client .query({ diff --git a/packages/client-common/__tests__/integration/abort_request.test.ts b/packages/client-common/__tests__/integration/abort_request.test.ts index 268dabcb..0b4d0126 100644 --- a/packages/client-common/__tests__/integration/abort_request.test.ts +++ b/packages/client-common/__tests__/integration/abort_request.test.ts @@ -25,7 +25,7 @@ describe('abort request', () => { await expectAsync(selectPromise).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching('The user aborted a request'), - }) + }), ) }) @@ -47,7 +47,7 @@ describe('abort request', () => { await expectAsync(selectPromise).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching('The user aborted a request'), - }) + }), ) }) @@ -71,7 +71,7 @@ describe('abort request', () => { await expectAsync(selectPromise).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching('The user aborted a request'), - }) + }), ) }) @@ -106,7 +106,7 @@ describe('abort request', () => { queries.every((q) => { console.log(`${q.query} VS ${longRunningQuery}`) return !q.query.includes(longRunningQuery) - }) + }), ) }) @@ -136,7 +136,7 @@ describe('abort request', () => { }) } return requestPromise - }) + }), ) controller.abort() @@ -149,7 +149,7 @@ describe('abort request', () => { async function assertActiveQueries( client: ClickHouseClient, - assertQueries: (queries: Array<{ query: string }>) => boolean + assertQueries: (queries: Array<{ query: string }>) => boolean, ) { let isRunning = true while (isRunning) { diff --git a/packages/client-common/__tests__/integration/auth.test.ts b/packages/client-common/__tests__/integration/auth.test.ts index 0c350cf0..3a734cc3 100644 --- a/packages/client-common/__tests__/integration/auth.test.ts +++ b/packages/client-common/__tests__/integration/auth.test.ts @@ -16,13 +16,13 @@ describe('authentication', () => { await expectAsync( client.query({ query: 'SELECT number FROM system.numbers LIMIT 3', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ code: '516', type: 'AUTHENTICATION_FAILED', message: jasmine.stringMatching('Authentication failed'), - }) + }), ) }) }) diff --git a/packages/client-common/__tests__/integration/clickhouse_settings.test.ts b/packages/client-common/__tests__/integration/clickhouse_settings.test.ts index 2fee6caf..1f89f5b6 100644 --- a/packages/client-common/__tests__/integration/clickhouse_settings.test.ts +++ b/packages/client-common/__tests__/integration/clickhouse_settings.test.ts @@ -72,7 +72,7 @@ describe('ClickHouse settings', () => { query: `SELECT * FROM ${tableName}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([ { id: '1', name: 'foobar', sku: [1, 2] }, { id: '1', name: 'foobar', sku: [1, 2] }, diff --git a/packages/client-common/__tests__/integration/config.test.ts b/packages/client-common/__tests__/integration/config.test.ts index 3bad6c3d..606c50e6 100644 --- a/packages/client-common/__tests__/integration/config.test.ts +++ b/packages/client-common/__tests__/integration/config.test.ts @@ -16,11 +16,11 @@ describe('config', () => { await expectAsync( client.query({ query: 'SELECT sleep(3)', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching('Timeout error.'), - }) + }), ) }) diff --git a/packages/client-common/__tests__/integration/data_types.test.ts b/packages/client-common/__tests__/integration/data_types.test.ts index d194a6e9..020c21ad 100644 --- a/packages/client-common/__tests__/integration/data_types.test.ts +++ b/packages/client-common/__tests__/integration/data_types.test.ts @@ -49,7 +49,7 @@ describe('data types', () => { const table = await createTableWithFields( client, 'u1 UInt8, u2 UInt16, u3 UInt32, u4 UInt64, u5 UInt128, u6 UInt256, ' + - 'i1 Int8, i2 Int16, i3 Int32, i4 Int64, i5 Int128, i6 Int256' + 'i1 Int8, i2 Int16, i3 Int32, i4 Int64, i5 Int128, i6 Int256', ) await insertAndAssert(table, values) }) @@ -76,7 +76,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - 's String, fs FixedString(3)' + 's String, fs FixedString(3)', ) await insertAndAssert(table, values) }) @@ -88,11 +88,11 @@ describe('data types', () => { table, values: [{ fs: 'foobar' }], format: 'JSONEachRow', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Too large value for FixedString(3)'), - }) + }), ) }) @@ -120,7 +120,7 @@ describe('data types', () => { const table = await createTableWithFields( client, 'd1 Decimal(9, 2), d2 Decimal(18, 3), ' + - 'd3 Decimal(38, 10), d4 Decimal(76, 20)' + 'd3 Decimal(38, 10), d4 Decimal(76, 20)', ) await client.insert({ table, @@ -165,7 +165,7 @@ describe('data types', () => { const table = await createTableWithFields( client, 'd1 Date, d2 Date32, dt1 DateTime, ' + - 'dt2 DateTime64(3), dt3 DateTime64(6), dt4 DateTime64(9)' + 'dt2 DateTime64(3), dt3 DateTime64(6), dt4 DateTime64(9)', ) await insertAndAssert(table, values) }) @@ -204,7 +204,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - 'dt1 DateTime, dt2 DateTime64(3), dt3 DateTime64(6), dt4 DateTime64(9)' + 'dt1 DateTime, dt2 DateTime64(3), dt3 DateTime64(6), dt4 DateTime64(9)', ) await insertData(table, values, { // Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z') @@ -221,7 +221,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - `e1 Enum('Foo', 'Bar'), e2 Enum('Qaz', 'Qux')` + `e1 Enum('Foo', 'Bar'), e2 Enum('Qaz', 'Qux')`, ) await insertAndAssert(table, values) }) @@ -233,7 +233,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - `e1 Enum('Foo' = 42, 'Bar' = 43), e2 Enum('Qaz' = 100, 'Qux' = 127)` + `e1 Enum('Foo' = 42, 'Bar' = 43), e2 Enum('Qaz' = 100, 'Qux' = 127)`, ) await insertData(table, values) const result = await client @@ -258,7 +258,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - 's LowCardinality(String), fs LowCardinality(FixedString(3))' + 's LowCardinality(String), fs LowCardinality(FixedString(3))', ) await insertAndAssert(table, values) }) @@ -270,7 +270,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - 't1 Tuple(String, Int32), t2 Tuple(Date, Array(Int32))' + 't1 Tuple(String, Int32), t2 Tuple(Date, Array(Int32))', ) await insertAndAssert(table, values) }) @@ -282,7 +282,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - 's Nullable(String), i Nullable(Int32), a Array(Nullable(Int32))' + 's Nullable(String), i Nullable(Int32), a Array(Nullable(Int32))', ) await insertAndAssert(table, values) }) @@ -313,7 +313,7 @@ describe('data types', () => { function genNestedArray(level: number): unknown { if (level === 1) { return [...Array(getRandomInt(2, 4))].map(() => - Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2), ) } return [...Array(getRandomInt(1, 3))].map(() => genNestedArray(level - 1)) @@ -371,12 +371,12 @@ describe('data types', () => { if (level === 1) { ;[...Array(getRandomInt(2, 4))].forEach( () => - (obj[getRandomInt(1, 1000)] = Math.random().toString(36).slice(2)) + (obj[getRandomInt(1, 1000)] = Math.random().toString(36).slice(2)), ) return obj } ;[...Array(getRandomInt(1, 3))].forEach( - () => (obj[getRandomInt(1, 1000)] = genNestedMap(level - 1)) + () => (obj[getRandomInt(1, 1000)] = genNestedMap(level - 1)), ) return obj } @@ -403,7 +403,7 @@ describe('data types', () => { const table = await createTableWithFields( client, 'm1 Map(String, String), m2 Map(Int32, Int64), ' + - `m3 ${genMapType(maxNestingLevel)}` + `m3 ${genMapType(maxNestingLevel)}`, ) await insertAndAssert(table, values) }) @@ -416,7 +416,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - `route Int32, distance Decimal(10, 2)` + `route Int32, distance Decimal(10, 2)`, ) await client.insert({ table, @@ -429,7 +429,7 @@ describe('data types', () => { query: `SELECT sum(distance) FROM ${table}`, format: 'TabSeparated', }) - .then((r) => r.text()) + .then((r) => r.text()), ).toEqual('125.53\n') expect( await client @@ -437,7 +437,7 @@ describe('data types', () => { query: `SELECT max(distance) FROM ${table}`, format: 'TabSeparated', }) - .then((r) => r.text()) + .then((r) => r.text()), ).toEqual('100.52\n') expect( await client @@ -445,7 +445,7 @@ describe('data types', () => { query: `SELECT uniqExact(distance) FROM ${table}`, format: 'TabSeparated', }) - .then((r) => r.text()) + .then((r) => r.text()), ).toEqual('3\n') }) @@ -499,7 +499,7 @@ describe('data types', () => { ] const table = await createTableWithFields( client, - 'p Point, r Ring, pg Polygon, mpg MultiPolygon' + 'p Point, r Ring, pg Polygon, mpg MultiPolygon', ) await insertAndAssert(table, values) }) @@ -520,7 +520,7 @@ describe('data types', () => { allow_experimental_object_type: 1, }) await insertAndAssert(table, values) - } + }, ) describe('Nested', () => { @@ -598,7 +598,7 @@ describe('data types', () => { {}, { input_format_import_nested_json: 1, - } + }, ) }) @@ -632,20 +632,20 @@ describe('data types', () => { { flatten_nested: 0 }, { input_format_import_nested_json: 1, - } + }, ) }) async function insertAndAssertNestedValues( values: unknown[], createTableSettings: ClickHouseSettings, - insertSettings: ClickHouseSettings + insertSettings: ClickHouseSettings, ) { const table = await createTableWithFields( client, 'n Nested(id UInt32, name String, createdAt DateTime, ' + `roles Array(Enum('User', 'Admin')))`, - createTableSettings + createTableSettings, ) await client.insert({ table, @@ -679,7 +679,7 @@ describe('data types', () => { async function insertData( table: string, data: T[], - clickhouse_settings?: ClickHouseSettings + clickhouse_settings?: ClickHouseSettings, ) { const values = data.map((v, i) => ({ ...v, id: i + 1 })) await client.insert({ diff --git a/packages/client-common/__tests__/integration/date_time.test.ts b/packages/client-common/__tests__/integration/date_time.test.ts index 1ab5a25c..84c8a13d 100644 --- a/packages/client-common/__tests__/integration/date_time.test.ts +++ b/packages/client-common/__tests__/integration/date_time.test.ts @@ -28,7 +28,7 @@ describe('DateTime', () => { query: `SELECT * EXCEPT id FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([{ d: '2022-09-05' }]) }) }) @@ -50,7 +50,7 @@ describe('DateTime', () => { query: `SELECT * EXCEPT id FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([{ d: '2022-09-05' }]) }) }) @@ -73,7 +73,7 @@ describe('DateTime', () => { query: `SELECT d FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([ { d: '2022-09-04 22:02:49' }, // converted to UTC on the server { d: '2022-09-05 00:02:49' }, // this one was assumed UTC upon insertion @@ -87,14 +87,14 @@ describe('DateTime', () => { query: `SELECT toDateTime(d, 'Europe/Amsterdam') AS d FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([{ d: '2022-09-05 00:02:49' }, { d: '2022-09-05 02:02:49' }]) }) it('should insert DateTime and get it back (different timezone)', async () => { const table = await createTableWithFields( client, - `d DateTime('Asia/Istanbul')` + `d DateTime('Asia/Istanbul')`, ) await client.insert({ table, @@ -111,7 +111,7 @@ describe('DateTime', () => { query: `SELECT * EXCEPT id FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([ { d: '2022-09-05 01:02:49' }, // converted to Asia/Istanbul on the server { d: '2022-09-05 00:02:49' }, // this one was assumed Asia/Istanbul upon insertion @@ -125,7 +125,7 @@ describe('DateTime', () => { query: `SELECT toDateTime(d, 'Europe/Amsterdam') AS d FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([{ d: '2022-09-05 00:02:49' }, { d: '2022-09-04 23:02:49' }]) }) }) @@ -148,7 +148,7 @@ describe('DateTime', () => { query: `SELECT * EXCEPT id FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([ { d: '2022-09-04 22:02:49.123' }, // converted to UTC on the server { d: '2022-09-05 00:02:49.456' }, // this one was assumed UTC upon insertion @@ -162,7 +162,7 @@ describe('DateTime', () => { query: `SELECT toDateTime64(d, 3, 'Europe/Amsterdam') AS d FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([ { d: '2022-09-05 00:02:49.123' }, { d: '2022-09-05 02:02:49.456' }, @@ -172,7 +172,7 @@ describe('DateTime', () => { it('should insert DateTime64(3) and get it back (different timezone)', async () => { const table = await createTableWithFields( client, - `d DateTime64(3, 'Asia/Istanbul')` + `d DateTime64(3, 'Asia/Istanbul')`, ) await client.insert({ table, @@ -189,7 +189,7 @@ describe('DateTime', () => { query: `SELECT * EXCEPT id FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([ { d: '2022-09-05 01:02:49.123' }, // converted to Asia/Istanbul on the server { d: '2022-09-05 00:02:49.456' }, // this one was assumed Asia/Istanbul upon insertion @@ -203,7 +203,7 @@ describe('DateTime', () => { query: `SELECT toDateTime64(d, 3, 'Europe/Amsterdam') AS d FROM ${table}`, format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([ { d: '2022-09-05 00:02:49.123' }, { d: '2022-09-04 23:02:49.456' }, diff --git a/packages/client-common/__tests__/integration/error_parsing.test.ts b/packages/client-common/__tests__/integration/error_parsing.test.ts index 612bfa5a..a52b2db8 100644 --- a/packages/client-common/__tests__/integration/error_parsing.test.ts +++ b/packages/client-common/__tests__/integration/error_parsing.test.ts @@ -11,34 +11,44 @@ describe('ClickHouse server errors parsing', () => { }) it('returns "unknown identifier" error', async () => { + // possible error messages here: + // On-premise: Missing columns: 'number' while processing query: 'SELECT number AS FR', required columns: 'number'. + // Cloud SMT: Unknown expression identifier 'number' in scope + const errorMessagePattern = + `((?:^Missing columns: 'number' while processing query: 'SELECT number AS FR', required columns: 'number'.*$)|` + + `(?:^Unknown expression identifier 'number' in scope.*$))` await expectAsync( client.query({ query: 'SELECT number FR', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ - message: `Missing columns: 'number' while processing query: 'SELECT number AS FR', required columns: 'number'. `, + message: jasmine.stringMatching(errorMessagePattern), code: '47', type: 'UNKNOWN_IDENTIFIER', - }) + }), ) }) it('returns "unknown table" error', async () => { // possible error messages here: - // (since 23.8+) Table foo.unknown_table does not exist. - // (pre-23.8) Table foo.unknown_table doesn't exist. - const errorMessagePattern = `^Table ${getTestDatabaseName()}.unknown_table does(n't| not) exist.*$` + // (since 23.8+): Table foo.unknown_table does not exist. + // (pre-23.8): Table foo.unknown_table doesn't exist. + // Cloud SMT: Unknown table expression identifier 'unknown_table' in scope + const dbName = getTestDatabaseName() + const errorMessagePattern = + `((?:^Table ${dbName}.unknown_table does(n't| not) exist.*)|` + + `(?:Unknown table expression identifier 'unknown_table' in scope))` await expectAsync( client.query({ query: 'SELECT * FROM unknown_table', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching(errorMessagePattern), code: '60', type: 'UNKNOWN_TABLE', - }) + }), ) }) @@ -46,13 +56,13 @@ describe('ClickHouse server errors parsing', () => { await expectAsync( client.query({ query: 'SELECT * FRON unknown_table', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Syntax error: failed at position'), code: '62', type: 'SYNTAX_ERROR', - }) + }), ) }) @@ -66,13 +76,13 @@ describe('ClickHouse server errors parsing', () => { */ FRON unknown_table `, - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Syntax error: failed at position'), code: '62', type: 'SYNTAX_ERROR', - }) + }), ) }) }) diff --git a/packages/client-common/__tests__/integration/exec.test.ts b/packages/client-common/__tests__/integration/exec.test.ts index ada16329..ffed47a1 100644 --- a/packages/client-common/__tests__/integration/exec.test.ts +++ b/packages/client-common/__tests__/integration/exec.test.ts @@ -66,9 +66,9 @@ describe('exec', () => { code: '57', type: 'TABLE_ALREADY_EXISTS', message: jasmine.stringContaining( - `Table ${getTestDatabaseName()}.${tableName} already exists. ` + `Table ${getTestDatabaseName()}.${tableName} already exists. `, ), - }) + }), ) }) @@ -89,7 +89,7 @@ describe('exec', () => { await expectAsync( sessionClient.exec({ query: `CREATE TEMPORARY TABLE ${tableName} (val Int32)`, - }) + }), ).toBeResolved() }) }) @@ -121,7 +121,11 @@ describe('exec', () => { }) const { data, rows } = await selectResult.json< - ResponseJSON<{ name: string; engine: string; create_table_query: string }> + ResponseJSON<{ + name: string + engine: string + create_table_query: string + }> >() expect(rows).toBe(1) diff --git a/packages/client-common/__tests__/integration/insert.test.ts b/packages/client-common/__tests__/integration/insert.test.ts index e1a6e50e..6fed8c9b 100644 --- a/packages/client-common/__tests__/integration/insert.test.ts +++ b/packages/client-common/__tests__/integration/insert.test.ts @@ -114,8 +114,8 @@ describe('insert', () => { values: [row], table: tableName, format: 'JSONEachRow', - }) - ) + }), + ), ) await assertJsonValues(client, tableName) }) @@ -127,7 +127,7 @@ describe('insert', () => { values: jsonValues, format: 'JSONEachRow', clickhouse_settings: { foobar: 1 } as any, - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ // Possible error messages: @@ -136,7 +136,7 @@ describe('insert', () => { message: jasmine.stringContaining('foobar'), code: '115', type: 'UNKNOWN_SETTING', - }) + }), ) }) diff --git a/packages/client-common/__tests__/integration/insert_specific_columns.test.ts b/packages/client-common/__tests__/integration/insert_specific_columns.test.ts index ae1a5906..7a37435b 100644 --- a/packages/client-common/__tests__/integration/insert_specific_columns.test.ts +++ b/packages/client-common/__tests__/integration/insert_specific_columns.test.ts @@ -6,7 +6,7 @@ import { createTestClient, TestEnv, whenOnEnv } from '../utils' whenOnEnv( TestEnv.LocalSingleNode, TestEnv.LocalCluster, - TestEnv.Cloud + TestEnv.Cloud, ).describe('Insert with specific columns', () => { let client: ClickHouseClient let table: string @@ -34,7 +34,7 @@ whenOnEnv( repo_name LowCardinality(String) DEFAULT JSONExtractString(message_raw, 'repo', 'name'), message JSON DEFAULT message_raw, message_raw String EPHEMERAL - ` // `id UInt32` will be added as well + `, // `id UInt32` will be added as well ) }) @@ -214,11 +214,11 @@ whenOnEnv( ], format: 'JSONEachRow', columns: ['foobar', 'message_raw'], - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('No such column foobar'), - }) + }), ) }) }) @@ -229,7 +229,7 @@ whenOnEnv( beforeEach(async () => { table = await createTableWithFields( client, - `s String, b Boolean` // `id UInt32` will be added as well + `s String, b Boolean`, // `id UInt32` will be added as well ) }) @@ -264,7 +264,7 @@ whenOnEnv( beforeEach(async () => { table = await createTableWithFields( client, - `s String, b Boolean` // `id UInt32` will be added as well + `s String, b Boolean`, // `id UInt32` will be added as well ) }) diff --git a/packages/client-common/__tests__/integration/multiple_clients.test.ts b/packages/client-common/__tests__/integration/multiple_clients.test.ts index 6fa89a7f..faa69a1c 100644 --- a/packages/client-common/__tests__/integration/multiple_clients.test.ts +++ b/packages/client-common/__tests__/integration/multiple_clients.test.ts @@ -30,8 +30,8 @@ describe('multiple clients', () => { format: 'JSONEachRow', }) .then((r) => r.json()) - .then((json: Res) => results.push(json[0].sum)) - ) + .then((json: Res) => results.push(json[0].sum)), + ), ) expect(results.sort((a, b) => a - b)).toEqual([1, 3, 6, 10, 15]) }) @@ -40,7 +40,7 @@ describe('multiple clients', () => { const id = guid() const tableName = (i: number) => `multiple_clients_ddl_test__${id}__${i}` await Promise.all( - clients.map((client, i) => createSimpleTable(client, tableName(i))) + clients.map((client, i) => createSimpleTable(client, tableName(i))), ) for (let i = 0; i < CLIENTS_COUNT; i++) { const result = await clients[i].query({ @@ -80,8 +80,8 @@ describe('multiple clients', () => { table: tableName, values: [getValue(i)], format: 'JSONEachRow', - }) - ) + }), + ), ) const result = await clients[0].query({ query: `SELECT * FROM ${tableName} ORDER BY id ASC`, diff --git a/packages/client-common/__tests__/integration/query_log.test.ts b/packages/client-common/__tests__/integration/query_log.test.ts index 66b5c2c3..2331a20c 100644 --- a/packages/client-common/__tests__/integration/query_log.test.ts +++ b/packages/client-common/__tests__/integration/query_log.test.ts @@ -28,7 +28,7 @@ describe('query_log', () => { const formattedQuery = 'SELECT * FROM system.numbers LIMIT 144 \nFORMAT JSON' await assertQueryLog({ formattedQuery, query_id }) - } + }, ) whenOnEnv(...testEnvs).it( @@ -41,7 +41,7 @@ describe('query_log', () => { query, }) await assertQueryLog({ formattedQuery: query, query_id }) - } + }, ) whenOnEnv(...testEnvs).it( @@ -59,7 +59,7 @@ describe('query_log', () => { }) const formattedQuery = `INSERT INTO ${table} FORMAT JSONObjectEachRow\n` await assertQueryLog({ formattedQuery, query_id }) - } + }, ) async function assertQueryLog({ diff --git a/packages/client-common/__tests__/integration/read_only_user.test.ts b/packages/client-common/__tests__/integration/read_only_user.test.ts index 025d68f5..f12a5f7a 100644 --- a/packages/client-common/__tests__/integration/read_only_user.test.ts +++ b/packages/client-common/__tests__/integration/read_only_user.test.ts @@ -52,11 +52,11 @@ describe('read only user', () => { it('should fail to create a table', async () => { await expectAsync( - createSimpleTable(client, `should_not_be_created_${guid()}`) + createSimpleTable(client, `should_not_be_created_${guid()}`), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Not enough privileges'), - }) + }), ) }) @@ -65,11 +65,11 @@ describe('read only user', () => { client.insert({ table: tableName, values: [[43, 'foobar', [5, 25]]], - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Not enough privileges'), - }) + }), ) }) @@ -79,7 +79,7 @@ describe('read only user', () => { await expectAsync(client.query({ query })).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Not enough privileges'), - }) + }), ) }) }) diff --git a/packages/client-common/__tests__/integration/select.test.ts b/packages/client-common/__tests__/integration/select.test.ts index b09d44e8..c1a306aa 100644 --- a/packages/client-common/__tests__/integration/select.test.ts +++ b/packages/client-common/__tests__/integration/select.test.ts @@ -40,7 +40,7 @@ describe('select', () => { query: 'SELECT * FROM system.numbers LIMIT 0', format: 'JSONEachRow', }) - .then((r) => r.json()) + .then((r) => r.json()), ).toEqual([]) expect( await client @@ -48,7 +48,7 @@ describe('select', () => { query: 'SELECT * FROM system.numbers LIMIT 0', format: 'TabSeparated', }) - .then((r) => r.text()) + .then((r) => r.text()), ).toEqual('') }) @@ -127,11 +127,11 @@ describe('select', () => { it('does not swallow a client error', async () => { await expectAsync( - client.query({ query: 'SELECT number FR' }) + client.query({ query: 'SELECT number FR' }), ).toBeRejectedWith( jasmine.objectContaining({ type: 'UNKNOWN_IDENTIFIER', - }) + }), ) }) @@ -141,7 +141,7 @@ describe('select', () => { message: jasmine.stringContaining('Syntax error'), code: '62', type: 'SYNTAX_ERROR', - }) + }), ) }) @@ -150,7 +150,7 @@ describe('select', () => { client.query({ query: 'SELECT * FROM system.numbers', clickhouse_settings: { foobar: 1 } as any, - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ // Possible error messages: @@ -159,7 +159,7 @@ describe('select', () => { message: jasmine.stringContaining('foobar'), code: '115', type: 'UNKNOWN_SETTING', - }) + }), ) }) @@ -174,8 +174,8 @@ describe('select', () => { format: 'JSONEachRow', }) .then((r) => r.json()) - .then((json: Res) => results.push(json[0].sum)) - ) + .then((json: Res) => results.push(json[0].sum)), + ), ) expect(results.sort((a, b) => a - b)).toEqual([1, 3, 6, 10, 15]) }) diff --git a/packages/client-common/__tests__/integration/select_query_binding.test.ts b/packages/client-common/__tests__/integration/select_query_binding.test.ts index f11ed5f7..0af34754 100644 --- a/packages/client-common/__tests__/integration/select_query_binding.test.ts +++ b/packages/client-common/__tests__/integration/select_query_binding.test.ts @@ -257,18 +257,18 @@ describe('select with query binding', () => { SELECT * FROM system.numbers WHERE number > {min_limit: UInt64} LIMIT 3 `, - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching( // possible error messages here: // (since 23.8+) Substitution `min_limit` is not set. // (pre-23.8) Query parameter `min_limit` was not set - /^.+?`min_limit`.+?not set.*$/ + /^.+?`min_limit`.+?not set.*$/, ), code: '456', type: 'UNKNOWN_QUERY_PARAMETER', - }) + }), ) }) }) diff --git a/packages/client-common/__tests__/integration/select_result.test.ts b/packages/client-common/__tests__/integration/select_result.test.ts index 2699154a..1db06b61 100644 --- a/packages/client-common/__tests__/integration/select_result.test.ts +++ b/packages/client-common/__tests__/integration/select_result.test.ts @@ -26,7 +26,7 @@ describe('Select ResultSet', () => { }) expect(await rs.text()).toBe( - '{"number":"0"}\n{"number":"1"}\n{"number":"2"}\n' + '{"number":"0"}\n{"number":"1"}\n{"number":"2"}\n', ) }) }) @@ -86,7 +86,7 @@ describe('Select ResultSet', () => { rows_read: jasmine.any(Number), bytes_read: jasmine.any(Number), }, - }) + }), ) }) }) diff --git a/packages/client-common/__tests__/unit/config.test.ts b/packages/client-common/__tests__/unit/config.test.ts index c5a11ebb..707d426f 100644 --- a/packages/client-common/__tests__/unit/config.test.ts +++ b/packages/client-common/__tests__/unit/config.test.ts @@ -67,7 +67,7 @@ describe('config', () => { }, }, logger, - null + null, ) expect(res).toEqual({ url: new URL('https://my.host:8443/'), @@ -137,7 +137,7 @@ describe('config', () => { }, }, logger, - null + null, ) expect(res).toEqual({ url: new URL('https://my.host:8443/'), @@ -164,7 +164,7 @@ describe('config', () => { }, }, logger, - null + null, ) expect(res).toEqual({ url: new URL('https://my.host:8443/'), @@ -190,7 +190,7 @@ describe('config', () => { }, }, logger, - null + null, ) expect(res).toEqual({ url: new URL('https://my.host:8443/'), @@ -224,7 +224,7 @@ describe('config', () => { handled_params: new Set(['impl_specific_setting']), unknown_params: new Set(), } - } + }, ) expect(res).toEqual({ ...defaultConfig, @@ -242,7 +242,7 @@ describe('config', () => { expect(() => prepareConfigWithURL({ url: 'foo' }, logger, null)).toThrow( jasmine.objectContaining({ message: jasmine.stringContaining('ClickHouse URL is malformed.'), - }) + }), ) }) }) @@ -253,7 +253,7 @@ describe('config', () => { { url: new URL('https://my.host:8443/'), }, - logger + logger, ) expect(res).toEqual({ url: new URL('https://my.host:8443/'), @@ -296,7 +296,7 @@ describe('config', () => { keep_alive: { enabled: false }, application: 'my_app', }, - logger + logger, ) expect(res).toEqual({ url: new URL('https://my.host:8443/'), @@ -389,10 +389,10 @@ describe('config', () => { it('should create valid URLs', async () => { expect(createUrl(undefined)).toEqual(new URL('http://localhost:8123/')) expect(createUrl('http://localhost:8123')).toEqual( - new URL('http://localhost:8123/') + new URL('http://localhost:8123/'), ) expect(createUrl('https://bob:secret@my.host:8124')).toEqual( - new URL('https://bob:secret@my.host:8124/') + new URL('https://bob:secret@my.host:8124/'), ) }) @@ -400,13 +400,13 @@ describe('config', () => { expect(() => createUrl('foo')).toThrow( jasmine.objectContaining({ message: jasmine.stringContaining('ClickHouse URL is malformed.'), - }) + }), ) expect(() => createUrl('http://localhost/foo')).toThrowError( - 'ClickHouse URL must contain a valid port number.' + 'ClickHouse URL must contain a valid port number.', ) expect(() => createUrl('tcp://localhost:8443')).toThrowError( - 'ClickHouse URL protocol must be either http or https. Got: tcp:' + 'ClickHouse URL protocol must be either http or https. Got: tcp:', ) }) }) @@ -428,7 +428,7 @@ describe('config', () => { 'clickhouse_setting_async_insert=1', 'ch_wait_for_async_insert=0', 'http_header_X-CLICKHOUSE-AUTH=secret_header', - ].join('&') + ].join('&'), ) const res = loadConfigOptionsFromURL(url, null) expect(res[0].toString()).toEqual('https://my.host:8124/') @@ -477,7 +477,7 @@ describe('config', () => { 'application=my_app', 'request_timeout=42000', 'max_open_connections=2', - ].join('&') + ].join('&'), ) const res = loadConfigOptionsFromURL(url, null) expect(res[0].toString()).toEqual('http://localhost:8124/') @@ -511,11 +511,11 @@ describe('config', () => { it('should fail if there is an unknown setting and the extra URL params handler is not provided', async () => { const url1 = new URL('http://localhost:8124/?this_was_unexpected=1') expect(() => loadConfigOptionsFromURL(url1, null)).toThrowError( - 'Unknown URL parameters: this_was_unexpected' + 'Unknown URL parameters: this_was_unexpected', ) const url2 = new URL('http://localhost:8124/?url=this_is_not_allowed') expect(() => loadConfigOptionsFromURL(url2, null)).toThrowError( - 'Unknown URL parameters: url' + 'Unknown URL parameters: url', ) }) @@ -548,13 +548,13 @@ describe('config', () => { } } expect(() => loadConfigOptionsFromURL(url, handler)).toThrowError( - 'Unknown URL parameters: impl_specific_setting' + 'Unknown URL parameters: impl_specific_setting', ) }) it('should fail if only some parameters were handled by the extra URL params handler', async () => { const url = new URL( - 'http://localhost:8124/?impl_specific_setting=42&whatever=1' + 'http://localhost:8124/?impl_specific_setting=42&whatever=1', ) const handler: HandleImplSpecificURLParams = (config) => { return { @@ -567,7 +567,7 @@ describe('config', () => { } } expect(() => loadConfigOptionsFromURL(url, handler)).toThrowError( - 'Unknown URL parameters: whatever' + 'Unknown URL parameters: whatever', ) }) @@ -589,7 +589,7 @@ describe('config', () => { 'http_header_X-CLICKHOUSE-AUTH=secret_header', 'impl_specific_setting=qaz', 'another_impl_specific_setting=qux', - ].join('&') + ].join('&'), ) const handler: HandleImplSpecificURLParams = (config) => { return { @@ -642,13 +642,13 @@ describe('config', () => { 'application=my_app', 'session_id=sticky', 'request_timeout=42', - ].join('&') + ].join('&'), ) const handler: HandleImplSpecificURLParams = (config, url) => { // should fail the assertion if not empty if (url.searchParams.size > 0) { throw new Error( - `Unexpected URL params: ${url.searchParams.toString()}` + `Unexpected URL params: ${url.searchParams.toString()}`, ) } return { @@ -690,7 +690,7 @@ describe('config', () => { .toEqual(expected) }) expect(() => booleanConfigURLValue({ key, value: 'bar' })).toThrowError( - `"foo" has invalid boolean value: bar. Expected one of: 0, 1, true, false.` + `"foo" has invalid boolean value: bar. Expected one of: 0, 1, true, false.`, ) }) @@ -711,7 +711,7 @@ describe('config', () => { .toEqual(expected) }) expect(() => numberConfigURLValue({ key, value: 'bar' })).toThrowError( - `"foo" has invalid numeric value: bar` + `"foo" has invalid numeric value: bar`, ) }) @@ -719,7 +719,7 @@ describe('config', () => { expect(numberConfigURLValue({ key, value: '2', min: 1 })).toEqual(2) expect(numberConfigURLValue({ key, value: '2', min: 2 })).toEqual(2) expect(() => - numberConfigURLValue({ key, value: '2', min: 3 }) + numberConfigURLValue({ key, value: '2', min: 3 }), ).toThrowError(`"foo" value 2 is less than min allowed 3`) }) @@ -727,7 +727,7 @@ describe('config', () => { expect(numberConfigURLValue({ key, value: '2', max: 2 })).toEqual(2) expect(numberConfigURLValue({ key, value: '2', max: 3 })).toEqual(2) expect(() => - numberConfigURLValue({ key, value: '4', max: 3 }) + numberConfigURLValue({ key, value: '4', max: 3 }), ).toThrowError(`"foo" value 4 is greater than max allowed 3`) }) @@ -737,10 +737,10 @@ describe('config', () => { const r2 = numberConfigURLValue({ key, value: '2', min: 2, max: 2 }) expect(r2).toEqual(2) expect(() => - numberConfigURLValue({ key, value: '2', min: 3, max: 4 }) + numberConfigURLValue({ key, value: '2', min: 3, max: 4 }), ).toThrowError(`"foo" value 2 is less than min allowed 3`) expect(() => - numberConfigURLValue({ key, value: '5', min: 3, max: 4 }) + numberConfigURLValue({ key, value: '5', min: 3, max: 4 }), ).toThrowError(`"foo" value 5 is greater than max allowed 4`) }) @@ -765,7 +765,7 @@ describe('config', () => { key, value, enumObject: ClickHouseLogLevel, - }) + }), ) .withContext(`Expected log level for value "${value}" is ${expected}`) .toEqual(expected) @@ -775,9 +775,9 @@ describe('config', () => { key, value: 'bar', enumObject: ClickHouseLogLevel, - }) + }), ).toThrowError( - `"foo" has invalid value: bar. Expected one of: TRACE, DEBUG, INFO, WARN, ERROR, OFF.` + `"foo" has invalid value: bar. Expected one of: TRACE, DEBUG, INFO, WARN, ERROR, OFF.`, ) }) }) diff --git a/packages/client-common/__tests__/unit/format_query_params.test.ts b/packages/client-common/__tests__/unit/format_query_params.test.ts index 3107ff7b..23825346 100644 --- a/packages/client-common/__tests__/unit/format_query_params.test.ts +++ b/packages/client-common/__tests__/unit/format_query_params.test.ts @@ -50,13 +50,13 @@ describe('formatQueryParams', () => { it('formats a date with millis', () => { expect( - formatQueryParams(new Date(Date.UTC(2022, 6, 29, 7, 52, 14, 123))) + formatQueryParams(new Date(Date.UTC(2022, 6, 29, 7, 52, 14, 123))), ).toBe('1659081134.123') expect( - formatQueryParams(new Date(Date.UTC(2022, 6, 29, 7, 52, 14, 42))) + formatQueryParams(new Date(Date.UTC(2022, 6, 29, 7, 52, 14, 42))), ).toBe('1659081134.042') expect( - formatQueryParams(new Date(Date.UTC(2022, 6, 29, 7, 52, 14, 5))) + formatQueryParams(new Date(Date.UTC(2022, 6, 29, 7, 52, 14, 5))), ).toBe('1659081134.005') }) @@ -77,7 +77,7 @@ describe('formatQueryParams', () => { expect( formatQueryParams({ ["na'me"]: "cust'om", - }) + }), ).toBe("{'na\\'me':'cust\\'om'}") }) @@ -87,7 +87,7 @@ describe('formatQueryParams', () => { name: 'custom', id: 42, params: { refs: [44] }, - }) + }), ).toBe("{'name':'custom','id':42,'params':{'refs':[44]}}") }) }) diff --git a/packages/client-common/__tests__/unit/format_query_settings.test.ts b/packages/client-common/__tests__/unit/format_query_settings.test.ts index 133206f6..8fc50d95 100644 --- a/packages/client-common/__tests__/unit/format_query_settings.test.ts +++ b/packages/client-common/__tests__/unit/format_query_settings.test.ts @@ -16,16 +16,16 @@ describe('formatQuerySettings', () => { it('formats a Map', () => { expect( - formatQuerySettings(SettingsMap.from({ foo: 'bar', baz: 'qux' })) + formatQuerySettings(SettingsMap.from({ foo: 'bar', baz: 'qux' })), ).toBe(`{'foo':'bar','baz':'qux'}`) }) it('throws on unsupported values', () => { expect(() => formatQuerySettings(undefined as any)).toThrowError( - 'Unsupported value in query settings: [undefined].' + 'Unsupported value in query settings: [undefined].', ) expect(() => formatQuerySettings([1, 2] as any)).toThrowError( - 'Unsupported value in query settings: [1,2].' + 'Unsupported value in query settings: [1,2].', ) }) }) diff --git a/packages/client-common/__tests__/unit/parse_error.test.ts b/packages/client-common/__tests__/unit/parse_error.test.ts index e3b95f4c..7e413a5b 100644 --- a/packages/client-common/__tests__/unit/parse_error.test.ts +++ b/packages/client-common/__tests__/unit/parse_error.test.ts @@ -9,7 +9,7 @@ describe('parseError', () => { expect(error.code).toBe('62') expect(error.type).toBe('SYNTAX_ERROR') expect(error.message).toBe( - `Syntax error: failed at position 15 ('unknown_table') (line 1, col 15): unknown_table FORMAT JSON. Expected alias cannot be here. ` + `Syntax error: failed at position 15 ('unknown_table') (line 1, col 15): unknown_table FORMAT JSON. Expected alias cannot be here. `, ) }) @@ -23,7 +23,7 @@ describe('parseError', () => { expect(error.type).toBe('SYNTAX_ERROR') expect(error.message).toBe( `Syntax error: failed at position 15 ('unknown_table') (line 1, col 15): unknown_table - FORMAT JSON. Expected alias cannot be here. ` + FORMAT JSON. Expected alias cannot be here. `, ) }) @@ -35,7 +35,7 @@ describe('parseError', () => { expect(error.code).toBe('285') expect(error.type).toBe('TOO_FEW_LIVE_REPLICAS') expect(error.message).toBe( - 'Number of alive replicas (2) is less than requested quorum (3). ' + 'Number of alive replicas (2) is less than requested quorum (3). ', ) }) @@ -48,7 +48,7 @@ describe('parseError', () => { expect(error.code).toBe('499') expect(error.type).toBe('S3_ERROR') expect(error.message).toBe( - 'Could not list objects in bucket my-bucket with prefix my-organization, S3 exception: Some S3 error, message: Could not list objects. ' + 'Could not list objects in bucket my-bucket with prefix my-organization, S3 exception: Some S3 error, message: Could not list objects. ', ) }) @@ -60,7 +60,7 @@ describe('parseError', () => { expect(error.code).toBe('594') expect(error.type).toBe('BZIP2_STREAM_DECODER_FAILED') expect(error.message).toBe( - 'bzip2 stream encoder init failed: error code: 42 ' + 'bzip2 stream encoder init failed: error code: 42 ', ) }) @@ -72,7 +72,7 @@ describe('parseError', () => { expect(error.code).toBe('617') expect(error.type).toBe('LZ4_ENCODER_FAILED') expect(error.message).toBe( - 'creation of LZ4 compression context failed. LZ4F version: 1.9.3 ' + 'creation of LZ4 compression context failed. LZ4F version: 1.9.3 ', ) }) }) @@ -87,7 +87,7 @@ describe('parseError', () => { expect(error.code).toBe('57') expect(error.type).toBe('TABLE_ALREADY_EXISTS') expect(error.message).toBe( - 'Table default.command_test_2a751694160745f5aebe586c90b27515 already exists. ' + 'Table default.command_test_2a751694160745f5aebe586c90b27515 already exists. ', ) }) }) diff --git a/packages/client-common/__tests__/unit/to_search_params.test.ts b/packages/client-common/__tests__/unit/to_search_params.test.ts index 8619ee95..3f6f43ea 100644 --- a/packages/client-common/__tests__/unit/to_search_params.test.ts +++ b/packages/client-common/__tests__/unit/to_search_params.test.ts @@ -97,6 +97,6 @@ describe('toSearchParams', () => { function toSortedArray(params: URLSearchParams): [string, string][] { return [...params.entries()].sort(([key1], [key2]) => - String(key1).localeCompare(String(key2)) + String(key1).localeCompare(String(key2)), ) } diff --git a/packages/client-common/__tests__/utils/client.ts b/packages/client-common/__tests__/utils/client.ts index 0440ec6f..9a93c6ba 100644 --- a/packages/client-common/__tests__/utils/client.ts +++ b/packages/client-common/__tests__/utils/client.ts @@ -13,25 +13,30 @@ import { } from './test_env' import { TestLogger } from './test_logger' -jasmine.DEFAULT_TIMEOUT_INTERVAL = 120_000 +jasmine.DEFAULT_TIMEOUT_INTERVAL = 300_000 let databaseName: string beforeAll(async () => { console.log( `\nTest environment: ${getClickHouseTestEnvironment()}, database: ${ databaseName ?? 'default' - }` + }`, ) if (isCloudTestEnv() && databaseName === undefined) { - const client = createTestClient({}) - await wakeUpPing(client) - databaseName = await createRandomDatabase(client) - await client.close() + const cloudInitClient = createTestClient({ + request_timeout: 60_000, + keep_alive: { + enabled: false, + }, + }) + await wakeUpPing(cloudInitClient) + databaseName = await createRandomDatabase(cloudInitClient) + await cloudInitClient.close() } }) export function createTestClient( - config: BaseClickHouseClientConfigOptions = {} + config: BaseClickHouseClientConfigOptions = {}, ): ClickHouseClient { const env = getClickHouseTestEnvironment() const clickHouseSettings: ClickHouseSettings = {} @@ -66,7 +71,7 @@ export function createTestClient( // props to https://stackoverflow.com/a/41063795/4575540 // @ts-expect-error return eval('require')('../../../client-node/src/client').createClient( - cloudConfig + cloudConfig, ) as ClickHouseClient } } else { @@ -81,14 +86,14 @@ export function createTestClient( } else { // @ts-expect-error return eval('require')('../../../client-node/src/client').createClient( - localConfig + localConfig, ) as ClickHouseClient } } } export async function createRandomDatabase( - client: ClickHouseClient + client: ClickHouseClient, ): Promise { const databaseName = `clickhousejs__${guid()}__${+new Date()}` let maybeOnCluster = '' @@ -109,7 +114,7 @@ export async function createRandomDatabase( export async function createTable( client: ClickHouseClient, definition: (environment: TestEnv) => string, - clickhouse_settings?: ClickHouseSettings + clickhouse_settings?: ClickHouseSettings, ) { const env = getClickHouseTestEnvironment() const ddl = definition(env) @@ -134,7 +139,7 @@ const MaxPingRetries = 4 export async function wakeUpPing( client: ClickHouseClient, retries = 0, - lastError?: Error | unknown + lastError?: Error | unknown, ) { if (retries < MaxPingRetries) { const result = await client.ping() @@ -144,13 +149,13 @@ export async function wakeUpPing( // maybe the service is still waking up console.error( `Failed to ping, attempts so far: ${retries + 1}`, - result.error + result.error, ) await wakeUpPing(client, retries++, result.error) } else { console.error( `Failed to wake up the service after ${MaxPingRetries} retries, exiting...`, - lastError + lastError, ) process.exit(1) } diff --git a/packages/client-common/__tests__/utils/test_connection_type.ts b/packages/client-common/__tests__/utils/test_connection_type.ts index 8e433c00..409ba627 100644 --- a/packages/client-common/__tests__/utils/test_connection_type.ts +++ b/packages/client-common/__tests__/utils/test_connection_type.ts @@ -16,7 +16,7 @@ export function getTestConnectionType(): TestConnectionType { throw new Error( 'Unexpected CLICKHOUSE_TEST_CONNECTION_TYPE value. ' + 'Possible options: `node`, `browser` ' + - 'or keep it unset to fall back to `node`' + 'or keep it unset to fall back to `node`', ) } return connectionType diff --git a/packages/client-common/__tests__/utils/test_env.ts b/packages/client-common/__tests__/utils/test_env.ts index b730e2e2..1f294ca7 100644 --- a/packages/client-common/__tests__/utils/test_env.ts +++ b/packages/client-common/__tests__/utils/test_env.ts @@ -27,7 +27,7 @@ export function getClickHouseTestEnvironment(): TestEnv { throw new Error( `Unexpected CLICKHOUSE_TEST_ENVIRONMENT value: ${value}. ` + 'Possible options: `local_single_node`, `local_cluster`, `cloud`, `cloud_smt`. ' + - 'You can keep it unset to fall back to `local_single_node`' + 'You can keep it unset to fall back to `local_single_node`', ) } return env diff --git a/packages/client-common/__tests__/utils/test_logger.ts b/packages/client-common/__tests__/utils/test_logger.ts index c9e35835..de0abe53 100644 --- a/packages/client-common/__tests__/utils/test_logger.ts +++ b/packages/client-common/__tests__/utils/test_logger.ts @@ -21,7 +21,7 @@ export class TestLogger implements Logger { console.error( formatMessage({ level: 'ERROR', module, message }), args || '', - err + err, ) } } diff --git a/packages/client-common/src/client.ts b/packages/client-common/src/client.ts index ea2d90a0..3c833862 100644 --- a/packages/client-common/src/client.ts +++ b/packages/client-common/src/client.ts @@ -108,7 +108,7 @@ export class ClickHouseClient { private readonly sessionId?: string constructor( - config: BaseClickHouseClientConfigOptions & ImplementationDetails + config: BaseClickHouseClientConfigOptions & ImplementationDetails, ) { const logger = config?.log?.LoggerClass ? new config.log.LoggerClass() @@ -116,14 +116,14 @@ export class ClickHouseClient { const configWithURL = prepareConfigWithURL( config, logger, - config.impl.handle_specific_url_params ?? null + config.impl.handle_specific_url_params ?? null, ) const connectionParams = getConnectionParams(configWithURL, logger) this.clientClickHouseSettings = connectionParams.clickhouse_settings this.sessionId = config.session_id this.connection = config.impl.make_connection( configWithURL, - connectionParams + connectionParams, ) this.makeResultSet = config.impl.make_result_set this.valuesEncoder = config.impl.values_encoder @@ -259,7 +259,7 @@ function isInsertColumnsExcept(obj: unknown): obj is InsertColumnsExcept { function getInsertQuery( params: InsertParams, - format: DataFormat + format: DataFormat, ): string { let columnsPart = '' if (params.columns !== undefined) { diff --git a/packages/client-common/src/config.ts b/packages/client-common/src/config.ts index ba51e6d0..e691287d 100644 --- a/packages/client-common/src/config.ts +++ b/packages/client-common/src/config.ts @@ -85,19 +85,19 @@ export interface BaseClickHouseClientConfigOptions { export type MakeConnection< Stream, - Config = BaseClickHouseClientConfigOptionsWithURL + Config = BaseClickHouseClientConfigOptionsWithURL, > = (config: Config, params: ConnectionParams) => Connection export type MakeResultSet = ( stream: Stream, format: DataFormat, - session_id: string + session_id: string, ) => BaseResultSet export interface ValuesEncoder { validateInsertValues( values: InsertValues, - format: DataFormat + format: DataFormat, ): void /** @@ -111,7 +111,7 @@ export interface ValuesEncoder { */ encodeValues( values: InsertValues, - format: DataFormat + format: DataFormat, ): string | Stream } @@ -126,7 +126,7 @@ export type CloseStream = (stream: Stream) => Promise */ export type HandleImplSpecificURLParams = ( config: BaseClickHouseClientConfigOptions, - url: URL + url: URL, ) => { config: BaseClickHouseClientConfigOptions // params that were handled in the implementation; used to calculate final "unknown" URL params @@ -165,7 +165,7 @@ export type BaseClickHouseClientConfigOptionsWithURL = Omit< export function prepareConfigWithURL( baseConfigOptions: BaseClickHouseClientConfigOptions, logger: Logger, - handleImplURLParams: HandleImplSpecificURLParams | null + handleImplURLParams: HandleImplSpecificURLParams | null, ): BaseClickHouseClientConfigOptionsWithURL { const baseConfig = { ...baseConfigOptions } if (baseConfig.additional_headers !== undefined) { @@ -190,7 +190,7 @@ export function prepareConfigWithURL( } const [url, configFromURL] = loadConfigOptionsFromURL( configURL, - handleImplURLParams + handleImplURLParams, ) const config = mergeConfigs(baseConfig, configFromURL, logger) let clickHouseSettings: ClickHouseSettings @@ -239,7 +239,7 @@ export function prepareConfigWithURL( export function getConnectionParams( config: BaseClickHouseClientConfigOptionsWithURL, - logger: Logger + logger: Logger, ): ConnectionParams { return { url: config.url, @@ -269,11 +269,11 @@ export function getConnectionParams( export function mergeConfigs( baseConfig: BaseClickHouseClientConfigOptions, configFromURL: BaseClickHouseClientConfigOptions, - logger: Logger + logger: Logger, ): BaseClickHouseClientConfigOptions { const config = { ...baseConfig } const keys = Object.keys( - configFromURL + configFromURL, ) as (keyof BaseClickHouseClientConfigOptions)[] for (const key of keys) { if (config[key] !== undefined) { @@ -297,12 +297,12 @@ export function createUrl(configURL: string | URL | undefined): URL { } } catch (err) { throw new Error( - 'ClickHouse URL is malformed. Expected format: http[s]://[username:password@]hostname:port[/database][?param1=value1¶m2=value2]' + 'ClickHouse URL is malformed. Expected format: http[s]://[username:password@]hostname:port[/database][?param1=value1¶m2=value2]', ) } if (url.protocol !== 'http:' && url.protocol !== 'https:') { throw new Error( - `ClickHouse URL protocol must be either http or https. Got: ${url.protocol}` + `ClickHouse URL protocol must be either http or https. Got: ${url.protocol}`, ) } if (url.port === '' || isNaN(Number(url.port))) { @@ -318,7 +318,7 @@ export function createUrl(configURL: string | URL | undefined): URL { */ export function loadConfigOptionsFromURL( url: URL, - handleExtraURLParams: HandleImplSpecificURLParams | null + handleExtraURLParams: HandleImplSpecificURLParams | null, ): [URL, BaseClickHouseClientConfigOptions] { let config: BaseClickHouseClientConfigOptions = {} if (url.username.trim() !== '') { @@ -441,7 +441,7 @@ export function loadConfigOptionsFromURL( } if (unknownParams.size > 0) { throw new Error( - `Unknown URL parameters: ${Array.from(unknownParams).join(', ')}` + `Unknown URL parameters: ${Array.from(unknownParams).join(', ')}`, ) } } @@ -461,7 +461,7 @@ export function booleanConfigURLValue({ if (trimmed === 'true' || trimmed === '1') return true if (trimmed === 'false' || trimmed === '0') return false throw new Error( - `"${key}" has invalid boolean value: ${trimmed}. Expected one of: 0, 1, true, false.` + `"${key}" has invalid boolean value: ${trimmed}. Expected one of: 0, 1, true, false.`, ) } @@ -485,7 +485,7 @@ export function numberConfigURLValue({ } if (max !== undefined && number > max) { throw new Error( - `"${key}" value ${trimmed} is greater than max allowed ${max}` + `"${key}" value ${trimmed} is greater than max allowed ${max}`, ) } return number @@ -507,7 +507,7 @@ export function enumConfigURLValue({ if (!values.includes(trimmed)) { const expected = values.join(', ') throw new Error( - `"${key}" has invalid value: ${trimmed}. Expected one of: ${expected}.` + `"${key}" has invalid value: ${trimmed}. Expected one of: ${expected}.`, ) } return enumObject[trimmed as Key] diff --git a/packages/client-common/src/data_formatter/format_query_params.ts b/packages/client-common/src/data_formatter/format_query_params.ts index a16c0262..2095f31b 100644 --- a/packages/client-common/src/data_formatter/format_query_params.ts +++ b/packages/client-common/src/data_formatter/format_query_params.ts @@ -2,7 +2,7 @@ import { replaceAll } from '../utils' export function formatQueryParams( value: any, - wrapStringInQuotes = false + wrapStringInQuotes = false, ): string { if (value === null || value === undefined) return '\\N' if (Number.isNaN(value)) return 'nan' @@ -36,7 +36,7 @@ export function formatQueryParams( const formatted: string[] = [] for (const [key, val] of Object.entries(value)) { formatted.push( - `${formatQueryParams(key, true)}:${formatQueryParams(val, true)}` + `${formatQueryParams(key, true)}:${formatQueryParams(val, true)}`, ) } return `{${formatted.join(',')}}` diff --git a/packages/client-common/src/data_formatter/format_query_settings.ts b/packages/client-common/src/data_formatter/format_query_settings.ts index c100b74a..d0dff880 100644 --- a/packages/client-common/src/data_formatter/format_query_settings.ts +++ b/packages/client-common/src/data_formatter/format_query_settings.ts @@ -1,7 +1,7 @@ import { SettingsMap } from '../settings' export function formatQuerySettings( - value: number | string | boolean | SettingsMap + value: number | string | boolean | SettingsMap, ): string { if (typeof value === 'boolean') return value ? '1' : '0' if (typeof value === 'number') return String(value) diff --git a/packages/client-common/src/data_formatter/formatter.ts b/packages/client-common/src/data_formatter/formatter.ts index 259e9b00..ae2ee0cc 100644 --- a/packages/client-common/src/data_formatter/formatter.ts +++ b/packages/client-common/src/data_formatter/formatter.ts @@ -50,14 +50,14 @@ const streamableFormat = [ type StreamableDataFormat = (typeof streamableFormat)[number] function isNotStreamableJSONFamily( - format: DataFormat + format: DataFormat, ): format is SingleDocumentStreamableJsonDataFormat { // @ts-expect-error JSON is not assignable to notStreamableJSONFormats return singleDocumentJSONFormats.includes(format) } function isStreamableJSONFamily( - format: DataFormat + format: DataFormat, ): format is StreamableJsonDataFormat { // @ts-expect-error JSON is not assignable to streamableJSONFormats return streamableJSONFormats.includes(format) @@ -68,13 +68,13 @@ export function isSupportedRawFormat(dataFormat: DataFormat) { } export function validateStreamFormat( - format: any + format: any, ): format is StreamableDataFormat { if (!streamableFormat.includes(format)) { throw new Error( `${format} format is not streamable. Streamable formats: ${streamableFormat.join( - ',' - )}` + ',', + )}`, ) } return true @@ -112,6 +112,6 @@ export function encodeJSON(value: any, format: DataFormat): string { return JSON.stringify(value) + '\n' } throw new Error( - `The client does not support JSON encoding in [${format}] format.` + `The client does not support JSON encoding in [${format}] format.`, ) } diff --git a/packages/client-common/src/logger.ts b/packages/client-common/src/logger.ts index f791790d..fdbfe2ce 100644 --- a/packages/client-common/src/logger.ts +++ b/packages/client-common/src/logger.ts @@ -80,7 +80,7 @@ export class LogWriter { constructor( private readonly logger: Logger, private readonly module: string, - logLevel?: ClickHouseLogLevel + logLevel?: ClickHouseLogLevel, ) { this.logLevel = logLevel ?? ClickHouseLogLevel.OFF this.info({ diff --git a/packages/client-common/src/utils/connection.ts b/packages/client-common/src/utils/connection.ts index 8fe7f2a7..efef8503 100644 --- a/packages/client-common/src/utils/connection.ts +++ b/packages/client-common/src/utils/connection.ts @@ -21,7 +21,7 @@ export function withCompressionHeaders({ export function withHttpSettings( clickhouse_settings?: ClickHouseSettings, - compression?: boolean + compression?: boolean, ): ClickHouseSettings { return { ...(compression diff --git a/packages/client-common/src/utils/permutations.ts b/packages/client-common/src/utils/permutations.ts index 9fc788c6..db771d66 100644 --- a/packages/client-common/src/utils/permutations.ts +++ b/packages/client-common/src/utils/permutations.ts @@ -4,6 +4,6 @@ export function permutations(args: T[], n: number, prefix: T[] = []): T[][] { return [prefix] } return args.flatMap((arg, i) => - permutations(args.slice(i + 1), n - 1, [...prefix, arg]) + permutations(args.slice(i + 1), n - 1, [...prefix, arg]), ) } diff --git a/packages/client-common/src/utils/string.ts b/packages/client-common/src/utils/string.ts index fd61e4d0..e3bb4688 100644 --- a/packages/client-common/src/utils/string.ts +++ b/packages/client-common/src/utils/string.ts @@ -1,7 +1,7 @@ export function replaceAll( input: string, replace_char: string, - new_char: string + new_char: string, ): string { return input.split(replace_char).join(new_char) } diff --git a/packages/client-node/__tests__/integration/node_abort_request.test.ts b/packages/client-node/__tests__/integration/node_abort_request.test.ts index 1a62f164..f681def6 100644 --- a/packages/client-node/__tests__/integration/node_abort_request.test.ts +++ b/packages/client-node/__tests__/integration/node_abort_request.test.ts @@ -95,7 +95,7 @@ describe('[Node.js] abort request streaming', () => { }) } return insertPromise - }) + }), ) setTimeout(() => { @@ -137,7 +137,7 @@ describe('[Node.js] abort request streaming', () => { await expectAsync(insertPromise).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching('The user aborted a request'), - }) + }), ) }) @@ -149,11 +149,11 @@ describe('[Node.js] abort request streaming', () => { await client.insert({ table: tableName, values: stream, - }) + }), ).toEqual( jasmine.objectContaining({ query_id: jasmine.any(String), - }) + }), ) }) @@ -173,7 +173,7 @@ describe('[Node.js] abort request streaming', () => { await expectAsync(insertPromise).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching('The user aborted a request'), - }) + }), ) }) }) diff --git a/packages/client-node/__tests__/integration/node_errors_parsing.test.ts b/packages/client-node/__tests__/integration/node_errors_parsing.test.ts index b4e83bb0..7254c45e 100644 --- a/packages/client-node/__tests__/integration/node_errors_parsing.test.ts +++ b/packages/client-node/__tests__/integration/node_errors_parsing.test.ts @@ -8,11 +8,11 @@ describe('[Node.js] errors parsing', () => { await expectAsync( client.query({ query: 'SELECT * FROM system.numbers LIMIT 3', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ code: 'ECONNREFUSED', - }) + }), ) }) }) diff --git a/packages/client-node/__tests__/integration/node_insert.test.ts b/packages/client-node/__tests__/integration/node_insert.test.ts index 3f72e077..9e6b5f51 100644 --- a/packages/client-node/__tests__/integration/node_insert.test.ts +++ b/packages/client-node/__tests__/integration/node_insert.test.ts @@ -26,13 +26,13 @@ describe('[Node.js] insert', () => { objectMode: false, }), format: 'TabSeparated', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Cannot parse input'), code: '27', type: 'CANNOT_PARSE_INPUT_ASSERTION_FAILED', - }) + }), ) }) }) diff --git a/packages/client-node/__tests__/integration/node_keep_alive.test.ts b/packages/client-node/__tests__/integration/node_keep_alive.test.ts index 1bdf7c9a..a2c4d27e 100644 --- a/packages/client-node/__tests__/integration/node_keep_alive.test.ts +++ b/packages/client-node/__tests__/integration/node_keep_alive.test.ts @@ -54,12 +54,12 @@ xdescribe('[Node.js] Keep Alive', () => { } as NodeClickHouseClientConfigOptions) const results = await Promise.all( - [...Array(4).keys()].map((n) => query(n)) + [...Array(4).keys()].map((n) => query(n)), ) expect(results.sort()).toEqual([1, 2, 3, 4]) await sleep(socketTTL) const results2 = await Promise.all( - [...Array(4).keys()].map((n) => query(n + 10)) + [...Array(4).keys()].map((n) => query(n + 10)), ) expect(results2.sort()).toEqual([11, 12, 13, 14]) }) diff --git a/packages/client-node/__tests__/integration/node_logger.ts b/packages/client-node/__tests__/integration/node_logger.ts index 8db13e66..0d037bea 100644 --- a/packages/client-node/__tests__/integration/node_logger.ts +++ b/packages/client-node/__tests__/integration/node_logger.ts @@ -54,7 +54,7 @@ describe('[Node.js] logger support', () => { 'transfer-encoding': 'chunked', }), response_status: 200, - }) + }), ) }) @@ -74,7 +74,7 @@ describe('[Node.js] logger support', () => { request_path: '/ping', request_method: 'GET', }), - }) + }), ) }) diff --git a/packages/client-node/__tests__/integration/node_multiple_clients.test.ts b/packages/client-node/__tests__/integration/node_multiple_clients.test.ts index 179a6653..d229e25a 100644 --- a/packages/client-node/__tests__/integration/node_multiple_clients.test.ts +++ b/packages/client-node/__tests__/integration/node_multiple_clients.test.ts @@ -48,8 +48,8 @@ describe('[Node.js] multiple clients', () => { table: tableName, values: Stream.Readable.from([getValue(i)]), format: 'JSONEachRow', - }) - ) + }), + ), ) const result = await clients[0].query({ query: `SELECT * FROM ${tableName} ORDER BY id ASC`, diff --git a/packages/client-node/__tests__/integration/node_ping.test.ts b/packages/client-node/__tests__/integration/node_ping.test.ts index 3a284b14..9207495d 100644 --- a/packages/client-node/__tests__/integration/node_ping.test.ts +++ b/packages/client-node/__tests__/integration/node_ping.test.ts @@ -17,7 +17,7 @@ describe('[Node.js] ping', () => { expect(result.error).toEqual( jasmine.objectContaining({ code: 'ECONNREFUSED', - }) + }), ) }) }) diff --git a/packages/client-node/__tests__/integration/node_select_streaming.test.ts b/packages/client-node/__tests__/integration/node_select_streaming.test.ts index f49ab7d2..31413e77 100644 --- a/packages/client-node/__tests__/integration/node_select_streaming.test.ts +++ b/packages/client-node/__tests__/integration/node_select_streaming.test.ts @@ -16,14 +16,14 @@ describe('[Node.js] SELECT streaming', () => { await expectAsync(fn()).toBeRejectedWith( jasmine.objectContaining({ message: 'Stream has been already consumed', - }) + }), ) } function assertAlreadyConsumed(fn: () => T) { expect(fn).toThrow( jasmine.objectContaining({ message: 'Stream has been already consumed', - }) + }), ) } it('should consume a JSON response only once', async () => { @@ -79,7 +79,7 @@ describe('[Node.js] SELECT streaming', () => { await expectAsync((async () => result.stream())()).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('JSON format is not streamable'), - }) + }), ) } finally { result.close() diff --git a/packages/client-node/__tests__/integration/node_socket_timeout.test.ts b/packages/client-node/__tests__/integration/node_socket_timeout.test.ts index b21c9bcc..f59c4cff 100644 --- a/packages/client-node/__tests__/integration/node_socket_timeout.test.ts +++ b/packages/client-node/__tests__/integration/node_socket_timeout.test.ts @@ -52,13 +52,13 @@ describe('Node.js socket timeout handling', () => { const pingResult = await ping() expect(pingResult.success).toBeFalse() expect((pingResult as { error: Error }).error.message).toEqual( - jasmine.stringContaining('Timeout error.') + jasmine.stringContaining('Timeout error.'), ) await expectAsync(fn()) .withContext( `${opName} should have been rejected. Current ops: ${ops .map(({ opName }) => opName) - .join(', ')}` + .join(', ')}`, ) .toBeRejectedWithError('Timeout error.') } @@ -72,7 +72,7 @@ describe('Node.js socket timeout handling', () => { const pingResult = await client.ping() expect(pingResult.success).toBeFalse() expect((pingResult as { error: Error }).error.message).toEqual( - jasmine.stringContaining('Timeout error.') + jasmine.stringContaining('Timeout error.'), ) } expect().nothing() diff --git a/packages/client-node/__tests__/integration/node_stream_json_formats.test.ts b/packages/client-node/__tests__/integration/node_stream_json_formats.test.ts index fb0ff6d2..c196e2e2 100644 --- a/packages/client-node/__tests__/integration/node_stream_json_formats.test.ts +++ b/packages/client-node/__tests__/integration/node_stream_json_formats.test.ts @@ -178,9 +178,9 @@ describe('[Node.js] stream JSON formats', () => { await expectAsync(insertPromise).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringMatching( - `Type of 'name' must be String, not UInt64` + `Type of 'name' must be String, not UInt64`, ), - }) + }), ) }) @@ -243,7 +243,7 @@ describe('[Node.js] stream JSON formats', () => { client.insert({ table: tableName, values: stream, - }) + }), ).toBeResolved() }) @@ -281,7 +281,7 @@ describe('[Node.js] stream JSON formats', () => { format: 'JSONEachRow', table: tableName, }) - }) + }), ) setTimeout(() => { streams.forEach((stream) => stream.push(null)) @@ -299,11 +299,11 @@ describe('[Node.js] stream JSON formats', () => { table: tableName, values: stream, format: 'JSONEachRow', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Cannot parse input'), - }) + }), ) }) }) diff --git a/packages/client-node/__tests__/integration/node_stream_raw_formats.test.ts b/packages/client-node/__tests__/integration/node_stream_raw_formats.test.ts index 08b0549a..8bab203f 100644 --- a/packages/client-node/__tests__/integration/node_stream_raw_formats.test.ts +++ b/packages/client-node/__tests__/integration/node_stream_raw_formats.test.ts @@ -27,18 +27,18 @@ describe('[Node.js] stream raw formats', () => { `"baz","foo","[1,2]"\n43,"bar","[3,4]"\n`, { objectMode: false, - } + }, ) await expectAsync( client.insert({ table: tableName, values: stream, format: 'CSV', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Cannot parse input'), - }) + }), ) }) @@ -104,11 +104,11 @@ describe('[Node.js] stream raw formats', () => { table: tableName, values: stream, format: 'TabSeparated', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Cannot parse input'), - }) + }), ) }) @@ -124,7 +124,7 @@ describe('[Node.js] stream raw formats', () => { format: 'TabSeparated', table: tableName, }) - }) + }), ) setTimeout(() => { streams.forEach((stream) => stream.push(null)) @@ -179,7 +179,7 @@ describe('[Node.js] stream raw formats', () => { `"id","name","sku" 0,"foo","[1,2]" 0,"bar","[3,4]" -` +`, ) }) @@ -201,20 +201,20 @@ describe('[Node.js] stream raw formats', () => { `"id","name","sku"\n"UInt64","UInt64","Array(UInt8)"\n42,"foo","[1,2]"\n43,"bar","[3,4]"\n`, { objectMode: false, - } + }, ) await expectAsync( client.insert({ table: tableName, values: stream, format: 'CSVWithNamesAndTypes', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining( - `Type of 'name' must be String, not UInt64` + `Type of 'name' must be String, not UInt64`, ), - }) + }), ) }) @@ -227,11 +227,11 @@ describe('[Node.js] stream raw formats', () => { table: tableName, values: stream, format: 'CSV', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Cannot parse input'), - }) + }), ) }) @@ -247,7 +247,7 @@ describe('[Node.js] stream raw formats', () => { format: 'CSV', table: tableName, }) - }) + }), ) setTimeout(() => { streams.forEach((stream) => stream.push(null)) @@ -291,7 +291,7 @@ describe('[Node.js] stream raw formats', () => { await assertInsertedValues( 'CustomSeparatedWithNames', values, - clickhouse_settings + clickhouse_settings, ) }) @@ -309,7 +309,7 @@ describe('[Node.js] stream raw formats', () => { await assertInsertedValues( 'CustomSeparatedWithNamesAndTypes', values, - clickhouse_settings + clickhouse_settings, ) }) @@ -323,11 +323,11 @@ describe('[Node.js] stream raw formats', () => { values: stream, format: 'CustomSeparated', clickhouse_settings, - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Cannot parse input'), - }) + }), ) }) @@ -344,7 +344,7 @@ describe('[Node.js] stream raw formats', () => { table: tableName, clickhouse_settings, }) - }) + }), ) setTimeout(() => { streams.forEach((stream) => stream.push(null)) @@ -357,7 +357,7 @@ describe('[Node.js] stream raw formats', () => { async function assertInsertedValues( format: RawDataFormat, expected: string, - clickhouse_settings?: ClickHouseSettings + clickhouse_settings?: ClickHouseSettings, ) { const result = await client.query({ query: `SELECT * FROM ${tableName} ORDER BY id ASC`, diff --git a/packages/client-node/__tests__/integration/node_streaming_e2e.test.ts b/packages/client-node/__tests__/integration/node_streaming_e2e.test.ts index f3f247a9..38539f6f 100644 --- a/packages/client-node/__tests__/integration/node_streaming_e2e.test.ts +++ b/packages/client-node/__tests__/integration/node_streaming_e2e.test.ts @@ -1,5 +1,8 @@ import type { Row } from '@clickhouse/client-common' -import { type ClickHouseClient } from '@clickhouse/client-common' +import { + type ClickHouseClient, + type ClickHouseSettings, +} from '@clickhouse/client-common' import { fakerRU } from '@faker-js/faker' import { createSimpleTable } from '@test/fixtures/simple_table' import { createTableWithFields } from '@test/fixtures/table_with_fields' @@ -39,7 +42,7 @@ describe('[Node.js] streaming e2e', () => { table: tableName, values: Fs.createReadStream(filename).pipe( // should be removed when "insert" accepts a stream of strings/bytes - split((row: string) => JSON.parse(row)) + split((row: string) => JSON.parse(row)), ), format: 'JSONCompactEachRow', }) @@ -59,6 +62,15 @@ describe('[Node.js] streaming e2e', () => { }) it('should stream a Parquet file', async () => { + const streamParquetSettings: ClickHouseSettings = { + output_format_parquet_compression_method: 'none', + output_format_parquet_version: '2.6', + // 24.3+ has this enabled by default; prior versions need this setting to be enforced for consistent assertions + // Otherwise, the string type for Parquet will be Binary (24.3+) vs Utf8 (24.3-). + // https://github.com/ClickHouse/ClickHouse/pull/61817/files#diff-aa3c979016a9f8c6ab5a51560411afa3f4cef55d34c899a2b1e7aff38aca4076R1097 + output_format_parquet_string_as_string: 1, + } + const filename = 'packages/client-common/__tests__/fixtures/streaming_e2e_data.parquet' await client.insert({ @@ -85,10 +97,7 @@ describe('[Node.js] streaming e2e', () => { const stream = await client .exec({ query: `SELECT * from ${tableName} FORMAT Parquet`, - clickhouse_settings: { - output_format_parquet_compression_method: 'none', - output_format_parquet_version: '2.6', - }, + clickhouse_settings: streamParquetSettings, }) .then((r) => r.stream) @@ -98,17 +107,16 @@ describe('[Node.js] streaming e2e', () => { } const table = tableFromIPC( - readParquet(Buffer.concat(parquetChunks)).intoIPCStream() + readParquet(Buffer.concat(parquetChunks)).intoIPCStream(), ) expect(table.schema.toString()).toEqual( - 'Schema<{ 0: id: Uint64, 1: name: Binary, 2: sku: List }>' + 'Schema<{ 0: id: Uint64, 1: name: Utf8, 2: sku: List }>', ) const actualParquetData: unknown[] = [] - const textDecoder = new TextDecoder() table.toArray().map((v) => { const row: Record = {} row['id'] = v.id - row['name'] = textDecoder.decode(v.name) // [char] -> String + row['name'] = v.name row['sku'] = Array.from(v.sku.toArray()) // Vector -> UInt8Array -> Array actualParquetData.push(row) }) @@ -156,7 +164,7 @@ describe('[Node.js] streaming e2e', () => { }> { const table = await createTableWithFields( client as ClickHouseClient, - `sentence String, timestamp String` + `sentence String, timestamp String`, ) const values = [...new Array(rows)].map((_, id) => ({ id, diff --git a/packages/client-node/__tests__/integration/node_summary.test.ts b/packages/client-node/__tests__/integration/node_summary.test.ts index e81be7bc..ad42dfa4 100644 --- a/packages/client-node/__tests__/integration/node_summary.test.ts +++ b/packages/client-node/__tests__/integration/node_summary.test.ts @@ -10,7 +10,7 @@ import type Stream from 'stream' whenOnEnv( TestEnv.LocalSingleNode, TestEnv.LocalCluster, - TestEnv.Cloud + TestEnv.Cloud, ).describe('[Node.js] Summary header parsing', () => { let client: ClickHouseClient let tableName: string diff --git a/packages/client-node/__tests__/tls/tls.test.ts b/packages/client-node/__tests__/tls/tls.test.ts index c11de522..c7b590c4 100644 --- a/packages/client-node/__tests__/tls/tls.test.ts +++ b/packages/client-node/__tests__/tls/tls.test.ts @@ -63,13 +63,13 @@ describe('[Node.js] TLS connection', () => { client.query({ query: 'SELECT number FROM system.numbers LIMIT 3', format: 'CSV', - }) + }), ).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining( - 'Hostname/IP does not match certificate' + 'Hostname/IP does not match certificate', ), - }) + }), ) }) @@ -88,7 +88,7 @@ describe('[Node.js] TLS connection', () => { client.query({ query: 'SELECT number FROM system.numbers LIMIT 3', format: 'CSV', - }) + }), ).toBeRejectedWithError() }) }) diff --git a/packages/client-node/__tests__/unit/node_client.test.ts b/packages/client-node/__tests__/unit/node_client.test.ts index fbe7d3b7..93814232 100644 --- a/packages/client-node/__tests__/unit/node_client.test.ts +++ b/packages/client-node/__tests__/unit/node_client.test.ts @@ -11,7 +11,7 @@ describe('[Node.js] createClient', () => { expect(() => createClient({ url: 'foo' })).toThrow( jasmine.objectContaining({ message: jasmine.stringContaining('ClickHouse URL is malformed.'), - }) + }), ) }) @@ -75,7 +75,7 @@ describe('[Node.js] createClient', () => { { enabled: true, idle_socket_ttl: 2500, - } + }, ) expect(createConnectionStub).toHaveBeenCalledTimes(1) }) diff --git a/packages/client-node/__tests__/unit/node_config.test.ts b/packages/client-node/__tests__/unit/node_config.test.ts index 1aca4154..3c56fb00 100644 --- a/packages/client-node/__tests__/unit/node_config.test.ts +++ b/packages/client-node/__tests__/unit/node_config.test.ts @@ -15,7 +15,7 @@ describe('[Node.js] Config implementation details', () => { it('should handle known URL params', async () => { const url = new URL( 'http://localhost:8123/?' + - ['keep_alive_idle_socket_ttl=2500'].join('&') + ['keep_alive_idle_socket_ttl=2500'].join('&'), ) const config: BaseClickHouseClientConfigOptions = { keep_alive: { @@ -79,7 +79,7 @@ describe('[Node.js] Config implementation details', () => { const fakeConnection = { test: true } as unknown as NodeBaseConnection beforeEach(() => { createConnectionStub = spyOn(c, 'createConnection').and.returnValue( - fakeConnection + fakeConnection, ) }) @@ -94,7 +94,7 @@ describe('[Node.js] Config implementation details', () => { { enabled: true, idle_socket_ttl: 2500, - } + }, ) expect(createConnectionStub).toHaveBeenCalledTimes(1) expect(res).toEqual(fakeConnection) @@ -117,7 +117,7 @@ describe('[Node.js] Config implementation details', () => { { enabled: true, idle_socket_ttl: 2500, - } + }, ) expect(createConnectionStub).toHaveBeenCalledTimes(1) expect(res).toEqual(fakeConnection) @@ -144,7 +144,7 @@ describe('[Node.js] Config implementation details', () => { { enabled: true, idle_socket_ttl: 2500, - } + }, ) expect(createConnectionStub).toHaveBeenCalledTimes(1) expect(res).toEqual(fakeConnection) @@ -171,7 +171,7 @@ describe('[Node.js] Config implementation details', () => { { enabled: false, idle_socket_ttl: 42_000, - } + }, ) expect(createConnectionStub).toHaveBeenCalledTimes(1) expect(res).toEqual(fakeConnection) diff --git a/packages/client-node/__tests__/unit/node_connection.test.ts b/packages/client-node/__tests__/unit/node_connection.test.ts index b91ed66a..8b1507eb 100644 --- a/packages/client-node/__tests__/unit/node_connection.test.ts +++ b/packages/client-node/__tests__/unit/node_connection.test.ts @@ -15,7 +15,7 @@ describe('[Node.js] Connection', () => { const myHttpAdapter = new MyTestHttpConnection() const headers = myHttpAdapter.getDefaultHeaders() expect(headers['User-Agent']).toMatch( - /^clickhouse-js\/[0-9\\.]+-?(?:(alpha|beta)\.\d*)? \(lv:nodejs\/v[0-9\\.]+?; os:(?:linux|darwin|win32)\)$/ + /^clickhouse-js\/[0-9\\.]+-?(?:(alpha|beta)\.\d*)? \(lv:nodejs\/v[0-9\\.]+?; os:(?:linux|darwin|win32)\)$/, ) }) @@ -23,7 +23,7 @@ describe('[Node.js] Connection', () => { const myHttpAdapter = new MyTestHttpConnection('MyFancyApp') const headers = myHttpAdapter.getDefaultHeaders() expect(headers['User-Agent']).toMatch( - /^MyFancyApp clickhouse-js\/[0-9\\.]+-?(?:(alpha|beta)\.\d*)? \(lv:nodejs\/v[0-9\\.]+?; os:(?:linux|darwin|win32)\)$/ + /^MyFancyApp clickhouse-js\/[0-9\\.]+-?(?:(alpha|beta)\.\d*)? \(lv:nodejs\/v[0-9\\.]+?; os:(?:linux|darwin|win32)\)$/, ) }) }) diff --git a/packages/client-node/__tests__/unit/node_connection_compression.test.ts b/packages/client-node/__tests__/unit/node_connection_compression.test.ts index 9f13b741..b03b14be 100644 --- a/packages/client-node/__tests__/unit/node_connection_compression.test.ts +++ b/packages/client-node/__tests__/unit/node_connection_compression.test.ts @@ -132,7 +132,7 @@ describe('Node.js Connection compression', () => { await expectAsync(selectPromise).toBeRejectedWith( jasmine.objectContaining({ message: 'Unexpected encoding: br', - }) + }), ) }) @@ -158,7 +158,7 @@ describe('Node.js Connection compression', () => { headers: { 'content-encoding': 'gzip', }, - }) + }), ) const readStream = async () => { @@ -172,7 +172,7 @@ describe('Node.js Connection compression', () => { jasmine.objectContaining({ message: 'incorrect header check', code: 'Z_DATA_ERROR', - }) + }), ) }) }) diff --git a/packages/client-node/__tests__/unit/node_create_connection.test.ts b/packages/client-node/__tests__/unit/node_create_connection.test.ts index 7f2e8591..960d02cf 100644 --- a/packages/client-node/__tests__/unit/node_create_connection.test.ts +++ b/packages/client-node/__tests__/unit/node_create_connection.test.ts @@ -21,7 +21,7 @@ describe('[Node.js] createConnection', () => { url: new URL('http://localhost'), } as ConnectionParams, tlsParams, - keepAliveParams + keepAliveParams, ) it('should create an instance of HTTPS adapter', async () => { @@ -30,7 +30,7 @@ describe('[Node.js] createConnection', () => { url: new URL('https://localhost'), } as ConnectionParams, tlsParams, - keepAliveParams + keepAliveParams, ) expect(adapter).toBeInstanceOf(NodeHttpsConnection) }) @@ -42,8 +42,8 @@ describe('[Node.js] createConnection', () => { url: new URL('tcp://localhost'), } as ConnectionParams, tlsParams, - keepAliveParams - ) + keepAliveParams, + ), ).toThrowError('Only HTTP and HTTPS protocols are supported') }) }) diff --git a/packages/client-node/__tests__/unit/node_logger.test.ts b/packages/client-node/__tests__/unit/node_logger.test.ts index d57f8929..c6d41402 100644 --- a/packages/client-node/__tests__/unit/node_logger.test.ts +++ b/packages/client-node/__tests__/unit/node_logger.test.ts @@ -28,7 +28,7 @@ describe('[Node.js] Logger/LogWriter', () => { const logWriter = new LogWriter( new TestLogger(), 'LoggerTest', - ClickHouseLogLevel.TRACE + ClickHouseLogLevel.TRACE, ) checkLogLevelSet('TRACE') logEveryLogLevel(logWriter) @@ -65,7 +65,7 @@ describe('[Node.js] Logger/LogWriter', () => { const logWriter = new LogWriter( new TestLogger(), 'LoggerTest', - ClickHouseLogLevel.DEBUG + ClickHouseLogLevel.DEBUG, ) checkLogLevelSet('DEBUG') logEveryLogLevel(logWriter) @@ -97,7 +97,7 @@ describe('[Node.js] Logger/LogWriter', () => { const logWriter = new LogWriter( new TestLogger(), 'LoggerTest', - ClickHouseLogLevel.INFO + ClickHouseLogLevel.INFO, ) checkLogLevelSet('INFO') logEveryLogLevel(logWriter) @@ -124,7 +124,7 @@ describe('[Node.js] Logger/LogWriter', () => { const logWriter = new LogWriter( new TestLogger(), 'LoggerTest', - ClickHouseLogLevel.WARN + ClickHouseLogLevel.WARN, ) logEveryLogLevel(logWriter) expect(logs[0]).toEqual({ @@ -145,7 +145,7 @@ describe('[Node.js] Logger/LogWriter', () => { const logWriter = new LogWriter( new TestLogger(), 'LoggerTest', - ClickHouseLogLevel.ERROR + ClickHouseLogLevel.ERROR, ) logEveryLogLevel(logWriter) expect(logs[0]).toEqual({ diff --git a/packages/client-node/__tests__/unit/node_result_set.test.ts b/packages/client-node/__tests__/unit/node_result_set.test.ts index 2301269b..a6b053e5 100644 --- a/packages/client-node/__tests__/unit/node_result_set.test.ts +++ b/packages/client-node/__tests__/unit/node_result_set.test.ts @@ -53,7 +53,7 @@ describe('[Node.js] ResultSet', () => { const rs = new ResultSet( Stream.Readable.from([Buffer.from('{"foo":"bar"}\n')]), 'JSONEachRow', - guid() + guid(), ) const allRows: Row[] = [] for await (const rows of rs.stream()) { @@ -74,7 +74,7 @@ describe('[Node.js] ResultSet', () => { Buffer.from('{"qaz":"qux"}\n'), ]), 'JSONEachRow', - guid() + guid(), ) } }) diff --git a/packages/client-node/__tests__/unit/node_user_agent.test.ts b/packages/client-node/__tests__/unit/node_user_agent.test.ts index b45548af..cb55b28b 100644 --- a/packages/client-node/__tests__/unit/node_user_agent.test.ts +++ b/packages/client-node/__tests__/unit/node_user_agent.test.ts @@ -14,14 +14,14 @@ describe('[Node.js] User-Agent', () => { it('should generate a user agent without app id', async () => { const userAgent = getUserAgent() expect(userAgent).toEqual( - 'clickhouse-js/0.0.42 (lv:nodejs/v16.144; os:freebsd)' + 'clickhouse-js/0.0.42 (lv:nodejs/v16.144; os:freebsd)', ) }) it('should generate a user agent with app id', async () => { const userAgent = getUserAgent() expect(userAgent).toEqual( - 'clickhouse-js/0.0.42 (lv:nodejs/v16.144; os:freebsd)' + 'clickhouse-js/0.0.42 (lv:nodejs/v16.144; os:freebsd)', ) }) }) diff --git a/packages/client-node/__tests__/unit/node_values_encoder.test.ts b/packages/client-node/__tests__/unit/node_values_encoder.test.ts index 012f61c9..94e95a45 100644 --- a/packages/client-node/__tests__/unit/node_values_encoder.test.ts +++ b/packages/client-node/__tests__/unit/node_values_encoder.test.ts @@ -59,26 +59,26 @@ describe('[Node.js] ValuesEncoder', () => { objectFormats.forEach((format) => { expect(() => - encoder.validateInsertValues(objectModeStream, format as DataFormat) + encoder.validateInsertValues(objectModeStream, format as DataFormat), ).not.toThrow() expect(() => - encoder.validateInsertValues(rawStream, format as DataFormat) + encoder.validateInsertValues(rawStream, format as DataFormat), ).toThrow( jasmine.objectContaining({ message: jasmine.stringContaining('with enabled object mode'), - }) + }), ) }) rawFormats.forEach((format) => { expect(() => - encoder.validateInsertValues(objectModeStream, format as DataFormat) + encoder.validateInsertValues(objectModeStream, format as DataFormat), ).toThrow( jasmine.objectContaining({ message: jasmine.stringContaining('with disabled object mode'), - }) + }), ) expect(() => - encoder.validateInsertValues(rawStream, format as DataFormat) + encoder.validateInsertValues(rawStream, format as DataFormat), ).not.toThrow() }) }) @@ -91,7 +91,7 @@ describe('[Node.js] ValuesEncoder', () => { rawFormats.forEach((format) => { // should be exactly the same object (no duplicate instances) expect(encoder.encodeValues(values, format as DataFormat)).toEqual( - values + values, ) }) }) @@ -155,7 +155,7 @@ describe('[Node.js] ValuesEncoder', () => { it('should fail when we try to encode an unknown type of input', async () => { expect(() => encoder.encodeValues(1 as any, 'JSON')).toThrowError( - 'Cannot encode values of type number with JSON format' + 'Cannot encode values of type number with JSON format', ) }) }) diff --git a/packages/client-node/__tests__/utils/assert.ts b/packages/client-node/__tests__/utils/assert.ts index bcdf0f58..3cdf0edf 100644 --- a/packages/client-node/__tests__/utils/assert.ts +++ b/packages/client-node/__tests__/utils/assert.ts @@ -5,7 +5,7 @@ import { getAsText } from '../../src/utils' export async function assertConnQueryResult( { stream, query_id }: ConnQueryResult, - expectedResponseBody: any + expectedResponseBody: any, ) { expect(await getAsText(stream)).toBe(expectedResponseBody) assertQueryId(query_id) diff --git a/packages/client-node/__tests__/utils/http_stubs.ts b/packages/client-node/__tests__/utils/http_stubs.ts index ab7065e3..2863b861 100644 --- a/packages/client-node/__tests__/utils/http_stubs.ts +++ b/packages/client-node/__tests__/utils/http_stubs.ts @@ -65,20 +65,20 @@ export function stubClientRequest(): ClientRequest { export function emitResponseBody( request: Http.ClientRequest, - body: string | Buffer | undefined + body: string | Buffer | undefined, ) { request.emit( 'response', buildIncomingMessage({ body, - }) + }), ) } export async function emitCompressedBody( request: ClientRequest, body: string | Buffer, - encoding = 'gzip' + encoding = 'gzip', ) { const compressedBody = await gzip(body) request.emit( @@ -88,7 +88,7 @@ export async function emitCompressedBody( headers: { 'content-encoding': encoding, }, - }) + }), ) } @@ -127,7 +127,7 @@ export class MyTestHttpConnection extends NodeBaseConnection { enabled: false, }, } as NodeConnectionParams, - {} as Http.Agent + {} as Http.Agent, ) } protected createClientRequest(): Http.ClientRequest { diff --git a/packages/client-node/src/client.ts b/packages/client-node/src/client.ts index 1191e49f..ce81b5e5 100644 --- a/packages/client-node/src/client.ts +++ b/packages/client-node/src/client.ts @@ -4,7 +4,7 @@ import type { NodeClickHouseClientConfigOptions } from './config' import { NodeConfigImpl } from './config' export function createClient( - config?: NodeClickHouseClientConfigOptions + config?: NodeClickHouseClientConfigOptions, ): ClickHouseClient { return new ClickHouseClient({ impl: NodeConfigImpl, diff --git a/packages/client-node/src/config.ts b/packages/client-node/src/config.ts index 0594283e..f6c49edc 100644 --- a/packages/client-node/src/config.ts +++ b/packages/client-node/src/config.ts @@ -72,7 +72,7 @@ export const NodeConfigImpl: Required< }, make_connection: ( nodeConfig: NodeClickHouseClientConfigOptions, - params: ConnectionParams + params: ConnectionParams, ) => { let tls: TLSParams | undefined = undefined if (nodeConfig.tls !== undefined) { @@ -98,7 +98,7 @@ export const NodeConfigImpl: Required< make_result_set: ( stream: Stream.Readable, format: DataFormat, - session_id: string + session_id: string, ) => new ResultSet(stream, format, session_id), close_stream: async (stream) => { stream.destroy() diff --git a/packages/client-node/src/connection/compression.ts b/packages/client-node/src/connection/compression.ts index a864b9c7..4bd90933 100644 --- a/packages/client-node/src/connection/compression.ts +++ b/packages/client-node/src/connection/compression.ts @@ -20,7 +20,7 @@ export function decompressResponse(response: Http.IncomingMessage): // eslint-disable-next-line no-console console.error(err) } - } + }, ), } } else if (encoding !== undefined) { diff --git a/packages/client-node/src/connection/create_connection.ts b/packages/client-node/src/connection/create_connection.ts index 515b1432..f10f77a4 100644 --- a/packages/client-node/src/connection/create_connection.ts +++ b/packages/client-node/src/connection/create_connection.ts @@ -9,7 +9,7 @@ import { NodeHttpsConnection } from './node_https_connection' export function createConnection( params: ConnectionParams, tls: NodeConnectionParams['tls'], - keep_alive: NodeConnectionParams['keep_alive'] + keep_alive: NodeConnectionParams['keep_alive'], ): NodeBaseConnection { switch (params.url.protocol) { case 'http:': diff --git a/packages/client-node/src/connection/node_base_connection.ts b/packages/client-node/src/connection/node_base_connection.ts index 554c9668..f32eb139 100644 --- a/packages/client-node/src/connection/node_base_connection.ts +++ b/packages/client-node/src/connection/node_base_connection.ts @@ -69,27 +69,27 @@ export abstract class NodeBaseConnection protected constructor( protected readonly params: NodeConnectionParams, - protected readonly agent: Http.Agent + protected readonly agent: Http.Agent, ) { this.logger = params.log_writer this.idleSocketTTL = params.keep_alive.idle_socket_ttl this.headers = this.buildDefaultHeaders( params.username, params.password, - params.http_headers + params.http_headers, ) } protected buildDefaultHeaders( username: string, password: string, - additional_http_headers?: Record + additional_http_headers?: Record, ): Http.OutgoingHttpHeaders { return { // KeepAlive agent for some reason does not set this on its own Connection: this.params.keep_alive.enabled ? 'keep-alive' : 'close', Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString( - 'base64' + 'base64', )}`, 'User-Agent': getUserAgent(this.params.application_id), ...additional_http_headers, @@ -97,12 +97,12 @@ export abstract class NodeBaseConnection } protected abstract createClientRequest( - params: RequestParams + params: RequestParams, ): Http.ClientRequest private async request( params: RequestParams, - op: ConnOperation + op: ConnOperation, ): Promise { return new Promise((resolve, reject) => { const start = Date.now() @@ -114,7 +114,7 @@ export abstract class NodeBaseConnection } const onResponse = async ( - _response: Http.IncomingMessage + _response: Http.IncomingMessage, ): Promise => { this.logResponse(op, request, params, _response, start) @@ -287,7 +287,7 @@ export abstract class NodeBaseConnection url: transformUrl({ url: this.params.url, pathname: '/ping' }), abort_signal: abortController.signal, }, - 'Ping' + 'Ping', ) await drainStream(stream) return { success: true } @@ -308,12 +308,12 @@ export abstract class NodeBaseConnection } async query( - params: ConnBaseQueryParams + params: ConnBaseQueryParams, ): Promise> { const query_id = this.getQueryId(params.query_id) const clickhouse_settings = withHttpSettings( params.clickhouse_settings, - this.params.compression.decompress_response + this.params.compression.decompress_response, ) const searchParams = toSearchParams({ database: this.params.database, @@ -333,7 +333,7 @@ export abstract class NodeBaseConnection abort_signal: controller.signal, decompress_response: decompressResponse, }, - 'Query' + 'Query', ) return { stream, @@ -359,7 +359,7 @@ export abstract class NodeBaseConnection } async exec( - params: ConnBaseQueryParams + params: ConnBaseQueryParams, ): Promise> { const query_id = this.getQueryId(params.query_id) const searchParams = toSearchParams({ @@ -379,7 +379,7 @@ export abstract class NodeBaseConnection abort_signal: controller.signal, parse_summary: true, }, - 'Exec' + 'Exec', ) return { stream, @@ -405,7 +405,7 @@ export abstract class NodeBaseConnection } async insert( - params: ConnInsertParams + params: ConnInsertParams, ): Promise { const query_id = this.getQueryId(params.query_id) const searchParams = toSearchParams({ @@ -427,7 +427,7 @@ export abstract class NodeBaseConnection compress_request: this.params.compression.compress_request, parse_summary: true, }, - 'Insert' + 'Insert', ) await drainStream(stream) return { query_id, summary } @@ -482,7 +482,7 @@ export abstract class NodeBaseConnection request: Http.ClientRequest, params: RequestParams, response: Http.IncomingMessage, - startTimestamp: number + startTimestamp: number, ) { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { authorization, host, ...headers } = request.getHeaders() @@ -530,7 +530,7 @@ export abstract class NodeBaseConnection private parseSummary( op: ConnOperation, - response: Http.IncomingMessage + response: Http.IncomingMessage, ): ClickHouseSummary | undefined { const summaryHeader = response.headers['x-clickhouse-summary'] if (typeof summaryHeader === 'string') { diff --git a/packages/client-node/src/connection/node_https_connection.ts b/packages/client-node/src/connection/node_https_connection.ts index 70b43b50..2ab3d7b3 100644 --- a/packages/client-node/src/connection/node_https_connection.ts +++ b/packages/client-node/src/connection/node_https_connection.ts @@ -22,7 +22,7 @@ export class NodeHttpsConnection extends NodeBaseConnection { protected override buildDefaultHeaders( username: string, password: string, - additional_headers?: Record + additional_headers?: Record, ): Http.OutgoingHttpHeaders { if (this.params.tls?.type === 'Mutual') { return { diff --git a/packages/client-node/src/result_set.ts b/packages/client-node/src/result_set.ts index a0c1eff1..79faa007 100644 --- a/packages/client-node/src/result_set.ts +++ b/packages/client-node/src/result_set.ts @@ -11,7 +11,7 @@ export class ResultSet implements BaseResultSet { constructor( private _stream: Stream.Readable, private readonly format: DataFormat, - public readonly query_id: string + public readonly query_id: string, ) {} async text(): Promise { @@ -43,7 +43,7 @@ export class ResultSet implements BaseResultSet { transform( chunk: Buffer, _encoding: BufferEncoding, - callback: TransformCallback + callback: TransformCallback, ) { const rows: Row[] = [] let lastIdx = 0 @@ -55,7 +55,7 @@ export class ResultSet implements BaseResultSet { if (incompleteChunks.length > 0) { text = Buffer.concat( [...incompleteChunks, chunk.subarray(0, idx)], - incompleteChunks.reduce((sz, buf) => sz + buf.length, 0) + idx + incompleteChunks.reduce((sz, buf) => sz + buf.length, 0) + idx, ).toString() incompleteChunks = [] } else { diff --git a/packages/client-node/src/utils/encoder.ts b/packages/client-node/src/utils/encoder.ts index 9b4d4c0e..fadc60c5 100644 --- a/packages/client-node/src/utils/encoder.ts +++ b/packages/client-node/src/utils/encoder.ts @@ -10,7 +10,7 @@ import { isStream, mapStream } from './stream' export class NodeValuesEncoder implements ValuesEncoder { encodeValues( values: InsertValues, - format: DataFormat + format: DataFormat, ): string | Stream.Readable { if (isStream(values)) { // TSV/CSV/CustomSeparated formats don't require additional serialization @@ -21,7 +21,7 @@ export class NodeValuesEncoder implements ValuesEncoder { return Stream.pipeline( values, mapStream((value) => encodeJSON(value, format)), - pipelineCb + pipelineCb, ) } // JSON* arrays @@ -33,13 +33,13 @@ export class NodeValuesEncoder implements ValuesEncoder { return encodeJSON(values, format) } throw new Error( - `Cannot encode values of type ${typeof values} with ${format} format` + `Cannot encode values of type ${typeof values} with ${format} format`, ) } validateInsertValues( values: InsertValues, - format: DataFormat + format: DataFormat, ): void { if ( !Array.isArray(values) && @@ -48,7 +48,7 @@ export class NodeValuesEncoder implements ValuesEncoder { ) { throw new Error( 'Insert expected "values" to be an array, a stream of values or a JSON object, ' + - `got: ${typeof values}` + `got: ${typeof values}`, ) } @@ -56,12 +56,12 @@ export class NodeValuesEncoder implements ValuesEncoder { if (isSupportedRawFormat(format)) { if (values.readableObjectMode) { throw new Error( - `Insert for ${format} expected Readable Stream with disabled object mode.` + `Insert for ${format} expected Readable Stream with disabled object mode.`, ) } } else if (!values.readableObjectMode) { throw new Error( - `Insert for ${format} expected Readable Stream with enabled object mode.` + `Insert for ${format} expected Readable Stream with enabled object mode.`, ) } } diff --git a/packages/client-node/src/utils/stream.ts b/packages/client-node/src/utils/stream.ts index 65dcb552..279769e3 100644 --- a/packages/client-node/src/utils/stream.ts +++ b/packages/client-node/src/utils/stream.ts @@ -18,7 +18,7 @@ export async function getAsText(stream: Stream.Readable): Promise { } export function mapStream( - mapper: (input: unknown) => string + mapper: (input: unknown) => string, ): Stream.Transform { return new Stream.Transform({ objectMode: true, diff --git a/packages/client-web/__tests__/integration/web_abort_request.test.ts b/packages/client-web/__tests__/integration/web_abort_request.test.ts index 66d8cba5..ceeb5bcd 100644 --- a/packages/client-web/__tests__/integration/web_abort_request.test.ts +++ b/packages/client-web/__tests__/integration/web_abort_request.test.ts @@ -39,7 +39,7 @@ describe('[Web] abort request streaming', () => { jasmine.objectContaining({ // Chrome = The user aborted a request; FF = The operation was aborted message: jasmine.stringContaining('aborted'), - }) + }), ) }) @@ -67,7 +67,7 @@ describe('[Web] abort request streaming', () => { await expectAsync(selectPromise).toBeRejectedWith( jasmine.objectContaining({ message: jasmine.stringContaining('Stream has been already consumed'), - }) + }), ) }) }) diff --git a/packages/client-web/__tests__/integration/web_client.test.ts b/packages/client-web/__tests__/integration/web_client.test.ts index 8ee83429..20dddd19 100644 --- a/packages/client-web/__tests__/integration/web_client.test.ts +++ b/packages/client-web/__tests__/integration/web_client.test.ts @@ -5,7 +5,7 @@ describe('[Web] Client', () => { let fetchSpy: jasmine.Spy beforeEach(() => { fetchSpy = spyOn(window, 'fetch').and.returnValue( - Promise.resolve(new Response()) + Promise.resolve(new Response()), ) }) diff --git a/packages/client-web/__tests__/integration/web_error_parsing.test.ts b/packages/client-web/__tests__/integration/web_error_parsing.test.ts index 3f16761a..c79d1ed8 100644 --- a/packages/client-web/__tests__/integration/web_error_parsing.test.ts +++ b/packages/client-web/__tests__/integration/web_error_parsing.test.ts @@ -8,12 +8,12 @@ describe('[Web] errors parsing', () => { await expectAsync( client.query({ query: 'SELECT * FROM system.numbers LIMIT 3', - }) + }), ).toBeRejectedWith( // Chrome = Failed to fetch; FF = NetworkError when attempting to fetch resource jasmine.objectContaining({ message: jasmine.stringContaining('to fetch'), - }) + }), ) }) }) diff --git a/packages/client-web/__tests__/integration/web_ping.test.ts b/packages/client-web/__tests__/integration/web_ping.test.ts index 567cc8ea..0d172a01 100644 --- a/packages/client-web/__tests__/integration/web_ping.test.ts +++ b/packages/client-web/__tests__/integration/web_ping.test.ts @@ -18,7 +18,7 @@ describe('[Web] ping', () => { // Chrome = Failed to fetch; FF = NetworkError when attempting to fetch resource jasmine.objectContaining({ message: jasmine.stringContaining('to fetch'), - }) + }), ) }) }) diff --git a/packages/client-web/__tests__/integration/web_select_streaming.test.ts b/packages/client-web/__tests__/integration/web_select_streaming.test.ts index 63723d97..f3e02830 100644 --- a/packages/client-web/__tests__/integration/web_select_streaming.test.ts +++ b/packages/client-web/__tests__/integration/web_select_streaming.test.ts @@ -15,14 +15,14 @@ describe('[Web] SELECT streaming', () => { await expectAsync(fn()).toBeRejectedWith( jasmine.objectContaining({ message: 'Stream has been already consumed', - }) + }), ) } function assertAlreadyConsumed(fn: () => T) { expect(fn).toThrow( jasmine.objectContaining({ message: 'Stream has been already consumed', - }) + }), ) } it('should consume a JSON response only once', async () => { @@ -73,7 +73,7 @@ describe('[Web] SELECT streaming', () => { expect(() => result.stream()).toThrow( jasmine.objectContaining({ message: jasmine.stringContaining('JSON format is not streamable'), - }) + }), ) }) }) @@ -202,7 +202,7 @@ describe('[Web] SELECT streaming', () => { }) async function rowsJsonValues( - stream: ReadableStream + stream: ReadableStream, ): Promise { const result: T[] = [] const reader = stream.getReader() diff --git a/packages/client-web/__tests__/unit/web_client.test.ts b/packages/client-web/__tests__/unit/web_client.test.ts index 4b894905..01a07448 100644 --- a/packages/client-web/__tests__/unit/web_client.test.ts +++ b/packages/client-web/__tests__/unit/web_client.test.ts @@ -6,7 +6,7 @@ describe('[Web] createClient', () => { expect(() => createClient({ url: 'foo' })).toThrow( jasmine.objectContaining({ message: jasmine.stringContaining('ClickHouse URL is malformed.'), - }) + }), ) }) diff --git a/packages/client-web/__tests__/unit/web_result_set.test.ts b/packages/client-web/__tests__/unit/web_result_set.test.ts index bba01f1e..2c9918eb 100644 --- a/packages/client-web/__tests__/unit/web_result_set.test.ts +++ b/packages/client-web/__tests__/unit/web_result_set.test.ts @@ -56,7 +56,7 @@ describe('[Web] ResultSet', () => { }, }), 'JSONEachRow', - guid() + guid(), ) const allRows: Row[] = [] @@ -86,7 +86,7 @@ describe('[Web] ResultSet', () => { }, }), 'JSONEachRow', - guid() + guid(), ) } }) diff --git a/packages/client-web/src/client.ts b/packages/client-web/src/client.ts index 1a2e2441..d08a08dc 100644 --- a/packages/client-web/src/client.ts +++ b/packages/client-web/src/client.ts @@ -19,14 +19,14 @@ export type WebClickHouseClient = Omit< insert( params: Omit, 'values'> & { values: ReadonlyArray | InputJSON | InputJSONObjectEachRow - } + }, ): Promise // narrow down the return type here for better type-hinting query(params: QueryParams): Promise>> } export function createClient( - config?: WebClickHouseClientConfigOptions + config?: WebClickHouseClientConfigOptions, ): WebClickHouseClient { return new ClickHouseClient({ impl: WebImpl, diff --git a/packages/client-web/src/config.ts b/packages/client-web/src/config.ts index ed332f87..323912cf 100644 --- a/packages/client-web/src/config.ts +++ b/packages/client-web/src/config.ts @@ -15,7 +15,7 @@ export const WebImpl: ImplementationDetails['impl'] = { make_result_set: ( stream: ReadableStream, format: DataFormat, - query_id: string + query_id: string, ) => new ResultSet(stream, format, query_id), values_encoder: new WebValuesEncoder(), close_stream: (stream) => stream.cancel(), diff --git a/packages/client-web/src/connection/web_connection.ts b/packages/client-web/src/connection/web_connection.ts index 9e4167da..9d0e3f7a 100644 --- a/packages/client-web/src/connection/web_connection.ts +++ b/packages/client-web/src/connection/web_connection.ts @@ -36,12 +36,12 @@ export class WebConnection implements Connection { } async query( - params: ConnBaseQueryParams + params: ConnBaseQueryParams, ): Promise>> { const query_id = getQueryId(params.query_id) const clickhouse_settings = withHttpSettings( params.clickhouse_settings, - this.params.compression.decompress_response + this.params.compression.decompress_response, ) const searchParams = toSearchParams({ database: this.params.database, @@ -62,7 +62,7 @@ export class WebConnection implements Connection { } async exec( - params: ConnBaseQueryParams + params: ConnBaseQueryParams, ): Promise>> { const query_id = getQueryId(params.query_id) const searchParams = toSearchParams({ @@ -84,7 +84,7 @@ export class WebConnection implements Connection { } async insert( - params: WebInsertParams + params: WebInsertParams, ): Promise { const query_id = getQueryId(params.query_id) const searchParams = toSearchParams({ @@ -188,8 +188,8 @@ export class WebConnection implements Connection { } else { return Promise.reject( parseError( - await getAsText(response.body || new ReadableStream()) - ) + await getAsText(response.body || new ReadableStream()), + ), ) } } catch (err) { diff --git a/packages/client-web/src/result_set.ts b/packages/client-web/src/result_set.ts index 9052afe0..0878b345 100644 --- a/packages/client-web/src/result_set.ts +++ b/packages/client-web/src/result_set.ts @@ -7,7 +7,7 @@ export class ResultSet implements BaseResultSet> { constructor( private _stream: ReadableStream, private readonly format: DataFormat, - public readonly query_id: string + public readonly query_id: string, ) {} async text(): Promise { diff --git a/packages/client-web/src/utils/encoder.ts b/packages/client-web/src/utils/encoder.ts index e31ca535..0f7f6ea7 100644 --- a/packages/client-web/src/utils/encoder.ts +++ b/packages/client-web/src/utils/encoder.ts @@ -9,7 +9,7 @@ import { isStream } from './stream' export class WebValuesEncoder implements ValuesEncoder { encodeValues( values: InsertValues, - format: DataFormat + format: DataFormat, ): string | ReadableStream { throwIfStream(values) // JSON* arrays @@ -21,7 +21,7 @@ export class WebValuesEncoder implements ValuesEncoder { return encodeJSON(values, format) } throw new Error( - `Cannot encode values of type ${typeof values} with ${format} format` + `Cannot encode values of type ${typeof values} with ${format} format`, ) } @@ -30,7 +30,7 @@ export class WebValuesEncoder implements ValuesEncoder { if (!Array.isArray(values) && typeof values !== 'object') { throw new Error( 'Insert expected "values" to be an array or a JSON object, ' + - `got: ${typeof values}` + `got: ${typeof values}`, ) } } @@ -39,7 +39,7 @@ export class WebValuesEncoder implements ValuesEncoder { function throwIfStream(values: unknown) { if (isStream(values)) { throw new Error( - 'Streaming is not supported for inserts in the web version of the client' + 'Streaming is not supported for inserts in the web version of the client', ) } } diff --git a/tsconfig.all.json b/tsconfig.all.json index e5bdd36d..8edcbed4 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -8,6 +8,8 @@ "benchmarks/**/*.ts" ], "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", "noUnusedLocals": false, "noUnusedParameters": false, "outDir": "out", diff --git a/tsconfig.dev.json b/tsconfig.dev.json index fc697ae6..49144782 100644 --- a/tsconfig.dev.json +++ b/tsconfig.dev.json @@ -2,6 +2,8 @@ "extends": "./tsconfig.json", "include": ["./packages/**/*.ts", ".build/**/*.ts"], "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", "noUnusedLocals": false, "noUnusedParameters": false, "outDir": "out", diff --git a/tsconfig.json b/tsconfig.json index 20f42aa2..4c82fd98 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "es2020", - "module": "commonjs", - "moduleResolution": "node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "declaration": true, "pretty": true, "noEmitOnError": true, diff --git a/tsconfig.webpack.json b/tsconfig.webpack.json index ad886653..858adc9a 100644 --- a/tsconfig.webpack.json +++ b/tsconfig.webpack.json @@ -1,8 +1,8 @@ { "compilerOptions": { - "module": "es6", "target": "es6", - "moduleResolution": "node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "allowJs": true, "noImplicitAny": true, "esModuleInterop": true,