Skip to content

Commit

Permalink
🚑 Added openapi spec updates
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Aug 6, 2024
1 parent dfa7ada commit a0bb0a0
Show file tree
Hide file tree
Showing 27 changed files with 276 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export class JiraConnectionService implements ITicketingConnectionService {
});

//reconstruct the redirect URI that was passed in the githubend it must be the same
const REDIRECT_URI = `${this.env.getPanoraBaseUrl()}/connections/oauth/callback`;
const REDIRECT_URI = `${
this.env.getDistributionMode() == 'selfhost'
? this.env.getTunnelIngress()
: this.env.getPanoraBaseUrl()
}/connections/oauth/callback`;
const CREDENTIALS = (await this.cService.getCredentials(
projectId,
this.type,
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/ats/activity/services/activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,8 @@ export class ActivityService {
fieldMappingsMap.set(value.attribute.slug, value.data);
});

const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

return {
id: activity.id_ats_activity,
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/ats/candidate/services/candidate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,8 @@ export class CandidateService {
fieldMappingsMap.set(value.attribute.slug, value.data);
});

const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

return {
id: candidate.id_ats_candidate,
Expand Down
27 changes: 23 additions & 4 deletions packages/api/src/ats/candidate/types/model.unified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { Email, Phone, Url } from '@ats/@lib/@types';
import { UnifiedAtsApplicationOutput } from '@ats/application/types/model.unified';
import { UnifiedAtsAttachmentOutput } from '@ats/attachment/types/model.unified';
import { UnifiedAtsTagOutput } from '@ats/tag/types/model.unified';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
ApiProperty,
ApiPropertyOptional,
getSchemaPath,
} from '@nestjs/swagger';
import {
IsUUID,
IsOptional,
Expand Down Expand Up @@ -116,7 +120,13 @@ export class UnifiedAtsCandidateInput {
last_interaction_at?: string;

@ApiPropertyOptional({
type: [String],
type: 'array',
items: {
oneOf: [
{ type: 'string' },
{ $ref: getSchemaPath(UnifiedAtsAttachmentOutput) },
],
},
example: ['801f9ede-c698-4e66-a7fc-48d19eebaa4f'],
nullable: true,
description: 'The attachments UUIDs of the candidate',
Expand All @@ -126,7 +136,13 @@ export class UnifiedAtsCandidateInput {
attachments?: (string | UnifiedAtsAttachmentOutput)[];

@ApiPropertyOptional({
type: [String],
type: 'array',
items: {
oneOf: [
{ type: 'string' },
{ $ref: getSchemaPath(UnifiedAtsApplicationOutput) },
],
},
example: ['801f9ede-c698-4e66-a7fc-48d19eebaa4f'],
nullable: true,
description: 'The applications UUIDs of the candidate',
Expand All @@ -136,7 +152,10 @@ export class UnifiedAtsCandidateInput {
applications?: (string | UnifiedAtsApplicationOutput)[];

@ApiPropertyOptional({
type: [String],
type: 'array',
items: {
oneOf: [{ type: 'string' }, { $ref: getSchemaPath(UnifiedAtsTagOutput) }],
},
example: ['tag_1', 'tag_2'],
nullable: true,
description: 'The tags of the candidate',
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/ats/interview/services/interview.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,8 @@ export class InterviewService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedAtsInterviewOutput format
return {
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/crm/company/services/company.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,8 @@ export class CompanyService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedCrmCompanyOutput format
return {
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/crm/contact/contact.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
PaginatedDto,
} from '@@core/utils/dtos/openapi.respone.dto';


@ApiTags('crm/contacts')
@Controller('crm/contacts')
@ApiExtraModels(PaginatedDto, UnifiedCrmContactOutput)
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/crm/contact/services/contact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,8 @@ export class ContactService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedCrmContactInput format
return {
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/crm/deal/services/deal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,8 @@ export class DealService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedCrmDealOutput format
return {
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/crm/note/services/note.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,8 @@ export class NoteService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedCrmNoteOutput format
return {
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/crm/stage/services/stage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,8 @@ export class StageService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedCrmStageOutput format
return {
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/crm/task/services/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,8 @@ export class TaskService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedCrmTaskOutput format
return {
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/crm/user/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,8 @@ export class UserService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedCrmUserOutput format
return {
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/filestorage/file/services/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,8 @@ export class FileService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

let permission;
if (file.id_fs_permission) {
Expand Down
14 changes: 12 additions & 2 deletions packages/api/src/filestorage/group/types/model.unified.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { UnifiedFilestorageUserOutput } from '@filestorage/user/types/model.unified';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
ApiProperty,
ApiPropertyOptional,
getSchemaPath,
} from '@nestjs/swagger';
import { IsUUID, IsOptional, IsString } from 'class-validator';

export class UnifiedFilestorageGroupInput {
Expand All @@ -13,7 +17,13 @@ export class UnifiedFilestorageGroupInput {
name: string;

@ApiProperty({
type: [String],
type: 'array',
items: {
oneOf: [
{ type: 'string' },
{ $ref: getSchemaPath(UnifiedFilestorageUserOutput) },
],
},
example: ['801f9ede-c698-4e66-a7fc-48d19eebaa4f'],
description: 'Uuids of users of the group',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export type PermissionRole = 'READ' | 'WRITE' | 'OWNER';
export class UnifiedFilestoragePermissionInput {
@ApiProperty({
type: [String],
example: ['can_create'], //todo
example: ['READ'],
enum: ['READ', 'WRITE', 'OWNER'],
nullable: true,
description: 'The roles of the permission',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,8 @@ export class CommentService {
});
// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);*/
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);*/
const attachments = await this.prisma.tcg_attachments.findMany({
where: {
id_tcg_ticket: comment.id_tcg_ticket,
Expand Down
14 changes: 12 additions & 2 deletions packages/api/src/ticketing/comment/types/model.unified.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
ApiProperty,
ApiPropertyOptional,
getSchemaPath,
} from '@nestjs/swagger';
import { UnifiedTicketingAttachmentOutput } from '@ticketing/attachment/types/model.unified';
import { IsBoolean, IsIn, IsOptional, IsString, IsUUID } from 'class-validator';

Expand Down Expand Up @@ -81,7 +85,13 @@ export class UnifiedTicketingCommentInput {
user_id?: string; // UUID of User object

@ApiPropertyOptional({
type: [String],
type: 'array',
items: {
oneOf: [
{ type: 'string' },
{ $ref: getSchemaPath(UnifiedTicketingAttachmentOutput) },
],
},
nullable: true,
example: ['801f9ede-c698-4e66-a7fc-48d19eebaa4f'],
description: 'The attachements UUIDs tied to the comment',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ export class ContactService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedTicketingContactOutput format
return {
Expand Down
35 changes: 17 additions & 18 deletions packages/api/src/ticketing/tag/services/tag.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class TagService {
await this.prisma.events.create({
data: {
id_connection: connection_id,
id_project: project_id,
id_project: project_id,
id_event: uuidv4(),
status: 'success',
type: 'ticketing.tag.pull',
Expand All @@ -92,7 +92,7 @@ export class TagService {
}

async getTags(
connection_id: string,
connection_id: string,
project_id: string,
integrationId: string,
linkedUserId: string,
Expand Down Expand Up @@ -169,10 +169,8 @@ export class TagService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedTicketingTagOutput format
return {
Expand All @@ -189,24 +187,25 @@ export class TagService {
let res: UnifiedTicketingTagOutput[] = unifiedTags;

if (remote_data) {
const remote_array_data: UnifiedTicketingTagOutput[] = await Promise.all(
res.map(async (tag) => {
const resp = await this.prisma.remote_data.findFirst({
where: {
ressource_owner_id: tag.id,
},
});
const remote_data = JSON.parse(resp.data);
return { ...tag, remote_data };
}),
);
const remote_array_data: UnifiedTicketingTagOutput[] =
await Promise.all(
res.map(async (tag) => {
const resp = await this.prisma.remote_data.findFirst({
where: {
ressource_owner_id: tag.id,
},
});
const remote_data = JSON.parse(resp.data);
return { ...tag, remote_data };
}),
);

res = remote_array_data;
}
await this.prisma.events.create({
data: {
id_connection: connection_id,
id_project: project_id,
id_project: project_id,
id_event: uuidv4(),
status: 'success',
type: 'ticketing.tag.pull',
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/ticketing/tag/tag.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
ApiPaginatedResponse,
} from '@@core/utils/dtos/openapi.respone.dto';


@ApiTags('ticketing/tags')
@Controller('ticketing/tags')
export class TagController {
Expand Down
6 changes: 2 additions & 4 deletions packages/api/src/ticketing/team/services/team.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,8 @@ export class TeamService {
});

// Convert the map to an array of objects
const field_mappings = Array.from(
fieldMappingsMap,
([key, value]) => ({ [key]: value }),
);
// Convert the map to an object
const field_mappings = Object.fromEntries(fieldMappingsMap);

// Transform to UnifiedTicketingTeamOutput format
return {
Expand Down
Loading

0 comments on commit a0bb0a0

Please sign in to comment.