Skip to content

Commit

Permalink
🚧 BUILD works
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jan 6, 2024
1 parent d43ba6b commit 16d7435
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 29 deletions.
55 changes: 40 additions & 15 deletions packages/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ model crm_companies {
modified_at DateTime @db.Timestamp(6)
id_crm_user String? @db.Uuid
id_event String @db.Uuid
id_linked_user String? @db.Uuid
crm_addresses crm_addresses[]
events events @relation(fields: [id_event], references: [id_event], 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")
Expand All @@ -110,18 +111,16 @@ model crm_contacts {
last_name String
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
remote_platform String
remote_id String
remote_platform String
id_crm_user String? @db.Uuid
id_event String @db.Uuid
id_linked_user String? @db.Uuid
crm_addresses crm_addresses[]
crm_users crm_users? @relation(fields: [id_crm_user], references: [id_crm_user], onDelete: NoAction, onUpdate: NoAction, map: "fk_23")
events events @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "job_id_crm_contact")
crm_email_addresses crm_email_addresses[]
crm_notes crm_notes[]
crm_phone_numbers crm_phone_numbers[]
@@index([id_event], map: "crm_contact_id_job")
@@index([id_crm_user], map: "fk_crm_contact_userid")
}

Expand All @@ -135,6 +134,7 @@ model crm_deals {
modified_at DateTime @db.Timestamp(6)
id_crm_user String? @db.Uuid
id_crm_deals_stage String? @db.Uuid
id_linked_user 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[]
Expand All @@ -149,6 +149,7 @@ model crm_deals_stages {
stage_name String?
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_linked_user String? @db.Uuid
crm_deals crm_deals[]
}

Expand Down Expand Up @@ -202,6 +203,7 @@ model crm_engagements {
remote_id String?
id_crm_engagement_type String @db.Uuid
id_crm_company String? @db.Uuid
id_linked_user 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")
Expand All @@ -218,6 +220,7 @@ model crm_notes {
id_crm_company String? @db.Uuid
id_crm_contact String? @db.Uuid
id_crm_deal String? @db.Uuid
id_linked_user 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")
Expand Down Expand Up @@ -256,6 +259,7 @@ model crm_tasks {
id_crm_user String? @db.Uuid
id_crm_company String? @db.Uuid
id_crm_deal String? @db.Uuid
id_linked_user 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")
Expand All @@ -266,15 +270,16 @@ model crm_tasks {
}

model crm_users {
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[]
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)
id_linked_user String? @db.Uuid
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
Expand All @@ -297,7 +302,6 @@ model events {
provider String
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[]
tcg_comments tcg_comments[]
Expand Down Expand Up @@ -393,6 +397,7 @@ model tcg_comments {
id_tcg_contact String? @db.Uuid
id_tcg_user String? @db.Uuid
id_event String? @db.Uuid
id_linked_user String? @db.Uuid
tcg_attachments tcg_attachments[]
tcg_tickets tcg_tickets? @relation(fields: [id_tcg_ticket], references: [id_tcg_ticket], onDelete: NoAction, onUpdate: NoAction, map: "fk_40_1")
tcg_contacts tcg_contacts? @relation(fields: [id_tcg_contact], references: [id_tcg_contact], onDelete: NoAction, onUpdate: NoAction, map: "fk_41")
Expand All @@ -417,6 +422,7 @@ model tcg_contacts {
modified_at DateTime? @db.Timestamp(6)
id_event String? @db.Uuid
id_tcg_account String? @db.Uuid
id_linked_user String? @db.Uuid
tcg_comments tcg_comments[]
events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_43")
tcg_accounts tcg_accounts? @relation(fields: [id_tcg_account], references: [id_tcg_account], onDelete: NoAction, onUpdate: NoAction, map: "fk_49")
Expand Down Expand Up @@ -445,8 +451,10 @@ model tcg_tickets {
id_event String? @db.Uuid
creator_type String?
id_tcg_user String? @db.Uuid
id_linked_user String @db.Uuid
tcg_attachments tcg_attachments[]
tcg_comments tcg_comments[]
tcg_tags tcg_tags[]
events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_44")
@@index([id_event], map: "fk_tcg_tickets_eventid")
Expand All @@ -464,6 +472,7 @@ model tcg_users {
teams String[]
created_at DateTime? @db.Timestamp(6)
modified_at DateTime? @db.Timestamp(6)
id_linked_user String? @db.Uuid
tcg_comments tcg_comments[]
events events? @relation(fields: [id_event], references: [id_event], onDelete: NoAction, onUpdate: NoAction, map: "fk_45")
Expand Down Expand Up @@ -529,7 +538,7 @@ model webhook_endpoints {
secret String
active Boolean
created_at DateTime @db.Timestamp(6)
scope String?
scope String[]
id_project String @db.Uuid
last_update DateTime? @db.Timestamp(6)
webhook_delivery_attempts webhook_delivery_attempts[]
Expand Down Expand Up @@ -559,6 +568,7 @@ model tcg_accounts {
remote_platform String?
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_linked_user String? @db.Uuid
tcg_contacts tcg_contacts[]
}

Expand All @@ -571,6 +581,7 @@ model tcg_teams {
description String?
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_linked_user String? @db.Uuid
}

/// 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
Expand All @@ -592,3 +603,17 @@ model tcg_attachments {
@@index([id_tcg_comment], map: "fk_tcg_attachment_tcg_commentid")
@@index([id_tcg_ticket], map: "fk_tcg_attachment_tcg_ticketid")
}

model tcg_tags {
id_tcg_tag String @id(map: "pk_tcg_tags") @db.Uuid
name String?
remote_id String?
remote_platform String?
created_at DateTime @db.Timestamp(6)
modified_at DateTime @db.Timestamp(6)
id_tcg_ticket String? @db.Uuid
id_linked_user String? @db.Uuid
tcg_tickets tcg_tickets? @relation(fields: [id_tcg_ticket], references: [id_tcg_ticket], onDelete: NoAction, onUpdate: NoAction, map: "fk_48")
@@index([id_tcg_ticket], map: "fk_tcg_tag_tcg_ticketid")
}
2 changes: 1 addition & 1 deletion packages/api/scripts/webhook.testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function main() {
id_webhook_endpoint: 'a18682af-43f6-4ed2-8bde-b84298f51dde',
},
data: {
scope: 'crm.contact.pulled',
scope: ['crm.contact.pulled'],
},
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/@core/webhook/webhook.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class WebhookService {
active: true,
created_at: new Date(),
id_project: data.id_project,
scope: JSON.stringify(data.scope),
scope: data.scope,
},
});
} catch (error) {
Expand All @@ -73,7 +73,7 @@ export class WebhookService {
if (!webhooks) return;

const webhook = webhooks.find((wh) => {
const scopes = JSON.parse(wh.scope);
const scopes = wh.scope;
return scopes.includes(eventType);
});

Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/crm/contact/services/contact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,7 @@ export class ContactService {
const contacts = await this.prisma.crm_contacts.findMany({
where: {
remote_id: integrationId.toLowerCase(),
events: {
id_linked_user: linkedUserId,
},
id_linked_user: linkedUserId,
},
include: {
crm_email_addresses: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/ticketing/account/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class SyncService implements OnModuleInit {
where: {
remote_id: originId,
remote_platform: originSource,
id_linked_account: linkedUserId,
id_linked_user: linkedUserId,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class AttachmentService {
const data = {
id_tcg_attachment: uuidv4(),
file_name: unifiedAttachmentData.file_name,
uploader: linkedUserId, //TODO
created_at: new Date(),
modified_at: new Date(),
id_linked_user: linkedUserId,
Expand Down Expand Up @@ -187,7 +188,9 @@ export class AttachmentService {
// Transform to UnifiedAttachmentOutput format
const unifiedAttachment: UnifiedAttachmentOutput = {
id: attachment.id_tcg_attachment,
//TODO
file_name: attachment.file_name,
file_url: attachment.file_url,
uploader: attachment.uploader, //TODO
field_mappings: field_mappings,
};

Expand Down Expand Up @@ -261,7 +264,9 @@ export class AttachmentService {
// Transform to UnifiedAttachmentOutput format
return {
id: attachment.id_tcg_attachment,
//TODO
file_name: attachment.file_name,
file_url: attachment.file_url,
uploader: attachment.uploader, //TODO
field_mappings: field_mappings,
};
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ export class CommentService {
ticket_id: comment.id_tcg_ticket,
contact_id: comment.id_tcg_contact, // uuid of Contact object
user_id: comment.id_tcg_user, // uuid of User object
attachments: comment.attachments, //uuids of Attachments objects
};

let res: CommentResponse = {
Expand Down Expand Up @@ -401,7 +400,6 @@ export class CommentService {
ticket_id: comment.id_tcg_ticket,
contact_id: comment.id_tcg_contact, // uuid of Contact object
user_id: comment.id_tcg_user, // uuid of User object
attachments: comment.attachments, //uuids of Attachments objects
};
}),
);
Expand Down
4 changes: 1 addition & 3 deletions packages/api/src/ticketing/tag/services/tag.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export class TagService {
const tags = await this.prisma.tcg_tags.findMany({
where: {
remote_id: integrationId.toLowerCase(),
events: {
id_linked_user: linkedUserId,
},
id_linked_user: linkedUserId,
},
});

Expand Down

0 comments on commit 16d7435

Please sign in to comment.