Files
CRM_Montzar/apps/api/src/custom-fields/dto.ts
T
MahdiandCursor 8e1e94a439 feat(notes): let organizations define their own note fields
The note form was fixed. Owners can add fields and each note keeps those values.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-01 15:38:05 +03:30

109 lines
1.7 KiB
TypeScript

import { Type } from 'class-transformer';
import {
IsArray,
IsBoolean,
IsEnum,
IsInt,
IsOptional,
IsString,
MaxLength,
Min,
MinLength,
} from 'class-validator';
export enum CustomFieldEntityDto {
person = 'person',
company = 'company',
deal = 'deal',
note = 'note',
}
export enum CustomFieldTypeDto {
text = 'text',
number = 'number',
date = 'date',
boolean = 'boolean',
select = 'select',
}
export class ListCustomFieldsQueryDto {
@IsOptional()
@IsEnum(CustomFieldEntityDto)
entityType?: CustomFieldEntityDto;
@IsOptional()
@Type(() => Boolean)
@IsBoolean()
activeOnly?: boolean;
}
export class CreateCustomFieldDto {
@IsEnum(CustomFieldEntityDto)
entityType!: CustomFieldEntityDto;
@IsString()
@MinLength(1)
@MaxLength(120)
label!: string;
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(64)
key?: string;
@IsOptional()
@IsEnum(CustomFieldTypeDto)
fieldType?: CustomFieldTypeDto;
@IsOptional()
@IsArray()
@IsString({ each: true })
options?: string[];
@IsOptional()
@IsBoolean()
required?: boolean;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(0)
position?: number;
@IsOptional()
@IsBoolean()
isActive?: boolean;
}
export class UpdateCustomFieldDto {
@IsOptional()
@IsString()
@MinLength(1)
@MaxLength(120)
label?: string;
@IsOptional()
@IsEnum(CustomFieldTypeDto)
fieldType?: CustomFieldTypeDto;
@IsOptional()
@IsArray()
@IsString({ each: true })
options?: string[];
@IsOptional()
@IsBoolean()
required?: boolean;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(0)
position?: number;
@IsOptional()
@IsBoolean()
isActive?: boolean;
}