@hey-api/openapi-ts 0.95.0 → 0.96.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/README.md CHANGED
@@ -33,7 +33,7 @@ Part of the Hey API ecosystem.
33
33
  ## Features
34
34
 
35
35
  - production-ready code that compiles
36
- - runs in any Node.js 20+ environment
36
+ - runs in any Node.js 22+ environment
37
37
  - accepts any OpenAPI specification
38
38
  - core plugins for SDKs, types, and schemas
39
39
  - HTTP clients for Fetch API, Angular, Axios, Next.js, Nuxt, and more
@@ -41,12 +41,18 @@ Part of the Hey API ecosystem.
41
41
  - highly customizable via plugins
42
42
  - [sync with Hey API Registry](https://heyapi.dev/openapi-ts/integrations) for spec management
43
43
 
44
+ <!-- template-contributing-start -->
45
+
44
46
  ## Contributing
45
47
 
46
48
  Want to see your code in products used by millions?
47
49
 
48
50
  Start with our [Contributing](https://heyapi.dev/openapi-ts/community/contributing) guide and release your first feature.
49
51
 
52
+ <!-- template-contributing-end -->
53
+
54
+ <!-- template-sponsors-start -->
55
+
50
56
  ## Sponsors
51
57
 
52
58
  Hey API is sponsor-funded. If you rely on Hey API in production, consider becoming a [sponsor](https://github.com/sponsors/hey-api) to accelerate the roadmap.
@@ -153,6 +159,7 @@ Hey API is sponsor-funded. If you rely on Hey API in production, consider becomi
153
159
  </tr>
154
160
  </tbody>
155
161
  </table>
162
+ <!-- template-sponsors-end -->
156
163
 
157
164
  ## Quick Start
158
165
 
@@ -171,7 +178,7 @@ You can download `@hey-api/openapi-ts` from npm using your favorite package mana
171
178
  #### npm
172
179
 
173
180
  ```sh
174
- npm install @hey-api/openapi-ts -D -E
181
+ npm add @hey-api/openapi-ts -D -E
175
182
  ```
176
183
 
177
184
  #### pnpm
@@ -227,6 +234,56 @@ createClient({
227
234
  });
228
235
  ```
229
236
 
237
+ ### Vite
238
+
239
+ If you're using [Vite](https://vite.dev), you can integrate `@hey-api/openapi-ts` directly into your build pipeline with `@hey-api/vite-plugin`. Install it alongside the main package:
240
+
241
+ #### npm
242
+
243
+ ```sh
244
+ npm add @hey-api/vite-plugin -D -E
245
+ ```
246
+
247
+ #### pnpm
248
+
249
+ ```sh
250
+ pnpm add @hey-api/vite-plugin -D -E
251
+ ```
252
+
253
+ #### yarn
254
+
255
+ ```sh
256
+ yarn add @hey-api/vite-plugin -D -E
257
+ ```
258
+
259
+ #### bun
260
+
261
+ ```sh
262
+ bun add @hey-api/vite-plugin -D -E
263
+ ```
264
+
265
+ Then add the plugin to your Vite configuration:
266
+
267
+ #### `vite.config.ts`
268
+
269
+ ```ts
270
+ import { heyApiPlugin } from '@hey-api/vite-plugin';
271
+ import { defineConfig } from 'vite';
272
+
273
+ export default defineConfig({
274
+ plugins: [
275
+ heyApiPlugin({
276
+ config: {
277
+ input: 'hey-api/backend', // sign up at app.heyapi.dev
278
+ output: 'src/client',
279
+ },
280
+ }),
281
+ ],
282
+ });
283
+ ```
284
+
285
+ See the [Vite](https://heyapi.dev/openapi-ts/configuration/vite) page for full configuration options.
286
+
230
287
  ## Configuration
231
288
 
232
289
  `@hey-api/openapi-ts` supports loading configuration from any file inside your project root folder supported by [jiti loader](https://github.com/unjs/c12?tab=readme-ov-file#-features). Below are the most common file formats.
@@ -358,6 +415,10 @@ Don't see your plugin? [Build your own](https://heyapi.dev/openapi-ts/plugins/cu
358
415
 
359
416
  You can learn more on the [Migrating](https://heyapi.dev/openapi-ts/migrating) page.
360
417
 
418
+ <!-- template-license-start -->
419
+
361
420
  ## License
362
421
 
363
422
  Released under the [MIT License](https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md).
423
+
424
+ <!-- template-license-end -->
@@ -77,7 +77,7 @@ export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unkn
77
77
  >;
78
78
  };
79
79
 
80
- export const createSseClient = <TData = unknown>({
80
+ export function createSseClient<TData = unknown>({
81
81
  onRequest,
82
82
  onSseError,
83
83
  onSseEvent,
@@ -89,7 +89,7 @@ export const createSseClient = <TData = unknown>({
89
89
  sseSleepFn,
90
90
  url,
91
91
  ...options
92
- }: ServerSentEventsOptions): ServerSentEventsResult<TData> => {
92
+ }: ServerSentEventsOptions): ServerSentEventsResult<TData> {
93
93
  let lastEventId: string | undefined;
94
94
 
95
95
  const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
@@ -153,8 +153,7 @@ export const createSseClient = <TData = unknown>({
153
153
  const { done, value } = await reader.read();
154
154
  if (done) break;
155
155
  buffer += value;
156
- // Normalize line endings: CRLF -> LF, then CR -> LF
157
- buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
156
+ buffer = buffer.replace(/\r\n?/g, '\n'); // normalize line endings
158
157
 
159
158
  const chunks = buffer.split('\n\n');
160
159
  buffer = chunks.pop() ?? '';
@@ -238,4 +237,4 @@ export const createSseClient = <TData = unknown>({
238
237
  const stream = createStream();
239
238
 
240
239
  return { stream };
241
- };
240
+ }