api-core-lib 6.6.5 → 7.6.6

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 CHANGED
@@ -155,6 +155,8 @@ 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
+ encodeQuery: boolean;
159
+ pathParams: Record<string, string | number>;
158
160
  /** Callback function executed on a successful action. */
159
161
  onSuccess?: (message: string, data?: T) => void;
160
162
  /** Callback function executed on a failed action. */
@@ -236,6 +238,12 @@ interface ApiClientConfig {
236
238
  * @default 'info'
237
239
  */
238
240
  logLevel?: LogLevel;
241
+ /**
242
+ * If true, all requests will be treated as public by default.
243
+ * A request can override this by explicitly setting `isPublic: false`.
244
+ * @default false
245
+ */
246
+ defaultIsPublic?: boolean;
239
247
  }
240
248
 
241
249
  /**
@@ -340,10 +348,14 @@ declare const processResponse: <T>(responseOrError: AxiosResponse<any> | ApiErro
340
348
 
341
349
  /**
342
350
  * @file src/hooks/useApi.types.ts
343
- * @description This file defines the professional, publicly-facing types
344
- * returned by the `useApi` hook, providing a clean and stable contract for consumers.
351
+ * @description This file defines the professional, publicly-facing types for the `useApi` hook,
352
+ * providing a clean and stable contract for consumers.
345
353
  */
346
354
 
355
+ /**
356
+ * Configuration object for the `useApi` hook.
357
+ * @template T The type of the data entity.
358
+ */
347
359
  /**
348
360
  * The primary state object managed by the `useApi` hook.
349
361
  * It contains the fetched data, loading status, and any potential errors.
@@ -356,7 +368,18 @@ type UseApiState<T> = StandardResponse<T | T[]>;
356
368
  * @template T The type of the data entity being managed.
357
369
  */
358
370
  interface UseApiActions<T> {
359
- /** Fetches or refetches the list of data. */
371
+ /**
372
+ * Manually triggers a refetch of the hook's primary data using the current query options.
373
+ * This is useful for manual refresh buttons.
374
+ */
375
+ /**
376
+ * Fetches data from an arbitrary path, independent of the hook's main state.
377
+ * This is useful for one-off requests that shouldn't affect the primary data.
378
+ * @param path The relative or absolute path to fetch from.
379
+ * @param pathParams Optional parameters to fill dynamic parts of the path.
380
+ * @param options Optional Axios request configuration.
381
+ * @returns A promise that resolves with the standard API response.
382
+ */
360
383
  fetch: (options?: QueryOptions) => Promise<void>;
361
384
  /** Creates a new item. */
362
385
  create: (newItem: Partial<T>, options?: ActionOptions) => Promise<StandardResponse<T>>;
@@ -380,7 +403,7 @@ interface UseApiQuery {
380
403
  options: QueryOptions;
381
404
  /** A function to set the entire query options object at once. */
382
405
  setOptions: React.Dispatch<React.SetStateAction<QueryOptions>>;
383
- /** Sets the current page number and resets to the first page. */
406
+ /** Sets the current page number. */
384
407
  setPage: (page: number) => void;
385
408
  /** Sets the number of items per page and resets to the first page. */
386
409
  setLimit: (limit: number) => void;
@@ -393,7 +416,7 @@ interface UseApiQuery {
393
416
  }[]) => void;
394
417
  /** Sets the filter object and resets to the first page. */
395
418
  setFilters: (filter: Record<string, any>) => void;
396
- /** Sets a single, custom query parameter and resets to the first page. */
419
+ /** Sets a single, custom query parameter. */
397
420
  setQueryParam: (key: string, value: any) => void;
398
421
  /** Resets the query options to their initial state. */
399
422
  reset: () => void;
package/dist/index.d.ts CHANGED
@@ -155,6 +155,8 @@ 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
+ encodeQuery: boolean;
159
+ pathParams: Record<string, string | number>;
158
160
  /** Callback function executed on a successful action. */
159
161
  onSuccess?: (message: string, data?: T) => void;
160
162
  /** Callback function executed on a failed action. */
@@ -236,6 +238,12 @@ interface ApiClientConfig {
236
238
  * @default 'info'
237
239
  */
238
240
  logLevel?: LogLevel;
241
+ /**
242
+ * If true, all requests will be treated as public by default.
243
+ * A request can override this by explicitly setting `isPublic: false`.
244
+ * @default false
245
+ */
246
+ defaultIsPublic?: boolean;
239
247
  }
240
248
 
241
249
  /**
@@ -340,10 +348,14 @@ declare const processResponse: <T>(responseOrError: AxiosResponse<any> | ApiErro
340
348
 
341
349
  /**
342
350
  * @file src/hooks/useApi.types.ts
343
- * @description This file defines the professional, publicly-facing types
344
- * returned by the `useApi` hook, providing a clean and stable contract for consumers.
351
+ * @description This file defines the professional, publicly-facing types for the `useApi` hook,
352
+ * providing a clean and stable contract for consumers.
345
353
  */
346
354
 
355
+ /**
356
+ * Configuration object for the `useApi` hook.
357
+ * @template T The type of the data entity.
358
+ */
347
359
  /**
348
360
  * The primary state object managed by the `useApi` hook.
349
361
  * It contains the fetched data, loading status, and any potential errors.
@@ -356,7 +368,18 @@ type UseApiState<T> = StandardResponse<T | T[]>;
356
368
  * @template T The type of the data entity being managed.
357
369
  */
358
370
  interface UseApiActions<T> {
359
- /** Fetches or refetches the list of data. */
371
+ /**
372
+ * Manually triggers a refetch of the hook's primary data using the current query options.
373
+ * This is useful for manual refresh buttons.
374
+ */
375
+ /**
376
+ * Fetches data from an arbitrary path, independent of the hook's main state.
377
+ * This is useful for one-off requests that shouldn't affect the primary data.
378
+ * @param path The relative or absolute path to fetch from.
379
+ * @param pathParams Optional parameters to fill dynamic parts of the path.
380
+ * @param options Optional Axios request configuration.
381
+ * @returns A promise that resolves with the standard API response.
382
+ */
360
383
  fetch: (options?: QueryOptions) => Promise<void>;
361
384
  /** Creates a new item. */
362
385
  create: (newItem: Partial<T>, options?: ActionOptions) => Promise<StandardResponse<T>>;
@@ -380,7 +403,7 @@ interface UseApiQuery {
380
403
  options: QueryOptions;
381
404
  /** A function to set the entire query options object at once. */
382
405
  setOptions: React.Dispatch<React.SetStateAction<QueryOptions>>;
383
- /** Sets the current page number and resets to the first page. */
406
+ /** Sets the current page number. */
384
407
  setPage: (page: number) => void;
385
408
  /** Sets the number of items per page and resets to the first page. */
386
409
  setLimit: (limit: number) => void;
@@ -393,7 +416,7 @@ interface UseApiQuery {
393
416
  }[]) => void;
394
417
  /** Sets the filter object and resets to the first page. */
395
418
  setFilters: (filter: Record<string, any>) => void;
396
- /** Sets a single, custom query parameter and resets to the first page. */
419
+ /** Sets a single, custom query parameter. */
397
420
  setQueryParam: (key: string, value: any) => void;
398
421
  /** Resets the query options to their initial state. */
399
422
  reset: () => void;