Skip to content

Conversation

@AaronDDM
Copy link
Collaborator

@AaronDDM AaronDDM commented Oct 6, 2025

Summary

Migrates the SDK from node-fetch to Node.js 18+ native fetch API, removes fetch wrapper abstraction, updates Node.js engine requirements, and adds a Cloudflare Workers example.

Changes

Native Fetch Migration

  • Removed node-fetch dependency
  • Removed fetch wrapper files (fetchWrapper.ts, fetchWrapper-esm.ts, fetchWrapper-cjs.ts, setupFetchWrapper.js)
  • Updated API client to use native fetch, Request, and Response APIs
  • Simplified build process (removed fetch wrapper setup step)

Node.js Requirements

  • Updated minimum Node.js version: >=16>=18
  • Updated CI to test Node.js 18.x, 20.x, 24.x, 25.x

Type Updates

  • Changed stream types from NodeJS.ReadableStream to ReadableStream<Uint8Array>
  • Updated return types in apiClient.ts, attachments.ts, and resource.ts

Test Fixes

  • Fixed double-promise wrapping bug in attachments.spec.ts (changed mockResolvedValue(Promise.resolve(mockStream)) to mockResolvedValue(mockStream))
  • Updated tests to use native Web APIs
  • Removed fetch wrapper tests

Cloudflare Workers Example

  • Added examples/cloudflare-vite-calendars/ with calendar event manager
  • Includes Vite integration, documentation (README, QUICKSTART, FEATURES), and production configuration

Documentation

  • Updated examples README with Cloudflare Workers and module system sections

Impact

  • Breaking change: Requires Node.js 18+

Migration

Users upgrading from Node.js 16 need to upgrade to Node.js 18+. No code changes required - API remains the same.

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

…dule system examples, enhancing documentation for better user guidance.
- Deleted the fetch wrapper implementation for both CJS and ESM builds, simplifying the codebase.
- Updated Node.js engine requirement in package.json and package-lock.json to >=18.
- Adjusted APIClient and resource methods to use native Fetch API and ReadableStream.
- Updated tests to reflect changes in request handling and response types.
@dremnik
Copy link

dremnik commented Oct 21, 2025

What's the status of this? The response.buffer() call is currently breaking our attachment downloads in Node 22

@AaronDDM
Copy link
Collaborator Author

Sorry for the delay. Next week I should have something to go here.

@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@336bc5f). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #680   +/-   ##
=======================================
  Coverage        ?   98.60%           
=======================================
  Files           ?       35           
  Lines           ?      789           
  Branches        ?       67           
=======================================
  Hits            ?      778           
  Misses          ?       11           
  Partials        ?        0           

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

…, 24.x, and 25.x, enhancing compatibility with the latest Node.js releases.
- Added error handling for missing 'archiver' module with installation instructions.
- Improved dependency installation process to include all dependencies before building.
- Added verification steps for the generated handler.js file to ensure proper exports.
- Updated README.md with detailed error messages for handler configuration and API Gateway setup.
- Refactored multipart form data parsing for better error handling and clarity in the handler function.
…d error handling

- Cleaned up whitespace and formatting in build-manual.ts for better readability.
- Enhanced error messages in handler.ts for multipart form data parsing and missing fields.
- Improved logging for request handling and email sending processes.
- Ensured consistent formatting and structure in the handler function for better maintainability.
…ing and timeout settings

- Changed the Nylas dependency in package-lock.json to a specific version for consistency.
- Added a timeout setting to the Nylas client initialization in handler.ts.
- Enhanced logging of attachment details in the email sending process.
- Updated APIClient to properly handle form data encoding with FormDataEncoder and added duplex support for streaming requests.
- Adjusted tests to verify correct handling of form data and content-type headers.
…d payload size calculation

- Added tests to handle responses without headers.entries method in APIClient.
- Implemented tests for requestWithResponse to ensure proper handling of mock responses.
- Introduced tests for calculating total payload size, including scenarios with and without attachments.
- Added tests for converting object keys to camelCase and snake_case in nested arrays.
@AaronDDM AaronDDM merged commit 12f204d into main Dec 9, 2025
8 checks passed
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.

4 participants