@pagamio/frontend-commons-lib 0.8.212 → 0.8.214

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.
Files changed (105) hide show
  1. package/lib/api/TanstackQueryProvider.d.ts +146 -0
  2. package/lib/api/TanstackQueryProvider.js +140 -0
  3. package/lib/api/index.d.ts +2 -0
  4. package/lib/api/index.js +2 -0
  5. package/lib/api/tanstackQuery.d.ts +249 -0
  6. package/lib/api/tanstackQuery.js +299 -0
  7. package/lib/components/layout/Sidebar.js +50 -16
  8. package/lib/components/ui/Sheet.d.ts +1 -1
  9. package/lib/context/SidebarContext.d.ts +20 -0
  10. package/lib/dashboard-visuals-v2/DashboardWrapperV2.d.ts +81 -0
  11. package/lib/dashboard-visuals-v2/DashboardWrapperV2.js +217 -0
  12. package/lib/dashboard-visuals-v2/cards/CardGrid.d.ts +22 -0
  13. package/lib/dashboard-visuals-v2/cards/CardGrid.js +27 -0
  14. package/lib/dashboard-visuals-v2/cards/InfoCard.d.ts +7 -0
  15. package/lib/dashboard-visuals-v2/cards/InfoCard.js +26 -0
  16. package/lib/dashboard-visuals-v2/cards/MetricCard.d.ts +7 -0
  17. package/lib/dashboard-visuals-v2/cards/MetricCard.js +37 -0
  18. package/lib/dashboard-visuals-v2/cards/StatCard.d.ts +7 -0
  19. package/lib/dashboard-visuals-v2/cards/StatCard.js +92 -0
  20. package/lib/dashboard-visuals-v2/cards/TopItemsCard.d.ts +7 -0
  21. package/lib/dashboard-visuals-v2/cards/TopItemsCard.js +34 -0
  22. package/lib/dashboard-visuals-v2/cards/TransactionListCard.d.ts +7 -0
  23. package/lib/dashboard-visuals-v2/cards/TransactionListCard.js +24 -0
  24. package/lib/dashboard-visuals-v2/cards/index.d.ts +9 -0
  25. package/lib/dashboard-visuals-v2/cards/index.js +9 -0
  26. package/lib/dashboard-visuals-v2/charts/AreaChart.d.ts +7 -0
  27. package/lib/dashboard-visuals-v2/charts/AreaChart.js +124 -0
  28. package/lib/dashboard-visuals-v2/charts/BarChart.d.ts +7 -0
  29. package/lib/dashboard-visuals-v2/charts/BarChart.js +106 -0
  30. package/lib/dashboard-visuals-v2/charts/BaseChart.d.ts +61 -0
  31. package/lib/dashboard-visuals-v2/charts/BaseChart.js +173 -0
  32. package/lib/dashboard-visuals-v2/charts/DonutChart.d.ts +7 -0
  33. package/lib/dashboard-visuals-v2/charts/DonutChart.js +108 -0
  34. package/lib/dashboard-visuals-v2/charts/HeatmapChart.d.ts +7 -0
  35. package/lib/dashboard-visuals-v2/charts/HeatmapChart.js +101 -0
  36. package/lib/dashboard-visuals-v2/charts/LineChart.d.ts +7 -0
  37. package/lib/dashboard-visuals-v2/charts/LineChart.js +109 -0
  38. package/lib/dashboard-visuals-v2/charts/MixedChart.d.ts +7 -0
  39. package/lib/dashboard-visuals-v2/charts/MixedChart.js +106 -0
  40. package/lib/dashboard-visuals-v2/charts/PieChart.d.ts +7 -0
  41. package/lib/dashboard-visuals-v2/charts/PieChart.js +10 -0
  42. package/lib/dashboard-visuals-v2/charts/RadialChart.d.ts +7 -0
  43. package/lib/dashboard-visuals-v2/charts/RadialChart.js +72 -0
  44. package/lib/dashboard-visuals-v2/charts/index.d.ts +12 -0
  45. package/lib/dashboard-visuals-v2/charts/index.js +12 -0
  46. package/lib/dashboard-visuals-v2/components/DataFetchingVisual.d.ts +0 -0
  47. package/lib/dashboard-visuals-v2/components/DataFetchingVisual.js +1 -0
  48. package/lib/dashboard-visuals-v2/components/index.d.ts +0 -0
  49. package/lib/dashboard-visuals-v2/components/index.js +1 -0
  50. package/lib/dashboard-visuals-v2/hooks/index.d.ts +4 -0
  51. package/lib/dashboard-visuals-v2/hooks/index.js +4 -0
  52. package/lib/dashboard-visuals-v2/hooks/useChartData.d.ts +72 -0
  53. package/lib/dashboard-visuals-v2/hooks/useChartData.js +122 -0
  54. package/lib/dashboard-visuals-v2/index.d.ts +10 -0
  55. package/lib/dashboard-visuals-v2/index.js +16 -0
  56. package/lib/dashboard-visuals-v2/types/card.types.d.ts +237 -0
  57. package/lib/dashboard-visuals-v2/types/card.types.js +30 -0
  58. package/lib/dashboard-visuals-v2/types/chart.types.d.ts +308 -0
  59. package/lib/dashboard-visuals-v2/types/chart.types.js +25 -0
  60. package/lib/dashboard-visuals-v2/types/index.d.ts +6 -0
  61. package/lib/dashboard-visuals-v2/types/index.js +6 -0
  62. package/lib/dashboard-visuals-v2/utils/index.d.ts +0 -0
  63. package/lib/dashboard-visuals-v2/utils/index.js +1 -0
  64. package/lib/dashboard-visuals-v2/utils/propsTransformer.d.ts +0 -0
  65. package/lib/dashboard-visuals-v2/utils/propsTransformer.js +1 -0
  66. package/lib/dashboard-visuals-v2/visualRegistry.d.ts +59 -0
  67. package/lib/dashboard-visuals-v2/visualRegistry.js +110 -0
  68. package/lib/data-table-v2/DataTable.d.ts +7 -0
  69. package/lib/data-table-v2/DataTable.js +206 -0
  70. package/lib/data-table-v2/components/DataTableBody.d.ts +19 -0
  71. package/lib/data-table-v2/components/DataTableBody.js +20 -0
  72. package/lib/data-table-v2/components/DataTableEmpty.d.ts +17 -0
  73. package/lib/data-table-v2/components/DataTableEmpty.js +13 -0
  74. package/lib/data-table-v2/components/DataTableError.d.ts +16 -0
  75. package/lib/data-table-v2/components/DataTableError.js +14 -0
  76. package/lib/data-table-v2/components/DataTableHeader.d.ts +15 -0
  77. package/lib/data-table-v2/components/DataTableHeader.js +31 -0
  78. package/lib/data-table-v2/components/DataTableLoading.d.ts +14 -0
  79. package/lib/data-table-v2/components/DataTableLoading.js +19 -0
  80. package/lib/data-table-v2/components/DataTablePagination.d.ts +36 -0
  81. package/lib/data-table-v2/components/DataTablePagination.js +20 -0
  82. package/lib/data-table-v2/components/DataTableRowActions.d.ts +13 -0
  83. package/lib/data-table-v2/components/DataTableRowActions.js +57 -0
  84. package/lib/data-table-v2/components/DataTableSearch.d.ts +19 -0
  85. package/lib/data-table-v2/components/DataTableSearch.js +33 -0
  86. package/lib/data-table-v2/components/DataTableToolbar.d.ts +54 -0
  87. package/lib/data-table-v2/components/DataTableToolbar.js +28 -0
  88. package/lib/data-table-v2/components/index.d.ts +12 -0
  89. package/lib/data-table-v2/components/index.js +12 -0
  90. package/lib/data-table-v2/hooks/index.d.ts +4 -0
  91. package/lib/data-table-v2/hooks/index.js +4 -0
  92. package/lib/data-table-v2/hooks/useTableData.d.ts +118 -0
  93. package/lib/data-table-v2/hooks/useTableData.js +210 -0
  94. package/lib/data-table-v2/index.d.ts +9 -0
  95. package/lib/data-table-v2/index.js +12 -0
  96. package/lib/data-table-v2/types/index.d.ts +296 -0
  97. package/lib/data-table-v2/types/index.js +1 -0
  98. package/lib/data-table-v2/utils/export.d.ts +26 -0
  99. package/lib/data-table-v2/utils/export.js +92 -0
  100. package/lib/data-table-v2/utils/index.d.ts +4 -0
  101. package/lib/data-table-v2/utils/index.js +4 -0
  102. package/lib/index.d.ts +4 -0
  103. package/lib/index.js +23 -0
  104. package/lib/styles.css +219 -0
  105. package/package.json +7 -1
@@ -0,0 +1,146 @@
1
+ /**
2
+ * @fileoverview TanStack Query Provider for the API client
3
+ * Provides a configured QueryClient with sensible defaults
4
+ */
5
+ import { QueryClient } from '@tanstack/react-query';
6
+ import type { ReactNode } from 'react';
7
+ /**
8
+ * Default configuration for the QueryClient
9
+ * Matches the conservative caching strategy used in the SWR integration
10
+ */
11
+ export declare const DEFAULT_QUERY_CLIENT_OPTIONS: {
12
+ queries: {
13
+ /** Data is considered fresh for 5 minutes */
14
+ staleTime: number;
15
+ /** Garbage collection time - 10 minutes */
16
+ gcTime: number;
17
+ /** Don't refetch on window focus (matches SWR config) */
18
+ refetchOnWindowFocus: boolean;
19
+ /** Don't refetch on reconnect (matches SWR config) */
20
+ refetchOnReconnect: boolean;
21
+ /** Retry failed requests once */
22
+ retry: number;
23
+ /** Retry delay */
24
+ retryDelay: (attemptIndex: number) => number;
25
+ /** Don't refetch on mount if data exists */
26
+ refetchOnMount: boolean;
27
+ };
28
+ mutations: {
29
+ /** Retry failed mutations once */
30
+ retry: number;
31
+ };
32
+ };
33
+ /**
34
+ * Configuration options for the ApiQueryProvider
35
+ */
36
+ export interface ApiQueryProviderConfig {
37
+ /** Custom QueryClient options to merge with defaults */
38
+ queryClientOptions?: {
39
+ queries?: Partial<typeof DEFAULT_QUERY_CLIENT_OPTIONS.queries>;
40
+ mutations?: Partial<typeof DEFAULT_QUERY_CLIENT_OPTIONS.mutations>;
41
+ };
42
+ /** Show React Query Devtools (default: false in production) */
43
+ showDevtools?: boolean;
44
+ /** Devtools position */
45
+ devtoolsPosition?: 'left' | 'right' | 'top' | 'bottom';
46
+ /** Initial devtools open state */
47
+ devtoolsInitialIsOpen?: boolean;
48
+ }
49
+ /**
50
+ * Props for the ApiQueryProvider component
51
+ */
52
+ export interface ApiQueryProviderProps extends ApiQueryProviderConfig {
53
+ /** React children */
54
+ children: ReactNode;
55
+ /** Optional existing QueryClient instance */
56
+ queryClient?: QueryClient;
57
+ }
58
+ /**
59
+ * Creates a configured QueryClient instance
60
+ *
61
+ * @example
62
+ * ```tsx
63
+ * // Create a custom query client
64
+ * const queryClient = createQueryClient({
65
+ * queries: {
66
+ * staleTime: 10 * 60 * 1000, // 10 minutes
67
+ * },
68
+ * });
69
+ * ```
70
+ */
71
+ export declare function createQueryClient(options?: ApiQueryProviderConfig['queryClientOptions']): QueryClient;
72
+ /**
73
+ * Provider component for TanStack Query
74
+ * Wraps your application with a configured QueryClient
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * // Basic usage
79
+ * function App() {
80
+ * return (
81
+ * <ApiQueryProvider>
82
+ * <ApiProvider apiClient={apiClient}>
83
+ * <YourApp />
84
+ * </ApiProvider>
85
+ * </ApiQueryProvider>
86
+ * );
87
+ * }
88
+ *
89
+ * // With custom configuration
90
+ * function App() {
91
+ * return (
92
+ * <ApiQueryProvider
93
+ * queryClientOptions={{
94
+ * queries: {
95
+ * staleTime: 10 * 60 * 1000, // 10 minutes
96
+ * refetchOnWindowFocus: true,
97
+ * },
98
+ * }}
99
+ * showDevtools={process.env.NODE_ENV === 'development'}
100
+ * devtoolsPosition="bottom-right"
101
+ * >
102
+ * <ApiProvider apiClient={apiClient}>
103
+ * <YourApp />
104
+ * </ApiProvider>
105
+ * </ApiQueryProvider>
106
+ * );
107
+ * }
108
+ *
109
+ * // With existing QueryClient
110
+ * const queryClient = createQueryClient();
111
+ *
112
+ * function App() {
113
+ * return (
114
+ * <ApiQueryProvider queryClient={queryClient}>
115
+ * <ApiProvider apiClient={apiClient}>
116
+ * <YourApp />
117
+ * </ApiProvider>
118
+ * </ApiQueryProvider>
119
+ * );
120
+ * }
121
+ * ```
122
+ */
123
+ export declare function ApiQueryProvider({ children, queryClient: existingQueryClient, queryClientOptions, showDevtools, devtoolsPosition, devtoolsInitialIsOpen, }: ApiQueryProviderProps): import("react/jsx-runtime").JSX.Element;
124
+ /**
125
+ * Combined provider that includes both ApiQueryProvider and can be used
126
+ * as a drop-in replacement when you want TanStack Query with your API client
127
+ *
128
+ * @example
129
+ * ```tsx
130
+ * import { CombinedApiQueryProvider, createApiClient } from '@pagamio/frontend-commons-lib';
131
+ *
132
+ * const apiClient = createApiClient({ ... });
133
+ *
134
+ * function App() {
135
+ * return (
136
+ * <CombinedApiQueryProvider
137
+ * apiClient={apiClient}
138
+ * showDevtools={true}
139
+ * >
140
+ * <YourApp />
141
+ * </CombinedApiQueryProvider>
142
+ * );
143
+ * }
144
+ * ```
145
+ */
146
+ export { ApiQueryProvider as TanStackQueryProvider };
@@ -0,0 +1,140 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @fileoverview TanStack Query Provider for the API client
4
+ * Provides a configured QueryClient with sensible defaults
5
+ */
6
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
7
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
8
+ import { useMemo } from 'react';
9
+ /**
10
+ * Default configuration for the QueryClient
11
+ * Matches the conservative caching strategy used in the SWR integration
12
+ */
13
+ export const DEFAULT_QUERY_CLIENT_OPTIONS = {
14
+ queries: {
15
+ /** Data is considered fresh for 5 minutes */
16
+ staleTime: 5 * 60 * 1000,
17
+ /** Garbage collection time - 10 minutes */
18
+ gcTime: 10 * 60 * 1000,
19
+ /** Don't refetch on window focus (matches SWR config) */
20
+ refetchOnWindowFocus: false,
21
+ /** Don't refetch on reconnect (matches SWR config) */
22
+ refetchOnReconnect: false,
23
+ /** Retry failed requests once */
24
+ retry: 1,
25
+ /** Retry delay */
26
+ retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
27
+ /** Don't refetch on mount if data exists */
28
+ refetchOnMount: false,
29
+ },
30
+ mutations: {
31
+ /** Retry failed mutations once */
32
+ retry: 1,
33
+ },
34
+ };
35
+ /**
36
+ * Creates a configured QueryClient instance
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // Create a custom query client
41
+ * const queryClient = createQueryClient({
42
+ * queries: {
43
+ * staleTime: 10 * 60 * 1000, // 10 minutes
44
+ * },
45
+ * });
46
+ * ```
47
+ */
48
+ export function createQueryClient(options) {
49
+ return new QueryClient({
50
+ defaultOptions: {
51
+ queries: {
52
+ ...DEFAULT_QUERY_CLIENT_OPTIONS.queries,
53
+ ...options?.queries,
54
+ },
55
+ mutations: {
56
+ ...DEFAULT_QUERY_CLIENT_OPTIONS.mutations,
57
+ ...options?.mutations,
58
+ },
59
+ },
60
+ });
61
+ }
62
+ /**
63
+ * Provider component for TanStack Query
64
+ * Wraps your application with a configured QueryClient
65
+ *
66
+ * @example
67
+ * ```tsx
68
+ * // Basic usage
69
+ * function App() {
70
+ * return (
71
+ * <ApiQueryProvider>
72
+ * <ApiProvider apiClient={apiClient}>
73
+ * <YourApp />
74
+ * </ApiProvider>
75
+ * </ApiQueryProvider>
76
+ * );
77
+ * }
78
+ *
79
+ * // With custom configuration
80
+ * function App() {
81
+ * return (
82
+ * <ApiQueryProvider
83
+ * queryClientOptions={{
84
+ * queries: {
85
+ * staleTime: 10 * 60 * 1000, // 10 minutes
86
+ * refetchOnWindowFocus: true,
87
+ * },
88
+ * }}
89
+ * showDevtools={process.env.NODE_ENV === 'development'}
90
+ * devtoolsPosition="bottom-right"
91
+ * >
92
+ * <ApiProvider apiClient={apiClient}>
93
+ * <YourApp />
94
+ * </ApiProvider>
95
+ * </ApiQueryProvider>
96
+ * );
97
+ * }
98
+ *
99
+ * // With existing QueryClient
100
+ * const queryClient = createQueryClient();
101
+ *
102
+ * function App() {
103
+ * return (
104
+ * <ApiQueryProvider queryClient={queryClient}>
105
+ * <ApiProvider apiClient={apiClient}>
106
+ * <YourApp />
107
+ * </ApiProvider>
108
+ * </ApiQueryProvider>
109
+ * );
110
+ * }
111
+ * ```
112
+ */
113
+ export function ApiQueryProvider({ children, queryClient: existingQueryClient, queryClientOptions, showDevtools = process.env.NODE_ENV === 'development', devtoolsPosition = 'bottom', devtoolsInitialIsOpen = false, }) {
114
+ // Create or use existing query client
115
+ const queryClient = useMemo(() => existingQueryClient ?? createQueryClient(queryClientOptions), [existingQueryClient, queryClientOptions]);
116
+ return (_jsxs(QueryClientProvider, { client: queryClient, children: [children, showDevtools && _jsx(ReactQueryDevtools, { initialIsOpen: devtoolsInitialIsOpen, position: devtoolsPosition })] }));
117
+ }
118
+ /**
119
+ * Combined provider that includes both ApiQueryProvider and can be used
120
+ * as a drop-in replacement when you want TanStack Query with your API client
121
+ *
122
+ * @example
123
+ * ```tsx
124
+ * import { CombinedApiQueryProvider, createApiClient } from '@pagamio/frontend-commons-lib';
125
+ *
126
+ * const apiClient = createApiClient({ ... });
127
+ *
128
+ * function App() {
129
+ * return (
130
+ * <CombinedApiQueryProvider
131
+ * apiClient={apiClient}
132
+ * showDevtools={true}
133
+ * >
134
+ * <YourApp />
135
+ * </CombinedApiQueryProvider>
136
+ * );
137
+ * }
138
+ * ```
139
+ */
140
+ export { ApiQueryProvider as TanStackQueryProvider };
@@ -1,4 +1,6 @@
1
1
  export * from './client';
2
2
  export * from './swr';
3
+ export * from './tanstackQuery';
4
+ export * from './TanstackQueryProvider';
3
5
  export * from './context';
4
6
  export * from './types';
package/lib/api/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './client';
2
2
  export * from './swr';
3
+ export * from './tanstackQuery';
4
+ export * from './TanstackQueryProvider';
3
5
  export * from './context';
4
6
  export * from './types';
@@ -0,0 +1,249 @@
1
+ /**
2
+ * @fileoverview TanStack Query integration for the API client
3
+ * Provides hooks for data fetching, mutations, and cache management
4
+ */
5
+ import { type InfiniteData, type QueryKey, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UseMutationOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query';
6
+ import type { ApiErrorResponse, RequestConfig, SpringBootResponse } from './types';
7
+ /**
8
+ * Extended request config for TanStack Query hooks
9
+ */
10
+ export interface TanStackRequestConfig extends RequestConfig {
11
+ /** HTTP method for the request */
12
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
13
+ }
14
+ /**
15
+ * Main TanStack Query hook that automatically inherits auth config
16
+ * @template TData - Type of the expected response data
17
+ * @template TError - Type of the error response (defaults to ApiErrorResponse)
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * function UsersList() {
22
+ * const { data, isLoading, error } = useApiQuery<User[]>({
23
+ * queryKey: ['users'],
24
+ * endpoint: '/users',
25
+ * });
26
+ *
27
+ * if (isLoading) return <div>Loading...</div>;
28
+ * if (error) return <div>Error: {error.message}</div>;
29
+ *
30
+ * return (
31
+ * <ul>
32
+ * {data?.map(user => <li key={user.id}>{user.name}</li>)}
33
+ * </ul>
34
+ * );
35
+ * }
36
+ * ```
37
+ */
38
+ export declare function useApiQuery<TData = unknown, TError = ApiErrorResponse>(options: {
39
+ /** Unique query key for caching */
40
+ queryKey: QueryKey;
41
+ /** API endpoint to fetch */
42
+ endpoint: string;
43
+ /** Request configuration */
44
+ requestConfig?: TanStackRequestConfig;
45
+ } & Omit<UseQueryOptions<TData, TError, TData, QueryKey>, 'queryKey' | 'queryFn'>): UseQueryResult<TData, TError>;
46
+ /**
47
+ * Paginated TanStack Query hook for Spring Boot style responses
48
+ * @template TItem - Type of items in the paginated response
49
+ * @template TError - Type of the error response
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * function PaginatedUsers() {
54
+ * const { data, isLoading } = usePaginatedApiQuery<User>({
55
+ * queryKey: ['users', { page: 0, size: 10 }],
56
+ * endpoint: '/users?page=0&size=10',
57
+ * });
58
+ *
59
+ * return (
60
+ * <div>
61
+ * {data?.content.map(user => <div key={user.id}>{user.name}</div>)}
62
+ * <p>Total: {data?.totalElements}</p>
63
+ * </div>
64
+ * );
65
+ * }
66
+ * ```
67
+ */
68
+ export declare function usePaginatedApiQuery<TItem, TError = ApiErrorResponse>(options: {
69
+ queryKey: QueryKey;
70
+ endpoint: string;
71
+ requestConfig?: TanStackRequestConfig;
72
+ } & Omit<UseQueryOptions<SpringBootResponse<TItem>, TError, SpringBootResponse<TItem>, QueryKey>, 'queryKey' | 'queryFn'>): UseQueryResult<SpringBootResponse<TItem>, TError>;
73
+ /**
74
+ * Infinite query hook for infinite scrolling with Spring Boot pagination
75
+ * @template TItem - Type of items in the paginated response
76
+ * @template TError - Type of the error response
77
+ *
78
+ * @example
79
+ * ```tsx
80
+ * function InfiniteUsersList() {
81
+ * const {
82
+ * data,
83
+ * fetchNextPage,
84
+ * hasNextPage,
85
+ * isFetchingNextPage,
86
+ * } = useInfiniteApiQuery<User>({
87
+ * queryKey: ['users', 'infinite'],
88
+ * endpoint: '/users',
89
+ * pageSize: 20,
90
+ * });
91
+ *
92
+ * return (
93
+ * <div>
94
+ * {data?.pages.flatMap(page => page.content).map(user => (
95
+ * <div key={user.id}>{user.name}</div>
96
+ * ))}
97
+ * {hasNextPage && (
98
+ * <button onClick={() => fetchNextPage()} disabled={isFetchingNextPage}>
99
+ * {isFetchingNextPage ? 'Loading...' : 'Load More'}
100
+ * </button>
101
+ * )}
102
+ * </div>
103
+ * );
104
+ * }
105
+ * ```
106
+ */
107
+ export declare function useInfiniteApiQuery<TItem, TError = ApiErrorResponse>(options: {
108
+ queryKey: QueryKey;
109
+ /** Base endpoint (page params will be appended) */
110
+ endpoint: string;
111
+ /** Number of items per page */
112
+ pageSize?: number;
113
+ /** Parameter name for page number (default: 'page') */
114
+ pageParam?: string;
115
+ /** Parameter name for page size (default: 'size') */
116
+ sizeParam?: string;
117
+ requestConfig?: TanStackRequestConfig;
118
+ } & Omit<UseInfiniteQueryOptions<SpringBootResponse<TItem>, TError, InfiniteData<SpringBootResponse<TItem>>, QueryKey>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'getPreviousPageParam' | 'initialPageParam'>): UseInfiniteQueryResult<InfiniteData<SpringBootResponse<TItem>>, TError>;
119
+ /**
120
+ * Mutation types for the useApiQueryMutation hook
121
+ */
122
+ export type MutationType = 'POST' | 'PUT' | 'PATCH' | 'DELETE';
123
+ /**
124
+ * Variables passed to mutation function
125
+ */
126
+ export interface MutationVariables<TData = unknown> {
127
+ /** API endpoint */
128
+ endpoint: string;
129
+ /** Request body data (not needed for DELETE) */
130
+ data?: TData;
131
+ /** Additional request config */
132
+ config?: TanStackRequestConfig;
133
+ }
134
+ /**
135
+ * Mutation hook for POST, PUT, PATCH, DELETE operations
136
+ * @template TData - Type of the response data
137
+ * @template TVariables - Type of the mutation variables
138
+ * @template TError - Type of the error response
139
+ *
140
+ * @example
141
+ * ```tsx
142
+ * function CreateUserForm() {
143
+ * const queryClient = useQueryClient();
144
+ * const { mutate, isPending } = useApiQueryMutation<User, CreateUserDto>({
145
+ * method: 'POST',
146
+ * onSuccess: () => {
147
+ * queryClient.invalidateQueries({ queryKey: ['users'] });
148
+ * },
149
+ * });
150
+ *
151
+ * const handleSubmit = (data: CreateUserDto) => {
152
+ * mutate({ endpoint: '/users', data });
153
+ * };
154
+ *
155
+ * return (
156
+ * <form onSubmit={handleSubmit}>
157
+ * // ...form fields
158
+ * <button type="submit" disabled={isPending}>
159
+ * {isPending ? 'Creating...' : 'Create User'}
160
+ * </button>
161
+ * </form>
162
+ * );
163
+ * }
164
+ * ```
165
+ */
166
+ export declare function useApiQueryMutation<TData = unknown, TVariables = unknown, TError = ApiErrorResponse>(options: {
167
+ /** HTTP method for the mutation */
168
+ method: MutationType;
169
+ /** Query keys to invalidate on success */
170
+ invalidateKeys?: QueryKey[];
171
+ } & Omit<UseMutationOptions<TData, TError, MutationVariables<TVariables>>, 'mutationFn'>): UseMutationResult<TData, TError, MutationVariables<TVariables>>;
172
+ /**
173
+ * Convenience hook for POST mutations
174
+ */
175
+ export declare function useApiPostMutation<TData = unknown, TVariables = unknown, TError = ApiErrorResponse>(options?: Omit<Parameters<typeof useApiQueryMutation<TData, TVariables, TError>>[0], 'method'>): UseMutationResult<TData, TError, MutationVariables<TVariables>>;
176
+ /**
177
+ * Convenience hook for PUT mutations
178
+ */
179
+ export declare function useApiPutMutation<TData = unknown, TVariables = unknown, TError = ApiErrorResponse>(options?: Omit<Parameters<typeof useApiQueryMutation<TData, TVariables, TError>>[0], 'method'>): UseMutationResult<TData, TError, MutationVariables<TVariables>>;
180
+ /**
181
+ * Convenience hook for PATCH mutations
182
+ */
183
+ export declare function useApiPatchMutation<TData = unknown, TVariables = unknown, TError = ApiErrorResponse>(options?: Omit<Parameters<typeof useApiQueryMutation<TData, TVariables, TError>>[0], 'method'>): UseMutationResult<TData, TError, MutationVariables<TVariables>>;
184
+ /**
185
+ * Convenience hook for DELETE mutations
186
+ */
187
+ export declare function useApiDeleteMutation<TData = unknown, TError = ApiErrorResponse>(options?: Omit<Parameters<typeof useApiQueryMutation<TData, never, TError>>[0], 'method'>): UseMutationResult<TData, TError, MutationVariables<never>>;
188
+ /**
189
+ * Hook for prefetching data
190
+ *
191
+ * @example
192
+ * ```tsx
193
+ * function UserLink({ userId }: { userId: string }) {
194
+ * const prefetch = useApiPrefetch();
195
+ *
196
+ * return (
197
+ * <Link
198
+ * to={`/users/${userId}`}
199
+ * onMouseEnter={() => prefetch({
200
+ * queryKey: ['user', userId],
201
+ * endpoint: `/users/${userId}`,
202
+ * })}
203
+ * >
204
+ * View User
205
+ * </Link>
206
+ * );
207
+ * }
208
+ * ```
209
+ */
210
+ export declare function useApiPrefetch(): <TData = unknown>(options: {
211
+ queryKey: QueryKey;
212
+ endpoint: string;
213
+ requestConfig?: TanStackRequestConfig;
214
+ staleTime?: number;
215
+ }) => Promise<void>;
216
+ /**
217
+ * Hook for accessing the query client with typed helpers
218
+ *
219
+ * @example
220
+ * ```tsx
221
+ * function RefreshButton() {
222
+ * const { invalidate, setData, removeQueries } = useApiQueryClient();
223
+ *
224
+ * return (
225
+ * <button onClick={() => invalidate(['users'])}>
226
+ * Refresh Users
227
+ * </button>
228
+ * );
229
+ * }
230
+ * ```
231
+ */
232
+ export declare function useApiQueryClient(): {
233
+ /** The underlying query client */
234
+ queryClient: import("@tanstack/react-query").QueryClient;
235
+ /** Invalidate queries by key */
236
+ invalidate: (queryKey: QueryKey) => Promise<void>;
237
+ /** Set query data directly */
238
+ setData: <TData>(queryKey: QueryKey, data: TData) => unknown;
239
+ /** Get cached query data */
240
+ getData: <TData>(queryKey: QueryKey) => TData | undefined;
241
+ /** Remove queries from cache */
242
+ removeQueries: (queryKey: QueryKey) => void;
243
+ /** Cancel ongoing queries */
244
+ cancelQueries: (queryKey: QueryKey) => Promise<void>;
245
+ /** Refetch queries */
246
+ refetch: (queryKey: QueryKey) => Promise<void>;
247
+ /** Reset queries to initial state */
248
+ resetQueries: (queryKey: QueryKey) => Promise<void>;
249
+ };