@kubb/plugin-axios 5.0.0-beta.76 → 5.0.0-beta.77
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/package.json +4 -4
- package/templates/axios.ts +16 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-axios",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.77",
|
|
4
4
|
"description": "Generate a slim, type-safe HTTP client with Kubb based on axios.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"@kubb/ast": "5.0.0-beta.74",
|
|
53
53
|
"@kubb/core": "5.0.0-beta.74",
|
|
54
54
|
"@kubb/renderer-jsx": "5.0.0-beta.74",
|
|
55
|
-
"@kubb/plugin-ts": "5.0.0-beta.
|
|
56
|
-
"@kubb/plugin-zod": "5.0.0-beta.
|
|
55
|
+
"@kubb/plugin-ts": "5.0.0-beta.77",
|
|
56
|
+
"@kubb/plugin-zod": "5.0.0-beta.77"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"axios": "^1.18.
|
|
59
|
+
"axios": "^1.18.1",
|
|
60
60
|
"typescript": "^6.0.3",
|
|
61
61
|
"@internals/client": "0.0.0",
|
|
62
62
|
"@internals/shared": "0.0.0",
|
package/templates/axios.ts
CHANGED
|
@@ -114,6 +114,17 @@ export type AuthToken = string | undefined
|
|
|
114
114
|
*/
|
|
115
115
|
export type AuthResolver = AuthToken | ((auth: Auth) => AuthToken | Promise<AuthToken>)
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Extra axios config the runtime spreads onto every request, an escape hatch for the per-call fields
|
|
119
|
+
* it does not set itself, such as `timeout`, `proxy`, `maxRedirects`, `decompress`, and the
|
|
120
|
+
* `onUploadProgress` / `onDownloadProgress` callbacks. The runtime-owned fields (`url`, `baseURL`,
|
|
121
|
+
* `method`, `headers`, `params`, `paramsSerializer`, `data`, `transformRequest`, `signal`,
|
|
122
|
+
* `responseType`, `validateStatus`) always win over anything set here. This is the per-request analog
|
|
123
|
+
* of the `transport` instance, which stays the place for cross-cutting concerns like retries and
|
|
124
|
+
* interceptors. It mirrors `options` in `@kubb/plugin-fetch`.
|
|
125
|
+
*/
|
|
126
|
+
export type AxiosOptions = AxiosRequestConfig
|
|
127
|
+
|
|
117
128
|
/**
|
|
118
129
|
* The request a generated function hands to the runtime. `body` / `headers` / `path` / `query` come
|
|
119
130
|
* from the grouped options; everything else is plain request configuration. `transport` carries an
|
|
@@ -129,6 +140,7 @@ export type RequestConfig<TBody = unknown, TRequest = AxiosRequestConfig, TRespo
|
|
|
129
140
|
body?: TBody
|
|
130
141
|
headers?: HeadersInit
|
|
131
142
|
signal?: AbortSignal
|
|
143
|
+
options?: AxiosOptions
|
|
132
144
|
contentType?: string
|
|
133
145
|
responseType?: ResponseType
|
|
134
146
|
throwOnError?: boolean
|
|
@@ -162,6 +174,7 @@ export type Options<TData extends DataShape, ThrowOnError extends boolean = true
|
|
|
162
174
|
export type ClientConfig = {
|
|
163
175
|
baseURL?: string
|
|
164
176
|
headers?: HeadersInit
|
|
177
|
+
options?: AxiosOptions
|
|
165
178
|
throwOnError?: boolean
|
|
166
179
|
validateStatus?: (status: number) => boolean
|
|
167
180
|
transport?: AxiosInstance
|
|
@@ -471,7 +484,10 @@ export function createClientCore<TRequest = AxiosRequestConfig, TResponse = Axio
|
|
|
471
484
|
const throwOnError = requestConfig.throwOnError ?? config.throwOnError ?? true
|
|
472
485
|
const validateStatus = requestConfig.validateStatus ?? config.validateStatus ?? (throwOnError ? undefined : () => true)
|
|
473
486
|
|
|
487
|
+
const options = config.options || requestConfig.options ? { ...config.options, ...requestConfig.options } : undefined
|
|
488
|
+
|
|
474
489
|
const axiosConfig: AxiosRequestConfig = {
|
|
490
|
+
...options, // timeout, proxy, maxRedirects, decompress, onUploadProgress, …
|
|
475
491
|
url,
|
|
476
492
|
baseURL,
|
|
477
493
|
method: requestConfig.method ?? 'GET',
|