@vef-framework-react/core 2.1.0
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/README +15 -0
- package/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/ai/index.cjs +1 -0
- package/dist/cjs/api/client.cjs +1 -0
- package/dist/cjs/api/constants.cjs +1 -0
- package/dist/cjs/api/helpers.cjs +1 -0
- package/dist/cjs/api/index.cjs +1 -0
- package/dist/cjs/auth/helpers.cjs +1 -0
- package/dist/cjs/auth/index.cjs +1 -0
- package/dist/cjs/context/api-client.cjs +1 -0
- package/dist/cjs/context/app.cjs +1 -0
- package/dist/cjs/context/context-selector.cjs +1 -0
- package/dist/cjs/context/disabled.cjs +1 -0
- package/dist/cjs/context/index.cjs +1 -0
- package/dist/cjs/dnd/index.cjs +1 -0
- package/dist/cjs/http/client.cjs +1 -0
- package/dist/cjs/http/constants.cjs +1 -0
- package/dist/cjs/http/errors.cjs +1 -0
- package/dist/cjs/http/helpers.cjs +1 -0
- package/dist/cjs/http/index.cjs +1 -0
- package/dist/cjs/immer/index.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/motion/features.cjs +1 -0
- package/dist/cjs/motion/index.cjs +1 -0
- package/dist/cjs/motion/motion-provider.cjs +1 -0
- package/dist/cjs/query/constants.cjs +1 -0
- package/dist/cjs/query/helpers.cjs +1 -0
- package/dist/cjs/query/hooks.cjs +1 -0
- package/dist/cjs/query/index.cjs +1 -0
- package/dist/cjs/sse/client.cjs +1 -0
- package/dist/cjs/sse/helpers.cjs +1 -0
- package/dist/cjs/sse/index.cjs +1 -0
- package/dist/cjs/state/index.cjs +1 -0
- package/dist/cjs/state-machine/index.cjs +1 -0
- package/dist/cjs/store/bound.cjs +1 -0
- package/dist/cjs/store/index.cjs +1 -0
- package/dist/cjs/store/unbound.cjs +1 -0
- package/dist/cjs/store/use-deep.cjs +1 -0
- package/dist/es/ai/index.js +3 -0
- package/dist/es/api/client.js +74 -0
- package/dist/es/api/constants.js +14 -0
- package/dist/es/api/helpers.js +8 -0
- package/dist/es/api/index.js +4 -0
- package/dist/es/auth/helpers.js +10 -0
- package/dist/es/auth/index.js +2 -0
- package/dist/es/context/api-client.js +23 -0
- package/dist/es/context/app.js +9 -0
- package/dist/es/context/context-selector.js +40 -0
- package/dist/es/context/disabled.js +10 -0
- package/dist/es/context/index.js +5 -0
- package/dist/es/dnd/index.js +8 -0
- package/dist/es/http/client.js +187 -0
- package/dist/es/http/constants.js +5 -0
- package/dist/es/http/errors.js +11 -0
- package/dist/es/http/helpers.js +9 -0
- package/dist/es/http/index.js +5 -0
- package/dist/es/immer/index.js +6 -0
- package/dist/es/index.js +27 -0
- package/dist/es/motion/features.js +3 -0
- package/dist/es/motion/index.js +5 -0
- package/dist/es/motion/motion-provider.js +24 -0
- package/dist/es/query/constants.js +5 -0
- package/dist/es/query/helpers.js +41 -0
- package/dist/es/query/hooks.js +26 -0
- package/dist/es/query/index.js +4 -0
- package/dist/es/sse/client.js +121 -0
- package/dist/es/sse/helpers.js +8 -0
- package/dist/es/sse/index.js +3 -0
- package/dist/es/state/index.js +3 -0
- package/dist/es/state-machine/index.js +14 -0
- package/dist/es/store/bound.js +20 -0
- package/dist/es/store/index.js +6 -0
- package/dist/es/store/unbound.js +44 -0
- package/dist/es/store/use-deep.js +13 -0
- package/dist/types/src/ai/index.d.ts +6 -0
- package/dist/types/src/api/client.d.ts +55 -0
- package/dist/types/src/api/constants.d.ts +12 -0
- package/dist/types/src/api/helpers.d.ts +9 -0
- package/dist/types/src/api/index.d.ts +4 -0
- package/dist/types/src/api/types.d.ts +48 -0
- package/dist/types/src/auth/helpers.d.ts +11 -0
- package/dist/types/src/auth/index.d.ts +2 -0
- package/dist/types/src/auth/types.d.ts +1 -0
- package/dist/types/src/common/index.d.ts +1 -0
- package/dist/types/src/common/types.d.ts +98 -0
- package/dist/types/src/context/api-client.d.ts +17 -0
- package/dist/types/src/context/app.d.ts +12 -0
- package/dist/types/src/context/context-selector.d.ts +32 -0
- package/dist/types/src/context/disabled.d.ts +9 -0
- package/dist/types/src/context/index.d.ts +6 -0
- package/dist/types/src/context/types.d.ts +26 -0
- package/dist/types/src/dnd/index.d.ts +8 -0
- package/dist/types/src/http/client.d.ts +112 -0
- package/dist/types/src/http/constants.d.ts +24 -0
- package/dist/types/src/http/errors.d.ts +14 -0
- package/dist/types/src/http/helpers.d.ts +17 -0
- package/dist/types/src/http/index.d.ts +5 -0
- package/dist/types/src/http/types.d.ts +101 -0
- package/dist/types/src/immer/index.d.ts +2 -0
- package/dist/types/src/index.d.ts +16 -0
- package/dist/types/src/motion/features.d.ts +1 -0
- package/dist/types/src/motion/index.d.ts +4 -0
- package/dist/types/src/motion/motion-provider.d.ts +10 -0
- package/dist/types/src/query/constants.d.ts +1 -0
- package/dist/types/src/query/helpers.d.ts +7 -0
- package/dist/types/src/query/hooks.d.ts +27 -0
- package/dist/types/src/query/index.d.ts +4 -0
- package/dist/types/src/query/types.d.ts +51 -0
- package/dist/types/src/sse/client.d.ts +16 -0
- package/dist/types/src/sse/helpers.d.ts +9 -0
- package/dist/types/src/sse/index.d.ts +3 -0
- package/dist/types/src/sse/types.d.ts +98 -0
- package/dist/types/src/state/index.d.ts +1 -0
- package/dist/types/src/state-machine/index.d.ts +15 -0
- package/dist/types/src/store/bound.d.ts +28 -0
- package/dist/types/src/store/index.d.ts +5 -0
- package/dist/types/src/store/types.d.ts +50 -0
- package/dist/types/src/store/unbound.d.ts +26 -0
- package/dist/types/src/store/use-deep.d.ts +8 -0
- package/package.json +79 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { AnyObject, EmptyObject, Except, Key } from '@vef-framework-react/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Pagination parameters for list queries.
|
|
4
|
+
* Used to specify which page and how many items per page to retrieve.
|
|
5
|
+
*/
|
|
6
|
+
export interface PaginationParams {
|
|
7
|
+
/**
|
|
8
|
+
* The page number, starting from 1
|
|
9
|
+
*
|
|
10
|
+
* @default 1
|
|
11
|
+
*/
|
|
12
|
+
page?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The number of items per page
|
|
15
|
+
*
|
|
16
|
+
* @default 15
|
|
17
|
+
*/
|
|
18
|
+
size?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Pagination result wrapper for paginated list responses.
|
|
22
|
+
* Contains the items for the current page and the total count across all pages.
|
|
23
|
+
*
|
|
24
|
+
* @template T - The type of items in the paginated list
|
|
25
|
+
*/
|
|
26
|
+
export interface PaginationResult<T = unknown> {
|
|
27
|
+
/**
|
|
28
|
+
* Total number of items across all pages
|
|
29
|
+
*/
|
|
30
|
+
readonly total: number;
|
|
31
|
+
/**
|
|
32
|
+
* Items in the current page
|
|
33
|
+
*/
|
|
34
|
+
readonly items: T[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Base data option type for select, tree-select, cascader and other data-driven components.
|
|
38
|
+
*
|
|
39
|
+
* @template T - Additional custom fields that can be merged into the option
|
|
40
|
+
* @template M - Type of the metadata field
|
|
41
|
+
*/
|
|
42
|
+
export type DataOption<T = EmptyObject, M extends AnyObject = AnyObject> = T & {
|
|
43
|
+
/**
|
|
44
|
+
* Display text of the option
|
|
45
|
+
*/
|
|
46
|
+
label: string;
|
|
47
|
+
/**
|
|
48
|
+
* Unique identifier of the option
|
|
49
|
+
*/
|
|
50
|
+
value: Key;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the option is disabled
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Additional description or help text for the option
|
|
59
|
+
*/
|
|
60
|
+
description?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Additional metadata for the option
|
|
63
|
+
*/
|
|
64
|
+
meta?: M;
|
|
65
|
+
/**
|
|
66
|
+
* Child options for tree-like structures (e.g., TreeSelect, Cascader)
|
|
67
|
+
*/
|
|
68
|
+
children?: Array<DataOption<T, M>>;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Data option with pinyin fields for Chinese character search and sorting.
|
|
72
|
+
* Extends {@link DataOption} with pinyin support to enable fuzzy search by pronunciation.
|
|
73
|
+
*
|
|
74
|
+
* @template T - Additional custom fields that can be merged into the option
|
|
75
|
+
* @template M - Type of the metadata field
|
|
76
|
+
*/
|
|
77
|
+
export type DataOptionWithPinyin<T = EmptyObject, M extends AnyObject = AnyObject> = Except<DataOption<T, M>, "children"> & {
|
|
78
|
+
/**
|
|
79
|
+
* Pinyin representation of the label
|
|
80
|
+
*/
|
|
81
|
+
labelPinyin: string;
|
|
82
|
+
/**
|
|
83
|
+
* Initials of the pinyin representation of the label
|
|
84
|
+
*/
|
|
85
|
+
labelPinyinInitials: string;
|
|
86
|
+
/**
|
|
87
|
+
* Pinyin representation of the description
|
|
88
|
+
*/
|
|
89
|
+
descriptionPinyin?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Initials of the pinyin representation of the description
|
|
92
|
+
*/
|
|
93
|
+
descriptionPinyinInitials?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Child options with pinyin support
|
|
96
|
+
*/
|
|
97
|
+
children?: Array<DataOptionWithPinyin<T, M>>;
|
|
98
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { ApiClient } from '../api';
|
|
3
|
+
interface ApiClientProviderProps extends PropsWithChildren {
|
|
4
|
+
value: ApiClient;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Provider for the API client context.
|
|
8
|
+
* Wraps children with both ApiClient context and React Query's QueryClientProvider.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ApiClientProvider({ value, children }: ApiClientProviderProps): React.JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* Hook to access the API client from context.
|
|
13
|
+
*
|
|
14
|
+
* @throws Error if used outside of ApiClientProvider.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useApiClient(): ApiClient;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AppContext } from './types';
|
|
2
|
+
import { Context, Provider } from 'react';
|
|
3
|
+
declare const AppContext: Context<AppContext>;
|
|
4
|
+
/**
|
|
5
|
+
* Provider for the VEF app context.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AppContextProvider: Provider<AppContext>;
|
|
8
|
+
/**
|
|
9
|
+
* Hook to access the VEF app context.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useAppContext(): AppContext;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the selector context provider component.
|
|
4
|
+
*/
|
|
5
|
+
export interface SelectorContextProviderProps<TValue> extends PropsWithChildren {
|
|
6
|
+
value: TValue;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Context hook interface with optional selector support.
|
|
10
|
+
*/
|
|
11
|
+
export interface UseSelectorContext<in out TValue> {
|
|
12
|
+
/**
|
|
13
|
+
* Returns the full context value.
|
|
14
|
+
*/
|
|
15
|
+
<TStrictValue extends TValue = TValue>(): TStrictValue;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the selected portion of the context value.
|
|
18
|
+
*/
|
|
19
|
+
<TStrictValue extends TValue = TValue, TSelected = TStrictValue>(selector: (value: TStrictValue) => TSelected): NoInfer<TSelected>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Result of creating a selector context.
|
|
23
|
+
*/
|
|
24
|
+
export interface SelectorContextResult<TValue> {
|
|
25
|
+
Provider: ComponentType<SelectorContextProviderProps<TValue>>;
|
|
26
|
+
useContext: UseSelectorContext<TValue>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a context with selector support for optimal re-rendering.
|
|
30
|
+
* Consuming components can select specific parts of the context value.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createContextWithSelector<TValue>(defaultValue: TValue): SelectorContextResult<TValue>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ApiClientProvider, useApiClient } from './api-client';
|
|
2
|
+
export { AppContextProvider, useAppContext } from './app';
|
|
3
|
+
export type { SelectorContextProviderProps, SelectorContextResult, UseSelectorContext } from './context-selector';
|
|
4
|
+
export { createContextWithSelector } from './context-selector';
|
|
5
|
+
export { DisabledProvider, useDisabled } from './disabled';
|
|
6
|
+
export type { AppContext } from './types';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { QueryFunction } from '../api';
|
|
2
|
+
import { DataOption } from '../common';
|
|
3
|
+
/**
|
|
4
|
+
* The context of the vef app.
|
|
5
|
+
*/
|
|
6
|
+
export interface AppContext {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the user is authorized to access the resource identified by the token.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const isAuthorized = hasPermission("user:query");
|
|
13
|
+
* ```
|
|
14
|
+
* @param token - The permission token.
|
|
15
|
+
* @returns Whether the user has the permission to access the resource identified by the token.
|
|
16
|
+
*/
|
|
17
|
+
hasPermission?: (token: string) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The query function for the data dictionary.
|
|
20
|
+
*/
|
|
21
|
+
dataDictQueryFn?: QueryFunction<DataOption[], string>;
|
|
22
|
+
/**
|
|
23
|
+
* The base URL for file access.
|
|
24
|
+
*/
|
|
25
|
+
fileBaseUrl?: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AxisModifier, restrictShapeToBoundingRectangle, RestrictToHorizontalAxis, RestrictToVerticalAxis, SnapModifier } from '@dnd-kit/abstract/modifiers';
|
|
2
|
+
export { RestrictToElement, RestrictToWindow } from '@dnd-kit/dom/modifiers';
|
|
3
|
+
export { arrayMove as moveArrayItem, move as moveDragItem, arraySwap as swapArrayItem, swap as swapDragItem } from '@dnd-kit/helpers';
|
|
4
|
+
export type { DragDropEventHandlers, DragDropEvents } from '@dnd-kit/react';
|
|
5
|
+
export { DragDropProvider, DragOverlay, KeyboardSensor, PointerSensor, useDragDropMonitor, useDraggable, useDroppable } from '@dnd-kit/react';
|
|
6
|
+
export { useSortable } from '@dnd-kit/react/sortable';
|
|
7
|
+
export type { DragDropContextProps, DraggableChildrenFn, DraggableId, DraggableLocation, DraggableProps, DraggableProvided, DraggableProvidedDraggableProps, DraggableProvidedDragHandleProps, DraggableRubric, DraggableStateSnapshot, DroppableId, DroppableProps, DroppableProvided, DroppableProvidedProps, DroppableStateSnapshot, DropResult, OnBeforeCaptureResponder, OnBeforeDragStartResponder, OnDragEndResponder, OnDragStartResponder, OnDragUpdateResponder } from '@hello-pangea/dnd';
|
|
8
|
+
export { DragDropContext, Draggable, Droppable } from '@hello-pangea/dnd';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { AxiosProgressEvent } from 'axios';
|
|
2
|
+
import { ApiResult, HttpClientOptions, RequestOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The HTTP client.
|
|
5
|
+
*/
|
|
6
|
+
export declare class HttpClient {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(options: HttpClientOptions);
|
|
9
|
+
private initInterceptors;
|
|
10
|
+
/**
|
|
11
|
+
* Check if the code matches the target code(s).
|
|
12
|
+
*/
|
|
13
|
+
private matchesCode;
|
|
14
|
+
/**
|
|
15
|
+
* Handle the request interceptor.
|
|
16
|
+
*/
|
|
17
|
+
private handleRequest;
|
|
18
|
+
/**
|
|
19
|
+
* Handle the request error interceptor.
|
|
20
|
+
*/
|
|
21
|
+
private handleRequestError;
|
|
22
|
+
/**
|
|
23
|
+
* Handle the response interceptor.
|
|
24
|
+
*/
|
|
25
|
+
private handleResponse;
|
|
26
|
+
/**
|
|
27
|
+
* Handle the response error interceptor.
|
|
28
|
+
*/
|
|
29
|
+
private handleResponseError;
|
|
30
|
+
/**
|
|
31
|
+
* Handle 401 unauthorized response.
|
|
32
|
+
*/
|
|
33
|
+
private handleUnauthorized;
|
|
34
|
+
/**
|
|
35
|
+
* Log info message using configured handler or console.
|
|
36
|
+
*/
|
|
37
|
+
private logInfo;
|
|
38
|
+
/**
|
|
39
|
+
* Log warning message using configured handler or console.
|
|
40
|
+
*/
|
|
41
|
+
private logWarning;
|
|
42
|
+
/**
|
|
43
|
+
* Log error message using configured handler or console.
|
|
44
|
+
*/
|
|
45
|
+
private logError;
|
|
46
|
+
/**
|
|
47
|
+
* Inject access token into request Authorization header.
|
|
48
|
+
*/
|
|
49
|
+
private injectAccessToken;
|
|
50
|
+
/**
|
|
51
|
+
* Replace path parameters in the URL (e.g., /users/:id -> /users/123).
|
|
52
|
+
*/
|
|
53
|
+
private replacePathParams;
|
|
54
|
+
/**
|
|
55
|
+
* Ensure the token is refreshed. Can be called proactively by external code
|
|
56
|
+
* (e.g., fetch-based SSE) to refresh token before/after request.
|
|
57
|
+
*
|
|
58
|
+
* @param triggerCallback - Whether to trigger onUnauthenticated callback on failure.
|
|
59
|
+
* @returns True if token refresh succeeded, false otherwise.
|
|
60
|
+
*/
|
|
61
|
+
ensureTokenRefreshed(triggerCallback?: boolean): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Try to refresh the token using the provided refresh callback.
|
|
64
|
+
*/
|
|
65
|
+
private tryRefreshToken;
|
|
66
|
+
/**
|
|
67
|
+
* Retry the request with refreshed token.
|
|
68
|
+
*/
|
|
69
|
+
private retryRequest;
|
|
70
|
+
/**
|
|
71
|
+
* GET request.
|
|
72
|
+
*/
|
|
73
|
+
get<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
|
|
74
|
+
params?: P;
|
|
75
|
+
}): Promise<ApiResult<R>>;
|
|
76
|
+
/**
|
|
77
|
+
* POST request.
|
|
78
|
+
*/
|
|
79
|
+
post<R = unknown, D = unknown, P = unknown>(url: string, options?: RequestOptions & {
|
|
80
|
+
data?: D;
|
|
81
|
+
params?: P;
|
|
82
|
+
}): Promise<ApiResult<R>>;
|
|
83
|
+
/**
|
|
84
|
+
* PUT request.
|
|
85
|
+
*/
|
|
86
|
+
put<R = unknown, D = unknown, P = unknown>(url: string, options?: RequestOptions & {
|
|
87
|
+
data?: D;
|
|
88
|
+
params?: P;
|
|
89
|
+
}): Promise<ApiResult<R>>;
|
|
90
|
+
/**
|
|
91
|
+
* DELETE request.
|
|
92
|
+
*/
|
|
93
|
+
delete<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
|
|
94
|
+
params?: P;
|
|
95
|
+
}): Promise<ApiResult<R>>;
|
|
96
|
+
/**
|
|
97
|
+
* Upload file via multipart/form-data.
|
|
98
|
+
*/
|
|
99
|
+
upload<R = unknown, P = unknown>(url: string, options?: RequestOptions & {
|
|
100
|
+
params?: P;
|
|
101
|
+
data: FormData;
|
|
102
|
+
onProgress?: (event: AxiosProgressEvent) => void;
|
|
103
|
+
}): Promise<ApiResult<R>>;
|
|
104
|
+
/**
|
|
105
|
+
* Download file as blob and trigger browser download.
|
|
106
|
+
*/
|
|
107
|
+
download<P = unknown>(url: string, options?: RequestOptions & {
|
|
108
|
+
params?: P;
|
|
109
|
+
onProgress?: (progress: AxiosProgressEvent) => void;
|
|
110
|
+
filename?: string | ((filename: string) => string);
|
|
111
|
+
}): Promise<void>;
|
|
112
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The key for the HTTP client in dependency injection.
|
|
3
|
+
*/
|
|
4
|
+
export declare const HTTP_CLIENT_KEY = "__vef_http_client_key";
|
|
5
|
+
/**
|
|
6
|
+
* The regex for path parameters in URLs (e.g., /users/:id).
|
|
7
|
+
*/
|
|
8
|
+
export declare const PATH_PARAM_REGEX: RegExp;
|
|
9
|
+
/**
|
|
10
|
+
* The regex for extracting filename from Content-Disposition header.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CONTENT_DISPOSITION_FILENAME_REGEX: RegExp;
|
|
13
|
+
/**
|
|
14
|
+
* The header name for skipping authentication.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SKIP_AUTH_HEADER = "X-Skip-Authentication";
|
|
17
|
+
/**
|
|
18
|
+
* The header value for skipping authentication.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SKIP_AUTH_VALUE = "1";
|
|
21
|
+
/**
|
|
22
|
+
* Default request timeout in milliseconds (30 seconds).
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_TIMEOUT = 30000;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business error returned by the API when the response code indicates a business logic failure.
|
|
3
|
+
*/
|
|
4
|
+
export declare class BusinessError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* The business error code from the API response.
|
|
7
|
+
*/
|
|
8
|
+
readonly code: number;
|
|
9
|
+
/**
|
|
10
|
+
* The original API response data.
|
|
11
|
+
*/
|
|
12
|
+
readonly data?: unknown;
|
|
13
|
+
constructor(code: number, message: string, data?: unknown);
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpClientOptions } from './types';
|
|
2
|
+
import { HttpClient } from './client';
|
|
3
|
+
import { BusinessError } from './errors';
|
|
4
|
+
/**
|
|
5
|
+
* Create the http client.
|
|
6
|
+
*
|
|
7
|
+
* @param options - The options for the http client.
|
|
8
|
+
* @returns The http client.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createHttpClient(options: HttpClientOptions): Readonly<HttpClient>;
|
|
11
|
+
/**
|
|
12
|
+
* Type guard to check if an error is a BusinessError.
|
|
13
|
+
*
|
|
14
|
+
* @param error - The error to check.
|
|
15
|
+
* @returns True if the error is a BusinessError.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isBusinessError(error: unknown): error is BusinessError;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { HttpClient } from './client';
|
|
2
|
+
export { CONTENT_DISPOSITION_FILENAME_REGEX, DEFAULT_TIMEOUT, HTTP_CLIENT_KEY, PATH_PARAM_REGEX, SKIP_AUTH_HEADER, SKIP_AUTH_VALUE, SKIP_AUTH_HEADER as skipAuthenticationHeader, SKIP_AUTH_VALUE as skipAuthenticationValue } from './constants';
|
|
3
|
+
export { BusinessError } from './errors';
|
|
4
|
+
export { createHttpClient, isBusinessError } from './helpers';
|
|
5
|
+
export type * from './types';
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Awaitable, MaybeArray, MaybeUndefined } from '@vef-framework-react/shared';
|
|
2
|
+
import { AxiosProgressEvent, GenericAbortSignal, RawAxiosRequestHeaders } from 'axios';
|
|
3
|
+
export type ProgressEvent = AxiosProgressEvent;
|
|
4
|
+
/**
|
|
5
|
+
* The result of the API.
|
|
6
|
+
*/
|
|
7
|
+
export interface ApiResult<T = unknown> {
|
|
8
|
+
/**
|
|
9
|
+
* The code of the API.
|
|
10
|
+
*/
|
|
11
|
+
readonly code: number;
|
|
12
|
+
/**
|
|
13
|
+
* The message of the API.
|
|
14
|
+
*/
|
|
15
|
+
readonly message: string;
|
|
16
|
+
/**
|
|
17
|
+
* The data of the API.
|
|
18
|
+
*/
|
|
19
|
+
readonly data: T;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The authenticated tokens.
|
|
23
|
+
*/
|
|
24
|
+
export interface AuthTokens {
|
|
25
|
+
/**
|
|
26
|
+
* The access token
|
|
27
|
+
*/
|
|
28
|
+
accessToken: string;
|
|
29
|
+
/**
|
|
30
|
+
* The refresh token
|
|
31
|
+
*/
|
|
32
|
+
refreshToken: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The options for the HTTP client.
|
|
36
|
+
*/
|
|
37
|
+
export interface HttpClientOptions {
|
|
38
|
+
/**
|
|
39
|
+
* The base URL of the API.
|
|
40
|
+
*/
|
|
41
|
+
baseUrl: string;
|
|
42
|
+
/**
|
|
43
|
+
* The timeout of the request.
|
|
44
|
+
*/
|
|
45
|
+
timeout?: number;
|
|
46
|
+
/**
|
|
47
|
+
* The function to get the authentication tokens.
|
|
48
|
+
*/
|
|
49
|
+
getAuthTokens?: () => Awaitable<MaybeUndefined<Readonly<AuthTokens>>>;
|
|
50
|
+
/**
|
|
51
|
+
* The function to set the authentication tokens.
|
|
52
|
+
*/
|
|
53
|
+
setAuthTokens?: (tokens: Readonly<AuthTokens>) => Awaitable<void>;
|
|
54
|
+
/**
|
|
55
|
+
* The function to refresh the authentication tokens.
|
|
56
|
+
* Receives the current tokens and should return new tokens.
|
|
57
|
+
* If refresh fails, the promise should reject.
|
|
58
|
+
*/
|
|
59
|
+
refreshToken?: (tokens: Readonly<AuthTokens>) => Awaitable<Readonly<AuthTokens>>;
|
|
60
|
+
/**
|
|
61
|
+
* The codes that are considered as successful.
|
|
62
|
+
*/
|
|
63
|
+
okCode?: MaybeArray<number>;
|
|
64
|
+
/**
|
|
65
|
+
* The codes that are considered as authentication token expired.
|
|
66
|
+
*/
|
|
67
|
+
tokenExpiredCode?: MaybeArray<number>;
|
|
68
|
+
/**
|
|
69
|
+
* The function to handle the unauthenticated error.
|
|
70
|
+
*/
|
|
71
|
+
onUnauthenticated?: () => Awaitable<void>;
|
|
72
|
+
/**
|
|
73
|
+
* The function to handle the access denied error.
|
|
74
|
+
*/
|
|
75
|
+
onAccessDenied?: () => Awaitable<void>;
|
|
76
|
+
/**
|
|
77
|
+
* The function to show the info message.
|
|
78
|
+
*/
|
|
79
|
+
showInfoMessage?: (message: string) => void;
|
|
80
|
+
/**
|
|
81
|
+
* The function to show the warning message.
|
|
82
|
+
*/
|
|
83
|
+
showWarningMessage?: (message: string) => void;
|
|
84
|
+
/**
|
|
85
|
+
* The function to show the error message.
|
|
86
|
+
*/
|
|
87
|
+
showErrorMessage?: (message: string) => void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The options for the request.
|
|
91
|
+
*/
|
|
92
|
+
export interface RequestOptions {
|
|
93
|
+
/**
|
|
94
|
+
* The signal for the request.
|
|
95
|
+
*/
|
|
96
|
+
signal?: GenericAbortSignal;
|
|
97
|
+
/**
|
|
98
|
+
* The headers for the request.
|
|
99
|
+
*/
|
|
100
|
+
headers?: RawAxiosRequestHeaders;
|
|
101
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './ai';
|
|
2
|
+
export { ApiClient, createApiClient, HTTP_CLIENT, QUERY_CLIENT, type ApiClientOptions, type MutationFunction, type QueryFunction, type QueryKey } from './api';
|
|
3
|
+
export { checkPermission, type PermissionCheckMode } from './auth';
|
|
4
|
+
export { type DataOption, type DataOptionWithPinyin, type PaginationParams, type PaginationResult } from './common';
|
|
5
|
+
export { ApiClientProvider, AppContextProvider, createContextWithSelector, DisabledProvider, useApiClient, useAppContext, useDisabled, type AppContext, type SelectorContextProviderProps, type SelectorContextResult, type UseSelectorContext } from './context';
|
|
6
|
+
export { AxisModifier, DragDropContext, DragDropProvider, Draggable, DragOverlay, Droppable, KeyboardSensor, moveArrayItem, moveDragItem, PointerSensor, restrictShapeToBoundingRectangle, RestrictToElement, RestrictToHorizontalAxis, RestrictToVerticalAxis, RestrictToWindow, SnapModifier, swapArrayItem, swapDragItem, useDragDropMonitor, useDraggable, useDroppable, useSortable, type DragDropContextProps, type DragDropEventHandlers, type DragDropEvents, type DraggableChildrenFn, type DraggableId, type DraggableLocation, type DraggableProps, type DraggableProvided, type DraggableProvidedDraggableProps, type DraggableProvidedDragHandleProps, type DraggableRubric, type DraggableStateSnapshot, type DroppableId, type DroppableProps, type DroppableProvided, type DroppableProvidedProps, type DroppableStateSnapshot, type DropResult, type OnBeforeCaptureResponder, type OnBeforeDragStartResponder, type OnDragEndResponder, type OnDragStartResponder, type OnDragUpdateResponder } from './dnd';
|
|
7
|
+
export type { ApiResult, AuthTokens, BusinessError, HttpClient, HttpClientOptions, isBusinessError, ProgressEvent, RequestOptions } from './http';
|
|
8
|
+
export { skipAuthenticationHeader, skipAuthenticationValue } from './http';
|
|
9
|
+
export { applyPatches, currentState, originalState, produce, produceWithPatches, useImmer, useImmerReducer } from './immer';
|
|
10
|
+
export { AnimatePresence, LayoutGroup, motion, MotionProvider, Reorder, useDragControls, useInView, type MotionProps, type ResolvedValues, type TargetAndTransition, type Transition, type Variant, type VariantLabels, type Variants } from './motion';
|
|
11
|
+
export { keepPreviousData, matchMutation, matchQuery, skipQueryToken, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useMutationState, useQueries, useQuery, useQueryErrorResetBoundary, type DefinedInitialDataOptions, type DefinedUseQueryResult, type InitialDataFunction, type MutationFunctionContext, type MutationMeta, type MutationScope, type PlaceholderDataFunction, type QueryClientOptions, type QueryKeyHashFunction, type QueryMeta, type RefetchOptions, type RetryDelayFunction, type RetryDelayValue, type RetryValue, type ShouldRetryFunction, type SkipQueryToken, type StaleTime, type UndefinedInitialDataOptions, type UseInfiniteQueryOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult } from './query';
|
|
12
|
+
export { createSseClient, SseClient, type SseClientOptions, type SseEventHandlers, type SseMessageEvent, type SseRequestConfig } from './sse';
|
|
13
|
+
export { atom, AtomStoreProvider, createAtomStore, getDefaultAtomStore, useAtom, useAtomStore, useAtomValue, useSetAtom, type Atom, type AtomGetter, type AtomSetter, type ExtractAtomArgs, type ExtractAtomResult, type ExtractAtomValue, type PrimitiveAtom, type SetStateAction, type WritableAtom } from './state';
|
|
14
|
+
export { Actor, createActor, createMachine, updateContext, useActor, useActorRef, type ActorLogic, type ActorOptions, type AnyActorLogic, type AnyMachineSnapshot, type AnyStateMachine, type MachineConfig, type MachineContext, type MachineSnapshot, type RequiredActorOptionsKeys, type SnapshotFrom, type StateMachine } from './state-machine';
|
|
15
|
+
export { createComponentStore, createPersistedStore, createStore, useDeep, useShallow, type PersistenceOptions, type ReturnedComponentStoreResult, type SliceStateCreator, type StoreProviderProps, type UnboundStore, type UseBoundStore, type UseBoundStoreWithPersist, type UseStore } from './store';
|
|
16
|
+
export { clsx, type ClassArray, type ClassDictionary, type ClassValue } from 'clsx';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { domMax as default } from 'motion/react';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as MotionProvider } from './motion-provider.js';
|
|
2
|
+
export type { MotionProps, ResolvedValues, TargetAndTransition, Transition, Variant, VariantLabels, Variants } from 'motion/react';
|
|
3
|
+
export { AnimatePresence, LayoutGroup, Reorder, useDragControls, useInView } from 'motion/react';
|
|
4
|
+
export * as motion from 'motion/react-m';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface MotionProviderProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Motion provider component that wraps the application with LazyMotion and MotionConfig.
|
|
7
|
+
* Uses lazy loading for motion features to optimize bundle size.
|
|
8
|
+
*/
|
|
9
|
+
export default function MotionProvider({ children }: MotionProviderProps): ReactNode;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const QUERY_CLIENT_KEY = "__vef_query_client_key";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { QueryClientOptions } from './types';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a configured QueryClient instance with mutation cache and default options
|
|
5
|
+
*/
|
|
6
|
+
export declare function createQueryClient(options?: QueryClientOptions): QueryClient;
|
|
7
|
+
export { keepPreviousData } from '@tanstack/react-query';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DefinedInitialDataInfiniteOptions, DefinedInitialDataOptions, DefinedUseInfiniteQueryResult, DefinedUseQueryResult, InfiniteData, MutationFilters, MutationState, NoInfer, QueriesResults, QueryFilters, UndefinedInitialDataInfiniteOptions, UndefinedInitialDataOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, useMutationState as useMutationStateInternal, useQueries as useQueriesInternal } from '@tanstack/react-query';
|
|
2
|
+
import { QueryKey } from '../api';
|
|
3
|
+
export declare function useQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = never>(options: DefinedInitialDataOptions<TQueryFnData, Error, TData, QueryKey<TParams>>): DefinedUseQueryResult<NoInfer<TData>, Error>;
|
|
4
|
+
export declare function useQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = never>(options: UndefinedInitialDataOptions<TQueryFnData, Error, TData, QueryKey<TParams>> | UseQueryOptions<TQueryFnData, Error, TData, QueryKey<TParams>>): UseQueryResult<NoInfer<TData>, Error>;
|
|
5
|
+
export declare function useInfiniteQuery<TQueryFnData, TData = InfiniteData<TQueryFnData>, TParams = never, TPageParam = never>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>): DefinedUseInfiniteQueryResult<TData, Error>;
|
|
6
|
+
export declare function useInfiniteQuery<TQueryFnData, TData = InfiniteData<TQueryFnData>, TParams = never, TPageParam = never>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>): UseInfiniteQueryResult<TData, Error>;
|
|
7
|
+
/**
|
|
8
|
+
* Hook for executing multiple queries in parallel
|
|
9
|
+
*/
|
|
10
|
+
export declare function useQueries<T extends unknown[], TCombinedResult = QueriesResults<T>>(options: Parameters<typeof useQueriesInternal<T, TCombinedResult>>[0]): TCombinedResult;
|
|
11
|
+
/**
|
|
12
|
+
* Hook for executing mutations with automatic error typing
|
|
13
|
+
*/
|
|
14
|
+
export declare function useMutation<TData = unknown, TParams = void, TOnMutateResult = unknown>(options: UseMutationOptions<TData, Error, TParams, TOnMutateResult>): UseMutationResult<TData, Error, TParams, TOnMutateResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Hook for accessing mutation state across the application
|
|
17
|
+
*/
|
|
18
|
+
export declare function useMutationState<TResult = MutationState>(options?: Parameters<typeof useMutationStateInternal<TResult>>[0]): TResult[];
|
|
19
|
+
/**
|
|
20
|
+
* Hook for getting the count of currently fetching queries
|
|
21
|
+
*/
|
|
22
|
+
export declare function useIsFetching(filters?: QueryFilters): number;
|
|
23
|
+
/**
|
|
24
|
+
* Hook for getting the count of currently executing mutations
|
|
25
|
+
*/
|
|
26
|
+
export declare function useIsMutating(filters?: MutationFilters): number;
|
|
27
|
+
export { matchMutation, matchQuery, skipToken as skipQueryToken, useQueryErrorResetBoundary } from '@tanstack/react-query';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { QUERY_CLIENT_KEY } from './constants';
|
|
2
|
+
export { createQueryClient, keepPreviousData } from './helpers';
|
|
3
|
+
export { matchMutation, matchQuery, skipQueryToken, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useMutationState, useQueries, useQuery, useQueryErrorResetBoundary } from './hooks';
|
|
4
|
+
export type * from './types';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DefinedInitialDataOptions as DefinedInitialDataOptionsInternal, DefinedUseQueryResult as DefinedUseQueryResultInternal, QueryKeyHashFunction as QueryKeyHashFunctionInternal, UndefinedInitialDataOptions as UndefinedInitialDataOptionsInternal, UseInfiniteQueryOptions as UseInfiniteQueryOptionsInternal, UseMutationResult as UseMutationResultInternal, UseQueryOptions as UseQueryOptionsInternal, UseQueryResult as UseQueryResultInternal } from '@tanstack/react-query';
|
|
2
|
+
import { MaybeUndefined } from '@vef-framework-react/shared';
|
|
3
|
+
import { QueryKey } from '../api';
|
|
4
|
+
declare module "@tanstack/react-query" {
|
|
5
|
+
interface Register {
|
|
6
|
+
mutationMeta: {
|
|
7
|
+
/**
|
|
8
|
+
* Query keys to invalidate on successful mutation
|
|
9
|
+
*/
|
|
10
|
+
invalidates?: Array<QueryKey<never> | QueryKey<unknown>>;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to show success feedback (default: true)
|
|
13
|
+
*/
|
|
14
|
+
shouldShowSuccessFeedback?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for creating a QueryClient instance
|
|
20
|
+
*/
|
|
21
|
+
export interface QueryClientOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Time in ms before data is considered stale (default: 5000)
|
|
24
|
+
*/
|
|
25
|
+
staleTime?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Time in ms before inactive queries are garbage collected (default: 300000)
|
|
28
|
+
*/
|
|
29
|
+
gcTime?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Callback to display success message from mutation response
|
|
32
|
+
*/
|
|
33
|
+
showSuccessMessage?: (message: string) => void;
|
|
34
|
+
}
|
|
35
|
+
export type ShouldRetryFunction = (failureCount: number, error: Error) => boolean;
|
|
36
|
+
export type RetryValue = boolean | number | ShouldRetryFunction;
|
|
37
|
+
export type RetryDelayFunction = (failureCount: number, error: Error) => number;
|
|
38
|
+
export type RetryDelayValue = number | RetryDelayFunction;
|
|
39
|
+
export type PlaceholderDataFunction<TData = unknown> = (previousData: MaybeUndefined<TData>) => MaybeUndefined<TData>;
|
|
40
|
+
export interface RefetchOptions {
|
|
41
|
+
cancelRefetch?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export type QueryKeyHashFunction<TParams = never> = QueryKeyHashFunctionInternal<QueryKey<TParams>>;
|
|
44
|
+
export type UseQueryResult<TData = unknown> = UseQueryResultInternal<TData, Error>;
|
|
45
|
+
export type DefinedUseQueryResult<TData = unknown> = DefinedUseQueryResultInternal<TData, Error>;
|
|
46
|
+
export type UseQueryOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = UseQueryOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>>;
|
|
47
|
+
export type DefinedInitialDataOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = DefinedInitialDataOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>>;
|
|
48
|
+
export type UndefinedInitialDataOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = UndefinedInitialDataOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>>;
|
|
49
|
+
export type UseInfiniteQueryOptions<TQueryFnData, TData = TQueryFnData, TParams = never, TPageParam = never> = UseInfiniteQueryOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>;
|
|
50
|
+
export type UseMutationResult<TData = unknown, TParams = unknown, TOnMutateResult = unknown> = UseMutationResultInternal<TData, Error, TParams, TOnMutateResult>;
|
|
51
|
+
export type { InitialDataFunction, MutationFunctionContext, MutationMeta, MutationScope, QueryMeta, SkipToken as SkipQueryToken, StaleTime } from '@tanstack/react-query';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SseClientOptions, SseEventHandlers, SseRequestConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* SSE client wrapper around @microsoft/fetch-event-source.
|
|
4
|
+
*/
|
|
5
|
+
export declare class SseClient {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(options?: SseClientOptions);
|
|
8
|
+
/**
|
|
9
|
+
* Start an SSE stream request.
|
|
10
|
+
*/
|
|
11
|
+
stream(config: SseRequestConfig, handlers: SseEventHandlers): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Abort all active stream requests.
|
|
14
|
+
*/
|
|
15
|
+
abort(): void;
|
|
16
|
+
}
|