import { autoserializeAs, Command, deserialize, inheritSerialization, serializable, serialize, Validators } from '@my-devkit/core'; import { CreateRouteCommand } from './create-route-command'; import { CreateRouteQueryParamCommand } from './create-route-query-param-command'; import { DeleteRouteCommand } from './delete-route-command'; import { DeleteRouteQueryParamCommand } from './delete-route-query-param-command'; import { UpdateRouteCommand } from './update-route-command'; type CommandType = | CreateRouteCommand | CreateRouteQueryParamCommand | UpdateRouteCommand | DeleteRouteQueryParamCommand | DeleteRouteCommand; @serializable @inheritSerialization(Command) export class CreateRouteChangeCommand extends Command { @Validators.IsNotEmpty() @Validators.IsString() @autoserializeAs(String) public projectId: string = null; @Validators.IsNotEmpty() @Validators.IsString() @autoserializeAs(String) public storyId: string = null; @Validators.IsNotEmpty() @Validators.IsString() @autoserializeAs(String) public sectionId: string = null; @Validators.IsOptional() @Validators.IsString() @autoserializeAs(String) public routeId: string = null; @Validators.IsArray() public commands: CommandType[] = []; @Validators.IsOptional() @Validators.IsString() @autoserializeAs(String) public description: string = null; constructor() { super('CreateRouteChangeCommand'); } public static OnDeserialized(instance: CreateRouteChangeCommand, json: Record): void { if (json.commands) { instance.commands = json.commands.map((c: any) => deserialize(c)); } } public static OnSerialized(instance: CreateRouteChangeCommand, json: Record): void { if (instance.commands) { json.commands = instance.commands.map((c) => serialize(c)); } } }