fix: v2 ts config and errors (#14799)

* fix: exclude platform examples

* fix: v2 event-types TS errors

* fix: nest entry file

---------

Co-authored-by: Morgan Vernay <[email protected]>
Co-authored-by: Morgan <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-04-29 16:06:25 +00:00
1 parent 8b28a6f5df
commit bbad2c9d31
7 files changed
+33 -17

No files matched your search

@@ -6,7 +6,7 @@ import { DeleteEventTypeOutput } from "@/ee/event-types/outputs/delete-event-typ
import { GetEventTypePublicOutput } from "@/ee/event-types/outputs/get-event-type-public.output";
import { GetEventTypeOutput } from "@/ee/event-types/outputs/get-event-type.output";
import { GetEventTypesPublicOutput } from "@/ee/event-types/outputs/get-event-types-public.output";
import { GetEventTypesOutput } from "@/ee/event-types/outputs/get-event-types.output";
import { GetEventTypesData, GetEventTypesOutput } from "@/ee/event-types/outputs/get-event-types.output";
import { UpdateEventTypeOutput } from "@/ee/event-types/outputs/update-event-type.output";
import { EventTypesService } from "@/ee/event-types/services/event-types.service";
import { GetUser } from "@/modules/auth/decorators/get-user/get-user.decorator";
@@ -96,7 +96,7 @@ export class EventTypesController {
return {
status: SUCCESS_STATUS,
data: eventTypes,
data: eventTypes as GetEventTypesData,
};
}
@@ -59,7 +59,8 @@ export class EventTypeOutput {
@IsInt()
@ApiHideProperty()
position!: number;
@IsOptional()
position?: number;
@IsInt()
@ApiHideProperty()
@@ -71,7 +72,8 @@ export class EventTypeOutput {
@IsInt()
@ApiHideProperty()
profileId!: number | null;
@IsOptional()
profileId?: number | null;
@IsInt()
@ApiHideProperty()
@@ -83,7 +85,8 @@ export class EventTypeOutput {
@IsInt()
@ApiHideProperty()
parentId!: number | null;
@IsOptional()
parentId?: number | null;
@IsOptional()
@IsArray()
@@ -176,7 +179,8 @@ export class EventTypeOutput {
@IsInt()
@ApiHideProperty()
scheduleId!: number | null;
@IsOptional()
scheduleId?: number | null;
@IsNumber()
@ApiHideProperty()
@@ -12,7 +12,7 @@ class EventTypeGroup {
eventTypes!: EventTypeOutput[];
}
class GetEventTypesData {
export class GetEventTypesData {
@ValidateNested({ each: true })
@Type(() => EventTypeGroup)
@IsArray()
@@ -2,6 +2,7 @@ import { DEFAULT_EVENT_TYPES } from "@/ee/event-types/constants/constants";
import { EventTypesRepository } from "@/ee/event-types/event-types.repository";
import { CreateEventTypeInput } from "@/ee/event-types/inputs/create-event-type.input";
import { UpdateEventTypeInput } from "@/ee/event-types/inputs/update-event-type.input";
import { EventTypeOutput } from "@/ee/event-types/outputs/event-type.output";
import { MembershipsRepository } from "@/modules/memberships/memberships.repository";
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
import { SelectedCalendarsRepository } from "@/modules/selected-calendars/selected-calendars.repository";
@@ -22,7 +23,7 @@ export class EventTypesService {
private readonly dbWrite: PrismaWriteService
) {}
async createUserEventType(user: UserWithProfile, body: CreateEventTypeInput) {
async createUserEventType(user: UserWithProfile, body: CreateEventTypeInput): Promise<EventTypeOutput> {
await this.checkCanCreateEventType(user.id, body);
const eventTypeUser = await this.getUserToCreateEvent(user);
const { eventType } = await createEventType({
@@ -34,7 +35,7 @@ export class EventTypesService {
prisma: this.dbWrite.prisma,
},
});
return eventType;
return eventType as EventTypeOutput;
}
async checkCanCreateEventType(userId: number, body: CreateEventTypeInput) {
@@ -88,7 +89,7 @@ export class EventTypesService {
}
this.checkUserOwnsEventType(user.id, eventType.eventType);
return eventType;
return eventType as { eventType: EventTypeOutput };
}
async getEventTypesPublicByUsername(username: string): Promise<EventTypesPublic> {
@@ -126,9 +127,13 @@ export class EventTypesService {
},
});
const { eventType } = await this.getUserEventTypeForAtom(user, eventTypeId);
const eventType = await this.getUserEventTypeForAtom(user, eventTypeId);
return eventType;
if (!eventType) {
throw new NotFoundException(`Event type with id ${eventTypeId} not found`);
}
return eventType.eventType;
}
async checkCanUpdateEventType(userId: number, eventTypeId: number) {