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

feat: field mapping and custom schema #207

Merged
merged 52 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
9d76060
prisma migration to add field mapping schemas
hvinder Aug 23, 2023
4d21d8b
seed hs note model (unverified)
hvinder Aug 23, 2023
df2c7c5
seed hs note model (verified)
hvinder Aug 23, 2023
fcf1176
seed hs note model
hvinder Aug 23, 2023
ebf067e
transform note acc to schema mapping
hvinder Aug 24, 2023
2e5257c
(approach 2) transform note acc to schema field mapping
hvinder Aug 24, 2023
fb6717e
(approach 2) seed all note fields and fix single note structure
hvinder Aug 24, 2023
dd8aad0
minor fix
hvinder Aug 24, 2023
144fb04
common func to transform field mapping to model
hvinder Aug 24, 2023
8f3ccf3
disunify using field mapping
hvinder Aug 25, 2023
a56b065
allow connections to override field mapping
hvinder Aug 28, 2023
bb8e27a
support custom objects in schema; show custom fields as additional
hvinder Aug 28, 2023
fa51a0a
add winston and morgan logger
hvinder Aug 29, 2023
2d9b575
Field mapping for contact; support custom field mapping to custom crm…
hvinder Aug 30, 2023
601caca
add field mapping config
hvinder Aug 31, 2023
d9dedf5
common unify and disunify methods
hvinder Aug 31, 2023
a8e73d6
seed contact field mapping
hvinder Sep 1, 2023
5230efc
use lodash get to transform nested mappings
hvinder Sep 1, 2023
2768598
unify and disunify for contact
hvinder Sep 1, 2023
60b4e8f
disunify based on account config
hvinder Sep 4, 2023
2732938
unify and disunify for company
hvinder Sep 4, 2023
f366349
unify and disunify for deal
hvinder Sep 5, 2023
3e0e890
unify and disunify for event
hvinder Sep 5, 2023
b672234
unify and disunify for lead
hvinder Sep 6, 2023
b3aa64e
unify and disunify for task
hvinder Sep 6, 2023
d601167
unify and disunify for user
hvinder Sep 6, 2023
ef7ec12
minor refactor
hvinder Sep 6, 2023
5ccb267
handle 2 level nesting and fix mapping
hvinder Sep 7, 2023
ac63708
make target field optional; multi level nesting
hvinder Sep 7, 2023
16d2fd9
fix
hvinder Sep 7, 2023
f2076b7
fix
hvinder Sep 7, 2023
59bfaa1
fix obj merge
hvinder Sep 7, 2023
b9d6c3e
fix pipedrive get format
hvinder Sep 7, 2023
171ccbe
preprocess
hvinder Sep 7, 2023
d7df0c6
preprocess unify and disunify
hvinder Sep 8, 2023
6afaefd
disunify postprocess
hvinder Sep 11, 2023
2ba43d1
flatten before disunify
hvinder Sep 11, 2023
930e213
pipedrive fix contact create
hvinder Sep 11, 2023
73e7b51
minor fixes
hvinder Sep 12, 2023
eb3dd88
fix pipedrive lead disunify
hvinder Sep 12, 2023
f01765c
chore: add account id to morgan logs
hvinder Sep 25, 2023
46c0428
chore: cleanup
hvinder Sep 26, 2023
f6cd051
chore: cleanup
hvinder Sep 26, 2023
17cd4fa
chore: cleanup
hvinder Sep 26, 2023
0e333a8
feat: ui for field mapping (#242)
hvinder Sep 27, 2023
5165a5c
feat: add remove mapping btn and divider
hvinder Sep 27, 2023
10d9533
fix: fix logger
hvinder Sep 27, 2023
655502e
chore: cleanup
hvinder Sep 27, 2023
44ac756
chore: move endpoints to fern
hvinder Sep 29, 2023
fad4f9f
update yarn.lock
jatinsandilya Oct 2, 2023
bca170d
fix issues
jatinsandilya Oct 2, 2023
3aa4dba
add hubspot create custom properties api
jatinsandilya Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ npm-debug.log*
!.github/**/*.yml
!fern/**/*.yml
revert-dev.js
.yarn/install-state.gz
Binary file modified .yarn/install-state.gz
Binary file not shown.
10 changes: 10 additions & 0 deletions fern/api/definition/common/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ types:
- zohocrm
- sfdc
- pipedrive
StandardObject:
enum:
- company
- contact
- deal
- event
- lead
- note
- task
- user
ResponseStatus:
enum:
- ok
Expand Down
75 changes: 75 additions & 0 deletions fern/api/definition/crm/field-mapping/field-mapping.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

imports:
errors: ../../common/errors.yml
types: ../../common/types.yml

types:
MappableFieldType:
properties:
fieldName: string
objectName: types.StandardObject
FieldDetailsType:
properties:
fieldName: string
fieldType: string
fieldDescription: string
FieldMappingType:
properties:
sourceFieldName: string
targetFieldName: string
object: string
GetFieldMappingResponse:
properties:
canAddCustomMapping: boolean
mappableFields: list<MappableFieldType>
fieldList: unknown
CreateFieldMappingRequestBody:
properties:
standardMappings: list<FieldMappingType>
customMappings: list<FieldMappingType>
CreateFieldMappingResponse:
properties:
status: types.ResponseStatus

service:
base-path: /crm/field-mapping
auth: false
headers:
x-revert-api-token:
type: optional<string>
docs: Your official API key for accessing revert apis.
x-revert-t-id:
type: string
docs: The unique customer id used when the customer linked their account.
x-revert-t-token:
type: optional<string>
docs: The temp used to identify tenant.
x-api-version:
type: optional<string>
docs: Optional Revert API version you're using. If missing we default to the latest version of the API.
audiences:
- external
endpoints:
getFieldMapping:
docs: Get field mappings for a connection
method: GET
path: ''
request:
name: GetFieldMappingRequest
response: GetFieldMappingResponse
errors:
- errors.UnAuthorizedError
- errors.InternalServerError
createFieldMapping:
docs: Create field mappings for a connection
method: POST
path: ''
request:
name: CreateFieldMappingRequest
body: CreateFieldMappingRequestBody
response: CreateFieldMappingResponse
errors:
- errors.UnAuthorizedError
- errors.InternalServerError
- errors.NotFoundError
64 changes: 64 additions & 0 deletions fern/api/definition/crm/properties.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

imports:
errors: ../common/errors.yml
types: ../common/types.yml

types:
FieldDetailsType:
properties:
fieldName: string
fieldType: string
fieldDescription: string
FieldDetailsTypeRequest:
extends: FieldDetailsType
properties:
groupName: string
type: string
SetObjectPropertiesRequest: FieldDetailsTypeRequest
GetObjectPropertiesResponse: unknown
SetObjectPropertiesResponse: unknown

service:
base-path: /crm/properties
auth: false
headers:
x-revert-api-token:
type: string
docs: Your official API key for accessing revert apis.
x-revert-t-id:
type: string
docs: The unique customer id used when the customer linked their account.
x-api-version:
type: optional<string>
docs: Optional Revert API version you're using. If missing we default to the latest version of the API.
audiences:
- external
endpoints:
getObjectProperties:
docs: Get object properties for connection
method: GET
path: /{objectName}
path-parameters:
objectName: types.StandardObject
request:
name: GetObjectPropertiesRequest
response: GetObjectPropertiesResponse
errors:
- errors.UnAuthorizedError
- errors.InternalServerError
- errors.NotFoundError
setCustomProperties:
docs: Set custom properties on an object for a given connection
method: POST
path: /{objectName}
path-parameters:
objectName: types.StandardObject
request:
name: SetObjectCustomPropertiesRequest
body: SetObjectPropertiesRequest
response: SetObjectPropertiesResponse
errors:
- errors.UnAuthorizedError
- errors.InternalServerError
- errors.NotFoundError
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"packages/*"
],
"devDependencies": {
"concurrently": "^8.2.1",
"fern-api": "0.12.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
Expand All @@ -17,7 +18,8 @@
"fern-docs": "fern generate --group external",
"build": "yarn workspaces foreach run build",
"prepare": "husky install",
"lint": "lint-staged"
"lint": "lint-staged",
"dev:all": "concurrently --kill-others \"yarn workspace @revertdotdev/js dev\" \"yarn workspace @revertdotdev/backend dev\" \"yarn workspace @revertdotdev/revert-ui start\" "
},
"prisma": {
"schema": "packages/backend/prisma/schema.prisma",
Expand Down
19 changes: 19 additions & 0 deletions packages/backend/constants/associations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Subtype } from "./typeHelpers";

export type AllAssociation = 'contactId' | 'companyId' | 'leadId' | 'dealId' | 'noteId';

export type CompanyAssociation = Subtype<AllAssociation, 'dealId'>;

export type ContactAssociation = Subtype<AllAssociation, 'dealId'>;

export type DealAssociation = Subtype<AllAssociation, 'contactId' | 'companyId'>;

export type EventAssociation = Subtype<AllAssociation, 'dealId' | 'contactId'>;

export type LeadAssociation = Subtype<AllAssociation, 'contactId' | 'companyId' | 'dealId'>;

export type NoteAssociation = Subtype<AllAssociation, 'contactId' | 'companyId' | 'leadId' | 'dealId'>;

export type TaskAssociation = Subtype<AllAssociation, 'dealId'>;

export type UserAssociation = Subtype<AllAssociation, 'dealId'>;
71 changes: 70 additions & 1 deletion packages/backend/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,73 @@ export const DEFAULT_SCOPE = {
[TP_ID.pipedrive]: [],
};

export type AllAssociation = 'contactId' | 'companyId' | 'leadId' | 'dealId' | 'noteId';
export const mapIntegrationIdToIntegrationName = {
[TP_ID.hubspot]: "Hubspot",
[TP_ID.pipedrive]: "Pipedrive",
[TP_ID.sfdc]: "Salesforce",
[TP_ID.zohocrm]: "Zoho",
}

export const rootSchemaMappingId = 'revertRootSchemaMapping';

export enum StandardObjects {
company = 'company',
contact = 'contact',
deal = 'deal',
event = 'event',
lead = 'lead',
note = 'note',
task = 'task',
user = 'user',
}

export const objectNameMapping: Record<string, Record<TP_ID, string | undefined>> = {
[StandardObjects.company]: {
[TP_ID.hubspot]: 'companies',
[TP_ID.pipedrive]: 'organization',
[TP_ID.sfdc]: 'Account',
[TP_ID.zohocrm]: 'Accounts',
},
[StandardObjects.contact]: {
[TP_ID.hubspot]: 'contacts',
[TP_ID.pipedrive]: 'person',
[TP_ID.sfdc]: 'Contact',
[TP_ID.zohocrm]: 'Contacts',
},
[StandardObjects.deal]: {
[TP_ID.hubspot]: 'deals',
[TP_ID.pipedrive]: 'deal',
[TP_ID.sfdc]: 'Opportunity',
[TP_ID.zohocrm]: 'Deals',
},
[StandardObjects.event]: {
[TP_ID.hubspot]: 'meetings',
[TP_ID.pipedrive]: 'activity',
[TP_ID.sfdc]: 'Event',
[TP_ID.zohocrm]: 'Events',
},
[StandardObjects.lead]: {
[TP_ID.hubspot]: 'contacts',
[TP_ID.pipedrive]: 'lead',
[TP_ID.sfdc]: 'Lead',
[TP_ID.zohocrm]: 'Leads',
},
[StandardObjects.note]: {
[TP_ID.hubspot]: 'notes',
[TP_ID.pipedrive]: 'note',
[TP_ID.sfdc]: 'Note',
[TP_ID.zohocrm]: 'Notes',
},
[StandardObjects.task]: {
[TP_ID.hubspot]: 'tasks',
[TP_ID.pipedrive]: 'activity',
[TP_ID.sfdc]: 'Task',
[TP_ID.zohocrm]: 'Tasks',
},
[StandardObjects.user]: {
[TP_ID.hubspot]: 'users',
[TP_ID.pipedrive]: undefined,
[TP_ID.sfdc]: 'User',
[TP_ID.zohocrm]: 'users',
},
};
Loading