api-core-lib 12.0.9 → 12.0.11
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/README.md +1 -0
- package/dist/{apiModule.types-2yhaJWN3.d.cts → apiModule.types-CpwGDEpG.d.cts} +2 -2
- package/dist/{apiModule.types-2yhaJWN3.d.ts → apiModule.types-CpwGDEpG.d.ts} +2 -2
- package/dist/client.cjs +864 -0
- package/dist/client.d.cts +28 -0
- package/dist/client.d.ts +28 -0
- package/dist/client.js +824 -0
- package/dist/index.cjs +2 -458
- package/dist/index.d.cts +5 -113
- package/dist/index.d.ts +5 -113
- package/dist/index.js +659 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +310 -1
- package/dist/useApiRecord.types-B45E0qux.d.cts +90 -0
- package/dist/useApiRecord.types-DlrlXL1t.d.ts +90 -0
- package/package.json +8 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { U as UseApiConfig, A as ActionConfigModule, a as ApiModuleConfig, b as UseApiModuleOptions, c as UseApiModuleReturn } from './apiModule.types-CpwGDEpG.cjs';
|
|
3
|
+
import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-B45E0qux.cjs';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
declare function useApi<T>(axiosInstance: AxiosInstance, config: UseApiConfig<T>): any;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A React hook for managing the lifecycle of a single API resource (a record).
|
|
10
|
+
* It handles fetching, updating, replacing, and deleting a record, while managing
|
|
11
|
+
* loading, error, and data states. It supports dynamic path parameters for flexible API routing.
|
|
12
|
+
*
|
|
13
|
+
* @template T The data type of the record being managed.
|
|
14
|
+
* @param {AxiosInstance} axiosInstance - The configured Axios instance for making API calls.
|
|
15
|
+
* @param {UseApiRecordConfig<T>} config - Configuration options for the hook.
|
|
16
|
+
* @returns {UseApiRecordReturn<T>} An object containing the state, actions, and setState function.
|
|
17
|
+
*/
|
|
18
|
+
declare function useApiRecord<T>(axiosInstance: AxiosInstance, config: UseApiRecordConfig<T>): UseApiRecordReturn<T>;
|
|
19
|
+
|
|
20
|
+
type EffectCallback = () => (void | (() => void));
|
|
21
|
+
type DependencyList = readonly any[];
|
|
22
|
+
declare function useDeepCompareEffect(callback: EffectCallback, dependencies: DependencyList): void;
|
|
23
|
+
|
|
24
|
+
declare const ApiModuleProvider: React.Provider<UseApiModuleReturn<any> | null>;
|
|
25
|
+
declare function useModuleContext<TModule extends ApiModuleConfig<any>>(): UseApiModuleReturn<TModule['actions']>;
|
|
26
|
+
declare function useApiModule<TActions extends Record<string, ActionConfigModule<any, any>>>(axiosInstance: AxiosInstance, moduleConfig: ApiModuleConfig<TActions>, options?: UseApiModuleOptions): UseApiModuleReturn<TActions>;
|
|
27
|
+
|
|
28
|
+
export { ApiModuleProvider, useApi, useApiModule, useApiRecord, useDeepCompareEffect, useModuleContext };
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { U as UseApiConfig, A as ActionConfigModule, a as ApiModuleConfig, b as UseApiModuleOptions, c as UseApiModuleReturn } from './apiModule.types-CpwGDEpG.js';
|
|
3
|
+
import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-DlrlXL1t.js';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
declare function useApi<T>(axiosInstance: AxiosInstance, config: UseApiConfig<T>): any;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A React hook for managing the lifecycle of a single API resource (a record).
|
|
10
|
+
* It handles fetching, updating, replacing, and deleting a record, while managing
|
|
11
|
+
* loading, error, and data states. It supports dynamic path parameters for flexible API routing.
|
|
12
|
+
*
|
|
13
|
+
* @template T The data type of the record being managed.
|
|
14
|
+
* @param {AxiosInstance} axiosInstance - The configured Axios instance for making API calls.
|
|
15
|
+
* @param {UseApiRecordConfig<T>} config - Configuration options for the hook.
|
|
16
|
+
* @returns {UseApiRecordReturn<T>} An object containing the state, actions, and setState function.
|
|
17
|
+
*/
|
|
18
|
+
declare function useApiRecord<T>(axiosInstance: AxiosInstance, config: UseApiRecordConfig<T>): UseApiRecordReturn<T>;
|
|
19
|
+
|
|
20
|
+
type EffectCallback = () => (void | (() => void));
|
|
21
|
+
type DependencyList = readonly any[];
|
|
22
|
+
declare function useDeepCompareEffect(callback: EffectCallback, dependencies: DependencyList): void;
|
|
23
|
+
|
|
24
|
+
declare const ApiModuleProvider: React.Provider<UseApiModuleReturn<any> | null>;
|
|
25
|
+
declare function useModuleContext<TModule extends ApiModuleConfig<any>>(): UseApiModuleReturn<TModule['actions']>;
|
|
26
|
+
declare function useApiModule<TActions extends Record<string, ActionConfigModule<any, any>>>(axiosInstance: AxiosInstance, moduleConfig: ApiModuleConfig<TActions>, options?: UseApiModuleOptions): UseApiModuleReturn<TActions>;
|
|
27
|
+
|
|
28
|
+
export { ApiModuleProvider, useApi, useApiModule, useApiRecord, useDeepCompareEffect, useModuleContext };
|