import { ApiPropertyOptional } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { ArrayMaxSize, IsArray, IsEnum, IsMongoId, IsNumber, IsOptional, IsBoolean, IsString, IsUrl, Length, Max, Min, } from 'class-validator'; import { PostVisibility } from '../../../common/enums/post-visibility.enum'; import { toNumberArray, toStringArray } from '../../../common/utils/array-transform.util'; export class UpdatePostDto { @ApiPropertyOptional({ maxLength: 2200 }) @IsOptional() @IsString() @Length(1, 2200) content?: string; @ApiPropertyOptional({ maxLength: 2200, description: 'Text displayed above post media' }) @IsOptional() @IsString() @Length(0, 2200) contentTop?: string; @ApiPropertyOptional({ maxLength: 2200, description: 'Text displayed below post media' }) @IsOptional() @IsString() @Length(0, 2200) contentBottom?: string; @ApiPropertyOptional({ description: 'Set video URL. If provided, audioUrl will be cleared.' }) @IsOptional() @IsUrl({ require_tld: false }) videoUrl?: string; @ApiPropertyOptional({ description: 'Set audio URL. If provided, videoUrl will be cleared.' }) @IsOptional() @IsUrl({ require_tld: false }) audioUrl?: string; @ApiPropertyOptional({ description: 'Media duration in seconds for audio/video posts' }) @IsOptional() @IsNumber() @Min(1) @Max(7200) durationSeconds?: number; @ApiPropertyOptional({ description: 'Cover/thumbnail URL for audio/video posts' }) @IsOptional() @IsUrl({ require_tld: false }) thumbnailUrl?: string; @ApiPropertyOptional({ description: 'Music style or genre for audio/video posts', maxLength: 80 }) @IsOptional() @IsString() @Length(0, 80) style?: string; @ApiPropertyOptional({ description: 'Maqam name for audio/video posts', maxLength: 80 }) @IsOptional() @IsString() @Length(0, 80) maqam?: string; @ApiPropertyOptional({ description: 'Rhythm signature like 6/8 for audio/video posts', maxLength: 40 }) @IsOptional() @IsString() @Length(0, 40) rhythmSignature?: string; @ApiPropertyOptional({ type: [Number], description: 'Optional waveform samples for audio posts only', }) @IsOptional() @Transform(toNumberArray) @IsArray() @ArrayMaxSize(512) @IsNumber({}, { each: true }) waveformPeaks?: number[]; @ApiPropertyOptional({ type: [String], description: 'Set image carousel URLs (max 10)' }) @IsOptional() @Transform(toStringArray) @IsArray() @ArrayMaxSize(10) @IsUrl({ require_tld: false }, { each: true }) imageUrls?: string[]; @ApiPropertyOptional({ type: [String], description: 'Caption per carousel image, matched by order' }) @IsOptional() @Transform(toStringArray) @IsArray() @ArrayMaxSize(10) @IsString({ each: true }) @Length(0, 300, { each: true }) imageCaptions?: string[]; @ApiPropertyOptional({ type: [String], description: 'Alt text per carousel image, matched by order' }) @IsOptional() @Transform(toStringArray) @IsArray() @ArrayMaxSize(10) @IsString({ each: true }) @Length(0, 300, { each: true }) imageAltTexts?: string[]; @ApiPropertyOptional({ type: [String], description: 'Set tagged user ids (max 20)' }) @IsOptional() @Transform(toStringArray) @IsArray() @ArrayMaxSize(20) @IsMongoId({ each: true }) taggedUserIds?: string[]; @ApiPropertyOptional({ type: [String], description: 'Collaborator user ids (max 5)' }) @IsOptional() @Transform(toStringArray) @IsArray() @ArrayMaxSize(5) @IsMongoId({ each: true }) collaboratorIds?: string[]; @ApiPropertyOptional({ type: [String], description: 'Set mention usernames like rami_sabry (max 30)' }) @IsOptional() @Transform(toStringArray) @IsArray() @ArrayMaxSize(30) @IsString({ each: true }) @Length(1, 30, { each: true }) mentionUsernames?: string[]; @ApiPropertyOptional({ type: [String], description: 'Set mentioned user ids (max 30)' }) @IsOptional() @Transform(toStringArray) @IsArray() @ArrayMaxSize(30) @IsMongoId({ each: true }) mentionedUserIds?: string[]; @ApiPropertyOptional({ description: 'Post location text' }) @IsOptional() @IsString() @Length(0, 120) location?: string; @ApiPropertyOptional({ description: 'Post latitude' }) @IsOptional() @IsNumber() @Min(-90) @Max(90) latitude?: number; @ApiPropertyOptional({ description: 'Post longitude' }) @IsOptional() @IsNumber() @Min(-180) @Max(180) longitude?: number; @ApiPropertyOptional({ enum: PostVisibility }) @IsOptional() @IsEnum(PostVisibility) visibility?: PostVisibility; @ApiPropertyOptional() @IsOptional() @IsBoolean() commentsDisabled?: boolean; @ApiPropertyOptional() @IsOptional() @IsBoolean() commentsFollowersOnly?: boolean; }