import { IsString, IsEmail, IsBoolean, IsOptional, IsArray, MinLength } from 'class-validator'; export class User { id?: string; username: string; email: string; firstName?: string; lastName?: string; enabled?: boolean = true; emailVerified?: boolean = false; attributes?: Record; clientRoles?: string[]; // Rôles client uniquement (admin, merchant, support) createdTimestamp?: number; constructor(partial?: Partial) { if (partial) { Object.assign(this, partial); } } } export class UserCredentials { type: string; value: string; temporary: boolean = false; constructor(type: string, value: string, temporary: boolean = false) { this.type = type; this.value = value; this.temporary = temporary; } } export class CreateUserDto { @IsString() @MinLength(3) username: string; @IsEmail() email: string; @IsString() firstName?: string; @IsString() lastName?: string; @IsString() @MinLength(8) password: string; @IsOptional() @IsBoolean() enabled?: boolean = true; @IsOptional() @IsBoolean() emailVerified?: boolean = false; @IsOptional() attributes?: Record; @IsOptional() @IsArray() clientRoles?: string[]; } export class UpdateUserDto { @IsOptional() @IsString() username?: string; @IsOptional() @IsEmail() email?: string; @IsOptional() @IsString() firstName?: string; @IsOptional() @IsString() lastName?: string; @IsOptional() @IsBoolean() enabled?: boolean; @IsOptional() @IsBoolean() emailVerified?: boolean; @IsOptional() attributes?: Record; @IsOptional() @IsArray() clientRoles?: string[]; } export class UserQueryDto { @IsOptional() page?: number = 1; @IsOptional() limit?: number = 10; @IsOptional() @IsString() search?: string; @IsOptional() @IsBoolean() enabled?: boolean; @IsOptional() @IsBoolean() emailVerified?: boolean; } export class ResetPasswordDto { @IsString() userId: string; @IsString() @MinLength(8) newPassword: string; @IsOptional() @IsBoolean() temporary?: boolean = false; } export class UserResponse { id: string; username: string; email: string; firstName: string; lastName: string; enabled: boolean; emailVerified: boolean; attributes?: Record; clientRoles: string[]; // Rôles client uniquement createdTimestamp: number; constructor(user: any) { this.id = user.id; this.username = user.username; this.email = user.email; this.firstName = user.firstName; this.lastName = user.lastName; this.enabled = user.enabled; this.emailVerified = user.emailVerified; this.attributes = user.attributes; this.clientRoles = user.clientRoles || []; this.createdTimestamp = user.createdTimestamp; } } // Interface pour les réponses paginées export class PaginatedUserResponse { users: UserResponse[]; total: number; page: number; limit: number; totalPages: number; constructor(users: UserResponse[], total: number, page: number, limit: number) { this.users = users; this.total = total; this.page = page; this.limit = limit; this.totalPages = Math.ceil(total / limit); } } export class AssignRolesDto { @IsArray() @IsString({ each: true }) roles: string[]; } // Types pour les rôles client export type ClientRole = 'admin' | 'merchant' | 'support' | 'merchant-admin' | 'merchant-manager' | 'merchant-support'; // Interface pour l'authentification export interface LoginDto { username: string; password: string; } export interface TokenResponse { access_token: string; refresh_token?: string; expires_in: number; token_type: string; scope?: string; }