@duxweb/dvha-core 0.1.6 → 0.1.8
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/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/data.cjs +1 -1
- package/dist/cjs/hooks/form.cjs +1 -0
- package/dist/cjs/hooks/select.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/esm/hooks/auth.js +6 -6
- package/dist/esm/hooks/data.js +151 -151
- package/dist/esm/hooks/form.js +67 -0
- package/dist/esm/hooks/select.js +87 -0
- package/dist/esm/index.js +53 -49
- package/dist/esm/preset/authProvider.js +33 -33
- package/dist/esm/preset/dataProvider.js +108 -69
- package/dist/types/hooks/auth.d.ts +2 -2
- package/dist/types/hooks/data.d.ts +72 -72
- package/dist/types/hooks/form.d.ts +16 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/select.d.ts +3 -1
- package/dist/types/preset/dataProvider.d.ts +3 -1
- package/dist/types/types/auth.d.ts +6 -5
- package/dist/types/types/data.d.ts +10 -1
- package/package.json +1 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
type SelectValue = Array<string | number> | string | number | null | undefined;
|
|
2
2
|
interface UseSelectProps {
|
|
3
|
-
|
|
3
|
+
defaultValue?: SelectValue;
|
|
4
4
|
path?: string;
|
|
5
5
|
params?: Record<string, any>;
|
|
6
6
|
pagination?: boolean | number;
|
|
7
|
+
providerName?: string;
|
|
7
8
|
optionLabel?: string | ((item: Record<string, any>) => string);
|
|
8
9
|
optionValue?: string | ((item: Record<string, any>) => string);
|
|
9
10
|
optionField?: string;
|
|
10
11
|
keywordField?: string;
|
|
12
|
+
debounce?: number;
|
|
11
13
|
}
|
|
12
14
|
export declare function useSelect(props: UseSelectProps): {
|
|
13
15
|
onSearch: (searchValue: string) => void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { IDataProvider } from '../types';
|
|
1
|
+
import type { IDataProvider, IDataProviderError, IDataProviderResponse } from '../types';
|
|
2
2
|
export interface ISimpleDataProviderProps {
|
|
3
3
|
apiUrl: string;
|
|
4
|
+
successCallback?: (res: any) => IDataProviderResponse;
|
|
5
|
+
errorCallback?: (err: any) => IDataProviderError;
|
|
4
6
|
}
|
|
5
7
|
export declare function simpleDataProvider(props: ISimpleDataProviderProps): IDataProvider;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IManageHook } from '../hooks';
|
|
2
2
|
import type { IUserState } from '../stores/auth';
|
|
3
|
+
import type { IDataProviderError } from './data';
|
|
3
4
|
/**
|
|
4
5
|
* 认证提供者
|
|
5
6
|
* 为全局或管理端提供自定义认证服务
|
|
@@ -8,11 +9,11 @@ export interface IAuthProvider {
|
|
|
8
9
|
login: (params: any, manage: IManageHook) => Promise<IAuthLoginResponse>;
|
|
9
10
|
check: (params?: any, manage?: IManageHook) => Promise<IAuthCheckResponse>;
|
|
10
11
|
logout: (params?: any, manage?: IManageHook) => Promise<IAuthLogoutResponse>;
|
|
11
|
-
register
|
|
12
|
-
forgotPassword
|
|
13
|
-
updatePassword
|
|
12
|
+
register?: (params: any, manage?: IManageHook) => Promise<IAuthLoginResponse>;
|
|
13
|
+
forgotPassword?: (params: any, manage?: IManageHook) => Promise<IAuthActionResponse>;
|
|
14
|
+
updatePassword?: (params: any, manage?: IManageHook) => Promise<IAuthActionResponse>;
|
|
14
15
|
can?: (name: string, params?: any, manage?: IManageHook, auth?: IUserState) => boolean;
|
|
15
|
-
onError: (error?:
|
|
16
|
+
onError: (error?: IDataProviderError) => Promise<IAuthErrorResponse>;
|
|
16
17
|
}
|
|
17
18
|
export interface IAuthActionResponse {
|
|
18
19
|
success: boolean;
|
|
@@ -33,5 +34,5 @@ export interface IAuthLogoutResponse extends IAuthActionResponse {
|
|
|
33
34
|
export interface IAuthErrorResponse {
|
|
34
35
|
logout?: boolean;
|
|
35
36
|
redirectTo?: string;
|
|
36
|
-
error?:
|
|
37
|
+
error?: IDataProviderError;
|
|
37
38
|
}
|
|
@@ -21,6 +21,15 @@ export interface IDataProviderResponse {
|
|
|
21
21
|
message?: string;
|
|
22
22
|
data?: any;
|
|
23
23
|
meta?: Record<string, any>;
|
|
24
|
+
raw?: any;
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
27
|
+
export interface IDataProviderError {
|
|
28
|
+
status?: number;
|
|
29
|
+
message?: string;
|
|
30
|
+
data?: any;
|
|
31
|
+
meta?: Record<string, any>;
|
|
32
|
+
raw?: any;
|
|
24
33
|
[key: string]: any;
|
|
25
34
|
}
|
|
26
35
|
export interface IDataProviderListOptions {
|
|
@@ -43,7 +52,7 @@ export interface IDataProviderUpdateOptions extends IDataProviderCreateOptions {
|
|
|
43
52
|
}
|
|
44
53
|
export interface IDataProviderGetOneOptions {
|
|
45
54
|
path: string;
|
|
46
|
-
id
|
|
55
|
+
id?: string | number;
|
|
47
56
|
meta?: Record<string, any>;
|
|
48
57
|
}
|
|
49
58
|
export interface IDataProviderGetManyOptions {
|