Skip to content

Conversation

@jeffredodd
Copy link
Contributor

Summary

Upgrades us to a current default API version. Also adds a helper function to handle type transformation between API responses (which use null) and request payloads (which expect undefined).

Context

The embedded API returns null for missing/empty values in responses, but expects undefined in request payloads. This mismatch causes TypeScript errors when passing response data directly to update mutations.

Changes

  • ✨ Created nullToUndefined helper that recursively converts nullundefined
  • 🔧 Updated PayrollEditEmployee to use helper for transformation
  • 🔧 Updated PayrollConfiguration to use helper for transformation
  • ✅ Added comprehensive test coverage (11 tests)

Testing

  • All existing tests pass (187 tests)
  • New helper has 100% code coverage
  • Tested with complex nested objects and arrays

Copy link
Contributor

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 upgrades the embedded API package and introduces a type-safe helper to handle the null/undefined mismatch between API responses and request payloads. The API returns null for missing values but expects undefined in mutations.

  • Added nullToUndefined helper with recursive type transformation
  • Updated employee compensation transformations to use the helper
  • Upgraded @gusto/embedded-api from 0.8.1 to 0.10.0

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/helpers/nullToUndefined.ts New recursive helper that converts null to undefined in objects and arrays
src/helpers/nullToUndefined.test.ts Comprehensive test suite with 11 test cases covering edge cases
src/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx Applied helper to employee compensation transformation
src/components/Payroll/PayrollConfiguration/PayrollConfiguration.tsx Applied helper to payroll configuration compensation transformation
package.json Updated embedded API dependency version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

...compensation
}: PayrollEmployeeCompensationsType): PayrollUpdateEmployeeCompensations => {
return {
return nullToUndefined({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@serikjensen I really don't like that I did this, but maybe we chat about it in parking lot because I also have API questions that the team might know.

Basically, Cursor, is worried that we have a type mismatch between getting nulls from our server, and it wanting to take a type or undefined back.

So this is converting nulls we get from the API here to undefined.

I don't love it

@socket-security
Copy link

socket-security bot commented Nov 4, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • typescript@5.9.3

View full report

@jeffredodd jeffredodd changed the title fix: add nullToUndefined helper to transform API response types fix: Upgrade @gusto/embeded-api to 0.10.0 Nov 4, 2025
@jeffredodd
Copy link
Contributor Author

@SocketSecurity ignore npm/typescript@5.9.3

@jeffredodd jeffredodd force-pushed the jdj/api-upgrade-0.9 branch 2 times, most recently from 3317e9e to 2c8d9a9 Compare November 4, 2025 19:47
- Created nullToUndefined helper that recursively converts null to undefined
- Updated PayrollEditEmployee and PayrollConfiguration to use the helper
- Fixes type mismatch between API responses (null) and requests (undefined)
- Added comprehensive test coverage (11 tests)
- Upgraded @gusto/embedded-api from 0.8.1 to 0.10.0
- All tests, linting, and build passing
@jeffredodd jeffredodd enabled auto-merge (squash) November 4, 2025 23:35
@jeffredodd jeffredodd merged commit 714b753 into main Nov 4, 2025
9 checks passed
@jeffredodd jeffredodd deleted the jdj/api-upgrade-0.9 branch November 4, 2025 23:37
jeffredodd added a commit that referenced this pull request Nov 5, 2025
jeffredodd added a commit that referenced this pull request Nov 5, 2025
Revert "fix: Upgrade @gusto/embeded-api to 0.10.0 (#749)"

This reverts commit 714b753.
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