A small TypeScript script that maps person data from inputData.json using mappings.json and synchronizes it with Pipedrive.
npm installCreate .env in the project root:
PIPEDRIVE_API_KEY=your_api_token
PIPEDRIVE_COMPANY_DOMAIN=your_company_domainRun the project:
npm run devFor the compiled version:
npm run build
npm startRun the mapping checks with:
npm test- Read the input person and field mappings.
- Build a Pipedrive person payload from the mappings.
- Find the mapping for
nameand use its input value to search Pipedrive. - Update the matching person when one exact match is found.
- Create a new person when no match is found.
- Stop instead of guessing when multiple exact matches are returned.
Email and phone mappings are converted to Pipedrive's emails and phones arrays. Dot-separated input paths such as phone.home are supported.
- Missing name mapping: the sync stops because the name is required to find the existing person.
- Empty mapped name: the sync stops before making an API request.
- Multiple exact matches: the sync stops instead of updating an arbitrary person.
- API/network failure: the Pipedrive client throws an error with the HTTP status or network failure so the caller can exit cleanly.
src/
index.ts
lib/
mapping.ts
mapping.test.ts
pipedrive.ts
mappings/
inputData.json
mappings.json
types/
mapping.ts
pipedrive.ts
The mapping functions are kept separate from the Pipedrive client so the data transformation can be tested without making real API requests.
The API token is read from the environment and is not part of the source code. Do not commit .env.