@tealca/core-components 1.0.13 → 1.0.14

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.ts CHANGED
@@ -1565,6 +1565,39 @@ declare interface TrackingTableProps {
1565
1565
  wrapperClassName?: string;
1566
1566
  }
1567
1567
 
1568
+ /**
1569
+ * `api` is an instance of `axios` configured for interacting with the backend API.
1570
+ *
1571
+ * It has interceptors to standardize requests and responses.
1572
+ *
1573
+ * Request Interceptor:
1574
+ * 1. Adds the `Authorization` header with the JWT token if available.
1575
+ * 2. Converts the keys of the request `data` from camelCase to snake_case.
1576
+ * 3. Converts the keys of the request `params` from camelCase to snake_case.
1577
+ *
1578
+ * Response Interceptor:
1579
+ * 1. Converts the keys of the response `data` from snake_case to camelCase.
1580
+ * 2. If a 401 Unauthorized error occurs, it attempts to refresh the token.
1581
+ * - If token refresh is successful, it retries the original request with the new token.
1582
+ * - If token refresh fails, it rejects the promise.
1583
+ */
1584
+ export declare const useApi: (apiUri: string, basicApi: AxiosInstance) => AxiosInstance;
1585
+
1586
+ /**
1587
+ * `basicApi` is an instance of `axios` configured with a base URL and a response interceptor.
1588
+ *
1589
+ * The response interceptor automatically converts all snake_case keys in the API
1590
+ * response data to camelCase. This ensures that the frontend application can work
1591
+ * with a consistent camelCase naming convention, regardless of the API's naming
1592
+ * style.
1593
+ *
1594
+ * If an API response contains data, the interceptor will recursively traverse the
1595
+ * data object (or array of objects) and convert all keys. If there is no data,
1596
+ * or if an error occurs, the original response or error is returned without
1597
+ * modification.
1598
+ */
1599
+ export declare const useBasicApi: (apiUri: string) => AxiosInstance;
1600
+
1568
1601
  export declare interface User {
1569
1602
  userId: string;
1570
1603
  department?: Department;