From e503c935291ab5f9f7d15c940eccec23d6ba6ff2 Mon Sep 17 00:00:00 2001 From: nael Date: Sat, 25 Nov 2023 23:54:43 +0100 Subject: [PATCH 1/3] feat add --- packages/api/prisma/schema.prisma | 271 ++++++++++++++++-- packages/api/src/@core/auth/auth.service.ts | 16 +- .../crm/services/crm-connection.service.ts | 2 +- .../crm/services/hubspot/hubspot.service.ts | 8 +- .../services/pipedrive/pipedrive.service.ts | 8 +- .../crm/services/zendesk/zendesk.service.ts | 8 +- .../crm/services/zoho/zoho.service.ts | 8 +- .../field-mapping.controller.spec.ts | 18 ++ .../field-mapping/field-mapping.controller.ts | 4 + .../field-mapping/field-mapping.module.ts | 9 + .../field-mapping.service.spec.ts | 18 ++ .../field-mapping/field-mapping.service.ts | 4 + .../dto/create-linked-user.dto.ts | 2 +- .../linked-users/linked-users.service.ts | 2 +- .../src/@core/projects/projects.service.ts | 2 +- packages/api/src/app.module.ts | 2 + packages/api/src/app.service.ts | 1 - packages/api/src/crm/@types/index.ts | 6 + .../api/src/crm/contact/contact.controller.ts | 7 +- .../src/crm/contact/dto/create-contact.dto.ts | 5 + .../crm/contact/services/contact.service.ts | 29 +- .../crm/contact/services/freshsales/index.ts | 4 +- .../src/crm/contact/services/hubspot/index.ts | 4 +- .../crm/contact/services/pipedrive/index.ts | 4 +- .../src/crm/contact/services/zendesk/index.ts | 4 +- .../src/crm/contact/services/zoho/index.ts | 4 +- packages/api/src/crm/crm.controller.ts | 14 + packages/api/src/crm/crm.module.ts | 4 + packages/api/src/crm/crm.service.ts | 10 + 29 files changed, 403 insertions(+), 75 deletions(-) create mode 100644 packages/api/src/@core/field-mapping/field-mapping.controller.spec.ts create mode 100644 packages/api/src/@core/field-mapping/field-mapping.controller.ts create mode 100644 packages/api/src/@core/field-mapping/field-mapping.module.ts create mode 100644 packages/api/src/@core/field-mapping/field-mapping.service.spec.ts create mode 100644 packages/api/src/@core/field-mapping/field-mapping.service.ts create mode 100644 packages/api/src/crm/crm.controller.ts create mode 100644 packages/api/src/crm/crm.service.ts diff --git a/packages/api/prisma/schema.prisma b/packages/api/prisma/schema.prisma index 38fcf38d0..a2933fdbe 100644 --- a/packages/api/prisma/schema.prisma +++ b/packages/api/prisma/schema.prisma @@ -8,10 +8,10 @@ datasource db { } model api_keys { - id_api_key BigInt @id(map: "id_") @default(autoincrement()) + id_api_key String @id(map: "id_") @db.Uuid api_key_hash String @unique(map: "unique_api_keys") - id_user Int - id_project BigInt + id_project String @db.Uuid + id_user String @db.Uuid projects projects @relation(fields: [id_project], references: [id_project], onDelete: NoAction, onUpdate: NoAction, map: "fk_7") users users @relation(fields: [id_user], references: [id_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_8") @@ -20,43 +20,63 @@ model api_keys { } model crm_contact_email_addresses { - id_crm_contact_email Int @id(map: "pk_crm_contact_email_addresses") @default(autoincrement()) + id_crm_contact_email String @id(map: "pk_crm_contact_email_addresses") @db.Uuid email_address String email_address_type String - id_crm_contact Int @default(autoincrement()) - crm_contacts crm_contacts @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_3") + owner_type String + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_crm_company String? @db.Uuid + id_crm_contact String? @db.Uuid + crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_16") + crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_3") @@index([id_crm_contact], map: "crm_contactid_crm_contact_email_address") + @@index([id_crm_company], map: "fk_contact_email_adress_companyid") } model crm_contacts { - id_crm_contact Int @id(map: "pk_crm_contacts") @default(autoincrement()) + id_crm_contact String @id(map: "pk_crm_contacts") @db.Uuid first_name String last_name String - id_job Int @default(autoincrement()) + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_job String @db.Uuid + id_crm_user String? @db.Uuid + crm_addresses crm_addresses[] crm_contact_email_addresses crm_contact_email_addresses[] + crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_23") jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "job_id_crm_contact") crm_contacts_phone_numbers crm_contacts_phone_numbers[] + crm_notes crm_notes[] @@index([id_job], map: "crm_contact_id_job") + @@index([id_crm_user], map: "fk_crm_contact_userid") } model crm_contacts_phone_numbers { - id_crm_contacts_phone_number Int @id(map: "pk_crm_contacts_phone_numbers") @default(autoincrement()) + id_crm_contacts_phone_number String @id(map: "pk_crm_contacts_phone_numbers") @db.Uuid phone_number String phone_type String - id_crm_contact Int @default(autoincrement()) - crm_contacts crm_contacts @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_2") + owner_type String + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_crm_company String @db.Uuid + id_crm_contact String @db.Uuid + crm_companies crm_companies @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_17") + crm_contacts crm_contacts @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_2") @@index([id_crm_contact], map: "crm_contactid_crm_contact_phone_number") + @@index([id_crm_company], map: "fk_phone_number_companyid") } /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model jobs { - id_job Int @id(map: "pk_jobs") @default(autoincrement()) + id_job String @id(map: "pk_jobs") @db.Uuid status String timestamp DateTime @default(now()) @db.Timestamp(6) - id_linked_user BigInt + id_linked_user String @db.Uuid + crm_companies crm_companies[] crm_contacts crm_contacts[] linked_users linked_users @relation(fields: [id_linked_user], references: [id_linked_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_12") jobs_status_history jobs_status_history[] @@ -66,18 +86,18 @@ model jobs { /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model jobs_status_history { - id_jobs_status_history Int @id(map: "pk_1") @default(autoincrement()) + id_jobs_status_history String @id(map: "pk_jobs_status_history") @db.Uuid timestamp DateTime @default(now()) @db.Timestamp(6) previous_status String new_status String - id_job Int @default(autoincrement()) + id_job String @db.Uuid jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "fk_4") @@index([id_job], map: "id_job_jobs_status_history") } model organizations { - id_organization BigInt @id(map: "pk_organizations") @default(autoincrement()) + id_organization String @id(map: "pk_organizations") @db.Uuid name String stripe_customer_id String projects projects[] @@ -85,9 +105,9 @@ model organizations { } model projects { - id_project BigInt @id(map: "pk_projects") @default(autoincrement()) + id_project String @id(map: "pk_projects") @db.Uuid name String - id_organization BigInt + id_organization String @db.Uuid api_keys api_keys[] connections connections[] linked_users linked_users[] @@ -98,14 +118,14 @@ model projects { /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model users { - id_user Int @id(map: "pk_users") @default(autoincrement()) + id_user String @id(map: "pk_users") @db.Uuid email String password_hash String first_name String last_name String created_at DateTime @default(now()) @db.Timestamp(6) modified_at DateTime @default(now()) @db.Timestamp(6) - id_organization BigInt? + id_organization String? @db.Uuid api_keys api_keys[] organizations organizations? @relation(fields: [id_organization], references: [id_organization], onDelete: NoAction, onUpdate: NoAction, map: "fk_5") @@ -114,7 +134,7 @@ model users { /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model connections { - id_connection BigInt @id(map: "pk_connections") @default(autoincrement()) + id_connection String @id(map: "pk_connections") @db.Uuid provider_slug String account_url String? token_type String @@ -122,8 +142,8 @@ model connections { refresh_token String? expiration_timestamp DateTime? @db.Timestamp(6) created_at DateTime @db.Timestamp(6) - id_project BigInt - id_linked_user BigInt + id_project String @db.Uuid + id_linked_user String @db.Uuid linked_users linked_users @relation(fields: [id_linked_user], references: [id_linked_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_11") projects projects @relation(fields: [id_project], references: [id_project], onDelete: NoAction, onUpdate: NoAction, map: "fk_9") @@ -134,11 +154,11 @@ model connections { /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments model linked_users { - id_linked_user BigInt @id(map: "key_id_linked_users") @default(autoincrement()) + id_linked_user String @id(map: "key_id_linked_users") @db.Uuid linked_user_origin_id String alias String status String - id_project BigInt + id_project String @db.Uuid connections connections[] jobs jobs[] projects projects @relation(fields: [id_project], references: [id_project], onDelete: NoAction, onUpdate: NoAction, map: "fk_10") @@ -147,6 +167,203 @@ model linked_users { } model crm_users { - id_crm_user String @id(map: "pk_test") @db.Uuid - test String + id_crm_user String @id(map: "pk_crm_users") @db.Uuid + name String? + email String? + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + crm_companies crm_companies[] + crm_contacts crm_contacts[] + crm_deals crm_deals[] + crm_tasks crm_tasks[] +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model crm_addresses { + id_crm_address String @id(map: "pk_crm_addresses") @db.Uuid + street_1 String? + street_2 String? + city String? + state String? + postal_code String? + country String? + address_type String? + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + owner_type String + id_crm_company String? @db.Uuid + id_crm_contact String? @db.Uuid + crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_14") + crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_15") + + @@index([id_crm_contact], map: "fk_crm_addresses_to_crm_contacts") + @@index([id_crm_company], map: "fk_crm_adresses_to_crm_companies") +} + +model crm_companies { + id_crm_company String @id(map: "pk_crm_companies") @db.Uuid + name String? + industry String? + number_of_employees BigInt? + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_job String @db.Uuid + id_crm_user String? @db.Uuid + crm_addresses crm_addresses[] + jobs jobs @relation(fields: [id_job], references: [id_job], onDelete: NoAction, onUpdate: NoAction, map: "fk_13") + crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_24") + crm_contact_email_addresses crm_contact_email_addresses[] + crm_contacts_phone_numbers crm_contacts_phone_numbers[] + crm_engagements crm_engagements[] + crm_notes crm_notes[] + crm_tasks crm_tasks[] + + @@index([id_crm_user], map: "fk_crm_company_crm_userid") + @@index([id_job], map: "fk_crm_company_jobid") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model crm_deals { + id_crm_deal String @id(map: "pk_crm_deal") @db.Uuid + name String + description String + amount BigInt + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_crm_user String? @db.Uuid + id_crm_deals_stage String? @db.Uuid + crm_deals_stages crm_deals_stages? @relation(fields: [id_crm_deals_stage], references: [id_crm_deals_stage], onDelete: NoAction, onUpdate: NoAction, map: "fk_21") + crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_22") + crm_notes crm_notes[] + crm_tasks crm_tasks[] + + @@index([id_crm_user], map: "crm_deal_crm_userid") + @@index([id_crm_deals_stage], map: "crm_deal_deal_stageid") +} + +model crm_deals_stages { + id_crm_deals_stage String @id(map: "pk_crm_deal_stages") @db.Uuid + stage_name String? + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + crm_deals crm_deals[] +} + +model crm_engagement_contacts { + id_crm_engagement_contact String @id(map: "pk_crm_engagement_contact") @db.Uuid + uuid_crm_engagement String @db.Uuid + id_crm_contact String? @db.Uuid + crm_engagements crm_engagements @relation(fields: [uuid_crm_engagement], references: [uuid_crm_engagement], onDelete: NoAction, onUpdate: NoAction, map: "fk_30") + + @@index([uuid_crm_engagement], map: "fk_crm_engagement_contacts_crmengagementid") + @@index([id_crm_contact], map: "fk_engagement_contact_crmcontactid") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model crm_engagement_types { + id_crm_engagement_type String @id(map: "pk_crm_engagement_type") @db.Uuid + name String? + engagement_type String? + remote_id String? + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + crm_engagements crm_engagements[] +} + +model crm_engagements { + uuid_crm_engagement String @id(map: "pk_crm_engagement") @db.Uuid + content String? + direction String? + subject String? + start_at DateTime? @db.Timestamp(6) + end_time DateTime? @db.Timestamp(6) + created_at DateTime? @db.Timestamp(6) + modified_at DateTime? @db.Timestamp(6) + remote_id String? + id_crm_engagement_type String @db.Uuid + id_crm_company String? @db.Uuid + crm_engagement_contacts crm_engagement_contacts[] + crm_engagement_types crm_engagement_types @relation(fields: [id_crm_engagement_type], references: [id_crm_engagement_type], onDelete: NoAction, onUpdate: NoAction, map: "fk_28") + crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_29") + + @@index([id_crm_company], map: "fk_crm_engagement_crmcompanyid") + @@index([id_crm_engagement_type], map: "fk_crm_engagement_crmengagementtypeid") +} + +model crm_notes { + id_crm_note String @id(map: "pk_crm_notes") @db.Uuid + content String + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_crm_company String? @db.Uuid + id_crm_contact String? @db.Uuid + id_crm_deal String? @db.Uuid + crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_18") + crm_contacts crm_contacts? @relation(fields: [id_crm_contact], references: [id_crm_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_19") + crm_deals crm_deals? @relation(fields: [id_crm_deal], references: [id_crm_deal], onDelete: NoAction, onUpdate: NoAction, map: "fk_20") + + @@index([id_crm_contact], map: "fk_crm_note_crm_companyid") + @@index([id_crm_company], map: "fk_crm_note_crm_contactid") + @@index([id_crm_deal], map: "fk_crm_notes_crm_dealid") +} + +model crm_tasks { + id_crm_task String @id(map: "pk_crm_task") @db.Uuid + subject String? + content String? + status String? + due_date DateTime? @db.Timestamp(6) + finished_date DateTime? @db.Timestamp(6) + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) + id_crm_user String? @db.Uuid + id_crm_company String? @db.Uuid + id_crm_deal String? @db.Uuid + crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_25") + crm_companies crm_companies? @relation(fields: [id_crm_company], references: [id_crm_company], onDelete: NoAction, onUpdate: NoAction, map: "fk_26") + crm_deals crm_deals? @relation(fields: [id_crm_deal], references: [id_crm_deal], onDelete: NoAction, onUpdate: NoAction, map: "fk_27") + + @@index([id_crm_company], map: "fk_crm_task_companyid") + @@index([id_crm_user], map: "fk_crm_task_userid") + @@index([id_crm_deal], map: "fk_crmtask_dealid") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model attribute { + id_attribute String @id(map: "pk_attribute") @db.Uuid + status String + ressource_owner_type String + slug String + description String + data_type String + remote_id String + source String + id_entity String @db.Uuid + scope String + id_consumer String @db.Uuid + entity entity @relation(fields: [id_entity], references: [id_entity], onDelete: NoAction, onUpdate: NoAction, map: "fk_32") + value value[] + + @@index([id_entity], map: "fk_attribute_entityid") +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model entity { + id_entity String @id(map: "pk_entity") @db.Uuid + ressource_owner_id String + attribute attribute[] + value value[] +} + +/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments +model value { + id_value String @id(map: "pk_value") @db.Uuid + data String + id_entity String @db.Uuid + id_attribute String @db.Uuid + attribute attribute @relation(fields: [id_attribute], references: [id_attribute], onDelete: NoAction, onUpdate: NoAction, map: "fk_33") + entity entity @relation(fields: [id_entity], references: [id_entity], onDelete: NoAction, onUpdate: NoAction, map: "fk_34") + + @@index([id_attribute], map: "fk_value_attributeid") + @@index([id_entity], map: "fk_value_entityid") } diff --git a/packages/api/src/@core/auth/auth.service.ts b/packages/api/src/@core/auth/auth.service.ts index ed3d63f96..2d57e021f 100644 --- a/packages/api/src/@core/auth/auth.service.ts +++ b/packages/api/src/@core/auth/auth.service.ts @@ -42,7 +42,7 @@ export class AuthService { async login(user: LoginCredentials): Promise<{ access_token: string }> { try { const foundUser = await this.prisma.users.findUnique({ - where: { id_user: user.id_user }, + where: { id_user: String(user.id_user) }, }); //TODO: if not founder if ( @@ -104,8 +104,8 @@ export class AuthService { //must be called only if user is logged in async generateApiKey( - projectId: number, - userId: number, + projectId: number | string, + userId: number | string, ): Promise<{ access_token: string }> { console.log("'ddddd"); const jwtPayload = { @@ -121,8 +121,8 @@ export class AuthService { } async generateApiKeyForUser( - userId: number, - projectId: number, + userId: number | string, + projectId: number | string, ): Promise<{ api_key: string }> { try { //tmp create first these 2 : @@ -141,7 +141,7 @@ export class AuthService { //TODO: CHECK IF PROJECT_ID IS EXISTENT //fetch user_id const foundUser = await this.prisma.users.findUnique({ - where: { id_user: userId }, + where: { id_user: userId as string }, }); if (!foundUser) { throw new UnauthorizedException( @@ -159,8 +159,8 @@ export class AuthService { const new_api_key = await this.prisma.api_keys.create({ data: { api_key_hash: hashed_token, - id_project: projectId, - id_user: userId, + id_project: projectId as string, + id_user: userId as string, }, }); if (!new_api_key) { diff --git a/packages/api/src/@core/connections/crm/services/crm-connection.service.ts b/packages/api/src/@core/connections/crm/services/crm-connection.service.ts index 41d4dabd8..9d74d0645 100644 --- a/packages/api/src/@core/connections/crm/services/crm-connection.service.ts +++ b/packages/api/src/@core/connections/crm/services/crm-connection.service.ts @@ -91,7 +91,7 @@ export class CrmConnectionsService { } async handleCRMTokensRefresh( - connectionId: bigint, + connectionId: string, providerId: string, refresh_token: string, account_url?: string, diff --git a/packages/api/src/@core/connections/crm/services/hubspot/hubspot.service.ts b/packages/api/src/@core/connections/crm/services/hubspot/hubspot.service.ts index 69d0108e9..b8547ff6e 100644 --- a/packages/api/src/@core/connections/crm/services/hubspot/hubspot.service.ts +++ b/packages/api/src/@core/connections/crm/services/hubspot/hubspot.service.ts @@ -58,7 +58,7 @@ export class HubspotConnectionService { try { const isNotUnique = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); if (isNotUnique) @@ -101,10 +101,10 @@ export class HubspotConnectionService { ), created_at: new Date(), projects: { - connect: { id_project: BigInt(projectId) }, + connect: { id_project: projectId }, }, linked_users: { - connect: { id_linked_user: BigInt(linkedUserId) }, + connect: { id_linked_user: linkedUserId }, }, //id of the end-customer defined in the company application, this is how requests could be made on behlaf of the user // without it, we cant retrieve the right row in our db @@ -116,7 +116,7 @@ export class HubspotConnectionService { } } - async handleHubspotTokenRefresh(connectionId: bigint, refresh_token: string) { + async handleHubspotTokenRefresh(connectionId: string, refresh_token: string) { try { const REDIRECT_URI = `${config.OAUTH_REDIRECT_BASE}/connections/oauth/callback`; //tocheck diff --git a/packages/api/src/@core/connections/crm/services/pipedrive/pipedrive.service.ts b/packages/api/src/@core/connections/crm/services/pipedrive/pipedrive.service.ts index 559d9605c..e1eca200b 100644 --- a/packages/api/src/@core/connections/crm/services/pipedrive/pipedrive.service.ts +++ b/packages/api/src/@core/connections/crm/services/pipedrive/pipedrive.service.ts @@ -25,7 +25,7 @@ export class PipedriveConnectionService { try { const isNotUnique = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); if (isNotUnique) @@ -68,10 +68,10 @@ export class PipedriveConnectionService { ), created_at: new Date(), projects: { - connect: { id_project: BigInt(projectId) }, + connect: { id_project: projectId }, }, linked_users: { - connect: { id_linked_user: BigInt(linkedUserId) }, + connect: { id_linked_user: linkedUserId }, }, }, }); @@ -81,7 +81,7 @@ export class PipedriveConnectionService { } async handlePipedriveTokenRefresh( - connectionId: bigint, + connectionId: string, refresh_token: string, ) { try { diff --git a/packages/api/src/@core/connections/crm/services/zendesk/zendesk.service.ts b/packages/api/src/@core/connections/crm/services/zendesk/zendesk.service.ts index 785ed77ff..9594fabc6 100644 --- a/packages/api/src/@core/connections/crm/services/zendesk/zendesk.service.ts +++ b/packages/api/src/@core/connections/crm/services/zendesk/zendesk.service.ts @@ -23,7 +23,7 @@ export class ZendeskConnectionService { try { const isNotUnique = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); if (isNotUnique) @@ -66,10 +66,10 @@ export class ZendeskConnectionService { ), created_at: new Date(), projects: { - connect: { id_project: BigInt(projectId) }, + connect: { id_project: projectId }, }, linked_users: { - connect: { id_linked_user: BigInt(linkedUserId) }, + connect: { id_linked_user: linkedUserId }, }, }, }); @@ -77,7 +77,7 @@ export class ZendeskConnectionService { handleServiceError(error, this.logger, 'zendesk', Action.oauthCallback); } } - async handleZendeskTokenRefresh(connectionId: bigint, refresh_token: string) { + async handleZendeskTokenRefresh(connectionId: string, refresh_token: string) { try { const formData = new URLSearchParams({ grant_type: 'refresh_token', diff --git a/packages/api/src/@core/connections/crm/services/zoho/zoho.service.ts b/packages/api/src/@core/connections/crm/services/zoho/zoho.service.ts index e0db638f7..366c4968e 100644 --- a/packages/api/src/@core/connections/crm/services/zoho/zoho.service.ts +++ b/packages/api/src/@core/connections/crm/services/zoho/zoho.service.ts @@ -32,7 +32,7 @@ export class ZohoConnectionService { try { const isNotUnique = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); if (isNotUnique) @@ -73,10 +73,10 @@ export class ZohoConnectionService { ), created_at: new Date(), projects: { - connect: { id_project: BigInt(projectId) }, + connect: { id_project: projectId }, }, linked_users: { - connect: { id_linked_user: BigInt(linkedUserId) }, + connect: { id_linked_user: linkedUserId }, }, account_url: domain, }, @@ -86,7 +86,7 @@ export class ZohoConnectionService { } } async handleZohoTokenRefresh( - connectionId: bigint, + connectionId: string, refresh_token: string, domain: string, ) { diff --git a/packages/api/src/@core/field-mapping/field-mapping.controller.spec.ts b/packages/api/src/@core/field-mapping/field-mapping.controller.spec.ts new file mode 100644 index 000000000..99652ed0c --- /dev/null +++ b/packages/api/src/@core/field-mapping/field-mapping.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { FieldMappingController } from './field-mapping.controller'; + +describe('FieldMappingController', () => { + let controller: FieldMappingController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [FieldMappingController], + }).compile(); + + controller = module.get(FieldMappingController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/packages/api/src/@core/field-mapping/field-mapping.controller.ts b/packages/api/src/@core/field-mapping/field-mapping.controller.ts new file mode 100644 index 000000000..f1ddab3f7 --- /dev/null +++ b/packages/api/src/@core/field-mapping/field-mapping.controller.ts @@ -0,0 +1,4 @@ +import { Controller } from '@nestjs/common'; + +@Controller('field-mapping') +export class FieldMappingController {} diff --git a/packages/api/src/@core/field-mapping/field-mapping.module.ts b/packages/api/src/@core/field-mapping/field-mapping.module.ts new file mode 100644 index 000000000..9d4a42192 --- /dev/null +++ b/packages/api/src/@core/field-mapping/field-mapping.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { FieldMappingService } from './field-mapping.service'; +import { FieldMappingController } from './field-mapping.controller'; + +@Module({ + providers: [FieldMappingService], + controllers: [FieldMappingController], +}) +export class FieldMappingModule {} diff --git a/packages/api/src/@core/field-mapping/field-mapping.service.spec.ts b/packages/api/src/@core/field-mapping/field-mapping.service.spec.ts new file mode 100644 index 000000000..9a1abfcc7 --- /dev/null +++ b/packages/api/src/@core/field-mapping/field-mapping.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { FieldMappingService } from './field-mapping.service'; + +describe('FieldMappingService', () => { + let service: FieldMappingService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [FieldMappingService], + }).compile(); + + service = module.get(FieldMappingService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/packages/api/src/@core/field-mapping/field-mapping.service.ts b/packages/api/src/@core/field-mapping/field-mapping.service.ts new file mode 100644 index 000000000..7351efa34 --- /dev/null +++ b/packages/api/src/@core/field-mapping/field-mapping.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class FieldMappingService {} diff --git a/packages/api/src/@core/linked-users/dto/create-linked-user.dto.ts b/packages/api/src/@core/linked-users/dto/create-linked-user.dto.ts index a4d26c2fb..13f885ca7 100644 --- a/packages/api/src/@core/linked-users/dto/create-linked-user.dto.ts +++ b/packages/api/src/@core/linked-users/dto/create-linked-user.dto.ts @@ -2,5 +2,5 @@ export class CreateLinkedUserDto { linked_user_origin_id: string; alias: string; status?: string; - id_project: number; + id_project: string; } diff --git a/packages/api/src/@core/linked-users/linked-users.service.ts b/packages/api/src/@core/linked-users/linked-users.service.ts index 88f0b3806..f0ee38b96 100644 --- a/packages/api/src/@core/linked-users/linked-users.service.ts +++ b/packages/api/src/@core/linked-users/linked-users.service.ts @@ -14,7 +14,7 @@ export class LinkedUsersService { const res = await this.prisma.linked_users.create({ data: { ...rest, - id_project: Number(id_project), + id_project: id_project, status: data.status || 'active', }, }); diff --git a/packages/api/src/@core/projects/projects.service.ts b/packages/api/src/@core/projects/projects.service.ts index 546bdba8c..f9e3d110d 100644 --- a/packages/api/src/@core/projects/projects.service.ts +++ b/packages/api/src/@core/projects/projects.service.ts @@ -13,7 +13,7 @@ export class ProjectsService { const res = await this.prisma.projects.create({ data: { ...rest, - id_organization: Number(id_organization), + id_organization: id_organization, }, }); } diff --git a/packages/api/src/app.module.ts b/packages/api/src/app.module.ts index 8aa836740..a12c4f267 100644 --- a/packages/api/src/app.module.ts +++ b/packages/api/src/app.module.ts @@ -22,9 +22,11 @@ import { APP_INTERCEPTOR } from '@nestjs/core'; import { LinkedUsersModule } from './@core/linked-users/linked-users.module'; import { OrganisationsModule } from './@core/organisations/organisations.module'; import { ProjectsModule } from './@core/projects/projects.module'; +import { FieldMappingModule } from './@core/field-mapping/field-mapping.module'; @Module({ imports: [ + FieldMappingModule, LinkedUsersModule, OrganisationsModule, ProjectsModule, diff --git a/packages/api/src/app.service.ts b/packages/api/src/app.service.ts index a43192516..257ce8cde 100644 --- a/packages/api/src/app.service.ts +++ b/packages/api/src/app.service.ts @@ -1,5 +1,4 @@ import { Injectable } from '@nestjs/common'; -import { LoggerService } from './@core/logger/logger.service'; @Injectable() export class AppService { diff --git a/packages/api/src/crm/@types/index.ts b/packages/api/src/crm/@types/index.ts index 751db38a3..1a8fe1462 100644 --- a/packages/api/src/crm/@types/index.ts +++ b/packages/api/src/crm/@types/index.ts @@ -20,6 +20,12 @@ export type UnifiedCrm = | UnifiedContactOutput | UnifiedDealInput; +export class PassThroughRequestDto { + method: 'GET' | 'POST'; + path: string; + data?: Record | Record[]; + headers?: Record; +} export * from './../contact/services/freshsales/types'; export * from './../contact/services/zendesk/types'; export * from './../contact/services/hubspot/types'; diff --git a/packages/api/src/crm/contact/contact.controller.ts b/packages/api/src/crm/contact/contact.controller.ts index 20345a9ad..94065e53d 100644 --- a/packages/api/src/crm/contact/contact.controller.ts +++ b/packages/api/src/crm/contact/contact.controller.ts @@ -16,8 +16,13 @@ export class ContactController { getContacts( @Query('integrationId') integrationId: string, @Query('linkedUserId') linkedUserId: string, + @Query('remote_data') remote_data?: boolean, ) { - return this.contactService.getContacts(integrationId, linkedUserId); + return this.contactService.getContacts( + integrationId, + linkedUserId, + remote_data, + ); } @Post() diff --git a/packages/api/src/crm/contact/dto/create-contact.dto.ts b/packages/api/src/crm/contact/dto/create-contact.dto.ts index e0c1b7707..3c6c8a895 100644 --- a/packages/api/src/crm/contact/dto/create-contact.dto.ts +++ b/packages/api/src/crm/contact/dto/create-contact.dto.ts @@ -8,3 +8,8 @@ export class UnifiedContactInput { } export class UnifiedContactOutput extends UnifiedContactInput {} + +export class ContactResponse { + contacts: UnifiedContactOutput[]; + remote_data?: Record[]; +} diff --git a/packages/api/src/crm/contact/services/contact.service.ts b/packages/api/src/crm/contact/services/contact.service.ts index 46cffc50a..4a71773c9 100644 --- a/packages/api/src/crm/contact/services/contact.service.ts +++ b/packages/api/src/crm/contact/services/contact.service.ts @@ -1,5 +1,6 @@ import { HttpStatus, Injectable } from '@nestjs/common'; import { + ContactResponse, UnifiedContactInput, UnifiedContactOutput, } from '../dto/create-contact.dto'; @@ -70,7 +71,7 @@ export class ContactService { }; } - async addContactToDb(data: UnifiedContactInput, job_id: number | bigint) { + async addContactToDb(data: UnifiedContactInput, job_id: string) { const { first_name, last_name, email_addresses, phone_numbers } = data; const { normalizedEmails, normalizedPhones } = this.normalizeEmailsAndNumbers(email_addresses, phone_numbers); @@ -85,7 +86,7 @@ export class ContactService { crm_contacts_phone_numbers: { create: normalizedPhones, }, - id_job: job_id as number, + id_job: job_id, }, }); } @@ -97,7 +98,7 @@ export class ContactService { ): Promise> { const job_resp_create = await this.prisma.jobs.create({ data: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, status: 'initialized', }, }); @@ -175,10 +176,11 @@ export class ContactService { async getContacts( integrationId: string, linkedUserId: string, - ): Promise> { + remote_data?: boolean, + ): Promise> { const job_resp_create = await this.prisma.jobs.create({ data: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, status: 'written', }, }); @@ -212,11 +214,22 @@ export class ContactService { const sourceObject: ContactOutput[] = resp.data; //unify the data according to the target obj wanted - const unifiedObject = await unify({ + const unifiedObject = (await unify({ sourceObject, targetType: CrmObject.contact, providerName: integrationId, - }); + })) as UnifiedContactOutput[]; + + let res: ContactResponse = { + contacts: unifiedObject, + }; + + if (remote_data) { + res = { + ...res, + remote_data: sourceObject, + }; + } const status_resp = resp.statusCode === HttpStatus.OK ? 'success' : 'fail'; @@ -228,6 +241,6 @@ export class ContactService { status: status_resp, }, }); - return { ...resp, data: unifiedObject as UnifiedContactOutput[] }; + return { ...resp, data: res }; } } diff --git a/packages/api/src/crm/contact/services/freshsales/index.ts b/packages/api/src/crm/contact/services/freshsales/index.ts index 9c4fb0e45..8092de450 100644 --- a/packages/api/src/crm/contact/services/freshsales/index.ts +++ b/packages/api/src/crm/contact/services/freshsales/index.ts @@ -26,7 +26,7 @@ export class FreshSalesService { try { const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const dataBody = { @@ -65,7 +65,7 @@ export class FreshSalesService { //TODO: check required scope => crm.objects.contacts.READ const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const resp = await axios.get( diff --git a/packages/api/src/crm/contact/services/hubspot/index.ts b/packages/api/src/crm/contact/services/hubspot/index.ts index e9f24a9aa..48fe44074 100644 --- a/packages/api/src/crm/contact/services/hubspot/index.ts +++ b/packages/api/src/crm/contact/services/hubspot/index.ts @@ -25,7 +25,7 @@ export class HubspotService { //TODO: check required scope => crm.objects.contacts.write const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const dataBody = { @@ -64,7 +64,7 @@ export class HubspotService { //TODO: check required scope => crm.objects.contacts.READ const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const resp = await axios.get( diff --git a/packages/api/src/crm/contact/services/pipedrive/index.ts b/packages/api/src/crm/contact/services/pipedrive/index.ts index f219609bd..2a6f3c707 100644 --- a/packages/api/src/crm/contact/services/pipedrive/index.ts +++ b/packages/api/src/crm/contact/services/pipedrive/index.ts @@ -26,7 +26,7 @@ export class PipedriveService { //TODO: check required scope => crm.objects.contacts.write const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const resp = await axios.post( @@ -63,7 +63,7 @@ export class PipedriveService { //TODO: check required scope => crm.objects.contacts.READ const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const resp = await axios.get(`https://api.pipedrive.com/v1/persons`, { diff --git a/packages/api/src/crm/contact/services/zendesk/index.ts b/packages/api/src/crm/contact/services/zendesk/index.ts index 4f521195b..75099880a 100644 --- a/packages/api/src/crm/contact/services/zendesk/index.ts +++ b/packages/api/src/crm/contact/services/zendesk/index.ts @@ -25,7 +25,7 @@ export class ZendeskService { //TODO: check required scope => crm.objects.contacts.write const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const resp = await axios.post( @@ -62,7 +62,7 @@ export class ZendeskService { //TODO: check required scope => crm.objects.contacts.READ const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const resp = await axios.get(`https://api.getbase.com/v2/contacts`, { diff --git a/packages/api/src/crm/contact/services/zoho/index.ts b/packages/api/src/crm/contact/services/zoho/index.ts index a6cac53fc..e09a5867a 100644 --- a/packages/api/src/crm/contact/services/zoho/index.ts +++ b/packages/api/src/crm/contact/services/zoho/index.ts @@ -23,7 +23,7 @@ export class ZohoService { //TODO: check required scope => crm.objects.contacts.write const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const resp = await axios.post( @@ -61,7 +61,7 @@ export class ZohoService { //TODO: check required scope => crm.objects.contacts.READ const connection = await this.prisma.connections.findFirst({ where: { - id_linked_user: BigInt(linkedUserId), + id_linked_user: linkedUserId, }, }); const resp = await axios.get(`https://www.zohoapis.com/crm/v3/Contacts`, { diff --git a/packages/api/src/crm/crm.controller.ts b/packages/api/src/crm/crm.controller.ts new file mode 100644 index 000000000..70372a59b --- /dev/null +++ b/packages/api/src/crm/crm.controller.ts @@ -0,0 +1,14 @@ +import { Controller, Post, Body } from '@nestjs/common'; +import { PassThroughRequestDto } from './@types'; +import { CrmService } from './crm.service'; + +@Controller() +export class CrmController { + constructor(private readonly crmService: CrmService) {} + + //TODO: how to know which provider we should make the call to + @Post('/crm/passthrough') + async passthroughRequest(@Body() requestParams: PassThroughRequestDto) { + return this.crmService.sendPassthroughRequest(requestParams); + } +} diff --git a/packages/api/src/crm/crm.module.ts b/packages/api/src/crm/crm.module.ts index e2251f878..6338173bf 100644 --- a/packages/api/src/crm/crm.module.ts +++ b/packages/api/src/crm/crm.module.ts @@ -1,8 +1,12 @@ import { Module } from '@nestjs/common'; import { ContactModule } from './contact/contact.module'; import { DealModule } from './deal/deal.module'; +import { CrmService } from './crm.service'; +import { CrmController } from './crm.controller'; @Module({ imports: [ContactModule, DealModule], + providers: [CrmService], + controllers: [CrmController], }) export class CrmModule {} diff --git a/packages/api/src/crm/crm.service.ts b/packages/api/src/crm/crm.service.ts new file mode 100644 index 000000000..6131f263f --- /dev/null +++ b/packages/api/src/crm/crm.service.ts @@ -0,0 +1,10 @@ +import { Injectable } from '@nestjs/common'; +import { PassThroughRequestDto } from './@types'; + +@Injectable() +export class CrmService { + async sendPassthroughRequest(requestParams: PassThroughRequestDto) { + const { method, path, data, headers } = requestParams; + //TODO: make the right call + } +} From bb5ed9d483b63f62650a134558634fded8684184 Mon Sep 17 00:00:00 2001 From: nael Date: Sat, 25 Nov 2023 23:57:14 +0100 Subject: [PATCH 2/3] feat: fix WIP --- pnpm-lock.yaml | 177 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 137 insertions(+), 40 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e4fe7b926..7162956fe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -183,6 +183,9 @@ importers: react-dom: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) + react-loader-spinner: + specifier: ^5.4.5 + version: 5.4.5(@babel/core@7.23.2)(react-dom@18.2.0)(react@18.2.0) tailwind-scrollbar-hide: specifier: ^1.1.7 version: 1.1.7 @@ -517,10 +520,10 @@ packages: '@babel/helpers': 7.23.2 '@babel/parser': 7.23.0 '@babel/template': 7.22.15 - '@babel/traverse': 7.23.2 + '@babel/traverse': 7.23.2(supports-color@5.5.0) '@babel/types': 7.23.0 convert-source-map: 1.9.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) gensync: 1.0.0-beta.2 json5: 2.2.3 lodash: 4.17.21 @@ -543,10 +546,10 @@ packages: '@babel/helpers': 7.23.2 '@babel/parser': 7.23.0 '@babel/template': 7.22.15 - '@babel/traverse': 7.23.2 + '@babel/traverse': 7.23.2(supports-color@5.5.0) '@babel/types': 7.23.0 convert-source-map: 2.0.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -624,7 +627,7 @@ packages: '@babel/core': 7.23.2 '@babel/helper-compilation-targets': 7.22.15 '@babel/helper-plugin-utils': 7.22.5 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) lodash.debounce: 4.0.8 resolve: 1.22.8 transitivePeerDependencies: @@ -772,7 +775,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 - '@babel/traverse': 7.23.2 + '@babel/traverse': 7.23.2(supports-color@5.5.0) '@babel/types': 7.23.0 transitivePeerDependencies: - supports-color @@ -1842,7 +1845,7 @@ packages: '@babel/parser': 7.23.0 '@babel/types': 7.23.0 - /@babel/traverse@7.23.2: + /@babel/traverse@7.23.2(supports-color@5.5.0): resolution: {integrity: sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==} engines: {node: '>=6.9.0'} dependencies: @@ -1854,7 +1857,7 @@ packages: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.23.0 '@babel/types': 7.23.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -2122,7 +2125,7 @@ packages: '@babel/preset-typescript': 7.23.2(@babel/core@7.23.2) '@babel/runtime': 7.23.2 '@babel/runtime-corejs3': 7.23.2 - '@babel/traverse': 7.23.2 + '@babel/traverse': 7.23.2(supports-color@5.5.0) '@docusaurus/cssnano-preset': 2.4.3 '@docusaurus/logger': 2.4.3 '@docusaurus/mdx-loader': 2.4.3(@docusaurus/types@2.4.3)(react-dom@17.0.2)(react@17.0.2) @@ -2231,7 +2234,7 @@ packages: react-dom: ^16.8.4 || ^17.0.0 dependencies: '@babel/parser': 7.23.0 - '@babel/traverse': 7.23.2 + '@babel/traverse': 7.23.2(supports-color@5.5.0) '@docusaurus/logger': 2.4.3 '@docusaurus/utils': 2.4.3(@docusaurus/types@2.4.3) '@mdx-js/mdx': 1.6.22 @@ -2856,6 +2859,24 @@ packages: - webpack-cli dev: false + /@emotion/is-prop-valid@1.2.1: + resolution: {integrity: sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==} + dependencies: + '@emotion/memoize': 0.8.1 + dev: false + + /@emotion/memoize@0.8.1: + resolution: {integrity: sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==} + dev: false + + /@emotion/stylis@0.8.5: + resolution: {integrity: sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ==} + dev: false + + /@emotion/unitless@0.7.5: + resolution: {integrity: sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==} + dev: false + /@esbuild/android-arm64@0.18.20: resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} engines: {node: '>=12'} @@ -3072,7 +3093,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) espree: 9.6.1 globals: 13.23.0 ignore: 5.2.4 @@ -3144,7 +3165,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 2.0.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -4589,7 +4610,7 @@ packages: '@typescript-eslint/scope-manager': 5.59.11 '@typescript-eslint/type-utils': 5.59.11(eslint@8.52.0)(typescript@5.1.3) '@typescript-eslint/utils': 5.59.11(eslint@8.52.0)(typescript@5.1.3) - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 grapheme-splitter: 1.0.4 ignore: 5.2.4 @@ -4618,7 +4639,7 @@ packages: '@typescript-eslint/type-utils': 6.9.0(eslint@8.52.0)(typescript@5.1.3) '@typescript-eslint/utils': 6.9.0(eslint@8.52.0)(typescript@5.1.3) '@typescript-eslint/visitor-keys': 6.9.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 graphemer: 1.4.0 ignore: 5.2.4 @@ -4647,7 +4668,7 @@ packages: '@typescript-eslint/type-utils': 6.9.1(eslint@8.52.0)(typescript@4.9.5) '@typescript-eslint/utils': 6.9.1(eslint@8.52.0)(typescript@4.9.5) '@typescript-eslint/visitor-keys': 6.9.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 graphemer: 1.4.0 ignore: 5.2.4 @@ -4676,7 +4697,7 @@ packages: '@typescript-eslint/type-utils': 6.9.1(eslint@8.52.0)(typescript@5.1.3) '@typescript-eslint/utils': 6.9.1(eslint@8.52.0)(typescript@5.1.3) '@typescript-eslint/visitor-keys': 6.9.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 graphemer: 1.4.0 ignore: 5.2.4 @@ -4701,7 +4722,7 @@ packages: '@typescript-eslint/scope-manager': 5.59.11 '@typescript-eslint/types': 5.59.11 '@typescript-eslint/typescript-estree': 5.59.11(typescript@5.1.3) - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 typescript: 5.1.3 transitivePeerDependencies: @@ -4722,7 +4743,7 @@ packages: '@typescript-eslint/types': 6.9.0 '@typescript-eslint/typescript-estree': 6.9.0(typescript@5.1.3) '@typescript-eslint/visitor-keys': 6.9.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 typescript: 5.1.3 transitivePeerDependencies: @@ -4743,7 +4764,7 @@ packages: '@typescript-eslint/types': 6.9.1 '@typescript-eslint/typescript-estree': 6.9.1(typescript@4.9.5) '@typescript-eslint/visitor-keys': 6.9.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 typescript: 4.9.5 transitivePeerDependencies: @@ -4764,7 +4785,7 @@ packages: '@typescript-eslint/types': 6.9.1 '@typescript-eslint/typescript-estree': 6.9.1(typescript@5.1.3) '@typescript-eslint/visitor-keys': 6.9.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 typescript: 5.1.3 transitivePeerDependencies: @@ -4807,7 +4828,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 5.59.11(typescript@5.1.3) '@typescript-eslint/utils': 5.59.11(eslint@8.52.0)(typescript@5.1.3) - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 tsutils: 3.21.0(typescript@5.1.3) typescript: 5.1.3 @@ -4827,7 +4848,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.9.0(typescript@5.1.3) '@typescript-eslint/utils': 6.9.0(eslint@8.52.0)(typescript@5.1.3) - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 ts-api-utils: 1.0.3(typescript@5.1.3) typescript: 5.1.3 @@ -4847,7 +4868,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.9.1(typescript@4.9.5) '@typescript-eslint/utils': 6.9.1(eslint@8.52.0)(typescript@4.9.5) - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 ts-api-utils: 1.0.3(typescript@4.9.5) typescript: 4.9.5 @@ -4867,7 +4888,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.9.1(typescript@5.1.3) '@typescript-eslint/utils': 6.9.1(eslint@8.52.0)(typescript@5.1.3) - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) eslint: 8.52.0 ts-api-utils: 1.0.3(typescript@5.1.3) typescript: 5.1.3 @@ -4901,7 +4922,7 @@ packages: dependencies: '@typescript-eslint/types': 5.59.11 '@typescript-eslint/visitor-keys': 5.59.11 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -4922,7 +4943,7 @@ packages: dependencies: '@typescript-eslint/types': 6.9.0 '@typescript-eslint/visitor-keys': 6.9.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -4943,7 +4964,7 @@ packages: dependencies: '@typescript-eslint/types': 6.9.1 '@typescript-eslint/visitor-keys': 6.9.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -4964,7 +4985,7 @@ packages: dependencies: '@typescript-eslint/types': 6.9.1 '@typescript-eslint/visitor-keys': 6.9.1 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -5240,7 +5261,7 @@ packages: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: false @@ -5674,6 +5695,21 @@ packages: - supports-color dev: false + /babel-plugin-styled-components@2.1.4(@babel/core@7.23.2)(styled-components@5.3.11): + resolution: {integrity: sha512-Xgp9g+A/cG47sUyRwwYxGM4bR/jDRg5N6it/8+HxCnbT5XNKSKDT9xm4oag/osgqjC2It/vH0yXsomOG6k558g==} + peerDependencies: + styled-components: '>= 2' + dependencies: + '@babel/helper-annotate-as-pure': 7.22.5 + '@babel/helper-module-imports': 7.22.15 + '@babel/plugin-syntax-jsx': 7.22.5(@babel/core@7.23.2) + lodash: 4.17.21 + picomatch: 2.3.1 + styled-components: 5.3.11(@babel/core@7.23.2)(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0) + transitivePeerDependencies: + - '@babel/core' + dev: false + /babel-preset-current-node-syntax@1.0.1(@babel/core@7.23.2): resolution: {integrity: sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==} peerDependencies: @@ -5991,6 +6027,10 @@ packages: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} + /camelize@1.0.1: + resolution: {integrity: sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==} + dev: false + /caniuse-api@3.0.0: resolution: {integrity: sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==} dependencies: @@ -6558,6 +6598,11 @@ packages: deprecated: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in. dev: false + /css-color-keywords@1.0.0: + resolution: {integrity: sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==} + engines: {node: '>=4'} + dev: false + /css-declaration-sorter@6.4.1(postcss@8.4.31): resolution: {integrity: sha512-rtdthzxKuyq6IzqX6jEcIzQF/YqccluefyCYheovBOLhFT/drQA9zj/UbRAa9J7C0o6EG6u3E6g+vKkay7/k3g==} engines: {node: ^10 || ^12 || >=14} @@ -6639,6 +6684,14 @@ packages: nth-check: 2.1.1 dev: false + /css-to-react-native@3.2.0: + resolution: {integrity: sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==} + dependencies: + camelize: 1.0.1 + css-color-keywords: 1.0.0 + postcss-value-parser: 4.2.0 + dev: false + /css-tree@1.1.3: resolution: {integrity: sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==} engines: {node: '>=8.0.0'} @@ -6777,7 +6830,7 @@ packages: dependencies: ms: 2.0.0 - /debug@4.3.4: + /debug@4.3.4(supports-color@5.5.0): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} peerDependencies: @@ -6787,6 +6840,7 @@ packages: optional: true dependencies: ms: 2.1.2 + supports-color: 5.5.0 /decamelize-keys@1.1.1: resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} @@ -6942,7 +6996,7 @@ packages: hasBin: true dependencies: address: 1.2.2 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: false @@ -7407,7 +7461,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -8590,7 +8644,7 @@ packages: engines: {node: '>= 6'} dependencies: agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) transitivePeerDependencies: - supports-color dev: false @@ -9174,7 +9228,7 @@ packages: resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} engines: {node: '>=10'} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) istanbul-lib-coverage: 3.2.0 source-map: 0.6.1 transitivePeerDependencies: @@ -9823,7 +9877,7 @@ packages: dependencies: chalk: 5.3.0 commander: 11.1.0 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) execa: 8.0.1 lilconfig: 2.1.0 listr2: 7.0.2 @@ -11791,7 +11845,6 @@ packages: /react-is@18.2.0: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} - dev: true /react-json-view@1.21.3(react-dom@17.0.2)(react@17.0.2): resolution: {integrity: sha512-13p8IREj9/x/Ye4WI/JpjhoIwuzEgUAtgJZNBJckfzJt1qyh24BdTm6UQNGnyTq9dapQdrqvquZTo3dz1X6Cjw==} @@ -11826,6 +11879,21 @@ packages: webpack: 5.89.0 dev: false + /react-loader-spinner@5.4.5(@babel/core@7.23.2)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-32f+sb/v2tnNfyvnCCOS4fpyVHsGXjSyNo6QLniHcaj1XjKLxx14L2z0h6szRugOL8IEJ+53GPwNAdbkDqmy4g==} + peerDependencies: + react: ^16.0.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0 + dependencies: + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + react-is: 18.2.0 + styled-components: 5.3.11(@babel/core@7.23.2)(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0) + styled-tools: 1.7.2 + transitivePeerDependencies: + - '@babel/core' + dev: false + /react-refresh@0.14.0: resolution: {integrity: sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==} engines: {node: '>=0.10.0'} @@ -12733,7 +12801,7 @@ packages: /spdy-transport@3.0.0: resolution: {integrity: sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw==} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) detect-node: 2.1.0 hpack.js: 2.1.6 obuf: 1.1.2 @@ -12747,7 +12815,7 @@ packages: resolution: {integrity: sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA==} engines: {node: '>=6.0.0'} dependencies: - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) handle-thing: 2.0.1 http-deceiver: 1.2.7 select-hose: 2.0.0 @@ -12944,6 +13012,35 @@ packages: inline-style-parser: 0.1.1 dev: false + /styled-components@5.3.11(@babel/core@7.23.2)(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw==} + engines: {node: '>=10'} + peerDependencies: + react: '>= 16.8.0' + react-dom: '>= 16.8.0' + react-is: '>= 16.8.0' + dependencies: + '@babel/helper-module-imports': 7.22.15 + '@babel/traverse': 7.23.2(supports-color@5.5.0) + '@emotion/is-prop-valid': 1.2.1 + '@emotion/stylis': 0.8.5 + '@emotion/unitless': 0.7.5 + babel-plugin-styled-components: 2.1.4(@babel/core@7.23.2)(styled-components@5.3.11) + css-to-react-native: 3.2.0 + hoist-non-react-statics: 3.3.2 + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + react-is: 18.2.0 + shallowequal: 1.1.0 + supports-color: 5.5.0 + transitivePeerDependencies: + - '@babel/core' + dev: false + + /styled-tools@1.7.2: + resolution: {integrity: sha512-IjLxzM20RMwAsx8M1QoRlCG/Kmq8lKzCGyospjtSXt/BTIIcvgTonaxQAsKnBrsZNwhpHzO9ADx5te0h76ILVg==} + dev: false + /stylehacks@5.1.1(postcss@8.4.31): resolution: {integrity: sha512-sBpcd5Hx7G6seo7b1LkpttvTz7ikD0LlH5RmdcBNb6fFR0Fl7LQwHDFr300q4cwUqi+IYrFGmsIHieMBfnN/Bw==} engines: {node: ^10 || ^12 || >=14.0} @@ -12993,7 +13090,7 @@ packages: dependencies: component-emitter: 1.3.0 cookiejar: 2.1.4 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) fast-safe-stringify: 2.1.1 form-data: 4.0.0 formidable: 2.1.2 @@ -13455,7 +13552,7 @@ packages: bundle-require: 4.0.2(esbuild@0.18.20) cac: 6.7.14 chokidar: 3.5.3 - debug: 4.3.4 + debug: 4.3.4(supports-color@5.5.0) esbuild: 0.18.20 execa: 5.1.1 globby: 11.1.0 From e5c8d909c230300cd081ff9bbdcf212680d7648a Mon Sep 17 00:00:00 2001 From: nael Date: Sun, 26 Nov 2023 15:57:34 +0100 Subject: [PATCH 3/3] feat: done --- packages/api/src/@core/auth/auth.service.ts | 2 ++ .../crm/services/hubspot/hubspot.service.ts | 8 +++++-- .../services/pipedrive/pipedrive.service.ts | 1 + .../crm/services/zendesk/zendesk.service.ts | 1 + .../crm/services/zoho/zoho.service.ts | 1 + .../linked-users/linked-users.service.ts | 1 + .../organisations/organisations.service.ts | 5 ++++- .../src/@core/projects/projects.service.ts | 1 + .../crm/contact/services/contact.service.ts | 22 ++++++++++++++----- packages/api/src/crm/contact/types/index.ts | 2 ++ 10 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/api/src/@core/auth/auth.service.ts b/packages/api/src/@core/auth/auth.service.ts index 2d57e021f..8746ebde3 100644 --- a/packages/api/src/@core/auth/auth.service.ts +++ b/packages/api/src/@core/auth/auth.service.ts @@ -23,6 +23,7 @@ export class AuthService { const res = await this.prisma.users.create({ data: { + id_user: '1', //todo email: user.email, password_hash: hashedPassword, first_name: user.first_name, @@ -158,6 +159,7 @@ export class AuthService { console.log('hey2'); const new_api_key = await this.prisma.api_keys.create({ data: { + id_api_key: '1', //TODO api_key_hash: hashed_token, id_project: projectId as string, id_user: userId as string, diff --git a/packages/api/src/@core/connections/crm/services/hubspot/hubspot.service.ts b/packages/api/src/@core/connections/crm/services/hubspot/hubspot.service.ts index b8547ff6e..86b9c8e3b 100644 --- a/packages/api/src/@core/connections/crm/services/hubspot/hubspot.service.ts +++ b/packages/api/src/@core/connections/crm/services/hubspot/hubspot.service.ts @@ -19,6 +19,7 @@ export class HubspotConnectionService { async addLinkedUserAndProjectTest() { // Adding a new organization const newOrganization = { + id_organization: '1', //TODO name: 'New Organization', stripe_customer_id: 'stripe-customer-123', }; @@ -30,8 +31,9 @@ export class HubspotConnectionService { // Example data for a new project const newProject = { + id_project: '1', name: 'New Project', - id_organization: 1n, // bigint value + id_organization: '1', }; const data1 = await this.prisma.projects.create({ data: newProject, @@ -39,10 +41,11 @@ export class HubspotConnectionService { this.logger.log('Added new project ' + data1); const newLinkedUser = { + id_linked_user: '1', linked_user_origin_id: '12345', alias: 'ACME COMPANY', status: 'Active', - id_project: 1n, // bigint value + id_project: '1', }; const data = await this.prisma.linked_users.create({ data: newLinkedUser, @@ -92,6 +95,7 @@ export class HubspotConnectionService { //TODO: encrypt the access token and refresh tokens const db_res = await this.prisma.connections.create({ data: { + id_connection: '1', //TODO provider_slug: 'hubspot', token_type: 'oauth', access_token: data.access_token, diff --git a/packages/api/src/@core/connections/crm/services/pipedrive/pipedrive.service.ts b/packages/api/src/@core/connections/crm/services/pipedrive/pipedrive.service.ts index e1eca200b..4176e9b21 100644 --- a/packages/api/src/@core/connections/crm/services/pipedrive/pipedrive.service.ts +++ b/packages/api/src/@core/connections/crm/services/pipedrive/pipedrive.service.ts @@ -59,6 +59,7 @@ export class PipedriveConnectionService { //TODO: encrypt the access token and refresh tokens const db_res = await this.prisma.connections.create({ data: { + id_connection: '1', //TODO provider_slug: 'pipedrive', token_type: 'oauth', access_token: data.access_token, diff --git a/packages/api/src/@core/connections/crm/services/zendesk/zendesk.service.ts b/packages/api/src/@core/connections/crm/services/zendesk/zendesk.service.ts index 9594fabc6..9b22f2122 100644 --- a/packages/api/src/@core/connections/crm/services/zendesk/zendesk.service.ts +++ b/packages/api/src/@core/connections/crm/services/zendesk/zendesk.service.ts @@ -57,6 +57,7 @@ export class ZendeskConnectionService { //TODO: encrypt the access token and refresh tokens const db_res = await this.prisma.connections.create({ data: { + id_connection: '1', //TODO provider_slug: 'zendesk', token_type: 'oauth', access_token: data.access_token, diff --git a/packages/api/src/@core/connections/crm/services/zoho/zoho.service.ts b/packages/api/src/@core/connections/crm/services/zoho/zoho.service.ts index 366c4968e..de5e74fee 100644 --- a/packages/api/src/@core/connections/crm/services/zoho/zoho.service.ts +++ b/packages/api/src/@core/connections/crm/services/zoho/zoho.service.ts @@ -64,6 +64,7 @@ export class ZohoConnectionService { //TODO: encrypt the access token and refresh tokens const db_res = await this.prisma.connections.create({ data: { + id_connection: '1', //TODO provider_slug: 'zoho', token_type: 'oauth', access_token: data.access_token, diff --git a/packages/api/src/@core/linked-users/linked-users.service.ts b/packages/api/src/@core/linked-users/linked-users.service.ts index f0ee38b96..e80bfb147 100644 --- a/packages/api/src/@core/linked-users/linked-users.service.ts +++ b/packages/api/src/@core/linked-users/linked-users.service.ts @@ -14,6 +14,7 @@ export class LinkedUsersService { const res = await this.prisma.linked_users.create({ data: { ...rest, + id_linked_user: '1', // TODO id_project: id_project, status: data.status || 'active', }, diff --git a/packages/api/src/@core/organisations/organisations.service.ts b/packages/api/src/@core/organisations/organisations.service.ts index 22c396a04..26b09f652 100644 --- a/packages/api/src/@core/organisations/organisations.service.ts +++ b/packages/api/src/@core/organisations/organisations.service.ts @@ -10,7 +10,10 @@ export class OrganisationsService { } async createOrganization(data: CreateOrganizationDto) { const res = await this.prisma.organizations.create({ - data: data, + data: { + ...data, + id_organization: '1', + }, }); } } diff --git a/packages/api/src/@core/projects/projects.service.ts b/packages/api/src/@core/projects/projects.service.ts index f9e3d110d..11aa84cb5 100644 --- a/packages/api/src/@core/projects/projects.service.ts +++ b/packages/api/src/@core/projects/projects.service.ts @@ -13,6 +13,7 @@ export class ProjectsService { const res = await this.prisma.projects.create({ data: { ...rest, + id_project: '1', //TODO id_organization: id_organization, }, }); diff --git a/packages/api/src/crm/contact/services/contact.service.ts b/packages/api/src/crm/contact/services/contact.service.ts index 4a71773c9..609f9f777 100644 --- a/packages/api/src/crm/contact/services/contact.service.ts +++ b/packages/api/src/crm/contact/services/contact.service.ts @@ -10,7 +10,7 @@ import { HubspotService } from './hubspot'; import { ZohoService } from './zoho'; import { ZendeskService } from './zendesk'; import { PipedriveService } from './pipedrive'; -import { ApiResponse, Email, NormalizedContactInfo, Phone } from '../types'; +import { ApiResponse, Email, Phone } from '../types'; import { desunify } from 'src/@core/utils/unification/desunify'; import { CrmObject, @@ -50,18 +50,25 @@ export class ContactService { } //utils functions - normalizeEmailsAndNumbers( - email_addresses: Email[], - phone_numbers: Phone[], - ): NormalizedContactInfo { + normalizeEmailsAndNumbers(email_addresses: Email[], phone_numbers: Phone[]) { const normalizedEmails = email_addresses.map((email) => ({ ...email, + owner_type: email.owner_type ? email.owner_type : '', + created_at: new Date(), + modified_at: new Date(), + id_crm_contact_email: '1', //TODO email_address_type: email.email_address_type === '' ? 'work' : email.email_address_type, })); const normalizedPhones = phone_numbers.map((phone) => ({ ...phone, + owner_type: phone.owner_type ? phone.owner_type : '', + created_at: new Date(), + modified_at: new Date(), + id_crm_company: '1', //TODO + id_crm_contact: '1', //TODO + id_crm_contacts_phone_number: '1', //TODO phone_type: phone.phone_type === '' ? 'work' : phone.phone_type, })); @@ -78,6 +85,9 @@ export class ContactService { const resp = await this.prisma.crm_contacts.create({ data: { + id_crm_contact: '1', + created_at: new Date(), + modified_at: new Date(), first_name: first_name, last_name: last_name, crm_contact_email_addresses: { @@ -98,6 +108,7 @@ export class ContactService { ): Promise> { const job_resp_create = await this.prisma.jobs.create({ data: { + id_job: '1', //TODO id_linked_user: linkedUserId, status: 'initialized', }, @@ -180,6 +191,7 @@ export class ContactService { ): Promise> { const job_resp_create = await this.prisma.jobs.create({ data: { + id_job: '1', //TODO id_linked_user: linkedUserId, status: 'written', }, diff --git a/packages/api/src/crm/contact/types/index.ts b/packages/api/src/crm/contact/types/index.ts index fdee8ed6f..58726c30b 100644 --- a/packages/api/src/crm/contact/types/index.ts +++ b/packages/api/src/crm/contact/types/index.ts @@ -8,11 +8,13 @@ export class ApiResponse { export type Email = { email_address: string; email_address_type: string; + owner_type?: string; }; export type Phone = { phone_number: string; phone_type: string; + owner_type?: string; }; export type NormalizedContactInfo = {