Skip to content

Commit bbad2c9

Browse files
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]>
1 parent 8b28a6f commit bbad2c9

File tree

7 files changed

+33
-17
lines changed

7 files changed

+33
-17
lines changed

apps/api/v2/nest-cli.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://json.schemastore.org/nest-cli",
33
"collection": "@nestjs/schematics",
44
"sourceRoot": "src",
5+
"entryFile": "./apps/api/v2/src/main.js",
56
"compilerOptions": {
67
"deleteOutDir": true,
78
"plugins": [

apps/api/v2/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"start": "nest start",
1212
"dev:build:watch": "yarn workspace @calcom/platform-constants build:watch & yarn workspace @calcom/platform-utils build:watch & yarn workspace @calcom/platform-types build:watch & yarn workspace @calcom/platform-libraries build:watch",
1313
"dev:build": "yarn workspace @calcom/platform-constants build && yarn workspace @calcom/platform-utils build && yarn workspace @calcom/platform-types build && yarn workspace @calcom/platform-libraries build",
14-
"dev": "yarn dev:build && docker-compose up -d && yarn copy-swagger-module && nest start --watch",
14+
"dev": "yarn dev:build && docker-compose up -d && yarn copy-swagger-module && yarn start --watch",
1515
"start:debug": "nest start --debug --watch",
16-
"start:prod": "node dist/src/main",
16+
"start:prod": "node ./dist/apps/api/v2/src/main.js",
1717
"test": "yarn dev:build && jest",
1818
"test:watch": "yarn dev:build && jest --watch",
1919
"test:cov": "yarn dev:build && jest --coverage",

apps/api/v2/src/ee/event-types/controllers/event-types.controller.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { DeleteEventTypeOutput } from "@/ee/event-types/outputs/delete-event-typ
66
import { GetEventTypePublicOutput } from "@/ee/event-types/outputs/get-event-type-public.output";
77
import { GetEventTypeOutput } from "@/ee/event-types/outputs/get-event-type.output";
88
import { GetEventTypesPublicOutput } from "@/ee/event-types/outputs/get-event-types-public.output";
9-
import { GetEventTypesOutput } from "@/ee/event-types/outputs/get-event-types.output";
9+
import { GetEventTypesData, GetEventTypesOutput } from "@/ee/event-types/outputs/get-event-types.output";
1010
import { UpdateEventTypeOutput } from "@/ee/event-types/outputs/update-event-type.output";
1111
import { EventTypesService } from "@/ee/event-types/services/event-types.service";
1212
import { GetUser } from "@/modules/auth/decorators/get-user/get-user.decorator";
@@ -96,7 +96,7 @@ export class EventTypesController {
9696

9797
return {
9898
status: SUCCESS_STATUS,
99-
data: eventTypes,
99+
data: eventTypes as GetEventTypesData,
100100
};
101101
}
102102

apps/api/v2/src/ee/event-types/outputs/event-type.output.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export class EventTypeOutput {
5959

6060
@IsInt()
6161
@ApiHideProperty()
62-
position!: number;
62+
@IsOptional()
63+
position?: number;
6364

6465
@IsInt()
6566
@ApiHideProperty()
@@ -71,7 +72,8 @@ export class EventTypeOutput {
7172

7273
@IsInt()
7374
@ApiHideProperty()
74-
profileId!: number | null;
75+
@IsOptional()
76+
profileId?: number | null;
7577

7678
@IsInt()
7779
@ApiHideProperty()
@@ -83,7 +85,8 @@ export class EventTypeOutput {
8385

8486
@IsInt()
8587
@ApiHideProperty()
86-
parentId!: number | null;
88+
@IsOptional()
89+
parentId?: number | null;
8790

8891
@IsOptional()
8992
@IsArray()
@@ -176,7 +179,8 @@ export class EventTypeOutput {
176179

177180
@IsInt()
178181
@ApiHideProperty()
179-
scheduleId!: number | null;
182+
@IsOptional()
183+
scheduleId?: number | null;
180184

181185
@IsNumber()
182186
@ApiHideProperty()

apps/api/v2/src/ee/event-types/outputs/get-event-types.output.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class EventTypeGroup {
1212
eventTypes!: EventTypeOutput[];
1313
}
1414

15-
class GetEventTypesData {
15+
export class GetEventTypesData {
1616
@ValidateNested({ each: true })
1717
@Type(() => EventTypeGroup)
1818
@IsArray()

apps/api/v2/src/ee/event-types/services/event-types.service.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DEFAULT_EVENT_TYPES } from "@/ee/event-types/constants/constants";
22
import { EventTypesRepository } from "@/ee/event-types/event-types.repository";
33
import { CreateEventTypeInput } from "@/ee/event-types/inputs/create-event-type.input";
44
import { UpdateEventTypeInput } from "@/ee/event-types/inputs/update-event-type.input";
5+
import { EventTypeOutput } from "@/ee/event-types/outputs/event-type.output";
56
import { MembershipsRepository } from "@/modules/memberships/memberships.repository";
67
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
78
import { SelectedCalendarsRepository } from "@/modules/selected-calendars/selected-calendars.repository";
@@ -22,7 +23,7 @@ export class EventTypesService {
2223
private readonly dbWrite: PrismaWriteService
2324
) {}
2425

25-
async createUserEventType(user: UserWithProfile, body: CreateEventTypeInput) {
26+
async createUserEventType(user: UserWithProfile, body: CreateEventTypeInput): Promise<EventTypeOutput> {
2627
await this.checkCanCreateEventType(user.id, body);
2728
const eventTypeUser = await this.getUserToCreateEvent(user);
2829
const { eventType } = await createEventType({
@@ -34,7 +35,7 @@ export class EventTypesService {
3435
prisma: this.dbWrite.prisma,
3536
},
3637
});
37-
return eventType;
38+
return eventType as EventTypeOutput;
3839
}
3940

4041
async checkCanCreateEventType(userId: number, body: CreateEventTypeInput) {
@@ -88,7 +89,7 @@ export class EventTypesService {
8889
}
8990

9091
this.checkUserOwnsEventType(user.id, eventType.eventType);
91-
return eventType;
92+
return eventType as { eventType: EventTypeOutput };
9293
}
9394

9495
async getEventTypesPublicByUsername(username: string): Promise<EventTypesPublic> {
@@ -126,9 +127,13 @@ export class EventTypesService {
126127
},
127128
});
128129

129-
const { eventType } = await this.getUserEventTypeForAtom(user, eventTypeId);
130+
const eventType = await this.getUserEventTypeForAtom(user, eventTypeId);
130131

131-
return eventType;
132+
if (!eventType) {
133+
throw new NotFoundException(`Event type with id ${eventTypeId} not found`);
134+
}
135+
136+
return eventType.eventType;
132137
}
133138

134139
async checkCanUpdateEventType(userId: number, eventTypeId: number) {

apps/api/v2/tsconfig.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@
2727
"forceConsistentCasingInFileNames": false,
2828
"noFallthroughCasesInSwitch": false
2929
},
30-
"exclude": ["./dist", "next-i18next.config.js"],
30+
"exclude": ["./dist", "./node_modules", "next-i18next.config.js"],
3131
"include": [
3232
"./**/*.ts",
3333
"../../../packages/types/*.d.ts",
34-
"../../../packages/platform/**/*.ts",
35-
"../../../packages/platform/**/*.d.ts"
34+
"../../../packages/platform/libraries/**/*.ts",
35+
"../../../packages/platform/libraries/**/*.d.ts",
36+
"../../../packages/platform/constants/**/*.ts",
37+
"../../../packages/platform/constants/**/*.d.ts",
38+
"../../../packages/platform/types/**/*.ts",
39+
"../../../packages/platform/types/**/*.d.ts",
40+
"../../../packages/platform/utils/**/*.ts",
41+
"../../../packages/platform/utils/**/*.d.ts"
3642
]
3743
}

0 commit comments

Comments
 (0)