|
| 1 | +/// <reference types="node" /> |
| 2 | +import * as https from "https"; |
| 3 | +import * as stream from "stream"; |
| 4 | + |
| 5 | +declare class ClickHouse { |
| 6 | + constructor(options: ClickHouse.Options); |
| 7 | + query(chQuery: string, options: ClickHouse.QueryOptions, cb?: ClickHouse.QueryCallback): ClickHouse.RecordStream; |
| 8 | + query(chQuery: string, cb?: ClickHouse.QueryCallback): ClickHouse.RecordStream; |
| 9 | + querying(chQuery: string, options?: ClickHouse.QueryOptions): Promise<ClickHouse.QueryResult>; |
| 10 | + ping(cb?: ClickHouse.QueryCallback): ClickHouse.RecordStream; |
| 11 | + pinging(): Promise<ClickHouse.QueryResult>; |
| 12 | +} |
| 13 | + |
| 14 | +declare namespace ClickHouse { |
| 15 | + type SpecificConstructorOptions = { |
| 16 | + user?: string; |
| 17 | + password?: string; |
| 18 | + useQueryString?: boolean; |
| 19 | + } & QueryOptions; |
| 20 | + |
| 21 | + type ConstructorOptions = https.RequestOptions & SpecificConstructorOptions; |
| 22 | + |
| 23 | + export type Options = ConstructorOptions | string; |
| 24 | + |
| 25 | + export type QueryOptions = { |
| 26 | + dataObjects?: boolean; |
| 27 | + format?: string; |
| 28 | + syncParser?: boolean; |
| 29 | + omitFormat?: boolean; |
| 30 | + readonly?: boolean; |
| 31 | + |
| 32 | + // Any object suitable for querystring.stringify() |
| 33 | + // @see https://nodejs.org/docs/latest-v8.x/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options |
| 34 | + queryOptions?: { |
| 35 | + [key: string]: string | Array<string> | number | Array<number> | boolean | Array<boolean>; |
| 36 | + }; |
| 37 | + }; |
| 38 | + |
| 39 | + export type QueryCallback = (error?: Error) => void; |
| 40 | + |
| 41 | + export class RecordStream extends stream.Duplex {} |
| 42 | + |
| 43 | + export type Value = any; |
| 44 | + |
| 45 | + export type QueryResult = Array<Array<Value>>; |
| 46 | +} |
| 47 | + |
| 48 | +export = ClickHouse; |
0 commit comments