hook-fetch 0.0.8 → 0.0.9
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/package.json +1 -1
- package/types/base.d.ts +18 -18
- package/types/types.d.ts +23 -1
package/package.json
CHANGED
package/types/base.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { AnyObject, Generic } from 'typescript-api-pro';
|
|
2
|
-
import { BaseOptions, HookFetchPlugin,
|
|
2
|
+
import { BaseOptions, DeleteOptions, GetOptions, HeadOptions, HookFetchPlugin, OptionsOptions, PatchOptions, PostOptions, PutOptions, RequestOptions } from './types';
|
|
3
3
|
import { HookFetchRequest } from './utils';
|
|
4
4
|
declare class Base<R extends AnyObject = AnyObject, E = AnyObject, K extends keyof R = string> {
|
|
5
5
|
#private;
|
|
6
6
|
constructor({ timeout, baseURL, headers, plugins, withCredentials }: BaseOptions);
|
|
7
7
|
use(plugin: HookFetchPlugin<any, any, any, any>): this;
|
|
8
|
-
request<T = AnyObject, P = AnyObject, D = AnyObject>(url: string, { timeout, headers, method, params, data, qsArrayFormat, withCredentials, extra }?:
|
|
9
|
-
get<T = AnyObject, P = AnyObject>(url: string, params?: P, options?:
|
|
10
|
-
head<T = AnyObject, P = AnyObject>(url: string, params?: P, options?:
|
|
11
|
-
options<T = AnyObject, P = AnyObject>(url: string, params?: P, options?:
|
|
12
|
-
delete<T = AnyObject, P = AnyObject>(url: string, options?:
|
|
13
|
-
post<T = AnyObject, D = AnyObject, P = AnyObject>(url: string, data?: D, options?:
|
|
14
|
-
put<T = AnyObject, D = AnyObject, P = AnyObject>(url: string, data?: D, options?:
|
|
15
|
-
patch<T = AnyObject, D = AnyObject, P = AnyObject>(url: string, data?: D, options?:
|
|
8
|
+
request<T = AnyObject, P = AnyObject, D = AnyObject>(url: string, { timeout, headers, method, params, data, qsArrayFormat, withCredentials, extra }?: RequestOptions<P, D, E>): HookFetchRequest<Generic<R, K, T>, E>;
|
|
9
|
+
get<T = AnyObject, P = AnyObject>(url: string, params?: P, options?: GetOptions<P, E>): HookFetchRequest<Generic<R, K, T>, E>;
|
|
10
|
+
head<T = AnyObject, P = AnyObject>(url: string, params?: P, options?: HeadOptions<P, E>): HookFetchRequest<Generic<R, K, T>, E>;
|
|
11
|
+
options<T = AnyObject, P = AnyObject>(url: string, params?: P, options?: OptionsOptions<P, E>): HookFetchRequest<Generic<R, K, T>, E>;
|
|
12
|
+
delete<T = AnyObject, P = AnyObject>(url: string, options?: DeleteOptions<P, E>): HookFetchRequest<Generic<R, K, T>, E>;
|
|
13
|
+
post<T = AnyObject, D = AnyObject, P = AnyObject>(url: string, data?: D, options?: PostOptions<D, P, E>): HookFetchRequest<Generic<R, K, T>, E>;
|
|
14
|
+
put<T = AnyObject, D = AnyObject, P = AnyObject>(url: string, data?: D, options?: PutOptions<D, P, E>): HookFetchRequest<Generic<R, K, T>, E>;
|
|
15
|
+
patch<T = AnyObject, D = AnyObject, P = AnyObject>(url: string, data?: D, options?: PatchOptions<D, P, E>): HookFetchRequest<Generic<R, K, T>, E>;
|
|
16
16
|
abortAll(): void;
|
|
17
17
|
}
|
|
18
|
-
declare const useRequest: <R = AnyObject, P = AnyObject, D = AnyObject, E = AnyObject>(url: string, options?:
|
|
19
|
-
export declare const request: <R = AnyObject, P = AnyObject, D = AnyObject, E = AnyObject>(url: string, options?:
|
|
20
|
-
export declare const get: <R = AnyObject, P = AnyObject, E = AnyObject>(url: string, params?: P, options?:
|
|
21
|
-
export declare const head: <R = AnyObject, P = AnyObject, E = AnyObject>(url: string, params?: P, options?:
|
|
22
|
-
export declare const options: <R = AnyObject, P = AnyObject, E = AnyObject>(url: string, params?: P, options?:
|
|
23
|
-
export declare const del: <R = AnyObject, P = AnyObject, E = AnyObject>(url: string, options?:
|
|
24
|
-
export declare const post: <R = AnyObject, D = AnyObject, P = AnyObject, E = AnyObject>(url: string, data?: D, options?:
|
|
25
|
-
export declare const put: <R = AnyObject, D = AnyObject, P = AnyObject, E = AnyObject>(url: string, data?: D, options?:
|
|
26
|
-
export declare const patch: <R = AnyObject, D = AnyObject, P = AnyObject, E = AnyObject>(url: string, data?: D, options?:
|
|
18
|
+
declare const useRequest: <R = AnyObject, P = AnyObject, D = AnyObject, E = AnyObject>(url: string, options?: RequestOptions<P, D, E>) => HookFetchRequest<R, E>;
|
|
19
|
+
export declare const request: <R = AnyObject, P = AnyObject, D = AnyObject, E = AnyObject>(url: string, options?: RequestOptions<P, D, E>) => HookFetchRequest<R, E>;
|
|
20
|
+
export declare const get: <R = AnyObject, P = AnyObject, E = AnyObject>(url: string, params?: P, options?: GetOptions<P, E>) => HookFetchRequest<R, E>;
|
|
21
|
+
export declare const head: <R = AnyObject, P = AnyObject, E = AnyObject>(url: string, params?: P, options?: HeadOptions<P, E>) => HookFetchRequest<R, E>;
|
|
22
|
+
export declare const options: <R = AnyObject, P = AnyObject, E = AnyObject>(url: string, params?: P, options?: OptionsOptions<P, E>) => HookFetchRequest<R, E>;
|
|
23
|
+
export declare const del: <R = AnyObject, P = AnyObject, E = AnyObject>(url: string, options?: DeleteOptions<P, E>) => HookFetchRequest<R, E>;
|
|
24
|
+
export declare const post: <R = AnyObject, D = AnyObject, P = AnyObject, E = AnyObject>(url: string, data?: D, options?: PostOptions<D, P, E>) => HookFetchRequest<R, E>;
|
|
25
|
+
export declare const put: <R = AnyObject, D = AnyObject, P = AnyObject, E = AnyObject>(url: string, data?: D, options?: PutOptions<D, P, E>) => HookFetchRequest<R, E>;
|
|
26
|
+
export declare const patch: <R = AnyObject, D = AnyObject, P = AnyObject, E = AnyObject>(url: string, data?: D, options?: PatchOptions<D, P, E>) => HookFetchRequest<R, E>;
|
|
27
27
|
type ExportDefault = typeof useRequest & {
|
|
28
28
|
create: <R extends AnyObject = AnyObject, E = AnyObject, K extends keyof R = string>(options: BaseOptions) => (Base<R, E, K>['request'] & Base<R, E, K>);
|
|
29
29
|
get: typeof get;
|
package/types/types.d.ts
CHANGED
|
@@ -64,5 +64,27 @@ export interface OptionProps {
|
|
|
64
64
|
withCredentials: boolean;
|
|
65
65
|
}
|
|
66
66
|
export type BaseOptions = Partial<OptionProps>;
|
|
67
|
-
export type
|
|
67
|
+
export type RequestOptions<P = AnyObject, D = AnyObject, E = AnyObject> = Omit<BaseRequestOptions<P, D, E>, 'url' | 'plugins' | 'baseURL' | 'controller'>;
|
|
68
|
+
/**
|
|
69
|
+
* 已废除, 请改用 RequestOptions
|
|
70
|
+
*
|
|
71
|
+
* Deprecated, please use RequestOptions instead
|
|
72
|
+
*/
|
|
73
|
+
export type RequestUseOptions<P = AnyObject, D = AnyObject, E = AnyObject> = RequestOptions<P, D, E>;
|
|
74
|
+
export type RequestWithBodyOptions<D = AnyObject, P = AnyObject, E = AnyObject> = Omit<RequestOptions<P, D, E>, 'data'>;
|
|
75
|
+
export type RequestWithParamsOptions<P = AnyObject, E = AnyObject> = Omit<RequestOptions<P, null, E>, 'params' | 'data'>;
|
|
76
|
+
export type RequestWithBodyFnOptions<D = AnyObject, P = AnyObject, E = AnyObject> = Omit<RequestOptions<P, D, E>, 'data' | 'method'>;
|
|
77
|
+
export type RequestWithParamsFnOptions<P = AnyObject, E = AnyObject> = Omit<RequestOptions<P, null, E>, 'params' | 'data' | 'method'>;
|
|
78
|
+
export type PostOptions<D = AnyObject, P = AnyObject, E = AnyObject> = RequestWithBodyFnOptions<D, P, E>;
|
|
79
|
+
export type PutOptions<D = AnyObject, P = AnyObject, E = AnyObject> = RequestWithBodyFnOptions<D, P, E>;
|
|
80
|
+
export type PatchOptions<D = AnyObject, P = AnyObject, E = AnyObject> = RequestWithBodyFnOptions<D, P, E>;
|
|
81
|
+
export type GetOptions<P = AnyObject, E = AnyObject> = RequestWithParamsFnOptions<P, E>;
|
|
82
|
+
export type HeadOptions<P = AnyObject, E = AnyObject> = RequestWithParamsFnOptions<P, E>;
|
|
83
|
+
/**
|
|
84
|
+
* OPTIONS 方法请求的可选参数类型
|
|
85
|
+
*
|
|
86
|
+
* OPTIONS method request optional parameter types
|
|
87
|
+
*/
|
|
88
|
+
export type OptionsOptions<P = AnyObject, E = AnyObject> = RequestWithParamsFnOptions<P, E>;
|
|
89
|
+
export type DeleteOptions<P = AnyObject, E = AnyObject> = RequestWithParamsFnOptions<P, E>;
|
|
68
90
|
export {};
|