This commit is contained in:
pradeepkumar
2026-01-24 03:33:54 +05:30
parent 3df8ea067a
commit 710803a3ec
14 changed files with 1099 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
import { IsUUID, IsOptional, IsBoolean, IsInt } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class AssignSectionDto {
@ApiProperty({ description: 'Agent Type ID to assign this section to' })
@IsUUID()
agentTypeId: string;
@ApiPropertyOptional({ description: 'Sort order for this agent type', default: 0 })
@IsOptional()
@IsInt()
sortOrder?: number;
@ApiPropertyOptional({ description: 'Whether this section is required for this agent type', default: false })
@IsOptional()
@IsBoolean()
isRequired?: boolean;
}
export class UpdateAssignmentDto {
@ApiPropertyOptional({ description: 'Sort order for this agent type' })
@IsOptional()
@IsInt()
sortOrder?: number;
@ApiPropertyOptional({ description: 'Whether this section is required for this agent type' })
@IsOptional()
@IsBoolean()
isRequired?: boolean;
}

View File

@@ -0,0 +1,113 @@
import {
IsString,
IsOptional,
IsBoolean,
IsInt,
IsUUID,
IsEnum,
IsObject,
IsArray,
MinLength,
MaxLength,
ValidateNested,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { FieldType } from '@prisma/client';
export class FieldOptionDto {
@ApiProperty({ description: 'Option value' })
@IsString()
value: string;
@ApiProperty({ description: 'Option display label' })
@IsString()
label: string;
@ApiPropertyOptional({ description: 'Sort order for this option' })
@IsOptional()
@IsInt()
sortOrder?: number;
}
export class RangeConfigDto {
@ApiProperty({ description: 'Minimum value' })
min: number;
@ApiProperty({ description: 'Maximum value' })
max: number;
@ApiPropertyOptional({ description: 'Step increment', default: 1 })
@IsOptional()
step?: number;
}
export class CreateFieldDto {
@ApiProperty({ description: 'Section ID this field belongs to' })
@IsUUID()
sectionId: string;
@ApiProperty({ description: 'Field name', example: 'Years in Business' })
@IsString()
@MinLength(2)
@MaxLength(100)
name: string;
@ApiProperty({ description: 'Field type', enum: FieldType })
@IsEnum(FieldType)
fieldType: FieldType;
@ApiPropertyOptional({ description: 'Help text for the field' })
@IsOptional()
@IsString()
@MaxLength(500)
description?: string;
@ApiPropertyOptional({ description: 'Placeholder text' })
@IsOptional()
@IsString()
@MaxLength(200)
placeholder?: string;
@ApiPropertyOptional({ description: 'Default value (JSON string for complex types)' })
@IsOptional()
@IsString()
defaultValue?: string;
@ApiPropertyOptional({ description: 'Sort order within the section', default: 0 })
@IsOptional()
@IsInt()
sortOrder?: number;
@ApiPropertyOptional({ description: 'Whether this field is active', default: true })
@IsOptional()
@IsBoolean()
isActive?: boolean;
@ApiPropertyOptional({ description: 'Whether this field is required', default: false })
@IsOptional()
@IsBoolean()
isRequired?: boolean;
@ApiPropertyOptional({ description: 'Validation rules (JSON object)' })
@IsOptional()
@IsObject()
validation?: Record<string, any>;
@ApiPropertyOptional({ description: 'Options for SELECT, RADIO, MULTI_SELECT, CHECKBOX_GROUP', type: [FieldOptionDto] })
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => FieldOptionDto)
options?: FieldOptionDto[];
@ApiPropertyOptional({ description: 'Configuration for RANGE fields', type: RangeConfigDto })
@IsOptional()
@IsObject()
rangeConfig?: RangeConfigDto;
@ApiPropertyOptional({ description: 'UI configuration (JSON object)' })
@IsOptional()
@IsObject()
uiConfig?: Record<string, any>;
}

View File

@@ -0,0 +1,36 @@
import { IsString, IsOptional, IsBoolean, IsInt, MinLength, MaxLength } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class CreateSectionDto {
@ApiProperty({ description: 'Section name', example: 'Location' })
@IsString()
@MinLength(2)
@MaxLength(100)
name: string;
@ApiPropertyOptional({ description: 'Section description' })
@IsOptional()
@IsString()
@MaxLength(500)
description?: string;
@ApiPropertyOptional({ description: 'Icon URL or icon name' })
@IsOptional()
@IsString()
icon?: string;
@ApiPropertyOptional({ description: 'Sort order for display', default: 0 })
@IsOptional()
@IsInt()
sortOrder?: number;
@ApiPropertyOptional({ description: 'Whether this section is active', default: true })
@IsOptional()
@IsBoolean()
isActive?: boolean;
@ApiPropertyOptional({ description: 'Whether this section applies to all agent types', default: false })
@IsOptional()
@IsBoolean()
isGlobal?: boolean;
}

View File

@@ -0,0 +1,5 @@
export * from './create-section.dto';
export * from './update-section.dto';
export * from './create-field.dto';
export * from './update-field.dto';
export * from './assign-section.dto';

View File

@@ -0,0 +1,4 @@
import { PartialType, OmitType } from '@nestjs/swagger';
import { CreateFieldDto } from './create-field.dto';
export class UpdateFieldDto extends PartialType(OmitType(CreateFieldDto, ['sectionId'] as const)) {}

View File

@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateSectionDto } from './create-section.dto';
export class UpdateSectionDto extends PartialType(CreateSectionDto) {}