@kubb/plugin-axios 5.3.0-canary.20260907T104724 → 5.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-axios",
3
- "version": "5.3.0-canary.20260907T104724",
3
+ "version": "5.3.0",
4
4
  "description": "Generate a slim, type-safe HTTP client with Kubb based on axios.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -61,19 +61,19 @@
61
61
  "registry": "https://registry.npmjs.org/"
62
62
  },
63
63
  "dependencies": {
64
- "@kubb/plugin-ts": "^5.1.0-canary.20260907T104719",
65
- "@kubb/plugin-zod": "^5.2.0-canary.20260907T104719"
64
+ "@kubb/plugin-ts": "^5.0.1",
65
+ "@kubb/plugin-zod": "^5.1.4"
66
66
  },
67
67
  "devDependencies": {
68
- "@internals/client": "0.1.0-canary.20260907T104721",
69
- "@internals/shared": "0.1.0-canary.20260907T104718",
68
+ "@internals/client": "0.0.0",
69
+ "@internals/shared": "0.0.0",
70
70
  "axios": "^1.20.0",
71
- "kubb": "^5.0.6",
71
+ "kubb": "^5.1.0",
72
72
  "typescript": "^6.0.3"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "axios": "^1.20.0",
76
- "kubb": "^5.0.6"
76
+ "kubb": "^5.1.0"
77
77
  },
78
78
  "peerDependenciesMeta": {
79
79
  "axios": {
package/src/plugin.ts CHANGED
@@ -44,6 +44,7 @@ export const pluginAxios = definePlugin<PluginAxios>((options) => {
44
44
  override = [],
45
45
  baseURL,
46
46
  validator = false,
47
+ returnType = 'full',
47
48
  group,
48
49
  sdk,
49
50
  resolver: userResolver,
@@ -57,6 +58,7 @@ export const pluginAxios = definePlugin<PluginAxios>((options) => {
57
58
  group: createGroupConfig(group),
58
59
  baseURL,
59
60
  validator,
61
+ returnType,
60
62
  sdk: sdk ? { mode: sdk.mode ?? 'tag', name: sdk.name } : undefined,
61
63
  resolver: userResolver ? Resolver.merge<ResolverClient>(resolverClient, userResolver) : resolverClient,
62
64
  }
@@ -110,6 +110,30 @@ export function withUnwrap<T extends { data: unknown; error: unknown }>(promise:
110
110
  return unwrappable
111
111
  }
112
112
 
113
+ /**
114
+ * The shape a generated operation returns when `returnType: 'data'` is set: the bare success body
115
+ * once `throwOnError` (on by default) narrows away the error branch, falling back to the full
116
+ * `RequestResult` when a call sets `throwOnError: false` and still needs `error` to discriminate a
117
+ * failed response.
118
+ */
119
+ export type UnwrappedResult<
120
+ TResponses,
121
+ ThrowOnError extends boolean = true,
122
+ TRequest = AxiosRequestConfig,
123
+ TResponse = AxiosResponse,
124
+ > = ThrowOnError extends true ? RequestResult<TResponses, true, TRequest, TResponse>['data'] : RequestResult<TResponses, ThrowOnError, TRequest, TResponse>
125
+
126
+ /**
127
+ * Narrows a resolved call down to its success body once `throwOnError` (on by default) rules out
128
+ * the error branch, the same default the runtime itself applies. Falls back to the full result for
129
+ * a call that sets `throwOnError: false`, since that path still needs `error` to discriminate a
130
+ * failed response. Backs `returnType: 'data'`, mirroring how `toEventStream` centralizes the
131
+ * post-processing for `text/event-stream` operations.
132
+ */
133
+ export function unwrapResult<T extends { data: unknown; error: unknown }>(promise: Promise<T>, throwOnError: boolean | undefined): Promise<T | T['data']> {
134
+ return promise.then((result) => ((throwOnError ?? true) ? result.data : result))
135
+ }
136
+
113
137
  /**
114
138
  * The data-shaped keys of the grouped options object, which `Options` re-adds typed per operation.
115
139
  */