import { autoserializeAs, Command, deserialize, inheritSerialization, serializable, serialize, Validators } from '@my-devkit/core'; import { CreateObjectCommand } from './create-object-command'; import { CreateObjectPropertyCommand } from './create-object-property-command'; import { DeleteObjectCommand } from './delete-object-command'; import { DeleteObjectPropertyCommand } from './delete-object-property-command'; import { UpdateObjectCommand } from './update-object-command'; type CommandType = | CreateObjectCommand | UpdateObjectCommand | CreateObjectPropertyCommand | DeleteObjectPropertyCommand | DeleteObjectCommand; @serializable @inheritSerialization(Command) export class CreateObjectChangeCommand 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 objectId: string = null; @Validators.IsOptional() @Validators.IsString() @autoserializeAs(String) public description: string = null; @Validators.IsArray() public commands: CommandType[] = []; constructor() { super('CreateObjectChangeCommand'); } public static OnDeserialized(instance: CreateObjectChangeCommand, json: Record): void { if (json.commands) { instance.commands = json.commands.map((c: any) => deserialize(c)); } } public static OnSerialized(instance: CreateObjectChangeCommand, json: Record): void { if (instance.commands) { json.commands = instance.commands.map((c) => serialize(c)); } } }