api-core-lib 16.2.0 → 16.12.134

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 CHANGED
@@ -0,0 +1 @@
1
+ "build": "tsup && node scripts/obfuscate.js",
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+
3
+ // bin/cli-launcher.js
4
+ // هذا الملف هو مجرد مشغّل بسيط بصيغة CommonJS.
5
+ // وظيفته الوحيدة هي تحميل وتشغيل منطق الـ CLI الفعلي من مجلد dist.
6
+
7
+ try {
8
+ // استدعاء المنطق الرئيسي للـ CLI الذي تم بناؤه بواسطة tsup
9
+ require('../dist/cli.cjs');
10
+ } catch (error) {
11
+ console.error('Failed to start the API Core generator.');
12
+ console.error(error);
13
+ process.exit(1);
14
+ }
@@ -0,0 +1,278 @@
1
+ import { AxiosRequestConfig, AxiosProgressEvent, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
2
+ import react__default from 'react';
3
+
4
+ /**
5
+ * يمثل معلومات الترقيم (Pagination) التي قد تعود من ה-API.
6
+ */
7
+ interface PaginationMeta {
8
+ itemsPerPage: number;
9
+ totalItems: number;
10
+ currentPage: number;
11
+ totalPages: number;
12
+ [key: string]: any;
13
+ }
14
+ /**
15
+ * يمثل خطأ تحقق واحد لحقل معين.
16
+ */
17
+ interface ValidationError {
18
+ field: string;
19
+ message: string;
20
+ }
21
+ /**
22
+ * يمثل كائن الخطأ الموحد الذي تنتجه المكتبة.
23
+ */
24
+ interface ApiError {
25
+ message: string;
26
+ status: number;
27
+ code?: string;
28
+ errors?: ValidationError[];
29
+ requestId?: string;
30
+ }
31
+ /**
32
+ * الكائن القياسي والموحد الذي تعيده جميع دوال المكتبة.
33
+ * هذا هو النوع الأساسي الذي سيتعامل معه المطورون.
34
+ * @template T نوع البيانات الأساسية.
35
+ */
36
+ interface StandardResponse<T> {
37
+ data: T | null;
38
+ links?: Record<string, string | null>;
39
+ meta?: PaginationMeta | Record<string, any>;
40
+ rawResponse: any;
41
+ error: ApiError | null;
42
+ loading: boolean;
43
+ success: boolean;
44
+ message?: string;
45
+ validationErrors?: ValidationError[];
46
+ }
47
+ interface Tokens {
48
+ accessToken: string | null;
49
+ refreshToken: string | null;
50
+ expiresAt?: number;
51
+ tokenType?: string;
52
+ }
53
+ interface TokenManager {
54
+ getTokens(): Promise<Tokens>;
55
+ setTokens(tokens: Tokens): Promise<void>;
56
+ clearTokens(): Promise<void>;
57
+ isHttpOnly(): boolean;
58
+ }
59
+ interface MiddlewareContext {
60
+ req: InternalAxiosRequestConfig;
61
+ res?: AxiosResponse;
62
+ error?: any;
63
+ custom?: Record<string, any>;
64
+ }
65
+ type Middleware = (context: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
66
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
67
+ interface RefreshTokenConfig {
68
+ path: string;
69
+ buildRequestBody?: (refreshToken: string) => Record<string, any>;
70
+ buildRequestHeaders?: (currentTokens: Tokens) => Record<string, string>;
71
+ extractTokens: (responseData: any) => {
72
+ accessToken: string;
73
+ refreshToken?: string;
74
+ expiresIn: number;
75
+ tokenType?: string;
76
+ };
77
+ }
78
+ interface ApiClientConfig {
79
+ baseURL?: string;
80
+ tokenManager: TokenManager;
81
+ timeout?: number;
82
+ headers?: Record<string, string>;
83
+ withCredentials?: boolean;
84
+ refreshTokenConfig?: RefreshTokenConfig;
85
+ onRefreshError?: (error: any) => void;
86
+ middleware?: Middleware[];
87
+ logLevel?: LogLevel;
88
+ defaultIsPublic?: boolean;
89
+ maxTokenRefreshRetries?: number;
90
+ maxQueueSize?: number;
91
+ }
92
+ interface RequestConfig extends AxiosRequestConfig {
93
+ isPublic?: boolean;
94
+ upload?: boolean;
95
+ cancelTokenKey?: string;
96
+ onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
97
+ onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
98
+ }
99
+ interface QueryOptions {
100
+ page?: number;
101
+ limit?: number;
102
+ search?: string;
103
+ sortBy?: {
104
+ key: string;
105
+ direction: 'asc' | 'desc';
106
+ }[];
107
+ filter?: Record<string, any>;
108
+ [key: string]: any;
109
+ }
110
+ interface ActionOptions extends RequestConfig {
111
+ endpoint?: string;
112
+ refetch?: boolean;
113
+ upload?: boolean;
114
+ }
115
+ /**
116
+ * يمثل إعدادات إجراء واحد داخل الموديول.
117
+ */
118
+ interface ActionConfig<TInput = any, TOutput = any> {
119
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
120
+ path: string;
121
+ description?: string;
122
+ isList?: boolean;
123
+ invalidates?: string[];
124
+ }
125
+ /**
126
+ * [مُحدَّث] يمثل الحالة التفاعلية الكاملة لإجراء واحد.
127
+ * هذا هو النوع الذي يتم إرجاعه في `states` من الهوك.
128
+ */
129
+ interface ActionStateModule<TOutput> {
130
+ data: TOutput | null;
131
+ links?: Record<string, string | null>;
132
+ meta?: PaginationMeta | Record<string, any>;
133
+ error: ApiError | null;
134
+ loading: boolean;
135
+ success: boolean;
136
+ called: boolean;
137
+ message?: string;
138
+ validationErrors?: ValidationError[];
139
+ rawResponse: any | null;
140
+ isStale?: boolean;
141
+ lastSuccessAt?: number;
142
+ }
143
+ /**
144
+ * الكائن الموحد الذي يتم إرجاعه لكل إجراء، ويحتوي على حالته ومنفذه وأدوات التحكم.
145
+ */
146
+ interface ExecutableAction<TInput, TOutput> {
147
+ state: ActionStateModule<TOutput>;
148
+ execute: (input?: TInput, options?: {
149
+ pathParams?: Record<string, any>;
150
+ config?: AxiosRequestConfig;
151
+ query?: QueryOptions;
152
+ }) => Promise<StandardResponse<TOutput>>;
153
+ reset: () => void;
154
+ query?: UseApiQuery;
155
+ }
156
+ type UseApiState<T> = StandardResponse<T>;
157
+ interface UseApiQuery {
158
+ /** The current query options state. */
159
+ options: QueryOptions;
160
+ /** A function to set the entire query options object at once. */
161
+ setOptions: react__default.Dispatch<react__default.SetStateAction<QueryOptions>>;
162
+ /** Sets the current page number. */
163
+ setPage: (page: number) => void;
164
+ /** Sets the number of items per page and resets to the first page. */
165
+ setLimit: (limit: number) => void;
166
+ /** Sets the search term and resets to the first page. */
167
+ setSearchTerm: (search: string) => void;
168
+ /** Sets the sorting configuration. */
169
+ setSorting: (sortBy: {
170
+ key: string;
171
+ direction: 'asc' | 'desc';
172
+ }[]) => void;
173
+ /** Sets the filter object and resets to the first page. */
174
+ setFilters: (filter: Record<string, any>) => void;
175
+ /** Sets a single, custom query parameter. */
176
+ setQueryParam: (key: string, value: any) => void;
177
+ /** Resets the query options to their initial state. */
178
+ reset: () => void;
179
+ /** Re-fetches the query using the last used query options. */
180
+ refetch: () => void;
181
+ }
182
+ interface UseApiConfig<T> {
183
+ endpoint: string;
184
+ initialData?: T | null;
185
+ initialQuery?: QueryOptions;
186
+ enabled?: boolean;
187
+ refetchAfterChange?: boolean;
188
+ requestConfig?: RequestConfig;
189
+ pathParams?: Record<string, string | number>;
190
+ encodeQuery?: boolean;
191
+ onSuccess?: (message: string, data?: T) => void;
192
+ onError?: (message: string, error?: ApiError) => void;
193
+ }
194
+ interface t {
195
+ type: string;
196
+ payload?: any;
197
+ }
198
+
199
+ interface ActionState<TOutput> extends ActionStateModule<TOutput> {
200
+ isStale?: boolean;
201
+ }
202
+ interface ActionConfigModule<TInput extends Record<string, any> | undefined = undefined, TOutput = unknown> {
203
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
204
+ path: string;
205
+ description?: string;
206
+ hasQuery?: boolean;
207
+ autoFetch?: boolean;
208
+ cacheResponse?: boolean;
209
+ upload?: boolean;
210
+ invalidates?: string[];
211
+ requiresAuth?: boolean;
212
+ pathParams?: string[];
213
+ _input?: TInput;
214
+ _output?: TOutput;
215
+ }
216
+ interface ApiModuleConfig<TActions extends Record<string, ActionConfigModule<any, any>>> {
217
+ baseEndpoint: string;
218
+ actions: TActions;
219
+ }
220
+ interface UrlSyncOptions<TModule extends ApiModuleConfig<any>> {
221
+ searchParams: string;
222
+ updateUrl: (newSearchParams: string) => void;
223
+ actionsToSync: (keyof TModule['actions'])[];
224
+ defaultSyncAction?: keyof TModule['actions'];
225
+ }
226
+ interface UseApiModuleOptions<TModule extends ApiModuleConfig<any>, TExtra = {}> {
227
+ onSuccess?: (actionName: string, message: string, data: unknown) => void;
228
+ onError?: (actionName: string, message: string, error?: ApiError | null) => void;
229
+ refetchOnWindowFocus?: boolean;
230
+ pathParams?: Record<string, any>;
231
+ enabled?: boolean;
232
+ hydratedState?: string;
233
+ extraContextData?: TExtra;
234
+ urlSync?: UrlSyncOptions<TModule>;
235
+ defaultQueryOptions?: Partial<Record<keyof TModule['actions'], QueryOptions>>;
236
+ initialActionsToExecute?: (keyof TModule['actions'])[];
237
+ }
238
+ type InputOf<TActionConfig> = TActionConfig extends ActionConfigModule<infer TInput, any> ? TInput : never;
239
+ type OutputOf<TActionConfig> = TActionConfig extends ActionConfigModule<any, infer TOutput> ? TOutput : never;
240
+ interface ExecuteOptions<TInput, TOutput, TContext = unknown> {
241
+ pathParams?: Record<string, any>;
242
+ config?: AxiosRequestConfig;
243
+ onMutate?: (variables: TInput) => TContext | Promise<TContext>;
244
+ onSuccess?: (data: TOutput, context?: TContext) => void;
245
+ onError?: (error: ApiError, context?: TContext) => void;
246
+ onSettled?: (data?: TOutput, error?: ApiError, context?: TContext) => void;
247
+ }
248
+ type ModuleActions<TActions extends Record<string, ActionConfigModule<any, any>>> = {
249
+ [K in keyof TActions]: {
250
+ execute: <TContext = unknown>(input?: InputOf<TActions[K]>, options?: ExecuteOptions<InputOf<TActions[K]>, OutputOf<TActions[K]>, TContext>) => Promise<StandardResponse<OutputOf<TActions[K]>>>;
251
+ reset: (input?: InputOf<TActions[K]>, options?: {
252
+ pathParams?: Record<string, any>;
253
+ }) => void;
254
+ };
255
+ };
256
+ type ModuleStates<TActions extends Record<string, ActionConfigModule<any, any>>> = {
257
+ [K in keyof TActions]: ActionState<OutputOf<TActions[K]>>;
258
+ };
259
+ type ActionsWithQuery<TActions extends Record<string, ActionConfigModule<any, any>>> = {
260
+ [K in keyof TActions]: TActions[K] extends ActionConfigModule<QueryOptions, any> ? K : never;
261
+ }[keyof TActions];
262
+ type ModuleQueries<TActions extends Record<string, ActionConfigModule<any, any>>> = {
263
+ [K in ActionsWithQuery<TActions>]: UseApiQuery;
264
+ };
265
+ type UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<any, any>>, TExtra extends object = {}> = {
266
+ states: ModuleStates<TActions>;
267
+ actions: ModuleActions<TActions>;
268
+ queries: ModuleQueries<TActions>;
269
+ dehydrate: () => string;
270
+ } & TExtra;
271
+ type ActionMethods<TAction extends ActionConfigModule<any, any>> = {
272
+ execute: <TContext = unknown>(input?: InputOf<TAction>, options?: ExecuteOptions<InputOf<TAction>, OutputOf<TAction>, TContext>) => Promise<StandardResponse<OutputOf<TAction>>>;
273
+ reset: (input?: InputOf<TAction>, options?: {
274
+ pathParams?: Record<string, any>;
275
+ }) => void;
276
+ };
277
+
278
+ export type { ApiModuleConfig 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, UseApiModuleOptions as a, UseApiModuleReturn as b, ModuleActions as c, ModuleQueries as d, ApiClientConfig as e, ActionConfigModule as f, ActionOptions as g, ActionStateModule as h, UseApiQuery as i, ApiError as j, TokenManager as k, MiddlewareContext as l, Middleware as m, RefreshTokenConfig as n, ActionConfig as o, UseApiState as p, ActionState as q, UrlSyncOptions as r, ExecuteOptions as s, t, ActionsWithQuery as u, ActionMethods as v };
@@ -0,0 +1,278 @@
1
+ import { AxiosRequestConfig, AxiosProgressEvent, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
2
+ import react__default from 'react';
3
+
4
+ /**
5
+ * يمثل معلومات الترقيم (Pagination) التي قد تعود من ה-API.
6
+ */
7
+ interface PaginationMeta {
8
+ itemsPerPage: number;
9
+ totalItems: number;
10
+ currentPage: number;
11
+ totalPages: number;
12
+ [key: string]: any;
13
+ }
14
+ /**
15
+ * يمثل خطأ تحقق واحد لحقل معين.
16
+ */
17
+ interface ValidationError {
18
+ field: string;
19
+ message: string;
20
+ }
21
+ /**
22
+ * يمثل كائن الخطأ الموحد الذي تنتجه المكتبة.
23
+ */
24
+ interface ApiError {
25
+ message: string;
26
+ status: number;
27
+ code?: string;
28
+ errors?: ValidationError[];
29
+ requestId?: string;
30
+ }
31
+ /**
32
+ * الكائن القياسي والموحد الذي تعيده جميع دوال المكتبة.
33
+ * هذا هو النوع الأساسي الذي سيتعامل معه المطورون.
34
+ * @template T نوع البيانات الأساسية.
35
+ */
36
+ interface StandardResponse<T> {
37
+ data: T | null;
38
+ links?: Record<string, string | null>;
39
+ meta?: PaginationMeta | Record<string, any>;
40
+ rawResponse: any;
41
+ error: ApiError | null;
42
+ loading: boolean;
43
+ success: boolean;
44
+ message?: string;
45
+ validationErrors?: ValidationError[];
46
+ }
47
+ interface Tokens {
48
+ accessToken: string | null;
49
+ refreshToken: string | null;
50
+ expiresAt?: number;
51
+ tokenType?: string;
52
+ }
53
+ interface TokenManager {
54
+ getTokens(): Promise<Tokens>;
55
+ setTokens(tokens: Tokens): Promise<void>;
56
+ clearTokens(): Promise<void>;
57
+ isHttpOnly(): boolean;
58
+ }
59
+ interface MiddlewareContext {
60
+ req: InternalAxiosRequestConfig;
61
+ res?: AxiosResponse;
62
+ error?: any;
63
+ custom?: Record<string, any>;
64
+ }
65
+ type Middleware = (context: MiddlewareContext, next: () => Promise<void>) => Promise<void>;
66
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
67
+ interface RefreshTokenConfig {
68
+ path: string;
69
+ buildRequestBody?: (refreshToken: string) => Record<string, any>;
70
+ buildRequestHeaders?: (currentTokens: Tokens) => Record<string, string>;
71
+ extractTokens: (responseData: any) => {
72
+ accessToken: string;
73
+ refreshToken?: string;
74
+ expiresIn: number;
75
+ tokenType?: string;
76
+ };
77
+ }
78
+ interface ApiClientConfig {
79
+ baseURL?: string;
80
+ tokenManager: TokenManager;
81
+ timeout?: number;
82
+ headers?: Record<string, string>;
83
+ withCredentials?: boolean;
84
+ refreshTokenConfig?: RefreshTokenConfig;
85
+ onRefreshError?: (error: any) => void;
86
+ middleware?: Middleware[];
87
+ logLevel?: LogLevel;
88
+ defaultIsPublic?: boolean;
89
+ maxTokenRefreshRetries?: number;
90
+ maxQueueSize?: number;
91
+ }
92
+ interface RequestConfig extends AxiosRequestConfig {
93
+ isPublic?: boolean;
94
+ upload?: boolean;
95
+ cancelTokenKey?: string;
96
+ onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
97
+ onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
98
+ }
99
+ interface QueryOptions {
100
+ page?: number;
101
+ limit?: number;
102
+ search?: string;
103
+ sortBy?: {
104
+ key: string;
105
+ direction: 'asc' | 'desc';
106
+ }[];
107
+ filter?: Record<string, any>;
108
+ [key: string]: any;
109
+ }
110
+ interface ActionOptions extends RequestConfig {
111
+ endpoint?: string;
112
+ refetch?: boolean;
113
+ upload?: boolean;
114
+ }
115
+ /**
116
+ * يمثل إعدادات إجراء واحد داخل الموديول.
117
+ */
118
+ interface ActionConfig<TInput = any, TOutput = any> {
119
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
120
+ path: string;
121
+ description?: string;
122
+ isList?: boolean;
123
+ invalidates?: string[];
124
+ }
125
+ /**
126
+ * [مُحدَّث] يمثل الحالة التفاعلية الكاملة لإجراء واحد.
127
+ * هذا هو النوع الذي يتم إرجاعه في `states` من الهوك.
128
+ */
129
+ interface ActionStateModule<TOutput> {
130
+ data: TOutput | null;
131
+ links?: Record<string, string | null>;
132
+ meta?: PaginationMeta | Record<string, any>;
133
+ error: ApiError | null;
134
+ loading: boolean;
135
+ success: boolean;
136
+ called: boolean;
137
+ message?: string;
138
+ validationErrors?: ValidationError[];
139
+ rawResponse: any | null;
140
+ isStale?: boolean;
141
+ lastSuccessAt?: number;
142
+ }
143
+ /**
144
+ * الكائن الموحد الذي يتم إرجاعه لكل إجراء، ويحتوي على حالته ومنفذه وأدوات التحكم.
145
+ */
146
+ interface ExecutableAction<TInput, TOutput> {
147
+ state: ActionStateModule<TOutput>;
148
+ execute: (input?: TInput, options?: {
149
+ pathParams?: Record<string, any>;
150
+ config?: AxiosRequestConfig;
151
+ query?: QueryOptions;
152
+ }) => Promise<StandardResponse<TOutput>>;
153
+ reset: () => void;
154
+ query?: UseApiQuery;
155
+ }
156
+ type UseApiState<T> = StandardResponse<T>;
157
+ interface UseApiQuery {
158
+ /** The current query options state. */
159
+ options: QueryOptions;
160
+ /** A function to set the entire query options object at once. */
161
+ setOptions: react__default.Dispatch<react__default.SetStateAction<QueryOptions>>;
162
+ /** Sets the current page number. */
163
+ setPage: (page: number) => void;
164
+ /** Sets the number of items per page and resets to the first page. */
165
+ setLimit: (limit: number) => void;
166
+ /** Sets the search term and resets to the first page. */
167
+ setSearchTerm: (search: string) => void;
168
+ /** Sets the sorting configuration. */
169
+ setSorting: (sortBy: {
170
+ key: string;
171
+ direction: 'asc' | 'desc';
172
+ }[]) => void;
173
+ /** Sets the filter object and resets to the first page. */
174
+ setFilters: (filter: Record<string, any>) => void;
175
+ /** Sets a single, custom query parameter. */
176
+ setQueryParam: (key: string, value: any) => void;
177
+ /** Resets the query options to their initial state. */
178
+ reset: () => void;
179
+ /** Re-fetches the query using the last used query options. */
180
+ refetch: () => void;
181
+ }
182
+ interface UseApiConfig<T> {
183
+ endpoint: string;
184
+ initialData?: T | null;
185
+ initialQuery?: QueryOptions;
186
+ enabled?: boolean;
187
+ refetchAfterChange?: boolean;
188
+ requestConfig?: RequestConfig;
189
+ pathParams?: Record<string, string | number>;
190
+ encodeQuery?: boolean;
191
+ onSuccess?: (message: string, data?: T) => void;
192
+ onError?: (message: string, error?: ApiError) => void;
193
+ }
194
+ interface t {
195
+ type: string;
196
+ payload?: any;
197
+ }
198
+
199
+ interface ActionState<TOutput> extends ActionStateModule<TOutput> {
200
+ isStale?: boolean;
201
+ }
202
+ interface ActionConfigModule<TInput extends Record<string, any> | undefined = undefined, TOutput = unknown> {
203
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
204
+ path: string;
205
+ description?: string;
206
+ hasQuery?: boolean;
207
+ autoFetch?: boolean;
208
+ cacheResponse?: boolean;
209
+ upload?: boolean;
210
+ invalidates?: string[];
211
+ requiresAuth?: boolean;
212
+ pathParams?: string[];
213
+ _input?: TInput;
214
+ _output?: TOutput;
215
+ }
216
+ interface ApiModuleConfig<TActions extends Record<string, ActionConfigModule<any, any>>> {
217
+ baseEndpoint: string;
218
+ actions: TActions;
219
+ }
220
+ interface UrlSyncOptions<TModule extends ApiModuleConfig<any>> {
221
+ searchParams: string;
222
+ updateUrl: (newSearchParams: string) => void;
223
+ actionsToSync: (keyof TModule['actions'])[];
224
+ defaultSyncAction?: keyof TModule['actions'];
225
+ }
226
+ interface UseApiModuleOptions<TModule extends ApiModuleConfig<any>, TExtra = {}> {
227
+ onSuccess?: (actionName: string, message: string, data: unknown) => void;
228
+ onError?: (actionName: string, message: string, error?: ApiError | null) => void;
229
+ refetchOnWindowFocus?: boolean;
230
+ pathParams?: Record<string, any>;
231
+ enabled?: boolean;
232
+ hydratedState?: string;
233
+ extraContextData?: TExtra;
234
+ urlSync?: UrlSyncOptions<TModule>;
235
+ defaultQueryOptions?: Partial<Record<keyof TModule['actions'], QueryOptions>>;
236
+ initialActionsToExecute?: (keyof TModule['actions'])[];
237
+ }
238
+ type InputOf<TActionConfig> = TActionConfig extends ActionConfigModule<infer TInput, any> ? TInput : never;
239
+ type OutputOf<TActionConfig> = TActionConfig extends ActionConfigModule<any, infer TOutput> ? TOutput : never;
240
+ interface ExecuteOptions<TInput, TOutput, TContext = unknown> {
241
+ pathParams?: Record<string, any>;
242
+ config?: AxiosRequestConfig;
243
+ onMutate?: (variables: TInput) => TContext | Promise<TContext>;
244
+ onSuccess?: (data: TOutput, context?: TContext) => void;
245
+ onError?: (error: ApiError, context?: TContext) => void;
246
+ onSettled?: (data?: TOutput, error?: ApiError, context?: TContext) => void;
247
+ }
248
+ type ModuleActions<TActions extends Record<string, ActionConfigModule<any, any>>> = {
249
+ [K in keyof TActions]: {
250
+ execute: <TContext = unknown>(input?: InputOf<TActions[K]>, options?: ExecuteOptions<InputOf<TActions[K]>, OutputOf<TActions[K]>, TContext>) => Promise<StandardResponse<OutputOf<TActions[K]>>>;
251
+ reset: (input?: InputOf<TActions[K]>, options?: {
252
+ pathParams?: Record<string, any>;
253
+ }) => void;
254
+ };
255
+ };
256
+ type ModuleStates<TActions extends Record<string, ActionConfigModule<any, any>>> = {
257
+ [K in keyof TActions]: ActionState<OutputOf<TActions[K]>>;
258
+ };
259
+ type ActionsWithQuery<TActions extends Record<string, ActionConfigModule<any, any>>> = {
260
+ [K in keyof TActions]: TActions[K] extends ActionConfigModule<QueryOptions, any> ? K : never;
261
+ }[keyof TActions];
262
+ type ModuleQueries<TActions extends Record<string, ActionConfigModule<any, any>>> = {
263
+ [K in ActionsWithQuery<TActions>]: UseApiQuery;
264
+ };
265
+ type UseApiModuleReturn<TActions extends Record<string, ActionConfigModule<any, any>>, TExtra extends object = {}> = {
266
+ states: ModuleStates<TActions>;
267
+ actions: ModuleActions<TActions>;
268
+ queries: ModuleQueries<TActions>;
269
+ dehydrate: () => string;
270
+ } & TExtra;
271
+ type ActionMethods<TAction extends ActionConfigModule<any, any>> = {
272
+ execute: <TContext = unknown>(input?: InputOf<TAction>, options?: ExecuteOptions<InputOf<TAction>, OutputOf<TAction>, TContext>) => Promise<StandardResponse<OutputOf<TAction>>>;
273
+ reset: (input?: InputOf<TAction>, options?: {
274
+ pathParams?: Record<string, any>;
275
+ }) => void;
276
+ };
277
+
278
+ export type { ApiModuleConfig 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, UseApiModuleOptions as a, UseApiModuleReturn as b, ModuleActions as c, ModuleQueries as d, ApiClientConfig as e, ActionConfigModule as f, ActionOptions as g, ActionStateModule as h, UseApiQuery as i, ApiError as j, TokenManager as k, MiddlewareContext as l, Middleware as m, RefreshTokenConfig as n, ActionConfig as o, UseApiState as p, ActionState as q, UrlSyncOptions as r, ExecuteOptions as s, t, ActionsWithQuery as u, ActionMethods as v };