Skip to content

Commit b1d05cb

Browse files
author
Slava Baginov
committed
Added typings for package
1 parent 263e564 commit b1d05cb

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"mocha": "^2.5.3",
3535
"nyc": "^10.2.0"
3636
},
37+
"typings": "typings.d.ts",
3738
"engines": {
3839
"node": ">=0.10"
3940
}

typings.d.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)