first commit
هذا الالتزام موجود في:
10
src/modules/users/dto/admin-disable-user.dto.ts
Normal file
10
src/modules/users/dto/admin-disable-user.dto.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsOptional, IsString, Length } from 'class-validator';
|
||||
|
||||
export class AdminDisableUserDto {
|
||||
@ApiPropertyOptional({ example: 'Violation of community guidelines' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 300)
|
||||
reason?: string;
|
||||
}
|
||||
27
src/modules/users/dto/create-admin.dto.ts
Normal file
27
src/modules/users/dto/create-admin.dto.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { IsEmail, IsNotEmpty, IsString, MaxLength, MinLength } from 'class-validator';
|
||||
|
||||
export class CreateAdminDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(80)
|
||||
name!: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MinLength(3)
|
||||
@MaxLength(30)
|
||||
username!: string;
|
||||
|
||||
@IsEmail()
|
||||
email!: string;
|
||||
|
||||
@IsString()
|
||||
@MinLength(8)
|
||||
@MaxLength(128)
|
||||
password!: string;
|
||||
|
||||
@IsString()
|
||||
@MinLength(8)
|
||||
@MaxLength(128)
|
||||
confirmPassword!: string;
|
||||
}
|
||||
115
src/modules/users/dto/create-user.dto.ts
Normal file
115
src/modules/users/dto/create-user.dto.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
IsEmail,
|
||||
IsEnum,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUrl,
|
||||
Length,
|
||||
Max,
|
||||
Matches,
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
import { ExperienceLevel } from '../../../common/enums/experience-level.enum';
|
||||
import { MusicRole } from '../../../common/enums/music-role.enum';
|
||||
|
||||
export class CreateUserDto {
|
||||
@ApiProperty({ example: 'John Doe' })
|
||||
@IsString()
|
||||
@Length(2, 80)
|
||||
name!: string;
|
||||
|
||||
@ApiProperty({ required: false, example: 'Artist One' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 80)
|
||||
stageName?: string;
|
||||
|
||||
@ApiProperty({ example: 'john_doe' })
|
||||
@IsString()
|
||||
@Length(3, 30)
|
||||
@Matches(/^[a-zA-Z0-9_.]+$/, { message: 'username can contain letters, numbers, _ and .' })
|
||||
username!: string;
|
||||
|
||||
@ApiProperty({ example: 'john@example.com' })
|
||||
@IsEmail()
|
||||
email!: string;
|
||||
|
||||
@ApiProperty({ minLength: 8, example: 'StrongPass123!' })
|
||||
@IsString()
|
||||
@Length(8, 64)
|
||||
password!: string;
|
||||
|
||||
@ApiProperty({ required: false, maxLength: 160 })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 160)
|
||||
bio?: string;
|
||||
|
||||
@ApiProperty({ required: false, example: 'https://cdn.example.com/avatar.jpg' })
|
||||
@IsOptional()
|
||||
@IsUrl({ require_tld: false })
|
||||
avatar?: string;
|
||||
|
||||
@ApiProperty({ required: false, example: 'Riyadh, Saudi Arabia' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 120)
|
||||
location?: string;
|
||||
|
||||
@ApiProperty({ required: false, example: 24.7136, minimum: -90, maximum: 90 })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(-90)
|
||||
@Max(90)
|
||||
latitude?: number;
|
||||
|
||||
@ApiProperty({ required: false, example: 46.6753, minimum: -180, maximum: 180 })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(-180)
|
||||
@Max(180)
|
||||
longitude?: number;
|
||||
|
||||
@ApiProperty({ required: false, default: false })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isPrivate?: boolean;
|
||||
|
||||
@ApiProperty({ required: false, default: false })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isVerified?: boolean;
|
||||
|
||||
@ApiProperty({ required: false, enum: MusicRole, isArray: true })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsEnum(MusicRole, { each: true })
|
||||
musicRoles?: MusicRole[];
|
||||
|
||||
@ApiProperty({ required: false, enum: ExperienceLevel, example: ExperienceLevel.BEGINNER })
|
||||
@IsOptional()
|
||||
@IsEnum(ExperienceLevel)
|
||||
experienceLevel?: ExperienceLevel;
|
||||
|
||||
@ApiProperty({ required: false, type: [String], example: ['Tarab', 'Pop'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
musicGenres?: string[];
|
||||
|
||||
@ApiProperty({ required: false, type: [String], example: ['Oud', 'Piano'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
favoriteInstruments?: string[];
|
||||
|
||||
@ApiProperty({ required: false, type: [String], example: ['Bayati', 'Rast'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
favoriteMaqamat?: string[];
|
||||
}
|
||||
35
src/modules/users/dto/music-setup.dto.ts
Normal file
35
src/modules/users/dto/music-setup.dto.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsArray, IsEnum, IsOptional, IsString } from 'class-validator';
|
||||
import { ExperienceLevel } from '../../../common/enums/experience-level.enum';
|
||||
import { MusicRole } from '../../../common/enums/music-role.enum';
|
||||
|
||||
export class MusicSetupDto {
|
||||
@ApiPropertyOptional({ enum: MusicRole, isArray: true })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsEnum(MusicRole, { each: true })
|
||||
musicRoles?: MusicRole[];
|
||||
|
||||
@ApiPropertyOptional({ type: [String], example: ['Tarab', 'Pop'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
musicGenres?: string[];
|
||||
|
||||
@ApiPropertyOptional({ enum: ExperienceLevel, example: ExperienceLevel.BEGINNER })
|
||||
@IsOptional()
|
||||
@IsEnum(ExperienceLevel)
|
||||
experienceLevel?: ExperienceLevel;
|
||||
|
||||
@ApiPropertyOptional({ type: [String], example: ['Oud', 'Piano'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
favoriteInstruments?: string[];
|
||||
|
||||
@ApiPropertyOptional({ type: [String], example: ['Bayati', 'Rast'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
favoriteMaqamat?: string[];
|
||||
}
|
||||
44
src/modules/users/dto/profile-setup.dto.ts
Normal file
44
src/modules/users/dto/profile-setup.dto.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
import { IsNumber, IsOptional, IsString, IsUrl, Length, Max, Min } from 'class-validator';
|
||||
|
||||
export class ProfileSetupDto {
|
||||
@ApiPropertyOptional({ example: 'Artist One' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(1, 80)
|
||||
stageName?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'https://cdn.example.com/avatar.jpg' })
|
||||
@IsOptional()
|
||||
@IsUrl({ require_tld: false })
|
||||
avatar?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '<27><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>', maxLength: 150 })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 150)
|
||||
bio?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Riyadh, Saudi Arabia' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 120)
|
||||
location?: string;
|
||||
|
||||
@ApiProperty({ example: 24.7136, minimum: -90, maximum: 90 })
|
||||
@Transform(({ value }) => (typeof value === 'string' ? Number.parseFloat(value) : value))
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(-90)
|
||||
@Max(90)
|
||||
latitude!: number;
|
||||
|
||||
@ApiProperty({ example: 46.6753, minimum: -180, maximum: 180 })
|
||||
@Transform(({ value }) => (typeof value === 'string' ? Number.parseFloat(value) : value))
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(-180)
|
||||
@Max(180)
|
||||
longitude!: number;
|
||||
}
|
||||
7
src/modules/users/dto/update-user-role.dto.ts
Normal file
7
src/modules/users/dto/update-user-role.dto.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { IsEnum } from 'class-validator';
|
||||
import { UserRole } from '../../../common/enums/user-role.enum';
|
||||
|
||||
export class UpdateUserRoleDto {
|
||||
@IsEnum(UserRole)
|
||||
role!: UserRole;
|
||||
}
|
||||
69
src/modules/users/dto/update-user.dto.ts
Normal file
69
src/modules/users/dto/update-user.dto.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsArray, IsBoolean, IsEnum, IsOptional, IsString, IsUrl, Length } from 'class-validator';
|
||||
import { ExperienceLevel } from '../../../common/enums/experience-level.enum';
|
||||
import { MusicRole } from '../../../common/enums/music-role.enum';
|
||||
|
||||
export class UpdateUserDto {
|
||||
@ApiPropertyOptional({ example: 'John Doe' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(2, 80)
|
||||
name?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Artist One' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 80)
|
||||
stageName?: string;
|
||||
|
||||
@ApiPropertyOptional({ maxLength: 160 })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 160)
|
||||
bio?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'https://cdn.example.com/avatar.jpg' })
|
||||
@IsOptional()
|
||||
@IsUrl({ require_tld: false })
|
||||
avatar?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: 'Riyadh, Saudi Arabia' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@Length(0, 120)
|
||||
location?: string;
|
||||
|
||||
@ApiPropertyOptional({ default: false })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isPrivate?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ enum: MusicRole, isArray: true })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsEnum(MusicRole, { each: true })
|
||||
musicRoles?: MusicRole[];
|
||||
|
||||
@ApiPropertyOptional({ enum: ExperienceLevel })
|
||||
@IsOptional()
|
||||
@IsEnum(ExperienceLevel)
|
||||
experienceLevel?: ExperienceLevel;
|
||||
|
||||
@ApiPropertyOptional({ type: [String], example: ['Tarab', 'Pop'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
musicGenres?: string[];
|
||||
|
||||
@ApiPropertyOptional({ type: [String], example: ['Oud', 'Piano'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
favoriteInstruments?: string[];
|
||||
|
||||
@ApiPropertyOptional({ type: [String], example: ['Bayati', 'Rast'] })
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
favoriteMaqamat?: string[];
|
||||
}
|
||||
15
src/modules/users/dto/user-query.dto.ts
Normal file
15
src/modules/users/dto/user-query.dto.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsOptional, IsString } from 'class-validator';
|
||||
import { PaginationQueryDto } from '../../../common/dto/pagination-query.dto';
|
||||
|
||||
export class UserQueryDto extends PaginationQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Search by name or username' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
q?: string;
|
||||
|
||||
@ApiPropertyOptional({ default: false })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isVerified?: boolean;
|
||||
}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم