-
Notifications
You must be signed in to change notification settings - Fork 123
Refactor: Remove fetch wrapper and update Node.js engine requirement #680
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
Conversation
…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.
|
What's the status of this? The response.buffer() call is currently breaking our attachment downloads in Node 22 |
|
Sorry for the delay. Next week I should have something to go here. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
…, 24.x, and 25.x, enhancing compatibility with the latest Node.js releases.
…with APIClient requestStream
…ending email attachments with Nylas SDK
07b50ba to
9bfac4f
Compare
- 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.
Summary
Migrates the SDK from
node-fetchto Node.js 18+ nativefetchAPI, removes fetch wrapper abstraction, updates Node.js engine requirements, and adds a Cloudflare Workers example.Changes
Native Fetch Migration
node-fetchdependencyfetchWrapper.ts,fetchWrapper-esm.ts,fetchWrapper-cjs.ts,setupFetchWrapper.js)fetch,Request, andResponseAPIsNode.js Requirements
>=16→>=18Type Updates
NodeJS.ReadableStreamtoReadableStream<Uint8Array>apiClient.ts,attachments.ts, andresource.tsTest Fixes
attachments.spec.ts(changedmockResolvedValue(Promise.resolve(mockStream))tomockResolvedValue(mockStream))Cloudflare Workers Example
examples/cloudflare-vite-calendars/with calendar event managerDocumentation
Impact
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.