ChuckJonas / ts-force

A Salesforce REST Client written in Typescript for Typescript
88 stars 21 forks source link

Fix field mapping camelcase #82

Closed CarsonF closed 4 years ago

CarsonF commented 4 years ago

Previously the wrong first letter was being used because it was pulling from the raw, uncleaned API name.

Using lodash's camelCase we can handle other cases too: API Before Now Best
npe01SYSTEMIsIndividualc sYSTEMIsIndividual systemIsIndividual same as now
No_of_Years_as_a_Donor__c noofYearsasaDonor noOfYearsAsADonor same as now
Do_Not_Invite_to_forWORD__c doNotInvitetoforWORD doNotInviteToForWord doNotInviteToForWORD
Children_s_Names_and_DOB__c childrensNamesandDOB childrenSNamesAndDob childrensNamesAndDOB

It doesn't handle all cases as noted with difference between now and best, but I think it gets closer.

ChuckJonas commented 4 years ago

Nice, ya this seems like it will give more consistent result. Right now it relies on the casing of the API name itself being standardized and consistent.

I would suggest that we don't include the entire lodash library as it's actually quite large ~(75kb), and the build process doesn't currently use any type of tree-shaking.

I believe we can install just a single lodash function:

npm install --save lodash.camelCase

CarsonF commented 4 years ago

I didn't think size mattered. That was the point of moving the generator into a separate library. It's only ran server side. Right?

Also those packages are deprecated and will be removed in v5

ChuckJonas commented 4 years ago

duh!

lol, sorry I wasn't using my brain. Ya, we can add pretty much whatever to the generator.