/**
 * Command DTOs
 *
 * Data Transfer Objects for command message operations.
 */

import { IsString, IsObject, IsNotEmpty, IsNumber } from "class-validator";
import type { CommandMessage } from "../types/message.types";
import { SanitizeObject } from "../../common/decorators/sanitize.decorator";

/**
 * DTO for sending a command to a remote instance
 */
export class SendCommandDto {
  @IsString()
  @IsNotEmpty()
  connectionId!: string;

  @IsString()
  @IsNotEmpty()
  commandType!: string;

  @IsObject()
  @IsNotEmpty()
  @SanitizeObject()
  payload!: Record<string, unknown>;
}

/**
 * DTO for incoming command request from remote instance
 */
export class IncomingCommandDto implements CommandMessage {
  @IsString()
  @IsNotEmpty()
  messageId!: string;

  @IsString()
  @IsNotEmpty()
  instanceId!: string;

  @IsString()
  @IsNotEmpty()
  commandType!: string;

  @IsObject()
  @IsNotEmpty()
  @SanitizeObject()
  payload!: Record<string, unknown>;

  @IsNumber()
  @IsNotEmpty()
  timestamp!: number;

  @IsString()
  @IsNotEmpty()
  signature!: string;
}
