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

salesforce Add helper for validating and format input data #883

Merged
merged 11 commits into from
Jan 10, 2025

Conversation

mtuchi
Copy link
Collaborator

@mtuchi mtuchi commented Jan 8, 2025

Summary

Add utils helper validateNoDotKeys and flattenData to help with validation of input data when using upsert, update or create and to transform nested object into a dot notation syntax when using bulk operation.

Fixes #556

Details

When mapping a salesforce data model there is a bit of confusion on when to use the dot notation and when not to. Since the best practice when mapping objects is to always use a nested object for relationship, it's important that the adaptor adds a safe check when you forgot and use the dot notation to map salesforce relationship. This PR adds two things

  1. A validation step for upsert, update and create function. This is achieved by the new util helper validateNotDotKeys
  2. A transformer to a dot notation syntax when using bulk function. This is done by the flattenData util helper

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Review Checklist

Before merging, the reviewer should check the following items:

  • Does the PR do what it claims to do?
  • If this is a new adaptor, added the adaptor on marketing website ?
  • Are there any unit tests?
  • Is there a changeset associated with this PR? Should there be? Note that
    dev only changes don't need a changeset.
  • Have you ticked a box under AI Usage?

@mtuchi mtuchi changed the title 556 dot mapping salesforce Add helper for validating and format input data Jan 8, 2025
@mtuchi mtuchi requested a review from josephjclark January 8, 2025 12:24
@mtuchi mtuchi marked this pull request as ready for review January 8, 2025 12:24
packages/salesforce/src/Adaptor.js Outdated Show resolved Hide resolved
packages/salesforce/src/Utils.js Outdated Show resolved Hide resolved
packages/salesforce/src/Utils.js Outdated Show resolved Hide resolved
packages/salesforce/src/Utils.js Outdated Show resolved Hide resolved
packages/salesforce/test/Utils.test.js Outdated Show resolved Hide resolved
@josephjclark josephjclark mentioned this pull request Jan 8, 2025
4 tasks
@mtuchi mtuchi requested a review from josephjclark January 10, 2025 10:46
@josephjclark
Copy link
Collaborator

Hey @mtuchi we need super clear docs on this to avoid confusion in the future.

I've updated the changeset to remove irrelevant stuff (users don't need to know about private internal APIs we've added) and to explain the changes. I've also added docs and example to each affected function.

Can you just check that this looks all correct? Any other suggestions as to how to best communicate this?

@mtuchi
Copy link
Collaborator Author

mtuchi commented Jan 10, 2025

Thanks @josephjclark for the suggestions edit. I made tiny changes to the error message to give user more context if they want to map relationship records

@mtuchi mtuchi requested a review from josephjclark January 10, 2025 15:01
@josephjclark josephjclark merged commit ae31cdd into epic/salesforce Jan 10, 2025
2 checks passed
@josephjclark josephjclark deleted the 556-dot-mapping branch January 10, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants