|
| 1 | +/***************************************************************************** |
| 2 | + * Source: https://github.com/swellstores/swell-node/issues/11 |
| 3 | + ****************************************************************************/ |
| 4 | + |
| 5 | +declare module 'swell-node' { |
| 6 | + import EventEmitter from 'node:events'; |
| 7 | + |
| 8 | + type Callback<D, T> = (error: unknown, data?: D, response?: T) => void | Promise<void>; |
| 9 | + |
| 10 | + interface SwellNodeClientParams { |
| 11 | + clientId?: string; |
| 12 | + clientKey?: string; |
| 13 | + host?: string; |
| 14 | + port?: string; |
| 15 | + verifyCert?: boolean; |
| 16 | + version?: string; |
| 17 | + session?: unknown; |
| 18 | + route?: unknown; |
| 19 | + timeout?: number; |
| 20 | + routeClientId?: string; |
| 21 | + cache?: boolean; |
| 22 | + debug?: boolean; |
| 23 | + } |
| 24 | + |
| 25 | + interface SwellNodeClient extends EventEmitter { |
| 26 | + params: unknown; |
| 27 | + server: unknown; |
| 28 | + cache: unknown; |
| 29 | + authed: boolean; |
| 30 | + |
| 31 | + // eslint-disable-next-line @typescript-eslint/no-misused-new |
| 32 | + new ( |
| 33 | + clientId: string, |
| 34 | + clientKey: string, |
| 35 | + options?: SwellNodeClientParams, |
| 36 | + callback?: (arg: this) => void | Promise<void> |
| 37 | + ): SwellNodeClient; |
| 38 | + create( |
| 39 | + clientId: string, |
| 40 | + clientKey: string, |
| 41 | + options?: SwellNodeClientParams, |
| 42 | + callback?: (arg: this) => void | Promise<void> |
| 43 | + ): SwellNodeClient; |
| 44 | + init(clientId: string, clientKey: string, options?: SwellNodeClientParams): SwellNodeClient; |
| 45 | + connect(callback: (arg: this) => void | Promise<void>): void; |
| 46 | + request<T = unknown>(method: string, url: string, data?: unknown): Promise<T>; |
| 47 | + get<T = unknown>(url: string, data?: unknown): Promise<T>; |
| 48 | + post<T = unknown>(url: string, data?: unknown): Promise<T>; |
| 49 | + put<T = unknown>(url: string, data?: unknown): Promise<T>; |
| 50 | + delete<T = unknown>(url: string, data?: unknown): Promise<T>; |
| 51 | + } |
| 52 | + |
| 53 | + export function createClient( |
| 54 | + clientId: string, |
| 55 | + clientKey: string, |
| 56 | + options?: SwellNodeClientParams, |
| 57 | + callback?: (arg: this) => void |
| 58 | + ): SwellNodeClient; |
| 59 | +} |
0 commit comments