@kubb/plugin-fetch 5.2.0 → 5.2.2

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-fetch",
3
- "version": "5.2.0",
3
+ "version": "5.2.2",
4
4
  "description": "Generate a slim, type-safe HTTP client with Kubb based on the native Fetch api.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -49,6 +49,7 @@
49
49
  },
50
50
  "exports": {
51
51
  ".": {
52
+ "types": "./dist/index.d.ts",
52
53
  "import": "./dist/index.js",
53
54
  "require": "./dist/index.cjs"
54
55
  },
@@ -60,17 +61,17 @@
60
61
  "registry": "https://registry.npmjs.org/"
61
62
  },
62
63
  "dependencies": {
63
- "@kubb/plugin-ts": "^5.0.0",
64
- "@kubb/plugin-zod": "^5.1.2"
64
+ "@kubb/plugin-ts": "^5.0.1",
65
+ "@kubb/plugin-zod": "^5.1.3"
65
66
  },
66
67
  "devDependencies": {
67
68
  "@internals/client": "0.0.0",
68
69
  "@internals/shared": "0.0.0",
69
- "kubb": "^5.0.4",
70
+ "kubb": "^5.0.6",
70
71
  "typescript": "^6.0.3"
71
72
  },
72
73
  "peerDependencies": {
73
- "kubb": "^5.0.4"
74
+ "kubb": "^5.0.6"
74
75
  },
75
76
  "engines": {
76
77
  "node": ">=22"
@@ -1,5 +1,5 @@
1
1
  import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers'
2
- import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers'
2
+ import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers'
3
3
  import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema'
4
4
 
5
5
  /**
@@ -124,7 +124,7 @@ export type Deserializer<T = unknown> = (raw: unknown, contentType: string) => T
124
124
  /**
125
125
  * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle.
126
126
  */
127
- export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined
127
+ export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined
128
128
 
129
129
  /**
130
130
  * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the
@@ -238,7 +238,7 @@ export type ResolvedRequest = {
238
238
  url: string
239
239
  method: string
240
240
  headers: Record<string, string>
241
- body?: BodyInit
241
+ body?: RequestBody
242
242
  signal?: AbortSignal
243
243
  credentials?: RequestCredentials
244
244
  options?: FetchOptions
@@ -1,6 +1,12 @@
1
1
  export type HeaderValue = string | number | boolean | null | undefined | object
2
2
  export type HeadersInit = Array<[string, HeaderValue]> | Record<string, HeaderValue>
3
3
 
4
+ /**
5
+ * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit`
6
+ * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare.
7
+ */
8
+ export type RequestBody = NonNullable<RequestInit['body']>
9
+
4
10
  /**
5
11
  * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and
6
12
  * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as
@@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle<QueryStyle> & {
67
73
  * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries
68
74
  * the per-property OpenAPI `encoding` metadata for form bodies.
69
75
  */
70
- export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record<string, BodyEncoding> }) => BodyInit | undefined
76
+ export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record<string, BodyEncoding> }) => RequestBody | undefined
71
77
 
72
78
  /**
73
79
  * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value;
@@ -111,7 +117,7 @@ export type Styles = {
111
117
  body?: Record<string, BodyEncoding>
112
118
  }
113
119
 
114
- function isFormBody(body: unknown): body is BodyInit {
120
+ function isFormBody(body: unknown): body is RequestBody {
115
121
  return (
116
122
  body instanceof FormData ||
117
123
  body instanceof URLSearchParams ||
@@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData:
163
169
  */
164
170
  export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => {
165
171
  if (body === undefined || body === null) return undefined
166
- if (isFormBody(body)) return body as BodyInit
172
+ if (isFormBody(body)) return body as RequestBody
167
173
  if (contentType?.includes('multipart/form-data')) {
168
174
  const formData = new FormData()
169
175
  for (const [key, value] of Object.entries(body as Record<string, unknown>)) {