Skip to content

feat: add proxy support with node-fetch-native/proxy #40

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 3 commits into from
Apr 18, 2025
Merged

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented Apr 18, 2025

Important

Add proxy support using node-fetch-native/proxy and update dependencies to node-fetch-native.

  • New Features:
    • Added proxy configuration support for translation requests using createProxy from node-fetch-native/proxy in translate.ts.
  • Dependencies:
    • Replaced node-fetch with node-fetch-native in cli/package.json and core/package.json.
    • Updated package.json resolutions to use node-fetch-native and undici.
  • Refactor:
    • Improved type safety in constants.ts by using as const satisfies HeadersInit for COMMON_HEADERS.
    • Renamed _proxyUrl to proxyUrl in makeRequest function in translate.ts for consistency.

This description was created by Ellipsis for 25d94af. It will automatically update as commits are pushed.


Summary by CodeRabbit

  • Chores
    • Updated and removed some package dependencies and resolutions to improve compatibility and maintenance.
  • Refactor
    • Improved type safety and code clarity in header and fetch handling.
    • Renamed a parameter in the translation request function for consistency.
  • New Features
    • Added proxy configuration support for translation requests.

@JounQin JounQin requested a review from Copilot April 18, 2025 17:56
Copy link

changeset-bot bot commented Apr 18, 2025

🦋 Changeset detected

Latest commit: 063d291

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

This PR includes changesets to release 2 packages
Name Type
@deeplx/cli Patch
@deeplx/core Patch

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

coderabbitai bot commented Apr 18, 2025

Walkthrough

This update modifies package dependencies and refines HTTP request handling in the project. The root package.json removes an unused type dependency, updates a deduplication tool, and adds resolution overrides for certain packages. The @deeplx/core package now depends on node-fetch-native, and its constants are updated to use a more type-safe and immutable approach. The translation logic replaces its fetch implementation with xfetch, introduces proxy configuration, and updates a function parameter name. TypeScript error suppression comments are cleaned up in the CLI fetch logic.

Changes

File(s) Change Summary
package.json Removed "@types/web" from devDependencies, updated "yarn-berry-deduplicate" version, and added resolutions for "node-fetch-native", "undici", and "undici-types".
packages/@deeplx/core/package.json Added "node-fetch-native" dependency.
packages/@deeplx/core/src/constants.ts Changed COMMON_HEADERS to use a const assertion with satisfies HeadersInit for improved type safety and immutability.
packages/@deeplx/core/src/translate.ts Switched from fetchApi to xfetch, added proxy support with createProxy, and renamed the makeRequest function parameter from _proxyUrl to proxyUrl.
packages/@deeplx/cli/package.json Replaced "node-fetch" dependency with "node-fetch-native".
packages/@deeplx/cli/src/fetch.ts Changed import source of fetch and Headers from "node-fetch" to "node-fetch-native" and removed TypeScript expect-error comments related to assigning these to globalThis.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant translate.ts
    participant node-fetch-native/proxy
    participant xfetch

    Caller->>translate.ts: makeRequest(postData, proxyUrl, dlSession)
    translate.ts->>node-fetch-native/proxy: createProxy({ url: proxyUrl })
    translate.ts->>xfetch: xfetch(url, { ...options, ...proxyOptions })
    xfetch-->>translate.ts: HTTP response
    translate.ts-->>Caller: Response/result
Loading

Poem

In the warren, code hops anew,
With proxies ready, fetches flew!
Types are tidier, headers tight,
Dependencies trimmed just right.
A bunny cheers this tidy patch—
Hopping forward, swift dispatch!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
error Couldn't find any versions for "@deeplx/core" that matches "workspace:*"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25d94af and 063d291.

📒 Files selected for processing (2)
  • .changeset/great-steaks-melt.md (1 hunks)
  • packages/@deeplx/core/src/translate.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/great-steaks-melt.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/@deeplx/core/src/translate.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds proxy support by integrating node-fetch-native/proxy and updates related components to align with the new proxy functionality.

  • Updates translate.ts to use xfetch and apply proxy settings via createProxy.
  • Adjusts constants.ts to type COMMON_HEADERS with a proper type assertion.
  • Cleans up the CLI fetch initialization by removing obsolete ts-expect-error directives.

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

File Description
packages/@deeplx/core/src/translate.ts Replaces fetchApi with xfetch and integrates createProxy for proxy support.
packages/@deeplx/core/src/constants.ts Updates COMMON_HEADERS to use type assertion with satisfies HeadersInit.
packages/@deeplx/cli/src/fetch.ts Removes ts-expect-error comments for global fetch and Headers assignment.
Files not reviewed (2)
  • package.json: Language not supported
  • packages/@deeplx/core/package.json: Language not supported
Comments suppressed due to low confidence (2)

packages/@deeplx/core/src/translate.ts:33

  • If proxy support is now implemented via createProxy, please update or remove the 'unsupported yet' comment to accurately reflect the current status.
proxyUrl?: string, // unsupported yet

packages/@deeplx/cli/src/fetch.ts:3

  • Confirm that the removal of @ts-expect-error comments does not reintroduce type compatibility issues between node-fetch and the global fetch assignment.
globalThis.fetch ??= fetch

Copy link

codesandbox-ci bot commented Apr 18, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

codecov bot commented Apr 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.55%. Comparing base (4b07662) to head (063d291).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #40   +/-   ##
=======================================
  Coverage   86.55%   86.55%           
=======================================
  Files           4        4           
  Lines         119      119           
  Branches       29       30    +1     
=======================================
  Hits          103      103           
  Misses         15       15           
  Partials        1        1           

☔ 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.

Copy link

pkg-pr-new bot commented Apr 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/deeplx@40
npm i https://pkg.pr.new/@deeplx/cli@40
npm i https://pkg.pr.new/@deeplx/core@40

commit: 063d291

Copy link
Contributor

github-actions bot commented Apr 18, 2025

size-limit report 📦

Path Size
packages/@deeplx/cli/lib/cli.js 815 B (0%)
packages/@deeplx/core/lib/index.js 110 B (0%)
packages/deeplx/lib/index.js 83 B (0%)

Copy link
Contributor

github-actions bot commented Apr 18, 2025

Deploy preview for deeplx ready!

✅ Preview
https://deeplx-11bhxs9ds-1stg.vercel.app

Built with commit 063d291.
This pull request is being automatically deployed with vercel-action

Copy link

socket-security bot commented Apr 18, 2025

Copy link
Contributor

github-actions bot commented Apr 18, 2025

📊 Package size report   0.01%↑

File Before After
.changeset/great-steaks-melt.md 109 B
package.json 2.1 kB 5%↑2.2 kB
packages/@deeplx/cli/package.json 1.3 kB 0.5%↑1.3 kB
packages/@deeplx/cli/src/fetch.ts 332 B -23.2%↓255 B
packages/@deeplx/core/package.json 1.5 kB 2%↑1.5 kB
packages/@deeplx/core/src/constants.ts 2.5 kB 2%↑2.6 kB
packages/@deeplx/core/src/translate.ts 6.1 kB 1%↑6.2 kB
Total (Includes all files) 3.1 MB 0.01%↑3.1 MB
Tarball size 1.1 MB 0.01%↑1.1 MB
Unchanged files
File Size
.changeset/config.json 311 B
.changeset/README.md 510 B
.codesandbox/ci.json 77 B
.commitlintrc 25 B
.editorconfig 145 B
.gitattributes 35 B
.github/workflows/autofix.yml 909 B
.github/workflows/ci.yml 1.6 kB
.github/workflows/pkg-pr-new.yml 691 B
.github/workflows/pkg-size.yml 542 B
.github/workflows/release.yml 1.2 kB
.github/workflows/size-limit.yml 829 B
.github/workflows/vercel.yml 986 B
.nano-staged.js 48 B
.prettierignore 22 B
.prettierrc 24 B
.remarkrc 42 B
.simple-git-hooks.js 49 B
.size-limit.json 236 B
.yarn/plugins/plugin-prepare-lifecycle.cjs 202 B
.yarn/releases/yarn-4.9.1.cjs 3.0 MB
.yarnrc.yml 397 B
api/translate.ts 1.6 kB
CHANGELOG.md 318 B
eslint.config.js 46 B
LICENSE 1.1 kB
packages/@deeplx/cli/CHANGELOG.md 1.1 kB
packages/@deeplx/cli/README.md 8.3 kB
packages/@deeplx/cli/src/cli.ts 2.1 kB
packages/@deeplx/cli/tsconfig.json 156 B
packages/@deeplx/core/CHANGELOG.md 771 B
packages/@deeplx/core/index.d.cts 54 B
packages/@deeplx/core/README.md 7.1 kB
packages/@deeplx/core/src/api.ts 448 B
packages/@deeplx/core/src/index.ts 146 B
packages/@deeplx/core/src/types.ts 2.6 kB
packages/@deeplx/core/src/utils.ts 2.0 kB
packages/@deeplx/core/test/translation.spec.ts 4.3 kB
packages/@deeplx/core/test/utils.spec.ts 332 B
packages/@deeplx/core/tsconfig.json 156 B
packages/deeplx/CHANGELOG.md 2.8 kB
packages/deeplx/index.d.cts 58 B
packages/deeplx/package.json 1.7 kB
packages/deeplx/README.md 9.1 kB
packages/deeplx/src/cli.ts 28 B
packages/deeplx/src/index.ts 29 B
packages/deeplx/tsconfig.json 156 B
public/apple-touch-icon.png 4.8 kB
public/favicon_16.png 540 B
public/favicon_32.png 978 B
public/favicon_96.png 2.7 kB
README.md 8.3 kB
renovate.json 146 B
scripts/build.ts 1.7 kB
test/gliobal.d.ts 41 B
test/tsconfig.json 156 B
tsconfig.json 205 B
tsconfig.lib.json 195 B
vercel.json 146 B
vitest.config.ts 414 B

🤖 This report was automatically generated by pkg-size-action

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to 9a550abf4f1cabae6fc1e0ab97a761c9c4d2160b in 1 minute and 41 seconds

More details
  • Looked at 110 lines of code in 5 files
  • Skipped 1 files when reviewing.
  • Skipped posting 15 drafted comments based on config settings.
1. package.json:56
  • Draft comment:
    Using npm aliases in the resolutions (node-fetch, undici, undici-types) is acceptable, but double-check that these overrides don't conflict with any dependency versions elsewhere in the project.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
2. package.json:35
  • Draft comment:
    Removal of '@types/web' may be intentional; verify that no code elsewhere depends on these types.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
3. packages/@deeplx/cli/src/fetch.ts:4
  • Draft comment:
    Assignment to globalThis.fetch and globalThis.Headers looks fine now, but ensure the types align with environment expectations since the ts-expect-error comments were removed.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
4. packages/@deeplx/core/src/translate.ts:1
  • Draft comment:
    Importing and using createProxy from 'node-fetch-native/proxy' is a neat addition. Verify that createProxy gracefully handles an undefined proxyUrl.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    The comment is asking the author to verify the behavior of a function when given an undefined input. This falls under asking the author to ensure the behavior is intended, which is against the rules.
5. packages/@deeplx/core/src/translate.ts:3
  • Draft comment:
    Switching from fetchApi to xfetch should be reviewed to ensure behavior consistency. Confirm that xfetch’s error handling and request options align with previous expectations.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
6. package.json:35
  • Draft comment:
    Removed unused '@types/web' dependency. Confirm it isn’t required by any part of the code.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
7. package.json:56
  • Draft comment:
    Using resolutions for 'node-fetch', 'undici', and 'undici-types' is intentional. Verify that enforcing these versions doesn’t conflict with any dependent packages.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
8. packages/@deeplx/cli/src/fetch.ts:4
  • Draft comment:
    Removed obsolete '@ts-expect-error' comments. Confirm that globalThis.fetch and globalThis.Headers now have compatible types.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
9. packages/@deeplx/core/package.json:48
  • Draft comment:
    Added the 'node-fetch-native' dependency for proxy support. Ensure its version remains compatible with the resolutions enforced in the root package.json.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
10. packages/@deeplx/core/src/constants.ts:79
  • Draft comment:
    Using 'as const satisfies HeadersInit' improves type safety for COMMON_HEADERS. Verify that consumers of COMMON_HEADERS don’t require mutable headers.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
11. packages/@deeplx/core/src/translate.ts:1
  • Draft comment:
    Importing 'createProxy' enables proxy support—ensure that createProxy handles an undefined proxyUrl gracefully.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The comment is speculative - it's asking to verify behavior rather than pointing out a definite issue. We don't have evidence that createProxy doesn't handle undefined gracefully. The library node-fetch-native/proxy is a third-party dependency that we should assume works correctly. The code already properly handles proxyUrl as optional.
    The comment could be valid if there's evidence that createProxy throws errors with undefined urls. The proxy handling could be important for reliability.
    Without concrete evidence of an issue, this is just speculative. The comment is asking for verification rather than pointing out a clear problem that needs fixing.
    Delete this comment as it's speculative and asks for verification without evidence of an actual issue. We should assume third-party libraries work correctly unless proven otherwise.
12. packages/@deeplx/core/src/translate.ts:3
  • Draft comment:
    Switched from 'fetchApi' to 'xfetch'. Ensure that 'xfetch' supports all required options, especially proxy configurations.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
13. packages/@deeplx/core/src/translate.ts:42
  • Draft comment:
    Consider conditionally including the proxy options only when proxyUrl is provided. Ensure createProxy returns a no-op or empty object if proxyUrl is undefined.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
14. packages/@deeplx/core/src/translate.ts:33
  • Draft comment:
    Update the comment for the proxyUrl parameter—remove misleading 'unsupported yet' text now that proxy support is implemented.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
15. package.json:2
  • Draft comment:
    The package name is set to '@unts/deeplx', but the repository URL uses 'un-ts/deeplx.git'. It seems there is an inconsistency (possibly a missing hyphen) between the package name and the repository owner. Please verify if this is intentional or a typo.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_FVdGA0Fi2BqIyf4F


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/@deeplx/core/src/translate.ts (1)

33-33: Changed parameter name to reflect actual usage.

Renaming from _proxyUrl to proxyUrl indicates this parameter is now actively used rather than just reserved for future implementation. However, the comment "unsupported yet" should be removed since the feature is now supported.

-  proxyUrl?: string, // unsupported yet
+  proxyUrl?: string,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b07662 and 9a550abf4f1cabae6fc1e0ab97a761c9c4d2160b.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • package.json (1 hunks)
  • packages/@deeplx/cli/src/fetch.ts (0 hunks)
  • packages/@deeplx/core/package.json (1 hunks)
  • packages/@deeplx/core/src/constants.ts (3 hunks)
  • packages/@deeplx/core/src/translate.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/@deeplx/cli/src/fetch.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/@deeplx/core/src/translate.ts (3)
packages/@deeplx/core/src/types.ts (1)
  • TranslationResponse (75-85)
packages/@deeplx/core/src/constants.ts (2)
  • API_URL (60-60)
  • COMMON_HEADERS (69-82)
packages/@deeplx/core/src/utils.ts (1)
  • formatPostString (31-40)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (7)
packages/@deeplx/core/package.json (1)

51-51: LGTM: Added dependency for proxy support.

The addition of node-fetch-native is appropriate for implementing the proxy support mentioned in the PR title.

package.json (2)

53-53: LGTM: Updated dependency version.

Updating yarn-berry-deduplicate to the latest version is a good maintenance practice.


56-59: LGTM: Added appropriate dependency resolutions.

The added resolutions ensure consistent fetch implementations across the project:

  1. Redirecting node-fetch to node-fetch-native aligns with the new proxy support feature
  2. Standardizing undici and undici-types versions prevents potential compatibility issues

These changes follow good package management practices.

packages/@deeplx/core/src/constants.ts (2)

1-1: LGTM: Added import for improved type safety.

Importing HeadersInit from 'undici' provides proper typing for the headers object.


69-82: LGTM: Improved type safety with const assertion.

Using as const satisfies HeadersInit provides two benefits:

  1. as const makes the object immutable with literal types
  2. satisfies HeadersInit ensures the object conforms to the expected interface

This is a TypeScript best practice for constants that need to maintain both their literal types and interface compatibility.

packages/@deeplx/core/src/translate.ts (2)

1-3: LGTM: Updated imports to support proxy functionality.

The changes appropriately:

  1. Import createProxy from 'node-fetch-native/proxy' to enable proxy support
  2. Replace fetchApi with xfetch for a more consistent fetch implementation

36-43: LGTM: Implemented proxy support.

The implementation correctly:

  1. Switches from fetchApi to xfetch
  2. Uses createProxy({ url: proxyUrl }) to enable proxy configuration when specified

This allows the function to work through a proxy when needed, which is the main feature of this PR.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Incremental review on 25d94af in 1 minute and 37 seconds

More details
  • Looked at 124 lines of code in 6 files
  • Skipped 1 files when reviewing.
  • Skipped posting 11 drafted comments based on config settings.
1. packages/@deeplx/core/src/translate.ts:1
  • Draft comment:
    Importing createProxy is good. Consider verifying that createProxy handles undefined or empty proxyUrl gracefully.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
2. packages/@deeplx/core/src/translate.ts:42
  • Draft comment:
    Spreading createProxy output is concise; consider validating proxyUrl before passing to createProxy if needed.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
3. packages/@deeplx/cli/src/fetch.ts:1
  • Draft comment:
    Switch to node-fetch-native import looks correct; ensure global fetch/Headers override works in all environments.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50%
    None
4. package.json:55
  • Draft comment:
    Review resolutions: Ensure node-fetch-native and undici versions are fully compatible with all dependent packages.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is asking the PR author to ensure compatibility of dependencies, which is against the rules. It doesn't provide a specific suggestion or point out a specific issue with the code.
5. packages/@deeplx/cli/src/fetch.ts:3
  • Draft comment:
    If type issues are resolved with node-fetch-native, consider removing the eslint-disable comments for global assignments.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
6. packages/@deeplx/core/src/constants.ts:69
  • Draft comment:
    Ensure 'as const satisfies HeadersInit' is supported in your TS config if targeting older TypeScript versions.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None
7. packages/@deeplx/core/src/translate.ts:33
  • Draft comment:
    Update the proxyUrl parameter comment to reflect that proxy support is now active (remove 'unsupported yet').
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    The comment is correct - the code now clearly uses the proxyUrl parameter with createProxy, so the comment saying it's "unsupported yet" is outdated and incorrect. However, this is just a documentation update, not a code quality or logic issue. Our rules say to only comment if there's clearly a code change required.
    Documentation accuracy is important for maintainability. Outdated comments can mislead developers.
    While accurate documentation is valuable, our explicit rules state to only comment when code changes are required. Documentation-only changes are not in scope.
    Delete the comment since it only suggests a documentation update rather than a required code change.
8. packages/@deeplx/core/src/translate.ts:42
  • Draft comment:
    Consider validating proxyUrl before spreading proxy settings to avoid issues when proxyUrl is undefined or empty.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 30% vs. threshold = 50%
    The comment makes a valid point about defensive programming. However, looking at the code, createProxy() is imported from node-fetch-native/proxy, which is a third-party library. Without knowing how that library handles undefined/empty URLs, we can't be certain there's actually a problem. The library may already handle this case gracefully.
    I may be too quick to dismiss potential runtime issues. An undefined proxyUrl could cause problems if the library doesn't handle it well.
    While the concern is valid, we don't have enough context about the createProxy function's behavior to be certain this is an issue. The library may already handle this case appropriately.
    Delete the comment since we don't have strong evidence that this is actually a problem without knowing how createProxy handles undefined values.
9. packages/@deeplx/core/src/translate.ts:36
  • Draft comment:
    Verify that xfetch provides behavior equivalent to the previous fetchApi, especially regarding custom headers and proxy support.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    The comment is asking the PR author to verify the behavior of xfetch compared to fetchApi, which violates the rule against asking the author to confirm or verify behavior. It does not provide a specific suggestion or point out a specific issue.
10. package.json:2
  • Draft comment:
    It looks like the package is named "@unts/deeplx", but given that the repository owner is "un-ts", please confirm if this naming is intentional or if it should be made consistent.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
11. package.json:6
  • Draft comment:
    The author's name is listed as "JounQin". Please verify if this is the intended spelling or if it should be corrected (e.g., "JonQin").
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_8AzAnLIuRsbhiWN5


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

JounQin and others added 2 commits April 19, 2025 02:14
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Copy link

@JounQin JounQin merged commit 65855bf into master Apr 18, 2025
26 checks passed
@JounQin JounQin deleted the feat/proxy branch April 18, 2025 18:22
@github-actions github-actions bot mentioned this pull request Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant