-
Notifications
You must be signed in to change notification settings - Fork 48
Added typings for package #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SlNPacifist
wants to merge
2
commits into
apla:master
Choose a base branch
from
SlNPacifist:typings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /// <reference types="node" /> | ||
| import * as https from "https"; | ||
| import * as stream from "stream"; | ||
|
|
||
| declare class ClickHouse<ConstructorOptions extends ClickHouse.Options = ClickHouse.Options> { | ||
| constructor(options: ConstructorOptions); | ||
| query(chQuery: string, options: ClickHouse.QueryOptions, cb?: ClickHouse.QueryCallback): ClickHouse.RecordStream; | ||
| query(chQuery: string, cb?: ClickHouse.QueryCallback): ClickHouse.RecordStream; | ||
| querying< | ||
| QueryOptions extends ClickHouse.QueryOptions, | ||
| RecordType extends ClickHouse.DefaultRecordType<ConstructorOptions, QueryOptions, unknown> = ClickHouse.DefaultRecordType<ConstructorOptions, QueryOptions, any> | ||
| >(chQuery: string, options?: QueryOptions): Promise<ClickHouse.QueryResult<RecordType>>; | ||
| ping(cb?: ClickHouse.QueryCallback): ClickHouse.RecordStream; | ||
| pinging(): Promise<string>; | ||
| } | ||
|
|
||
| declare namespace ClickHouse { | ||
| type SpecificConstructorOptions = { | ||
| // Host is required, overriding it | ||
| host: string; | ||
| user?: string; | ||
| password?: string; | ||
| useQueryString?: boolean; | ||
| } & QueryOptions; | ||
|
|
||
| type ConstructorOptions = https.RequestOptions & SpecificConstructorOptions; | ||
|
|
||
| export type Options = ConstructorOptions | string; | ||
|
|
||
| export type QueryOptions = { | ||
| dataObjects?: boolean; | ||
| format?: Format; | ||
| syncParser?: boolean; | ||
| omitFormat?: boolean; | ||
| readonly?: boolean; | ||
| queryOptions?: { | ||
| [key: string]: string | number | boolean; | ||
| }; | ||
| }; | ||
|
|
||
| export type QueryCallback = (error?: Error) => void; | ||
|
|
||
| export class RecordStream extends stream.Duplex {} | ||
|
|
||
| export type Format = "TabSeparated" | "TSV" | "TabSeparatedRaw" | "TSVRaw" | "TabSeparatedWithNames" | "TSVWithNames" | "TabSeparatedWithNamesAndTypes" | "TSVWithNamesAndTypes" | "Template" | "TemplateIgnoreSpaces" | "CSV" | "CSVWithNames" | "CustomSeparated" | "Values" | "Vertical" | "JSON" | "JSONCompact" | "JSONEachRow" | "TSKV" | "Pretty" | "PrettyCompact" | "PrettyCompactMonoBlock" | "PrettyNoEscapes" | "PrettySpace" | "Protobuf" | "Parquet" | "RowBinary" | "RowBinaryWithNamesAndTypes" | "Native" | "Null" | "XML" | "CapnProto"; | ||
|
|
||
| type StringResultFormat = Exclude<Format, "JSON" | "JSONCompact">; | ||
|
|
||
| // This is returned when format=JSON, format=JSONCompact or dataObject=true specified | ||
| export type ObjectQueryResult<RecordType> = { | ||
| meta: Array<{ | ||
| name: string; | ||
| type: string; | ||
| }>; | ||
| totals?: any; | ||
| extremes?: any; | ||
| data: Array<RecordType>; | ||
| rows: number; | ||
| rows_before_limit_at_least?: number; | ||
| statistics: { | ||
| elapsed: number; | ||
| rows_read: number; | ||
| bytes_read: number; | ||
| }; | ||
| transferred: number; | ||
| } | ||
|
|
||
| // DefaultRecordType<ConstructorOptions, QueryOptions, unknown> is used to check any user-defined type | ||
| // DefaultRecordType<ConstructorOptions, QueryOptions, any> is used as a default if user does not supply specific type | ||
| // DefaultRecordType<ConstructorOptions, QueryOptions, any> cannot be used to check user-defined type as it allows pretty much anything, including Array | ||
| type DefaultRecordType<ConstructorOptions, QueryOptions, Value> = | ||
| QueryOptions extends {format: "JSON"} ? Record<string, Value> : | ||
| QueryOptions extends {format: "JSONCompact"} ? Array<Value> : | ||
| QueryOptions extends {format: StringResultFormat} ? null : | ||
| ConstructorOptions extends {format: "JSON"} ? Record<string, Value> : | ||
| ConstructorOptions extends {format: "JSONCompact"} ? Array<Value> : | ||
| ConstructorOptions extends {format: StringResultFormat} ? null : | ||
| QueryOptions extends {dataObjects: true} ? Record<string, Value> : | ||
| ConstructorOptions extends {dataObjects: true} ? Record<string, Value> : | ||
| Array<Value>; | ||
|
|
||
| // string is returned for any non-JSON format | ||
| export type QueryResult<RecordType> = | ||
| RecordType extends null ? string : ObjectQueryResult<RecordType>; | ||
| } | ||
|
|
||
| export = ClickHouse; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.