api-core-lib 12.0.23 → 12.0.24
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/{apiModule.types-D0LSWRW8.d.cts → apiModule.types-B_MxXat3.d.cts} +5 -4
- package/dist/{apiModule.types-D0LSWRW8.d.ts → apiModule.types-B_MxXat3.d.ts} +5 -4
- package/dist/client.cjs +15 -2
- package/dist/client.d.cts +12 -5
- package/dist/client.d.ts +12 -5
- package/dist/client.js +15 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/{useApiRecord.types-DXv1-ly6.d.cts → useApiRecord.types-A-m0WKKh.d.cts} +1 -1
- package/dist/{useApiRecord.types-C7T0gsX_.d.ts → useApiRecord.types-BgjdqOHw.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -218,13 +218,14 @@ interface ApiModuleConfig<TActions extends Record<string, ActionConfigModule<any
|
|
|
218
218
|
actions: TActions;
|
|
219
219
|
}
|
|
220
220
|
/** @description Configuration options passed directly to the `useApiModule` hook. */
|
|
221
|
-
interface UseApiModuleOptions {
|
|
221
|
+
interface UseApiModuleOptions<TExtra = {}> {
|
|
222
222
|
onSuccess?: (actionName: string, message: string, data: unknown) => void;
|
|
223
223
|
onError?: (actionName: string, message: string, error?: ApiError | null) => void;
|
|
224
224
|
refetchOnWindowFocus?: boolean;
|
|
225
225
|
pathParams?: Record<string, any>;
|
|
226
226
|
enabled?: boolean;
|
|
227
227
|
hydratedState?: string;
|
|
228
|
+
extraContextData?: TExtra;
|
|
228
229
|
}
|
|
229
230
|
/** A utility type to infer the Input type (`TInput`) from an ActionConfigModule. */
|
|
230
231
|
type InputOf<TActionConfig> = TActionConfig extends ActionConfigModule<infer TInput, any> ? TInput : never;
|
|
@@ -253,7 +254,7 @@ type ModuleStates<TActions extends Record<string, ActionConfigModule<any, any>>>
|
|
|
253
254
|
[K in keyof TActions]: ActionState<OutputOf<TActions[K]>>;
|
|
254
255
|
};
|
|
255
256
|
/** @description The complete, fully-typed return object of the `useApiModule` hook. */
|
|
256
|
-
|
|
257
|
+
type UseApiModuleReturn<TActions extends Record<string, any>, TExtra = {}> = {
|
|
257
258
|
states: ModuleStates<TActions>;
|
|
258
259
|
actions: ModuleActions<TActions>;
|
|
259
260
|
queries: {
|
|
@@ -262,7 +263,7 @@ interface UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<
|
|
|
262
263
|
} ? UseApiQuery : never;
|
|
263
264
|
};
|
|
264
265
|
dehydrate: () => string;
|
|
265
|
-
}
|
|
266
|
+
} & TExtra;
|
|
266
267
|
/**
|
|
267
268
|
* يصف دوال `execute` و `reset` لإجراء واحد.
|
|
268
269
|
* هذا النوع عام (generic) ليتناسب مع أنواع الإدخال والإخراج المختلفة لكل إجراء.
|
|
@@ -281,4 +282,4 @@ type ActionMethods<TAction extends ActionConfigModule<any, any>> = {
|
|
|
281
282
|
}) => void;
|
|
282
283
|
};
|
|
283
284
|
|
|
284
|
-
export type { ActionConfigModule as A, ExecutableAction as E, InputOf as I, LogLevel as L,
|
|
285
|
+
export type { ActionConfigModule as A, ExecutableAction as E, InputOf as I, LogLevel as L, ModuleStates as M, OutputOf as O, PaginationMeta as P, QueryOptions as Q, RequestConfig as R, StandardResponse as S, Tokens as T, UseApiConfig as U, ValidationError as V, ApiModuleConfig as a, UseApiModuleOptions as b, UseApiModuleReturn as c, ModuleActions as d, UseApiQuery as e, ApiClientConfig as f, ActionOptions as g, ActionStateModule as h, ApiError as i, TokenManager as j, MiddlewareContext as k, Middleware as l, RefreshTokenConfig as m, ActionConfig as n, UseApiState as o, ActionState as p, ExecuteOptions as q, ActionMethods as r, t };
|
|
@@ -218,13 +218,14 @@ interface ApiModuleConfig<TActions extends Record<string, ActionConfigModule<any
|
|
|
218
218
|
actions: TActions;
|
|
219
219
|
}
|
|
220
220
|
/** @description Configuration options passed directly to the `useApiModule` hook. */
|
|
221
|
-
interface UseApiModuleOptions {
|
|
221
|
+
interface UseApiModuleOptions<TExtra = {}> {
|
|
222
222
|
onSuccess?: (actionName: string, message: string, data: unknown) => void;
|
|
223
223
|
onError?: (actionName: string, message: string, error?: ApiError | null) => void;
|
|
224
224
|
refetchOnWindowFocus?: boolean;
|
|
225
225
|
pathParams?: Record<string, any>;
|
|
226
226
|
enabled?: boolean;
|
|
227
227
|
hydratedState?: string;
|
|
228
|
+
extraContextData?: TExtra;
|
|
228
229
|
}
|
|
229
230
|
/** A utility type to infer the Input type (`TInput`) from an ActionConfigModule. */
|
|
230
231
|
type InputOf<TActionConfig> = TActionConfig extends ActionConfigModule<infer TInput, any> ? TInput : never;
|
|
@@ -253,7 +254,7 @@ type ModuleStates<TActions extends Record<string, ActionConfigModule<any, any>>>
|
|
|
253
254
|
[K in keyof TActions]: ActionState<OutputOf<TActions[K]>>;
|
|
254
255
|
};
|
|
255
256
|
/** @description The complete, fully-typed return object of the `useApiModule` hook. */
|
|
256
|
-
|
|
257
|
+
type UseApiModuleReturn<TActions extends Record<string, any>, TExtra = {}> = {
|
|
257
258
|
states: ModuleStates<TActions>;
|
|
258
259
|
actions: ModuleActions<TActions>;
|
|
259
260
|
queries: {
|
|
@@ -262,7 +263,7 @@ interface UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<
|
|
|
262
263
|
} ? UseApiQuery : never;
|
|
263
264
|
};
|
|
264
265
|
dehydrate: () => string;
|
|
265
|
-
}
|
|
266
|
+
} & TExtra;
|
|
266
267
|
/**
|
|
267
268
|
* يصف دوال `execute` و `reset` لإجراء واحد.
|
|
268
269
|
* هذا النوع عام (generic) ليتناسب مع أنواع الإدخال والإخراج المختلفة لكل إجراء.
|
|
@@ -281,4 +282,4 @@ type ActionMethods<TAction extends ActionConfigModule<any, any>> = {
|
|
|
281
282
|
}) => void;
|
|
282
283
|
};
|
|
283
284
|
|
|
284
|
-
export type { ActionConfigModule as A, ExecutableAction as E, InputOf as I, LogLevel as L,
|
|
285
|
+
export type { ActionConfigModule as A, ExecutableAction as E, InputOf as I, LogLevel as L, ModuleStates as M, OutputOf as O, PaginationMeta as P, QueryOptions as Q, RequestConfig as R, StandardResponse as S, Tokens as T, UseApiConfig as U, ValidationError as V, ApiModuleConfig as a, UseApiModuleOptions as b, UseApiModuleReturn as c, ModuleActions as d, UseApiQuery as e, ApiClientConfig as f, ActionOptions as g, ActionStateModule as h, ApiError as i, TokenManager as j, MiddlewareContext as k, Middleware as l, RefreshTokenConfig as m, ActionConfig as n, UseApiState as o, ActionState as p, ExecuteOptions as q, ActionMethods as r, t };
|
package/dist/client.cjs
CHANGED
|
@@ -741,7 +741,15 @@ function useModuleContext() {
|
|
|
741
741
|
return context;
|
|
742
742
|
}
|
|
743
743
|
function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
744
|
-
const {
|
|
744
|
+
const {
|
|
745
|
+
refetchOnWindowFocus = true,
|
|
746
|
+
onSuccess,
|
|
747
|
+
onError,
|
|
748
|
+
pathParams: modulePathParams,
|
|
749
|
+
enabled = true,
|
|
750
|
+
hydratedState,
|
|
751
|
+
extraContextData
|
|
752
|
+
} = options;
|
|
745
753
|
const pathParamsString = (0, import_react4.useMemo)(() => JSON.stringify(modulePathParams || {}), [modulePathParams]);
|
|
746
754
|
const [queryOptions, setQueryOptions] = (0, import_react4.useState)({});
|
|
747
755
|
const savedCallbacks = (0, import_react4.useRef)({ onSuccess, onError });
|
|
@@ -913,7 +921,12 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
|
913
921
|
const dehydrate = (0, import_react4.useMemo)(() => {
|
|
914
922
|
return () => globalStateManager.dehydrate();
|
|
915
923
|
}, []);
|
|
916
|
-
|
|
924
|
+
const baseApiReturn = { actions, states, queries, dehydrate };
|
|
925
|
+
const finalApiReturn = (0, import_react4.useMemo)(() => ({
|
|
926
|
+
...baseApiReturn,
|
|
927
|
+
...extraContextData || {}
|
|
928
|
+
}), [baseApiReturn, extraContextData]);
|
|
929
|
+
return finalApiReturn;
|
|
917
930
|
}
|
|
918
931
|
// Annotate the CommonJS export names for ESM import in node:
|
|
919
932
|
0 && (module.exports = {
|
package/dist/client.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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-
|
|
3
|
-
import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-
|
|
2
|
+
import { U as UseApiConfig, A as ActionConfigModule, a as ApiModuleConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, M as ModuleStates, d as ModuleActions, e as UseApiQuery } from './apiModule.types-B_MxXat3.cjs';
|
|
3
|
+
import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-A-m0WKKh.cjs';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
|
|
6
6
|
declare function useApi<T>(axiosInstance: AxiosInstance, config: UseApiConfig<T>): any;
|
|
@@ -21,8 +21,15 @@ type EffectCallback = () => (void | (() => void));
|
|
|
21
21
|
type DependencyList = readonly any[];
|
|
22
22
|
declare function useDeepCompareEffect(callback: EffectCallback, dependencies: DependencyList): void;
|
|
23
23
|
|
|
24
|
-
declare const ApiModuleProvider: React.Provider<
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
declare const ApiModuleProvider: React.Provider<{
|
|
25
|
+
states: ModuleStates<any>;
|
|
26
|
+
actions: ModuleActions<any>;
|
|
27
|
+
queries: {
|
|
28
|
+
[x: string]: UseApiQuery | undefined;
|
|
29
|
+
};
|
|
30
|
+
dehydrate: () => string;
|
|
31
|
+
} | null>;
|
|
32
|
+
declare function useModuleContext<TModule extends ApiModuleConfig<any>, TExtra = {}>(): UseApiModuleReturn<TModule['actions'], TExtra>;
|
|
33
|
+
declare function useApiModule<TActions extends Record<string, ActionConfigModule<any, any>>, TExtra extends object = {}>(axiosInstance: AxiosInstance, moduleConfig: ApiModuleConfig<TActions>, options?: UseApiModuleOptions<TExtra>): UseApiModuleReturn<TActions, TExtra>;
|
|
27
34
|
|
|
28
35
|
export { ApiModuleProvider, useApi, useApiModule, useApiRecord, useDeepCompareEffect, useModuleContext };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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-
|
|
3
|
-
import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-
|
|
2
|
+
import { U as UseApiConfig, A as ActionConfigModule, a as ApiModuleConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, M as ModuleStates, d as ModuleActions, e as UseApiQuery } from './apiModule.types-B_MxXat3.js';
|
|
3
|
+
import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-BgjdqOHw.js';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
|
|
6
6
|
declare function useApi<T>(axiosInstance: AxiosInstance, config: UseApiConfig<T>): any;
|
|
@@ -21,8 +21,15 @@ type EffectCallback = () => (void | (() => void));
|
|
|
21
21
|
type DependencyList = readonly any[];
|
|
22
22
|
declare function useDeepCompareEffect(callback: EffectCallback, dependencies: DependencyList): void;
|
|
23
23
|
|
|
24
|
-
declare const ApiModuleProvider: React.Provider<
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
declare const ApiModuleProvider: React.Provider<{
|
|
25
|
+
states: ModuleStates<any>;
|
|
26
|
+
actions: ModuleActions<any>;
|
|
27
|
+
queries: {
|
|
28
|
+
[x: string]: UseApiQuery | undefined;
|
|
29
|
+
};
|
|
30
|
+
dehydrate: () => string;
|
|
31
|
+
} | null>;
|
|
32
|
+
declare function useModuleContext<TModule extends ApiModuleConfig<any>, TExtra = {}>(): UseApiModuleReturn<TModule['actions'], TExtra>;
|
|
33
|
+
declare function useApiModule<TActions extends Record<string, ActionConfigModule<any, any>>, TExtra extends object = {}>(axiosInstance: AxiosInstance, moduleConfig: ApiModuleConfig<TActions>, options?: UseApiModuleOptions<TExtra>): UseApiModuleReturn<TActions, TExtra>;
|
|
27
34
|
|
|
28
35
|
export { ApiModuleProvider, useApi, useApiModule, useApiRecord, useDeepCompareEffect, useModuleContext };
|
package/dist/client.js
CHANGED
|
@@ -702,7 +702,15 @@ function useModuleContext() {
|
|
|
702
702
|
return context;
|
|
703
703
|
}
|
|
704
704
|
function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
705
|
-
const {
|
|
705
|
+
const {
|
|
706
|
+
refetchOnWindowFocus = true,
|
|
707
|
+
onSuccess,
|
|
708
|
+
onError,
|
|
709
|
+
pathParams: modulePathParams,
|
|
710
|
+
enabled = true,
|
|
711
|
+
hydratedState,
|
|
712
|
+
extraContextData
|
|
713
|
+
} = options;
|
|
706
714
|
const pathParamsString = useMemo3(() => JSON.stringify(modulePathParams || {}), [modulePathParams]);
|
|
707
715
|
const [queryOptions, setQueryOptions] = useState3({});
|
|
708
716
|
const savedCallbacks = useRef4({ onSuccess, onError });
|
|
@@ -874,7 +882,12 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
|
874
882
|
const dehydrate = useMemo3(() => {
|
|
875
883
|
return () => globalStateManager.dehydrate();
|
|
876
884
|
}, []);
|
|
877
|
-
|
|
885
|
+
const baseApiReturn = { actions, states, queries, dehydrate };
|
|
886
|
+
const finalApiReturn = useMemo3(() => ({
|
|
887
|
+
...baseApiReturn,
|
|
888
|
+
...extraContextData || {}
|
|
889
|
+
}), [baseApiReturn, extraContextData]);
|
|
890
|
+
return finalApiReturn;
|
|
878
891
|
}
|
|
879
892
|
export {
|
|
880
893
|
ApiModuleProvider,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, Method, AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-
|
|
2
|
+
import { f as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, g as ActionOptions, R as RequestConfig, h as ActionStateModule, Q as QueryOptions, e as UseApiQuery, i as ApiError, L as LogLevel } from './apiModule.types-B_MxXat3.cjs';
|
|
3
|
+
export { n as ActionConfig, r as ActionMethods, p as ActionState, a as ApiModuleConfig, E as ExecutableAction, q as ExecuteOptions, I as InputOf, l as Middleware, k as MiddlewareContext, d as ModuleActions, M as ModuleStates, O as OutputOf, P as PaginationMeta, m as RefreshTokenConfig, j as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, o as UseApiState, V as ValidationError, t } from './apiModule.types-B_MxXat3.cjs';
|
|
4
|
+
export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-A-m0WKKh.cjs';
|
|
5
5
|
import 'react';
|
|
6
6
|
|
|
7
7
|
declare function createApiClient(config: ApiClientConfig): AxiosInstance;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, Method, AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-
|
|
2
|
+
import { f as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, g as ActionOptions, R as RequestConfig, h as ActionStateModule, Q as QueryOptions, e as UseApiQuery, i as ApiError, L as LogLevel } from './apiModule.types-B_MxXat3.js';
|
|
3
|
+
export { n as ActionConfig, r as ActionMethods, p as ActionState, a as ApiModuleConfig, E as ExecutableAction, q as ExecuteOptions, I as InputOf, l as Middleware, k as MiddlewareContext, d as ModuleActions, M as ModuleStates, O as OutputOf, P as PaginationMeta, m as RefreshTokenConfig, j as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, o as UseApiState, V as ValidationError, t } from './apiModule.types-B_MxXat3.js';
|
|
4
|
+
export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-BgjdqOHw.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
|
|
7
7
|
declare function createApiClient(config: ApiClientConfig): AxiosInstance;
|
package/dist/server.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { A as ActionConfigModule, a as ApiModuleConfig, I as InputOf } from './apiModule.types-
|
|
2
|
+
import { A as ActionConfigModule, a as ApiModuleConfig, I as InputOf } from './apiModule.types-B_MxXat3.cjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { A as ActionConfigModule, a as ApiModuleConfig, I as InputOf } from './apiModule.types-
|
|
2
|
+
import { A as ActionConfigModule, a as ApiModuleConfig, I as InputOf } from './apiModule.types-B_MxXat3.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { R as RequestConfig,
|
|
2
|
+
import { R as RequestConfig, i as ApiError, S as StandardResponse, g as ActionOptions } from './apiModule.types-B_MxXat3.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents the internal state of the `useApiRecord` hook.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { R as RequestConfig,
|
|
2
|
+
import { R as RequestConfig, i as ApiError, S as StandardResponse, g as ActionOptions } from './apiModule.types-B_MxXat3.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents the internal state of the `useApiRecord` hook.
|