fork of hey-api/openapi-ts because I need some additional things

feat: bundle next client

Lubos ​ 723f1820 2d7dc55c

+29 -387
-85
packages/client-next/CHANGELOG.md
··· 1 - # @hey-api/client-next 2 - 3 - ## 0.5.1 4 - 5 - ### Patch Changes 6 - 7 - - [#2165](https://github.com/hey-api/openapi-ts/pull/2165) [`f23f3ae`](https://github.com/hey-api/openapi-ts/commit/f23f3ae874385e758eb8d43bb4e274c9858a4e40) Thanks [@mrlubos](https://github.com/mrlubos)! - fix(client): do not serialize path param name in url 8 - 9 - ## 0.5.0 10 - 11 - ### Minor Changes 12 - 13 - - [#2148](https://github.com/hey-api/openapi-ts/pull/2148) [`10d2e03`](https://github.com/hey-api/openapi-ts/commit/10d2e03b8295e4e887fab8d023aa823699efbae8) Thanks [@mrlubos](https://github.com/mrlubos)! - feat: export `buildClientParams` function 14 - 15 - ## 0.4.0 16 - 17 - ### Minor Changes 18 - 19 - - [#2094](https://github.com/hey-api/openapi-ts/pull/2094) [`8152aaf`](https://github.com/hey-api/openapi-ts/commit/8152aaf4892c48b79fd3dc486eb3c0ea333dc3e6) Thanks [@mrlubos](https://github.com/mrlubos)! - feat: accept responses/errors map instead of union 20 - 21 - **BREAKING**: Update `@hey-api/openapi-ts` to the latest version. 22 - 23 - ## 0.3.2 24 - 25 - ### Patch Changes 26 - 27 - - [#2029](https://github.com/hey-api/openapi-ts/pull/2029) [`1f99066`](https://github.com/hey-api/openapi-ts/commit/1f99066efbb2d0e6b9e3710c701293c2cc09d65e) Thanks [@henry-encord](https://github.com/henry-encord)! - feat: support referencing interceptors by index 28 - 29 - ## 0.3.1 30 - 31 - ### Patch Changes 32 - 33 - - [#2039](https://github.com/hey-api/openapi-ts/pull/2039) [`565e0b8`](https://github.com/hey-api/openapi-ts/commit/565e0b89fbab4556ecdc63dfe08250942681140e) Thanks [@Le0Developer](https://github.com/Le0Developer)! - fix(clients): fix query string encoding with empty lists/objects 34 - 35 - ## 0.3.0 36 - 37 - ### Minor Changes 38 - 39 - - [#1889](https://github.com/hey-api/openapi-ts/pull/1889) [`67c385b`](https://github.com/hey-api/openapi-ts/commit/67c385bf6289a79726b0cdd85fd81ca501cf2248) Thanks [@mrlubos](https://github.com/mrlubos)! - fix: add @hey-api/openapi-ts to peer dependencies 40 - 41 - ## 0.2.4 42 - 43 - ### Patch Changes 44 - 45 - - [#1850](https://github.com/hey-api/openapi-ts/pull/1850) [`fe43b88`](https://github.com/hey-api/openapi-ts/commit/fe43b889c20a2001f56e259f93f64851a1caa1d1) Thanks [@kelnos](https://github.com/kelnos)! - feat: add support for cookies auth 46 - 47 - ## 0.2.3 48 - 49 - ### Patch Changes 50 - 51 - - [#1774](https://github.com/hey-api/openapi-ts/pull/1774) [`c0b36b9`](https://github.com/hey-api/openapi-ts/commit/c0b36b95645d484034c3af145c5554867568979b) Thanks [@mrlubos](https://github.com/mrlubos)! - docs: announce Hey API platform 52 - 53 - ## 0.2.2 54 - 55 - ### Patch Changes 56 - 57 - - [#1753](https://github.com/hey-api/openapi-ts/pull/1753) [`b8cc9f8`](https://github.com/hey-api/openapi-ts/commit/b8cc9f8a5eaf4f4ff345abc49c14c6b96744c2ea) Thanks [@LinuCC](https://github.com/LinuCC)! - fix: dropping Content-Type header with falsey but valid json body 58 - 59 - ## 0.2.1 60 - 61 - ### Patch Changes 62 - 63 - - [#1674](https://github.com/hey-api/openapi-ts/pull/1674) [`7f0f4a7`](https://github.com/hey-api/openapi-ts/commit/7f0f4a76b06c8fafb33581b522faf8efc6fd85ac) Thanks [@ale18V](https://github.com/ale18V)! - Return a string from urlSearchParamsBodySerializer instead of a URLSearchParams object. 64 - This is due to some runtimes not being able to handle the URLSearchParams object as fetch body. 65 - 66 - ## 0.2.0 67 - 68 - ### Minor Changes 69 - 70 - - [#1661](https://github.com/hey-api/openapi-ts/pull/1661) [`bb6d46a`](https://github.com/hey-api/openapi-ts/commit/bb6d46ae119ce4e7e3a2ab3fded74ac4fb4cdff2) Thanks [@mrlubos](https://github.com/mrlubos)! - fix: make createConfig, CreateClientConfig, and Config accept ClientOptions generic 71 - 72 - ### Added `ClientOptions` interface 73 - 74 - The `Config` interface now accepts an optional generic extending `ClientOptions` instead of `boolean` type `ThrowOnError`. 75 - 76 - ```ts 77 - type Foo = Config<false>; // [!code --] 78 - type Foo = Config<{ throwOnError: false }>; // [!code ++] 79 - ``` 80 - 81 - ## 0.1.0 82 - 83 - ### Minor Changes 84 - 85 - - [#1637](https://github.com/hey-api/openapi-ts/pull/1637) [`2dc380e`](https://github.com/hey-api/openapi-ts/commit/2dc380eabc17c723654beb04ecd7bce6d33d3b49) Thanks [@mrlubos](https://github.com/mrlubos)! - feat: initial release
-21
packages/client-next/LICENSE.md
··· 1 - MIT License 2 - 3 - Copyright (c) Hey API 4 - 5 - Permission is hereby granted, free of charge, to any person obtaining a copy 6 - of this software and associated documentation files (the "Software"), to deal 7 - in the Software without restriction, including without limitation the rights 8 - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 - copies of the Software, and to permit persons to whom the Software is 10 - furnished to do so, subject to the following conditions: 11 - 12 - The above copyright notice and this permission notice shall be included in all 13 - copies or substantial portions of the Software. 14 - 15 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 - SOFTWARE.
-102
packages/client-next/README.md
··· 1 - <div align="center"> 2 - <img alt="Hey API logo" height="150" src="https://heyapi.dev/images/logo-300w.png" width="150"> 3 - <h1 align="center"><b>Next.js Client</b></h1> 4 - <p align="center">🚀 Next.js client for `@hey-api/openapi-ts` codegen.</p> 5 - </div> 6 - 7 - <!-- TODO: Add working Next.js example --> 8 - <!-- [Live demo](https://stackblitz.com/edit/hey-api-client-fetch-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts,src%2FApp.tsx) --> 9 - 10 - ## Features 11 - 12 - - seamless integration with `@hey-api/openapi-ts` ecosystem 13 - - type-safe response data and errors 14 - - response data validation and transformation 15 - - access to the original request and response 16 - - granular request and response customization options 17 - - minimal learning curve thanks to extending the underlying technology 18 - - support bundling inside the generated output 19 - - [platform](https://heyapi.dev/openapi-ts/integrations) for automating codegen builds 20 - 21 - ## Dashboard 22 - 23 - Hey API is an ecosystem of products helping you build better APIs. Superpower your codegen and APIs with our platform. 24 - 25 - [Sign In](https://app.heyapi.dev) to Hey API platform. 26 - 27 - ## Documentation 28 - 29 - Please visit our [website](https://heyapi.dev) for documentation, guides, migrating, and more. 30 - 31 - ## Sponsors 32 - 33 - Love Hey API? Become our [sponsor](https://github.com/sponsors/hey-api). 34 - 35 - <h3 align="center">Gold</h3> 36 - 37 - <table align="center" style="justify-content: center;align-items: center;display: flex;"> 38 - <tbody> 39 - <tr> 40 - <td align="center"> 41 - <p></p> 42 - <p> 43 - <a href="https://kutt.it/pkEZyc" target="_blank"> 44 - <picture height="50px"> 45 - <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/stainless-logo-wordmark-480w.jpeg"> 46 - <img alt="Stainless logo" height="50px" src="https://heyapi.dev/images/stainless-logo-wordmark-480w.jpeg"> 47 - </picture> 48 - </a> 49 - <br/> 50 - Generate best-in-class SDKs. 51 - <br/> 52 - <a href="https://kutt.it/pkEZyc" style="text-decoration:none;" target="_blank"> 53 - stainless.com 54 - </a> 55 - </p> 56 - <p></p> 57 - </td> 58 - </tr> 59 - </tbody> 60 - </table> 61 - 62 - <h3 align="center">Silver</h3> 63 - 64 - <table align="center" style="justify-content: center;align-items: center;display: flex;"> 65 - <tbody> 66 - <tr> 67 - <td align="center"> 68 - <a href="https://kutt.it/skQUVd" target="_blank"> 69 - <picture height="40px"> 70 - <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/scalar-logo-wordmark-480w.jpeg"> 71 - <img alt="Scalar logo" height="40px" src="https://heyapi.dev/images/scalar-logo-wordmark-480w.jpeg"> 72 - </picture> 73 - </a> 74 - <br/> 75 - <a href="https://kutt.it/skQUVd" style="text-decoration:none;" target="_blank"> 76 - scalar.com 77 - </a> 78 - </td> 79 - </tr> 80 - </tbody> 81 - </table> 82 - 83 - <h3 align="center">Bronze</h3> 84 - 85 - <table align="center" style="justify-content: center;align-items: center;display: flex;"> 86 - <tbody> 87 - <tr> 88 - <td align="center"> 89 - <a href="https://kutt.it/YpaKsX" target="_blank"> 90 - <picture height="34px"> 91 - <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/kinde-logo-wordmark-dark-480w.webp"> 92 - <img alt="Kinde logo" height="34px" src="https://heyapi.dev/images/kinde-logo-wordmark-480w.jpeg"> 93 - </picture> 94 - </a> 95 - </td> 96 - </tr> 97 - </tbody> 98 - </table> 99 - 100 - ## Migration Guides 101 - 102 - [OpenAPI Typescript Codegen](https://heyapi.dev/openapi-ts/migrating#openapi-typescript-codegen)
-76
packages/client-next/package.json
··· 1 - { 2 - "name": "@hey-api/client-next", 3 - "version": "0.5.1", 4 - "description": "🚀 Next.js client for `@hey-api/openapi-ts` codegen.", 5 - "homepage": "https://heyapi.dev/", 6 - "repository": { 7 - "type": "git", 8 - "url": "git+https://github.com/hey-api/openapi-ts.git" 9 - }, 10 - "bugs": { 11 - "url": "https://github.com/hey-api/openapi-ts/issues" 12 - }, 13 - "license": "MIT", 14 - "author": { 15 - "email": "lubos@heyapi.dev", 16 - "name": "Hey API", 17 - "url": "https://heyapi.dev" 18 - }, 19 - "funding": "https://github.com/sponsors/hey-api", 20 - "keywords": [ 21 - "client", 22 - "codegen", 23 - "fetch", 24 - "http", 25 - "javascript", 26 - "next", 27 - "next.js", 28 - "openapi", 29 - "react", 30 - "rest", 31 - "swagger", 32 - "typescript" 33 - ], 34 - "type": "module", 35 - "main": "./dist/index.cjs", 36 - "module": "./dist/index.js", 37 - "types": "./dist/index.d.ts", 38 - "exports": { 39 - ".": { 40 - "import": { 41 - "types": "./dist/index.d.ts", 42 - "default": "./dist/index.js" 43 - }, 44 - "require": { 45 - "types": "./dist/index.d.cts", 46 - "default": "./dist/index.cjs" 47 - } 48 - }, 49 - "./package.json": "./package.json" 50 - }, 51 - "sideEffects": false, 52 - "files": [ 53 - "dist", 54 - "LICENSE.md", 55 - "src" 56 - ], 57 - "scripts": { 58 - "build": "tsup && rollup -c && pnpm check-exports", 59 - "check-exports": "attw --pack .", 60 - "dev": "tsup --watch", 61 - "prepublishOnly": "pnpm build", 62 - "test:coverage": "vitest run --coverage", 63 - "test:update": "vitest watch --update", 64 - "test:watch": "vitest watch", 65 - "test": "vitest run", 66 - "typecheck": "vitest --typecheck --watch=false" 67 - }, 68 - "peerDependencies": { 69 - "@hey-api/openapi-ts": "< 2" 70 - }, 71 - "devDependencies": { 72 - "@config/vite-base": "workspace:*", 73 - "@hey-api/client-core": "workspace:*", 74 - "@hey-api/openapi-ts": "workspace:*" 75 - } 76 - }
-30
packages/client-next/rollup.config.mjs
··· 1 - import path from 'node:path'; 2 - 3 - import { defineConfig } from 'rollup'; 4 - import dts from 'rollup-plugin-dts'; 5 - 6 - const files = ['index.d.ts', 'index.d.cts']; 7 - 8 - export default files.map((file) => 9 - defineConfig({ 10 - external: (id) => { 11 - const normalizedId = id.split(path.sep).join('/'); 12 - if (normalizedId === '@hey-api/client-core') { 13 - return false; 14 - } 15 - return ( 16 - !normalizedId.startsWith('/') && !/^[a-zA-Z]:\//.test(normalizedId) 17 - ); 18 - }, 19 - input: `./dist/${file}`, 20 - output: { 21 - file: `./dist/${file}`, 22 - format: 'es', 23 - }, 24 - plugins: [ 25 - dts({ 26 - respectExternal: true, 27 - }), 28 - ], 29 - }), 30 - );
packages/client-next/src/__tests__/client.test.ts packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts
packages/client-next/src/__tests__/utils.test.ts packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/utils.test.ts
packages/client-next/src/client.ts packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts
-20
packages/client-next/src/index.ts
··· 1 - export { createClient } from './client'; 2 - export type { 3 - Client, 4 - ClientOptions, 5 - Config, 6 - CreateClientConfig, 7 - Options, 8 - OptionsLegacyParser, 9 - RequestOptions, 10 - RequestResult, 11 - TDataShape, 12 - } from './types'; 13 - export { createConfig } from './utils'; 14 - export type { Auth, QuerySerializerOptions } from '@hey-api/client-core'; 15 - export { 16 - buildClientParams, 17 - formDataBodySerializer, 18 - jsonBodySerializer, 19 - urlSearchParamsBodySerializer, 20 - } from '@hey-api/client-core';
+2 -3
packages/client-next/src/types.ts packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts
··· 1 + import type { Auth } from '../../client-core/bundle/auth'; 1 2 import type { 2 - Auth, 3 3 Client as CoreClient, 4 4 Config as CoreConfig, 5 - } from '@hey-api/client-core'; 6 - 5 + } from '../../client-core/bundle/types'; 7 6 import type { Middleware } from './utils'; 8 7 9 8 export interface Config<T extends ClientOptions = ClientOptions>
+4 -5
packages/client-next/src/utils.ts packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/utils.ts
··· 1 + import { getAuthToken } from '../../client-core/bundle/auth'; 1 2 import type { 2 3 QuerySerializer, 3 4 QuerySerializerOptions, 4 - } from '@hey-api/client-core'; 5 + } from '../../client-core/bundle/bodySerializer'; 6 + import { jsonBodySerializer } from '../../client-core/bundle/bodySerializer'; 5 7 import { 6 - getAuthToken, 7 - jsonBodySerializer, 8 8 serializeArrayParam, 9 9 serializeObjectParam, 10 10 serializePrimitiveParam, 11 - } from '@hey-api/client-core'; 12 - 11 + } from '../../client-core/bundle/pathSerializer'; 13 12 import type { Client, ClientOptions, Config, RequestOptions } from './types'; 14 13 15 14 interface PathSerializer {
-14
packages/client-next/tsconfig.base.json
··· 1 - { 2 - "compilerOptions": { 3 - "declaration": true, 4 - "esModuleInterop": true, 5 - "module": "ESNext", 6 - "moduleResolution": "Bundler", 7 - "noImplicitOverride": true, 8 - "noUncheckedIndexedAccess": true, 9 - "noUnusedLocals": true, 10 - "strict": true, 11 - "target": "ES2022", 12 - "useUnknownInCatchVariables": false 13 - } 14 - }
-7
packages/client-next/tsconfig.json
··· 1 - { 2 - "extends": "./tsconfig.base.json", 3 - "compilerOptions": { 4 - "declaration": false, 5 - "esModuleInterop": true 6 - } 7 - }
-12
packages/client-next/tsup.config.ts
··· 1 - import { defineConfig } from 'tsup'; 2 - 3 - export default defineConfig((options) => ({ 4 - clean: true, 5 - dts: true, 6 - entry: ['src/index.ts'], 7 - format: ['cjs', 'esm'], 8 - minify: !options.watch, 9 - shims: false, 10 - sourcemap: true, 11 - treeshake: true, 12 - }));
-10
packages/client-next/vitest.config.ts
··· 1 - import { fileURLToPath } from 'node:url'; 2 - 3 - import { createVitestConfig } from '@config/vite-base'; 4 - 5 - export default createVitestConfig( 6 - fileURLToPath(new URL('./', import.meta.url)), 7 - { 8 - // Add specific configuration here if needed 9 - }, 10 - );
+1 -1
packages/openapi-ts-tests/test/openapi-ts.config.ts
··· 97 97 { 98 98 // baseUrl: false, 99 99 // exportFromIndex: true, 100 - name: '@hey-api/client-axios', 100 + name: '@hey-api/client-next', 101 101 // name: 'legacy/fetch', 102 102 // strictBaseUrl: true, 103 103 },
+21
packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/index.ts
··· 1 + export type { Auth } from '../../client-core/bundle/auth'; 2 + export type { QuerySerializerOptions } from '../../client-core/bundle/bodySerializer'; 3 + export { 4 + formDataBodySerializer, 5 + jsonBodySerializer, 6 + urlSearchParamsBodySerializer, 7 + } from '../../client-core/bundle/bodySerializer'; 8 + export { buildClientParams } from '../../client-core/bundle/params'; 9 + export { createClient } from './client'; 10 + export type { 11 + Client, 12 + ClientOptions, 13 + Config, 14 + CreateClientConfig, 15 + Options, 16 + OptionsLegacyParser, 17 + RequestOptions, 18 + RequestResult, 19 + TDataShape, 20 + } from './types'; 21 + export { createConfig } from './utils';
+1 -1
packages/openapi-ts/tsup.config.ts
··· 36 36 'client-axios', 37 37 'client-core', 38 38 'client-fetch', 39 - // 'client-next', 39 + 'client-next', 40 40 // 'client-nuxt', 41 41 ]; 42 42