@vef-framework/core 1.0.135 → 2.0.1
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/api/client.cjs +171 -0
- package/dist/cjs/api/constants.cjs +13 -0
- package/dist/cjs/api/helpers.cjs +12 -0
- package/dist/cjs/api/index.cjs +14 -0
- package/dist/cjs/auth/helpers.cjs +19 -0
- package/dist/cjs/auth/index.cjs +10 -0
- package/dist/cjs/common/index.cjs +3 -0
- package/dist/cjs/context/api-client.cjs +25 -0
- package/dist/cjs/context/app.cjs +15 -0
- package/dist/cjs/context/context-selector.cjs +65 -0
- package/dist/cjs/context/disabled.cjs +15 -0
- package/dist/cjs/context/index.cjs +19 -0
- package/dist/cjs/dnd/index.cjs +102 -0
- package/dist/cjs/http/client.cjs +445 -0
- package/dist/cjs/http/errors.cjs +23 -0
- package/dist/cjs/http/helpers.cjs +17 -0
- package/dist/cjs/http/index.cjs +17 -0
- package/dist/cjs/immer/index.cjs +40 -0
- package/dist/cjs/index.cjs +306 -0
- package/dist/cjs/motion/features.cjs +13 -0
- package/dist/cjs/motion/index.cjs +48 -0
- package/dist/cjs/motion/motion-provider.cjs +29 -0
- package/dist/cjs/query/constants.cjs +8 -0
- package/dist/cjs/query/helpers.cjs +67 -0
- package/dist/cjs/query/hooks.cjs +52 -0
- package/dist/cjs/query/index.cjs +20 -0
- package/dist/cjs/state/index.cjs +41 -0
- package/dist/cjs/state-machine/index.cjs +35 -0
- package/dist/cjs/store/bound.cjs +42 -0
- package/dist/cjs/store/index.cjs +20 -0
- package/dist/cjs/store/unbound.cjs +74 -0
- package/dist/cjs/store/use-deep.cjs +17 -0
- package/dist/es/api/client.js +167 -0
- package/dist/es/api/constants.js +8 -0
- package/dist/es/api/helpers.js +8 -0
- package/dist/es/api/index.js +4 -0
- package/dist/es/auth/helpers.js +15 -0
- package/dist/es/auth/index.js +2 -0
- package/dist/es/common/index.js +1 -0
- package/dist/es/context/api-client.js +20 -0
- package/dist/es/context/app.js +10 -0
- package/dist/es/context/context-selector.js +61 -0
- package/dist/es/context/disabled.js +10 -0
- package/dist/es/context/index.js +5 -0
- package/dist/es/dnd/index.js +7 -0
- package/dist/es/http/client.js +439 -0
- package/dist/es/http/errors.js +19 -0
- package/dist/es/http/helpers.js +12 -0
- package/dist/es/http/index.js +4 -0
- package/dist/es/immer/index.js +8 -0
- package/dist/es/index.js +43 -0
- package/dist/es/motion/features.js +2 -0
- package/dist/es/motion/index.js +5 -0
- package/dist/es/motion/motion-provider.js +25 -0
- package/dist/es/query/constants.js +4 -0
- package/dist/es/query/helpers.js +60 -0
- package/dist/es/query/hooks.js +27 -0
- package/dist/es/query/index.js +4 -0
- package/dist/es/state/index.js +2 -0
- package/dist/es/state-machine/index.js +12 -0
- package/dist/es/store/bound.js +37 -0
- package/dist/es/store/index.js +5 -0
- package/dist/es/store/unbound.js +70 -0
- package/dist/es/store/use-deep.js +13 -0
- package/dist/types/api/client.d.ts +75 -0
- package/dist/types/api/constants.d.ts +8 -0
- package/dist/types/api/helpers.d.ts +9 -0
- package/dist/types/api/index.d.ts +4 -0
- package/dist/types/api/types.d.ts +48 -0
- package/dist/types/auth/helpers.d.ts +11 -0
- package/dist/types/auth/index.d.ts +2 -0
- package/dist/types/auth/types.d.ts +1 -0
- package/dist/types/common/index.d.ts +1 -0
- package/dist/types/common/types.d.ts +95 -0
- package/dist/types/context/api-client.d.ts +18 -0
- package/dist/types/context/app.d.ts +4 -0
- package/dist/types/context/context-selector.d.ts +44 -0
- package/dist/types/context/disabled.d.ts +9 -0
- package/dist/types/context/index.d.ts +5 -0
- package/dist/types/context/types.d.ts +27 -0
- package/dist/types/dnd/index.d.ts +6 -0
- package/dist/types/http/client.d.ts +144 -0
- package/dist/types/http/errors.d.ts +14 -0
- package/dist/types/http/helpers.d.ts +17 -0
- package/dist/types/http/index.d.ts +4 -0
- package/dist/types/http/types.d.ts +101 -0
- package/dist/types/immer/index.d.ts +2 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/motion/features.d.ts +1 -0
- package/dist/types/motion/index.d.ts +4 -0
- package/dist/types/motion/motion-provider.d.ts +5 -0
- package/dist/types/query/constants.d.ts +1 -0
- package/dist/types/query/helpers.d.ts +10 -0
- package/dist/types/query/hooks.d.ts +66 -0
- package/dist/types/query/index.d.ts +4 -0
- package/dist/types/query/types.d.ts +51 -0
- package/dist/types/state/index.d.ts +1 -0
- package/dist/types/state-machine/index.d.ts +14 -0
- package/dist/types/store/bound.d.ts +28 -0
- package/dist/types/store/index.d.ts +5 -0
- package/dist/types/store/types.d.ts +50 -0
- package/dist/types/store/unbound.d.ts +26 -0
- package/dist/types/store/use-deep.d.ts +7 -0
- package/package.json +59 -37
- package/README.md +0 -25
- package/cjs/api/api-client.cjs +0 -2
- package/cjs/api/api-context.cjs +0 -2
- package/cjs/api/index.cjs +0 -2
- package/cjs/api/query-client.cjs +0 -2
- package/cjs/api/request-client.cjs +0 -2
- package/cjs/auth/auth-context.cjs +0 -2
- package/cjs/auth/index.cjs +0 -2
- package/cjs/expr/compiler.cjs +0 -2
- package/cjs/expr/helpers.cjs +0 -2
- package/cjs/index.cjs +0 -2
- package/cjs/middleware/dispatcher.cjs +0 -2
- package/esm/api/api-client.js +0 -2
- package/esm/api/api-context.js +0 -2
- package/esm/api/index.js +0 -2
- package/esm/api/query-client.js +0 -2
- package/esm/api/request-client.js +0 -2
- package/esm/auth/auth-context.js +0 -2
- package/esm/auth/index.js +0 -2
- package/esm/expr/compiler.js +0 -2
- package/esm/expr/helpers.js +0 -2
- package/esm/index.js +0 -2
- package/esm/middleware/dispatcher.js +0 -2
- package/types/api/api-client.d.ts +0 -203
- package/types/api/api-context.d.ts +0 -167
- package/types/api/index.d.ts +0 -3
- package/types/api/query-client.d.ts +0 -27
- package/types/api/request-client.d.ts +0 -95
- package/types/auth/auth-context.d.ts +0 -29
- package/types/auth/index.d.ts +0 -1
- package/types/expr/compiler.d.ts +0 -35
- package/types/expr/helpers.d.ts +0 -58
- package/types/index.d.ts +0 -3
- package/types/middleware/dispatcher.d.ts +0 -22
|
@@ -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,101 @@
|
|
|
1
|
+
import { Awaitable, MaybeArray, MaybeUndefined } from '@vef-framework/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,14 @@
|
|
|
1
|
+
export { ApiClient, createApiClient, type ApiClientOptions, type MutationFunction, type QueryFunction, type QueryKey } from './api';
|
|
2
|
+
export { checkPermission, type PermissionCheckMode } from './auth';
|
|
3
|
+
export { type DataOption, type DataOptionWithPinyin, type PaginationParams, type PaginationResult } from './common';
|
|
4
|
+
export { ApiClientProvider, AppContextProvider, createContextWithSelector, DisabledProvider, useApiClient, useAppContext, useDisabled, type AppContext, type SelectorContextProviderProps, type SelectorContextResult, type UseSelectorContext } from './context';
|
|
5
|
+
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';
|
|
6
|
+
export type { ApiResult, AuthTokens, BusinessError, HttpClient, HttpClientOptions, isBusinessError, ProgressEvent, RequestOptions } from './http';
|
|
7
|
+
export { skipAuthenticationHeader, skipAuthenticationValue } from './http';
|
|
8
|
+
export { applyPatches, currentState, originalState, produce, produceWithPatches, useImmer, useImmerReducer } from './immer';
|
|
9
|
+
export { AnimatePresence, LayoutGroup, motion, MotionProvider, Reorder, useInView, type MotionProps, type ResolvedValues, type TargetAndTransition, type Transition, type Variant, type VariantLabels, type Variants } from './motion';
|
|
10
|
+
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';
|
|
11
|
+
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';
|
|
12
|
+
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';
|
|
13
|
+
export { createComponentStore, createPersistedStore, createStore, useDeep, useShallow, type PersistenceOptions, type ReturnedComponentStoreResult, type SliceStateCreator, type StoreProviderProps, type UnboundStore, type UseBoundStore, type UseBoundStoreWithPersist, type UseStore } from './store';
|
|
14
|
+
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';
|
|
2
|
+
export type { MotionProps, ResolvedValues, TargetAndTransition, Transition, Variant, VariantLabels, Variants } from 'motion/react';
|
|
3
|
+
export { AnimatePresence, LayoutGroup, Reorder, useInView } from 'motion/react';
|
|
4
|
+
export * as motion from 'motion/react-m';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const QUERY_CLIENT_KEY = "__vef_query_client_key";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QueryClientOptions } from './types';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new query client.
|
|
5
|
+
*
|
|
6
|
+
* @param options - The options for the query client.
|
|
7
|
+
* @returns The query client.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createQueryClient(options?: QueryClientOptions): QueryClient;
|
|
10
|
+
export { keepPreviousData } from '@tanstack/react-query';
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
/**
|
|
4
|
+
* The hook for the query.
|
|
5
|
+
*
|
|
6
|
+
* @param options - The options for the query.
|
|
7
|
+
* @returns The result of the query.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = never>(options: DefinedInitialDataOptions<TQueryFnData, Error, TData, QueryKey<TParams>>): DefinedUseQueryResult<NoInfer<TData>, Error>;
|
|
10
|
+
/**
|
|
11
|
+
* The hook for the query.
|
|
12
|
+
*
|
|
13
|
+
* @param options - The options for the query.
|
|
14
|
+
* @returns The result of the query.
|
|
15
|
+
*/
|
|
16
|
+
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>;
|
|
17
|
+
/**
|
|
18
|
+
* The hook for the infinite query.
|
|
19
|
+
*
|
|
20
|
+
* @param options - The options for the infinite query.
|
|
21
|
+
* @returns The result of the infinite query.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useInfiniteQuery<TQueryFnData, TData = InfiniteData<TQueryFnData>, TParams = never, TPageParam = never>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>): DefinedUseInfiniteQueryResult<TData, Error>;
|
|
24
|
+
/**
|
|
25
|
+
* The hook for the infinite query.
|
|
26
|
+
*
|
|
27
|
+
* @param options - The options for the infinite query.
|
|
28
|
+
* @returns The result of the infinite query.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useInfiniteQuery<TQueryFnData, TData = InfiniteData<TQueryFnData>, TParams = never, TPageParam = never>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>): UseInfiniteQueryResult<TData, Error>;
|
|
31
|
+
/**
|
|
32
|
+
* The hook for the queries.
|
|
33
|
+
*
|
|
34
|
+
* @param options - The options for the queries.
|
|
35
|
+
* @returns The results of the queries.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useQueries<T extends any[], TCombinedResult = QueriesResults<T>>(options: Parameters<typeof useQueriesInternal<T, TCombinedResult>>[0]): TCombinedResult;
|
|
38
|
+
/**
|
|
39
|
+
* The hook for the mutation.
|
|
40
|
+
*
|
|
41
|
+
* @param mutationOptions - The options for the mutation.
|
|
42
|
+
* @returns The result of the mutation.
|
|
43
|
+
*/
|
|
44
|
+
export declare function useMutation<TData = unknown, TParams = void, TOnMutateResult = unknown>(options: UseMutationOptions<TData, Error, TParams, TOnMutateResult>): UseMutationResult<TData, Error, TParams, TOnMutateResult>;
|
|
45
|
+
/**
|
|
46
|
+
* The hook for the mutation state.
|
|
47
|
+
*
|
|
48
|
+
* @param options - The options for the mutation state.
|
|
49
|
+
* @returns The state of the mutations.
|
|
50
|
+
*/
|
|
51
|
+
export declare function useMutationState<TResult = MutationState>(options?: Parameters<typeof useMutationStateInternal<TResult>>[0]): TResult[];
|
|
52
|
+
/**
|
|
53
|
+
* The hook for getting the number of queries that are fetching.
|
|
54
|
+
*
|
|
55
|
+
* @param filters - The filters for the queries.
|
|
56
|
+
* @returns The number of queries that are fetching.
|
|
57
|
+
*/
|
|
58
|
+
export declare function useIsFetching(filters?: QueryFilters): number;
|
|
59
|
+
/**
|
|
60
|
+
* The hook for getting the number of mutations that are mutating.
|
|
61
|
+
*
|
|
62
|
+
* @param filters - The filters for the mutations.
|
|
63
|
+
* @returns The number of mutations that are mutating.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useIsMutating(filters?: MutationFilters): number;
|
|
66
|
+
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/shared';
|
|
3
|
+
import { QueryKey } from '../api';
|
|
4
|
+
declare module "@tanstack/react-query" {
|
|
5
|
+
interface Register {
|
|
6
|
+
mutationMeta: {
|
|
7
|
+
/**
|
|
8
|
+
* The query keys that will be invalidated when the mutation is successful.
|
|
9
|
+
*/
|
|
10
|
+
invalidates?: QueryKey[];
|
|
11
|
+
/**
|
|
12
|
+
* The should show success feedback.
|
|
13
|
+
*/
|
|
14
|
+
shouldShowSuccessFeedback?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The options for the query client.
|
|
20
|
+
*/
|
|
21
|
+
export interface QueryClientOptions {
|
|
22
|
+
/**
|
|
23
|
+
* The stale time.
|
|
24
|
+
*/
|
|
25
|
+
staleTime?: number;
|
|
26
|
+
/**
|
|
27
|
+
* The gc time.
|
|
28
|
+
*/
|
|
29
|
+
gcTime?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The show success message when the mutation is successful.
|
|
32
|
+
*/
|
|
33
|
+
showSuccessMessage?: (message: string) => void;
|
|
34
|
+
}
|
|
35
|
+
export type RetryValue = boolean | number | ShouldRetryFunction;
|
|
36
|
+
export type ShouldRetryFunction = (failureCount: number, error: Error) => boolean;
|
|
37
|
+
export type RetryDelayValue = number | RetryDelayFunction;
|
|
38
|
+
export type RetryDelayFunction = (failureCount: number, error: Error) => number;
|
|
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 UseMutationResult<TData = unknown, TParams = unknown, TOnMutateResult = unknown> = UseMutationResultInternal<TData, Error, TParams, TOnMutateResult>;
|
|
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 DefinedUseQueryResult<TData = unknown> = DefinedUseQueryResultInternal<TData, Error>;
|
|
50
|
+
export type UseInfiniteQueryOptions<TQueryFnData, TData = TQueryFnData, TParams = never, TPageParam = never> = UseInfiniteQueryOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>;
|
|
51
|
+
export { type InitialDataFunction, type MutationFunctionContext, type MutationMeta, type MutationScope, type QueryMeta, type SkipToken as SkipQueryToken, type StaleTime } from '@tanstack/react-query';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { atom, Provider as AtomStoreProvider, createStore as createAtomStore, getDefaultStore as getDefaultAtomStore, useAtom, useStore as useAtomStore, useAtomValue, useSetAtom, type Atom, type Getter as AtomGetter, type Setter as AtomSetter, type ExtractAtomArgs, type ExtractAtomResult, type ExtractAtomValue, type PrimitiveAtom, type SetStateAction, type WritableAtom } from 'jotai';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ActorOptions, AnyActorLogic, ConditionalRequired, IsNotNever, RequiredActorOptionsKeys, SnapshotFrom, Actor } from 'xstate';
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook for creating and using an XState actor with state selection
|
|
4
|
+
*
|
|
5
|
+
* @param logic - The actor logic (state machine or other actor logic)
|
|
6
|
+
* @param selector - Function to select specific data from the actor's snapshot
|
|
7
|
+
* @param options - Optional actor configuration options
|
|
8
|
+
* @returns A tuple containing [selectedState, sendFunction, actorRef]
|
|
9
|
+
*/
|
|
10
|
+
export declare function useActor<TLogic extends AnyActorLogic, TSelected>(logic: TLogic, selector: (snapshot: SnapshotFrom<TLogic>) => TSelected, ...[options]: ConditionalRequired<[
|
|
11
|
+
options?: ActorOptions<TLogic> & Record<RequiredActorOptionsKeys<TLogic>, unknown>
|
|
12
|
+
], IsNotNever<RequiredActorOptionsKeys<TLogic>>>): [TSelected, Actor<TLogic>["send"], Actor<TLogic>];
|
|
13
|
+
export { useActorRef } from '@xstate/react';
|
|
14
|
+
export { Actor, createActor, createMachine, assign as updateContext, type ActorLogic, type ActorOptions, type AnyActorLogic, type AnyMachineSnapshot, type AnyStateMachine, type MachineConfig, type MachineContext, type MachineSnapshot, type RequiredActorOptionsKeys, type SnapshotFrom, type StateMachine } from 'xstate';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { StateCreator } from 'zustand';
|
|
2
|
+
import { PersistenceOptions, UseBoundStore, UseBoundStoreWithPersist } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Create a store with the given initializer
|
|
5
|
+
*
|
|
6
|
+
* @param initializer - The initializer for the store
|
|
7
|
+
* @returns The store
|
|
8
|
+
*/
|
|
9
|
+
export declare function createStore<TState extends {
|
|
10
|
+
name: string;
|
|
11
|
+
}>(initializer: StateCreator<TState, [
|
|
12
|
+
["zustand/subscribeWithSelector", never],
|
|
13
|
+
["zustand/immer", never]
|
|
14
|
+
], [
|
|
15
|
+
]>): UseBoundStore<TState>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a persisted store with the given initializer and persistence options
|
|
18
|
+
*
|
|
19
|
+
* @param initializer - The initializer for the store
|
|
20
|
+
* @param persistenceOptions - The persistence options for the store
|
|
21
|
+
* @returns The store
|
|
22
|
+
*/
|
|
23
|
+
export declare function createPersistedStore<TState>(initializer: StateCreator<TState, [
|
|
24
|
+
["zustand/subscribeWithSelector", never],
|
|
25
|
+
["zustand/persist", unknown],
|
|
26
|
+
["zustand/immer", never]
|
|
27
|
+
], [
|
|
28
|
+
]>, persistenceOptions: PersistenceOptions<TState, unknown>): UseBoundStoreWithPersist<TState>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createPersistedStore, createStore } from './bound';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
export { createComponentStore, type ComponentStoreResult as ReturnedComponentStoreResult, type UseStore } from './unbound';
|
|
4
|
+
export { useDeep } from './use-deep';
|
|
5
|
+
export { useShallow } from 'zustand/shallow';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { If, IsNever } from '@vef-framework/shared';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { Mutate, StateCreator, StoreApi, UseBoundStore as UseBoundStoreInternal } from 'zustand';
|
|
4
|
+
export type SliceStateCreator<TState, TSlice, TPersist extends boolean = false> = StateCreator<TState, [
|
|
5
|
+
[
|
|
6
|
+
"zustand/subscribeWithSelector",
|
|
7
|
+
never
|
|
8
|
+
],
|
|
9
|
+
If<TPersist, ["zustand/persist", unknown], never>,
|
|
10
|
+
[
|
|
11
|
+
"zustand/immer",
|
|
12
|
+
never
|
|
13
|
+
]
|
|
14
|
+
], [
|
|
15
|
+
If<TPersist, never, ["zustand/immer", never]>
|
|
16
|
+
], TSlice>;
|
|
17
|
+
export type UnboundStore<TState> = Mutate<StoreApi<TState>, [["zustand/subscribeWithSelector", never], ["zustand/immer", never]]>;
|
|
18
|
+
export type UseBoundStore<TState> = UseBoundStoreInternal<Mutate<StoreApi<TState>, [["zustand/subscribeWithSelector", never], ["zustand/immer", never]]>>;
|
|
19
|
+
export type UseBoundStoreWithPersist<TState> = UseBoundStoreInternal<Mutate<StoreApi<TState>, [["zustand/subscribeWithSelector", never], ["zustand/persist", unknown], ["zustand/immer", never]]>>;
|
|
20
|
+
/**
|
|
21
|
+
* The options for the persistence
|
|
22
|
+
*/
|
|
23
|
+
export interface PersistenceOptions<TState, TSelectedState = TState> {
|
|
24
|
+
/**
|
|
25
|
+
* The unique name of the store
|
|
26
|
+
*/
|
|
27
|
+
name: string;
|
|
28
|
+
/**
|
|
29
|
+
* The storage type of the store
|
|
30
|
+
*/
|
|
31
|
+
storage?: "local" | "session";
|
|
32
|
+
/**
|
|
33
|
+
* The selector of the store
|
|
34
|
+
*/
|
|
35
|
+
selector?: (state: TState) => TSelectedState;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The props of the store provider
|
|
39
|
+
*/
|
|
40
|
+
export type StoreProviderProps<TInitialState> = PropsWithChildren<If<IsNever<TInitialState>, {
|
|
41
|
+
/**
|
|
42
|
+
* The initial state of the store
|
|
43
|
+
*/
|
|
44
|
+
initialState?: never;
|
|
45
|
+
}, {
|
|
46
|
+
/**
|
|
47
|
+
* The initial state of the store
|
|
48
|
+
*/
|
|
49
|
+
initialState: TInitialState;
|
|
50
|
+
}>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { StateCreator } from 'zustand';
|
|
3
|
+
import { StoreProviderProps, UnboundStore } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* The type for the useStore hook
|
|
6
|
+
*/
|
|
7
|
+
export interface UseStore<in out TState> {
|
|
8
|
+
(): TState;
|
|
9
|
+
<TSelected>(selector: (state: TState) => TSelected): NoInfer<TSelected>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The type for the returned component store result
|
|
13
|
+
*/
|
|
14
|
+
export interface ComponentStoreResult<TState, TInitialState extends Partial<TState> = never> {
|
|
15
|
+
StoreProvider: ComponentType<StoreProviderProps<TInitialState>>;
|
|
16
|
+
useStoreApi: <TStrictState extends TState = TState>() => UnboundStore<TStrictState>;
|
|
17
|
+
useStore: UseStore<TState>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a component store
|
|
21
|
+
*
|
|
22
|
+
* @param name - The name of the store
|
|
23
|
+
* @param initializer - The initializer for the store
|
|
24
|
+
* @returns The component store result
|
|
25
|
+
*/
|
|
26
|
+
export declare function createComponentStore<TState, TInitialState extends Partial<TState> = never>(name: string, initializer: StateCreator<TState, [["zustand/subscribeWithSelector", never], ["zustand/immer", never]], []>): ComponentStoreResult<TState, TInitialState>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A hook that returns a memoized selector function that is deeply equal to the previous selector function.
|
|
3
|
+
*
|
|
4
|
+
* @param selector - The selector function to memoize.
|
|
5
|
+
* @returns The memoized selector function.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useDeep<TState, TSelected>(selector: (state: TState) => TSelected): (state: TState) => TSelected;
|
package/package.json
CHANGED
|
@@ -1,56 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vef-framework/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"private": false,
|
|
6
|
-
"description": "
|
|
7
|
-
"author":
|
|
6
|
+
"description": "Core features for VEF framework",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Venus",
|
|
9
|
+
"email": "iweixiaopeng@163.com",
|
|
10
|
+
"url": "https://github.com/ilxqx"
|
|
11
|
+
},
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"homepage": "https://vef.ilxqx.com",
|
|
8
14
|
"keywords": [
|
|
9
15
|
"vef",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
16
|
+
"framework",
|
|
17
|
+
"react",
|
|
18
|
+
"core"
|
|
12
19
|
],
|
|
13
20
|
"sideEffects": false,
|
|
14
|
-
"main": "cjs/index.cjs",
|
|
15
|
-
"types": "types/index.d.ts",
|
|
16
|
-
"files": [
|
|
17
|
-
"*"
|
|
18
|
-
],
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=20"
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@emotion/cache": "11.14.0",
|
|
24
|
-
"@emotion/react": "11.14.0",
|
|
25
|
-
"@emotion/styled": "11.14.0",
|
|
26
|
-
"antd": "5.24.7",
|
|
27
|
-
"use-sync-external-store": "^1.5.0",
|
|
28
|
-
"@tanstack/react-query": "5.74.3",
|
|
29
|
-
"@tanstack/react-router": "1.116.0",
|
|
30
|
-
"@vef-framework/shared": "1.0.135",
|
|
31
|
-
"axios": "1.8.4",
|
|
32
|
-
"qs": "6.14.0"
|
|
33
|
-
},
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"access": "public"
|
|
36
|
-
},
|
|
37
21
|
"exports": {
|
|
38
22
|
".": {
|
|
23
|
+
"source": "./src/index.ts",
|
|
39
24
|
"import": {
|
|
40
|
-
"types": "./types/index.d.ts",
|
|
41
|
-
"default": "./
|
|
25
|
+
"types": "./dist/types/index.d.ts",
|
|
26
|
+
"default": "./dist/es/index.js"
|
|
42
27
|
},
|
|
43
28
|
"require": {
|
|
44
|
-
"types": "./types/index.d.ts",
|
|
45
|
-
"default": "./cjs/index.cjs"
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
|
+
"default": "./dist/cjs/index.cjs"
|
|
46
31
|
}
|
|
47
32
|
},
|
|
48
33
|
"./package.json": "./package.json"
|
|
49
34
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
35
|
+
"main": "dist/cjs/index.cjs",
|
|
36
|
+
"module": "dist/es/index.js",
|
|
37
|
+
"types": "dist/types/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=22.x"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
52
47
|
"peerDependencies": {
|
|
53
|
-
"react": "
|
|
54
|
-
|
|
48
|
+
"react": ">=19"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@dnd-kit/abstract": "^0.1.21",
|
|
52
|
+
"@dnd-kit/dom": "^0.1.21",
|
|
53
|
+
"@dnd-kit/helpers": "^0.1.21",
|
|
54
|
+
"@dnd-kit/react": "^0.1.21",
|
|
55
|
+
"@emotion/react": "^11.14.0",
|
|
56
|
+
"@hello-pangea/dnd": "^18.0.1",
|
|
57
|
+
"@tanstack/react-query": "^5.90.10",
|
|
58
|
+
"@xstate/react": "^6.0.0",
|
|
59
|
+
"axios": "^1.13.2",
|
|
60
|
+
"clsx": "^2.1.1",
|
|
61
|
+
"immer": "^11.0.0",
|
|
62
|
+
"jotai": "^2.15.1",
|
|
63
|
+
"motion": "^12.23.24",
|
|
64
|
+
"use-immer": "^0.11.0",
|
|
65
|
+
"xstate": "^5.24.0",
|
|
66
|
+
"zustand": "^5.0.8",
|
|
67
|
+
"@vef-framework/shared": "2.0.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"react": "^19.2.0"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"clean": "rimraf dist",
|
|
74
|
+
"typecheck": "tsc --noEmit",
|
|
75
|
+
"build": "vite build",
|
|
76
|
+
"pub": "tsx ../../scripts/publish.ts"
|
|
55
77
|
}
|
|
56
|
-
}
|
|
78
|
+
}
|
package/README.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# The Core of VEF Framework
|
|
2
|
-
|
|
3
|
-
VEF framework made by Venus is built on top of React, and it provides a set of components that are essential for building a modern web application. These components are designed to be highly customizable and reusable, allowing developers to build complex and dynamic user interfaces with ease.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
To install the VEF framework core, you can use pnpm or any other package manager you like:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pnpm add @vef-framework/core
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
To use the VEF framework core in your project, you can import them from the package, for example:
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { xxx } from "@vef-framework/core";
|
|
19
|
-
|
|
20
|
-
const result = xxx();
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Documentation
|
|
24
|
-
|
|
25
|
-
For more details on how to use the VEF framework core, please refer to the [official documentation](https://vef.ilxqx.com/docs).
|
package/cjs/api/api-client.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use strict";var f=require("@tanstack/react-query"),K=require("react"),C=require("./query-client.cjs"),I=require("./request-client.cjs"),R=Object.defineProperty,P=r=>{throw TypeError(r)},x=(r,e,i)=>e in r?R(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i,A=(r,e,i)=>x(r,typeof e!="symbol"?e+"":e,i),q=(r,e,i)=>e.has(r)||P("Cannot "+i),n=(r,e,i)=>(q(r,e,"read from private field"),i?i.call(r):e.get(r)),D=(r,e,i)=>e.has(r)?P("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,i),o=(r,e,i,t)=>(q(r,e,"write to private field"),t?t.call(r,i):e.set(r,i),i),m=(r,e,i)=>(q(r,e,"access private method"),i),c,y,b,h,g,k,M,S,F;class E{constructor(e){this.options=e,D(this,g),A(this,"useApiQuery"),A(this,"useSuspenseApiQuery"),A(this,"useApiMutation"),A(this,"useIsFetching"),A(this,"useIsMutating"),A(this,"QueryClientProvider"),D(this,c),D(this,y),D(this,b),D(this,h),o(this,c,C.createQueryClient(e)),o(this,y,I.createRequestClient(e)),o(this,b,{get:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).get(t,{...s,signal:a})},post:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).post(t,s,{...a,signal:u})},put:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).put(t,s,{...a,signal:u})},delete:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).delete(t,{...s,signal:a})},upload:async(t,s,a)=>{const u=n(this,h);return o(this,h,void 0),await n(this,y).upload(t,s,{...a,signal:u})},download:async(t,s)=>{const a=n(this,h);return o(this,h,void 0),await n(this,y).download(t,{...s,signal:a})}});const i=this;this.useApiQuery=function(t,s,a){var u;const{keepPreviousData:p,placeholderData:Q,initialData:l,...v}=a??{},d=f.useQuery({queryKey:[t.key,s],queryFn:({signal:w})=>t(s,{signal:w}),select:m(i,g,k),placeholderData:Q??p===!0?f.keepPreviousData:void 0,initialData:l?{code:0,message:"ok",data:l}:void 0,...v});return m(u=i,g,S).call(u,d)},this.useSuspenseApiQuery=function(t,s,a){const{keepPreviousData:u,initialData:p,...Q}=a??{},{data:l,refetch:v}=f.useSuspenseQuery({queryKey:[t.key,s],queryFn:({signal:d})=>t(s,{signal:d}),select:m(i,g,k),initialData:p?{code:0,message:"ok",data:p}:void 0,...Q});return{data:l,refetch:m(this,g,M).call(this,v)}},this.useApiMutation=function(t){const{isPending:s,isIdle:a,isError:u,isSuccess:p,error:Q,data:l,mutateAsync:v}=f.useMutation({mutationKey:[t.key],mutationFn:d=>t(d)});return{mutate:async d=>await v(d),isPending:s,isIdle:a,isError:u,isSuccess:p,message:l?.message,error:Q??void 0,data:l?.data}},this.useIsFetching=function(t,s){return f.useIsFetching({queryKey:arguments.length>1?[t,s]:[t],type:"active",exact:!1})>0},this.useIsMutating=function(t){return f.useIsMutating({mutationKey:[t],exact:!1})>0},this.QueryClientProvider=function({children:t}){return K.createElement(f.QueryClientProvider,{client:n(i,c)},t)}}async fetchApiQuery(e,i,t){const{initialData:s,...a}=t??{};return(await n(this,c).fetchQuery({queryKey:[e.key,i],queryFn:({signal:u})=>e(i,{signal:u}),initialData:s?{code:0,message:"ok",data:s}:void 0,...a})).data}createQueryApi(e,i){const t=m(this,g,F).call(this,e,i);return t.useQuery=this.useApiQuery.bind(this,t),t.useSuspenseQuery=this.useSuspenseApiQuery.bind(this,t),t.fetchQuery=this.fetchApiQuery.bind(this,t),t.getQueryData=this.getApiQueryData.bind(this,e),t.getQueriesData=this.getApiQueriesData.bind(this,e),t.setQueryData=(s,a)=>this.setApiQueryData(s,e,a),t.ensureQueryData=this.ensureApiQueryData.bind(this,t),t.removeQueries=this.removeApiQueries.bind(this,e),t.invalidateQueries=this.invalidateApiQueries.bind(this,e),t.resetQueries=this.resetApiQueries.bind(this,e),t.refetchQueries=this.refetchApiQueries.bind(this,e),t.cancelQueries=this.cancelApiQueries.bind(this,e),t.isFetching=this.isFetching.bind(this,e),t.useIsFetching=this.useIsFetching.bind(void 0,e),Object.freeze(t)}createMutationApi(e,i,t=[]){const s=m(this,g,F).call(this,e,i);return s.relatedQueries=Object.freeze(t),s.useMutation=this.useApiMutation.bind(this,s),s.refetchRelatedQueries=function(){return Promise.all(t.map(a=>a.refetchQueries()))},s.invalidateRelatedQueries=function(){return Promise.all(t.map(a=>a.invalidateQueries()))},s.isMutating=this.isMutating.bind(this,e),s.useIsMutating=this.useIsMutating.bind(void 0,e),Object.freeze(s)}getApiQueryData(e,i){return n(this,c).getQueryData(arguments.length>1?[e,i]:[e])}getApiQueriesData(e,i){return n(this,c).getQueriesData({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1})}setApiQueryData(e,i,t){n(this,c).setQueryData(arguments.length>2?[i,t]:[i],e)}async ensureApiQueryData(e,i,t){const{initialData:s,...a}=t??{};return(await n(this,c).ensureQueryData({queryKey:[e.key,i],queryFn:({signal:u})=>e(i,{signal:u}),initialData:s?{code:0,message:"ok",data:s}:void 0,...a,revalidateIfStale:!0})).data}removeApiQueries(e,i){n(this,c).removeQueries({type:"all",exact:!1,queryKey:arguments.length>1?[e,i]:[e]})}invalidateApiQueries(e,i){return n(this,c).invalidateQueries({queryKey:arguments.length>1?[e,i]:[e],type:"all",exact:!1,stale:!1,refetchType:"active"},{throwOnError:!1,cancelRefetch:!1})}resetApiQueries(e,i){return n(this,c).resetQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{cancelRefetch:!0,throwOnError:!1})}refetchApiQueries(e,i){return n(this,c).refetchQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{throwOnError:!1,cancelRefetch:!1})}cancelApiQueries(e,i){return n(this,c).cancelQueries({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1},{revert:!0,silent:!0})}isFetching(e,i){return n(this,c).isFetching({queryKey:arguments.length>1?[e,i]:[e],type:"active",exact:!1})>0}isMutating(e){return n(this,c).isMutating({mutationKey:[e],exact:!1})>0}}c=new WeakMap,y=new WeakMap,b=new WeakMap,h=new WeakMap,g=new WeakSet,k=function(r){return r.data},M=function(r){return async e=>{const i=await r(e);return{isSuccess:i.isSuccess,isError:i.isError,error:i.error,data:i.data}}},S=function({isPending:r,isFetching:e,isLoading:i,isRefetching:t,isSuccess:s,isPlaceholderData:a,isError:u,isLoadingError:p,isRefetchError:Q,isStale:l,error:v,data:d,refetch:w}){return{isPending:r,isSuccess:s,isError:u,isLoadingError:p,isRefetchError:Q,isLoading:i,isFetching:e,isRefetching:t,isPlaceholderData:a,isStale:l,error:v??void 0,data:d,refetch:m(this,g,M).call(this,w)}},F=function(r,e){const i=e(n(this,b)),t=async(s,a)=>(o(this,h,a?.signal),await i(s));return t.key=r,t};function O(r){return Object.freeze(new E(r))}exports.ApiClient=E,exports.createApiClient=O;
|
package/cjs/api/api-context.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use strict";var l=require("@vef-framework/shared"),t=require("react");const A=t.createContext(null),g=({client:e,dataDictionaryApi:n,loginApi:u,logoutApi:a,fetchAuthenticatedUserApi:s,children:p})=>{const o=t.useMemo(()=>{const c=e.createQueryApi("_vefStubQueryApi",()=>i=>Promise.resolve({code:0,message:"ok",data:i})),d=e.createQueryApi("_vefAsyncFnQueryApi",()=>async({args:i,fn:r})=>({code:0,message:"ok",data:await r(...i)})),Q=e.createMutationApi("_vefStubMutationApi",()=>i=>Promise.resolve({code:0,message:"ok",data:i})),y=e.createMutationApi("_vefAsyncFnMutationApi",()=>async({args:i,fn:r})=>({code:0,message:"ok",data:await r(...i)}));return Object.freeze({useApiQuery:e.useApiQuery,useSuspenseApiQuery:e.useSuspenseApiQuery,useApiMutation:e.useApiMutation,useIsFetching:e.useIsFetching,useIsMutating:e.useIsMutating,fetchApiQuery:e.fetchApiQuery.bind(e),createQueryApi:e.createQueryApi.bind(e),createMutationApi:e.createMutationApi.bind(e),getApiQueryData:e.getApiQueryData.bind(e),getApiQueriesData:e.getApiQueriesData.bind(e),setApiQueryData:e.setApiQueryData.bind(e),ensureApiQueryData:e.ensureApiQueryData.bind(e),removeApiQueries:e.removeApiQueries.bind(e),invalidateApiQueries:e.invalidateApiQueries.bind(e),resetApiQueries:e.resetApiQueries.bind(e),refetchApiQueries:e.refetchApiQueries.bind(e),cancelApiQueries:e.cancelApiQueries.bind(e),isFetching:e.isFetching.bind(e),isMutating:e.isMutating.bind(e),stubQueryApi:c,asyncFnQueryApi:d,stubMutationApi:Q,asyncFnMutationApi:y,dataDictionaryApi:n,loginApi:u,logoutApi:a,fetchAuthenticatedUserApi:s})},[e,n,u,a,s]);return t.createElement(A.Provider,{value:o},t.createElement(e.QueryClientProvider,{},p))};function b(){const e=t.useContext(A);if(e===null)throw new l.VefError(-1,"Api context not found: Please ensure useApiContext is called within an ApiContextProvider");return e}exports.ApiContextProvider=g,exports.useApiContext=b;
|
package/cjs/api/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use strict";var e=require("./api-client.cjs"),r=require("./api-context.cjs"),t=require("@tanstack/react-query");exports.ApiClient=e.ApiClient,exports.createApiClient=e.createApiClient,exports.ApiContextProvider=r.ApiContextProvider,exports.useApiContext=r.useApiContext,Object.defineProperty(exports,"useQueryErrorResetBoundary",{enumerable:!0,get:function(){return t.useQueryErrorResetBoundary}});
|
package/cjs/api/query-client.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use strict";var n=require("@tanstack/react-query");function c(e){const r=e?.staleTime??1/0,t=e?.gcTime??10*60*1e3;return new n.QueryClient({defaultOptions:{queries:{networkMode:"always",staleTime:r,gcTime:t,retry:!1,structuralSharing:!0,throwOnError:!1,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!0},mutations:{networkMode:"always",gcTime:r,retry:!1,throwOnError:!1}}})}exports.createQueryClient=c;
|