UNPKG

1.17 kBTypeScriptView Raw
1declare module 'telegram-mtproto' {
2 type ServerConfig = {
3 dev?: boolean
4 webogram?: boolean
5 }
6 type AppConfig = {
7 debug?: boolean
8 storage?: AsyncStorage
9 }
10 type ApiConfig = {
11 invokeWithLayer?: number
12 layer ?: number
13 initConnection ?: number
14 api_id ?: string
15 device_model ?: string
16 system_version ?: string
17 app_version ?: string
18 lang_code ?: string
19 }
20 type Config = {
21 server?: ServerConfig
22 api?: ApiConfig
23 app?: AppConfig
24 schema?: Object
25 mtSchema?: Object
26 }
27 class ApiManager {
28 constructor()
29 constructor({ server, api, app, schema, mtSchema }: Config)
30 readonly storage: AsyncStorage
31 mtpInvokeApi<T>(method: string): Promise<T>
32 mtpInvokeApi<T>(method: string, params: Object): Promise<T>
33 mtpInvokeApi<T>(method: string, params: Object, options: Object): Promise<T>
34 on(event: string|string[], handler: Function)
35 }
36 interface AsyncStorage {
37 get(...keys: string[]): Promise<any[]>
38 set(obj: Object): Promise<Object>
39 remove(...keys: string[]): Promise<any>
40 clear(): Promise<{}>
41 }
42}
\No newline at end of file