izen-react-starter 2.1.0 → 2.2.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/{MIMHJGAX-BUG-Z2YP.js → MIMHJGAX-D6lE7oii.js} +1 -1
- package/dist/{Q7LWSL4U-CGtIukTY.js → Q7LWSL4U-v0l_umPn.js} +2 -2
- package/dist/{VLTTJS3N-DuHfwBTL.js → VLTTJS3N-BqFxuU2V.js} +2 -2
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/toast.d.ts +1 -1
- package/dist/{index-BNRXa5M-.js → index-BVgl5TkI.js} +51909 -51100
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/api/axios/axios.d.ts +44 -0
- package/dist/lib/api/axios/axios.d.ts.map +1 -0
- package/dist/lib/api/axios/delete-item.d.ts +39 -0
- package/dist/lib/api/axios/delete-item.d.ts.map +1 -0
- package/dist/lib/api/axios/hooks/useAxiosAuth.d.ts +61 -0
- package/dist/lib/api/axios/hooks/useAxiosAuth.d.ts.map +1 -0
- package/dist/lib/api/axios/hooks/useAxiosHeadersUrl.d.ts +35 -0
- package/dist/lib/api/axios/hooks/useAxiosHeadersUrl.d.ts.map +1 -0
- package/dist/lib/api/axios/hooks/useFetchSingleAxios.d.ts +61 -0
- package/dist/lib/api/axios/hooks/useFetchSingleAxios.d.ts.map +1 -0
- package/dist/lib/api/axios/index.d.ts +13 -0
- package/dist/lib/api/axios/index.d.ts.map +1 -0
- package/dist/lib/api/axios/useRefreshToken.d.ts +38 -0
- package/dist/lib/api/axios/useRefreshToken.d.ts.map +1 -0
- package/dist/lib/api/index.d.ts +14 -0
- package/dist/lib/api/index.d.ts.map +1 -0
- package/dist/lib/api/mutation/file-uploading.d.ts +88 -0
- package/dist/lib/api/mutation/file-uploading.d.ts.map +1 -0
- package/dist/lib/api/mutation/index.d.ts +5 -0
- package/dist/lib/api/mutation/index.d.ts.map +1 -0
- package/dist/lib/api/mutation/send-email.d.ts +74 -0
- package/dist/lib/api/mutation/send-email.d.ts.map +1 -0
- package/dist/lib/api/queries/generic.d.ts +102 -0
- package/dist/lib/api/queries/generic.d.ts.map +1 -0
- package/dist/lib/api/queries/index.d.ts +3 -0
- package/dist/lib/api/queries/index.d.ts.map +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/react-starter.js +170 -159
- package/dist/react-starter.umd.cjs +147 -147
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export type { FileUploadButtonProps, DatePickerProps, TimeInputProps, TextInputP
|
|
|
17
17
|
export { LayoutProvider, useLayout } from './contexts/LayoutContext';
|
|
18
18
|
export type { LayoutContextType } from './contexts/LayoutContext';
|
|
19
19
|
export { useIsMobile } from './hooks';
|
|
20
|
-
export { cn, capitalize, convertToHourMinuteString, formatErrorToList, formatDate, appendFormData, debounce, throttle, handleEditCache, handleSingleEditCache } from './lib';
|
|
21
|
-
export type { CacheEditOptions } from './lib';
|
|
20
|
+
export { cn, capitalize, convertToHourMinuteString, formatErrorToList, formatDate, appendFormData, debounce, throttle, handleEditCache, handleSingleEditCache, createAxiosInstance, createAuthAxiosInstance, onDelete, useRefreshToken, useAxiosAuth, useAxiosHeadersUrl, useFetchSingleAxios, useGet, useGetSingle, useUploadFile, useSendEmail, } from './lib';
|
|
21
|
+
export type { CacheEditOptions, AxiosConfig, DeleteOptions, RefreshTokenResponse, UseRefreshTokenOptions, UseAxiosAuthOptions, AxiosHeadersConfig, UseFetchSingleAxiosOptions, UseFetchSingleAxiosReturn, UseGetOptions, FileUploadResponse, FileUploadParams, UseUploadFileOptions, SendEmailResponse, SendEmailParams, UseSendEmailOptions, } from './lib';
|
|
22
22
|
export { CommonActions, userCan, useAccessControl, AccessControlWrapper, withAccessControl, UpdateAccessControlWrapper, RBACProvider, useRBAC } from './rbac';
|
|
23
23
|
export type { Action, Resource, Role, RoleLabel, Rule, RoleRules, Rules, RBACConfig, UseAccessControlReturn, AccessControlWrapperProps, WithAccessControlProps, UpdateAccessControlWrapperProps, RBACProviderProps, RBACContextType } from './rbac';
|
|
24
24
|
export { AuthProvider, useAuth, ModalProvider, useModal, OverlayProvider, useOverlay, ThemeProvider, useTheme, AppProvider, queryClient } from './providers';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;AAGrB,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AAGpC,OAAO,EACL,OAAO,EACP,YAAY,EACZ,OAAO,IAAI,UAAU,EACrB,aAAa,EACd,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,IAAI,eAAe,EAC/B,mBAAmB,IAAI,kBAAkB,EAC1C,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACT,MAAM,IAAI,UAAU,EACpB,cAAc,EACd,WAAW,EACX,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,SAAS,EACT,cAAc,EACd,WAAW,IAAI,eAAe,EAC9B,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,EACL,EAAE,EACF,UAAU,EACV,yBAAyB,EACzB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { default as axios, AxiosInstance, CreateAxiosDefaults } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for creating axios instances
|
|
4
|
+
*/
|
|
5
|
+
export interface AxiosConfig extends CreateAxiosDefaults {
|
|
6
|
+
baseURL: string;
|
|
7
|
+
withCredentials?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a basic axios instance
|
|
11
|
+
*
|
|
12
|
+
* @param config - Axios configuration
|
|
13
|
+
* @returns Configured axios instance
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const api = createAxiosInstance({
|
|
18
|
+
* baseURL: 'https://api.example.com',
|
|
19
|
+
* headers: {
|
|
20
|
+
* 'Content-Type': 'application/json'
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function createAxiosInstance(config: AxiosConfig): AxiosInstance;
|
|
26
|
+
/**
|
|
27
|
+
* Create an authenticated axios instance with cancel token
|
|
28
|
+
*
|
|
29
|
+
* @param config - Axios configuration
|
|
30
|
+
* @returns Configured axios instance with cancel token
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const authApi = createAuthAxiosInstance({
|
|
35
|
+
* baseURL: 'https://api.example.com',
|
|
36
|
+
* headers: {
|
|
37
|
+
* 'Accept': 'application/json'
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function createAuthAxiosInstance(config: AxiosConfig): AxiosInstance;
|
|
43
|
+
export default axios;
|
|
44
|
+
//# sourceMappingURL=axios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/axios/axios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,mBAAmB;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAQtE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAY1E;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface DeleteOptions {
|
|
2
|
+
url: string;
|
|
3
|
+
item: any;
|
|
4
|
+
axios: any;
|
|
5
|
+
toast?: any;
|
|
6
|
+
onSuccess?: (item: any) => void;
|
|
7
|
+
onError?: (error: any) => void;
|
|
8
|
+
onFinally?: () => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generic delete handler with toast notifications
|
|
12
|
+
*
|
|
13
|
+
* @param options - Delete operation options
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { onDelete } from 'izen-react-starter';
|
|
18
|
+
* import { useAxiosAuth } from './hooks/useAxiosAuth';
|
|
19
|
+
* import { toast } from 'sonner';
|
|
20
|
+
*
|
|
21
|
+
* function MyComponent() {
|
|
22
|
+
* const axios = useAxiosAuth();
|
|
23
|
+
*
|
|
24
|
+
* const handleDelete = (item) => {
|
|
25
|
+
* onDelete({
|
|
26
|
+
* url: `/api/items/${item.id}`,
|
|
27
|
+
* item,
|
|
28
|
+
* axios,
|
|
29
|
+
* toast: (options) => toast(options.title, { description: options.description }),
|
|
30
|
+
* onSuccess: (deletedItem) => {
|
|
31
|
+
* console.log('Item deleted:', deletedItem);
|
|
32
|
+
* }
|
|
33
|
+
* });
|
|
34
|
+
* };
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const onDelete: ({ url, item, axios, toast, onSuccess, onError, onFinally, }: DeleteOptions) => void;
|
|
39
|
+
//# sourceMappingURL=delete-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-item.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/axios/delete-item.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,QAAQ,GAAI,6DAQtB,aAAa,SA4Df,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { RefreshTokenResponse } from '../useRefreshToken';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
export interface UseAxiosAuthOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The axios instance to configure with auth interceptors
|
|
6
|
+
*/
|
|
7
|
+
axiosInstance: AxiosInstance;
|
|
8
|
+
/**
|
|
9
|
+
* URL for token refresh endpoint
|
|
10
|
+
*/
|
|
11
|
+
refreshUrl?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Custom headers to add to requests
|
|
14
|
+
*/
|
|
15
|
+
customHeaders?: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Callback when token refresh fails
|
|
18
|
+
*/
|
|
19
|
+
onRefreshFail?: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Callback when token is refreshed successfully
|
|
22
|
+
*/
|
|
23
|
+
onRefreshSuccess?: (tokens: RefreshTokenResponse) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook to add authentication interceptors to axios instance
|
|
27
|
+
* Automatically adds Authorization header and handles token refresh
|
|
28
|
+
*
|
|
29
|
+
* @param options - Configuration options
|
|
30
|
+
* @returns Axios instance with auth interceptors
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* import { createAuthAxiosInstance, useAxiosAuth } from 'izen-react-starter';
|
|
35
|
+
*
|
|
36
|
+
* const axiosAuth = createAuthAxiosInstance({
|
|
37
|
+
* baseURL: 'https://api.example.com'
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* function MyComponent() {
|
|
41
|
+
* const axios = useAxiosAuth({
|
|
42
|
+
* axiosInstance: axiosAuth,
|
|
43
|
+
* refreshUrl: '/auth/refresh',
|
|
44
|
+
* customHeaders: {
|
|
45
|
+
* 'X-Custom-Header': 'value'
|
|
46
|
+
* },
|
|
47
|
+
* onRefreshFail: () => {
|
|
48
|
+
* window.location.href = '/login';
|
|
49
|
+
* }
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* const fetchData = async () => {
|
|
53
|
+
* const response = await axios.get('/api/data');
|
|
54
|
+
* return response.data;
|
|
55
|
+
* };
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare const useAxiosAuth: (options: UseAxiosAuthOptions) => AxiosInstance;
|
|
60
|
+
export default useAxiosAuth;
|
|
61
|
+
//# sourceMappingURL=useAxiosAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAxiosAuth.d.ts","sourceRoot":"","sources":["../../../../../src/lib/api/axios/hooks/useAxiosAuth.ts"],"names":[],"mappings":"AACA,OAAwB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAAc,aAAa,EAA8B,MAAM,OAAO,CAAC;AAE9E,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,QAAA,MAAM,YAAY,GAAI,SAAS,mBAAmB,KAAG,aAwFpD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface AxiosHeadersConfig {
|
|
2
|
+
baseURL: string;
|
|
3
|
+
multipartUrls?: string[];
|
|
4
|
+
customHeaders?: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Generate axios headers and URL configuration based on endpoint
|
|
8
|
+
*
|
|
9
|
+
* @param url - API endpoint path
|
|
10
|
+
* @param config - Configuration options
|
|
11
|
+
* @returns Tuple of [fullUrl, headersConfig]
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { useAxiosHeadersUrl } from 'izen-react-starter';
|
|
16
|
+
*
|
|
17
|
+
* function MyComponent() {
|
|
18
|
+
* const [apiUrl, headers] = useAxiosHeadersUrl('/users', {
|
|
19
|
+
* baseURL: 'https://api.example.com',
|
|
20
|
+
* multipartUrls: ['/upload', '/files'],
|
|
21
|
+
* customHeaders: {
|
|
22
|
+
* 'X-Custom': 'value'
|
|
23
|
+
* }
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Use with axios
|
|
27
|
+
* axios.get(apiUrl, headers);
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare const useAxiosHeadersUrl: (url: string, config: AxiosHeadersConfig) => [string, {
|
|
32
|
+
headers: Record<string, string>;
|
|
33
|
+
}];
|
|
34
|
+
export default useAxiosHeadersUrl;
|
|
35
|
+
//# sourceMappingURL=useAxiosHeadersUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAxiosHeadersUrl.d.ts","sourceRoot":"","sources":["../../../../../src/lib/api/axios/hooks/useAxiosHeadersUrl.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,kBAAkB,GACtB,KAAK,MAAM,EACX,QAAQ,kBAAkB,KACzB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAyB9C,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export interface UseFetchSingleAxiosOptions {
|
|
3
|
+
/**
|
|
4
|
+
* API endpoint URL
|
|
5
|
+
*/
|
|
6
|
+
url: string;
|
|
7
|
+
/**
|
|
8
|
+
* HTTP method to use
|
|
9
|
+
*/
|
|
10
|
+
method: 'get' | 'post' | 'patch' | 'delete';
|
|
11
|
+
/**
|
|
12
|
+
* Base URL for API
|
|
13
|
+
*/
|
|
14
|
+
baseURL: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional axios instance to use (defaults to axios)
|
|
17
|
+
*/
|
|
18
|
+
axiosInstance?: AxiosInstance;
|
|
19
|
+
/**
|
|
20
|
+
* Optional authorization token
|
|
21
|
+
*/
|
|
22
|
+
token?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Custom headers
|
|
25
|
+
*/
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface UseFetchSingleAxiosReturn<T = any> {
|
|
29
|
+
data: T;
|
|
30
|
+
loading: boolean;
|
|
31
|
+
error: boolean;
|
|
32
|
+
errorMessage: string | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Hook to fetch data from a single endpoint with cancel token support
|
|
36
|
+
*
|
|
37
|
+
* @param options - Fetch configuration
|
|
38
|
+
* @returns Object with data, loading, error, and errorMessage
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* import { useFetchSingleAxios } from 'izen-react-starter';
|
|
43
|
+
*
|
|
44
|
+
* function MyComponent() {
|
|
45
|
+
* const { data, loading, error, errorMessage } = useFetchSingleAxios({
|
|
46
|
+
* url: '/api/users/1',
|
|
47
|
+
* method: 'get',
|
|
48
|
+
* baseURL: 'https://api.example.com',
|
|
49
|
+
* token: 'your-token-here'
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* if (loading) return <div>Loading...</div>;
|
|
53
|
+
* if (error) return <div>Error: {errorMessage}</div>;
|
|
54
|
+
*
|
|
55
|
+
* return <div>Data: {JSON.stringify(data)}</div>;
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare const useFetchSingleAxios: <T = any>(options: UseFetchSingleAxiosOptions) => UseFetchSingleAxiosReturn<T>;
|
|
60
|
+
export default useFetchSingleAxios;
|
|
61
|
+
//# sourceMappingURL=useFetchSingleAxios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchSingleAxios.d.ts","sourceRoot":"","sources":["../../../../../src/lib/api/axios/hooks/useFetchSingleAxios.ts"],"names":[],"mappings":"AACA,OAAc,EAA4B,aAAa,EAAE,MAAM,OAAO,CAAC;AAEvE,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,yBAAyB,CAAC,CAAC,GAAG,GAAG;IAChD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,mBAAmB,GAAI,CAAC,GAAG,GAAG,EAClC,SAAS,0BAA0B,KAClC,yBAAyB,CAAC,CAAC,CAkF7B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { createAxiosInstance, createAuthAxiosInstance, } from './axios';
|
|
2
|
+
export type { AxiosConfig } from './axios';
|
|
3
|
+
export { onDelete } from './delete-item';
|
|
4
|
+
export type { DeleteOptions } from './delete-item';
|
|
5
|
+
export { default as useRefreshToken } from './useRefreshToken';
|
|
6
|
+
export type { RefreshTokenResponse, UseRefreshTokenOptions } from './useRefreshToken';
|
|
7
|
+
export { default as useAxiosAuth } from './hooks/useAxiosAuth';
|
|
8
|
+
export type { UseAxiosAuthOptions } from './hooks/useAxiosAuth';
|
|
9
|
+
export { default as useAxiosHeadersUrl } from './hooks/useAxiosHeadersUrl';
|
|
10
|
+
export type { AxiosHeadersConfig } from './hooks/useAxiosHeadersUrl';
|
|
11
|
+
export { default as useFetchSingleAxios } from './hooks/useFetchSingleAxios';
|
|
12
|
+
export type { UseFetchSingleAxiosOptions, UseFetchSingleAxiosReturn } from './hooks/useFetchSingleAxios';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/axios/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAGtF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,YAAY,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface RefreshTokenResponse {
|
|
2
|
+
access_token: string;
|
|
3
|
+
refresh_token?: string;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export interface UseRefreshTokenOptions {
|
|
7
|
+
refreshUrl?: string;
|
|
8
|
+
onSuccess?: (tokens: RefreshTokenResponse) => void;
|
|
9
|
+
onError?: (error: any) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hook to refresh authentication tokens
|
|
13
|
+
*
|
|
14
|
+
* @param options - Configuration options
|
|
15
|
+
* @returns Function to refresh tokens
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { useRefreshToken } from 'izen-react-starter';
|
|
20
|
+
*
|
|
21
|
+
* function MyComponent() {
|
|
22
|
+
* const refresh = useRefreshToken({
|
|
23
|
+
* refreshUrl: '/auth/refresh',
|
|
24
|
+
* onSuccess: (tokens) => console.log('Tokens refreshed'),
|
|
25
|
+
* onError: (error) => console.error('Refresh failed', error)
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* const handleRefresh = async () => {
|
|
29
|
+
* const newTokens = await refresh();
|
|
30
|
+
* if (newTokens) {
|
|
31
|
+
* console.log('Got new tokens:', newTokens);
|
|
32
|
+
* }
|
|
33
|
+
* };
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export default function useRefreshToken(options?: UseRefreshTokenOptions): () => Promise<null | RefreshTokenResponse>;
|
|
38
|
+
//# sourceMappingURL=useRefreshToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRefreshToken.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/axios/useRefreshToken.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,OAAO,GAAE,sBAA2B,GACnC,MAAM,OAAO,CAAC,IAAI,GAAG,oBAAoB,CAAC,CA0C5C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API utilities for data fetching, mutations, and axios configuration
|
|
3
|
+
*
|
|
4
|
+
* Includes:
|
|
5
|
+
* - Axios configuration and instances
|
|
6
|
+
* - Authentication hooks and interceptors
|
|
7
|
+
* - Generic queries for fetching data
|
|
8
|
+
* - Mutation hooks for file uploads and emails
|
|
9
|
+
* - Token refresh handling
|
|
10
|
+
*/
|
|
11
|
+
export * from './axios';
|
|
12
|
+
export * from './queries';
|
|
13
|
+
export * from './mutation';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC;AAG1B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
export interface FileUploadResponse {
|
|
4
|
+
data: any;
|
|
5
|
+
message: string;
|
|
6
|
+
status?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface FileUploadParams {
|
|
9
|
+
file: File;
|
|
10
|
+
modelId: number | string;
|
|
11
|
+
model: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export interface UseUploadFileOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Cache key for invalidation
|
|
17
|
+
*/
|
|
18
|
+
queryKey?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Callback on success
|
|
21
|
+
*/
|
|
22
|
+
onSuccess?: (response: FileUploadResponse) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Callback on error
|
|
25
|
+
*/
|
|
26
|
+
onError?: (error: Error) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Callback on settle (success or error)
|
|
29
|
+
*/
|
|
30
|
+
onSettled?: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Custom API endpoint
|
|
33
|
+
*/
|
|
34
|
+
endpoint?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Additional form data fields
|
|
37
|
+
*/
|
|
38
|
+
additionalData?: Record<string, any>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Hook to upload files with automatic cache update
|
|
42
|
+
*
|
|
43
|
+
* @param axios - Configured axios instance
|
|
44
|
+
* @param options - Upload configuration options
|
|
45
|
+
* @returns Mutation result object
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```tsx
|
|
49
|
+
* import { useUploadFile } from 'izen-react-starter';
|
|
50
|
+
* import useAxiosAuth from './hooks/useAxiosAuth';
|
|
51
|
+
*
|
|
52
|
+
* function FileUploader() {
|
|
53
|
+
* const axios = useAxiosAuth({ axiosInstance: myAxios });
|
|
54
|
+
* const uploadMutation = useUploadFile(axios, {
|
|
55
|
+
* queryKey: 'files',
|
|
56
|
+
* endpoint: '/shared/attachments',
|
|
57
|
+
* onSuccess: (response) => {
|
|
58
|
+
* console.log('File uploaded:', response);
|
|
59
|
+
* }
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* const handleUpload = (file, modelId) => {
|
|
63
|
+
* uploadMutation.mutate({
|
|
64
|
+
* file,
|
|
65
|
+
* modelId,
|
|
66
|
+
* model: 'users'
|
|
67
|
+
* });
|
|
68
|
+
* };
|
|
69
|
+
*
|
|
70
|
+
* return (
|
|
71
|
+
* <div>
|
|
72
|
+
* {uploadMutation.isPending && <div>Uploading...</div>}
|
|
73
|
+
* {uploadMutation.isError && <div>Error: {uploadMutation.error?.message}</div>}
|
|
74
|
+
* <input
|
|
75
|
+
* type="file"
|
|
76
|
+
* onChange={(e) => {
|
|
77
|
+
* const file = e.target.files?.[0];
|
|
78
|
+
* if (file) handleUpload(file, 1);
|
|
79
|
+
* }}
|
|
80
|
+
* />
|
|
81
|
+
* </div>
|
|
82
|
+
* );
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare const useUploadFile: (axios: AxiosInstance, options?: UseUploadFileOptions) => UseMutationResult<FileUploadResponse, Error, FileUploadParams>;
|
|
87
|
+
export { useUploadFile };
|
|
88
|
+
//# sourceMappingURL=file-uploading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-uploading.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/mutation/file-uploading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAkB,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,QAAA,MAAM,aAAa,GACjB,OAAO,aAAa,EACpB,UAAS,oBAAyB,KACjC,iBAAiB,CAAC,kBAAkB,EAAE,KAAK,EAAE,gBAAgB,CAmD/D,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useUploadFile } from './file-uploading';
|
|
2
|
+
export type { FileUploadResponse, FileUploadParams, UseUploadFileOptions } from './file-uploading';
|
|
3
|
+
export { useSendEmail } from './send-email';
|
|
4
|
+
export type { SendEmailResponse, SendEmailParams, UseSendEmailOptions } from './send-email';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/mutation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGnG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
export interface SendEmailResponse {
|
|
4
|
+
success: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface SendEmailParams {
|
|
9
|
+
to: string | string[];
|
|
10
|
+
subject: string;
|
|
11
|
+
body: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export interface UseSendEmailOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Custom API endpoint
|
|
17
|
+
*/
|
|
18
|
+
endpoint?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Callback on success
|
|
21
|
+
*/
|
|
22
|
+
onSuccess?: (response: SendEmailResponse) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Callback on error
|
|
25
|
+
*/
|
|
26
|
+
onError?: (error: Error) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Callback on settle (success or error)
|
|
29
|
+
*/
|
|
30
|
+
onSettled?: () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Hook to send emails through API
|
|
34
|
+
*
|
|
35
|
+
* @param axios - Configured axios instance
|
|
36
|
+
* @param options - Email configuration options
|
|
37
|
+
* @returns Mutation result object
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* import { useSendEmail } from 'izen-react-starter';
|
|
42
|
+
* import useAxiosAuth from './hooks/useAxiosAuth';
|
|
43
|
+
*
|
|
44
|
+
* function EmailSender() {
|
|
45
|
+
* const axios = useAxiosAuth({ axiosInstance: myAxios });
|
|
46
|
+
* const sendEmail = useSendEmail(axios, {
|
|
47
|
+
* endpoint: '/email/send',
|
|
48
|
+
* onSuccess: (response) => {
|
|
49
|
+
* console.log('Email sent successfully');
|
|
50
|
+
* }
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* const handleSendEmail = () => {
|
|
54
|
+
* sendEmail.mutate({
|
|
55
|
+
* to: 'user@example.com',
|
|
56
|
+
* subject: 'Hello',
|
|
57
|
+
* body: 'This is a test email'
|
|
58
|
+
* });
|
|
59
|
+
* };
|
|
60
|
+
*
|
|
61
|
+
* return (
|
|
62
|
+
* <div>
|
|
63
|
+
* {sendEmail.isPending && <div>Sending...</div>}
|
|
64
|
+
* {sendEmail.isError && <div>Error: {sendEmail.error?.message}</div>}
|
|
65
|
+
* {sendEmail.isSuccess && <div>Email sent!</div>}
|
|
66
|
+
* <button onClick={handleSendEmail}>Send Email</button>
|
|
67
|
+
* </div>
|
|
68
|
+
* );
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare const useSendEmail: (axios: AxiosInstance, options?: UseSendEmailOptions) => UseMutationResult<SendEmailResponse, Error, SendEmailParams>;
|
|
73
|
+
export { useSendEmail };
|
|
74
|
+
//# sourceMappingURL=send-email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-email.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/mutation/send-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAClD;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,QAAA,MAAM,YAAY,GAChB,OAAO,aAAa,EACpB,UAAS,mBAAwB,KAChC,iBAAiB,CAAC,iBAAiB,EAAE,KAAK,EAAE,eAAe,CAqB7D,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
export interface UseGetOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Cache key for the query
|
|
6
|
+
*/
|
|
7
|
+
queryKey?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Query parameters
|
|
10
|
+
*/
|
|
11
|
+
params?: Record<string, any>;
|
|
12
|
+
/**
|
|
13
|
+
* Override URL (if different from key)
|
|
14
|
+
*/
|
|
15
|
+
url?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Time in milliseconds until data is considered stale
|
|
18
|
+
*/
|
|
19
|
+
staleTime?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Enable refetch on window focus
|
|
22
|
+
*/
|
|
23
|
+
refetchOnWindowFocus?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Enable refetch on mount
|
|
26
|
+
*/
|
|
27
|
+
refetchOnMount?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Enable refetch on reconnect
|
|
30
|
+
*/
|
|
31
|
+
refetchOnReconnect?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Enable the query (useful for conditional queries)
|
|
34
|
+
*/
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generic hook to fetch multiple items
|
|
39
|
+
*
|
|
40
|
+
* @param axios - Configured axios instance
|
|
41
|
+
* @param key - Query key / API endpoint
|
|
42
|
+
* @param options - Query configuration options
|
|
43
|
+
* @returns React Query result object
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { useGet } from 'izen-react-starter';
|
|
48
|
+
* import useAxiosAuth from './hooks/useAxiosAuth';
|
|
49
|
+
*
|
|
50
|
+
* function UsersList() {
|
|
51
|
+
* const axios = useAxiosAuth({ axiosInstance: myAxios });
|
|
52
|
+
* const { data, isLoading, error } = useGet(axios, '/users', {
|
|
53
|
+
* queryKey: 'users',
|
|
54
|
+
* params: { page: 1, limit: 10 }
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
58
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
59
|
+
*
|
|
60
|
+
* return (
|
|
61
|
+
* <ul>
|
|
62
|
+
* {data?.map(user => (
|
|
63
|
+
* <li key={user.id}>{user.name}</li>
|
|
64
|
+
* ))}
|
|
65
|
+
* </ul>
|
|
66
|
+
* );
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare const useGet: <T = any>(axios: AxiosInstance, key: string, options?: UseGetOptions) => UseQueryResult<T[], Error>;
|
|
71
|
+
/**
|
|
72
|
+
* Generic hook to fetch a single item
|
|
73
|
+
*
|
|
74
|
+
* @param axios - Configured axios instance
|
|
75
|
+
* @param key - Query key / API endpoint
|
|
76
|
+
* @param options - Query configuration options
|
|
77
|
+
* @returns React Query result object with single item
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```tsx
|
|
81
|
+
* import { useGetSingle } from 'izen-react-starter';
|
|
82
|
+
* import useAxiosAuth from './hooks/useAxiosAuth';
|
|
83
|
+
*
|
|
84
|
+
* function UserDetail({ userId }) {
|
|
85
|
+
* const axios = useAxiosAuth({ axiosInstance: myAxios });
|
|
86
|
+
* const { data: user, isLoading, error } = useGetSingle(axios, `/users/${userId}`, {
|
|
87
|
+
* queryKey: `user-${userId}`,
|
|
88
|
+
* enabled: !!userId
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
92
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
93
|
+
*
|
|
94
|
+
* return <div>{user?.name}</div>;
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
declare const useGetSingle: <T = any>(axios: AxiosInstance, key: string, options?: UseGetOptions & {
|
|
99
|
+
defaultValue?: T;
|
|
100
|
+
}) => UseQueryResult<T, Error>;
|
|
101
|
+
export { useGet, useGetSingle };
|
|
102
|
+
//# sourceMappingURL=generic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../../src/lib/api/queries/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,QAAA,MAAM,MAAM,GAAI,CAAC,GAAG,GAAG,EACrB,OAAO,aAAa,EACpB,KAAK,MAAM,EACX,UAAS,aAAkB,KAC1B,cAAc,CAAC,CAAC,EAAE,EAAE,KAAK,CAkC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,QAAA,MAAM,YAAY,GAAI,CAAC,GAAG,GAAG,EAC3B,OAAO,aAAa,EACpB,KAAK,MAAM,EACX,UAAS,aAAa,GAAG;IAAE,YAAY,CAAC,EAAE,CAAC,CAAA;CAAO,KACjD,cAAc,CAAC,CAAC,EAAE,KAAK,CAmCzB,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC"}
|