Skip to content

Commit

Permalink
✨ Ingest data to handle ensted objects when sync
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jun 26, 2024
1 parent 3d358cb commit 8a52d59
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class IngestDataService {
slug: string;
remote_id: string;
}[],
extraParams?: { [key: string]: any },
): Promise<any[]> {
const unifiedObject = (await this.coreUnification.unify<U[]>({
sourceObject,
Expand All @@ -52,6 +53,7 @@ export class IngestDataService {
unifiedObject,
integrationId,
sourceObject,
...Object.values(extraParams || {}),
);
const event = await this.prisma.events.create({
data: {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/@core/utils/types/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ export interface IBaseSync {
data: any[],
originSource: string,
remote_data: Record<string, any>[],
...rest: any
): Promise<any[]>;
}
5 changes: 1 addition & 4 deletions packages/api/src/ats/user/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ export class SyncService implements OnModuleInit, IBaseSync {
) {
this.logger.setContext(SyncService.name);
this.registry.registerService('ats', 'user', this);
saveToDb(connection_id: string, linkedUserId: string, data: any[], originSource: string, remote_data: Record<string, any>[]): Promise<any[]> {
throw new Error('Method not implemented.');
}
}

async onModuleInit() {
Expand Down Expand Up @@ -193,7 +190,7 @@ export class SyncService implements OnModuleInit, IBaseSync {
}
}

async saveUsersInDb(
async saveToDb(
linkedUserId: string,
users: UnifiedUserOutput[],
originSource: string,
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/crm/stage/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export class SyncService implements OnModuleInit, IBaseSync {
'crm',
'stage',
customFieldMappings,
{ id_deal: deal_id },
);
} catch (error) {
throw error;
Expand All @@ -187,8 +188,8 @@ export class SyncService implements OnModuleInit, IBaseSync {
linkedUserId: string,
data: UnifiedStageOutput[],
originSource: string,
deal_id: string,
remote_data: Record<string, any>[],
deal_id: string,
): Promise<CrmStage[]> {
try {
let stages_results: CrmStage[] = [];
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/ticketing/comment/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class SyncService implements OnModuleInit, IBaseSync {
'tikceting',
'comment',
customFieldMappings,
{ id_ticket: id_ticket },
);
} catch (error) {
throw error;
Expand All @@ -179,8 +180,9 @@ export class SyncService implements OnModuleInit, IBaseSync {
connection_id: string,
linkedUserId: string,
comments: UnifiedCommentOutput[],
id_ticket: string,
originSource: string,
remote_data: Record<string, any>[],
id_ticket?: string,
): Promise<TicketingComment[]> {
try {
let comments_results: TicketingComment[] = [];
Expand Down
12 changes: 2 additions & 10 deletions packages/api/src/ticketing/contact/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ export class SyncService implements OnModuleInit, IBaseSync {
this.logger.setContext(SyncService.name);
this.registry.registerService('ticketing', 'contact', this);
}
saveToDb(
connection_id: string,
linkedUserId: string,
data: any[],
originSource: string,
remote_data: Record<string, any>[],
): Promise<any[]> {
throw new Error('Method not implemented.');
}

async onModuleInit() {
try {
Expand Down Expand Up @@ -203,13 +194,14 @@ export class SyncService implements OnModuleInit, IBaseSync {
'ticketing',
'contact',
customFieldMappings,
{ remote_account_id: remote_account_id },
);
} catch (error) {
throw error;
}
}

async saveContactsInDb(
async saveToDb(
connection_id: string,
linkedUserId: string,
contacts: UnifiedContactOutput[],
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/ticketing/tag/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class SyncService implements OnModuleInit, IBaseSync {
'ticketing',
'tag',
customFieldMappings,
{ id_ticket: id_ticket },
);
//TODO; do it in every file
if (!sourceObject || sourceObject.length == 0) {
Expand All @@ -182,8 +183,8 @@ export class SyncService implements OnModuleInit, IBaseSync {
linkedUserId: string,
tags: UnifiedTagOutput[],
originSource: string,
id_ticket: string,
remote_data: Record<string, any>[],
id_ticket: string,
): Promise<TicketingTag[]> {
try {
let tags_results: TicketingTag[] = [];
Expand Down

0 comments on commit 8a52d59

Please sign in to comment.