refactor: added ApiPropertyOptional decorator for optional fields in api for better documentation (#18208)

* update decorators 1

* update decorators 2

* update decorators 3

* update decorators 4

* update decorators 4

* update decorators 6

* update decorators 7

* added documentation,json and openapi.json

* implemented feedback

* remove default values from update dto's

* update

* removed default from redirectUris
This commit is contained in:
Somay Chauhan authored and GitHub committed 2024-12-17 10:29:07 +00:00
1 parent 5fad7c9478
commit a613c975d3
68 files changed
+1506 -614

No files matched your search

@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Type, Transform } from "class-transformer";
import {
ValidateNested,
@@ -26,25 +26,30 @@ class Filters {
@IsOptional()
@IsArray()
@Type(() => Number)
@ApiPropertyOptional({ type: [Number] })
teamsIds?: number[];
@IsOptional()
@IsArray()
@Type(() => Number)
@ApiPropertyOptional({ type: [Number] })
userIds?: number[];
@IsEnum(Status_2024_04_15)
@ApiProperty({ enum: Status_2024_04_15 })
status!: BookingStatus;
@IsOptional()
@IsArray()
@Type(() => Number)
@ApiPropertyOptional({ type: [Number] })
eventTypeIds?: number[];
}
export class GetBookingsInput_2024_04_15 {
@ValidateNested({ each: true })
@Type(() => Filters)
@ApiProperty({ type: Filters })
filters!: Filters;
@Transform(({ value }: { value: string }) => value && parseInt(value))
@@ -52,37 +57,45 @@ export class GetBookingsInput_2024_04_15 {
@Min(1)
@Max(100)
@IsOptional()
@ApiPropertyOptional({ description: "Maximum number of bookings to retrieve.", example: 50 })
limit?: number;
@Transform(({ value }: { value: string }) => value && parseInt(value))
@IsNumber()
@IsOptional()
@ApiPropertyOptional({ description: "Cursor for pagination.", example: 10, nullable: true })
cursor?: number | null;
}
export class CancelBookingInput_2024_04_15 {
@IsNumber()
@IsOptional()
@ApiProperty()
@ApiPropertyOptional({ description: "Booking ID to cancel.", example: 123 })
id?: number;
@IsString()
@IsOptional()
@ApiProperty()
@ApiPropertyOptional()
uid?: string;
@IsBoolean()
@IsOptional()
@ApiProperty()
@ApiPropertyOptional({
example: true,
})
allRemainingBookings?: boolean;
@IsString()
@IsOptional()
@ApiProperty()
@ApiPropertyOptional({
type: String,
description: "Reason for cancellation.",
example: "Scheduling conflict",
})
cancellationReason?: string;
@IsString()
@IsOptional()
@ApiProperty()
@ApiPropertyOptional()
seatReferenceUid?: string;
}
@@ -1,17 +1,17 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsBoolean, IsOptional, IsString } from "class-validator";
export class CancelBookingInput_2024_08_13 {
@IsString()
@IsOptional()
@ApiProperty({ example: "User requested cancellation" })
@ApiPropertyOptional({ example: "User requested cancellation" })
cancellationReason?: string;
@IsBoolean()
@IsOptional()
@ApiProperty({
@ApiPropertyOptional({
description:
"For recurring non-seated booking - if true, cancel booking with the bookingUid of the individual recorrence and all recurrences that come after it.",
"For recurring non-seated booking - if true, cancel booking with the bookingUid of the individual recurrence and all recurrences that come after it.",
})
cancelSubsequentBookings?: boolean;
}
@@ -20,7 +20,7 @@ export class CancelSeatedBookingInput_2024_08_13 {
@ApiProperty({
type: String,
example: "3be561a9-31f1-4b8e-aefc-9d9a085f0dd1",
description: "Uid of the specific seat withing booking.",
description: "Uid of the specific seat within booking.",
})
@IsString()
seatUid!: string;
@@ -68,7 +68,7 @@ export class CreateBookingInput_2024_08_13 {
@IsOptional()
@IsInt()
@Min(1)
@ApiProperty({
@ApiPropertyOptional({
example: 30,
description: `If it is an event type that has multiple possible lengths that attendee can pick from, you can pass the desired booking length here.
If not provided then event type default length will be used for the booking.`,
@@ -1,12 +1,11 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { IsOptional, IsString } from "class-validator";
export class DeclineBookingInput_2024_08_13 {
@IsString()
@IsOptional()
@ApiProperty({
@ApiPropertyOptional({
example: "Host has to take another call",
required: false,
description: "Reason for declining a booking that requires a confirmation",
})
reason?: string;
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsOptional, IsBoolean, IsEmail, IsArray, ArrayMinSize, ValidateNested } from "class-validator";
@@ -15,18 +15,14 @@ class Attendee {
export class MarkAbsentBookingInput_2024_08_13 {
@IsBoolean()
@IsOptional()
@ApiProperty({ example: false, required: false, description: "Whether the host was absent" })
@ApiPropertyOptional({ example: false, description: "Whether the host was absent" })
host?: boolean;
@ArrayMinSize(1)
@ApiProperty({
type: [String],
description: "Toggle whether an attendee was absent or not.",
example: [{ absent: true, email: "[email protected]" }],
})
@ValidateNested()
@Type(() => Attendee)
@IsArray()
@ValidateNested({ each: true })
@Type(() => Attendee)
@IsOptional()
@ApiPropertyOptional({ type: [Attendee] })
attendees?: Attendee[];
}
@@ -1,12 +1,11 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { IsOptional, IsString } from "class-validator";
export class ReassignToUserBookingInput_2024_08_13 {
@IsString()
@IsOptional()
@ApiProperty({
@ApiPropertyOptional({
example: "Host has to take another call",
required: false,
description: "Reason for reassigning the booking",
})
reason?: string;
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsDateString, IsOptional, IsString } from "class-validator";
export class RescheduleBookingInput_2024_08_13 {
@@ -11,10 +11,9 @@ export class RescheduleBookingInput_2024_08_13 {
@IsString()
@IsOptional()
@ApiProperty({
@ApiPropertyOptional({
example: "User requested reschedule",
description: "Reason for rescheduling the booking",
required: false,
})
reschedulingReason?: string;
}
@@ -30,7 +29,7 @@ export class RescheduleSeatedBookingInput_2024_08_13 {
@ApiProperty({
type: String,
example: "3be561a9-31f1-4b8e-aefc-9d9a085f0dd1",
description: "Uid of the specific seat withing booking.",
description: "Uid of the specific seat within booking.",
})
@IsString()
seatUid!: string;
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Expose, Type } from "class-transformer";
import {
IsArray,
@@ -34,7 +34,7 @@ class Attendee {
@Expose()
timeZone!: string;
@ApiProperty({ enum: BookingLanguage, required: false, example: "en" })
@ApiPropertyOptional({ enum: BookingLanguage, example: "en" })
@IsEnum(BookingLanguage)
@Expose()
@IsOptional()
@@ -57,16 +57,15 @@ export class SeatedAttendee extends Attendee {
description:
"Booking field responses consisting of an object with booking field slug as keys and user response as values.",
example: { customField: "customValue" },
required: false,
required: true,
})
@IsObject()
@Expose()
bookingFieldsResponses!: Record<string, unknown>;
@ApiProperty({
@ApiPropertyOptional({
type: Object,
example: { key: "value" },
required: false,
})
@IsObject()
@IsOptional()
@@ -140,19 +139,19 @@ class BaseBookingOutput_2024_08_13 {
@Expose()
status!: "cancelled" | "accepted" | "rejected" | "pending";
@ApiProperty({ type: String, required: false, example: "User requested cancellation" })
@ApiPropertyOptional({ type: String, example: "User requested cancellation" })
@IsString()
@IsOptional()
@Expose()
cancellationReason?: string;
@ApiProperty({ type: String, required: false, example: "User rescheduled the event" })
@ApiPropertyOptional({ type: String, example: "User rescheduled the event" })
@IsString()
@IsOptional()
@Expose()
reschedulingReason?: string;
@ApiProperty({ type: String, required: false, example: "previous_uid_123" })
@ApiPropertyOptional({ type: String, example: "previous_uid_123" })
@IsString()
@IsOptional()
@Expose()
@@ -188,9 +187,9 @@ class BaseBookingOutput_2024_08_13 {
@Expose()
eventType!: EventType;
@ApiProperty({
@ApiPropertyOptional({
type: String,
required: false,
description: "Deprecated - rely on 'location' field instead.",
example: "https://example.com/recurring-meeting",
deprecated: true,
@@ -200,8 +199,7 @@ class BaseBookingOutput_2024_08_13 {
@Expose()
meetingUrl?: string;
@ApiProperty({ type: String, required: false, example: "https://example.com/meeting" })
@IsOptional()
@ApiProperty({ type: String, example: "https://example.com/meeting" })
@Expose()
location!: string;
@@ -215,10 +213,9 @@ class BaseBookingOutput_2024_08_13 {
@Expose()
createdAt!: string;
@ApiProperty({
@ApiPropertyOptional({
type: Object,
example: { key: "value" },
required: false,
})
@IsObject()
@IsOptional()
@@ -233,7 +230,10 @@ export class BookingOutput_2024_08_13 extends BaseBookingOutput_2024_08_13 {
@Expose()
attendees!: Attendee[];
@ApiProperty({ type: [String], required: false, example: ["[email protected]", "[email protected]"] })
@ApiPropertyOptional({
type: [String],
example: ["[email protected]", "[email protected]"],
})
@IsArray()
@IsString({ each: true })
@IsOptional()
@@ -245,7 +245,6 @@ export class BookingOutput_2024_08_13 extends BaseBookingOutput_2024_08_13 {
description:
"Booking field responses consisting of an object with booking field slug as keys and user response as values.",
example: { customField: "customValue" },
required: false,
})
@IsObject()
@Expose()
@@ -263,7 +262,6 @@ export class RecurringBookingOutput_2024_08_13 extends BookingOutput_2024_08_13
description:
"Booking field responses consisting of an object with booking field slug as keys and user response as values.",
example: { customField: "customValue" },
required: false,
})
@IsObject()
@Expose()
+5
View File
@@ -8,9 +8,11 @@ import { IsYearMonthDays } from "./validators/isYearMonthDays";
export class Calendar {
@Transform(({ value }: { value: string }) => value && parseInt(value))
@IsNumber()
@ApiProperty()
credentialId!: number;
@IsString()
@ApiProperty()
externalId!: string;
}
@@ -27,6 +29,7 @@ export class CalendarBusyTimesInput {
required: false,
description: "The starting date for the busy times query",
example: "2023-10-01",
nullable: true,
})
@IsString()
@IsOptional()
@@ -37,6 +40,7 @@ export class CalendarBusyTimesInput {
required: false,
description: "The ending date for the busy times query",
example: "2023-10-31",
nullable: true,
})
@IsString()
@IsOptional()
@@ -44,6 +48,7 @@ export class CalendarBusyTimesInput {
dateTo?: string | null;
@ApiProperty({
type: [Calendar],
required: true,
description: "An array of Calendar objects representing the calendars to be loaded",
example: `[{ credentialId: "1", externalId: "AQgtJE7RnHEeyisVq2ENs2gAAAgEGAAAACgtJE7RnHEeyisVq2ENs2gAAAhSDAAAA" }, { credentialId: "2", externalId: "AQM7RnHEeyisVq2ENs2gAAAhFDBBBBB" }]`,
@@ -49,6 +49,7 @@ export class BaseBookingLimitsCount_2024_06_14 {
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean, default: false })
disabled?: boolean = false;
}
@@ -60,6 +61,7 @@ class BookingLimitsCountValidator implements ValidatorConstraintInterface {
invalidLimit?: string;
comparedLimit?: string;
} = {};
validate(value: BookingLimitsCount_2024_06_14) {
if (!value) return false;
if ("disabled" in value) {
@@ -101,10 +103,10 @@ class BookingLimitsCountValidator implements ValidatorConstraintInterface {
}
}
export function ValidateBookingLimistsCount(validationOptions?: ValidationOptions) {
export function ValidateBookingLimitsCount(validationOptions?: ValidationOptions) {
return function (object: any, propertyName: string) {
registerDecorator({
name: "ValidateBookingLimistsCount",
name: "ValidateBookingLimitsCount",
target: object.constructor,
propertyName: propertyName,
options: validationOptions,
@@ -38,7 +38,7 @@ import {
import type { InputBookingField_2024_06_14 } from "./booking-fields.input";
import { ValidateInputBookingFields_2024_06_14 } from "./booking-fields.input";
import type { BookingLimitsCount_2024_06_14 } from "./booking-limits-count.input";
import { BaseBookingLimitsCount_2024_06_14, ValidateBookingLimistsCount } from "./booking-limits-count.input";
import { BaseBookingLimitsCount_2024_06_14, ValidateBookingLimitsCount } from "./booking-limits-count.input";
import type { BookingLimitsDuration_2024_06_14 } from "./booking-limits-duration.input";
import {
BaseBookingLimitsDuration_2024_06_14,
@@ -226,7 +226,7 @@ export class CreateEventTypeInput_2024_06_14 {
scheduleId?: number;
@IsOptional()
@ValidateBookingLimistsCount()
@ValidateBookingLimitsCount()
@DocsPropertyOptional({
description: "Limit how many times this event can be booked",
oneOf: [
@@ -35,7 +35,7 @@ import {
ValidateInputBookingFields_2024_06_14,
} from "./booking-fields.input";
import type { BookingLimitsCount_2024_06_14 } from "./booking-limits-count.input";
import { BaseBookingLimitsCount_2024_06_14, ValidateBookingLimistsCount } from "./booking-limits-count.input";
import { BaseBookingLimitsCount_2024_06_14, ValidateBookingLimitsCount } from "./booking-limits-count.input";
import type { BookingLimitsDuration_2024_06_14 } from "./booking-limits-duration.input";
import {
BaseBookingLimitsDuration_2024_06_14,
@@ -227,7 +227,7 @@ export class UpdateEventTypeInput_2024_06_14 {
scheduleId?: number;
@IsOptional()
@ValidateBookingLimistsCount()
@ValidateBookingLimitsCount()
@DocsPropertyOptional({
description: "Limit how many times this event can be booked",
oneOf: [
@@ -1,4 +1,9 @@
import { ApiProperty as DocsProperty, ApiExtraModels, getSchemaPath } from "@nestjs/swagger";
import {
ApiProperty as DocsProperty,
ApiPropertyOptional,
ApiExtraModels,
getSchemaPath,
} from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
ArrayNotEmpty,
@@ -71,27 +76,35 @@ export type EventTypesOutputSchedulingType = "ROUND_ROBIN" | "COLLECTIVE" | "MAN
class User_2024_06_14 {
@IsInt()
@DocsProperty()
id!: number;
@IsString()
@DocsProperty({ nullable: true })
name!: string | null;
@IsString()
@DocsProperty({ nullable: true, type: String })
username!: string | null;
@IsString()
@DocsProperty({ nullable: true, type: String })
avatarUrl!: string | null;
@IsString()
@DocsProperty({ type: String })
weekStart!: string;
@IsString()
@DocsProperty({ type: String, nullable: true })
brandColor!: string | null;
@IsString()
@DocsProperty({ type: String, nullable: true })
darkBrandColor!: string | null;
@Type(() => Object)
@DocsProperty({ type: Object })
metadata!: Record<string, unknown>;
}
@@ -141,7 +154,8 @@ class BaseEventTypeOutput_2024_06_14 {
@ArrayUnique()
@IsInt({ each: true })
@Min(1, { each: true })
@DocsProperty({
@ApiPropertyOptional({
type: [Number],
example: [15, 30, 60],
description:
"If you want that user can choose between different lengths of the event you can specify them here. Must include the provided `lengthInMinutes`.",
@@ -164,6 +178,7 @@ class BaseEventTypeOutput_2024_06_14 {
@ValidateOutputLocations_2024_06_14()
@DocsProperty({
required: true,
oneOf: [
{ $ref: getSchemaPath(OutputAddressLocation_2024_06_14) },
{ $ref: getSchemaPath(OutputLinkLocation_2024_06_14) },
@@ -180,6 +195,7 @@ class BaseEventTypeOutput_2024_06_14 {
@ValidateOutputBookingFields_2024_06_14()
@DocsProperty()
@DocsProperty({
required: true,
oneOf: [
{ $ref: getSchemaPath(NameDefaultFieldOutput_2024_06_14) },
{ $ref: getSchemaPath(EmailDefaultFieldOutput_2024_06_14) },
@@ -211,31 +227,38 @@ class BaseEventTypeOutput_2024_06_14 {
@IsInt()
@IsOptional()
@DocsProperty({ example: 60, type: Number })
@ApiPropertyOptional({ example: 60, nullable: true })
slotInterval?: number | null;
@IsOptional()
@IsInt()
@Min(0)
@IsOptional()
@DocsProperty({ example: 0 })
@ApiPropertyOptional({ example: 0 })
minimumBookingNotice?: number;
@IsInt()
@IsOptional()
@DocsProperty({ example: 0 })
@IsInt()
@Min(0)
@ApiPropertyOptional({ example: 0 })
beforeEventBuffer?: number;
@IsInt()
@IsOptional()
@DocsProperty({ example: 0 })
@IsInt()
@Min(0)
@ApiPropertyOptional({ example: 0 })
afterEventBuffer?: number;
@Type(() => Recurrence_2024_06_14)
@DocsProperty()
@DocsProperty({
type: Recurrence_2024_06_14,
nullable: true,
})
recurrence!: Recurrence_2024_06_14 | null;
@Type(() => Object)
@DocsProperty()
@DocsProperty({
type: Object,
})
metadata!: Record<string, unknown>;
@IsInt()
@@ -251,16 +274,16 @@ class BaseEventTypeOutput_2024_06_14 {
lockTimeZoneToggleOnBookingPage!: boolean;
@IsInt()
@DocsProperty()
@ApiPropertyOptional({ nullable: true })
@IsOptional()
seatsPerTimeSlot?: number | null;
@IsBoolean()
@DocsProperty()
@DocsProperty({ nullable: true })
forwardParamsSuccessRedirect!: boolean | null;
@IsString()
@DocsProperty()
@DocsProperty({ nullable: true })
successRedirectUrl!: string | null;
@IsBoolean()
@@ -269,28 +292,28 @@ class BaseEventTypeOutput_2024_06_14 {
@IsOptional()
@IsBoolean()
@DocsProperty()
@ApiPropertyOptional({ type: Boolean, nullable: true })
seatsShowAvailabilityCount?: boolean | null;
@IsInt()
@DocsProperty()
@DocsProperty({ type: Number, nullable: true })
scheduleId!: number | null;
@IsOptional()
@DocsProperty()
@ApiPropertyOptional()
bookingLimitsCount?: BookingLimitsCount_2024_06_14;
@IsOptional()
@IsBoolean()
@DocsProperty()
@ApiPropertyOptional()
onlyShowFirstAvailableSlot?: boolean;
@IsOptional()
@DocsProperty()
@ApiPropertyOptional()
bookingLimitsDuration?: BookingLimitsDuration_2024_06_14;
@IsOptional()
@DocsProperty({
@ApiPropertyOptional({
description: "Limit how far in the future this event can be booked",
oneOf: [
{ $ref: getSchemaPath(BusinessDaysWindow_2024_06_14) },
@@ -304,57 +327,57 @@ class BaseEventTypeOutput_2024_06_14 {
@IsOptional()
@Type(() => BookerLayouts_2024_06_14)
@DocsProperty()
@ApiPropertyOptional()
bookerLayouts?: BookerLayouts_2024_06_14;
@IsOptional()
@DocsProperty()
@ApiPropertyOptional()
confirmationPolicy?: ConfirmationPolicy_2024_06_14;
@IsOptional()
@IsBoolean()
@DocsProperty()
@ApiPropertyOptional()
requiresBookerEmailVerification?: boolean;
@IsOptional()
@IsBoolean()
@DocsProperty()
@ApiPropertyOptional()
hideCalendarNotes?: boolean;
@IsOptional()
@Type(() => EventTypeColor_2024_06_14)
@DocsProperty()
@ApiPropertyOptional({ type: EventTypeColor_2024_06_14 })
color?: EventTypeColor_2024_06_14;
@IsOptional()
@Type(() => Seats_2024_06_14)
@DocsProperty()
@ApiPropertyOptional({ type: Seats_2024_06_14 })
seats?: Seats_2024_06_14;
@IsOptional()
@IsInt()
@Min(1)
@DocsProperty()
@ApiPropertyOptional()
offsetStart?: number;
@IsOptional()
@IsString()
@DocsProperty()
@ApiPropertyOptional()
customName?: string;
@IsOptional()
@Type(() => DestinationCalendar_2024_06_14)
@DocsProperty()
@ApiPropertyOptional({ type: DestinationCalendar_2024_06_14 })
destinationCalendar?: DestinationCalendar_2024_06_14;
@IsOptional()
@IsBoolean()
@DocsProperty()
@ApiPropertyOptional()
useDestinationCalendarEmail?: boolean;
@IsOptional()
@IsBoolean()
@DocsProperty()
@ApiPropertyOptional()
hideCalendarEventDetails?: boolean;
}
@@ -365,7 +388,10 @@ export class TeamEventTypeResponseHost extends TeamEventTypeHostInput {
@IsString()
@IsOptional()
@DocsProperty({ example: "https://cal.com/api/avatar/d95949bc-ccb1-400f-acf6-045c51a16856.png" })
@ApiPropertyOptional({
example: "https://cal.com/api/avatar/d95949bc-ccb1-400f-acf6-045c51a16856.png",
nullable: true,
})
avatarUrl?: string | null;
}
@@ -383,19 +409,20 @@ export class EventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_14 {
export class TeamEventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_14 {
@IsInt()
@IsOptional()
@DocsProperty()
@ApiPropertyOptional({ nullable: true })
teamId?: number | null;
@IsInt()
@IsOptional()
@DocsProperty()
@ApiPropertyOptional({ nullable: true })
ownerId?: number | null;
@IsInt()
@IsOptional()
@DocsProperty({
@ApiPropertyOptional({
description:
"For managed event types, parent event type is the event type that this event type is based on",
nullable: true,
})
parentEventTypeId?: number | null;
@@ -407,20 +434,20 @@ export class TeamEventTypeOutput_2024_06_14 extends BaseEventTypeOutput_2024_06_
@IsBoolean()
@IsOptional()
@DocsProperty()
@ApiPropertyOptional()
assignAllTeamMembers?: boolean;
@IsEnum(SchedulingTypeEnum)
@DocsProperty({ enum: SchedulingTypeEnum })
@DocsProperty({ enum: SchedulingTypeEnum, nullable: true })
schedulingType!: EventTypesOutputSchedulingType | null;
@IsOptional()
@IsBoolean()
@DocsProperty()
@ApiPropertyOptional()
hideCalendarEventDetails?: boolean;
@IsString()
@IsOptional()
@DocsProperty()
@ApiPropertyOptional()
bannerUrl?: string;
}
@@ -1,5 +1,5 @@
import { BadRequestException } from "@nestjs/common";
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
import { ApiPropertyOptional, ApiProperty as DocsProperty } from "@nestjs/swagger";
import { plainToInstance } from "class-transformer";
import { IsUrl, IsIn, IsOptional, IsNumber, IsString } from "class-validator";
import type { ValidationOptions, ValidatorConstraintInterface } from "class-validator";
@@ -61,19 +61,29 @@ export type OutputIntegration_2024_06_14 = (typeof integrationsValues)[number];
export class OutputIntegrationLocation_2024_06_14 {
@IsIn(outputLocations)
@DocsProperty({ example: "integration", description: "only allowed value for type is `integration`" })
@DocsProperty({
example: "integration",
description: "Only allowed value for type is `integration`",
})
type!: "integration";
@IsIn(integrationsValues)
@DocsProperty({ example: integrationsValues[0], enum: integrationsValues })
integration!: OutputIntegration_2024_06_14;
@IsUrl()
@IsOptional()
@IsUrl()
@ApiPropertyOptional({
type: String,
example: "https://example.com",
})
link?: string;
@IsNumber()
@IsOptional()
@IsNumber()
@ApiPropertyOptional({
description: "Credential ID associated with the integration",
})
credentialId?: number;
}
@@ -89,6 +99,7 @@ export class OutputUnknownLocation_2024_06_14 {
type!: "unknown";
@IsString()
@DocsProperty()
location!: string;
}
+10
View File
@@ -1,40 +1,50 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsArray, IsNumber, IsOptional, IsBoolean, IsString } from "class-validator";
import { z } from "zod";
export class CreateOAuthClientInput {
@IsOptional()
@IsString()
@ApiPropertyOptional()
logo?: string;
@IsString()
@ApiProperty()
name!: string;
@IsArray()
@IsString({ each: true })
@ApiProperty({ type: [String] })
redirectUris!: string[];
@IsNumber()
@ApiProperty()
permissions!: number;
@IsOptional()
@IsString()
@ApiPropertyOptional()
bookingRedirectUri?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
bookingCancelRedirectUri?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
bookingRescheduleRedirectUri?: string;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional()
areEmailsEnabled?: boolean;
}
export class DeleteOAuthClientInput {
@IsString()
@ApiProperty()
id!: string;
}
@@ -1,107 +1,129 @@
import { ApiProperty as DocsProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Expose } from "class-transformer";
import { IsBoolean, IsInt, IsOptional, IsString, IsUrl, Length } from "class-validator";
export class OrgTeamOutputDto {
@IsInt()
@Expose()
@DocsProperty()
readonly id!: number;
@IsInt()
@IsOptional()
@Expose()
@ApiPropertyOptional()
readonly parentId?: number;
@IsString()
@Length(1)
@Expose()
@DocsProperty()
readonly name!: string;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly slug?: string;
@IsOptional()
@IsUrl()
@Expose()
@ApiPropertyOptional()
readonly logoUrl?: string;
@IsOptional()
@IsUrl()
@Expose()
@ApiPropertyOptional()
readonly calVideoLogo?: string;
@IsOptional()
@IsUrl()
@Expose()
@ApiPropertyOptional()
readonly appLogo?: string;
@IsOptional()
@IsUrl()
@Expose()
@ApiPropertyOptional()
readonly appIconLogo?: string;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly bio?: string;
@IsOptional()
@IsBoolean()
@Expose()
@ApiPropertyOptional()
readonly hideBranding?: boolean;
@IsBoolean()
@Expose()
readonly isOrganization?: boolean;
@DocsProperty()
readonly isOrganization!: boolean;
@IsOptional()
@IsBoolean()
@Expose()
@ApiPropertyOptional()
readonly isPrivate?: boolean;
@IsOptional()
@IsBoolean()
@Expose()
@ApiPropertyOptional()
readonly hideBookATeamMember?: boolean = false;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly metadata?: string;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly theme?: string;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly brandColor?: string;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly darkBrandColor?: string;
@IsOptional()
@IsUrl()
@Expose()
@ApiPropertyOptional()
readonly bannerUrl?: string;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly timeFormat?: number;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional({ type: String, default: "Europe/London" })
readonly timeZone?: string = "Europe/London";
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional({ type: String, default: "Sunday" })
readonly weekStart?: string = "Sunday";
}
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
IsBoolean,
@@ -19,6 +19,7 @@ export class ScheduleAvailabilityInput_2024_06_11 {
@IsArray()
@IsIn(WEEK_DAYS, { each: true })
@ApiProperty({
type: [String],
example: ["Monday", "Tuesday"],
description: "Array of days when schedule is active.",
enum: WEEK_DAYS,
@@ -27,38 +28,56 @@ export class ScheduleAvailabilityInput_2024_06_11 {
@IsString()
@Matches(TIME_FORMAT_HH_MM, { message: "startTime must be a valid time format HH:MM" })
@ApiProperty({ example: "08:00", description: "startTime must be a valid time in format HH:MM e.g. 08:00" })
@ApiProperty({
example: "08:00",
description: "startTime must be a valid time in format HH:MM e.g. 08:00",
})
startTime!: string;
@IsString()
@Matches(TIME_FORMAT_HH_MM, { message: "endTime must be a valid time format HH:MM" })
@ApiProperty({ example: "15:00", description: "endTime must be a valid time in format HH:MM e.g. 15:00" })
@ApiProperty({
example: "15:00",
description: "endTime must be a valid time in format HH:MM e.g. 15:00",
})
endTime!: string;
}
export class ScheduleOverrideInput_2024_06_11 {
@IsISO8601({ strict: true })
@ApiProperty({ example: "2024-05-20" })
@ApiProperty({
example: "2024-05-20",
})
date!: string;
@IsString()
@Matches(TIME_FORMAT_HH_MM, { message: "startTime must be a valid time format HH:MM" })
@ApiProperty({ example: "12:00", description: "startTime must be a valid time in format HH:MM e.g. 12:00" })
@ApiProperty({
example: "12:00",
description: "startTime must be a valid time in format HH:MM e.g. 12:00",
})
startTime!: string;
@IsString()
@Matches(TIME_FORMAT_HH_MM, { message: "endTime must be a valid time format HH:MM" })
@ApiProperty({ example: "13:00", description: "endTime must be a valid time in format HH:MM e.g. 13:00" })
@ApiProperty({
example: "13:00",
description: "endTime must be a valid time in format HH:MM e.g. 13:00",
})
endTime!: string;
}
export class CreateScheduleInput_2024_06_11 {
@IsString()
@ApiProperty({ example: "Catch up hours" })
@ApiProperty({
type: String,
example: "Catch up hours",
})
name!: string;
@IsTimeZone()
@ApiProperty({
type: String,
example: "Europe/Rome",
description: "Timezone is used to calculate available times when an event using the schedule is booked.",
})
@@ -68,7 +87,7 @@ export class CreateScheduleInput_2024_06_11 {
@IsOptional()
@ValidateNested({ each: true })
@Type(() => ScheduleAvailabilityInput_2024_06_11)
@ApiProperty({
@ApiPropertyOptional({
type: [ScheduleAvailabilityInput_2024_06_11],
description:
"Each object contains days and times when the user is available. If not passed, the default availability is Monday to Friday from 09:00 to 17:00.",
@@ -84,12 +103,12 @@ export class CreateScheduleInput_2024_06_11 {
endTime: "20:00",
},
],
required: false,
})
availability?: ScheduleAvailabilityInput_2024_06_11[];
@IsBoolean()
@ApiProperty({
type: Boolean,
example: true,
description: `Each user should have 1 default schedule. If you specified \`timeZone\` when creating managed user, then the default schedule will be created with that timezone.
Default schedule means that if an event type is not tied to a specific schedule then the default schedule is used.`,
@@ -100,7 +119,7 @@ export class CreateScheduleInput_2024_06_11 {
@IsOptional()
@ValidateNested({ each: true })
@Type(() => ScheduleOverrideInput_2024_06_11)
@ApiProperty({
@ApiPropertyOptional({
type: [ScheduleOverrideInput_2024_06_11],
description: "Need to change availability for a specific date? Add an override.",
example: [
@@ -110,7 +129,6 @@ export class CreateScheduleInput_2024_06_11 {
endTime: "21:00",
},
],
required: false,
})
overrides?: ScheduleOverrideInput_2024_06_11[];
}
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsString, IsBoolean, IsOptional, ValidateNested, IsArray, IsTimeZone } from "class-validator";
@@ -10,19 +10,19 @@ import {
export class UpdateScheduleInput_2024_06_11 {
@IsString()
@IsOptional()
@ApiProperty({ example: "One-on-one coaching", required: false })
@ApiPropertyOptional({ type: String, example: "One-on-one coaching" })
name?: string;
@IsTimeZone()
@IsOptional()
@ApiProperty({ example: "Europe/Rome", required: false })
@ApiPropertyOptional({ type: String, example: "Europe/Rome" })
timeZone?: string;
@IsArray()
@IsOptional()
@ValidateNested({ each: true })
@Type(() => ScheduleAvailabilityInput_2024_06_11)
@ApiProperty({
@ApiPropertyOptional({
type: [ScheduleAvailabilityInput_2024_06_11],
example: [
{
@@ -31,20 +31,19 @@ export class UpdateScheduleInput_2024_06_11 {
endTime: "10:00",
},
],
required: false,
})
availability?: ScheduleAvailabilityInput_2024_06_11[];
@IsBoolean()
@IsOptional()
@ApiProperty({ example: true, required: false })
@ApiPropertyOptional({ type: Boolean, example: true })
isDefault?: boolean;
@IsArray()
@IsOptional()
@ValidateNested({ each: true })
@Type(() => ScheduleOverrideInput_2024_06_11)
@ApiProperty({
@ApiPropertyOptional({
type: [ScheduleOverrideInput_2024_06_11],
example: [
{
@@ -53,7 +52,6 @@ export class UpdateScheduleInput_2024_06_11 {
endTime: "14:00",
},
],
required: false,
})
overrides?: ScheduleOverrideInput_2024_06_11[];
}
@@ -1,14 +1,6 @@
import { ApiProperty } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
IsBoolean,
IsOptional,
IsString,
ValidateNested,
IsArray,
IsTimeZone,
IsNumber,
} from "class-validator";
import { IsBoolean, IsString, ValidateNested, IsArray, IsTimeZone, IsNumber } from "class-validator";
import {
ScheduleAvailabilityInput_2024_06_11,
@@ -57,7 +49,6 @@ export class ScheduleOutput_2024_06_11 {
isDefault!: boolean;
@IsArray()
@IsOptional()
@ValidateNested({ each: true })
@Type(() => ScheduleOverrideInput_2024_06_11)
@ApiProperty({
+9 -4
View File
@@ -32,43 +32,48 @@ export class GetAvailableSlotsInput {
@Transform(({ value }: { value: string }) => value && parseInt(value))
@IsNumber()
@IsOptional()
@ApiProperty({ description: "Event Type ID for which slots are being fetched.", example: 100 })
@ApiPropertyOptional({ description: "Event Type ID for which slots are being fetched.", example: 100 })
eventTypeId?: number;
@IsString()
@IsOptional()
@ApiProperty({ description: "Slug of the event type for which slots are being fetched." })
@ApiPropertyOptional({ description: "Slug of the event type for which slots are being fetched." })
eventTypeSlug?: string;
@IsArray()
@IsString({ each: true })
@IsOptional()
@ApiProperty({
@ApiPropertyOptional({
type: [String],
description: "Only for dynamic events - list of usernames for which slots are being fetched.",
})
usernameList?: string[];
@IsBoolean()
@IsOptional()
@ApiPropertyOptional()
debug?: boolean;
@Transform(({ value }: { value: string }) => value && parseInt(value))
@IsNumber()
@IsOptional()
@Min(1, { message: "Duration must be a positive number" })
@ApiProperty({ description: "Only for dynamic events - length of returned slots." })
@ApiPropertyOptional({ description: "Only for dynamic events - length of returned slots." })
duration?: number;
@IsOptional()
@IsString()
@ApiPropertyOptional({ type: String, nullable: true })
rescheduleUid?: string | null;
@IsString()
@IsOptional()
@ApiPropertyOptional()
timeZone?: string;
@IsString()
@IsOptional()
@ApiPropertyOptional({ description: "Organization slug." })
orgSlug?: string;
@IsString()