diff --git a/packages/api/prisma/schema.prisma b/packages/api/prisma/schema.prisma index b600e19e2..85a130bc1 100644 --- a/packages/api/prisma/schema.prisma +++ b/packages/api/prisma/schema.prisma @@ -187,7 +187,7 @@ model crm_contacts { model crm_deals { id_crm_deal String @id(map: "pk_crm_deal") @db.Uuid name String - description String? + description String amount BigInt created_at DateTime @db.Timestamp(6) modified_at DateTime @db.Timestamp(6) @@ -499,7 +499,6 @@ model tcg_collections { remote_platform String? collection_type String? parent_collection String? @db.Uuid - id_tcg_ticket String? @db.Uuid created_at DateTime @db.Timestamp(6) modified_at DateTime @db.Timestamp(6) id_linked_user String @db.Uuid @@ -514,14 +513,14 @@ model tcg_comments { is_private Boolean? remote_id String? remote_platform String? + created_at DateTime? @db.Timestamp(6) + modified_at DateTime? @db.Timestamp(6) creator_type String? id_tcg_attachment String[] id_tcg_ticket String? @db.Uuid id_tcg_contact String? @db.Uuid id_tcg_user String? @db.Uuid id_linked_user String? @db.Uuid - created_at DateTime? @db.Timestamp(6) - modified_at DateTime? @db.Timestamp(6) id_connection 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") @@ -592,14 +591,14 @@ model tcg_tickets { collections String[] completed_at DateTime? @db.Timestamp(6) priority String? + created_at DateTime @db.Timestamp(6) + modified_at DateTime @db.Timestamp(6) assigned_to String[] remote_id String? remote_platform String? creator_type String? id_tcg_user String? @db.Uuid - id_linked_user String? @db.Uuid - created_at DateTime @db.Timestamp(6) - modified_at DateTime @db.Timestamp(6) + id_linked_user String @db.Uuid id_connection String @db.Uuid tcg_attachments tcg_attachments[] tcg_comments tcg_comments[] @@ -616,10 +615,10 @@ model tcg_users { remote_id String? remote_platform String? teams String[] - id_linked_user String? @db.Uuid - id_connection String @db.Uuid created_at DateTime? @db.Timestamp(6) modified_at DateTime? @db.Timestamp(6) + id_linked_user String? @db.Uuid + id_connection String @db.Uuid tcg_comments tcg_comments[] } @@ -674,6 +673,7 @@ model connector_sets { crm_zendesk Boolean? crm_close Boolean? fs_box Boolean? + tcg_github Boolean? projects projects[] } @@ -1635,111 +1635,3 @@ model acc_vendor_credits { tracking_categories String[] accounting_period 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 -model ecom_customer_addresses { - id_ecom_customer_address String @id(map: "pk_ecom_customer_addresses") @db.Uuid - address_type String? - line_1 String? - line_2 String? - street_1 String? - street_2 String? - city String? - state String? - postal_code String? - country String? - id_ecom_customer String @db.Uuid - modified_at DateTime @db.Timestamptz(6) - created_at DateTime @db.Timestamptz(6) - ecom_customers ecom_customers @relation(fields: [id_ecom_customer], references: [id_ecom_customer], onDelete: NoAction, onUpdate: NoAction, map: "fk_ecom_customer_customeraddress") - - @@index([id_ecom_customer], map: "fk_index_ecom_customer_customeraddress") -} - -model ecom_customers { - id_ecom_customer String @id(map: "pk_ecom_customers") @db.Uuid - remote_id String? - email String? - first_name String? - last_name String? - phone_number String? - modifed_at DateTime @db.Timestamptz(6) - created_at DateTime @db.Timestamptz(6) - id_connection String @db.Uuid - ecom_customer_addresses ecom_customer_addresses[] - ecom_orders ecom_orders[] -} - -/// 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 ecom_fulfilments { - id_ecom_fulfilment String @id(map: "pk_ecom_fulfilments") @db.Uuid - carrier String? - tracking_urls String[] - tracking_numbers String[] - items Json? - remote_id String? - id_ecom_order String? @db.Uuid - id_connection String @db.Uuid - modifed_at DateTime @db.Timestamptz(6) - created_at DateTime @db.Timestamptz(6) - ecom_orders ecom_orders? @relation(fields: [id_ecom_order], references: [id_ecom_order], onDelete: NoAction, onUpdate: NoAction, map: "fk_ecom_order_fulfilment") - - @@index([id_ecom_order], map: "fk_index_ecom_order_fulfilment") -} - -model ecom_orders { - id_ecom_order String @id(map: "pk_ecom_orders") @db.Uuid - order_status String? - order_number String? - payment_status String? - currency String? - total_price BigInt? - total_discount BigInt? - total_shipping BigInt? - total_tax BigInt? - fulfillment_status String? - remote_id String? - id_ecom_customer String? @db.Uuid - id_connection String @db.Uuid - modifed_at DateTime @db.Timestamptz(6) - created_at DateTime @db.Timestamptz(6) - ecom_fulfilments ecom_fulfilments[] - ecom_customers ecom_customers? @relation(fields: [id_ecom_customer], references: [id_ecom_customer], onDelete: NoAction, onUpdate: NoAction, map: "fk_ecom_customer_orders") - - @@index([id_ecom_customer], map: "fk_index_ecom_customer_orders") -} - -/// 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 ecom_product_variants { - id_ecom_product_variant String @id(map: "pk_ecom_product_variants") @db.Uuid - id_connection String @db.Uuid - remote_id String? - title String? - price BigInt? - sku String? - options Json? - weight BigInt? - inventory_quantity BigInt? - id_ecom_product String? @db.Uuid - modifed_at DateTime @db.Timestamptz(6) - created_at DateTime @db.Timestamptz(6) - ecom_products ecom_products? @relation(fields: [id_ecom_product], references: [id_ecom_product], onDelete: NoAction, onUpdate: NoAction, map: "fk_ecom_products_variants") - - @@index([id_ecom_product], map: "fk_index_ecom_products_variants") -} - -model ecom_products { - id_ecom_product String @id(map: "pk_ecom_products") @db.Uuid - remote_id String? - product_url String? - product_type String? - product_status String? - images_urls String[] - description String? - vendor String? - tags String[] - modifed_at DateTime @db.Timestamptz(6) - created_at DateTime @db.Timestamptz(6) - id_connection String @db.Uuid - ecom_product_variants ecom_product_variants[] -} diff --git a/packages/api/scripts/init.sql b/packages/api/scripts/init.sql index d9a630743..3f67248bd 100644 --- a/packages/api/scripts/init.sql +++ b/packages/api/scripts/init.sql @@ -492,7 +492,8 @@ CREATE TABLE connector_sets crm_zendesk boolean NULL, crm_close boolean NULL, fs_box boolean NULL, - CONSTRAINT PK_project_connector PRIMARY KEY ( id_connector_set ) + tcg_github boolean NULL, +CONSTRAINT PK_project_connector PRIMARY KEY ( id_connector_set ) ); diff --git a/packages/api/scripts/seed.sql b/packages/api/scripts/seed.sql index 0f4451e45..2efa9006b 100644 --- a/packages/api/scripts/seed.sql +++ b/packages/api/scripts/seed.sql @@ -1,10 +1,10 @@ INSERT INTO users (id_user, identification_strategy, email, password_hash, first_name, last_name) VALUES ('0ce39030-2901-4c56-8db0-5e326182ec6b', 'b2c','local@panora.dev', '$2b$10$Y7Q8TWGyGuc5ecdIASbBsuXMo3q/Rs3/cnY.mLZP4tUgfGUOCUBlG', 'local', 'Panora'); -INSERT INTO connector_sets (id_connector_set, crm_hubspot, crm_zoho, crm_pipedrive, crm_attio, crm_zendesk, crm_close, tcg_zendesk, tcg_gorgias, tcg_front, tcg_jira, tcg_gitlab, fs_box) VALUES - ('1709da40-17f7-4d3a-93a0-96dc5da6ddd7', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), - ('852dfff8-ab63-4530-ae49-e4b2924407f8', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), - ('aed0f856-f802-4a79-8640-66d441581a99', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); +INSERT INTO connector_sets (id_connector_set, crm_hubspot, crm_zoho, crm_pipedrive, crm_attio, crm_zendesk, crm_close, tcg_zendesk, tcg_gorgias, tcg_front, tcg_jira, tcg_gitlab, fs_box, tcg_github) VALUES + ('1709da40-17f7-4d3a-93a0-96dc5da6ddd7', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), + ('852dfff8-ab63-4530-ae49-e4b2924407f8', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), + ('aed0f856-f802-4a79-8640-66d441581a99', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); INSERT INTO projects (id_project, name, sync_mode, id_user, id_connector_set) VALUES ('1e468c15-aa57-4448-aa2b-7fed640d1e3d', 'Project 1', 'pool', '0ce39030-2901-4c56-8db0-5e326182ec6b', '1709da40-17f7-4d3a-93a0-96dc5da6ddd7'), diff --git a/packages/api/src/@core/utils/types/original/original.ticketing.ts b/packages/api/src/@core/utils/types/original/original.ticketing.ts index ff69acd3b..20285be76 100644 --- a/packages/api/src/@core/utils/types/original/original.ticketing.ts +++ b/packages/api/src/@core/utils/types/original/original.ticketing.ts @@ -1,3 +1,16 @@ +import { GithubCollectionInput, GithubCollectionOutput } from '@ticketing/collection/services/github/types'; + +import { GithubCommentInput, GithubCommentOutput } from '@ticketing/comment/services/github/types'; + +import { GithubTagInput, GithubTagOutput } from '@ticketing/tag/services/github/types'; + +import { GithubTeamInput, GithubTeamOutput } from '@ticketing/team/services/github/types'; + +import { GithubTicketInput, GithubTicketOutput } from '@ticketing/ticket/services/github/types'; + +import { GithubUserInput, GithubUserOutput } from '@ticketing/user/services/github/types'; +import { GitlabUserInput, GitlabUserOutput } from '@ticketing/user/services/gitlab/types'; + import { FrontAccountInput, FrontAccountOutput, @@ -131,7 +144,7 @@ export type OriginalTicketInput = | FrontTicketInput | GorgiasTicketInput | JiraTicketInput - | GitlabTicketInput; + | GitlabTicketInput | GithubTicketInput; //| JiraServiceMgmtTicketInput; /* comment */ @@ -140,14 +153,14 @@ export type OriginalCommentInput = | FrontCommentInput | GorgiasCommentInput | JiraCommentInput - | GitlabCommentInput; + | GitlabCommentInput | GithubCommentInput; //| JiraCommentServiceMgmtInput; /* user */ export type OriginalUserInput = | ZendeskUserInput | FrontUserInput | GorgiasUserInput - | JiraUserInput; + | JiraUserInput | GithubUserInput | GitlabUserInput; //| JiraServiceMgmtUserInput; /* account */ export type OriginalAccountInput = ZendeskAccountInput | FrontAccountInput; @@ -163,20 +176,20 @@ export type OriginalTagInput = | FrontTagInput | GorgiasTagInput | JiraTagInput - | GitlabTagInput; + | GitlabTagInput | GithubTagInput; /* team */ export type OriginalTeamInput = | ZendeskTeamInput | FrontTeamInput | GorgiasTeamInput - | JiraTeamInput; + | JiraTeamInput | GithubTeamInput; /* attachment */ export type OriginalAttachmentInput = null; export type OriginalCollectionInput = | JiraCollectionInput - | GitlabCollectionInput; + | GitlabCollectionInput | GithubCollectionInput; export type TicketingObjectInput = | OriginalTicketInput @@ -197,7 +210,7 @@ export type OriginalTicketOutput = | FrontTicketOutput | GorgiasTicketOutput | JiraTicketOutput - | GitlabTicketOutput; + | GitlabTicketOutput | GithubTicketOutput; /* comment */ export type OriginalCommentOutput = @@ -205,13 +218,13 @@ export type OriginalCommentOutput = | FrontCommentOutput | GorgiasCommentOutput | JiraCommentOutput - | GitlabCommentOutput; + | GitlabCommentOutput | GithubCommentOutput; /* user */ export type OriginalUserOutput = | ZendeskUserOutput | FrontUserOutput | GorgiasUserOutput - | JiraUserOutput; + | JiraUserOutput | GithubUserOutput | GitlabUserOutput; /* account */ export type OriginalAccountOutput = ZendeskAccountOutput | FrontAccountOutput; /* contact */ @@ -226,14 +239,14 @@ export type OriginalTagOutput = | FrontTagOutput | GorgiasTagOutput | JiraTagOutput - | GitlabTagOutput; + | GitlabTagOutput | GithubTagOutput; /* team */ export type OriginalTeamOutput = | ZendeskTeamOutput | FrontTeamOutput | GorgiasTeamOutput - | JiraTeamOutput; + | JiraTeamOutput | GithubTeamOutput; /* attachment */ export type OriginalAttachmentOutput = @@ -246,7 +259,7 @@ export type OriginalAttachmentOutput = export type OriginalCollectionOutput = | JiraCollectionOutput - | GitlabCollectionOutput; + | GitlabCollectionOutput | GithubCollectionOutput; export type TicketingObjectOutput = | OriginalTicketOutput diff --git a/packages/api/src/ticketing/collection/collection.module.ts b/packages/api/src/ticketing/collection/collection.module.ts index efc18590c..0f2714338 100644 --- a/packages/api/src/ticketing/collection/collection.module.ts +++ b/packages/api/src/ticketing/collection/collection.module.ts @@ -1,3 +1,5 @@ +import { GithubCollectionMapper } from './services/github/mappers'; +import { GithubService } from './services/github'; import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; import { LoggerService } from '@@core/@core-services/logger/logger.service'; import { BullQueueModule } from '@@core/@core-services/queues/queue.module'; @@ -36,6 +38,8 @@ import { IngestDataService } from '@@core/@core-services/unification/ingest-data /* PROVIDERS MAPPERS */ JiraCollectionMapper, GitlabCollectionMapper, + GithubService, + GithubCollectionMapper, ], exports: [SyncService, ServiceRegistry, WebhookService], }) diff --git a/packages/api/src/ticketing/collection/services/github/mappers.ts b/packages/api/src/ticketing/collection/services/github/mappers.ts index 268f31ae5..b8796a6d6 100644 --- a/packages/api/src/ticketing/collection/services/github/mappers.ts +++ b/packages/api/src/ticketing/collection/services/github/mappers.ts @@ -1,13 +1,15 @@ import { ICollectionMapper } from '@ticketing/collection/types'; import { GithubCollectionInput, GithubCollectionOutput } from './types'; import { - UnifiedCollectionInput, - UnifiedCollectionOutput, + UnifiedTicketingCollectionInput, + UnifiedTicketingCollectionOutput, } from '@ticketing/collection/types/model.unified'; import { MappersRegistry } from '@@core/@core-services/registries/mappers.registry'; import { Injectable } from '@nestjs/common'; import { Utils } from '@ticketing/@lib/@utils'; + + @Injectable() export class GithubCollectionMapper implements ICollectionMapper { constructor(private mappersRegistry: MappersRegistry, private utils: Utils) { @@ -19,7 +21,7 @@ export class GithubCollectionMapper implements ICollectionMapper { ); } desunify( - source: UnifiedCollectionInput, + source: UnifiedTicketingCollectionInput, customFieldMappings?: { slug: string; remote_id: string; @@ -35,7 +37,7 @@ export class GithubCollectionMapper implements ICollectionMapper { slug: string; remote_id: string; }[], - ): UnifiedCollectionOutput | UnifiedCollectionOutput[] { + ): UnifiedTicketingCollectionOutput | UnifiedTicketingCollectionOutput[] { // If the source is not an array, convert it to an array for mapping const sourcesArray = Array.isArray(source) ? source : [source]; @@ -55,8 +57,8 @@ export class GithubCollectionMapper implements ICollectionMapper { slug: string; remote_id: string; }[], - ): UnifiedCollectionOutput { - const unifiedCollection: UnifiedCollectionOutput = { + ): UnifiedTicketingCollectionOutput { + const unifiedCollection: UnifiedTicketingCollectionOutput = { remote_id: String(collection.id), remote_data: collection, name: collection.name, diff --git a/packages/api/src/ticketing/comment/comment.module.ts b/packages/api/src/ticketing/comment/comment.module.ts index 9984d7218..1bf9bb8f5 100644 --- a/packages/api/src/ticketing/comment/comment.module.ts +++ b/packages/api/src/ticketing/comment/comment.module.ts @@ -1,3 +1,5 @@ +import { GithubCommentMapper } from './services/github/mappers'; +import { GithubService } from './services/github'; import { LoggerService } from '@@core/@core-services/logger/logger.service'; import { BullQueueModule } from '@@core/@core-services/queues/queue.module'; @@ -42,6 +44,8 @@ import { SyncService } from './sync/sync.service'; JiraCommentMapper, GorgiasCommentMapper, GitlabCommentMapper, + GithubService, + GithubCommentMapper, ], exports: [SyncService, ServiceRegistry, WebhookService], }) diff --git a/packages/api/src/ticketing/comment/services/github/mappers.ts b/packages/api/src/ticketing/comment/services/github/mappers.ts index ef028e05e..683eb4d01 100644 --- a/packages/api/src/ticketing/comment/services/github/mappers.ts +++ b/packages/api/src/ticketing/comment/services/github/mappers.ts @@ -4,11 +4,11 @@ import { OriginalAttachmentOutput } from '@@core/utils/types/original/original.t import { Injectable } from '@nestjs/common'; import { TicketingObject } from '@ticketing/@lib/@types'; import { Utils } from '@ticketing/@lib/@utils'; -import { UnifiedAttachmentOutput } from '@ticketing/attachment/types/model.unified'; +import { UnifiedTicketingAttachmentOutput } from '@ticketing/attachment/types/model.unified'; import { ICommentMapper } from '@ticketing/comment/types'; import { - UnifiedCommentInput, - UnifiedCommentOutput, + UnifiedTicketingCommentInput, + UnifiedTicketingCommentOutput, } from '@ticketing/comment/types/model.unified'; import { GithubCommentInput, GithubCommentOutput } from './types'; @@ -28,7 +28,7 @@ export class GithubCommentMapper implements ICommentMapper { } async desunify( - source: UnifiedCommentInput, + source: UnifiedTicketingCommentInput, customFieldMappings?: { slug: string; remote_id: string; @@ -51,7 +51,7 @@ export class GithubCommentMapper implements ICommentMapper { slug: string; remote_id: string; }[], - ): Promise { + ): Promise { if (!Array.isArray(source)) { return await this.mapSingleCommentToUnified( source, @@ -77,7 +77,7 @@ export class GithubCommentMapper implements ICommentMapper { slug: string; remote_id: string; }[], - ): Promise { + ): Promise { let opts: any = {}; // Here Github represent Attachment as URL in body of comment as Markdown so we do not have to store in attachement unified object. diff --git a/packages/api/src/ticketing/tag/services/github/mappers.ts b/packages/api/src/ticketing/tag/services/github/mappers.ts index 06f745ce6..43881b841 100644 --- a/packages/api/src/ticketing/tag/services/github/mappers.ts +++ b/packages/api/src/ticketing/tag/services/github/mappers.ts @@ -1,8 +1,8 @@ import { ITagMapper } from '@ticketing/tag/types'; import { GithubTagInput, GithubTagOutput } from './types'; import { - UnifiedTagInput, - UnifiedTagOutput, + UnifiedTicketingTagInput, + UnifiedTicketingTagOutput, } from '@ticketing/tag/types/model.unified'; import { MappersRegistry } from '@@core/@core-services/registries/mappers.registry'; import { Injectable } from '@nestjs/common'; @@ -14,7 +14,7 @@ export class GithubTagMapper implements ITagMapper { this.mappersRegistry.registerService('ticketing', 'tag', 'github', this); } desunify( - source: UnifiedTagInput, + source: UnifiedTicketingTagInput, customFieldMappings?: { slug: string; remote_id: string; @@ -30,7 +30,7 @@ export class GithubTagMapper implements ITagMapper { slug: string; remote_id: string; }[], - ): UnifiedTagOutput | UnifiedTagOutput[] { + ): UnifiedTicketingTagOutput | UnifiedTicketingTagOutput[] { // If the source is not an array, convert it to an array for mapping const sourcesArray = Array.isArray(source) ? source : [source]; @@ -46,8 +46,8 @@ export class GithubTagMapper implements ITagMapper { slug: string; remote_id: string; }[], - ): UnifiedTagOutput { - const unifiedTag: UnifiedTagOutput = { + ): UnifiedTicketingTagOutput { + const unifiedTag: UnifiedTicketingTagOutput = { remote_id: tag.id ? String(tag.id) : null, remote_data: tag, name: tag.name, diff --git a/packages/api/src/ticketing/tag/tag.module.ts b/packages/api/src/ticketing/tag/tag.module.ts index 1358ea4b4..e5aed608d 100644 --- a/packages/api/src/ticketing/tag/tag.module.ts +++ b/packages/api/src/ticketing/tag/tag.module.ts @@ -1,3 +1,5 @@ +import { GithubTagMapper } from './services/github/mappers'; +import { GithubService } from './services/github'; import { BullQueueModule } from '@@core/@core-services/queues/queue.module'; import { IngestDataService } from '@@core/@core-services/unification/ingest-data.service'; @@ -41,6 +43,8 @@ import { GitlabTagMapper } from './services/gitlab/mappers'; JiraTagMapper, GorgiasTagMapper, GitlabTagMapper, + GithubService, + GithubTagMapper, ], exports: [SyncService, ServiceRegistry, WebhookService], }) diff --git a/packages/api/src/ticketing/team/services/github/mappers.ts b/packages/api/src/ticketing/team/services/github/mappers.ts index 23f75599f..69e647078 100644 --- a/packages/api/src/ticketing/team/services/github/mappers.ts +++ b/packages/api/src/ticketing/team/services/github/mappers.ts @@ -1,8 +1,8 @@ import { ITeamMapper } from '@ticketing/team/types'; import { GithubTeamInput, GithubTeamOutput } from './types'; import { - UnifiedTeamInput, - UnifiedTeamOutput, + UnifiedTicketingTeamInput, + UnifiedTicketingTeamOutput, } from '@ticketing/team/types/model.unified'; import { MappersRegistry } from '@@core/@core-services/registries/mappers.registry'; import { Injectable } from '@nestjs/common'; @@ -14,7 +14,7 @@ export class GithubTeamMapper implements ITeamMapper { this.mappersRegistry.registerService('ticketing', 'team', 'github', this); } desunify( - source: UnifiedTeamInput, + source: UnifiedTicketingTeamInput, customFieldMappings?: { slug: string; remote_id: string; @@ -30,7 +30,7 @@ export class GithubTeamMapper implements ITeamMapper { slug: string; remote_id: string; }[], - ): UnifiedTeamOutput | UnifiedTeamOutput[] { + ): UnifiedTicketingTeamOutput | UnifiedTicketingTeamOutput[] { // If the source is not an array, convert it to an array for mapping const sourcesArray = Array.isArray(source) ? source : [source]; @@ -46,8 +46,8 @@ export class GithubTeamMapper implements ITeamMapper { slug: string; remote_id: string; }[], - ): UnifiedTeamOutput { - const unifiedTeam: UnifiedTeamOutput = { + ): UnifiedTicketingTeamOutput { + const unifiedTeam: UnifiedTicketingTeamOutput = { remote_id: String(team.id), remote_data: team, name: team.name, diff --git a/packages/api/src/ticketing/team/team.module.ts b/packages/api/src/ticketing/team/team.module.ts index d868b6185..075026dfa 100644 --- a/packages/api/src/ticketing/team/team.module.ts +++ b/packages/api/src/ticketing/team/team.module.ts @@ -1,3 +1,5 @@ +import { GithubTeamMapper } from './services/github/mappers'; +import { GithubService } from './services/github'; import { BullQueueModule } from '@@core/@core-services/queues/queue.module'; import { IngestDataService } from '@@core/@core-services/unification/ingest-data.service'; import { WebhookService } from '@@core/@core-services/webhooks/panora-webhooks/webhook.service'; @@ -36,6 +38,8 @@ import { TeamController } from './team.controller'; FrontTeamMapper, JiraTeamMapper, GorgiasTeamMapper, + GithubService, + GithubTeamMapper, ], exports: [SyncService, ServiceRegistry, WebhookService], }) diff --git a/packages/api/src/ticketing/ticket/services/github/mappers.ts b/packages/api/src/ticketing/ticket/services/github/mappers.ts index 7503e624c..51500e665 100644 --- a/packages/api/src/ticketing/ticket/services/github/mappers.ts +++ b/packages/api/src/ticketing/ticket/services/github/mappers.ts @@ -1,19 +1,19 @@ import { MappersRegistry } from '@@core/@core-services/registries/mappers.registry'; import { CoreUnification } from '@@core/@core-services/unification/core-unification.service'; import { OriginalTagOutput } from '@@core/utils/types/original/original.ticketing'; -import { UnifiedTagOutput } from '@ticketing/tag/types/model.unified'; +import { UnifiedTicketingTagOutput } from '@ticketing/tag/types/model.unified'; import { Injectable } from '@nestjs/common'; import { TicketingObject } from '@ticketing/@lib/@types'; import { Utils } from '@ticketing/@lib/@utils'; import { ITicketMapper } from '@ticketing/ticket/types'; import { - UnifiedTicketInput, - UnifiedTicketOutput, + UnifiedTicketingTicketInput, + UnifiedTicketingTicketOutput, } from '@ticketing/ticket/types/model.unified'; import { GithubTicketInput, GithubTicketOutput } from './types'; import { GithubTagOutput } from '@ticketing/tag/services/github/types'; import { IngestDataService } from '@@core/@core-services/unification/ingest-data.service'; -import { UnifiedCommentOutput } from '@ticketing/comment/types/model.unified'; +import { UnifiedTicketingCommentOutput } from '@ticketing/comment/types/model.unified'; import { GithubCommentInput } from '@ticketing/comment/services/github/types'; @Injectable() @@ -28,7 +28,7 @@ export class GithubTicketMapper implements ITicketMapper { } async desunify( - source: UnifiedTicketInput, + source: UnifiedTicketingTicketInput, customFieldMappings?: { slug: string; remote_id: string; @@ -63,7 +63,7 @@ export class GithubTicketMapper implements ITicketMapper { if (source.comment) { const comment = - (await this.coreUnificationService.desunify({ + (await this.coreUnificationService.desunify({ sourceObject: source.comment, targetType: TicketingObject.comment, providerName: 'github', @@ -97,7 +97,7 @@ export class GithubTicketMapper implements ITicketMapper { slug: string; remote_id: string; }[], - ): Promise { + ): Promise { const sourcesArray = Array.isArray(source) ? source : [source]; return Promise.all( sourcesArray.map(async (ticket) => @@ -117,7 +117,7 @@ export class GithubTicketMapper implements ITicketMapper { slug: string; remote_id: string; }[], - ): Promise { + ): Promise { const field_mappings: { [key: string]: any } = {}; if (customFieldMappings) { for (const mapping of customFieldMappings) { @@ -143,7 +143,7 @@ export class GithubTicketMapper implements ITicketMapper { if (ticket.labels) { const tags = await this.ingestService.ingestData< - UnifiedTagOutput, + UnifiedTicketingTagOutput, GithubTagOutput >( ticket.labels.map( @@ -174,7 +174,7 @@ export class GithubTicketMapper implements ITicketMapper { } } - const unifiedTicket: UnifiedTicketOutput = { + const unifiedTicket: UnifiedTicketingTicketOutput = { remote_id: String(ticket.id), remote_data: ticket, name: ticket.title, diff --git a/packages/api/src/ticketing/ticket/ticket.module.ts b/packages/api/src/ticketing/ticket/ticket.module.ts index d4530ada2..a7d15caea 100644 --- a/packages/api/src/ticketing/ticket/ticket.module.ts +++ b/packages/api/src/ticketing/ticket/ticket.module.ts @@ -1,3 +1,5 @@ +import { GithubTicketMapper } from './services/github/mappers'; +import { GithubService } from './services/github'; import { BullQueueModule } from '@@core/@core-services/queues/queue.module'; import { IngestDataService } from '@@core/@core-services/unification/ingest-data.service'; import { WebhookService } from '@@core/@core-services/webhooks/panora-webhooks/webhook.service'; @@ -39,6 +41,8 @@ import { TicketController } from './ticket.controller'; JiraTicketMapper, GorgiasTicketMapper, GitlabTicketMapper, + GithubService, + GithubTicketMapper, ], exports: [SyncService, ServiceRegistry, WebhookService, IngestDataService], }) diff --git a/packages/api/src/ticketing/user/services/github/mappers.ts b/packages/api/src/ticketing/user/services/github/mappers.ts index c9d49862c..45725d849 100644 --- a/packages/api/src/ticketing/user/services/github/mappers.ts +++ b/packages/api/src/ticketing/user/services/github/mappers.ts @@ -1,7 +1,7 @@ import { IUserMapper } from '@ticketing/user/types'; import { - UnifiedUserInput, - UnifiedUserOutput, + UnifiedTicketingUserInput, + UnifiedTicketingUserOutput, } from '@ticketing/user/types/model.unified'; import { GithubUserInput, GithubUserOutput } from './types'; import { MappersRegistry } from '@@core/@core-services/registries/mappers.registry'; @@ -14,7 +14,7 @@ export class GithubUserMapper implements IUserMapper { this.mappersRegistry.registerService('ticketing', 'user', 'github', this); } desunify( - source: UnifiedUserInput, + source: UnifiedTicketingUserInput, customFieldMappings?: { slug: string; remote_id: string; @@ -30,7 +30,7 @@ export class GithubUserMapper implements IUserMapper { slug: string; remote_id: string; }[], - ): Promise { + ): Promise { const sourcesArray = Array.isArray(source) ? source : [source]; return sourcesArray.map((user) => this.mapSingleUserToUnified(user, connectionId, customFieldMappings), @@ -44,7 +44,7 @@ export class GithubUserMapper implements IUserMapper { slug: string; remote_id: string; }[], - ): UnifiedUserOutput { + ): UnifiedTicketingUserOutput { // Initialize field_mappings array from customFields, if provided const field_mappings = customFieldMappings ? customFieldMappings @@ -55,7 +55,7 @@ export class GithubUserMapper implements IUserMapper { .filter((mapping) => mapping.value !== undefined) : []; - const unifiedUser: UnifiedUserOutput = { + const unifiedUser: UnifiedTicketingUserOutput = { remote_id: String(user.id), remote_data: user, // does not have name, only github username is available diff --git a/packages/api/src/ticketing/user/user.module.ts b/packages/api/src/ticketing/user/user.module.ts index 13fc5aaae..ab11a146d 100644 --- a/packages/api/src/ticketing/user/user.module.ts +++ b/packages/api/src/ticketing/user/user.module.ts @@ -1,3 +1,5 @@ +import { GithubUserMapper } from './services/github/mappers'; +import { GithubService } from './services/github'; import { WebhookService } from '@@core/@core-services/webhooks/panora-webhooks/webhook.service'; import { Module } from '@nestjs/common'; import { FrontService } from './services/front'; @@ -39,6 +41,8 @@ import { ZendeskUserMapper } from './services/zendesk/mappers'; JiraUserMapper, GorgiasUserMapper, GitlabUserMapper, + GithubService, + GithubUserMapper, ], exports: [SyncService, ServiceRegistry, WebhookService, IngestDataService], }) diff --git a/packages/api/swagger/swagger-spec.yaml b/packages/api/swagger/swagger-spec.yaml index 7f4ebf2a0..c423a3fff 100644 --- a/packages/api/swagger/swagger-spec.yaml +++ b/packages/api/swagger/swagger-spec.yaml @@ -8,6 +8,10 @@ paths: responses: '200': description: '' + content: + application/json: + schema: + type: string /health: get: operationId: health @@ -16,6 +20,10 @@ paths: responses: '200': description: '' + content: + application/json: + schema: + type: number /webhook: get: operationId: listWebhooks @@ -63,6 +71,8 @@ paths: schema: type: string responses: + '200': + description: '' '201': description: '' content: @@ -81,6 +91,8 @@ paths: schema: type: string responses: + '200': + description: '' '201': description: '' content: @@ -500,6 +512,8 @@ paths: responses: '200': description: '' + '201': + description: '' tags: *ref_9 x-speakeasy-group: sync /crm/companies: @@ -1878,6 +1892,12 @@ paths: application/json: schema: $ref: '#/components/schemas/PassThroughResponse' + '201': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/PassThroughResponse' tags: - passthrough /hris/bankinfo: @@ -8016,6 +8036,7 @@ components: description: The unique UUID of the webhook. endpoint_description: type: string + nullable: true description: The description of the webhook. url: type: string @@ -8041,6 +8062,7 @@ components: last_update: format: date-time type: string + nullable: true description: The last update date of the webhook. required: - id_webhook_endpoint @@ -8068,7 +8090,6 @@ components: type: string required: - url - - description - scope EventPayload: type: object diff --git a/packages/shared/src/connectors/enum.ts b/packages/shared/src/connectors/enum.ts index ce0ef4aaf..00cb9111d 100644 --- a/packages/shared/src/connectors/enum.ts +++ b/packages/shared/src/connectors/enum.ts @@ -12,6 +12,7 @@ export enum TicketingConnectors { FRONT = 'front', JIRA = 'jira', GORGIAS = 'gorgias', + GITHUB = 'github', GITLAB = 'gitlab' } diff --git a/packages/shared/src/connectors/index.ts b/packages/shared/src/connectors/index.ts index a32615e52..b3cb80a38 100644 --- a/packages/shared/src/connectors/index.ts +++ b/packages/shared/src/connectors/index.ts @@ -2,6 +2,6 @@ export const CRM_PROVIDERS = ['zoho', 'zendesk', 'hubspot', 'pipedrive', 'attio' export const HRIS_PROVIDERS = []; export const ATS_PROVIDERS = []; export const ACCOUNTING_PROVIDERS = []; -export const TICKETING_PROVIDERS = ['zendesk', 'front', 'jira', 'gorgias', 'gitlab']; +export const TICKETING_PROVIDERS = ['zendesk', 'front', 'jira', 'gorgias', 'gitlab', 'github']; export const MARKETINGAUTOMATION_PROVIDERS = []; export const FILESTORAGE_PROVIDERS = [];