Skip to content

Commit 94d20c6

Browse files
feat: field mapping and custom schema (#207)
* prisma migration to add field mapping schemas * seed hs note model (unverified) * seed hs note model (verified) * seed hs note model * transform note acc to schema mapping * (approach 2) transform note acc to schema field mapping * (approach 2) seed all note fields and fix single note structure * minor fix * common func to transform field mapping to model * disunify using field mapping * allow connections to override field mapping * support custom objects in schema; show custom fields as additional * add winston and morgan logger * Field mapping for contact; support custom field mapping to custom crm field * add field mapping config * common unify and disunify methods * seed contact field mapping * use lodash get to transform nested mappings * unify and disunify for contact * disunify based on account config * unify and disunify for company * unify and disunify for deal * unify and disunify for event * unify and disunify for lead * unify and disunify for task * unify and disunify for user * minor refactor * handle 2 level nesting and fix mapping * make target field optional; multi level nesting * fix * fix * fix obj merge * fix pipedrive get format * preprocess * preprocess unify and disunify * disunify postprocess * flatten before disunify * pipedrive fix contact create * minor fixes * fix pipedrive lead disunify * chore: add account id to morgan logs * chore: cleanup * chore: cleanup * chore: cleanup * feat: ui for field mapping (#242) * feat: processing ui * feat: immplememt sse and redis pubsub * feat: read sse data to render failed ui * minor changes * feat: api to fetch mappable details and crm object properties * feat: api to create connection field mapping * feat: add custom field mapped to connection schema * feat: reallly basic ui for std field mapping * feat: reallly basic ui for custom field mapping * feat: add styling * fix: fix add btn order * feat: check for t_id in sse msg; send private token for calling further apis * feat: save mappings on click * feat: fix ui * feat: show done screen * feat: mark form dirty if empty fields * feat: show done stage if config doesnt exist * chore: fix pr comments * chore: use temp tenant token for auth; ui fixes * chore: fix dropdown caret; redis timeout * chore: pubsub fix * chore: cleanup * chore: cleanup * chore: resolve conflicts * feat: add remove mapping btn and divider * fix: fix logger * chore: cleanup * chore: move endpoints to fern * update yarn.lock * fix issues * add hubspot create custom properties api --------- Co-authored-by: jatin <[email protected]>
1 parent ac18977 commit 94d20c6

File tree

71 files changed

+4994
-2059
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4994
-2059
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ npm-debug.log*
8585
!.github/**/*.yml
8686
!fern/**/*.yml
8787
revert-dev.js
88+
.yarn/install-state.gz

.yarn/install-state.gz

37.4 KB
Binary file not shown.

fern/api/definition/common/types.yml

+10
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ types:
4949
- zohocrm
5050
- sfdc
5151
- pipedrive
52+
StandardObject:
53+
enum:
54+
- company
55+
- contact
56+
- deal
57+
- event
58+
- lead
59+
- note
60+
- task
61+
- user
5262
ResponseStatus:
5363
enum:
5464
- ok
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json
2+
3+
imports:
4+
errors: ../../common/errors.yml
5+
types: ../../common/types.yml
6+
7+
types:
8+
MappableFieldType:
9+
properties:
10+
fieldName: string
11+
objectName: types.StandardObject
12+
FieldDetailsType:
13+
properties:
14+
fieldName: string
15+
fieldType: string
16+
fieldDescription: string
17+
FieldMappingType:
18+
properties:
19+
sourceFieldName: string
20+
targetFieldName: string
21+
object: string
22+
GetFieldMappingResponse:
23+
properties:
24+
canAddCustomMapping: boolean
25+
mappableFields: list<MappableFieldType>
26+
fieldList: unknown
27+
CreateFieldMappingRequestBody:
28+
properties:
29+
standardMappings: list<FieldMappingType>
30+
customMappings: list<FieldMappingType>
31+
CreateFieldMappingResponse:
32+
properties:
33+
status: types.ResponseStatus
34+
35+
service:
36+
base-path: /crm/field-mapping
37+
auth: false
38+
headers:
39+
x-revert-api-token:
40+
type: optional<string>
41+
docs: Your official API key for accessing revert apis.
42+
x-revert-t-id:
43+
type: string
44+
docs: The unique customer id used when the customer linked their account.
45+
x-revert-t-token:
46+
type: optional<string>
47+
docs: The temp used to identify tenant.
48+
x-api-version:
49+
type: optional<string>
50+
docs: Optional Revert API version you're using. If missing we default to the latest version of the API.
51+
audiences:
52+
- external
53+
endpoints:
54+
getFieldMapping:
55+
docs: Get field mappings for a connection
56+
method: GET
57+
path: ''
58+
request:
59+
name: GetFieldMappingRequest
60+
response: GetFieldMappingResponse
61+
errors:
62+
- errors.UnAuthorizedError
63+
- errors.InternalServerError
64+
createFieldMapping:
65+
docs: Create field mappings for a connection
66+
method: POST
67+
path: ''
68+
request:
69+
name: CreateFieldMappingRequest
70+
body: CreateFieldMappingRequestBody
71+
response: CreateFieldMappingResponse
72+
errors:
73+
- errors.UnAuthorizedError
74+
- errors.InternalServerError
75+
- errors.NotFoundError
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json
2+
3+
imports:
4+
errors: ../common/errors.yml
5+
types: ../common/types.yml
6+
7+
types:
8+
FieldDetailsType:
9+
properties:
10+
fieldName: string
11+
fieldType: string
12+
fieldDescription: string
13+
FieldDetailsTypeRequest:
14+
extends: FieldDetailsType
15+
properties:
16+
groupName: string
17+
type: string
18+
SetObjectPropertiesRequest: FieldDetailsTypeRequest
19+
GetObjectPropertiesResponse: unknown
20+
SetObjectPropertiesResponse: unknown
21+
22+
service:
23+
base-path: /crm/properties
24+
auth: false
25+
headers:
26+
x-revert-api-token:
27+
type: string
28+
docs: Your official API key for accessing revert apis.
29+
x-revert-t-id:
30+
type: string
31+
docs: The unique customer id used when the customer linked their account.
32+
x-api-version:
33+
type: optional<string>
34+
docs: Optional Revert API version you're using. If missing we default to the latest version of the API.
35+
audiences:
36+
- external
37+
endpoints:
38+
getObjectProperties:
39+
docs: Get object properties for connection
40+
method: GET
41+
path: /{objectName}
42+
path-parameters:
43+
objectName: types.StandardObject
44+
request:
45+
name: GetObjectPropertiesRequest
46+
response: GetObjectPropertiesResponse
47+
errors:
48+
- errors.UnAuthorizedError
49+
- errors.InternalServerError
50+
- errors.NotFoundError
51+
setCustomProperties:
52+
docs: Set custom properties on an object for a given connection
53+
method: POST
54+
path: /{objectName}
55+
path-parameters:
56+
objectName: types.StandardObject
57+
request:
58+
name: SetObjectCustomPropertiesRequest
59+
body: SetObjectPropertiesRequest
60+
response: SetObjectPropertiesResponse
61+
errors:
62+
- errors.UnAuthorizedError
63+
- errors.InternalServerError
64+
- errors.NotFoundError

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"packages/*"
66
],
77
"devDependencies": {
8+
"concurrently": "^8.2.1",
89
"fern-api": "0.12.0",
910
"husky": "^8.0.3",
1011
"lint-staged": "^14.0.1",
@@ -17,7 +18,8 @@
1718
"fern-docs": "fern generate --group external",
1819
"build": "yarn workspaces foreach run build",
1920
"prepare": "husky install",
20-
"lint": "lint-staged"
21+
"lint": "lint-staged",
22+
"dev:all": "concurrently --kill-others \"yarn workspace @revertdotdev/js dev\" \"yarn workspace @revertdotdev/backend dev\" \"yarn workspace @revertdotdev/revert-ui start\" "
2123
},
2224
"prisma": {
2325
"schema": "packages/backend/prisma/schema.prisma",
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Subtype } from "./typeHelpers";
2+
3+
export type AllAssociation = 'contactId' | 'companyId' | 'leadId' | 'dealId' | 'noteId';
4+
5+
export type CompanyAssociation = Subtype<AllAssociation, 'dealId'>;
6+
7+
export type ContactAssociation = Subtype<AllAssociation, 'dealId'>;
8+
9+
export type DealAssociation = Subtype<AllAssociation, 'contactId' | 'companyId'>;
10+
11+
export type EventAssociation = Subtype<AllAssociation, 'dealId' | 'contactId'>;
12+
13+
export type LeadAssociation = Subtype<AllAssociation, 'contactId' | 'companyId' | 'dealId'>;
14+
15+
export type NoteAssociation = Subtype<AllAssociation, 'contactId' | 'companyId' | 'leadId' | 'dealId'>;
16+
17+
export type TaskAssociation = Subtype<AllAssociation, 'dealId'>;
18+
19+
export type UserAssociation = Subtype<AllAssociation, 'dealId'>;

packages/backend/constants/common.ts

+70-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,73 @@ export const DEFAULT_SCOPE = {
3636
[TP_ID.pipedrive]: [],
3737
};
3838

39-
export type AllAssociation = 'contactId' | 'companyId' | 'leadId' | 'dealId' | 'noteId';
39+
export const mapIntegrationIdToIntegrationName = {
40+
[TP_ID.hubspot]: "Hubspot",
41+
[TP_ID.pipedrive]: "Pipedrive",
42+
[TP_ID.sfdc]: "Salesforce",
43+
[TP_ID.zohocrm]: "Zoho",
44+
}
45+
46+
export const rootSchemaMappingId = 'revertRootSchemaMapping';
47+
48+
export enum StandardObjects {
49+
company = 'company',
50+
contact = 'contact',
51+
deal = 'deal',
52+
event = 'event',
53+
lead = 'lead',
54+
note = 'note',
55+
task = 'task',
56+
user = 'user',
57+
}
58+
59+
export const objectNameMapping: Record<string, Record<TP_ID, string | undefined>> = {
60+
[StandardObjects.company]: {
61+
[TP_ID.hubspot]: 'companies',
62+
[TP_ID.pipedrive]: 'organization',
63+
[TP_ID.sfdc]: 'Account',
64+
[TP_ID.zohocrm]: 'Accounts',
65+
},
66+
[StandardObjects.contact]: {
67+
[TP_ID.hubspot]: 'contacts',
68+
[TP_ID.pipedrive]: 'person',
69+
[TP_ID.sfdc]: 'Contact',
70+
[TP_ID.zohocrm]: 'Contacts',
71+
},
72+
[StandardObjects.deal]: {
73+
[TP_ID.hubspot]: 'deals',
74+
[TP_ID.pipedrive]: 'deal',
75+
[TP_ID.sfdc]: 'Opportunity',
76+
[TP_ID.zohocrm]: 'Deals',
77+
},
78+
[StandardObjects.event]: {
79+
[TP_ID.hubspot]: 'meetings',
80+
[TP_ID.pipedrive]: 'activity',
81+
[TP_ID.sfdc]: 'Event',
82+
[TP_ID.zohocrm]: 'Events',
83+
},
84+
[StandardObjects.lead]: {
85+
[TP_ID.hubspot]: 'contacts',
86+
[TP_ID.pipedrive]: 'lead',
87+
[TP_ID.sfdc]: 'Lead',
88+
[TP_ID.zohocrm]: 'Leads',
89+
},
90+
[StandardObjects.note]: {
91+
[TP_ID.hubspot]: 'notes',
92+
[TP_ID.pipedrive]: 'note',
93+
[TP_ID.sfdc]: 'Note',
94+
[TP_ID.zohocrm]: 'Notes',
95+
},
96+
[StandardObjects.task]: {
97+
[TP_ID.hubspot]: 'tasks',
98+
[TP_ID.pipedrive]: 'activity',
99+
[TP_ID.sfdc]: 'Task',
100+
[TP_ID.zohocrm]: 'Tasks',
101+
},
102+
[StandardObjects.user]: {
103+
[TP_ID.hubspot]: 'users',
104+
[TP_ID.pipedrive]: undefined,
105+
[TP_ID.sfdc]: 'User',
106+
[TP_ID.zohocrm]: 'users',
107+
},
108+
};

0 commit comments

Comments
 (0)