@robot-admin/request-core 0.2.0 → 0.4.1

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/LICENSE +21 -0
  3. package/README.md +248 -357
  4. package/SECURITY.md +14 -0
  5. package/dist/axios.cjs +134 -809
  6. package/dist/axios.cjs.map +1 -1
  7. package/dist/axios.d.cts +55 -220
  8. package/dist/axios.d.ts +55 -220
  9. package/dist/axios.js +2 -790
  10. package/dist/axios.js.map +1 -1
  11. package/dist/chunk-2JXH7SIL.js +711 -0
  12. package/dist/chunk-2JXH7SIL.js.map +1 -0
  13. package/dist/chunk-56QOEWUS.js +8 -0
  14. package/dist/chunk-56QOEWUS.js.map +1 -0
  15. package/dist/chunk-DUP3Y4DN.js +320 -0
  16. package/dist/chunk-DUP3Y4DN.js.map +1 -0
  17. package/dist/chunk-JGFRUAZT.cjs +1007 -0
  18. package/dist/chunk-JGFRUAZT.cjs.map +1 -0
  19. package/dist/chunk-KHI6XQRN.cjs +717 -0
  20. package/dist/chunk-KHI6XQRN.cjs.map +1 -0
  21. package/dist/chunk-OAZ5BUBU.js +969 -0
  22. package/dist/chunk-OAZ5BUBU.js.map +1 -0
  23. package/dist/chunk-QSDNDTOZ.js +28 -0
  24. package/dist/chunk-QSDNDTOZ.js.map +1 -0
  25. package/dist/chunk-UHXBAFY6.cjs +323 -0
  26. package/dist/chunk-UHXBAFY6.cjs.map +1 -0
  27. package/dist/chunk-WUZ43MLM.cjs +30 -0
  28. package/dist/chunk-WUZ43MLM.cjs.map +1 -0
  29. package/dist/chunk-WXHQXPS4.cjs +10 -0
  30. package/dist/chunk-WXHQXPS4.cjs.map +1 -0
  31. package/dist/crud.cjs +12 -484
  32. package/dist/crud.cjs.map +1 -1
  33. package/dist/crud.d.cts +8 -269
  34. package/dist/crud.d.ts +8 -269
  35. package/dist/crud.js +4 -487
  36. package/dist/crud.js.map +1 -1
  37. package/dist/index.cjs +136 -1302
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +7 -165
  40. package/dist/index.d.ts +7 -165
  41. package/dist/index.js +5 -1283
  42. package/dist/index.js.map +1 -1
  43. package/dist/naive.cjs +14 -0
  44. package/dist/naive.cjs.map +1 -0
  45. package/dist/naive.d.cts +9 -0
  46. package/dist/naive.d.ts +9 -0
  47. package/dist/naive.js +5 -0
  48. package/dist/naive.js.map +1 -0
  49. package/dist/types-BRDRqYFs.d.cts +197 -0
  50. package/dist/types-BVJhlSuh.d.cts +310 -0
  51. package/dist/types-BVJhlSuh.d.ts +310 -0
  52. package/dist/types-CUyibJZX.d.ts +197 -0
  53. package/dist/vue.cjs +93 -0
  54. package/dist/vue.cjs.map +1 -0
  55. package/dist/vue.d.cts +38 -0
  56. package/dist/vue.d.ts +38 -0
  57. package/dist/vue.js +71 -0
  58. package/dist/vue.js.map +1 -0
  59. package/package.json +60 -16
@@ -0,0 +1,310 @@
1
+ import { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError, InternalAxiosRequestConfig } from 'axios';
2
+ import { App } from 'vue';
3
+
4
+ type RequestScope = string | symbol;
5
+ type ConcurrencyPolicy = "allow" | "join" | "takeLatest" | "takeFirst";
6
+ interface DedupeConfig {
7
+ /** @default true for GET/HEAD/OPTIONS, false for mutation methods */
8
+ enabled?: boolean;
9
+ keyGenerator?: (config: AxiosRequestConfig) => string;
10
+ }
11
+ interface CacheConfig {
12
+ /** @default false */
13
+ enabled?: boolean;
14
+ /** Cache lifetime in milliseconds. @default 300000 */
15
+ ttl?: number;
16
+ /** Skip reads while still replacing the stored value. */
17
+ forceUpdate?: boolean;
18
+ /** Optional invalidation tags associated with this entry. */
19
+ tags?: readonly string[];
20
+ /** Additional response-varying request headers included in the cache key. */
21
+ varyHeaders?: readonly string[];
22
+ /** Override the generated cache key for this request. */
23
+ key?: string;
24
+ }
25
+ interface RetryContext {
26
+ attempt: number;
27
+ delay: number;
28
+ elapsed: number;
29
+ error: AxiosError;
30
+ config: EnhancedAxiosRequestConfig;
31
+ }
32
+ interface RetryConfig {
33
+ /** @default false */
34
+ enabled?: boolean;
35
+ /** Number of retry attempts after the initial request. @default 3 */
36
+ count?: number;
37
+ /** Base retry delay in milliseconds. @default 1000 */
38
+ delay?: number;
39
+ /** @default true */
40
+ exponentialBackoff?: boolean;
41
+ /** @default true */
42
+ jitter?: boolean;
43
+ retryableStatusCodes?: number[];
44
+ /** @default GET, HEAD, OPTIONS, PUT and DELETE */
45
+ retryableMethods?: string[];
46
+ /** Maximum delay for one retry. @default 30000 */
47
+ maxDelay?: number;
48
+ /** Maximum elapsed retry time. Zero disables the limit. @default 0 */
49
+ maxElapsedMs?: number;
50
+ /** Honor Retry-After for 429/503 responses. @default true */
51
+ respectRetryAfter?: boolean;
52
+ /** Allow replaying stream-like request bodies. @default false */
53
+ retryUnsafeBody?: boolean;
54
+ shouldRetry?: (error: AxiosError, attempt: number) => boolean | Promise<boolean>;
55
+ onRetry?: (context: RetryContext) => void | Promise<void>;
56
+ }
57
+ interface CancelConfig {
58
+ /** Track the request so it can be canceled by scope or as a group. @default true */
59
+ enabled?: boolean;
60
+ whitelist?: RegExp[];
61
+ scope?: RequestScope;
62
+ }
63
+ interface RequestPolicyDefaults {
64
+ cache?: boolean | CacheConfig;
65
+ retry?: boolean | RetryConfig;
66
+ dedupe?: boolean | DedupeConfig;
67
+ cancel?: boolean | CancelConfig;
68
+ concurrency?: ConcurrencyPolicy;
69
+ }
70
+ interface EnhancedAxiosRequestConfig<D = unknown> extends AxiosRequestConfig<D> {
71
+ dedupe?: boolean | DedupeConfig;
72
+ cache?: boolean | CacheConfig;
73
+ retry?: boolean | RetryConfig;
74
+ cancel?: boolean | CancelConfig;
75
+ concurrency?: ConcurrencyPolicy;
76
+ scope?: RequestScope;
77
+ /** Skip token injection and unauthorized recovery for this request. */
78
+ skipAuth?: boolean;
79
+ /** Skip the client-level error callback for this request. */
80
+ silent?: boolean;
81
+ /** @internal */
82
+ __retryCount?: number;
83
+ /** @internal */
84
+ __retryStartedAt?: number;
85
+ /** @internal */
86
+ __cancelId?: string;
87
+ /** @internal */
88
+ __requestKey?: string;
89
+ /** @internal */
90
+ __fromCache?: boolean;
91
+ /** @internal */
92
+ __cachedResponse?: AxiosResponse;
93
+ /** @internal */
94
+ __abortController?: EnhancedAbortController;
95
+ /** @internal */
96
+ __externalSignal?: AxiosRequestConfig["signal"];
97
+ /** @internal */
98
+ __abortCleanup?: () => void;
99
+ /** @internal */
100
+ __managedByCancel?: boolean;
101
+ /** @internal */
102
+ __handling401?: boolean;
103
+ /** @internal */
104
+ __authRetryCount?: number;
105
+ }
106
+ type EnhancedAxiosInstance = AxiosInstance & {
107
+ request<T = unknown, R = AxiosResponse<T>, D = unknown>(config: EnhancedAxiosRequestConfig<D>): Promise<R>;
108
+ get<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
109
+ delete<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
110
+ head<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
111
+ options<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
112
+ post<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, data?: D, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
113
+ put<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, data?: D, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
114
+ patch<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, data?: D, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
115
+ };
116
+ interface CacheItem<T = unknown> {
117
+ data: T;
118
+ expireAt: number;
119
+ tags?: readonly string[];
120
+ }
121
+ interface CacheStore {
122
+ get<T = unknown>(key: string): T | null;
123
+ set<T = unknown>(key: string, data: T, ttl: number, options?: {
124
+ tags?: readonly string[];
125
+ }): void;
126
+ delete(key: string): boolean;
127
+ clear(): void;
128
+ cleanup?(): void;
129
+ deleteByPrefix?(prefix: string): number;
130
+ deleteByTag?(tag: string): number;
131
+ readonly size: number;
132
+ }
133
+ interface MemoryCacheOptions {
134
+ maxSize?: number;
135
+ clone?: boolean | (<T>(value: T) => T);
136
+ }
137
+ interface RequestKeyParams {
138
+ method?: string;
139
+ url?: string;
140
+ baseURL?: string;
141
+ params?: unknown;
142
+ data?: unknown;
143
+ }
144
+ interface RequestKeyOptions {
145
+ varyHeaders?: readonly string[];
146
+ }
147
+ interface EnhancedAbortController extends AbortController {
148
+ _startTime?: number;
149
+ }
150
+
151
+ interface InterceptorConfig {
152
+ request?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
153
+ requestError?: (error: AxiosError) => unknown;
154
+ response?: (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
155
+ responseError?: (error: AxiosError) => unknown;
156
+ }
157
+ interface FieldAliases {
158
+ data?: string[];
159
+ list?: string[];
160
+ total?: string[];
161
+ }
162
+ interface RequestCoreConfig {
163
+ request?: AxiosRequestConfig;
164
+ interceptors?: InterceptorConfig;
165
+ successCodes?: Array<number | string>;
166
+ fieldAliases?: FieldAliases;
167
+ defaults?: RequestPolicyDefaults;
168
+ cacheStore?: CacheStore;
169
+ }
170
+ /** Returns a defensive copy of the legacy default response configuration. */
171
+ declare function getGlobalConfig(): {
172
+ successCodes: Array<number | string>;
173
+ fieldAliases: {
174
+ data: string[];
175
+ list: string[];
176
+ total: string[];
177
+ };
178
+ };
179
+ /**
180
+ * Creates the 0.2-compatible Vue plugin and selects its Axios instance for
181
+ * global getData/postData helpers.
182
+ *
183
+ * @deprecated Prefer createRequestClient() plus createRequestPlugin().
184
+ */
185
+ declare function createRequestCore(config?: RequestCoreConfig): {
186
+ install(app: App): void;
187
+ axiosInstance: EnhancedAxiosInstance;
188
+ };
189
+
190
+ type RequestErrorKind = "business" | "http" | "network" | "timeout" | "canceled" | "concurrency" | "configuration" | "unknown";
191
+ interface RequestErrorOptions<T = unknown> {
192
+ kind: RequestErrorKind;
193
+ message: string;
194
+ code?: string | number;
195
+ status?: number;
196
+ data?: T;
197
+ requestId?: string;
198
+ retryable?: boolean;
199
+ config?: AxiosRequestConfig;
200
+ cause?: unknown;
201
+ }
202
+ declare class RequestError<T = unknown> extends Error {
203
+ readonly name = "RequestError";
204
+ readonly kind: RequestErrorKind;
205
+ readonly code?: string | number;
206
+ readonly status?: number;
207
+ readonly data?: T;
208
+ readonly requestId?: string;
209
+ readonly retryable: boolean;
210
+ readonly config?: AxiosRequestConfig;
211
+ readonly cause?: unknown;
212
+ constructor(options: RequestErrorOptions<T>);
213
+ }
214
+ declare function isRequestError(error: unknown): error is RequestError;
215
+ declare function isCanceledError(error: unknown): boolean;
216
+ declare function normalizeRequestError(error: unknown): RequestError;
217
+
218
+ type MaybePromise<T> = T | Promise<T>;
219
+ type AuthTokenResult = string | {
220
+ token: string;
221
+ } | null | undefined | void;
222
+ interface RawRequest {
223
+ <T = unknown, D = unknown>(config: EnhancedAxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>;
224
+ }
225
+ interface AuthContext {
226
+ raw: RawRequest;
227
+ signal?: AbortSignal;
228
+ }
229
+ interface RequestAuthConfig {
230
+ getToken: () => MaybePromise<string | null | undefined>;
231
+ applyToken?: (config: InternalAxiosRequestConfig, token: string) => MaybePromise<void>;
232
+ shouldRefresh?: () => MaybePromise<boolean>;
233
+ refresh?: (context: AuthContext) => Promise<AuthTokenResult>;
234
+ reauthenticate?: (context: AuthContext) => Promise<AuthTokenResult>;
235
+ isAuthRequest?: (config: AxiosRequestConfig) => boolean;
236
+ isUnauthorized?: (error: AxiosError) => boolean;
237
+ /** Continue with the existing token if proactive refresh fails. @default true */
238
+ continueOnProactiveRefreshError?: boolean;
239
+ }
240
+ interface BusinessErrorDescriptor<T = unknown> {
241
+ message: string;
242
+ code?: string | number;
243
+ data?: T;
244
+ }
245
+ interface ResponseAdapter {
246
+ isSuccess?: (data: unknown, response: AxiosResponse) => MaybePromise<boolean>;
247
+ getData?: (data: unknown, response: AxiosResponse) => MaybePromise<unknown>;
248
+ getError?: (data: unknown, response: AxiosResponse) => MaybePromise<BusinessErrorDescriptor | string>;
249
+ }
250
+ interface RequestInterceptors {
251
+ request?: (config: InternalAxiosRequestConfig) => MaybePromise<InternalAxiosRequestConfig>;
252
+ requestError?: (error: AxiosError) => unknown;
253
+ response?: (response: AxiosResponse) => MaybePromise<AxiosResponse>;
254
+ responseError?: (error: AxiosError) => unknown;
255
+ }
256
+ interface RequestHooks {
257
+ onRequestStart?: (config: EnhancedAxiosRequestConfig) => MaybePromise<void>;
258
+ onRequestEnd?: (context: {
259
+ config: EnhancedAxiosRequestConfig;
260
+ response: AxiosResponse;
261
+ duration: number;
262
+ fromCache: boolean;
263
+ }) => MaybePromise<void>;
264
+ onError?: (error: RequestError) => MaybePromise<void>;
265
+ }
266
+ interface RequestClientConfig {
267
+ request?: AxiosRequestConfig;
268
+ defaults?: RequestPolicyDefaults;
269
+ cache?: CacheStore | MemoryCacheOptions;
270
+ auth?: RequestAuthConfig;
271
+ response?: ResponseAdapter;
272
+ interceptors?: RequestInterceptors;
273
+ hooks?: RequestHooks;
274
+ /** Make legacy getData/postData helpers point at this client. @default false */
275
+ setAsDefault?: boolean;
276
+ successCodes?: Array<number | string>;
277
+ fieldAliases?: FieldAliases;
278
+ }
279
+ interface RequestConfig<D = unknown> extends EnhancedAxiosRequestConfig<D> {
280
+ }
281
+ interface RequestCacheController {
282
+ clear(): void;
283
+ delete(config: AxiosRequestConfig): boolean;
284
+ invalidatePrefix(prefix: string): number;
285
+ invalidateTag(tag: string): number;
286
+ cleanup(): void;
287
+ readonly size: number;
288
+ }
289
+ interface RequestLifecycleController {
290
+ cancelAll(): void;
291
+ cancelScope(scope: RequestScope): number;
292
+ readonly pending: number;
293
+ }
294
+ interface RequestClient {
295
+ readonly axios: AxiosInstance;
296
+ request<T = unknown, D = unknown>(config: RequestConfig<D>): Promise<T>;
297
+ raw<T = unknown, D = unknown>(config: RequestConfig<D>): Promise<AxiosResponse<T, D>>;
298
+ get<T = unknown>(url: string, config?: RequestConfig): Promise<T>;
299
+ delete<T = unknown>(url: string, config?: RequestConfig): Promise<T>;
300
+ head<T = unknown>(url: string, config?: RequestConfig): Promise<T>;
301
+ options<T = unknown>(url: string, config?: RequestConfig): Promise<T>;
302
+ post<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<T>;
303
+ put<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<T>;
304
+ patch<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<T>;
305
+ readonly cache: RequestCacheController;
306
+ readonly requests: RequestLifecycleController;
307
+ dispose(): void;
308
+ }
309
+
310
+ export { type BusinessErrorDescriptor as B, type CacheConfig as C, type DedupeConfig as D, type EnhancedAxiosInstance as E, type FieldAliases as F, type InterceptorConfig as I, type MemoryCacheOptions as M, type RequestAuthConfig as R, type CacheItem as a, type CacheStore as b, type CancelConfig as c, type ConcurrencyPolicy as d, type EnhancedAxiosRequestConfig as e, type RequestClient as f, type RequestClientConfig as g, type RequestConfig as h, type RequestCoreConfig as i, RequestError as j, type RequestHooks as k, type RequestInterceptors as l, type RequestKeyOptions as m, type RequestKeyParams as n, type RequestPolicyDefaults as o, type RequestScope as p, type ResponseAdapter as q, type RetryConfig as r, type RetryContext as s, createRequestCore as t, getGlobalConfig as u, isCanceledError as v, isRequestError as w, normalizeRequestError as x };
@@ -0,0 +1,310 @@
1
+ import { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError, InternalAxiosRequestConfig } from 'axios';
2
+ import { App } from 'vue';
3
+
4
+ type RequestScope = string | symbol;
5
+ type ConcurrencyPolicy = "allow" | "join" | "takeLatest" | "takeFirst";
6
+ interface DedupeConfig {
7
+ /** @default true for GET/HEAD/OPTIONS, false for mutation methods */
8
+ enabled?: boolean;
9
+ keyGenerator?: (config: AxiosRequestConfig) => string;
10
+ }
11
+ interface CacheConfig {
12
+ /** @default false */
13
+ enabled?: boolean;
14
+ /** Cache lifetime in milliseconds. @default 300000 */
15
+ ttl?: number;
16
+ /** Skip reads while still replacing the stored value. */
17
+ forceUpdate?: boolean;
18
+ /** Optional invalidation tags associated with this entry. */
19
+ tags?: readonly string[];
20
+ /** Additional response-varying request headers included in the cache key. */
21
+ varyHeaders?: readonly string[];
22
+ /** Override the generated cache key for this request. */
23
+ key?: string;
24
+ }
25
+ interface RetryContext {
26
+ attempt: number;
27
+ delay: number;
28
+ elapsed: number;
29
+ error: AxiosError;
30
+ config: EnhancedAxiosRequestConfig;
31
+ }
32
+ interface RetryConfig {
33
+ /** @default false */
34
+ enabled?: boolean;
35
+ /** Number of retry attempts after the initial request. @default 3 */
36
+ count?: number;
37
+ /** Base retry delay in milliseconds. @default 1000 */
38
+ delay?: number;
39
+ /** @default true */
40
+ exponentialBackoff?: boolean;
41
+ /** @default true */
42
+ jitter?: boolean;
43
+ retryableStatusCodes?: number[];
44
+ /** @default GET, HEAD, OPTIONS, PUT and DELETE */
45
+ retryableMethods?: string[];
46
+ /** Maximum delay for one retry. @default 30000 */
47
+ maxDelay?: number;
48
+ /** Maximum elapsed retry time. Zero disables the limit. @default 0 */
49
+ maxElapsedMs?: number;
50
+ /** Honor Retry-After for 429/503 responses. @default true */
51
+ respectRetryAfter?: boolean;
52
+ /** Allow replaying stream-like request bodies. @default false */
53
+ retryUnsafeBody?: boolean;
54
+ shouldRetry?: (error: AxiosError, attempt: number) => boolean | Promise<boolean>;
55
+ onRetry?: (context: RetryContext) => void | Promise<void>;
56
+ }
57
+ interface CancelConfig {
58
+ /** Track the request so it can be canceled by scope or as a group. @default true */
59
+ enabled?: boolean;
60
+ whitelist?: RegExp[];
61
+ scope?: RequestScope;
62
+ }
63
+ interface RequestPolicyDefaults {
64
+ cache?: boolean | CacheConfig;
65
+ retry?: boolean | RetryConfig;
66
+ dedupe?: boolean | DedupeConfig;
67
+ cancel?: boolean | CancelConfig;
68
+ concurrency?: ConcurrencyPolicy;
69
+ }
70
+ interface EnhancedAxiosRequestConfig<D = unknown> extends AxiosRequestConfig<D> {
71
+ dedupe?: boolean | DedupeConfig;
72
+ cache?: boolean | CacheConfig;
73
+ retry?: boolean | RetryConfig;
74
+ cancel?: boolean | CancelConfig;
75
+ concurrency?: ConcurrencyPolicy;
76
+ scope?: RequestScope;
77
+ /** Skip token injection and unauthorized recovery for this request. */
78
+ skipAuth?: boolean;
79
+ /** Skip the client-level error callback for this request. */
80
+ silent?: boolean;
81
+ /** @internal */
82
+ __retryCount?: number;
83
+ /** @internal */
84
+ __retryStartedAt?: number;
85
+ /** @internal */
86
+ __cancelId?: string;
87
+ /** @internal */
88
+ __requestKey?: string;
89
+ /** @internal */
90
+ __fromCache?: boolean;
91
+ /** @internal */
92
+ __cachedResponse?: AxiosResponse;
93
+ /** @internal */
94
+ __abortController?: EnhancedAbortController;
95
+ /** @internal */
96
+ __externalSignal?: AxiosRequestConfig["signal"];
97
+ /** @internal */
98
+ __abortCleanup?: () => void;
99
+ /** @internal */
100
+ __managedByCancel?: boolean;
101
+ /** @internal */
102
+ __handling401?: boolean;
103
+ /** @internal */
104
+ __authRetryCount?: number;
105
+ }
106
+ type EnhancedAxiosInstance = AxiosInstance & {
107
+ request<T = unknown, R = AxiosResponse<T>, D = unknown>(config: EnhancedAxiosRequestConfig<D>): Promise<R>;
108
+ get<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
109
+ delete<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
110
+ head<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
111
+ options<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
112
+ post<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, data?: D, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
113
+ put<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, data?: D, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
114
+ patch<T = unknown, R = AxiosResponse<T>, D = unknown>(url: string, data?: D, config?: EnhancedAxiosRequestConfig<D>): Promise<R>;
115
+ };
116
+ interface CacheItem<T = unknown> {
117
+ data: T;
118
+ expireAt: number;
119
+ tags?: readonly string[];
120
+ }
121
+ interface CacheStore {
122
+ get<T = unknown>(key: string): T | null;
123
+ set<T = unknown>(key: string, data: T, ttl: number, options?: {
124
+ tags?: readonly string[];
125
+ }): void;
126
+ delete(key: string): boolean;
127
+ clear(): void;
128
+ cleanup?(): void;
129
+ deleteByPrefix?(prefix: string): number;
130
+ deleteByTag?(tag: string): number;
131
+ readonly size: number;
132
+ }
133
+ interface MemoryCacheOptions {
134
+ maxSize?: number;
135
+ clone?: boolean | (<T>(value: T) => T);
136
+ }
137
+ interface RequestKeyParams {
138
+ method?: string;
139
+ url?: string;
140
+ baseURL?: string;
141
+ params?: unknown;
142
+ data?: unknown;
143
+ }
144
+ interface RequestKeyOptions {
145
+ varyHeaders?: readonly string[];
146
+ }
147
+ interface EnhancedAbortController extends AbortController {
148
+ _startTime?: number;
149
+ }
150
+
151
+ interface InterceptorConfig {
152
+ request?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig | Promise<InternalAxiosRequestConfig>;
153
+ requestError?: (error: AxiosError) => unknown;
154
+ response?: (response: AxiosResponse) => AxiosResponse | Promise<AxiosResponse>;
155
+ responseError?: (error: AxiosError) => unknown;
156
+ }
157
+ interface FieldAliases {
158
+ data?: string[];
159
+ list?: string[];
160
+ total?: string[];
161
+ }
162
+ interface RequestCoreConfig {
163
+ request?: AxiosRequestConfig;
164
+ interceptors?: InterceptorConfig;
165
+ successCodes?: Array<number | string>;
166
+ fieldAliases?: FieldAliases;
167
+ defaults?: RequestPolicyDefaults;
168
+ cacheStore?: CacheStore;
169
+ }
170
+ /** Returns a defensive copy of the legacy default response configuration. */
171
+ declare function getGlobalConfig(): {
172
+ successCodes: Array<number | string>;
173
+ fieldAliases: {
174
+ data: string[];
175
+ list: string[];
176
+ total: string[];
177
+ };
178
+ };
179
+ /**
180
+ * Creates the 0.2-compatible Vue plugin and selects its Axios instance for
181
+ * global getData/postData helpers.
182
+ *
183
+ * @deprecated Prefer createRequestClient() plus createRequestPlugin().
184
+ */
185
+ declare function createRequestCore(config?: RequestCoreConfig): {
186
+ install(app: App): void;
187
+ axiosInstance: EnhancedAxiosInstance;
188
+ };
189
+
190
+ type RequestErrorKind = "business" | "http" | "network" | "timeout" | "canceled" | "concurrency" | "configuration" | "unknown";
191
+ interface RequestErrorOptions<T = unknown> {
192
+ kind: RequestErrorKind;
193
+ message: string;
194
+ code?: string | number;
195
+ status?: number;
196
+ data?: T;
197
+ requestId?: string;
198
+ retryable?: boolean;
199
+ config?: AxiosRequestConfig;
200
+ cause?: unknown;
201
+ }
202
+ declare class RequestError<T = unknown> extends Error {
203
+ readonly name = "RequestError";
204
+ readonly kind: RequestErrorKind;
205
+ readonly code?: string | number;
206
+ readonly status?: number;
207
+ readonly data?: T;
208
+ readonly requestId?: string;
209
+ readonly retryable: boolean;
210
+ readonly config?: AxiosRequestConfig;
211
+ readonly cause?: unknown;
212
+ constructor(options: RequestErrorOptions<T>);
213
+ }
214
+ declare function isRequestError(error: unknown): error is RequestError;
215
+ declare function isCanceledError(error: unknown): boolean;
216
+ declare function normalizeRequestError(error: unknown): RequestError;
217
+
218
+ type MaybePromise<T> = T | Promise<T>;
219
+ type AuthTokenResult = string | {
220
+ token: string;
221
+ } | null | undefined | void;
222
+ interface RawRequest {
223
+ <T = unknown, D = unknown>(config: EnhancedAxiosRequestConfig<D>): Promise<AxiosResponse<T, D>>;
224
+ }
225
+ interface AuthContext {
226
+ raw: RawRequest;
227
+ signal?: AbortSignal;
228
+ }
229
+ interface RequestAuthConfig {
230
+ getToken: () => MaybePromise<string | null | undefined>;
231
+ applyToken?: (config: InternalAxiosRequestConfig, token: string) => MaybePromise<void>;
232
+ shouldRefresh?: () => MaybePromise<boolean>;
233
+ refresh?: (context: AuthContext) => Promise<AuthTokenResult>;
234
+ reauthenticate?: (context: AuthContext) => Promise<AuthTokenResult>;
235
+ isAuthRequest?: (config: AxiosRequestConfig) => boolean;
236
+ isUnauthorized?: (error: AxiosError) => boolean;
237
+ /** Continue with the existing token if proactive refresh fails. @default true */
238
+ continueOnProactiveRefreshError?: boolean;
239
+ }
240
+ interface BusinessErrorDescriptor<T = unknown> {
241
+ message: string;
242
+ code?: string | number;
243
+ data?: T;
244
+ }
245
+ interface ResponseAdapter {
246
+ isSuccess?: (data: unknown, response: AxiosResponse) => MaybePromise<boolean>;
247
+ getData?: (data: unknown, response: AxiosResponse) => MaybePromise<unknown>;
248
+ getError?: (data: unknown, response: AxiosResponse) => MaybePromise<BusinessErrorDescriptor | string>;
249
+ }
250
+ interface RequestInterceptors {
251
+ request?: (config: InternalAxiosRequestConfig) => MaybePromise<InternalAxiosRequestConfig>;
252
+ requestError?: (error: AxiosError) => unknown;
253
+ response?: (response: AxiosResponse) => MaybePromise<AxiosResponse>;
254
+ responseError?: (error: AxiosError) => unknown;
255
+ }
256
+ interface RequestHooks {
257
+ onRequestStart?: (config: EnhancedAxiosRequestConfig) => MaybePromise<void>;
258
+ onRequestEnd?: (context: {
259
+ config: EnhancedAxiosRequestConfig;
260
+ response: AxiosResponse;
261
+ duration: number;
262
+ fromCache: boolean;
263
+ }) => MaybePromise<void>;
264
+ onError?: (error: RequestError) => MaybePromise<void>;
265
+ }
266
+ interface RequestClientConfig {
267
+ request?: AxiosRequestConfig;
268
+ defaults?: RequestPolicyDefaults;
269
+ cache?: CacheStore | MemoryCacheOptions;
270
+ auth?: RequestAuthConfig;
271
+ response?: ResponseAdapter;
272
+ interceptors?: RequestInterceptors;
273
+ hooks?: RequestHooks;
274
+ /** Make legacy getData/postData helpers point at this client. @default false */
275
+ setAsDefault?: boolean;
276
+ successCodes?: Array<number | string>;
277
+ fieldAliases?: FieldAliases;
278
+ }
279
+ interface RequestConfig<D = unknown> extends EnhancedAxiosRequestConfig<D> {
280
+ }
281
+ interface RequestCacheController {
282
+ clear(): void;
283
+ delete(config: AxiosRequestConfig): boolean;
284
+ invalidatePrefix(prefix: string): number;
285
+ invalidateTag(tag: string): number;
286
+ cleanup(): void;
287
+ readonly size: number;
288
+ }
289
+ interface RequestLifecycleController {
290
+ cancelAll(): void;
291
+ cancelScope(scope: RequestScope): number;
292
+ readonly pending: number;
293
+ }
294
+ interface RequestClient {
295
+ readonly axios: AxiosInstance;
296
+ request<T = unknown, D = unknown>(config: RequestConfig<D>): Promise<T>;
297
+ raw<T = unknown, D = unknown>(config: RequestConfig<D>): Promise<AxiosResponse<T, D>>;
298
+ get<T = unknown>(url: string, config?: RequestConfig): Promise<T>;
299
+ delete<T = unknown>(url: string, config?: RequestConfig): Promise<T>;
300
+ head<T = unknown>(url: string, config?: RequestConfig): Promise<T>;
301
+ options<T = unknown>(url: string, config?: RequestConfig): Promise<T>;
302
+ post<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<T>;
303
+ put<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<T>;
304
+ patch<T = unknown, D = unknown>(url: string, data?: D, config?: RequestConfig<D>): Promise<T>;
305
+ readonly cache: RequestCacheController;
306
+ readonly requests: RequestLifecycleController;
307
+ dispose(): void;
308
+ }
309
+
310
+ export { type BusinessErrorDescriptor as B, type CacheConfig as C, type DedupeConfig as D, type EnhancedAxiosInstance as E, type FieldAliases as F, type InterceptorConfig as I, type MemoryCacheOptions as M, type RequestAuthConfig as R, type CacheItem as a, type CacheStore as b, type CancelConfig as c, type ConcurrencyPolicy as d, type EnhancedAxiosRequestConfig as e, type RequestClient as f, type RequestClientConfig as g, type RequestConfig as h, type RequestCoreConfig as i, RequestError as j, type RequestHooks as k, type RequestInterceptors as l, type RequestKeyOptions as m, type RequestKeyParams as n, type RequestPolicyDefaults as o, type RequestScope as p, type ResponseAdapter as q, type RetryConfig as r, type RetryContext as s, createRequestCore as t, getGlobalConfig as u, isCanceledError as v, isRequestError as w, normalizeRequestError as x };