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,10 +1,12 @@
import { Transform, Type } from "class-transformer";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { ArrayNotEmpty, IsArray, IsInt, IsNumber, IsOptional } from "class-validator";
export class EventTypesAppInput {
@Transform(({ value }: { value: string }) => value && parseInt(value))
@IsNumber()
@IsOptional()
@ApiPropertyOptional()
teamId?: number;
}
@@ -12,5 +14,6 @@ export class BulkUpdateEventTypeToDefaultLocationDto {
@IsArray()
@ArrayNotEmpty()
@IsInt({ each: true })
@ApiProperty({ type: [Number] })
eventTypeIds!: number[];
}
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Expose, Type } from "class-transformer";
import { IsString, ValidateNested, IsEnum, IsNumber, IsOptional, IsBoolean } from "class-validator";
@@ -20,7 +20,11 @@ export class ConferencingAppsOutputDto {
@IsNumber()
userId!: number;
@ApiProperty({ example: true, description: "Whether if the connection is working or not." })
@ApiPropertyOptional({
example: true,
description: "Whether if the connection is working or not.",
nullable: true,
})
@Expose()
@IsBoolean()
@IsOptional()
@@ -28,24 +32,26 @@ export class ConferencingAppsOutputDto {
}
export class ConferencingAppsOutputResponseDto {
@ApiProperty({ example: SUCCESS_STATUS, enum: [SUCCESS_STATUS, ERROR_STATUS] })
@ApiProperty({ type: String, enum: [SUCCESS_STATUS, ERROR_STATUS] })
@IsEnum([SUCCESS_STATUS, ERROR_STATUS])
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS;
@Expose()
@ValidateNested()
@ValidateNested({ each: true })
@Type(() => ConferencingAppsOutputDto)
@ApiProperty({ type: [ConferencingAppsOutputDto] })
data!: ConferencingAppsOutputDto[];
}
export class ConferencingAppOutputResponseDto {
@ApiProperty({ example: SUCCESS_STATUS, enum: [SUCCESS_STATUS, ERROR_STATUS] })
@ApiProperty({ type: String, enum: [SUCCESS_STATUS, ERROR_STATUS] })
@IsEnum([SUCCESS_STATUS, ERROR_STATUS])
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS;
@Expose()
@ValidateNested()
@Type(() => ConferencingAppsOutputDto)
@ApiProperty({ type: ConferencingAppsOutputDto })
data!: ConferencingAppsOutputDto;
}
@@ -10,10 +10,10 @@ export class ManagedUserOutput {
@ApiProperty({ example: "[email protected]" })
email!: string;
@ApiProperty({ example: "alice" })
@ApiProperty({ example: "alice", nullable: true })
username!: string | null;
@ApiProperty({ example: "alice" })
@ApiProperty({ example: "alice", nullable: true })
name!: string | null;
@ApiProperty({ example: "America/New_York" })
@@ -22,19 +22,19 @@ export class ManagedUserOutput {
@ApiProperty({ example: "Sunday" })
weekStart!: string;
@ApiProperty({ example: "2024-04-01T00:00:00.000Z", type: "string" })
@ApiProperty({ type: String, example: "2024-04-01T00:00:00.000Z" })
@Transform(({ value }) => value.toISOString())
createdDate!: Date;
@ApiProperty({ example: 12, nullable: true })
@ApiProperty({ type: Number, example: 12, nullable: true })
timeFormat!: number | null;
@ApiProperty({ example: null })
@ApiProperty({ type: Number, example: null, nullable: true })
defaultScheduleId!: number | null;
@IsEnum(Locales)
@IsOptional()
@ApiProperty({ example: Locales.EN, enum: Locales })
@ApiPropertyOptional({ type: String, example: Locales.EN, enum: Locales })
locale?: Locales;
@IsUrl()
@@ -43,7 +43,7 @@ export class ManagedUserOutput {
type: String,
example: "https://cal.com/api/avatar/2b735186-b01b-46d3-87da-019b8f61776b.png",
description: `URL of the user's avatar image`,
required: false,
nullable: true,
})
avatarUrl?: string | null;
}
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
IsArray,
@@ -30,7 +30,7 @@ export class PlatformOAuthClientDto {
@IsNumber()
permissions!: number;
@ApiProperty({ example: "https://example.com/logo.png", required: false })
@ApiPropertyOptional({ example: "https://example.com/logo.png" })
@IsOptional()
@IsString()
logo!: string | null;
@@ -54,9 +54,7 @@ export class GetOAuthClientResponseDto {
@IsEnum([SUCCESS_STATUS, ERROR_STATUS])
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS;
@ApiProperty({
type: PlatformOAuthClientDto,
})
@ApiProperty({ type: PlatformOAuthClientDto })
@IsNotEmptyObject()
@ValidateNested()
@Type(() => PlatformOAuthClientDto)
@@ -1,32 +1,40 @@
import { ApiPropertyOptional } from "@nestjs/swagger";
import { IsArray, IsBoolean, IsOptional, IsString } from "class-validator";
export class UpdateOAuthClientInput {
@IsOptional()
@IsString()
@ApiPropertyOptional()
logo?: string;
@IsString()
@IsOptional()
@ApiPropertyOptional()
name?: string;
@IsArray()
@IsOptional()
@IsString({ each: true })
redirectUris?: string[] = [];
@ApiPropertyOptional({ type: [String] })
redirectUris?: string[];
@IsOptional()
@IsString()
@ApiPropertyOptional()
bookingRedirectUri?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
bookingCancelRedirectUri?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
bookingRescheduleRedirectUri?: string;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional()
areEmailsEnabled?: boolean;
}
@@ -1,17 +1,21 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsNotEmpty, IsOptional, IsString } from "class-validator";
export class AssignOrganizationAttributeOptionToUserInput {
@IsOptional()
@IsString()
@IsNotEmpty()
@ApiPropertyOptional()
readonly value?: string;
@IsOptional()
@IsString()
@IsNotEmpty()
@ApiPropertyOptional()
readonly attributeOptionId?: string;
@IsNotEmpty()
@IsString()
@ApiProperty()
readonly attributeId!: string;
}
@@ -1,4 +1,5 @@
import { CreateOrganizationAttributeOptionInput } from "@/modules/organizations/inputs/attributes/options/create-organization-attribute-option.input";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { AttributeType } from "@prisma/client";
import { Type } from "class-transformer";
import {
@@ -14,22 +15,27 @@ import {
export class CreateOrganizationAttributeInput {
@IsString()
@IsNotEmpty()
@ApiProperty()
readonly name!: string;
@IsString()
@IsNotEmpty()
@ApiProperty()
readonly slug!: string;
@IsEnum(AttributeType)
@IsNotEmpty()
@ApiProperty({ enum: AttributeType })
readonly type!: AttributeType;
@IsArray()
@ValidateNested()
@ValidateNested({ each: true })
@Type(() => CreateOrganizationAttributeOptionInput)
@ApiProperty({ type: [CreateOrganizationAttributeOptionInput] })
readonly options!: CreateOrganizationAttributeOptionInput[];
@IsBoolean()
@IsOptional()
@ApiPropertyOptional()
readonly enabled?: boolean;
}
@@ -1,11 +1,14 @@
import { IsNotEmpty, IsOptional, IsString } from "class-validator";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { IsString, IsOptional } from "class-validator";
export class UpdateOrganizationAttributeOptionInput {
@IsString()
@IsOptional()
@ApiPropertyOptional()
readonly value?: string;
@IsString()
@IsOptional()
@ApiPropertyOptional()
readonly slug?: string;
}
@@ -1,20 +1,25 @@
import { ApiPropertyOptional } from "@nestjs/swagger";
import { AttributeType } from "@prisma/client";
import { IsBoolean, IsEnum, IsOptional, IsString } from "class-validator";
export class UpdateOrganizationAttributeInput {
@IsString()
@IsOptional()
@ApiPropertyOptional()
readonly name?: string;
@IsString()
@IsOptional()
@ApiPropertyOptional()
readonly slug?: string;
@IsEnum(AttributeType)
@IsOptional()
@ApiPropertyOptional({ enum: AttributeType })
readonly type?: AttributeType;
@IsBoolean()
@IsOptional()
@ApiPropertyOptional()
readonly enabled?: boolean;
}
@@ -1,13 +1,15 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { IsBoolean, IsOptional, IsEnum, IsInt } from "class-validator";
export class CreateOrgMembershipDto {
@IsInt()
@ApiProperty()
readonly userId!: number;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean, default: false })
readonly accepted?: boolean = false;
@IsEnum(MembershipRole)
@@ -16,5 +18,6 @@ export class CreateOrgMembershipDto {
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean, default: false })
readonly disableImpersonation?: boolean = false;
}
@@ -1,12 +1,14 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { IsBoolean, IsOptional, IsEnum, IsInt } from "class-validator";
export class CreateOrgTeamMembershipDto {
@IsInt()
@ApiProperty()
readonly userId!: number;
@IsOptional()
@ApiPropertyOptional({ type: Boolean, default: false })
@IsBoolean()
readonly accepted?: boolean = false;
@@ -15,6 +17,7 @@ export class CreateOrgTeamMembershipDto {
readonly role: MembershipRole = MembershipRole.MEMBER;
@IsOptional()
@ApiPropertyOptional({ type: Boolean, default: false })
@IsBoolean()
readonly disableImpersonation?: boolean = false;
}
@@ -9,7 +9,7 @@ export class CreateOrgTeamDto {
@IsOptional()
@IsString()
@ApiPropertyOptional({ type: String, description: "Team slug", example: "caltel", required: false })
@ApiPropertyOptional({ type: String, description: "Team slug", example: "caltel" })
readonly slug?: string;
@IsOptional()
@@ -18,52 +18,62 @@ export class CreateOrgTeamDto {
type: String,
example: "https://i.cal.com/api/avatar/b0b58752-68ad-4c0d-8024-4fa382a77752.png",
description: `URL of the teams logo image`,
required: false,
})
readonly logoUrl?: string;
@IsOptional()
@IsUrl()
@ApiPropertyOptional()
readonly calVideoLogo?: string;
@IsOptional()
@IsUrl()
@ApiPropertyOptional()
readonly appLogo?: string;
@IsOptional()
@IsUrl()
@ApiPropertyOptional()
readonly appIconLogo?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly bio?: string;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean, default: false })
readonly hideBranding?: boolean = false;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional()
readonly isPrivate?: boolean;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional()
readonly hideBookATeamMember?: boolean;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly metadata?: string; // Assuming metadata is a JSON string. Adjust accordingly if it's a nested object.
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly theme?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly brandColor?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly darkBrandColor?: string;
@IsOptional()
@@ -78,6 +88,7 @@ export class CreateOrgTeamDto {
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly timeFormat?: number;
@IsOptional()
@@ -96,12 +107,12 @@ export class CreateOrgTeamDto {
@ApiPropertyOptional({
type: String,
example: "Monday",
required: false,
default: "Sunday",
})
readonly weekStart?: string = "Sunday";
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean, default: true })
readonly autoAcceptCreator?: boolean = true;
}
@@ -1,17 +1,21 @@
import { CreateUserInput } from "@/modules/users/inputs/create-user.input";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { IsString, IsOptional, IsBoolean, IsEnum } from "class-validator";
export class CreateOrganizationUserInput extends CreateUserInput {
@IsOptional()
@IsString()
@ApiPropertyOptional({ type: String, default: "en" })
locale = "en";
@IsOptional()
@IsEnum(MembershipRole)
@ApiPropertyOptional({ enum: MembershipRole, default: MembershipRole.MEMBER })
organizationRole: MembershipRole = MembershipRole.MEMBER;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean, default: true })
autoAccept = true;
}
@@ -1,17 +1,20 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { IsBoolean, IsOptional, IsEnum } from "class-validator";
export class UpdateOrgMembershipDto {
@IsOptional()
@IsBoolean()
readonly accepted?: boolean = false;
@ApiPropertyOptional()
readonly accepted?: boolean;
@IsOptional()
@IsEnum(MembershipRole)
@ApiProperty({ enum: ["MEMBER", "OWNER", "ADMIN"] })
readonly role?: MembershipRole = MembershipRole.MEMBER;
@ApiPropertyOptional({ enum: ["MEMBER", "OWNER", "ADMIN"] })
readonly role?: MembershipRole;
@IsOptional()
@IsBoolean()
readonly disableImpersonation?: boolean = false;
@ApiPropertyOptional()
readonly disableImpersonation?: boolean;
}
@@ -1,17 +1,20 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { IsBoolean, IsOptional, IsEnum } from "class-validator";
export class UpdateOrgTeamMembershipDto {
@IsOptional()
@IsBoolean()
readonly accepted?: boolean = false;
@ApiPropertyOptional()
readonly accepted?: boolean;
@IsOptional()
@IsEnum(MembershipRole)
@ApiProperty({ enum: ["MEMBER", "OWNER", "ADMIN"] })
readonly role?: MembershipRole = MembershipRole.MEMBER;
@ApiPropertyOptional({ enum: ["MEMBER", "OWNER", "ADMIN"] })
readonly role?: MembershipRole;
@IsOptional()
@IsBoolean()
readonly disableImpersonation?: boolean = false;
@ApiPropertyOptional()
readonly disableImpersonation?: boolean;
}
@@ -4,12 +4,12 @@ import { IsBoolean, IsOptional, IsString, IsUrl, Length } from "class-validator"
export class UpdateOrgTeamDto {
@IsString()
@Length(1)
@ApiPropertyOptional({ description: "Name of the team", example: "CalTeam", required: false })
@ApiPropertyOptional({ description: "Name of the team", example: "CalTeam" })
readonly name?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional({ type: String, description: "Team slug", example: "caltel", required: false })
@ApiPropertyOptional({ type: String, description: "Team slug", example: "caltel" })
readonly slug?: string;
@IsOptional()
@@ -18,52 +18,62 @@ export class UpdateOrgTeamDto {
type: String,
example: "https://i.cal.com/api/avatar/b0b58752-68ad-4c0d-8024-4fa382a77752.png",
description: `URL of the teams logo image`,
required: false,
})
readonly logoUrl?: string;
@IsOptional()
@IsUrl()
@ApiPropertyOptional()
readonly calVideoLogo?: string;
@IsOptional()
@IsUrl()
@ApiPropertyOptional()
readonly appLogo?: string;
@IsOptional()
@IsUrl()
@ApiPropertyOptional()
readonly appIconLogo?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly bio?: string;
@IsOptional()
@IsBoolean()
readonly hideBranding?: boolean = false;
@ApiPropertyOptional()
readonly hideBranding?: boolean;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional()
readonly isPrivate?: boolean;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional()
readonly hideBookATeamMember?: boolean;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly metadata?: string; // Assuming metadata is a JSON string. Adjust accordingly if it's a nested object.
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly theme?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly brandColor?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly darkBrandColor?: string;
@IsOptional()
@@ -72,12 +82,12 @@ export class UpdateOrgTeamDto {
type: String,
example: "https://i.cal.com/api/avatar/949be534-7a88-4185-967c-c020b0c0bef3.png",
description: `URL of the teams banner image which is shown on booker`,
required: false,
})
readonly bannerUrl?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly timeFormat?: number;
@IsOptional()
@@ -86,26 +96,24 @@ export class UpdateOrgTeamDto {
type: String,
example: "America/New_York",
description: `Timezone is used to create teams's default schedule from Monday to Friday from 9AM to 5PM. It will default to Europe/London if not passed.`,
required: false,
default: "Europe/London",
})
readonly timeZone?: string = "Europe/London";
readonly timeZone?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional({
type: String,
example: "Monday",
required: false,
default: "Sunday",
})
readonly weekStart?: string = "Sunday";
readonly weekStart?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional()
readonly bookingLimits?: string;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional()
readonly includeManagedEventsInLimits?: boolean;
}
@@ -2,21 +2,21 @@ import { Attribute } from "@/modules/organizations/outputs/attributes/attribute.
import { BaseOutputDTO } from "@/modules/organizations/outputs/attributes/base.output";
import { ApiProperty } from "@nestjs/swagger";
import { Expose, Type } from "class-transformer";
import { IsBoolean, IsInt, IsString, IsEnum, ValidateNested, IsOptional } from "class-validator";
import { AttributeType } from "@calcom/prisma/client";
import { IsOptional, ValidateNested } from "class-validator";
export class GetSingleAttributeOutput extends BaseOutputDTO {
@Expose()
@ValidateNested()
@IsOptional()
@Type(() => Attribute)
@ApiProperty({ type: Attribute, nullable: true })
data!: Attribute | null;
}
export class GetOrganizationAttributesOutput extends BaseOutputDTO {
@Expose()
@ValidateNested()
@ValidateNested({ each: true })
@Type(() => Attribute)
@ApiProperty({ type: [Attribute] })
data!: Attribute[];
}
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { Expose } from "class-transformer";
import { IsBoolean, IsInt, IsOptional, IsString } from "class-validator";
@@ -6,18 +6,22 @@ import { IsBoolean, IsInt, IsOptional, IsString } from "class-validator";
export class OrgMembershipOutputDto {
@IsInt()
@Expose()
@ApiProperty()
readonly id!: number;
@IsInt()
@Expose()
@ApiProperty()
readonly userId!: number;
@IsInt()
@Expose()
@ApiProperty()
readonly teamId!: number;
@IsBoolean()
@Expose()
@ApiProperty()
readonly accepted!: boolean;
@IsString()
@@ -28,5 +32,6 @@ export class OrgMembershipOutputDto {
@IsOptional()
@IsBoolean()
@Expose()
@ApiPropertyOptional()
readonly disableImpersonation?: boolean;
}
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { Expose, Type } from "class-transformer";
import { IsArray, IsBoolean, IsEnum, IsInt, IsOptional, IsString, ValidateNested } from "class-validator";
@@ -9,38 +9,46 @@ export class MembershipUserOutputDto {
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly avatarUrl?: string;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly username?: string;
@IsOptional()
@IsString()
@Expose()
@ApiPropertyOptional()
readonly name?: string;
@IsBoolean()
@Expose()
@ApiProperty()
readonly email!: string;
}
export class OrgTeamMembershipOutputDto {
@IsInt()
@Expose()
@ApiProperty()
readonly id!: number;
@IsInt()
@Expose()
@ApiProperty()
readonly userId!: number;
@IsInt()
@Expose()
@ApiProperty()
readonly teamId!: number;
@IsBoolean()
@Expose()
@ApiProperty()
readonly accepted!: boolean;
@IsString()
@@ -51,11 +59,13 @@ export class OrgTeamMembershipOutputDto {
@IsOptional()
@IsBoolean()
@Expose()
@ApiPropertyOptional()
readonly disableImpersonation?: boolean;
@ValidateNested()
@Type(() => MembershipUserOutputDto)
@Expose()
@ApiProperty({ type: MembershipUserOutputDto })
user!: MembershipUserOutputDto;
}
@@ -68,6 +78,7 @@ export class OrgTeamMembershipsOutputResponseDto {
@ValidateNested()
@Type(() => OrgTeamMembershipOutputDto)
@IsArray()
@ApiProperty({ type: [OrgTeamMembershipOutputDto] })
data!: OrgTeamMembershipOutputDto[];
}
@@ -79,5 +90,6 @@ export class OrgTeamMembershipOutputResponseDto {
@Expose()
@ValidateNested()
@Type(() => OrgTeamMembershipOutputDto)
@ApiProperty({ type: OrgTeamMembershipOutputDto })
data!: OrgTeamMembershipOutputDto;
}
@@ -1,20 +1,24 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { IsBoolean, IsOptional, IsEnum, IsInt } from "class-validator";
export class CreateTeamMembershipInput {
@IsInt()
@ApiProperty({ type: Number })
readonly userId!: number;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean, default: false })
readonly accepted?: boolean = false;
@IsOptional()
@IsEnum(MembershipRole)
@ApiProperty({ enum: ["MEMBER", "OWNER", "ADMIN"] })
@ApiPropertyOptional({ enum: ["MEMBER", "OWNER", "ADMIN"], default: "MEMBER" })
readonly role: MembershipRole = MembershipRole.MEMBER;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ type: Boolean, default: false })
readonly disableImpersonation?: boolean = false;
}
@@ -1,17 +1,20 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { IsBoolean, IsOptional, IsEnum } from "class-validator";
export class UpdateTeamMembershipInput {
@IsOptional()
@IsBoolean()
readonly accepted?: boolean = false;
@ApiPropertyOptional({ type: Boolean })
readonly accepted?: boolean;
@IsOptional()
@IsEnum(MembershipRole)
@ApiProperty({ enum: ["MEMBER", "OWNER", "ADMIN"] })
readonly role?: MembershipRole = MembershipRole.MEMBER;
@ApiPropertyOptional({ enum: ["MEMBER", "OWNER", "ADMIN"] })
readonly role?: MembershipRole;
@IsOptional()
@IsBoolean()
readonly disableImpersonation?: boolean = false;
@ApiPropertyOptional({ type: Boolean })
readonly disableImpersonation?: boolean;
}
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { MembershipRole } from "@prisma/client";
import { Expose } from "class-transformer";
import { IsBoolean, IsInt, IsOptional, IsString } from "class-validator";
@@ -6,18 +6,22 @@ import { IsBoolean, IsInt, IsOptional, IsString } from "class-validator";
export class TeamMembershipOutput {
@IsInt()
@Expose()
@ApiProperty()
readonly id!: number;
@IsInt()
@Expose()
@ApiProperty()
readonly userId!: number;
@IsInt()
@Expose()
@ApiProperty()
readonly teamId!: number;
@IsBoolean()
@Expose()
@ApiProperty()
readonly accepted!: boolean;
@IsString()
@@ -28,5 +32,6 @@ export class TeamMembershipOutput {
@IsOptional()
@IsBoolean()
@Expose()
@ApiPropertyOptional()
readonly disableImpersonation?: boolean;
}
@@ -16,12 +16,12 @@ export class CreateManagedUserInput {
@IsOptional()
@IsIn([12, 24], { message: "timeFormat must be a number either 12 or 24" })
@ApiProperty({ example: 12, enum: [12, 24], description: "Must be a number 12 or 24" })
@ApiPropertyOptional({ example: 12, enum: [12, 24], description: "Must be a number 12 or 24" })
timeFormat?: TimeFormat;
@IsOptional()
@IsString()
@ApiProperty({
@ApiPropertyOptional({
example: "Monday",
enum: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
})
@@ -30,7 +30,7 @@ export class CreateManagedUserInput {
@IsTimeZone()
@IsOptional()
@CapitalizeTimeZone()
@ApiProperty({
@ApiPropertyOptional({
example: "America/New_York",
description: `Timezone is used to create user's default schedule from Monday to Friday from 9AM to 5PM. If it is not passed then user does not have
a default schedule and it must be created manually via the /schedules endpoint. Until the schedule is created, the user can't access availability atom to set his / her availability nor booked.
@@ -49,7 +49,6 @@ export class CreateManagedUserInput {
type: String,
example: "https://cal.com/api/avatar/2b735186-b01b-46d3-87da-019b8f61776b.png",
description: `URL of the user's avatar image`,
required: false,
})
avatarUrl?: string;
}
@@ -1,4 +1,4 @@
import { ApiProperty } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsOptional, Validate } from "class-validator";
@@ -12,7 +12,8 @@ export class GetUsersInput extends SkipTakePagination {
@Transform(({ value }: { value: string | string[] }) => {
return typeof value === "string" ? [value] : value;
})
@ApiProperty({
@ApiPropertyOptional({
type: [String],
description: "The email address or an array of email addresses to filter by",
})
emails?: string[];
@@ -1,31 +1,34 @@
import { Locales } from "@/lib/enums/locales";
import { CapitalizeTimeZone } from "@/lib/inputs/capitalize-timezone";
import { TimeFormat, WeekDay } from "@/modules/users/inputs/create-managed-user.input";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { ApiPropertyOptional } from "@nestjs/swagger";
import { IsEnum, IsIn, IsNumber, IsOptional, IsString, IsTimeZone, IsUrl } from "class-validator";
export class UpdateManagedUserInput {
@IsString()
@IsOptional()
@ApiPropertyOptional()
email?: string;
@IsString()
@IsOptional()
@ApiPropertyOptional()
name?: string;
@IsOptional()
@IsIn([12, 24])
@ApiProperty({ example: 12, enum: [12, 24], description: "Must be 12 or 24" })
@ApiPropertyOptional({ example: 12, enum: [12, 24], description: "Must be 12 or 24" })
timeFormat?: TimeFormat;
@IsNumber()
@IsOptional()
@ApiPropertyOptional()
defaultScheduleId?: number;
@IsOptional()
@IsString()
@IsIn(["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"])
@ApiProperty({
@ApiPropertyOptional({
example: "Monday",
enum: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
})
@@ -34,11 +37,12 @@ export class UpdateManagedUserInput {
@IsTimeZone()
@IsOptional()
@CapitalizeTimeZone()
@ApiPropertyOptional()
timeZone?: string;
@IsEnum(Locales)
@IsOptional()
@ApiProperty({ example: Locales.EN, enum: Locales })
@ApiPropertyOptional({ example: Locales.EN, enum: Locales })
locale?: Locales;
@IsUrl()
@@ -47,7 +51,6 @@ export class UpdateManagedUserInput {
type: String,
example: "https://cal.com/api/avatar/2b735186-b01b-46d3-87da-019b8f61776b.png",
description: `URL of the user's avatar image`,
required: false,
})
avatarUrl?: string;
}
@@ -1,4 +1,4 @@
import { ApiProperty, PartialType } from "@nestjs/swagger";
import { ApiProperty, ApiPropertyOptional, PartialType } from "@nestjs/swagger";
import { WebhookTriggerEvents } from "@prisma/client";
import { IsArray, IsBoolean, IsEnum, IsOptional, IsString } from "class-validator";
@@ -19,9 +19,11 @@ export class CreateWebhookInputDto {
payloadTemplate?: string;
@IsBoolean()
@ApiProperty()
active!: boolean;
@IsString()
@ApiProperty()
subscriberUrl!: string;
@IsArray()
@@ -43,6 +45,7 @@ export class CreateWebhookInputDto {
@IsString()
@IsOptional()
@ApiPropertyOptional()
secret?: string;
}