kbfetch 0.0.11 → 0.0.13
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 +0 -17
- package/dist/typings/index.d.ts +28 -17
- package/package.json +1 -1
package/dist/typings/help.d.ts
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
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
|
-
type _KbFetchInit = {
|
|
7
|
-
before?: Before;
|
|
8
|
-
parser?: Parser;
|
|
9
|
-
after?: After;
|
|
10
|
-
baseUrl?: string;
|
|
11
|
-
canAbort?: boolean;
|
|
12
|
-
flags?: Record<string, any>;
|
|
13
|
-
};
|
|
14
|
-
export type KbFetchInit = Omit<RequestInit, 'timeout' | 'headers'> & {
|
|
15
|
-
timeout?: number;
|
|
16
|
-
headers?: Record<string, string>;
|
|
17
|
-
} & _KbFetchInit;
|
|
18
1
|
declare const help: {
|
|
19
2
|
synthesizeUrlWithParams: (url: string, params?: Record<string, any>) => string;
|
|
20
3
|
createTimeoutAbortController: (timeout: number) => AbortController;
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -1,37 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
type _KbFetchInit = {
|
|
2
|
+
before?: DefaultKbFetch['before'];
|
|
3
|
+
parser?: DefaultKbFetch['parser'];
|
|
4
|
+
after?: DefaultKbFetch['after'];
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
canAbort?: boolean;
|
|
7
|
+
flags?: Record<string, any>;
|
|
8
|
+
};
|
|
9
|
+
type KbFetchInit = Omit<RequestInit, 'timeout' | 'headers'> & {
|
|
10
|
+
timeout?: number;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
} & _KbFetchInit;
|
|
2
13
|
type Res<T> = Promise<T> & {
|
|
3
14
|
abort: () => void;
|
|
4
15
|
};
|
|
5
16
|
interface DefaultKbFetch {
|
|
6
17
|
baseUrl: string;
|
|
7
18
|
before: (init: KbFetchInit) => KbFetchInit;
|
|
8
|
-
after:
|
|
9
|
-
data:
|
|
10
|
-
}>) =>
|
|
11
|
-
parser: (res: Response) =>
|
|
19
|
+
after: (res: Promise<Response & {
|
|
20
|
+
data: any;
|
|
21
|
+
}>) => any;
|
|
22
|
+
parser: (res: Response) => any;
|
|
12
23
|
timeout: number;
|
|
13
24
|
do: <T>(url: string, init?: KbFetchInit) => Res<T>;
|
|
14
|
-
get: <T =
|
|
15
|
-
g: <T =
|
|
25
|
+
get: <T = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Res<T>;
|
|
26
|
+
g: <T = any>(url: string, init?: KbFetchInit & {
|
|
16
27
|
params?: Record<string, any>;
|
|
17
28
|
}) => Res<T>;
|
|
18
|
-
post: <T =
|
|
29
|
+
post: <T = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Res<T>;
|
|
19
30
|
}
|
|
20
31
|
declare const defaultKbFetch: DefaultKbFetch;
|
|
21
32
|
export declare const createKbFetch: (config: Partial<typeof defaultKbFetch>) => {
|
|
22
33
|
baseUrl: string;
|
|
23
34
|
before: (init: KbFetchInit) => KbFetchInit;
|
|
24
|
-
after:
|
|
25
|
-
data:
|
|
26
|
-
}>) =>
|
|
27
|
-
parser: (res: Response) =>
|
|
35
|
+
after: (res: Promise<Response & {
|
|
36
|
+
data: any;
|
|
37
|
+
}>) => any;
|
|
38
|
+
parser: (res: Response) => any;
|
|
28
39
|
timeout: number;
|
|
29
|
-
do: <
|
|
30
|
-
get: <
|
|
31
|
-
g: <
|
|
40
|
+
do: <T>(url: string, init?: KbFetchInit) => Res<T>;
|
|
41
|
+
get: <T_1 = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Res<T_1>;
|
|
42
|
+
g: <T_2 = any>(url: string, init?: KbFetchInit & {
|
|
32
43
|
params?: Record<string, any>;
|
|
33
|
-
}) => Res<
|
|
34
|
-
post: <
|
|
44
|
+
}) => Res<T_2>;
|
|
45
|
+
post: <T_3 = any>(url: string, params?: Record<string, any>, init?: KbFetchInit) => Res<T_3>;
|
|
35
46
|
};
|
|
36
47
|
declare const kbFetch: DefaultKbFetch;
|
|
37
48
|
export default kbFetch;
|