api-core-lib 12.11.4 → 12.12.4
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 +42 -8
- package/dist/index.d.ts +42 -8
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -211,14 +211,6 @@ interface ApiModuleConfig<TActions extends Record<string, ActionConfigModule<any
|
|
|
211
211
|
baseEndpoint: string;
|
|
212
212
|
actions: TActions;
|
|
213
213
|
}
|
|
214
|
-
/** @description Configuration options passed directly to the `useApiModule` hook. */
|
|
215
|
-
interface UseApiModuleOptions {
|
|
216
|
-
onSuccess?: (actionName: string, message: string, data: unknown) => void;
|
|
217
|
-
onError?: (actionName: string, message: string, error?: ApiError | null) => void;
|
|
218
|
-
refetchOnWindowFocus?: boolean;
|
|
219
|
-
pathParams?: Record<string, any>;
|
|
220
|
-
enabled?: boolean;
|
|
221
|
-
}
|
|
222
214
|
/** A utility type to infer the Input type (`TInput`) from an ActionConfigModule. */
|
|
223
215
|
type InputOf<TActionConfig> = TActionConfig extends ActionConfigModule<infer TInput, any> ? TInput : never;
|
|
224
216
|
/** A utility type to infer the Output type (`TOutput`) from an ActionConfigModule. */
|
|
@@ -244,6 +236,24 @@ type ModuleActions<TActions extends Record<string, ActionConfigModule<any, any>>
|
|
|
244
236
|
type ModuleStates<TActions extends Record<string, ActionConfigModule<any, any>>> = {
|
|
245
237
|
[K in keyof TActions]: ActionState<OutputOf<TActions[K]>>;
|
|
246
238
|
};
|
|
239
|
+
/** @description Configuration options passed directly to the `useApiModule` hook. */
|
|
240
|
+
interface UseApiModuleOptions {
|
|
241
|
+
onSuccess?: (actionName: string, message: string, data: unknown) => void;
|
|
242
|
+
onError?: (actionName: string, message: string, error?: ApiError | null) => void;
|
|
243
|
+
refetchOnWindowFocus?: boolean;
|
|
244
|
+
pathParams?: Record<string, any>;
|
|
245
|
+
enabled?: boolean;
|
|
246
|
+
}
|
|
247
|
+
/** @description Configuration options passed directly to the `useApiModule` hook. */
|
|
248
|
+
interface UseApiModuleOptions {
|
|
249
|
+
onSuccess?: (actionName: string, message: string, data: unknown) => void;
|
|
250
|
+
onError?: (actionName: string, message: string, error?: ApiError | null) => void;
|
|
251
|
+
refetchOnWindowFocus?: boolean;
|
|
252
|
+
pathParams?: Record<string, any>;
|
|
253
|
+
enabled?: boolean;
|
|
254
|
+
/** [NEW.............] The dehydrated state string from the server to avoid re-fetching on the client. */
|
|
255
|
+
hydratedState?: string;
|
|
256
|
+
}
|
|
247
257
|
/** @description The complete, fully-typed return object of the `useApiModule` hook. */
|
|
248
258
|
interface UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<any, any>>> {
|
|
249
259
|
states: ModuleStates<TActions>;
|
|
@@ -254,6 +264,18 @@ interface UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<
|
|
|
254
264
|
} ? UseApiQuery : never;
|
|
255
265
|
};
|
|
256
266
|
}
|
|
267
|
+
/** @description The complete, fully-typed return object of the `useApiModule` hook. */
|
|
268
|
+
interface UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<any, any>>> {
|
|
269
|
+
states: ModuleStates<TActions>;
|
|
270
|
+
actions: ModuleActions<TActions>;
|
|
271
|
+
queries: {
|
|
272
|
+
[K in keyof TActions]?: TActions[K] extends {
|
|
273
|
+
hasQuery: true;
|
|
274
|
+
} ? UseApiQuery : never;
|
|
275
|
+
};
|
|
276
|
+
/** [NEW.............] A function to serialize the current state of all queries in the hook's scope to a JSON string. */
|
|
277
|
+
dehydrate: () => string;
|
|
278
|
+
}
|
|
257
279
|
|
|
258
280
|
/**
|
|
259
281
|
* A factory function to create a reusable set of API services for a specific endpoint.
|
|
@@ -489,6 +511,18 @@ declare class GlobalStateManager {
|
|
|
489
511
|
* @example invalidateByPrefix('myModule/list::') سيبطل كل صفحات القائمة.
|
|
490
512
|
*/
|
|
491
513
|
invalidateByPrefix(prefix: string): void;
|
|
514
|
+
/**
|
|
515
|
+
* Serializes the current state of the query store into a JSON string.
|
|
516
|
+
* This is used on the server to pass the initial state to the client.
|
|
517
|
+
* @returns A JSON string representing the dehydrated state.
|
|
518
|
+
*/
|
|
519
|
+
dehydrate(): string;
|
|
520
|
+
/**
|
|
521
|
+
* Merges a dehydrated state object into the current store.
|
|
522
|
+
* This is used on the client to hydrate the state received from the server.
|
|
523
|
+
* @param hydratedState - A JSON string from the `dehydrate` method.
|
|
524
|
+
*/
|
|
525
|
+
rehydrate(hydratedState: string): void;
|
|
492
526
|
}
|
|
493
527
|
declare const globalStateManager: GlobalStateManager;
|
|
494
528
|
|
package/dist/index.d.ts
CHANGED
|
@@ -211,14 +211,6 @@ interface ApiModuleConfig<TActions extends Record<string, ActionConfigModule<any
|
|
|
211
211
|
baseEndpoint: string;
|
|
212
212
|
actions: TActions;
|
|
213
213
|
}
|
|
214
|
-
/** @description Configuration options passed directly to the `useApiModule` hook. */
|
|
215
|
-
interface UseApiModuleOptions {
|
|
216
|
-
onSuccess?: (actionName: string, message: string, data: unknown) => void;
|
|
217
|
-
onError?: (actionName: string, message: string, error?: ApiError | null) => void;
|
|
218
|
-
refetchOnWindowFocus?: boolean;
|
|
219
|
-
pathParams?: Record<string, any>;
|
|
220
|
-
enabled?: boolean;
|
|
221
|
-
}
|
|
222
214
|
/** A utility type to infer the Input type (`TInput`) from an ActionConfigModule. */
|
|
223
215
|
type InputOf<TActionConfig> = TActionConfig extends ActionConfigModule<infer TInput, any> ? TInput : never;
|
|
224
216
|
/** A utility type to infer the Output type (`TOutput`) from an ActionConfigModule. */
|
|
@@ -244,6 +236,24 @@ type ModuleActions<TActions extends Record<string, ActionConfigModule<any, any>>
|
|
|
244
236
|
type ModuleStates<TActions extends Record<string, ActionConfigModule<any, any>>> = {
|
|
245
237
|
[K in keyof TActions]: ActionState<OutputOf<TActions[K]>>;
|
|
246
238
|
};
|
|
239
|
+
/** @description Configuration options passed directly to the `useApiModule` hook. */
|
|
240
|
+
interface UseApiModuleOptions {
|
|
241
|
+
onSuccess?: (actionName: string, message: string, data: unknown) => void;
|
|
242
|
+
onError?: (actionName: string, message: string, error?: ApiError | null) => void;
|
|
243
|
+
refetchOnWindowFocus?: boolean;
|
|
244
|
+
pathParams?: Record<string, any>;
|
|
245
|
+
enabled?: boolean;
|
|
246
|
+
}
|
|
247
|
+
/** @description Configuration options passed directly to the `useApiModule` hook. */
|
|
248
|
+
interface UseApiModuleOptions {
|
|
249
|
+
onSuccess?: (actionName: string, message: string, data: unknown) => void;
|
|
250
|
+
onError?: (actionName: string, message: string, error?: ApiError | null) => void;
|
|
251
|
+
refetchOnWindowFocus?: boolean;
|
|
252
|
+
pathParams?: Record<string, any>;
|
|
253
|
+
enabled?: boolean;
|
|
254
|
+
/** [NEW.............] The dehydrated state string from the server to avoid re-fetching on the client. */
|
|
255
|
+
hydratedState?: string;
|
|
256
|
+
}
|
|
247
257
|
/** @description The complete, fully-typed return object of the `useApiModule` hook. */
|
|
248
258
|
interface UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<any, any>>> {
|
|
249
259
|
states: ModuleStates<TActions>;
|
|
@@ -254,6 +264,18 @@ interface UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<
|
|
|
254
264
|
} ? UseApiQuery : never;
|
|
255
265
|
};
|
|
256
266
|
}
|
|
267
|
+
/** @description The complete, fully-typed return object of the `useApiModule` hook. */
|
|
268
|
+
interface UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<any, any>>> {
|
|
269
|
+
states: ModuleStates<TActions>;
|
|
270
|
+
actions: ModuleActions<TActions>;
|
|
271
|
+
queries: {
|
|
272
|
+
[K in keyof TActions]?: TActions[K] extends {
|
|
273
|
+
hasQuery: true;
|
|
274
|
+
} ? UseApiQuery : never;
|
|
275
|
+
};
|
|
276
|
+
/** [NEW.............] A function to serialize the current state of all queries in the hook's scope to a JSON string. */
|
|
277
|
+
dehydrate: () => string;
|
|
278
|
+
}
|
|
257
279
|
|
|
258
280
|
/**
|
|
259
281
|
* A factory function to create a reusable set of API services for a specific endpoint.
|
|
@@ -489,6 +511,18 @@ declare class GlobalStateManager {
|
|
|
489
511
|
* @example invalidateByPrefix('myModule/list::') سيبطل كل صفحات القائمة.
|
|
490
512
|
*/
|
|
491
513
|
invalidateByPrefix(prefix: string): void;
|
|
514
|
+
/**
|
|
515
|
+
* Serializes the current state of the query store into a JSON string.
|
|
516
|
+
* This is used on the server to pass the initial state to the client.
|
|
517
|
+
* @returns A JSON string representing the dehydrated state.
|
|
518
|
+
*/
|
|
519
|
+
dehydrate(): string;
|
|
520
|
+
/**
|
|
521
|
+
* Merges a dehydrated state object into the current store.
|
|
522
|
+
* This is used on the client to hydrate the state received from the server.
|
|
523
|
+
* @param hydratedState - A JSON string from the `dehydrate` method.
|
|
524
|
+
*/
|
|
525
|
+
rehydrate(hydratedState: string): void;
|
|
492
526
|
}
|
|
493
527
|
declare const globalStateManager: GlobalStateManager;
|
|
494
528
|
|