Skip to content
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

Simplifies type generation for hooks #2723

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nick-Ag
Copy link
Member

@nick-Ag nick-Ag commented Feb 4, 2025

This PR addresses an issue that came up when adding object type hook input fields. The type generation couldn't properly define the nested shape of the properties and would incorrectly generate something like this:

export interface HookBundle {
  onMappingSave: {
    [k: string]: unknown
  }
}

In general the HookBundle previously would have a shape such as this:

export interface HookBundle {
  onMappingSave: {
    inputs?: { ... }
    outputs?: { ... }
  }
}

And I've updated it to flatter shape which cleanly generates nested object properties like this:

export interface OnMappingSaveInputs {
  name: string
  ...
  columns?: {
    name: string
    ...
  }[]
}

export interface OnMappingSaveOutputs {
...
}

Testing

This change should be non-functional, since it only applies to action hook types.
Tested successfully in stage against LinkedIn Conversions API: Could successfully create a Conversion rule with the actions onMappingSave hook

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Project coverage is 79.07%. Comparing base (52537f3) to head (a19c327).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
packages/cli/src/commands/generate/types.ts 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2723      +/-   ##
==========================================
+ Coverage   78.46%   79.07%   +0.61%     
==========================================
  Files        1036     1089      +53     
  Lines       18771    21534    +2763     
  Branches     3561     4312     +751     
==========================================
+ Hits        14729    17029    +2300     
- Misses       2844     3298     +454     
- Partials     1198     1207       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nick-Ag nick-Ag changed the title [wip dont review] Hooks type generation cleanup Simplifies type generation for hooks Feb 5, 2025
@nick-Ag nick-Ag marked this pull request as ready for review February 5, 2025 00:52
@nick-Ag nick-Ag requested a review from a team as a code owner February 5, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant