Skip to content

Commit

Permalink
feat: field mapping and custom schema (revertinc#207)
Browse files Browse the repository at this point in the history
* 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 (revertinc#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 <sandilya.jatin@gmail.com>
  • Loading branch information
2 people authored and hrutik7 committed Nov 15, 2023
1 parent c765ebd commit 045778b
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 11 deletions.
9 changes: 2 additions & 7 deletions packages/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import indexRouter from './routes/index';
import cors from 'cors';
import cron from 'node-cron';
import morgan from 'morgan';
import morgan from 'morgan';
import AuthService from './services/auth';
import versionMiddleware, { manageRouterVersioning } from './helpers/versionMiddleware';
import { ShortloopSDK } from '@shortloop/node';
Expand Down Expand Up @@ -75,13 +76,7 @@ morgan.token('tenant-id', (req: any) => {
morgan.token('account-id', (_req, res: any) => {
return res.locals?.account?.id;
});
app.use(
morgan('[:date[iso]] :method :url :status :response-time ms tenant - :tenant-id | account - :account-id', {
skip: (req, _) => {
return req.originalUrl.startsWith('/health-check');
},
})
);
app.use(morgan('[:date[iso]] :method :url :status :response-time ms tenant - :tenant-id | account - :account-id'));

app.use(limiter);
app.use(versionMiddleware());
Expand Down
5 changes: 3 additions & 2 deletions packages/backend/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import { fieldMappingService } from './v1/crm/fieldMapping';
import { propertiesService } from './properties';
import chatRouter from './v1/chat';
import { usersService } from '../services/chat/users';
import { channelsService } from '../services/chat/channels';
import { messageService } from '../services/chat/message';
import { channelService} from '../services/chat/channel';
import { messageService } from '../services/chat/messages';


const router = express.Router();

Expand Down
5 changes: 3 additions & 2 deletions packages/backend/routes/v1/crm/auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios';
import express from 'express';
import { randomUUID } from 'crypto';
import { randomUUID } from 'crypto';
import config from '../../../config';
import qs from 'qs';
import { TP_ID } from '@prisma/client';
Expand All @@ -9,7 +10,7 @@ import prisma, { Prisma, xprisma } from '../../../prisma/client';
import { logInfo, logError, logDebug } from '../../../helpers/logger';
import pubsub, { IntegrationStatusSseMessage, PUBSUB_CHANNELS } from '../../../redis/client/pubsub';
import redis from '../../../redis/client';
import { CRM_TP_ID, mapIntegrationIdToIntegrationName } from '../../../constants/common';
import { mapIntegrationIdToIntegrationName } from '../../../constants/common';

const authRouter = express.Router({ mergeParams: true });

Expand Down Expand Up @@ -310,7 +311,7 @@ authRouter.get('/oauth-callback', async (req, res) => {
tenantId: req.query.t_id,
tenantSecretToken,
} as IntegrationStatusSseMessage);
res.send({ status: 'ok', tp_customer_id: info.data.email });
res.send({ status: 'ok', tp_customer_id: 'testSfdcUser' });
} catch (error: any) {
logError(error);
if (error instanceof Prisma.PrismaClientKnownRequestError) {
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/common/oauth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const OAuthCallback = (props) => {
? ': Already connected another CRM. Please disconnect first.'
: '';
setStatus('Errored out' + errorMessage);
window.close();
} else {
setStatus('Succeeded. Please feel free to close this window.');
window.close();
Expand All @@ -116,6 +117,7 @@ export const OAuthCallback = (props) => {
setIsLoading(false);
console.error(err);
setStatus('Errored out');
window.close();
});
}else if (integrationId === 'discord') {
console.log('Post communication app installation', integrationId, params);
Expand Down
124 changes: 124 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3653,6 +3653,34 @@ __metadata:
languageName: node
linkType: hard

<<<<<<< HEAD
=======
"@discordjs/collection@npm:^0.7.0":
version: 0.7.0
resolution: "@discordjs/collection@npm:0.7.0"
checksum: 141aa35a5433bacba3617b533557b4948388c7b59cdaecee51ccd721c1b9242e50d95bdef53ee2491535a017095f5072ace3c3e9e594193f67a1c5a8a4b7db93
languageName: node
linkType: hard

"@dabh/diagnostics@npm:^2.0.2":
version: 2.0.3
resolution: "@dabh/diagnostics@npm:2.0.3"
dependencies:
colorspace: 1.1.x
enabled: 2.0.x
kuler: ^2.0.0
checksum: 4879600c55c8315a0fb85fbb19057bad1adc08f0a080a8cb4e2b63f723c379bfc4283b68123a2b078d367b327dd8df12fcb27464efe791addc0a48b9df6d79a1
languageName: node
linkType: hard

"@discoveryjs/json-ext@npm:0.5.7, @discoveryjs/json-ext@npm:^0.5.3":
version: 0.5.7
resolution: "@discoveryjs/json-ext@npm:0.5.7"
checksum: 2176d301cc258ea5c2324402997cf8134ebb212469c0d397591636cea8d3c02f2b3cf9fd58dcb748c7a0dade77ebdc1b10284fa63e608c033a1db52fddc69918
languageName: node
linkType: hard

>>>>>>> 26ec7ca (feat: field mapping and custom schema (#207))
"@electron/get@npm:^2.0.0":
version: 2.0.2
resolution: "@electron/get@npm:2.0.2"
Expand Down Expand Up @@ -5645,14 +5673,21 @@ __metadata:
"@types/cors": ^2.8.14
"@types/express": ^4.17.13
"@types/jest": ^29.5.4
<<<<<<< HEAD
"@types/lodash": ^4.14.199
=======
>>>>>>> 26ec7ca (feat: field mapping and custom schema (#207))
"@types/morgan": ^1.9.5
"@types/node": "*"
"@types/node-cron": ^3.0.8
"@types/uuid": ^9.0.2
axios: ^0.27.2
babel-jest: ^29.2.2
better-sse: ^0.9.0
<<<<<<< HEAD
=======
bull: ^4.8.5
>>>>>>> 26ec7ca (feat: field mapping and custom schema (#207))
concurrently: ^8.2.1
cors: ^2.8.5
dotenv: ^16.3.1
Expand All @@ -5662,8 +5697,14 @@ __metadata:
fern-api: ^0.0.184
jest: ^29.6.4
lodash: ^4.17.21
<<<<<<< HEAD
moesif-nodejs: ^3.5.3
morgan: ^1.10.0
=======
mongoose: ^6.6.5
morgan: ^1.10.0
nanoid: ^3.0.0
>>>>>>> 26ec7ca (feat: field mapping and custom schema (#207))
node-cron: ^3.0.2
prisma: ^4.16.0
redis: ^4.6.8
Expand Down Expand Up @@ -8875,6 +8916,27 @@ __metadata:
languageName: node
linkType: hard

<<<<<<< HEAD
=======
"@types/mkdirp@npm:^0.5.2":
version: 0.5.2
resolution: "@types/mkdirp@npm:0.5.2"
dependencies:
"@types/node": "*"
checksum: 21e6681ee18cee6314dbe0f57ada48981912b76de8266f438ba2573770d60aaa8dd376baad3f20e2346696a7cca84b0aadd1737222341553a0091831a46e6ad1
languageName: node
linkType: hard

"@types/morgan@npm:^1.9.5":
version: 1.9.6
resolution: "@types/morgan@npm:1.9.6"
dependencies:
"@types/node": "*"
checksum: 6525248325a74342f929c958be69c0840c8f3a288e003a8904319cae92e531f17a8aa2700701e66775adcca7f9506dd630fec2f95dc04a3e73add04fde42aab8
languageName: node
linkType: hard

>>>>>>> 26ec7ca (feat: field mapping and custom schema (#207))
"@types/node-cron@npm:^3.0.8":
version: 3.0.8
resolution: "@types/node-cron@npm:3.0.8"
Expand Down Expand Up @@ -9201,6 +9263,13 @@ __metadata:
languageName: node
linkType: hard

"@types/triple-beam@npm:^1.3.2":
version: 1.3.3
resolution: "@types/triple-beam@npm:1.3.3"
checksum: e2d54d27536a7a7cd1e4c6e9f3799a894aa5b2dc00b8dba656be7c038c3c1dedd6236551afa9c9c6ce32b0d691e1468bc124f899be0d832bc6ddea4e830107d6
languageName: node
linkType: hard

"@types/trusted-types@npm:^2.0.2":
version: 2.0.3
resolution: "@types/trusted-types@npm:2.0.3"
Expand Down Expand Up @@ -13275,7 +13344,11 @@ __metadata:
languageName: node
linkType: hard

<<<<<<< HEAD
"cluster-key-slot@npm:1.1.2":
=======
"cluster-key-slot@npm:1.1.2, cluster-key-slot@npm:^1.1.0":
>>>>>>> 26ec7ca (feat: field mapping and custom schema (#207))
version: 1.1.2
resolution: "cluster-key-slot@npm:1.1.2"
checksum: be0ad2d262502adc998597e83f9ded1b80f827f0452127c5a37b22dfca36bab8edf393f7b25bb626006fb9fb2436106939ede6d2d6ecf4229b96a47f27edd681
Expand Down Expand Up @@ -14708,6 +14781,16 @@ __metadata:
languageName: node
linkType: hard

<<<<<<< HEAD
=======
"denque@npm:^2.1.0":
version: 2.1.0
resolution: "denque@npm:2.1.0"
checksum: 1d4ae1d05e59ac3a3481e7b478293f4b4c813819342273f3d5b826c7ffa9753c520919ba264f377e09108d24ec6cf0ec0ac729a5686cbb8f32d797126c5dae74
languageName: node
linkType: hard

>>>>>>> 26ec7ca (feat: field mapping and custom schema (#207))
"depd@npm:2.0.0, depd@npm:~2.0.0":
version: 2.0.0
resolution: "depd@npm:2.0.0"
Expand Down Expand Up @@ -16773,6 +16856,13 @@ __metadata:
languageName: node
linkType: hard

"fecha@npm:^4.2.0":
version: 4.2.3
resolution: "fecha@npm:4.2.3"
checksum: f94e2fb3acf5a7754165d04549460d3ae6c34830394d20c552197e3e000035d69732d74af04b9bed3283bf29fe2a9ebdcc0085e640b0be3cc3658b9726265e31
languageName: node
linkType: hard

"fern-api@npm:0.12.0":
version: 0.12.0
resolution: "fern-api@npm:0.12.0"
Expand Down Expand Up @@ -17391,6 +17481,13 @@ __metadata:
languageName: node
linkType: hard

"generic-pool@npm:3.9.0":
version: 3.9.0
resolution: "generic-pool@npm:3.9.0"
checksum: 3d89e9b2018d2e3bbf44fec78c76b2b7d56d6a484237aa9daf6ff6eedb14b0899dadd703b5d810219baab2eb28e5128fb18b29e91e602deb2eccac14492d8ca8
languageName: node
linkType: hard

"gensync@npm:^1.0.0-beta.1, gensync@npm:^1.0.0-beta.2":
version: 1.0.0-beta.2
resolution: "gensync@npm:1.0.0-beta.2"
Expand Down Expand Up @@ -22217,6 +22314,19 @@ __metadata:
languageName: node
linkType: hard

"morgan@npm:^1.10.0":
version: 1.10.0
resolution: "morgan@npm:1.10.0"
dependencies:
basic-auth: ~2.0.1
debug: 2.6.9
depd: ~2.0.0
on-finished: ~2.3.0
on-headers: ~1.0.2
checksum: fb41e226ab5a1abf7e8909e486b387076534716d60207e361acfb5df78b84d703a7b7ea58f3046a9fd0b83d3c94bfabde32323341a1f1b26ce50680abd2ea5dd
languageName: node
linkType: hard

"move-concurrently@npm:^1.0.1":
version: 1.0.1
resolution: "move-concurrently@npm:1.0.1"
Expand Down Expand Up @@ -25641,6 +25751,20 @@ __metadata:
languageName: node
linkType: hard

"redis@npm:^4.6.8":
version: 4.6.8
resolution: "redis@npm:4.6.8"
dependencies:
"@redis/bloom": 1.2.0
"@redis/client": 1.5.9
"@redis/graph": 1.1.0
"@redis/json": 1.0.4
"@redis/search": 1.1.3
"@redis/time-series": 1.0.5
checksum: 1626d0d739e5f2047824b77b472967af5938fba488a039bd0a5ad90814eb81cb29b7939e16adf0bc39b133165ec1bf147e4f944d0c54a2f9c32c8f004b015940
languageName: node
linkType: hard

"reflect-metadata@npm:0.1.13":
version: 0.1.13
resolution: "reflect-metadata@npm:0.1.13"
Expand Down

0 comments on commit 045778b

Please sign in to comment.