api-core-lib 4.3.3 → 4.4.3
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/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +10 -3
- package/dist/index.mjs +10 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
@@ -204,6 +204,11 @@ interface UseApiConfig<T> {
|
|
204
204
|
refetchAfterChange?: boolean;
|
205
205
|
onSuccess?: (message: string, data?: T) => void;
|
206
206
|
onError?: (message: string, error?: ApiError) => void;
|
207
|
+
/**
|
208
|
+
* إعدادات Axios/Request افتراضية يتم تطبيقها على جميع طلبات الجلب (GET).
|
209
|
+
* مفيدة لتمرير إعدادات مثل isPublic.
|
210
|
+
*/
|
211
|
+
requestConfig?: RequestConfig;
|
207
212
|
}
|
208
213
|
|
209
214
|
/**
|
package/dist/index.d.ts
CHANGED
@@ -204,6 +204,11 @@ interface UseApiConfig<T> {
|
|
204
204
|
refetchAfterChange?: boolean;
|
205
205
|
onSuccess?: (message: string, data?: T) => void;
|
206
206
|
onError?: (message: string, error?: ApiError) => void;
|
207
|
+
/**
|
208
|
+
* إعدادات Axios/Request افتراضية يتم تطبيقها على جميع طلبات الجلب (GET).
|
209
|
+
* مفيدة لتمرير إعدادات مثل isPublic.
|
210
|
+
*/
|
211
|
+
requestConfig?: RequestConfig;
|
207
212
|
}
|
208
213
|
|
209
214
|
/**
|
package/dist/index.js
CHANGED
@@ -96,6 +96,9 @@ function createApiClient(config) {
|
|
96
96
|
timeout = 15e3,
|
97
97
|
headers = {},
|
98
98
|
withCredentials = false
|
99
|
+
// onRefreshError = () => {},
|
100
|
+
// responseType = 'json',
|
101
|
+
// refreshTokenConfig,
|
99
102
|
} = config;
|
100
103
|
const axiosInstance = import_axios.default.create({
|
101
104
|
baseURL,
|
@@ -356,7 +359,7 @@ function useApi(axiosInstance, config) {
|
|
356
359
|
initialQuery = { limit: 10 },
|
357
360
|
enabled = true,
|
358
361
|
refetchAfterChange = true,
|
359
|
-
|
362
|
+
requestConfig,
|
360
363
|
onSuccess,
|
361
364
|
onError
|
362
365
|
} = config;
|
@@ -373,12 +376,16 @@ function useApi(axiosInstance, config) {
|
|
373
376
|
const currentQuery = options || queryOptions;
|
374
377
|
setState((prev) => ({ ...prev, data: null, loading: true, error: null }));
|
375
378
|
const queryString = buildPaginateQuery(currentQuery);
|
376
|
-
const result = await apiServices.getWithQuery(queryString, {
|
379
|
+
const result = await apiServices.getWithQuery(queryString, {
|
380
|
+
cancelTokenKey: endpoint,
|
381
|
+
...requestConfig
|
382
|
+
// <-- هنا نمرر الإعدادات الافتراضية
|
383
|
+
});
|
377
384
|
setState(result);
|
378
385
|
if (!result.success && onError) {
|
379
386
|
onError(result.message || "Fetch failed", result.error || void 0);
|
380
387
|
}
|
381
|
-
}, [apiServices, queryOptions, endpoint, onError]);
|
388
|
+
}, [apiServices, queryOptions, endpoint, onError, requestConfig]);
|
382
389
|
(0, import_react.useEffect)(() => {
|
383
390
|
if (enabled) {
|
384
391
|
fetchData();
|
package/dist/index.mjs
CHANGED
@@ -54,6 +54,9 @@ function createApiClient(config) {
|
|
54
54
|
timeout = 15e3,
|
55
55
|
headers = {},
|
56
56
|
withCredentials = false
|
57
|
+
// onRefreshError = () => {},
|
58
|
+
// responseType = 'json',
|
59
|
+
// refreshTokenConfig,
|
57
60
|
} = config;
|
58
61
|
const axiosInstance = axios.create({
|
59
62
|
baseURL,
|
@@ -314,7 +317,7 @@ function useApi(axiosInstance, config) {
|
|
314
317
|
initialQuery = { limit: 10 },
|
315
318
|
enabled = true,
|
316
319
|
refetchAfterChange = true,
|
317
|
-
|
320
|
+
requestConfig,
|
318
321
|
onSuccess,
|
319
322
|
onError
|
320
323
|
} = config;
|
@@ -331,12 +334,16 @@ function useApi(axiosInstance, config) {
|
|
331
334
|
const currentQuery = options || queryOptions;
|
332
335
|
setState((prev) => ({ ...prev, data: null, loading: true, error: null }));
|
333
336
|
const queryString = buildPaginateQuery(currentQuery);
|
334
|
-
const result = await apiServices.getWithQuery(queryString, {
|
337
|
+
const result = await apiServices.getWithQuery(queryString, {
|
338
|
+
cancelTokenKey: endpoint,
|
339
|
+
...requestConfig
|
340
|
+
// <-- هنا نمرر الإعدادات الافتراضية
|
341
|
+
});
|
335
342
|
setState(result);
|
336
343
|
if (!result.success && onError) {
|
337
344
|
onError(result.message || "Fetch failed", result.error || void 0);
|
338
345
|
}
|
339
|
-
}, [apiServices, queryOptions, endpoint, onError]);
|
346
|
+
}, [apiServices, queryOptions, endpoint, onError, requestConfig]);
|
340
347
|
useEffect(() => {
|
341
348
|
if (enabled) {
|
342
349
|
fetchData();
|