Skip to content

Conversation

@AaronDDM
Copy link
Collaborator

@AaronDDM AaronDDM commented Aug 27, 2025

What did you do?

  • add tests for rawHeaders on responses
  • update response models to include rawHeaders
  • attach rawHeaders in API client without breaking equality

Addresses #659

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.

…rable rawHeaders; keep existing camelCased headers intact

- add tests for rawHeaders on responses
- update response models to include rawHeaders
- attach rawHeaders in API client without breaking equality
@playerzero-ai
Copy link

playerzero-ai bot commented Aug 27, 2025

Pull Request Summary

  • New Features:

    • Introduced a flowId field in response interfaces (NylasBaseResponse, NylasResponse, and NylasListResponse) to aid in tracing requests and responses.
    • Added rawHeaders to responses, providing original dashed lowercase headers for better compatibility and clarity.
  • Deprecations:

    • Deprecated the headers field in favor of rawHeaders in response interfaces, indicating a shift towards using a more standardized header format.
  • Testing Enhancements:

    • Updated tests to include checks for rawHeaders, ensuring specific headers like x-fastly-id and x-request-id are accessible and verifiable.
    • Ensured consistency in handling API responses by implementing rawHeaders in both mock and actual API call scenarios.
  • Response Handling Improvements:

    • Modified the requestWithResponse method to use a structured approach for merging flowId and headers with the response JSON.
    • Introduced a non-enumerable rawHeaders property to avoid issues with deep equality checks, improving response processing clarity and maintainability.
  • Future Considerations:

    • The deprecation of headers suggests a future update where this field might be removed or handled differently, indicating ongoing improvements in response data management.

Functional Tests

  • Verify that the flowId is correctly added to both NylasBaseResponse and NylasListResponse and is retrievable for tracing requests and responses.
  • Test that rawHeaders are accessible in API responses with original dashed lowercase keys and include keys like x-fastly-id, x-request-id, x-nylas-api-version, x-rate-limit-limit, and x-rate-limit-remaining.
  • Ensure that headers are still present in the response for backward compatibility, but marked as deprecated, and verify that they are camelCased.
  • Check that rawHeaders are non-enumerable and do not interfere with deep equality checks in response objects.
  • Validate that the requestWithResponse method correctly merges parsed JSON with flowId and headers into a new payload object.
  • Confirm that both mock and actual API call scenarios consistently handle rawHeaders in the responses.

Files Changed

File Name Summary
src/models/response.ts Added flowId to response interfaces for tracing; deprecated headers in favor of rawHeaders to provide original dashed lowercase headers.
tests/apiClient.spec.ts Added tests for rawHeaders in API responses, verifying specific header keys; implemented rawHeaders support in both mocked and real request tests.
src/apiClient.ts Refined requestWithResponse to merge parsed JSON with flowId and deprecated headers in a new payload object; added non-enumerable rawHeaders property to store original headers, improving response handling and future-proofing.

View more in PlayerZero
updated: Aug 28 @ 02:13 AM UTC

@codecov
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.87%. Comparing base (d4079e7) to head (da3d7c1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #660   +/-   ##
=======================================
  Coverage   94.87%   94.87%           
=======================================
  Files          35       35           
  Lines         781      781           
  Branches       66       66           
=======================================
  Hits          741      741           
  Misses         33       33           
  Partials        7        7           

☔ 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

@uriell-keeper uriell-keeper left a comment

Choose a reason for hiding this comment

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

approved w/ a non blocking comment, looks good!

@AaronDDM AaronDDM merged commit 7fe13ff into main Aug 28, 2025
7 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