129 lines
2.2 KiB
TypeScript
Executable File
129 lines
2.2 KiB
TypeScript
Executable File
import {
|
|
IsEmail,
|
|
IsString,
|
|
IsOptional,
|
|
IsBoolean,
|
|
MinLength,
|
|
} from "class-validator";
|
|
import { ApiProperty, ApiPropertyOptional, PartialType } from "@nestjs/swagger";
|
|
|
|
export class CreateUserDto {
|
|
@ApiPropertyOptional({ example: "user@example.com" })
|
|
@IsEmail()
|
|
email: string;
|
|
|
|
@ApiPropertyOptional({ example: "password123", minLength: 8 })
|
|
@IsString()
|
|
@MinLength(8)
|
|
password: string;
|
|
|
|
@ApiPropertyOptional({ example: "John" })
|
|
@IsOptional()
|
|
@IsString()
|
|
firstName?: string;
|
|
|
|
@ApiPropertyOptional({ example: "Doe" })
|
|
@IsOptional()
|
|
@IsString()
|
|
lastName?: string;
|
|
|
|
@ApiPropertyOptional({ default: true })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
}
|
|
|
|
export class UpdateUserDto extends PartialType(CreateUserDto) {
|
|
@ApiPropertyOptional({ example: "John" })
|
|
@IsOptional()
|
|
@IsString()
|
|
firstName?: string;
|
|
|
|
@ApiPropertyOptional({ example: "Doe" })
|
|
@IsOptional()
|
|
@IsString()
|
|
lastName?: string;
|
|
|
|
@ApiPropertyOptional({ default: true })
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
}
|
|
|
|
export class UpdateProfileDto {
|
|
@ApiPropertyOptional({ example: "John" })
|
|
@IsOptional()
|
|
@IsString()
|
|
firstName?: string;
|
|
|
|
@ApiPropertyOptional({ example: "Doe" })
|
|
@IsOptional()
|
|
@IsString()
|
|
lastName?: string;
|
|
}
|
|
|
|
export class ChangePasswordDto {
|
|
@ApiProperty({ example: "oldPassword123" })
|
|
@IsString()
|
|
currentPassword: string;
|
|
|
|
@ApiProperty({ example: "newPassword456", minLength: 8 })
|
|
@IsString()
|
|
@MinLength(8)
|
|
newPassword: string;
|
|
}
|
|
|
|
import { Exclude, Expose, Type } from "class-transformer";
|
|
|
|
@Exclude()
|
|
export class UsageLimitDto {
|
|
@Expose()
|
|
analysisCount: number;
|
|
|
|
@Expose()
|
|
couponCount: number;
|
|
|
|
@Expose()
|
|
maxAnalyses: number;
|
|
|
|
@Expose()
|
|
maxCoupons: number;
|
|
|
|
@Expose()
|
|
lastResetDate: Date;
|
|
}
|
|
|
|
@Exclude()
|
|
export class UserResponseDto {
|
|
@Expose()
|
|
id: string;
|
|
|
|
@Expose()
|
|
email: string;
|
|
|
|
@Expose()
|
|
firstName: string | null;
|
|
|
|
@Expose()
|
|
lastName: string | null;
|
|
|
|
@Expose()
|
|
role: string;
|
|
|
|
@Expose()
|
|
isActive: boolean;
|
|
|
|
@Expose()
|
|
subscriptionStatus: string;
|
|
|
|
@Expose()
|
|
createdAt: Date;
|
|
|
|
@Expose()
|
|
updatedAt: Date;
|
|
|
|
@Expose()
|
|
@Type(() => UsageLimitDto)
|
|
usageLimit?: UsageLimitDto;
|
|
}
|