kbfetch 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/typings/help.d.ts +21 -8
- package/dist/typings/index.d.ts +30 -28
- package/package.json +1 -1
package/dist/typings/help.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
type Before = (init: KbFetchInit) => KbFetchInit;
|
|
2
|
-
type Parser = (res: Response) => any;
|
|
3
|
-
type After = <T = any>(res: Promise<Response & {
|
|
4
|
-
data: T;
|
|
5
|
-
}>) => Promise<T>;
|
|
6
1
|
type _KbFetchInit = {
|
|
7
|
-
before?:
|
|
8
|
-
parser?:
|
|
9
|
-
after?:
|
|
2
|
+
before?: DefaultKbFetch['before'];
|
|
3
|
+
parser?: DefaultKbFetch['parser'];
|
|
4
|
+
after?: DefaultKbFetch['after'];
|
|
10
5
|
baseUrl?: string;
|
|
11
6
|
canAbort?: boolean;
|
|
12
7
|
flags?: Record<string, any>;
|
|
@@ -15,6 +10,24 @@ export type KbFetchInit = Omit<RequestInit, 'timeout' | 'headers'> & {
|
|
|
15
10
|
timeout?: number;
|
|
16
11
|
headers?: Record<string, string>;
|
|
17
12
|
} & _KbFetchInit;
|
|
13
|
+
type Res<T> = Promise<T> & {
|
|
14
|
+
abort: () => void;
|
|
15
|
+
};
|
|
16
|
+
export interface DefaultKbFetch {
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
before: (init: KbFetchInit) => KbFetchInit;
|
|
19
|
+
after: (res: Promise<Response & {
|
|
20
|
+
data: any;
|
|
21
|
+
}>) => any;
|
|
22
|
+
parser: (res: Response) => any;
|
|
23
|
+
timeout: number;
|
|
24
|
+
do: <T>(url: string, init?: KbFetchInit) => Res<T>;
|
|
25
|
+
get: <T = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Res<T>;
|
|
26
|
+
g: <T = any>(url: string, init?: KbFetchInit & {
|
|
27
|
+
params?: Record<string, any>;
|
|
28
|
+
}) => Res<T>;
|
|
29
|
+
post: <T = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Res<T>;
|
|
30
|
+
}
|
|
18
31
|
declare const help: {
|
|
19
32
|
synthesizeUrlWithParams: (url: string, params?: Record<string, any>) => string;
|
|
20
33
|
createTimeoutAbortController: (timeout: number) => AbortController;
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import { KbFetchInit } from './help';
|
|
2
|
-
type Res<T> = Promise<T> & {
|
|
3
|
-
abort: () => void;
|
|
4
|
-
};
|
|
5
|
-
interface DefaultKbFetch {
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
before: (init: KbFetchInit) => KbFetchInit;
|
|
8
|
-
after: <T = any>(res: Promise<Response & {
|
|
9
|
-
data: T;
|
|
10
|
-
}>) => Promise<T>;
|
|
11
|
-
parser: (res: Response) => Promise<any>;
|
|
12
|
-
timeout: number;
|
|
13
|
-
do: <T>(url: string, init?: KbFetchInit) => Res<T>;
|
|
14
|
-
get: <T = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Res<T>;
|
|
15
|
-
g: <T = any>(url: string, init?: KbFetchInit & {
|
|
16
|
-
params?: Record<string, any>;
|
|
17
|
-
}) => Res<T>;
|
|
18
|
-
post: <T = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Res<T>;
|
|
19
|
-
}
|
|
1
|
+
import { DefaultKbFetch, KbFetchInit } from './help';
|
|
20
2
|
declare const defaultKbFetch: DefaultKbFetch;
|
|
21
3
|
export declare const createKbFetch: (config: Partial<typeof defaultKbFetch>) => {
|
|
22
4
|
baseUrl: string;
|
|
23
5
|
before: (init: KbFetchInit) => KbFetchInit;
|
|
24
|
-
after:
|
|
25
|
-
data:
|
|
26
|
-
}>) =>
|
|
27
|
-
parser: (res: Response) =>
|
|
6
|
+
after: (res: Promise<Response & {
|
|
7
|
+
data: any;
|
|
8
|
+
}>) => any;
|
|
9
|
+
parser: (res: Response) => any;
|
|
28
10
|
timeout: number;
|
|
29
|
-
do: <
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
do: <T>(url: string, init?: KbFetchInit) => Promise<T> & {
|
|
12
|
+
abort: () => void;
|
|
13
|
+
};
|
|
14
|
+
get: <T_1 = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Promise<T_1> & {
|
|
15
|
+
abort: () => void;
|
|
16
|
+
};
|
|
17
|
+
g: <T_2 = any>(url: string, init?: Omit<RequestInit, "timeout" | "headers"> & {
|
|
18
|
+
timeout?: number;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
} & {
|
|
21
|
+
before?: (init: KbFetchInit) => KbFetchInit;
|
|
22
|
+
parser?: (res: Response) => any;
|
|
23
|
+
after?: (res: Promise<Response & {
|
|
24
|
+
data: any;
|
|
25
|
+
}>) => any;
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
canAbort?: boolean;
|
|
28
|
+
flags?: Record<string, any>;
|
|
29
|
+
} & {
|
|
32
30
|
params?: Record<string, any>;
|
|
33
|
-
}) =>
|
|
34
|
-
|
|
31
|
+
}) => Promise<T_2> & {
|
|
32
|
+
abort: () => void;
|
|
33
|
+
};
|
|
34
|
+
post: <T_3 = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Promise<T_3> & {
|
|
35
|
+
abort: () => void;
|
|
36
|
+
};
|
|
35
37
|
};
|
|
36
38
|
declare const kbFetch: DefaultKbFetch;
|
|
37
39
|
export default kbFetch;
|