api-core-lib 12.0.13 → 12.0.15
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-CpwGDEpG.d.cts → apiModule.types-BTtRM9wO.d.cts} +1 -0
- package/dist/{apiModule.types-CpwGDEpG.d.ts → apiModule.types-BTtRM9wO.d.ts} +1 -0
- package/dist/client.cjs +16 -9
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +16 -9
- package/dist/index.cjs +13 -0
- package/dist/index.d.cts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +12 -0
- package/dist/server.cjs +4 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +4 -1
- package/dist/{useApiRecord.types-DlrlXL1t.d.ts → useApiRecord.types-BsOSJZ5l.d.ts} +1 -1
- package/dist/{useApiRecord.types-B45E0qux.d.cts → useApiRecord.types-CBP3Ufvu.d.cts} +1 -1
- package/package.json +1 -1
|
@@ -228,6 +228,7 @@ interface ExecuteOptions<TInput, TOutput, TContext = unknown> {
|
|
|
228
228
|
onMutate?: (variables: TInput) => TContext | Promise<TContext>;
|
|
229
229
|
onSuccess?: (data: TOutput, context?: TContext) => void;
|
|
230
230
|
onError?: (error: ApiError, context?: TContext) => void;
|
|
231
|
+
onSettled?: (data?: TOutput, error?: ApiError, context?: TContext) => void;
|
|
231
232
|
}
|
|
232
233
|
/** @description A fully-typed object representing the callable actions for a module. */
|
|
233
234
|
type ModuleActions<TActions extends Record<string, ActionConfigModule<any, any>>> = {
|
|
@@ -228,6 +228,7 @@ interface ExecuteOptions<TInput, TOutput, TContext = unknown> {
|
|
|
228
228
|
onMutate?: (variables: TInput) => TContext | Promise<TContext>;
|
|
229
229
|
onSuccess?: (data: TOutput, context?: TContext) => void;
|
|
230
230
|
onError?: (error: ApiError, context?: TContext) => void;
|
|
231
|
+
onSettled?: (data?: TOutput, error?: ApiError, context?: TContext) => void;
|
|
231
232
|
}
|
|
232
233
|
/** @description A fully-typed object representing the callable actions for a module. */
|
|
233
234
|
type ModuleActions<TActions extends Record<string, ActionConfigModule<any, any>>> = {
|
package/dist/client.cjs
CHANGED
|
@@ -677,6 +677,17 @@ var GlobalStateManager = class {
|
|
|
677
677
|
};
|
|
678
678
|
var globalStateManager = new GlobalStateManager();
|
|
679
679
|
|
|
680
|
+
// src/core/cacheKey.ts
|
|
681
|
+
var generateCacheKey = (moduleName, actionName, input, callOptions = {}) => {
|
|
682
|
+
const params = { path: callOptions.pathParams, body: input };
|
|
683
|
+
try {
|
|
684
|
+
return `${moduleName}/${actionName}::${JSON.stringify(params)}`;
|
|
685
|
+
} catch (error) {
|
|
686
|
+
console.warn("Could not stringify cache key params, falling back to timestamp.", { moduleName, actionName, error });
|
|
687
|
+
return `${moduleName}/${actionName}::${Date.now()}`;
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
|
|
680
691
|
// src/hooks/useApiModule/useApiModule.ts
|
|
681
692
|
var ApiModuleContext = (0, import_react4.createContext)(null);
|
|
682
693
|
var ApiModuleProvider = ApiModuleContext.Provider;
|
|
@@ -697,7 +708,7 @@ function useApiActionState(actionConfig, cacheKey, actionExecutor, enabled) {
|
|
|
697
708
|
} else if (enabled && state.isStale && !state.loading) {
|
|
698
709
|
actionExecutor(input);
|
|
699
710
|
}
|
|
700
|
-
}, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, actionExecutor, input]);
|
|
711
|
+
}, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, actionExecutor, JSON.stringify(input)]);
|
|
701
712
|
return state;
|
|
702
713
|
}
|
|
703
714
|
function useModuleContext() {
|
|
@@ -707,14 +718,6 @@ function useModuleContext() {
|
|
|
707
718
|
}
|
|
708
719
|
return context;
|
|
709
720
|
}
|
|
710
|
-
var generateCacheKey = (moduleName, actionName, input, callOptions = {}) => {
|
|
711
|
-
const params = { path: callOptions.pathParams, body: input };
|
|
712
|
-
try {
|
|
713
|
-
return `${moduleName}/${actionName}::${JSON.stringify(params)}`;
|
|
714
|
-
} catch (error) {
|
|
715
|
-
return `${moduleName}/${actionName}::${Date.now()}`;
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
721
|
function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
719
722
|
const { refetchOnWindowFocus = true, onSuccess, onError, pathParams: modulePathParams, enabled = true, hydratedState } = options;
|
|
720
723
|
const pathParamsString = (0, import_react4.useMemo)(() => JSON.stringify(modulePathParams || {}), [modulePathParams]);
|
|
@@ -765,6 +768,10 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
|
765
768
|
savedCallbacks.current.onError?.(actionName, apiError.message, apiError);
|
|
766
769
|
options2.onError?.(apiError, mutationContext);
|
|
767
770
|
return errorResult;
|
|
771
|
+
} finally {
|
|
772
|
+
if (options2.onSettled) {
|
|
773
|
+
options2.onSettled();
|
|
774
|
+
}
|
|
768
775
|
}
|
|
769
776
|
};
|
|
770
777
|
const reset = (input, options2 = {}) => {
|
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 } from './apiModule.types-BTtRM9wO.cjs';
|
|
3
|
+
import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-CBP3Ufvu.cjs';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
|
|
6
6
|
declare function useApi<T>(axiosInstance: AxiosInstance, config: UseApiConfig<T>): any;
|
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 } from './apiModule.types-BTtRM9wO.js';
|
|
3
|
+
import { U as UseApiRecordConfig, a as UseApiRecordReturn } from './useApiRecord.types-BsOSJZ5l.js';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
|
|
6
6
|
declare function useApi<T>(axiosInstance: AxiosInstance, config: UseApiConfig<T>): any;
|
package/dist/client.js
CHANGED
|
@@ -638,6 +638,17 @@ var GlobalStateManager = class {
|
|
|
638
638
|
};
|
|
639
639
|
var globalStateManager = new GlobalStateManager();
|
|
640
640
|
|
|
641
|
+
// src/core/cacheKey.ts
|
|
642
|
+
var generateCacheKey = (moduleName, actionName, input, callOptions = {}) => {
|
|
643
|
+
const params = { path: callOptions.pathParams, body: input };
|
|
644
|
+
try {
|
|
645
|
+
return `${moduleName}/${actionName}::${JSON.stringify(params)}`;
|
|
646
|
+
} catch (error) {
|
|
647
|
+
console.warn("Could not stringify cache key params, falling back to timestamp.", { moduleName, actionName, error });
|
|
648
|
+
return `${moduleName}/${actionName}::${Date.now()}`;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
|
|
641
652
|
// src/hooks/useApiModule/useApiModule.ts
|
|
642
653
|
var ApiModuleContext = createContext(null);
|
|
643
654
|
var ApiModuleProvider = ApiModuleContext.Provider;
|
|
@@ -658,7 +669,7 @@ function useApiActionState(actionConfig, cacheKey, actionExecutor, enabled) {
|
|
|
658
669
|
} else if (enabled && state.isStale && !state.loading) {
|
|
659
670
|
actionExecutor(input);
|
|
660
671
|
}
|
|
661
|
-
}, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, actionExecutor, input]);
|
|
672
|
+
}, [enabled, state.isStale, state.loading, state.called, actionConfig.autoFetch, actionExecutor, JSON.stringify(input)]);
|
|
662
673
|
return state;
|
|
663
674
|
}
|
|
664
675
|
function useModuleContext() {
|
|
@@ -668,14 +679,6 @@ function useModuleContext() {
|
|
|
668
679
|
}
|
|
669
680
|
return context;
|
|
670
681
|
}
|
|
671
|
-
var generateCacheKey = (moduleName, actionName, input, callOptions = {}) => {
|
|
672
|
-
const params = { path: callOptions.pathParams, body: input };
|
|
673
|
-
try {
|
|
674
|
-
return `${moduleName}/${actionName}::${JSON.stringify(params)}`;
|
|
675
|
-
} catch (error) {
|
|
676
|
-
return `${moduleName}/${actionName}::${Date.now()}`;
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
682
|
function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
680
683
|
const { refetchOnWindowFocus = true, onSuccess, onError, pathParams: modulePathParams, enabled = true, hydratedState } = options;
|
|
681
684
|
const pathParamsString = useMemo3(() => JSON.stringify(modulePathParams || {}), [modulePathParams]);
|
|
@@ -726,6 +729,10 @@ function useApiModule(axiosInstance, moduleConfig, options = {}) {
|
|
|
726
729
|
savedCallbacks.current.onError?.(actionName, apiError.message, apiError);
|
|
727
730
|
options2.onError?.(apiError, mutationContext);
|
|
728
731
|
return errorResult;
|
|
732
|
+
} finally {
|
|
733
|
+
if (options2.onSettled) {
|
|
734
|
+
options2.onSettled();
|
|
735
|
+
}
|
|
729
736
|
}
|
|
730
737
|
};
|
|
731
738
|
const reset = (input, options2 = {}) => {
|
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
createApiActions: () => createApiActions,
|
|
39
39
|
createApiClient: () => createApiClient,
|
|
40
40
|
createApiServices: () => createApiServices,
|
|
41
|
+
generateCacheKey: () => generateCacheKey,
|
|
41
42
|
globalStateManager: () => globalStateManager,
|
|
42
43
|
processResponse: () => processResponse
|
|
43
44
|
});
|
|
@@ -690,6 +691,17 @@ var CacheManager = class {
|
|
|
690
691
|
}
|
|
691
692
|
};
|
|
692
693
|
var cacheManager = new CacheManager();
|
|
694
|
+
|
|
695
|
+
// src/core/cacheKey.ts
|
|
696
|
+
var generateCacheKey = (moduleName, actionName, input, callOptions = {}) => {
|
|
697
|
+
const params = { path: callOptions.pathParams, body: input };
|
|
698
|
+
try {
|
|
699
|
+
return `${moduleName}/${actionName}::${JSON.stringify(params)}`;
|
|
700
|
+
} catch (error) {
|
|
701
|
+
console.warn("Could not stringify cache key params, falling back to timestamp.", { moduleName, actionName, error });
|
|
702
|
+
return `${moduleName}/${actionName}::${Date.now()}`;
|
|
703
|
+
}
|
|
704
|
+
};
|
|
693
705
|
// Annotate the CommonJS export names for ESM import in node:
|
|
694
706
|
0 && (module.exports = {
|
|
695
707
|
buildPaginateQuery,
|
|
@@ -698,6 +710,7 @@ var cacheManager = new CacheManager();
|
|
|
698
710
|
createApiActions,
|
|
699
711
|
createApiClient,
|
|
700
712
|
createApiServices,
|
|
713
|
+
generateCacheKey,
|
|
701
714
|
globalStateManager,
|
|
702
715
|
processResponse
|
|
703
716
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, Method, AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import { d as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, e as ActionOptions, R as RequestConfig, f as ActionStateModule, Q as QueryOptions, g as UseApiQuery, h as ApiError, L as LogLevel } from './apiModule.types-
|
|
3
|
-
export { l as ActionConfig, n as ActionState, a as ApiModuleConfig, E as ExecutableAction, o as ExecuteOptions, I as InputOf, j as Middleware, M as MiddlewareContext, p as ModuleActions, q as ModuleStates, O as OutputOf, P as PaginationMeta, k as RefreshTokenConfig, i as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, m as UseApiState, V as ValidationError } from './apiModule.types-
|
|
4
|
-
export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-
|
|
2
|
+
import { d as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, e as ActionOptions, R as RequestConfig, f as ActionStateModule, Q as QueryOptions, g as UseApiQuery, h as ApiError, L as LogLevel } from './apiModule.types-BTtRM9wO.cjs';
|
|
3
|
+
export { l as ActionConfig, n as ActionState, a as ApiModuleConfig, E as ExecutableAction, o as ExecuteOptions, I as InputOf, j as Middleware, M as MiddlewareContext, p as ModuleActions, q as ModuleStates, O as OutputOf, P as PaginationMeta, k as RefreshTokenConfig, i as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, m as UseApiState, V as ValidationError } from './apiModule.types-BTtRM9wO.cjs';
|
|
4
|
+
export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-CBP3Ufvu.cjs';
|
|
5
5
|
import 'react';
|
|
6
6
|
|
|
7
7
|
declare function createApiClient(config: ApiClientConfig): AxiosInstance;
|
|
@@ -144,6 +144,19 @@ declare class CacheManager {
|
|
|
144
144
|
}
|
|
145
145
|
declare const cacheManager: CacheManager;
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* يقوم بإنشاء مفتاح تخزين مؤقت فريد وثابت لإجراء معين ومدخلاته.
|
|
149
|
+
* هذا يضمن أن نفس الطلب ينتج دائمًا نفس المفتاح.
|
|
150
|
+
* @param moduleName - عادةً ما يكون `baseEndpoint` للموديول.
|
|
151
|
+
* @param actionName - اسم الإجراء (مثل 'list', 'create').
|
|
152
|
+
* @param input - بيانات الطلب (body/query params).
|
|
153
|
+
* @param callOptions - خيارات إضافية مثل `pathParams`.
|
|
154
|
+
* @returns سلسلة نصية فريدة تمثل مفتاح التخزين المؤقت.
|
|
155
|
+
*/
|
|
156
|
+
declare const generateCacheKey: (moduleName: string, actionName: string, input?: unknown, callOptions?: {
|
|
157
|
+
pathParams?: Record<string, any>;
|
|
158
|
+
}) => string;
|
|
159
|
+
|
|
147
160
|
/**
|
|
148
161
|
* @file src/hooks/useApi.types.ts
|
|
149
162
|
* @description This file defines the professional, publicly-facing types for the `useApi` hook,
|
|
@@ -225,4 +238,4 @@ interface UseApiResourceReturn<T, TCreate, TUpdate, TPathParams> {
|
|
|
225
238
|
setQuery: React.Dispatch<React.SetStateAction<QueryOptions>>;
|
|
226
239
|
}
|
|
227
240
|
|
|
228
|
-
export { ActionConfigModule, ActionOptions, ActionStateModule, ApiClientConfig, ApiError, type ApiResourceStatus, LogLevel, QueryOptions, RequestConfig, StandardResponse, type UseApiActions, UseApiQuery, type UseApiResourceActions, type UseApiResourceConfig, type UseApiResourceReturn, type UseApiResourceState, type UseApiReturn, buildPaginateQuery, cacheManager, callDynamicApi, createApiActions, createApiClient, createApiServices, globalStateManager, processResponse };
|
|
241
|
+
export { ActionConfigModule, ActionOptions, ActionStateModule, ApiClientConfig, ApiError, type ApiResourceStatus, LogLevel, QueryOptions, RequestConfig, StandardResponse, type UseApiActions, UseApiQuery, type UseApiResourceActions, type UseApiResourceConfig, type UseApiResourceReturn, type UseApiResourceState, type UseApiReturn, buildPaginateQuery, cacheManager, callDynamicApi, createApiActions, createApiClient, createApiServices, generateCacheKey, globalStateManager, processResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, Method, AxiosResponse, AxiosError } from 'axios';
|
|
2
|
-
import { d as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, e as ActionOptions, R as RequestConfig, f as ActionStateModule, Q as QueryOptions, g as UseApiQuery, h as ApiError, L as LogLevel } from './apiModule.types-
|
|
3
|
-
export { l as ActionConfig, n as ActionState, a as ApiModuleConfig, E as ExecutableAction, o as ExecuteOptions, I as InputOf, j as Middleware, M as MiddlewareContext, p as ModuleActions, q as ModuleStates, O as OutputOf, P as PaginationMeta, k as RefreshTokenConfig, i as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, m as UseApiState, V as ValidationError } from './apiModule.types-
|
|
4
|
-
export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-
|
|
2
|
+
import { d as ApiClientConfig, A as ActionConfigModule, S as StandardResponse, e as ActionOptions, R as RequestConfig, f as ActionStateModule, Q as QueryOptions, g as UseApiQuery, h as ApiError, L as LogLevel } from './apiModule.types-BTtRM9wO.js';
|
|
3
|
+
export { l as ActionConfig, n as ActionState, a as ApiModuleConfig, E as ExecutableAction, o as ExecuteOptions, I as InputOf, j as Middleware, M as MiddlewareContext, p as ModuleActions, q as ModuleStates, O as OutputOf, P as PaginationMeta, k as RefreshTokenConfig, i as TokenManager, T as Tokens, U as UseApiConfig, b as UseApiModuleOptions, c as UseApiModuleReturn, m as UseApiState, V as ValidationError } from './apiModule.types-BTtRM9wO.js';
|
|
4
|
+
export { c as UseApiRecordActions, U as UseApiRecordConfig, a as UseApiRecordReturn, b as UseApiRecordState } from './useApiRecord.types-BsOSJZ5l.js';
|
|
5
5
|
import 'react';
|
|
6
6
|
|
|
7
7
|
declare function createApiClient(config: ApiClientConfig): AxiosInstance;
|
|
@@ -144,6 +144,19 @@ declare class CacheManager {
|
|
|
144
144
|
}
|
|
145
145
|
declare const cacheManager: CacheManager;
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* يقوم بإنشاء مفتاح تخزين مؤقت فريد وثابت لإجراء معين ومدخلاته.
|
|
149
|
+
* هذا يضمن أن نفس الطلب ينتج دائمًا نفس المفتاح.
|
|
150
|
+
* @param moduleName - عادةً ما يكون `baseEndpoint` للموديول.
|
|
151
|
+
* @param actionName - اسم الإجراء (مثل 'list', 'create').
|
|
152
|
+
* @param input - بيانات الطلب (body/query params).
|
|
153
|
+
* @param callOptions - خيارات إضافية مثل `pathParams`.
|
|
154
|
+
* @returns سلسلة نصية فريدة تمثل مفتاح التخزين المؤقت.
|
|
155
|
+
*/
|
|
156
|
+
declare const generateCacheKey: (moduleName: string, actionName: string, input?: unknown, callOptions?: {
|
|
157
|
+
pathParams?: Record<string, any>;
|
|
158
|
+
}) => string;
|
|
159
|
+
|
|
147
160
|
/**
|
|
148
161
|
* @file src/hooks/useApi.types.ts
|
|
149
162
|
* @description This file defines the professional, publicly-facing types for the `useApi` hook,
|
|
@@ -225,4 +238,4 @@ interface UseApiResourceReturn<T, TCreate, TUpdate, TPathParams> {
|
|
|
225
238
|
setQuery: React.Dispatch<React.SetStateAction<QueryOptions>>;
|
|
226
239
|
}
|
|
227
240
|
|
|
228
|
-
export { ActionConfigModule, ActionOptions, ActionStateModule, ApiClientConfig, ApiError, type ApiResourceStatus, LogLevel, QueryOptions, RequestConfig, StandardResponse, type UseApiActions, UseApiQuery, type UseApiResourceActions, type UseApiResourceConfig, type UseApiResourceReturn, type UseApiResourceState, type UseApiReturn, buildPaginateQuery, cacheManager, callDynamicApi, createApiActions, createApiClient, createApiServices, globalStateManager, processResponse };
|
|
241
|
+
export { ActionConfigModule, ActionOptions, ActionStateModule, ApiClientConfig, ApiError, type ApiResourceStatus, LogLevel, QueryOptions, RequestConfig, StandardResponse, type UseApiActions, UseApiQuery, type UseApiResourceActions, type UseApiResourceConfig, type UseApiResourceReturn, type UseApiResourceState, type UseApiReturn, buildPaginateQuery, cacheManager, callDynamicApi, createApiActions, createApiClient, createApiServices, generateCacheKey, globalStateManager, processResponse };
|
package/dist/index.js
CHANGED
|
@@ -649,6 +649,17 @@ var CacheManager = class {
|
|
|
649
649
|
}
|
|
650
650
|
};
|
|
651
651
|
var cacheManager = new CacheManager();
|
|
652
|
+
|
|
653
|
+
// src/core/cacheKey.ts
|
|
654
|
+
var generateCacheKey = (moduleName, actionName, input, callOptions = {}) => {
|
|
655
|
+
const params = { path: callOptions.pathParams, body: input };
|
|
656
|
+
try {
|
|
657
|
+
return `${moduleName}/${actionName}::${JSON.stringify(params)}`;
|
|
658
|
+
} catch (error) {
|
|
659
|
+
console.warn("Could not stringify cache key params, falling back to timestamp.", { moduleName, actionName, error });
|
|
660
|
+
return `${moduleName}/${actionName}::${Date.now()}`;
|
|
661
|
+
}
|
|
662
|
+
};
|
|
652
663
|
export {
|
|
653
664
|
buildPaginateQuery,
|
|
654
665
|
cacheManager,
|
|
@@ -656,6 +667,7 @@ export {
|
|
|
656
667
|
createApiActions,
|
|
657
668
|
createApiClient,
|
|
658
669
|
createApiServices,
|
|
670
|
+
generateCacheKey,
|
|
659
671
|
globalStateManager,
|
|
660
672
|
processResponse
|
|
661
673
|
};
|
package/dist/server.cjs
CHANGED
|
@@ -286,15 +286,18 @@ var GlobalStateManager = class {
|
|
|
286
286
|
};
|
|
287
287
|
var globalStateManager = new GlobalStateManager();
|
|
288
288
|
|
|
289
|
-
// src/
|
|
289
|
+
// src/core/cacheKey.ts
|
|
290
290
|
var generateCacheKey = (moduleName, actionName, input, callOptions = {}) => {
|
|
291
291
|
const params = { path: callOptions.pathParams, body: input };
|
|
292
292
|
try {
|
|
293
293
|
return `${moduleName}/${actionName}::${JSON.stringify(params)}`;
|
|
294
294
|
} catch (error) {
|
|
295
|
+
console.warn("Could not stringify cache key params, falling back to timestamp.", { moduleName, actionName, error });
|
|
295
296
|
return `${moduleName}/${actionName}::${Date.now()}`;
|
|
296
297
|
}
|
|
297
298
|
};
|
|
299
|
+
|
|
300
|
+
// src/server.ts
|
|
298
301
|
function createServerApi(apiClient, moduleConfig) {
|
|
299
302
|
return {
|
|
300
303
|
/**
|
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-BTtRM9wO.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-BTtRM9wO.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/server.js
CHANGED
|
@@ -252,15 +252,18 @@ var GlobalStateManager = class {
|
|
|
252
252
|
};
|
|
253
253
|
var globalStateManager = new GlobalStateManager();
|
|
254
254
|
|
|
255
|
-
// src/
|
|
255
|
+
// src/core/cacheKey.ts
|
|
256
256
|
var generateCacheKey = (moduleName, actionName, input, callOptions = {}) => {
|
|
257
257
|
const params = { path: callOptions.pathParams, body: input };
|
|
258
258
|
try {
|
|
259
259
|
return `${moduleName}/${actionName}::${JSON.stringify(params)}`;
|
|
260
260
|
} catch (error) {
|
|
261
|
+
console.warn("Could not stringify cache key params, falling back to timestamp.", { moduleName, actionName, error });
|
|
261
262
|
return `${moduleName}/${actionName}::${Date.now()}`;
|
|
262
263
|
}
|
|
263
264
|
};
|
|
265
|
+
|
|
266
|
+
// src/server.ts
|
|
264
267
|
function createServerApi(apiClient, moduleConfig) {
|
|
265
268
|
return {
|
|
266
269
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { R as RequestConfig, h as ApiError, S as StandardResponse, e as ActionOptions } from './apiModule.types-
|
|
2
|
+
import { R as RequestConfig, h as ApiError, S as StandardResponse, e as ActionOptions } from './apiModule.types-BTtRM9wO.js';
|
|
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, h as ApiError, S as StandardResponse, e as ActionOptions } from './apiModule.types-
|
|
2
|
+
import { R as RequestConfig, h as ApiError, S as StandardResponse, e as ActionOptions } from './apiModule.types-BTtRM9wO.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents the internal state of the `useApiRecord` hook.
|