这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: remove support for client packages #2172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 14, 2025
Merged

feat: remove support for client packages #2172

merged 13 commits into from
Jun 14, 2025

Conversation

mrlubos
Copy link
Member

@mrlubos mrlubos commented Jun 13, 2025

Closes #1969
Closes #1821
Closes #1660

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Jun 13, 2025

🦋 Changeset detected

Latest commit: cfc0abb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jun 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 14, 2025 8:32am

Copy link

pkg-pr-new bot commented Jun 13, 2025

Open in StackBlitz

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/nuxt@2172
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@2172
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/vite-plugin@2172

commit: cfc0abb

Copy link

codecov bot commented Jun 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 24.80%. Comparing base (16fb3c7) to head (cfc0abb).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2172      +/-   ##
==========================================
+ Coverage   22.49%   24.80%   +2.31%     
==========================================
  Files         273      293      +20     
  Lines       25634    27595    +1961     
  Branches      950     1242     +292     
==========================================
+ Hits         5766     6845    +1079     
- Misses      19862    20742     +880     
- Partials        6        8       +2     
Flag Coverage Δ
unittests 24.80% <ø> (+2.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

if (config.key) {
const field = map.get(config.key)!;
const name = field.map || config.key;
(params[field.in] as Record<string, unknown>)[name] = arg;

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.

Copilot Autofix

AI about 1 month ago

To fix the issue, we need to ensure that untrusted keys such as __proto__, constructor, and prototype cannot be used as property names in the assignment (params[field.in] as Record<string, unknown>)[name] = arg. This can be achieved by validating the fields parameter and rejecting or sanitizing any keys that could lead to prototype pollution. Alternatively, we can use a safer data structure, such as Map, to store the params object, as Map does not allow prototype pollution.

The best approach in this case is to validate the keys before performing the assignment. This ensures compatibility with the existing code structure while preventing prototype pollution.

Suggested changeset 1
packages/custom-client/src/core/params.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/custom-client/src/core/params.ts b/packages/custom-client/src/core/params.ts
--- a/packages/custom-client/src/core/params.ts
+++ b/packages/custom-client/src/core/params.ts
@@ -101,3 +101,5 @@
         const name = field.map || config.key;
-        (params[field.in] as Record<string, unknown>)[name] = arg;
+        if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') {
+          (params[field.in] as Record<string, unknown>)[name] = arg;
+        }
       } else {
@@ -127,3 +129,5 @@
               if (allowed) {
-                (params[slot as Slot] as Record<string, unknown>)[key] = value;
+                if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
+                  (params[slot as Slot] as Record<string, unknown>)[key] = value;
+                }
                 break;
EOF
@@ -101,3 +101,5 @@
const name = field.map || config.key;
(params[field.in] as Record<string, unknown>)[name] = arg;
if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') {
(params[field.in] as Record<string, unknown>)[name] = arg;
}
} else {
@@ -127,3 +129,5 @@
if (allowed) {
(params[slot as Slot] as Record<string, unknown>)[key] = value;
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
(params[slot as Slot] as Record<string, unknown>)[key] = value;
}
break;
Copilot is powered by AI and may make mistakes. Always verify output.

if (field) {
const name = field.map || key;
(params[field.in] as Record<string, unknown>)[name] = value;

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.

Copilot Autofix

AI about 1 month ago

To fix the issue, we need to ensure that keys derived from untrusted input cannot pollute the Object.prototype. This can be achieved by validating or sanitizing keys before using them in assignments. Specifically, we can check for dangerous keys like __proto__, constructor, and prototype and reject or skip them. Alternatively, we can use a prototype-less object (Object.create(null)) for params to eliminate the risk of prototype pollution entirely.

The best approach here is to create params as a prototype-less object using Object.create(null). This ensures that even if a malicious key like __proto__ is used, it will not affect Object.prototype. Additionally, we will add a safeguard to skip dangerous keys during the assignment process.


Suggested changeset 1
packages/custom-client/src/core/params.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/custom-client/src/core/params.ts b/packages/custom-client/src/core/params.ts
--- a/packages/custom-client/src/core/params.ts
+++ b/packages/custom-client/src/core/params.ts
@@ -78,6 +78,6 @@
   const params: Params = {
-    body: {},
-    headers: {},
-    path: {},
-    query: {},
+    body: Object.create(null),
+    headers: Object.create(null),
+    path: Object.create(null),
+    query: Object.create(null),
   };
@@ -111,3 +111,5 @@
           const name = field.map || key;
-          (params[field.in] as Record<string, unknown>)[name] = value;
+          if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') {
+            (params[field.in] as Record<string, unknown>)[name] = value;
+          }
         } else {
@@ -127,3 +129,5 @@
               if (allowed) {
-                (params[slot as Slot] as Record<string, unknown>)[key] = value;
+                if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
+                  (params[slot as Slot] as Record<string, unknown>)[key] = value;
+                }
                 break;
EOF
@@ -78,6 +78,6 @@
const params: Params = {
body: {},
headers: {},
path: {},
query: {},
body: Object.create(null),
headers: Object.create(null),
path: Object.create(null),
query: Object.create(null),
};
@@ -111,3 +111,5 @@
const name = field.map || key;
(params[field.in] as Record<string, unknown>)[name] = value;
if (name !== '__proto__' && name !== 'constructor' && name !== 'prototype') {
(params[field.in] as Record<string, unknown>)[name] = value;
}
} else {
@@ -127,3 +129,5 @@
if (allowed) {
(params[slot as Slot] as Record<string, unknown>)[key] = value;
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
(params[slot as Slot] as Record<string, unknown>)[key] = value;
}
break;
Copilot is powered by AI and may make mistakes. Always verify output.
@mrlubos mrlubos marked this pull request as ready for review June 14, 2025 07:58
@@ -2,11 +2,11 @@
import path from 'node:path';

// @ts-ignore
import { customClientPlugin } from '@hey-api/client-custom/plugin';
import { customClientPlugin } from '@hey-api/custom-client/plugin';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused import customClientPlugin.

Copilot Autofix

AI about 1 month ago

To fix the issue, we will remove the unused customClientPlugin import from line 5. This will eliminate the flagged error and improve the readability of the code. No other changes are necessary since the import is not used anywhere in the file.


Suggested changeset 1
packages/openapi-ts-tests/test/openapi-ts.config.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/openapi-ts-tests/test/openapi-ts.config.ts b/packages/openapi-ts-tests/test/openapi-ts.config.ts
--- a/packages/openapi-ts-tests/test/openapi-ts.config.ts
+++ b/packages/openapi-ts-tests/test/openapi-ts.config.ts
@@ -3,4 +3,2 @@
 
-// @ts-ignore
-import { customClientPlugin } from '@hey-api/custom-client/plugin';
 import { defineConfig } from '@hey-api/openapi-ts';
EOF
@@ -3,4 +3,2 @@

// @ts-ignore
import { customClientPlugin } from '@hey-api/custom-client/plugin';
import { defineConfig } from '@hey-api/openapi-ts';
Copilot is powered by AI and may make mistakes. Always verify output.
@mrlubos mrlubos force-pushed the feat/client-bundle branch from f2cf721 to cfc0abb Compare June 14, 2025 08:31
@mrlubos mrlubos merged commit a1e1395 into main Jun 14, 2025
17 checks passed
@mrlubos mrlubos deleted the feat/client-bundle branch June 14, 2025 08:36
@github-actions github-actions bot mentioned this pull request Jun 13, 2025
@johnny-mh
Copy link
Contributor

Hi @mrlubos, after updating to @hey-api/openapi-ts@0.73.0, I noticed that the @hey-api/client-* packages are now added directly into the codebase. This seems to allow for faster installation in most cases—thank you for that!

However, the source code under client/* and core/* is causing type errors with my current project settings, which prevents me from bundling it.
build-error.txt

While I could resolve this by modifying my tsconfig.json, I’d prefer to avoid potential side effects without fully verifying them.

Would it be possible to include pre-bundled client.js and client.d.ts files for each @hey-api/client-* package?

@mrlubos
Copy link
Member Author

mrlubos commented Jun 15, 2025

@johnny-mh Can you open a new issue with your tsconfig? I'll fix the types/errors so you'd be able to build the client yourself

@johnny-mh
Copy link
Contributor

@mrlubos I moved the generated files to another package in my monorepo and copied the openapi-ts/tsconfig.json file. After that, everything built successfully without type errors.

I believe that if you change your code to match my tsconfig.json, other projects might run into the same issue. I’ll open an issue if I encounter any other problems.

Thanks again!

@mrlubos
Copy link
Member Author

mrlubos commented Jun 15, 2025

Please open an issue with your config anyway!

@johnny-mh
Copy link
Contributor

Okay I’ll open issue tomorrow

@KiwiKilian
Copy link

KiwiKilian commented Jun 23, 2025

Is there still a possibility to keep using the packages? We now have the core and client files duplicated, as we are generating for multiple OpenAPI specs. Also I would have to disable quite a lot of ESLint rules. The main benefit I see here, that the client is in sync with the version of the generated code. But otherwise it's a bit troublesome in our use case.

@kylecarhart
Copy link

kylecarhart commented Jul 1, 2025

Yeah, I was very reluctant to upgrade past this version. To echo @KiwiKilian , in our use case, we generate multiple clients which would lead to a lot of duplicated code. We need some way to allow for multiple generated clients to share the same core code.

Not to mention that I'm not really a fan of having all this generated core code in our codebase, id much rather it live in the package like it used to... but I could look past that if this issue is fixed.

@mrlubos
Copy link
Member Author

mrlubos commented Jul 1, 2025

@kylecarhart definitely feel free to not upgrade and stay pinned on an older version! But please, please let me know why so I can figure out a way to make both you and me happy with these features 🤝 I'll get to these clients again, it's on my radar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants