|
1 |
| -import { ApiProperty } from "@nestjs/swagger"; |
2 |
| -import { IsNotEmpty, IsOptional, IsString, IsUUID, IsEnum, IsLongitude, IsLatitude, IsBoolean, IsInt, Min, IsDateString, IsObject, ValidateIf, ValidateNested, Validate, IsIn } from 'class-validator'; |
3 |
| -import { MeetingDetails } from "src/common/utils/types"; |
4 |
| -import { Transform, Type } from "class-transformer"; |
5 |
| -import { UrlWithProviderValidator } from "src/common/utils/validation.util"; |
6 |
| -import { MeetingDetailsDto } from "./create-event.dto"; |
| 1 | +import { ApiProperty } from '@nestjs/swagger'; |
| 2 | +import { |
| 3 | + IsNotEmpty, |
| 4 | + IsOptional, |
| 5 | + IsString, |
| 6 | + IsUUID, |
| 7 | + IsEnum, |
| 8 | + IsLongitude, |
| 9 | + IsLatitude, |
| 10 | + IsBoolean, |
| 11 | + IsInt, |
| 12 | + Min, |
| 13 | + IsDateString, |
| 14 | + IsObject, |
| 15 | + ValidateIf, |
| 16 | + ValidateNested, |
| 17 | + Validate, |
| 18 | + IsIn, |
| 19 | +} from 'class-validator'; |
| 20 | +import { MeetingDetails } from 'src/common/utils/types'; |
| 21 | +import { Transform, Type } from 'class-transformer'; |
| 22 | +import { UrlWithProviderValidator } from 'src/common/utils/validation.util'; |
| 23 | +import { MeetingDetailsDto } from './create-event.dto'; |
7 | 24 | export interface UpdateResult {
|
8 |
| - onlineDetails?: any; |
9 |
| - erMetaData?: any; |
10 |
| - eventDetails?: any; |
11 |
| - repetationDetail?: any; |
12 |
| - recurrenceUpdate?: any; |
| 25 | + onlineDetails?: any; |
| 26 | + erMetaData?: any; |
| 27 | + eventDetails?: any; |
| 28 | + repetationDetail?: any; |
| 29 | + recurrenceUpdate?: any; |
13 | 30 | }
|
14 | 31 |
|
15 | 32 | export class UpdateEventDto {
|
16 |
| - |
17 |
| - @ApiProperty({ |
18 |
| - type: String, |
19 |
| - description: 'Status', |
20 |
| - example: 'live' |
21 |
| - }) |
22 |
| - @IsEnum(['live', 'draft', 'archived'], { |
23 |
| - message: 'Status must be one of: live, draft, archived', |
24 |
| - }) |
25 |
| - @IsString() |
26 |
| - @IsOptional() |
27 |
| - @IsNotEmpty() |
28 |
| - status: string; |
29 |
| - |
30 |
| - @IsOptional() |
31 |
| - @IsString() |
32 |
| - startTime?: string; |
33 |
| - |
34 |
| - @ApiProperty({ |
35 |
| - type: String, |
36 |
| - description: 'title', |
37 |
| - example: 'Sample Event' |
38 |
| - }) |
39 |
| - @IsString() |
40 |
| - @IsNotEmpty() |
41 |
| - @IsOptional() |
42 |
| - title?: string; |
43 |
| - |
44 |
| - @ApiProperty({ |
45 |
| - type: String, |
46 |
| - description: 'isRecurring', |
47 |
| - example: true |
48 |
| - }) |
49 |
| - @IsBoolean() |
50 |
| - isMainEvent: boolean; |
51 |
| - |
52 |
| - @ApiProperty({ |
53 |
| - type: MeetingDetailsDto, |
54 |
| - description: 'Online Meeting Details', |
55 |
| - example: { |
56 |
| - url: 'https://example.com/meeting', |
57 |
| - id: '123-456-789', |
58 |
| - password: 'xxxxxxx', |
59 |
| - }, |
60 |
| - }) |
61 |
| - @IsObject() |
62 |
| - // @ValidateIf((o => o.onlineProvider != undefined)) |
63 |
| - @ValidateIf(o => o.onlineProvider != undefined || o.onlineDetails != undefined) |
64 |
| - @ValidateNested({ each: true }) |
65 |
| - @Type(() => MeetingDetailsDto) |
66 |
| - @Transform(({ value, obj }) => { |
67 |
| - value.onlineProvider = obj.onlineProvider; // Pass the provider to the nested DTO |
68 |
| - return value; |
69 |
| - }) |
70 |
| - onlineDetails: MeetingDetails; |
71 |
| - |
72 |
| - |
73 |
| - @ApiProperty({ |
74 |
| - description: 'MetaData Details', |
75 |
| - example: { |
76 |
| - "topic": "Java", |
77 |
| - "mentorId": "1244546647", |
78 |
| - "subTopic": "Type of fetaures" |
79 |
| - } |
80 |
| - }) |
81 |
| - @IsObject() |
82 |
| - @IsOptional() |
83 |
| - erMetaData: any; |
84 |
| - |
85 |
| - |
86 |
| - @ApiProperty({ |
87 |
| - type: String, |
88 |
| - description: 'Start Datetime', |
89 |
| - example: '2024-06-02T02:00:00Z' |
90 |
| - }) |
91 |
| - @ValidateIf(o => o.endDatetime !== undefined) |
92 |
| - @IsDateString() |
93 |
| - startDatetime: Date; |
94 |
| - |
95 |
| - @ApiProperty({ |
96 |
| - type: String, |
97 |
| - description: 'End Datetime', |
98 |
| - example: '2024-06-02T05:00:00Z' |
99 |
| - }) |
100 |
| - @ValidateIf(o => o.startDatetime !== undefined) |
101 |
| - @IsDateString() |
102 |
| - endDatetime: Date; |
103 |
| - |
104 |
| - @ApiProperty({ |
105 |
| - type: String, |
106 |
| - description: 'Location', |
107 |
| - example: 'Event Location' |
108 |
| - }) |
109 |
| - @IsString() |
110 |
| - @IsNotEmpty() |
111 |
| - @IsOptional() |
112 |
| - location: string; |
113 |
| - |
114 |
| - |
115 |
| - @ApiProperty({ |
116 |
| - type: Number, |
117 |
| - description: 'Latitude', |
118 |
| - example: 18.508345134886994 |
119 |
| - }) |
120 |
| - @ValidateIf(o => o.latitude !== undefined) |
121 |
| - @IsLongitude() |
122 |
| - longitude: number; |
123 |
| - |
124 |
| - @ApiProperty({ |
125 |
| - type: Number, |
126 |
| - description: 'Latitude', |
127 |
| - example: 18.508345134886994 |
128 |
| - }) |
129 |
| - @ValidateIf(o => o.longitude !== undefined) |
130 |
| - @IsLatitude() |
131 |
| - latitude: number; |
132 |
| - |
133 |
| - @ApiProperty({ |
134 |
| - type: String, |
135 |
| - description: 'Online Provider', |
136 |
| - example: 'Zoom', |
137 |
| - }) |
138 |
| - @IsOptional() |
139 |
| - @IsString() |
140 |
| - @IsNotEmpty() |
141 |
| - @IsIn(['Zoom', 'GoogleMeet']) |
142 |
| - onlineProvider: string; |
143 |
| - |
144 |
| - |
145 |
| - |
146 |
| - @IsString() |
147 |
| - @IsOptional() |
148 |
| - createdBy: string; |
149 |
| - |
150 |
| - @IsString() |
151 |
| - @IsOptional() |
152 |
| - updatedBy: string; |
153 |
| - |
154 |
| - @IsOptional() |
155 |
| - updateAt: Date; |
156 |
| - |
157 |
| - // Validation to ensure if isMainEvent is true, title or status must be provided |
158 |
| - @ValidateIf(o => !o.title && !o.status && !o.onlineDetails && !o.location && !o.latitude && !o.erMetaData && !o.startDatetime && !o.onlineProvider) |
159 |
| - @IsNotEmpty({ message: 'If isMainEvent is provided, at least one of title or status must be provided.' }) |
160 |
| - validateFields?: any; |
161 |
| - |
162 |
| - |
| 33 | + @ApiProperty({ |
| 34 | + type: String, |
| 35 | + description: 'Status', |
| 36 | + example: 'live', |
| 37 | + }) |
| 38 | + @IsEnum(['live', 'draft', 'archived'], { |
| 39 | + message: 'Status must be one of: live, draft, archived', |
| 40 | + }) |
| 41 | + @IsString() |
| 42 | + @IsOptional() |
| 43 | + @IsNotEmpty() |
| 44 | + status: string; |
| 45 | + |
| 46 | + @IsOptional() |
| 47 | + @IsString() |
| 48 | + startTime?: string; |
| 49 | + |
| 50 | + @ApiProperty({ |
| 51 | + type: String, |
| 52 | + description: 'title', |
| 53 | + example: 'Sample Event', |
| 54 | + }) |
| 55 | + @IsString() |
| 56 | + @IsNotEmpty() |
| 57 | + @IsOptional() |
| 58 | + title?: string; |
| 59 | + |
| 60 | + @ApiProperty({ |
| 61 | + type: String, |
| 62 | + description: 'isRecurring', |
| 63 | + example: true, |
| 64 | + }) |
| 65 | + @IsBoolean() |
| 66 | + isMainEvent: boolean; |
| 67 | + |
| 68 | + @ApiProperty({ |
| 69 | + type: MeetingDetailsDto, |
| 70 | + description: 'Online Meeting Details', |
| 71 | + example: { |
| 72 | + url: 'https://example.com/meeting', |
| 73 | + id: '123-456-789', |
| 74 | + password: 'xxxxxxx', |
| 75 | + }, |
| 76 | + }) |
| 77 | + @IsObject() |
| 78 | + // @ValidateIf((o => o.onlineProvider != undefined)) |
| 79 | + @ValidateIf( |
| 80 | + (o) => o.onlineProvider != undefined || o.onlineDetails != undefined, |
| 81 | + ) |
| 82 | + @ValidateNested({ each: true }) |
| 83 | + @Type(() => MeetingDetailsDto) |
| 84 | + @Transform(({ value, obj }) => { |
| 85 | + value.onlineProvider = obj.onlineProvider; // Pass the provider to the nested DTO |
| 86 | + return value; |
| 87 | + }) |
| 88 | + onlineDetails: MeetingDetails; |
| 89 | + |
| 90 | + @ApiProperty({ |
| 91 | + description: 'ErMetaData Details', |
| 92 | + example: { |
| 93 | + topic: 'Java', |
| 94 | + mentorId: '1244546647', |
| 95 | + subTopic: 'Type of fetaures', |
| 96 | + }, |
| 97 | + }) |
| 98 | + @IsObject() |
| 99 | + @IsOptional() |
| 100 | + erMetaData: any; |
| 101 | + |
| 102 | + @ApiProperty({ |
| 103 | + description: 'MetaData Details', |
| 104 | + example: { |
| 105 | + framework: { |
| 106 | + board: '', |
| 107 | + medium: '', |
| 108 | + grade: '', |
| 109 | + subject: '', |
| 110 | + topic: '', |
| 111 | + subTopic: '', |
| 112 | + teacherName: 'Vivek Kasture', |
| 113 | + }, |
| 114 | + eventType: 'PLANNED_SESSION', |
| 115 | + doId: '', |
| 116 | + cohortId: '71bdbed4-388a-4c79-bd69-65b08e857f1e', |
| 117 | + cycleId: '', |
| 118 | + tenant: '', |
| 119 | + }, |
| 120 | + }) |
| 121 | + @IsObject() |
| 122 | + @IsOptional() |
| 123 | + metadata: any; |
| 124 | + |
| 125 | + @ApiProperty({ |
| 126 | + type: String, |
| 127 | + description: 'Start Datetime', |
| 128 | + example: '2024-06-02T02:00:00Z', |
| 129 | + }) |
| 130 | + @ValidateIf((o) => o.endDatetime !== undefined) |
| 131 | + @IsDateString() |
| 132 | + startDatetime: Date; |
| 133 | + |
| 134 | + @ApiProperty({ |
| 135 | + type: String, |
| 136 | + description: 'End Datetime', |
| 137 | + example: '2024-06-02T05:00:00Z', |
| 138 | + }) |
| 139 | + @ValidateIf((o) => o.startDatetime !== undefined) |
| 140 | + @IsDateString() |
| 141 | + endDatetime: Date; |
| 142 | + |
| 143 | + @ApiProperty({ |
| 144 | + type: String, |
| 145 | + description: 'Location', |
| 146 | + example: 'Event Location', |
| 147 | + }) |
| 148 | + @IsString() |
| 149 | + @IsNotEmpty() |
| 150 | + @IsOptional() |
| 151 | + location: string; |
| 152 | + |
| 153 | + @ApiProperty({ |
| 154 | + type: Number, |
| 155 | + description: 'Latitude', |
| 156 | + example: 18.508345134886994, |
| 157 | + }) |
| 158 | + @ValidateIf((o) => o.latitude !== undefined) |
| 159 | + @IsLongitude() |
| 160 | + longitude: number; |
| 161 | + |
| 162 | + @ApiProperty({ |
| 163 | + type: Number, |
| 164 | + description: 'Latitude', |
| 165 | + example: 18.508345134886994, |
| 166 | + }) |
| 167 | + @ValidateIf((o) => o.longitude !== undefined) |
| 168 | + @IsLatitude() |
| 169 | + latitude: number; |
| 170 | + |
| 171 | + @ApiProperty({ |
| 172 | + type: String, |
| 173 | + description: 'Online Provider', |
| 174 | + example: 'Zoom', |
| 175 | + }) |
| 176 | + @IsOptional() |
| 177 | + @IsString() |
| 178 | + @IsNotEmpty() |
| 179 | + @IsIn(['Zoom', 'GoogleMeet']) |
| 180 | + onlineProvider: string; |
| 181 | + |
| 182 | + @IsString() |
| 183 | + @IsOptional() |
| 184 | + createdBy: string; |
| 185 | + |
| 186 | + @IsString() |
| 187 | + @IsOptional() |
| 188 | + updatedBy: string; |
| 189 | + |
| 190 | + @IsOptional() |
| 191 | + updateAt: Date; |
| 192 | + |
| 193 | + // Validation to ensure if isMainEvent is true, title or status must be provided |
| 194 | + @ValidateIf( |
| 195 | + (o) => |
| 196 | + !o.title && |
| 197 | + !o.status && |
| 198 | + !o.onlineDetails && |
| 199 | + !o.location && |
| 200 | + !o.latitude && |
| 201 | + !o.erMetaData && |
| 202 | + !o.startDatetime && |
| 203 | + !o.onlineProvider && |
| 204 | + !o.metadata, |
| 205 | + ) |
| 206 | + @IsNotEmpty({ |
| 207 | + message: |
| 208 | + 'If isMainEvent is provided, at least one of title or status must be provided.', |
| 209 | + }) |
| 210 | + validateFields?: any; |
163 | 211 | }
|
0 commit comments