@kubb/plugin-axios 5.7.0-canary.20261016T084648 → 5.7.0

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.cjs CHANGED
@@ -1430,7 +1430,7 @@ var compatibility = {
1430
1430
  };
1431
1431
  //#endregion
1432
1432
  //#region package.json
1433
- var version = "5.7.0-canary.20261016T084648";
1433
+ var version = "5.7.0";
1434
1434
  //#endregion
1435
1435
  //#region src/templates.ts
1436
1436
  /** Absolute path to the axios client template, copied into `.kubb/client.ts`. */
package/dist/index.js CHANGED
@@ -1404,7 +1404,7 @@ var compatibility = {
1404
1404
  };
1405
1405
  //#endregion
1406
1406
  //#region package.json
1407
- var version = "5.7.0-canary.20261016T084648";
1407
+ var version = "5.7.0";
1408
1408
  //#endregion
1409
1409
  //#region src/templates.ts
1410
1410
  /** Absolute path to the axios client template, copied into `.kubb/client.ts`. */
@@ -339,9 +339,15 @@ export declare function resolveAuth(params: {
339
339
  query: Record<string, unknown>;
340
340
  }): Promise<void>;
341
341
  /**
342
- * Builds the shared client core bound to an axios instance (defaulting to `axios.create()`), with `throwOnError` riding axios's `validateStatus`.
342
+ * Builds the shared client core bound to an axios instance (defaulting to `defaultTransport`, else `axios.create()`), with `throwOnError` riding axios's `validateStatus`.
343
343
  */
344
- export declare function createClientCore<TRequest = AxiosRequestConfig, TResponse = AxiosResponse>(options?: ClientConfig): ClientInstance<TRequest, TResponse>;
344
+ export declare function createClientCore<TRequest = AxiosRequestConfig, TResponse = AxiosResponse>(options?: {
345
+ defaultTransport?: AxiosInstance;
346
+ } & ClientConfig): ClientInstance<TRequest, TResponse>;
347
+ /**
348
+ * The axios instance the generated `client` sends through. Register axios interceptors on it or reuse it inside your own transport.
349
+ */
350
+ export declare const defaultTransport: AxiosInstance;
345
351
  /**
346
352
  * One decoded Server-Sent Event, with `data` parsed as JSON when valid and kept as the raw string otherwise.
347
353
  */
@@ -2,7 +2,7 @@
2
2
 
3
3
  Set a transport at runtime to replace the network send. The client still builds URLs, serializes parameters, resolves authentication, and handles results.
4
4
 
5
- The transport is an `AxiosInstance`. The default is `axios.create()`, and you can replace it with your own pre-configured instance. Use interceptors for request headers or response logging.
5
+ The transport is an `AxiosInstance`. The default is `defaultTransport`, an `axios.create()` instance exported from the generated client, and you can replace it with your own pre-configured instance. Use interceptors for request headers or response logging.
6
6
 
7
7
  ```typescript
8
8
  type ClientConfig = {
@@ -39,6 +39,22 @@ Every generated function now sends through your instance, so its timeout, header
39
39
  > [!NOTE]
40
40
  > Kubb sets `transformRequest`, `paramsSerializer`, and `validateStatus` on each request for its own serialization and `throwOnError` handling, so leave those fields alone. Set timeouts, retries, and interceptors on the instance. For one call, pass `options`, such as `{ timeout }` or `{ onUploadProgress }`, instead of building a new instance.
41
41
 
42
+ ## Use the default instance
43
+
44
+ The generated client exports `defaultTransport`, the instance it sends through when no transport is set. Configure it directly to add tracing or headers without replacing the transport:
45
+
46
+ ```typescript
47
+ import { defaultTransport } from './gen/.kubb/client'
48
+
49
+ defaultTransport.defaults.timeout = 10_000
50
+ defaultTransport.interceptors.request.use((config) => {
51
+ config.headers.set('traceparent', currentTraceparent())
52
+ return config
53
+ })
54
+ ```
55
+
56
+ Instances from `createClient()` get their own `axios.create()` and do not share these settings.
57
+
42
58
  ## Where to set it
43
59
 
44
60
  Use `client.setConfig({ transport })` for shared configuration, `createClient({ transport })` for an isolated instance, or pass `transport` on an operation to override it for one call.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-axios",
3
- "version": "5.7.0-canary.20261016T084648",
3
+ "version": "5.7.0",
4
4
  "description": "Generate a slim, type-safe HTTP client with Kubb based on axios.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -80,12 +80,12 @@
80
80
  "registry": "https://registry.npmjs.org/"
81
81
  },
82
82
  "dependencies": {
83
- "@kubb/plugin-ts": "^5.1.0-canary.20261016T084648",
84
- "@kubb/plugin-zod": "^5.5.0-canary.20261016T084648"
83
+ "@kubb/plugin-ts": "^5.0.14",
84
+ "@kubb/plugin-zod": "^5.4.12"
85
85
  },
86
86
  "devDependencies": {
87
- "@internals/client": "0.1.0-canary.20261016T084648",
88
- "@internals/shared": "0.1.0-canary.20261016T084648",
87
+ "@internals/client": "0.0.0",
88
+ "@internals/shared": "0.0.0",
89
89
  "axios": "^1.20.0",
90
90
  "kubb": "^5.10.3",
91
91
  "typescript": "^6.0.3"
@@ -723,11 +723,14 @@ async function settleResponse<TRequest, TResponse>({
723
723
  }
724
724
 
725
725
  /**
726
- * Builds the shared client core bound to an axios instance (defaulting to `axios.create()`), with `throwOnError` riding axios's `validateStatus`.
727
- */
728
- export function createClientCore<TRequest = AxiosRequestConfig, TResponse = AxiosResponse>(options: ClientConfig = {}): ClientInstance<TRequest, TResponse> {
729
- let config: ClientConfig = { ...options }
730
- const baseInstance = config.transport ?? axios.create()
726
+ * Builds the shared client core bound to an axios instance (defaulting to `defaultTransport`, else `axios.create()`), with `throwOnError` riding axios's `validateStatus`.
727
+ */
728
+ export function createClientCore<TRequest = AxiosRequestConfig, TResponse = AxiosResponse>(
729
+ options: { defaultTransport?: AxiosInstance } & ClientConfig = {},
730
+ ): ClientInstance<TRequest, TResponse> {
731
+ const { defaultTransport, ...initialConfig } = options
732
+ let config: ClientConfig = initialConfig
733
+ const baseInstance = config.transport ?? defaultTransport ?? axios.create()
731
734
  let instance = baseInstance
732
735
  const requestContexts = new Map<number, RequestConfig<unknown, TRequest, TResponse>>()
733
736
  let requestContextId = 0
@@ -861,6 +864,11 @@ export function createClientCore<TRequest = AxiosRequestConfig, TResponse = Axio
861
864
  return client
862
865
  }
863
866
 
867
+ /**
868
+ * The axios instance the generated `client` sends through. Register axios interceptors on it or reuse it inside your own transport.
869
+ */
870
+ export const defaultTransport = axios.create()
871
+
864
872
  /**
865
873
  * One decoded Server-Sent Event, with `data` parsed as JSON when valid and kept as the raw string otherwise.
866
874
  */
@@ -963,6 +971,6 @@ export async function toEventStream<TData = unknown>(result: Promise<{ data: unk
963
971
  }
964
972
  }
965
973
 
966
- export const client = createClientCore()
974
+ export const client = createClientCore({ defaultTransport })
967
975
 
968
976
  export const createClient = (config?: Parameters<typeof client.createClient>[0]) => client.createClient(config)