chore: fix input DTOs for v2 calendar busy times endpoint (#16526)
* add class-transformer package to type * update input dtos for get busy times and fix type issue * fixup --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com>
This commit is contained in:
co-authored by
Keith Williams
parent
84a2e55125
commit
8784be067f
@@ -1,9 +1,12 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { Type } from "class-transformer";
|
||||
import { Transform } from "class-transformer";
|
||||
import { IsNumber, IsString, IsOptional, IsArray, ValidateNested, Validate } from "class-validator";
|
||||
|
||||
import { IsYearMonthDays } from "./validators/isYearMonthDays";
|
||||
|
||||
export class Calendar {
|
||||
@Transform(({ value }: { value: string }) => value && parseInt(value))
|
||||
@IsNumber()
|
||||
credentialId!: number;
|
||||
|
||||
@@ -12,19 +15,39 @@ export class Calendar {
|
||||
}
|
||||
|
||||
export class CalendarBusyTimesInput {
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: "The timezone of the logged in user represented as a string",
|
||||
example: "America/New_York",
|
||||
})
|
||||
@IsString()
|
||||
loggedInUsersTz!: string;
|
||||
|
||||
@ApiProperty({
|
||||
required: false,
|
||||
description: "The starting date for the busy times query",
|
||||
example: "2023-10-01",
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Validate(IsYearMonthDays)
|
||||
dateFrom?: string | null;
|
||||
|
||||
@ApiProperty({
|
||||
required: false,
|
||||
description: "The ending date for the busy times query",
|
||||
example: "2023-10-31",
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Validate(IsYearMonthDays)
|
||||
dateTo?: string | null;
|
||||
|
||||
@ApiProperty({
|
||||
required: true,
|
||||
description: "An array of Calendar objects representing the calendars to be loaded",
|
||||
example: `[{ credentialId: "1", externalId: "AQgtJE7RnHEeyisVq2ENs2gAAAgEGAAAACgtJE7RnHEeyisVq2ENs2gAAAhSDAAAA" }, { credentialId: "2", externalId: "AQM7RnHEeyisVq2ENs2gAAAhFDBBBBB" }]`,
|
||||
})
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => Calendar)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"@calcom/platform-constants": "*",
|
||||
"@calcom/platform-enums": "*",
|
||||
"@types/express": "^4.17.21",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user