Skip to content

feat: expose fetch option on ManagementClient#1372

Closed
harshithRai wants to merge 2 commits into
masterfrom
ghIssue1330
Closed

feat: expose fetch option on ManagementClient#1372
harshithRai wants to merge 2 commits into
masterfrom
ghIssue1330

Conversation

@harshithRai

@harshithRai harshithRai commented Jul 16, 2026

Copy link
Copy Markdown

Changes

Exposes a fetch option on ManagementClient so consumers can supply their own HTTP transport. The internal fetcher layer (#1238) already routes through fetcherImpl(args.fetchFn ?? …), but the public wrapper both omitted fetch from ManagementClientOptions and explicitly deleted it in the constructor; so there was no supported way to plug one in.

  • ManagementClientOptions: drop "fetch" from the Omit<FernClient.Options, …> list so the field is part of the public surface.
  • ManagementClient constructor: stop deleting _options.fetch. The internal fetcher is still stripped (Fern implementation detail), with a comment explaining why and linking Adding support for fetch options in V5? #1330.
  • Add an enriched JSDoc on the fetch field (proxies/egress, retry middleware, OpenTelemetry, Cloudflare Workers/Bun).

Source-compatible: existing call sites that don't pass fetch are unaffected. Callers can now opt in:

new ManagementClient({
  domain: 'your-tenant.auth0.com',
  token: '...',
  fetch: myInstrumentedFetch,
});

References

Please include relevant links supporting this change such as a:

Testing

New unit test in src/management/tests/unit/management-client-fetch.test.ts:

  1. Constructs a ManagementClient with a custom fetch, calls client.rules.list(), and asserts the custom fetch was invoked against tenant.auth0.com/api/v2/rules and that the parsed return value matches the payload it served.
  2. Constructs a ManagementClient without fetch to confirm the default global-fetch route is unchanged.
    Verified the test fails to compile without the source change (regression guard). tsc --noEmit clean; existing unit tests pass.
  • This change adds unit test coverage
  • This change adds integration test coverage

Checklist

@harshithRai
harshithRai marked this pull request as ready for review July 16, 2026 04:28
@harshithRai
harshithRai requested a review from a team as a code owner July 16, 2026 04:28
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.75%. Comparing base (a823058) to head (193c32a).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1372      +/-   ##
==========================================
- Coverage   89.76%   89.75%   -0.01%     
==========================================
  Files         431      431              
  Lines       20108    20107       -1     
  Branches     9782     9452     -330     
==========================================
- Hits        18049    18048       -1     
  Misses       2059     2059              
Flag Coverage Δ
alltests 89.75% <ø> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
src/management/wrapper/ManagementClient.ts 100.00% <ø> (ø)
🚀 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.

@harshithRai
harshithRai marked this pull request as draft July 16, 2026 08:07
@harshithRai

Copy link
Copy Markdown
Author

closing as duplicate of #1352

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.

Adding support for fetch options in V5?

1 participant