salesforce-sanitize

1.0.0 • Public • Published

Salesforce Sanitize

This function transforms objects to Salesforce keys and to JavaScript keys

API

sanitize(schema: array, onConflict? = function, input: object)

This function supports currying

Valid invocations:

sanitize([{ name: 'Custom__c', type: 'reference' }], (a, b) => a, { custom: '1234' })
const transform = sanitize([{ name: 'Custom__c', type: 'reference' }], (a, b) => a)
transform({ custom: '1234' })
const transform = sanitize([{ name: 'Custom__c', type: 'reference' }])
transform({ custom: '1234' })

Usage

const sanitize = require('@vivintsolar/salesforce-santize');
const schema = require('./path/to/jsforce/describe/schema.json');
 
const opportunityMapper = sanitize(schema, (left, right) => {
  console.error('Salesforce field collision!!', left, right);
  return left;
})
 
module.exports = (input) => {
  return opportunityMapper(input);
};

Handling Collisions

If your schema encounters a collision, you need to notify the salesforce team that they have a data problem.

Collisions should never be handled in service code as a long term solution.

In the interim, you can hard-code resolution to the "correct" field, but these hacks should be prioritized to be removed.

Readme

Keywords

Package Sidebar

Install

npm i salesforce-sanitize

Weekly Downloads

0

Version

1.0.0

License

ISC

Last publish

Collaborators

  • vivintsolar-dev