1 | export interface ProgressEvent {
|
2 | loaded: number;
|
3 | percent?: number;
|
4 | total?: number;
|
5 | }
|
6 | export interface UploadOptions {
|
7 | headers?: Record<string, string>;
|
8 | data?: Record<string, string>;
|
9 | onprogress?: (event: ProgressEvent) => void;
|
10 | }
|
11 | interface RequestOptions extends UploadOptions {
|
12 | method?:
|
13 | | "OPTIONS"
|
14 | | "GET"
|
15 | | "HEAD"
|
16 | | "POST"
|
17 | | "PUT"
|
18 | | "DELETE"
|
19 | | "TRACE"
|
20 | | "CONNECT";
|
21 | }
|
22 | interface Response {
|
23 | status?: number;
|
24 | ok?: boolean;
|
25 | headers?: object;
|
26 | data?: object;
|
27 | }
|
28 | export interface FormDataPart {
|
29 | field: string;
|
30 | data: any;
|
31 | name: string;
|
32 | }
|
33 |
|
34 | export declare type SyncStorage = {
|
35 | async?: false;
|
36 | getItem: (key: string) => string | null;
|
37 | setItem: (key: string, value: string) => any;
|
38 | removeItem: (key: string) => any;
|
39 | clear: () => any;
|
40 | };
|
41 | export declare type AsyncStorage = {
|
42 | async: true;
|
43 | getItem: (key: string) => Promise<string | null>;
|
44 | setItem: (key: string, value: string) => Promise<any>;
|
45 | removeItem: (key: string) => Promise<any>;
|
46 | clear: () => Promise<any>;
|
47 | };
|
48 | export declare type Storage = SyncStorage | AsyncStorage;
|
49 |
|
50 | interface WebSocket {
|
51 | addEventListener(
|
52 | event: string,
|
53 | handler: (...args: any[]) => any,
|
54 | ...args: any[]
|
55 | ): any;
|
56 | removeEventListener(
|
57 | event: string,
|
58 | handler: (...args: any[]) => any,
|
59 | ...args: any[]
|
60 | ): any;
|
61 | send(data: string | ArrayBuffer): any;
|
62 | close(): any;
|
63 | }
|
64 |
|
65 | export interface Adapters {
|
66 | request: (url: string, options?: RequestOptions) => Promise<Response>;
|
67 | upload: (
|
68 | url: string,
|
69 | file: FormDataPart,
|
70 | options?: UploadOptions
|
71 | ) => Promise<Response>;
|
72 | storage: Storage;
|
73 | WebSocket: {
|
74 | new (url: string, protocols?: string | string[]): WebSocket;
|
75 | };
|
76 | }
|