import { IsIn, IsObject, IsOptional, IsString } from 'class-validator'; import { WIDGET_TYPES } from '@tessera/shared'; /** * DTO for creating a new widget instance on one dashboard tab. * * quick-260922-m1h: `widgetType` wird gegen `WIDGET_TYPES` aus * `@tessera/shared` geprüft — dieselbe Liste, aus der das Frontend seine * Registry und seinen Katalog ableitet. Vorher stand die Liste hier ein * zweites Mal; vergaß man einen Eintrag, lehnte die API eine im Katalog * angebotene Kachel mit 400 ab. * * quick-260923-ad9: `dashboardId` selects the tab — the service verifies * ownership before writing (`assertOwnedDashboard`). * * config is optional and defaults to {} on the model. */ export class CreateWidgetDto { @IsString() dashboardId!: string; @IsString() @IsIn([...WIDGET_TYPES]) widgetType!: string; @IsOptional() @IsObject() config?: Record; }