/**
 * Query DTOs
 *
 * Data Transfer Objects for query message operations.
 */

import { IsString, IsOptional, IsObject, IsNotEmpty } from "class-validator";
import type { QueryMessage } from "../types/message.types";

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

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

  @IsOptional()
  @IsObject()
  context?: Record<string, unknown>;
}

/**
 * DTO for incoming query request from remote instance
 */
export class IncomingQueryDto implements QueryMessage {
  @IsString()
  @IsNotEmpty()
  messageId!: string;

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

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

  @IsOptional()
  @IsObject()
  context?: Record<string, unknown>;

  @IsNotEmpty()
  timestamp!: number;

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