feat: v2 organizations event types endpoints (#15775)
* fix: event-types input service transform length property * feat: create organizations event-types controller, service and repository * feat: enable organizations event types * fix: create team request user isOrgAdmin check * refactor: hosts array required in team input and output * chore: use platform-libraries at version 0.0.19 * tests: test organizations event-types * feat: enable managed event-types * chore: fix main merge into this branch * feat: assign all team members for managed event-types * refactor: gathering managed event-type users ids * chore: include assignAllTeamMembers in team event response * test: assign all team members db event * chore: delete unused files * docs: swagger create and update request body objects * revert: event-types platform-libraries update * refactor: organisations event-types endpoints accessible by TEAM_ADMIN and up * fix: managed event types output hosts array empty * fix: dont allow creating event-type for non-team member * chore: delete unused variables * tests: negative tests * chore: finish main merge
This commit is contained in:
1 parent
94873ea3cb
commit
8b23e41954
45 files changed
+2991
-363
No files matched your search
@@ -1,14 +1,11 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { Transform } from "class-transformer";
|
||||
import { IsNumber, Min, Max, IsOptional } from "class-validator";
|
||||
import { IsEnum } from "class-validator";
|
||||
import type { Response as BaseResponse } from "express";
|
||||
|
||||
import type {
|
||||
ERROR_STATUS,
|
||||
SUCCESS_STATUS,
|
||||
API_ERROR_CODES,
|
||||
REDIRECT_STATUS,
|
||||
} from "@calcom/platform-constants";
|
||||
import { ERROR_STATUS, SUCCESS_STATUS } from "@calcom/platform-constants";
|
||||
import type { API_ERROR_CODES, REDIRECT_STATUS } from "@calcom/platform-constants";
|
||||
|
||||
export type ApiSuccessResponse<T> = { status: typeof SUCCESS_STATUS; data: T };
|
||||
export type ApiSuccessResponseWithoutData = { status: typeof SUCCESS_STATUS };
|
||||
@@ -75,3 +72,9 @@ export class SkipTakePagination {
|
||||
@IsOptional()
|
||||
skip?: number;
|
||||
}
|
||||
|
||||
export class ApiResponseWithoutData {
|
||||
@ApiProperty({ example: SUCCESS_STATUS, enum: [SUCCESS_STATUS, ERROR_STATUS] })
|
||||
@IsEnum([SUCCESS_STATUS, ERROR_STATUS])
|
||||
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS;
|
||||
}
|
||||
+103
-1
@@ -1,8 +1,19 @@
|
||||
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
|
||||
import { IsString, IsInt, IsBoolean, IsOptional, Min } from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
import {
|
||||
IsString,
|
||||
IsInt,
|
||||
IsBoolean,
|
||||
IsOptional,
|
||||
Min,
|
||||
IsEnum,
|
||||
IsArray,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
|
||||
import type { BookingField_2024_06_14 } from "./booking-fields.input";
|
||||
import { ValidateBookingFields_2024_06_14 } from "./booking-fields.input";
|
||||
import { SchedulingType } from "./enums/scheduling-type";
|
||||
import { ValidateLocations_2024_06_14 } from "./locations.input";
|
||||
import type { Location_2024_06_14 } from "./locations.input";
|
||||
|
||||
@@ -10,6 +21,7 @@ export const CREATE_EVENT_LENGTH_EXAMPLE = 60;
|
||||
export const CREATE_EVENT_TITLE_EXAMPLE = "Learn the secrets of masterchief!";
|
||||
export const CREATE_EVENT_DESCRIPTION_EXAMPLE =
|
||||
"Discover the culinary wonders of the Argentina by making the best flan ever!";
|
||||
|
||||
export class CreateEventTypeInput_2024_06_14 {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@@ -57,3 +69,93 @@ export class CreateEventTypeInput_2024_06_14 {
|
||||
@IsOptional()
|
||||
afterEventBuffer?: number;
|
||||
}
|
||||
|
||||
export enum HostPriority {
|
||||
lowest = "lowest",
|
||||
low = "low",
|
||||
medium = "medium",
|
||||
high = "high",
|
||||
highest = "highest",
|
||||
}
|
||||
export class Host {
|
||||
@IsInt()
|
||||
userId!: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
mandatory?: boolean = false;
|
||||
|
||||
@IsEnum(HostPriority)
|
||||
@IsOptional()
|
||||
priority?: keyof typeof HostPriority = "medium";
|
||||
}
|
||||
|
||||
export class CreateTeamEventTypeInput_2024_06_14 {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@DocsProperty({ example: CREATE_EVENT_LENGTH_EXAMPLE })
|
||||
lengthInMinutes!: number;
|
||||
|
||||
@IsString()
|
||||
@DocsProperty({ example: CREATE_EVENT_TITLE_EXAMPLE })
|
||||
title!: string;
|
||||
|
||||
@IsString()
|
||||
slug!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@DocsProperty({ example: CREATE_EVENT_DESCRIPTION_EXAMPLE })
|
||||
description?: string;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateLocations_2024_06_14()
|
||||
@DocsProperty()
|
||||
locations?: Location_2024_06_14[];
|
||||
|
||||
@IsOptional()
|
||||
@ValidateBookingFields_2024_06_14()
|
||||
@DocsProperty()
|
||||
bookingFields?: BookingField_2024_06_14[];
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
disableGuests?: boolean;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
slotInterval?: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
minimumBookingNotice?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
beforeEventBuffer?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
afterEventBuffer?: number;
|
||||
|
||||
@IsEnum(SchedulingType)
|
||||
@DocsProperty()
|
||||
schedulingType!: keyof typeof SchedulingType;
|
||||
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => Host)
|
||||
@IsArray()
|
||||
@DocsProperty()
|
||||
hosts!: Host[];
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
assignAllTeamMembers?: boolean;
|
||||
}
|
||||
+78
-1
@@ -1,7 +1,10 @@
|
||||
import { IsString, IsInt, IsBoolean, IsOptional, Min } from "class-validator";
|
||||
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
|
||||
import { Type } from "class-transformer";
|
||||
import { IsString, IsInt, IsBoolean, IsOptional, Min, ValidateNested, IsArray } from "class-validator";
|
||||
|
||||
import type { BookingField_2024_06_14 } from "./booking-fields.input";
|
||||
import { ValidateBookingFields_2024_06_14 } from "./booking-fields.input";
|
||||
import { Host } from "./create-event-type.input";
|
||||
import { ValidateLocations_2024_06_14 } from "./locations.input";
|
||||
import type { Location_2024_06_14 } from "./locations.input";
|
||||
|
||||
@@ -15,6 +18,10 @@ export class UpdateEventTypeInput_2024_06_14 {
|
||||
@IsString()
|
||||
title?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
slug?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
description?: string;
|
||||
@@ -48,3 +55,73 @@ export class UpdateEventTypeInput_2024_06_14 {
|
||||
@IsOptional()
|
||||
afterEventBuffer?: number;
|
||||
}
|
||||
export class UpdateTeamEventTypeInput_2024_06_14 {
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@DocsProperty()
|
||||
lengthInMinutes?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
title?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
slug?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@DocsProperty()
|
||||
description?: string;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateLocations_2024_06_14()
|
||||
@DocsProperty()
|
||||
locations?: Location_2024_06_14[];
|
||||
|
||||
@IsOptional()
|
||||
@ValidateBookingFields_2024_06_14()
|
||||
@DocsProperty()
|
||||
bookingFields?: BookingField_2024_06_14[];
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
disableGuests?: boolean;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
slotInterval?: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
minimumBookingNotice?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
beforeEventBuffer?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
afterEventBuffer?: number;
|
||||
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => Host)
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
hosts?: Host[];
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
assignAllTeamMembers?: boolean;
|
||||
}
|
||||
+115
-1
@@ -1,8 +1,18 @@
|
||||
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
|
||||
import { Type } from "class-transformer";
|
||||
import { IsBoolean, IsEnum, IsInt, IsOptional, IsString, Min } from "class-validator";
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
IsEnum,
|
||||
IsInt,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Min,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
|
||||
import type { Location_2024_06_14, BookingField_2024_06_14 } from "../inputs";
|
||||
import { Host } from "../inputs";
|
||||
import { RecurringEvent_2024_06_14 } from "../inputs";
|
||||
import { ValidateBookingFields_2024_06_14 } from "../inputs/booking-fields.input";
|
||||
import { ValidateLocations_2024_06_14 } from "../inputs/locations.input";
|
||||
@@ -135,3 +145,107 @@ export class EventTypeOutput_2024_06_14 {
|
||||
|
||||
schedule!: Schedule_2024_06_14 | null;
|
||||
}
|
||||
|
||||
export class TeamEventTypeOutput_2024_06_14 {
|
||||
@IsInt()
|
||||
@DocsProperty({ example: 1 })
|
||||
id!: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
lengthInMinutes!: number;
|
||||
|
||||
@IsString()
|
||||
title!: string;
|
||||
|
||||
@IsString()
|
||||
slug!: string;
|
||||
|
||||
@IsString()
|
||||
description!: string;
|
||||
|
||||
@ValidateLocations_2024_06_14()
|
||||
locations!: Location_2024_06_14[];
|
||||
|
||||
@ValidateBookingFields_2024_06_14()
|
||||
bookingFields!: BookingField_2024_06_14[];
|
||||
|
||||
@IsBoolean()
|
||||
disableGuests!: boolean;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
slotInterval?: number | null;
|
||||
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@IsOptional()
|
||||
minimumBookingNotice?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
beforeEventBuffer?: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
afterEventBuffer?: number;
|
||||
|
||||
@IsEnum(SchedulingTypeEnum)
|
||||
schedulingType!: SchedulingType | null;
|
||||
|
||||
@Type(() => RecurringEvent_2024_06_14)
|
||||
recurringEvent!: RecurringEvent_2024_06_14 | null;
|
||||
|
||||
@Type(() => Object)
|
||||
metadata!: Record<string, unknown>;
|
||||
|
||||
@IsBoolean()
|
||||
requiresConfirmation!: boolean;
|
||||
|
||||
@IsInt()
|
||||
price!: number;
|
||||
|
||||
@IsString()
|
||||
currency!: string;
|
||||
|
||||
@IsBoolean()
|
||||
lockTimeZoneToggleOnBookingPage!: boolean;
|
||||
|
||||
@IsInt()
|
||||
seatsPerTimeSlot!: number | null;
|
||||
|
||||
@IsBoolean()
|
||||
forwardParamsSuccessRedirect!: boolean | null;
|
||||
|
||||
@IsString()
|
||||
successRedirectUrl!: string | null;
|
||||
|
||||
@IsBoolean()
|
||||
seatsShowAvailabilityCount!: boolean | null;
|
||||
|
||||
@IsBoolean()
|
||||
isInstantEvent!: boolean;
|
||||
|
||||
schedule!: Schedule_2024_06_14 | null;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
teamId?: number | null;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
ownerId?: number | null;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
parentEventTypeId?: number | null;
|
||||
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => Host)
|
||||
@IsArray()
|
||||
hosts!: Host[];
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
assignAllTeamMembers?: boolean;
|
||||
}
|
||||
Reference in new issue
Block a user