import { IsArray, IsBoolean, IsIn, IsInt, IsOptional, IsString, Matches, MaxLength, Min, MinLength, } from 'class-validator'; import { Type } from 'class-transformer'; export const BUSINESS_STATUSES = [ 'draft', 'pending_review', 'published', 'hidden', 'rejected', ] as const; export type BusinessStatus = (typeof BUSINESS_STATUSES)[number]; export class CreateBusinessDto { @IsString() meshkeeBusinessId!: string; @IsString() @Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/) @MaxLength(100) slug!: string; /** Written to Meshkee only (not stored in marketplace DB). */ @IsOptional() @IsString() @MaxLength(255) name?: string; /** Meshkee business_category ids — written to Meshkee only. */ @IsOptional() @IsArray() @IsString({ each: true }) meshkeeCategoryIds?: string[]; @IsOptional() @IsIn(BUSINESS_STATUSES) status?: BusinessStatus; @IsOptional() @IsBoolean() isFeatured?: boolean; @IsOptional() @Type(() => Number) @IsInt() sortWeight?: number; } /** Public shop signup: creates a NEW Meshkee business + IranBay marketplace listing. */ export class RegisterShopDto { @IsString() @MaxLength(255) name!: string; @IsOptional() @IsString() @Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/) @MaxLength(100) slug?: string; @IsOptional() @IsString() @MaxLength(5000) about?: string; @IsOptional() @IsArray() @IsString({ each: true }) meshkeeCategoryIds?: string[]; /** * Account password confirmation — Meshkee create-owner updates password for * existing cells; must match the registrant’s current password. */ @IsString() @MinLength(8) ownerPassword!: string; } export class UpdateBusinessDto { @IsOptional() @IsString() @Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/) @MaxLength(100) slug?: string; /** Written to Meshkee only. */ @IsOptional() @IsString() @MaxLength(255) name?: string; /** Meshkee business_category ids — written to Meshkee only. */ @IsOptional() @IsArray() @IsString({ each: true }) meshkeeCategoryIds?: string[]; @IsOptional() @IsIn(BUSINESS_STATUSES) status?: BusinessStatus; @IsOptional() @IsBoolean() isFeatured?: boolean; @IsOptional() @Type(() => Number) @IsInt() sortWeight?: number; } export class ListBusinessesDto { @IsOptional() @IsString() q?: string; @IsOptional() @IsIn([...BUSINESS_STATUSES, 'all']) status?: BusinessStatus | 'all'; @IsOptional() @IsBoolean() @Type(() => Boolean) featured?: boolean; @IsOptional() @Type(() => Number) @IsInt() @Min(1) page?: number; @IsOptional() @Type(() => Number) @IsInt() @Min(1) limit?: number; }