@vef-framework/core 2.0.11 → 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/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/ai/index.cjs +1 -0
- package/dist/cjs/api/client.cjs +1 -1
- package/dist/cjs/api/constants.cjs +1 -1
- package/dist/cjs/api/helpers.cjs +1 -1
- package/dist/cjs/api/index.cjs +1 -1
- package/dist/cjs/auth/helpers.cjs +1 -1
- package/dist/cjs/auth/index.cjs +1 -1
- package/dist/cjs/context/api-client.cjs +1 -1
- package/dist/cjs/context/app.cjs +1 -1
- package/dist/cjs/context/context-selector.cjs +1 -1
- package/dist/cjs/context/disabled.cjs +1 -1
- package/dist/cjs/context/index.cjs +1 -1
- package/dist/cjs/dnd/index.cjs +1 -1
- package/dist/cjs/http/client.cjs +1 -1
- package/dist/cjs/http/constants.cjs +1 -0
- package/dist/cjs/http/errors.cjs +1 -1
- package/dist/cjs/http/helpers.cjs +1 -1
- package/dist/cjs/http/index.cjs +1 -1
- package/dist/cjs/immer/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/motion/features.cjs +1 -1
- package/dist/cjs/motion/index.cjs +1 -1
- package/dist/cjs/motion/motion-provider.cjs +1 -1
- package/dist/cjs/query/constants.cjs +1 -1
- package/dist/cjs/query/helpers.cjs +1 -1
- package/dist/cjs/query/hooks.cjs +1 -1
- package/dist/cjs/query/index.cjs +1 -1
- 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 -1
- package/dist/cjs/state-machine/index.cjs +1 -1
- package/dist/cjs/store/bound.cjs +1 -1
- package/dist/cjs/store/index.cjs +1 -1
- package/dist/cjs/store/unbound.cjs +1 -3
- package/dist/cjs/store/use-deep.cjs +1 -1
- package/dist/es/ai/index.js +3 -0
- package/dist/es/api/client.js +72 -147
- package/dist/es/api/constants.js +14 -7
- package/dist/es/api/helpers.js +7 -6
- package/dist/es/api/index.js +4 -8
- package/dist/es/auth/helpers.js +9 -9
- package/dist/es/auth/index.js +2 -4
- package/dist/es/context/api-client.js +21 -17
- package/dist/es/context/app.js +8 -8
- package/dist/es/context/context-selector.js +38 -50
- package/dist/es/context/disabled.js +9 -9
- package/dist/es/context/index.js +5 -13
- package/dist/es/dnd/index.js +8 -30
- package/dist/es/http/client.js +186 -359
- package/dist/es/http/constants.js +5 -0
- package/dist/es/http/errors.js +10 -15
- package/dist/es/http/helpers.js +8 -11
- package/dist/es/http/index.js +5 -11
- package/dist/es/immer/index.js +6 -15
- package/dist/es/index.js +27 -122
- package/dist/es/motion/features.js +3 -4
- package/dist/es/motion/index.js +5 -11
- package/dist/es/motion/motion-provider.js +22 -21
- package/dist/es/query/constants.js +5 -4
- package/dist/es/query/helpers.js +40 -54
- package/dist/es/query/hooks.js +18 -28
- package/dist/es/query/index.js +4 -14
- 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 -11
- package/dist/es/state-machine/index.js +13 -14
- package/dist/es/store/bound.js +18 -33
- package/dist/es/store/index.js +6 -11
- package/dist/es/store/unbound.js +43 -50
- package/dist/es/store/use-deep.js +12 -11
- package/dist/types/ai/index.d.ts +6 -0
- package/dist/types/api/client.d.ts +15 -35
- package/dist/types/api/constants.d.ts +7 -3
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/auth/helpers.d.ts +5 -5
- package/dist/types/auth/index.d.ts +2 -2
- package/dist/types/common/index.d.ts +1 -1
- package/dist/types/common/types.d.ts +3 -0
- package/dist/types/context/api-client.d.ts +9 -10
- package/dist/types/context/app.d.ts +9 -1
- package/dist/types/context/context-selector.d.ts +7 -19
- package/dist/types/context/disabled.d.ts +2 -2
- package/dist/types/context/index.d.ts +3 -2
- package/dist/types/context/types.d.ts +0 -1
- package/dist/types/dnd/index.d.ts +4 -2
- package/dist/types/http/client.d.ts +39 -71
- package/dist/types/http/constants.d.ts +24 -0
- package/dist/types/http/index.d.ts +2 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/motion/index.d.ts +2 -2
- package/dist/types/motion/motion-provider.d.ts +8 -3
- package/dist/types/query/helpers.d.ts +1 -4
- package/dist/types/query/hooks.d.ts +6 -45
- package/dist/types/query/types.d.ts +12 -12
- 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/dist/types/sse/client.d.ts +16 -0
- package/dist/types/sse/helpers.d.ts +9 -0
- package/dist/types/sse/index.d.ts +3 -0
- package/dist/types/sse/types.d.ts +98 -0
- package/dist/types/state-machine/index.d.ts +2 -1
- package/dist/types/store/unbound.d.ts +6 -6
- package/dist/types/store/use-deep.d.ts +4 -3
- package/package.json +18 -16
- package/dist/cjs/common/index.cjs +0 -1
- package/dist/es/common/index.js +0 -1
|
@@ -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;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { HttpClient
|
|
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';
|
|
2
3
|
export { BusinessError } from './errors';
|
|
3
4
|
export { createHttpClient, isBusinessError } from './helpers';
|
|
4
5
|
export type * from './types';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './ai';
|
|
2
|
+
export { ApiClient, createApiClient, HTTP_CLIENT, QUERY_CLIENT, type ApiClientOptions, type MutationFunction, type QueryFunction, type QueryKey } from './api';
|
|
2
3
|
export { checkPermission, type PermissionCheckMode } from './auth';
|
|
3
4
|
export { type DataOption, type DataOptionWithPinyin, type PaginationParams, type PaginationResult } from './common';
|
|
4
5
|
export { ApiClientProvider, AppContextProvider, createContextWithSelector, DisabledProvider, useApiClient, useAppContext, useDisabled, type AppContext, type SelectorContextProviderProps, type SelectorContextResult, type UseSelectorContext } from './context';
|
|
@@ -6,8 +7,9 @@ export { AxisModifier, DragDropContext, DragDropProvider, Draggable, DragOverlay
|
|
|
6
7
|
export type { ApiResult, AuthTokens, BusinessError, HttpClient, HttpClientOptions, isBusinessError, ProgressEvent, RequestOptions } from './http';
|
|
7
8
|
export { skipAuthenticationHeader, skipAuthenticationValue } from './http';
|
|
8
9
|
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 { AnimatePresence, LayoutGroup, motion, MotionProvider, Reorder, useDragControls, useInView, type MotionProps, type ResolvedValues, type TargetAndTransition, type Transition, type Variant, type VariantLabels, type Variants } from './motion';
|
|
10
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';
|
|
11
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';
|
|
12
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';
|
|
13
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';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as MotionProvider } from './motion-provider';
|
|
1
|
+
export { default as MotionProvider } from './motion-provider.js';
|
|
2
2
|
export type { MotionProps, ResolvedValues, TargetAndTransition, Transition, Variant, VariantLabels, Variants } from 'motion/react';
|
|
3
|
-
export { AnimatePresence, LayoutGroup, Reorder, useInView } from 'motion/react';
|
|
3
|
+
export { AnimatePresence, LayoutGroup, Reorder, useDragControls, useInView } from 'motion/react';
|
|
4
4
|
export * as motion from 'motion/react-m';
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface MotionProviderProps
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface MotionProviderProps {
|
|
3
|
+
children: ReactNode;
|
|
3
4
|
}
|
|
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;
|
|
5
10
|
export {};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { QueryClientOptions } from './types';
|
|
2
2
|
import { QueryClient } from '@tanstack/react-query';
|
|
3
3
|
/**
|
|
4
|
-
* Creates a
|
|
5
|
-
*
|
|
6
|
-
* @param options - The options for the query client.
|
|
7
|
-
* @returns The query client.
|
|
4
|
+
* Creates a configured QueryClient instance with mutation cache and default options
|
|
8
5
|
*/
|
|
9
6
|
export declare function createQueryClient(options?: QueryClientOptions): QueryClient;
|
|
10
7
|
export { keepPreviousData } from '@tanstack/react-query';
|
|
@@ -1,66 +1,27 @@
|
|
|
1
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
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
3
|
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
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>;
|
|
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
5
|
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
6
|
export declare function useInfiniteQuery<TQueryFnData, TData = InfiniteData<TQueryFnData>, TParams = never, TPageParam = never>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>): UseInfiniteQueryResult<TData, Error>;
|
|
31
7
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @param options - The options for the queries.
|
|
35
|
-
* @returns The results of the queries.
|
|
8
|
+
* Hook for executing multiple queries in parallel
|
|
36
9
|
*/
|
|
37
|
-
export declare function useQueries<T extends
|
|
10
|
+
export declare function useQueries<T extends unknown[], TCombinedResult = QueriesResults<T>>(options: Parameters<typeof useQueriesInternal<T, TCombinedResult>>[0]): TCombinedResult;
|
|
38
11
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @param mutationOptions - The options for the mutation.
|
|
42
|
-
* @returns The result of the mutation.
|
|
12
|
+
* Hook for executing mutations with automatic error typing
|
|
43
13
|
*/
|
|
44
14
|
export declare function useMutation<TData = unknown, TParams = void, TOnMutateResult = unknown>(options: UseMutationOptions<TData, Error, TParams, TOnMutateResult>): UseMutationResult<TData, Error, TParams, TOnMutateResult>;
|
|
45
15
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @param options - The options for the mutation state.
|
|
49
|
-
* @returns The state of the mutations.
|
|
16
|
+
* Hook for accessing mutation state across the application
|
|
50
17
|
*/
|
|
51
18
|
export declare function useMutationState<TResult = MutationState>(options?: Parameters<typeof useMutationStateInternal<TResult>>[0]): TResult[];
|
|
52
19
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @param filters - The filters for the queries.
|
|
56
|
-
* @returns The number of queries that are fetching.
|
|
20
|
+
* Hook for getting the count of currently fetching queries
|
|
57
21
|
*/
|
|
58
22
|
export declare function useIsFetching(filters?: QueryFilters): number;
|
|
59
23
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @param filters - The filters for the mutations.
|
|
63
|
-
* @returns The number of mutations that are mutating.
|
|
24
|
+
* Hook for getting the count of currently executing mutations
|
|
64
25
|
*/
|
|
65
26
|
export declare function useIsMutating(filters?: MutationFilters): number;
|
|
66
27
|
export { matchMutation, matchQuery, skipToken as skipQueryToken, useQueryErrorResetBoundary } from '@tanstack/react-query';
|
|
@@ -5,47 +5,47 @@ declare module "@tanstack/react-query" {
|
|
|
5
5
|
interface Register {
|
|
6
6
|
mutationMeta: {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Query keys to invalidate on successful mutation
|
|
9
9
|
*/
|
|
10
|
-
invalidates?: QueryKey
|
|
10
|
+
invalidates?: Array<QueryKey<never> | QueryKey<unknown>>;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Whether to show success feedback (default: true)
|
|
13
13
|
*/
|
|
14
14
|
shouldShowSuccessFeedback?: boolean;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Options for creating a QueryClient instance
|
|
20
20
|
*/
|
|
21
21
|
export interface QueryClientOptions {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Time in ms before data is considered stale (default: 5000)
|
|
24
24
|
*/
|
|
25
25
|
staleTime?: number;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Time in ms before inactive queries are garbage collected (default: 300000)
|
|
28
28
|
*/
|
|
29
29
|
gcTime?: number;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Callback to display success message from mutation response
|
|
32
32
|
*/
|
|
33
33
|
showSuccessMessage?: (message: string) => void;
|
|
34
34
|
}
|
|
35
|
-
export type RetryValue = boolean | number | ShouldRetryFunction;
|
|
36
35
|
export type ShouldRetryFunction = (failureCount: number, error: Error) => boolean;
|
|
37
|
-
export type
|
|
36
|
+
export type RetryValue = boolean | number | ShouldRetryFunction;
|
|
38
37
|
export type RetryDelayFunction = (failureCount: number, error: Error) => number;
|
|
38
|
+
export type RetryDelayValue = number | RetryDelayFunction;
|
|
39
39
|
export type PlaceholderDataFunction<TData = unknown> = (previousData: MaybeUndefined<TData>) => MaybeUndefined<TData>;
|
|
40
40
|
export interface RefetchOptions {
|
|
41
41
|
cancelRefetch?: boolean;
|
|
42
42
|
}
|
|
43
43
|
export type QueryKeyHashFunction<TParams = never> = QueryKeyHashFunctionInternal<QueryKey<TParams>>;
|
|
44
44
|
export type UseQueryResult<TData = unknown> = UseQueryResultInternal<TData, Error>;
|
|
45
|
-
export type
|
|
45
|
+
export type DefinedUseQueryResult<TData = unknown> = DefinedUseQueryResultInternal<TData, Error>;
|
|
46
46
|
export type UseQueryOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = UseQueryOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>>;
|
|
47
47
|
export type DefinedInitialDataOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = DefinedInitialDataOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>>;
|
|
48
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
49
|
export type UseInfiniteQueryOptions<TQueryFnData, TData = TQueryFnData, TParams = never, TPageParam = never> = UseInfiniteQueryOptionsInternal<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>;
|
|
51
|
-
export
|
|
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,6 @@
|
|
|
1
|
+
export { DefaultChatTransport, TextStreamChatTransport, type ChatTransport } from 'ai';
|
|
2
|
+
export type { DataUIPart, DynamicToolUIPart, FileUIPart, ReasoningUIPart, SourceDocumentUIPart, SourceUrlUIPart, StepStartUIPart, TextUIPart, ToolUIPart, UIMessage, UIMessageChunk, UIMessagePart } from 'ai';
|
|
3
|
+
export type { UIToolInvocation, UITools } from 'ai';
|
|
4
|
+
export { getToolName, getToolOrDynamicToolName } from 'ai';
|
|
5
|
+
export { isDataUIPart, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart } from 'ai';
|
|
6
|
+
export { isDeepEqualData, parsePartialJson } from 'ai';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { FetchQueryOptions, MutationOptions, QueryClient, QueryMeta } from '@tanstack/react-query';
|
|
2
|
+
import { Awaitable, Except, If, IsNever, IsOptional } from '@vef-framework/shared';
|
|
3
|
+
import { HttpClient } from '../http';
|
|
4
|
+
import { ApiClientOptions, MutationFunction, QueryFunction, QueryKey } from './types';
|
|
5
|
+
import { HTTP_CLIENT, QUERY_CLIENT } from './constants';
|
|
6
|
+
/**
|
|
7
|
+
* API client that combines HttpClient and QueryClient for data fetching.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ApiClient {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* Access the underlying QueryClient.
|
|
13
|
+
*/
|
|
14
|
+
get [QUERY_CLIENT](): QueryClient;
|
|
15
|
+
/**
|
|
16
|
+
* Access the underlying HttpClient.
|
|
17
|
+
*/
|
|
18
|
+
get [HTTP_CLIENT](): Readonly<HttpClient>;
|
|
19
|
+
constructor(options: ApiClientOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Create a proxied HttpClient that injects the current abort signal.
|
|
22
|
+
*/
|
|
23
|
+
private createProxiedHttpClient;
|
|
24
|
+
/**
|
|
25
|
+
* Create a query function with automatic signal injection.
|
|
26
|
+
*/
|
|
27
|
+
createQueryFn<TResult = unknown, TParams = never, TPageParam = never>(key: string, factory: (http: Readonly<HttpClient>) => (queryParams: TParams, pageParam: TPageParam, meta?: QueryMeta) => Awaitable<TResult>): QueryFunction<TResult, TParams, TPageParam>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a mutation function.
|
|
30
|
+
*/
|
|
31
|
+
createMutationFn<TResult = unknown, TParams = never>(key: string, factory: (http: Readonly<HttpClient>) => (params: TParams) => Awaitable<TResult>): MutationFunction<TResult, TParams>;
|
|
32
|
+
/**
|
|
33
|
+
* Fetch a query and return the result.
|
|
34
|
+
*/
|
|
35
|
+
fetchQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = unknown, TPageParam = never>(options: Except<FetchQueryOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>, "queryHash" | "queryKeyHashFn">): Promise<TData>;
|
|
36
|
+
/**
|
|
37
|
+
* Prefetch a query and store the result in cache.
|
|
38
|
+
*/
|
|
39
|
+
prefetchQuery<TQueryFnData = unknown, TData = TQueryFnData, TParams = unknown, TPageParam = never>(options: Except<FetchQueryOptions<TQueryFnData, Error, TData, QueryKey<TParams>, TPageParam>, "queryHash" | "queryKeyHashFn">): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Execute a mutation imperatively outside of React components.
|
|
42
|
+
*
|
|
43
|
+
* Useful for scenarios like login flows, event handlers, or any code outside React components.
|
|
44
|
+
* Lifecycle callbacks (onMutate, onSuccess, etc.) still fire.
|
|
45
|
+
*/
|
|
46
|
+
executeMutation<TData = unknown, TParams = unknown, TOnMutateResult = unknown>({ mutationFn, params, ...options }: Except<MutationOptions<TData, Error, TParams, TOnMutateResult>, "mutationKey" | "mutationFn"> & {
|
|
47
|
+
mutationFn: MutationFunction<TData, TParams>;
|
|
48
|
+
} & If<IsNever<TParams>, {
|
|
49
|
+
params?: never;
|
|
50
|
+
}, If<IsOptional<TParams>, {
|
|
51
|
+
params?: TParams;
|
|
52
|
+
}, {
|
|
53
|
+
params: TParams;
|
|
54
|
+
}>>): Promise<TData>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP methods that should have the abort signal injected.
|
|
3
|
+
*/
|
|
4
|
+
export declare const PROXIED_METHODS: Set<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Symbol for accessing the query client.
|
|
7
|
+
*/
|
|
8
|
+
export declare const QUERY_CLIENT: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* Symbol for accessing the HTTP client.
|
|
11
|
+
*/
|
|
12
|
+
export declare const HTTP_CLIENT: unique symbol;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ApiClientOptions } from './types';
|
|
2
|
+
import { ApiClient } from './client';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new API client.
|
|
5
|
+
*
|
|
6
|
+
* @param options - The options for the API client.
|
|
7
|
+
* @returns The API client.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createApiClient(options: ApiClientOptions): ApiClient;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MutationFunction as MutationFunctionInternal, QueryFunction as QueryFunctionInternal } from '@tanstack/react-query';
|
|
2
|
+
import { If, IsNever, Key } from '@vef-framework/shared';
|
|
3
|
+
import { HttpClientOptions } from '../http';
|
|
4
|
+
import { QueryClientOptions } from '../query';
|
|
5
|
+
/**
|
|
6
|
+
* The options for the API client.
|
|
7
|
+
*/
|
|
8
|
+
export interface ApiClientOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The options for the HTTP client.
|
|
11
|
+
*/
|
|
12
|
+
http: HttpClientOptions;
|
|
13
|
+
/**
|
|
14
|
+
* The options for the query client.
|
|
15
|
+
*/
|
|
16
|
+
query?: QueryClientOptions;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The key of the query.
|
|
20
|
+
*
|
|
21
|
+
* @param TParams - The parameters of the query.
|
|
22
|
+
*/
|
|
23
|
+
export type QueryKey<TParams = never> = readonly [Key, ...If<IsNever<TParams>, [], [TParams]>];
|
|
24
|
+
/**
|
|
25
|
+
* The query function.
|
|
26
|
+
*
|
|
27
|
+
* @param TResult - The result of the query.
|
|
28
|
+
* @param TParams - The parameters of the query.
|
|
29
|
+
* @param TPageParam - The page parameter of the query.
|
|
30
|
+
*/
|
|
31
|
+
export interface QueryFunction<TData = unknown, TParams = never, TPageParam = never> extends QueryFunctionInternal<TData, QueryKey<TParams>, TPageParam> {
|
|
32
|
+
/**
|
|
33
|
+
* The API identifier.
|
|
34
|
+
*/
|
|
35
|
+
key: Key;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The mutation function.
|
|
39
|
+
*
|
|
40
|
+
* @param TResult - The result of the mutation.
|
|
41
|
+
* @param TParams - The parameters of the mutation.
|
|
42
|
+
*/
|
|
43
|
+
export interface MutationFunction<TData = unknown, TParams = never> extends MutationFunctionInternal<TData, TParams> {
|
|
44
|
+
/**
|
|
45
|
+
* The API identifier.
|
|
46
|
+
*/
|
|
47
|
+
key: Key;
|
|
48
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MaybeArray } from '@vef-framework/shared';
|
|
2
|
+
import { PermissionCheckMode } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Check if the user is authorized to access the resource identified by the permission token.
|
|
5
|
+
*
|
|
6
|
+
* @param hasPermission - Function to check if the user has a specific permission token.
|
|
7
|
+
* @param permTokens - Single token or array of tokens to check. If nullish, returns true (no permission required).
|
|
8
|
+
* @param checkMode - "any" requires at least one token match, "all" requires all tokens to match.
|
|
9
|
+
* @returns True if the user has the required permission(s), false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkPermission(hasPermission: (token: string) => boolean, permTokens?: MaybeArray<string>, checkMode?: PermissionCheckMode): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type PermissionCheckMode = "any" | "all";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from './types.js';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { AnyObject, EmptyObject, Except, Key } from '@vef-framework/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';
|