feat: Troubleshooter atom (#27497)
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
import { ERROR_STATUS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { UpdateEventTypeReturn } from "@calcom/platform-libraries/event-types";
|
||||
import { listWithTeamHandler, PublicEventType } from "@calcom/platform-libraries/event-types";
|
||||
import { ApiResponse } from "@calcom/platform-types";
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Query,
|
||||
UseGuards,
|
||||
VERSION_NEUTRAL,
|
||||
Version,
|
||||
} from "@nestjs/common";
|
||||
import { ApiExcludeController as DocsExcludeController, ApiTags as DocsTags } from "@nestjs/swagger";
|
||||
import { GetEventTypePublicOutput } from "@/ee/event-types/event-types_2024_04_15/outputs/get-event-type-public.output";
|
||||
import { API_VERSIONS_VALUES } from "@/lib/api-versions";
|
||||
import {
|
||||
@@ -16,24 +33,6 @@ import { IsOrgGuard } from "@/modules/auth/guards/organizations/is-org.guard";
|
||||
import { RolesGuard } from "@/modules/auth/guards/roles/roles.guard";
|
||||
import { IsTeamInOrg } from "@/modules/auth/guards/teams/is-team-in-org.guard";
|
||||
import { UserWithProfile } from "@/modules/users/users.repository";
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
UseGuards,
|
||||
Version,
|
||||
VERSION_NEUTRAL,
|
||||
Patch,
|
||||
Body,
|
||||
Query,
|
||||
} from "@nestjs/common";
|
||||
import { ApiTags as DocsTags, ApiExcludeController as DocsExcludeController } from "@nestjs/swagger";
|
||||
|
||||
import { ERROR_STATUS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { UpdateEventTypeReturn } from "@calcom/platform-libraries/event-types";
|
||||
import { PublicEventType } from "@calcom/platform-libraries/event-types";
|
||||
import { ApiResponse } from "@calcom/platform-types";
|
||||
|
||||
/*
|
||||
Event-types endpoints for atoms, split from AtomsController for clarity and maintainability.
|
||||
@@ -49,6 +48,17 @@ These endpoints should not be recommended for use by third party and are exclude
|
||||
export class AtomsEventTypesController {
|
||||
constructor(private readonly eventTypesService: EventTypesAtomService) {}
|
||||
|
||||
@Get("/event-types/list-with-team")
|
||||
@Version(VERSION_NEUTRAL)
|
||||
@UseGuards(ApiAuthGuard)
|
||||
async listEventTypesWithTeam(@GetUser() user: UserWithProfile): Promise<ApiResponse<unknown>> {
|
||||
const eventTypes = await listWithTeamHandler({ ctx: { user } });
|
||||
return {
|
||||
status: SUCCESS_STATUS,
|
||||
data: eventTypes,
|
||||
};
|
||||
}
|
||||
|
||||
@Get("/event-types/:eventSlug/public")
|
||||
async getPublicEventType(
|
||||
@Param("eventSlug") eventSlug: string,
|
||||
|
||||
@@ -73,6 +73,21 @@ export class AtomsSchedulesController {
|
||||
};
|
||||
}
|
||||
|
||||
@Get("/schedules/event-type/:eventSlug")
|
||||
@Version(VERSION_NEUTRAL)
|
||||
@UseGuards(ApiAuthGuard)
|
||||
@Permissions([SCHEDULE_READ])
|
||||
async getScheduleByEventSlug(
|
||||
@GetUser() user: UserWithProfile,
|
||||
@Param("eventSlug") eventSlug: string
|
||||
): Promise<ApiResponse<unknown>> {
|
||||
const schedule = await this.schedulesService.getScheduleByEventSlug(user, eventSlug);
|
||||
return {
|
||||
status: SUCCESS_STATUS,
|
||||
data: schedule,
|
||||
};
|
||||
}
|
||||
|
||||
@Get("/schedules/all")
|
||||
@Version(VERSION_NEUTRAL)
|
||||
@UseGuards(ApiAuthGuard)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { UsersRepository } from "@/modules/users/users.repository";
|
||||
import { UserWithProfile } from "@/modules/users/users.repository";
|
||||
@@ -5,6 +6,7 @@ import { Logger } from "@nestjs/common";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import { ScheduleRepository, UpdateScheduleResponse } from "@calcom/platform-libraries/schedules";
|
||||
import { getScheduleByEventSlugHandler } from "@calcom/platform-libraries/schedules";
|
||||
import { updateSchedule } from "@calcom/platform-libraries/schedules";
|
||||
import { UpdateAtomScheduleDto } from "@calcom/platform-types";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
@@ -15,6 +17,7 @@ export class SchedulesAtomsService {
|
||||
|
||||
constructor(
|
||||
private readonly usersRepository: UsersRepository,
|
||||
private readonly dbRead: PrismaReadService,
|
||||
private readonly dbWrite: PrismaWriteService
|
||||
) {}
|
||||
|
||||
@@ -42,6 +45,13 @@ export class SchedulesAtomsService {
|
||||
});
|
||||
}
|
||||
|
||||
async getScheduleByEventSlug(user: UserWithProfile, eventSlug: string) {
|
||||
return getScheduleByEventSlugHandler({
|
||||
ctx: { user, prisma: this.dbRead.prisma as unknown as PrismaClient },
|
||||
input: { eventSlug },
|
||||
});
|
||||
}
|
||||
|
||||
async updateUserSchedule({
|
||||
input,
|
||||
user,
|
||||
|
||||
Reference in New Issue
Block a user