api-core-lib 12.0.0 → 12.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/index.d.mts +27 -7
- package/dist/index.d.ts +27 -7
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -155,8 +155,11 @@ interface UseApiConfig<T> {
|
|
|
155
155
|
refetchAfterChange?: boolean;
|
|
156
156
|
/** A default `RequestConfig` to apply to all GET requests made by the hook. */
|
|
157
157
|
requestConfig?: RequestConfig;
|
|
158
|
-
|
|
158
|
+
/**
|
|
159
|
+
* [NEW] كائن يحتوي على قيم المتغيرات في قالب المسار.
|
|
160
|
+
*/
|
|
159
161
|
pathParams?: Record<string, string | number>;
|
|
162
|
+
encodeQuery?: boolean;
|
|
160
163
|
/** Callback function executed on a successful action. */
|
|
161
164
|
onSuccess?: (message: string, data?: T) => void;
|
|
162
165
|
/** Callback function executed on a failed action. */
|
|
@@ -378,13 +381,16 @@ declare function createApiServices<T>(axiosInstance: AxiosInstance, baseEndpoint
|
|
|
378
381
|
* بالإضافة إلى دوال التحقق من الأنواع (type guards).
|
|
379
382
|
*/
|
|
380
383
|
|
|
384
|
+
interface BuildQueryOptions {
|
|
385
|
+
encode?: boolean;
|
|
386
|
+
}
|
|
381
387
|
/**
|
|
382
|
-
* يبني سلسلة استعلام (query string) من كائن
|
|
383
|
-
*
|
|
384
|
-
* @param
|
|
388
|
+
* يبني سلسلة استعلام (query string) من كائن الخيارات.
|
|
389
|
+
* @param options - كائن خيارات الاستعلام (فلترة, ترتيب, ...).
|
|
390
|
+
* @param config - إعدادات إضافية مثل التحكم في التشفير.
|
|
385
391
|
* @returns سلسلة استعلام جاهزة للإضافة للرابط.
|
|
386
392
|
*/
|
|
387
|
-
declare function buildPaginateQuery(
|
|
393
|
+
declare function buildPaginateQuery(options: QueryOptions, config?: BuildQueryOptions): string;
|
|
388
394
|
|
|
389
395
|
/**
|
|
390
396
|
* Defines a single custom API action.
|
|
@@ -502,8 +508,17 @@ interface UseApiRecordActions<T> {
|
|
|
502
508
|
* @template T The data type of the record.
|
|
503
509
|
*/
|
|
504
510
|
interface UseApiRecordConfig<T> {
|
|
505
|
-
/**
|
|
511
|
+
/**
|
|
512
|
+
* The base API endpoint template for the resource.
|
|
513
|
+
* Can contain placeholders like `{endpointName}`.
|
|
514
|
+
* @example 'v1/dynamic/{endpointName}'
|
|
515
|
+
*/
|
|
506
516
|
endpoint: string;
|
|
517
|
+
/**
|
|
518
|
+
* An object containing key-value pairs to replace placeholders in the endpoint template.
|
|
519
|
+
* @example { endpointName: 'products' }
|
|
520
|
+
*/
|
|
521
|
+
pathParams?: Record<string, string | number>;
|
|
507
522
|
/** The unique identifier of the record to fetch or modify. */
|
|
508
523
|
recordId?: string | number | null;
|
|
509
524
|
/** Optional initial data to populate the state before the first fetch is complete. */
|
|
@@ -535,7 +550,12 @@ interface UseApiRecordReturn<T> {
|
|
|
535
550
|
/**
|
|
536
551
|
* A React hook for managing the lifecycle of a single API resource (a record).
|
|
537
552
|
* It handles fetching, updating, replacing, and deleting a record, while managing
|
|
538
|
-
* loading, error, and data states.
|
|
553
|
+
* loading, error, and data states. It supports dynamic path parameters for flexible API routing.
|
|
554
|
+
*
|
|
555
|
+
* @template T The data type of the record being managed.
|
|
556
|
+
* @param {AxiosInstance} axiosInstance - The configured Axios instance for making API calls.
|
|
557
|
+
* @param {UseApiRecordConfig<T>} config - Configuration options for the hook.
|
|
558
|
+
* @returns {UseApiRecordReturn<T>} An object containing the state, actions, and setState function.
|
|
539
559
|
*/
|
|
540
560
|
declare function useApiRecord<T>(axiosInstance: AxiosInstance, config: UseApiRecordConfig<T>): UseApiRecordReturn<T>;
|
|
541
561
|
|
package/dist/index.d.ts
CHANGED
|
@@ -155,8 +155,11 @@ interface UseApiConfig<T> {
|
|
|
155
155
|
refetchAfterChange?: boolean;
|
|
156
156
|
/** A default `RequestConfig` to apply to all GET requests made by the hook. */
|
|
157
157
|
requestConfig?: RequestConfig;
|
|
158
|
-
|
|
158
|
+
/**
|
|
159
|
+
* [NEW] كائن يحتوي على قيم المتغيرات في قالب المسار.
|
|
160
|
+
*/
|
|
159
161
|
pathParams?: Record<string, string | number>;
|
|
162
|
+
encodeQuery?: boolean;
|
|
160
163
|
/** Callback function executed on a successful action. */
|
|
161
164
|
onSuccess?: (message: string, data?: T) => void;
|
|
162
165
|
/** Callback function executed on a failed action. */
|
|
@@ -378,13 +381,16 @@ declare function createApiServices<T>(axiosInstance: AxiosInstance, baseEndpoint
|
|
|
378
381
|
* بالإضافة إلى دوال التحقق من الأنواع (type guards).
|
|
379
382
|
*/
|
|
380
383
|
|
|
384
|
+
interface BuildQueryOptions {
|
|
385
|
+
encode?: boolean;
|
|
386
|
+
}
|
|
381
387
|
/**
|
|
382
|
-
* يبني سلسلة استعلام (query string) من كائن
|
|
383
|
-
*
|
|
384
|
-
* @param
|
|
388
|
+
* يبني سلسلة استعلام (query string) من كائن الخيارات.
|
|
389
|
+
* @param options - كائن خيارات الاستعلام (فلترة, ترتيب, ...).
|
|
390
|
+
* @param config - إعدادات إضافية مثل التحكم في التشفير.
|
|
385
391
|
* @returns سلسلة استعلام جاهزة للإضافة للرابط.
|
|
386
392
|
*/
|
|
387
|
-
declare function buildPaginateQuery(
|
|
393
|
+
declare function buildPaginateQuery(options: QueryOptions, config?: BuildQueryOptions): string;
|
|
388
394
|
|
|
389
395
|
/**
|
|
390
396
|
* Defines a single custom API action.
|
|
@@ -502,8 +508,17 @@ interface UseApiRecordActions<T> {
|
|
|
502
508
|
* @template T The data type of the record.
|
|
503
509
|
*/
|
|
504
510
|
interface UseApiRecordConfig<T> {
|
|
505
|
-
/**
|
|
511
|
+
/**
|
|
512
|
+
* The base API endpoint template for the resource.
|
|
513
|
+
* Can contain placeholders like `{endpointName}`.
|
|
514
|
+
* @example 'v1/dynamic/{endpointName}'
|
|
515
|
+
*/
|
|
506
516
|
endpoint: string;
|
|
517
|
+
/**
|
|
518
|
+
* An object containing key-value pairs to replace placeholders in the endpoint template.
|
|
519
|
+
* @example { endpointName: 'products' }
|
|
520
|
+
*/
|
|
521
|
+
pathParams?: Record<string, string | number>;
|
|
507
522
|
/** The unique identifier of the record to fetch or modify. */
|
|
508
523
|
recordId?: string | number | null;
|
|
509
524
|
/** Optional initial data to populate the state before the first fetch is complete. */
|
|
@@ -535,7 +550,12 @@ interface UseApiRecordReturn<T> {
|
|
|
535
550
|
/**
|
|
536
551
|
* A React hook for managing the lifecycle of a single API resource (a record).
|
|
537
552
|
* It handles fetching, updating, replacing, and deleting a record, while managing
|
|
538
|
-
* loading, error, and data states.
|
|
553
|
+
* loading, error, and data states. It supports dynamic path parameters for flexible API routing.
|
|
554
|
+
*
|
|
555
|
+
* @template T The data type of the record being managed.
|
|
556
|
+
* @param {AxiosInstance} axiosInstance - The configured Axios instance for making API calls.
|
|
557
|
+
* @param {UseApiRecordConfig<T>} config - Configuration options for the hook.
|
|
558
|
+
* @returns {UseApiRecordReturn<T>} An object containing the state, actions, and setState function.
|
|
539
559
|
*/
|
|
540
560
|
declare function useApiRecord<T>(axiosInstance: AxiosInstance, config: UseApiRecordConfig<T>): UseApiRecordReturn<T>;
|
|
541
561
|
|