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 <[email protected]>
This commit is contained in:
1 parent
84a2e55125
commit
8784be067f
2 files changed
+24
No files matched your search
@@ -1,9 +1,12 @@
|
|||||||
|
import { ApiProperty } from "@nestjs/swagger";
|
||||||
import { Type } from "class-transformer";
|
import { Type } from "class-transformer";
|
||||||
|
import { Transform } from "class-transformer";
|
||||||
import { IsNumber, IsString, IsOptional, IsArray, ValidateNested, Validate } from "class-validator";
|
import { IsNumber, IsString, IsOptional, IsArray, ValidateNested, Validate } from "class-validator";
|
||||||
|
|
||||||
import { IsYearMonthDays } from "./validators/isYearMonthDays";
|
import { IsYearMonthDays } from "./validators/isYearMonthDays";
|
||||||
|
|
||||||
export class Calendar {
|
export class Calendar {
|
||||||
|
@Transform(({ value }: { value: string }) => value && parseInt(value))
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
credentialId!: number;
|
credentialId!: number;
|
||||||
|
|
||||||
@@ -12,19 +15,39 @@ export class Calendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class CalendarBusyTimesInput {
|
export class CalendarBusyTimesInput {
|
||||||
|
@ApiProperty({
|
||||||
|
required: true,
|
||||||
|
description: "The timezone of the logged in user represented as a string",
|
||||||
|
example: "America/New_York",
|
||||||
|
})
|
||||||
@IsString()
|
@IsString()
|
||||||
loggedInUsersTz!: string;
|
loggedInUsersTz!: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
required: false,
|
||||||
|
description: "The starting date for the busy times query",
|
||||||
|
example: "2023-10-01",
|
||||||
|
})
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Validate(IsYearMonthDays)
|
@Validate(IsYearMonthDays)
|
||||||
dateFrom?: string | null;
|
dateFrom?: string | null;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
required: false,
|
||||||
|
description: "The ending date for the busy times query",
|
||||||
|
example: "2023-10-31",
|
||||||
|
})
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Validate(IsYearMonthDays)
|
@Validate(IsYearMonthDays)
|
||||||
dateTo?: string | null;
|
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()
|
@IsArray()
|
||||||
@ValidateNested({ each: true })
|
@ValidateNested({ each: true })
|
||||||
@Type(() => Calendar)
|
@Type(() => Calendar)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"@calcom/platform-constants": "*",
|
"@calcom/platform-constants": "*",
|
||||||
"@calcom/platform-enums": "*",
|
"@calcom/platform-enums": "*",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.14.0"
|
"class-validator": "^0.14.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user