/**
 * Event DTOs
 *
 * Data Transfer Objects for event subscription and publishing.
 */

import { IsString, IsNotEmpty, IsOptional, IsObject } from "class-validator";

/**
 * DTO for subscribing to an event type
 */
export class SubscribeToEventDto {
  @IsString()
  @IsNotEmpty()
  connectionId!: string;

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

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

/**
 * DTO for unsubscribing from an event type
 */
export class UnsubscribeFromEventDto {
  @IsString()
  @IsNotEmpty()
  connectionId!: string;

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

/**
 * DTO for publishing an event
 */
export class PublishEventDto {
  @IsString()
  @IsNotEmpty()
  eventType!: string;

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

/**
 * DTO for incoming event request
 */
export class IncomingEventDto {
  @IsString()
  @IsNotEmpty()
  messageId!: string;

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

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

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

  @IsNotEmpty()
  timestamp!: number;

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

/**
 * DTO for incoming event acknowledgment
 */
export class IncomingEventAckDto {
  @IsString()
  @IsNotEmpty()
  messageId!: string;

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

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

  @IsNotEmpty()
  received!: boolean;

  @IsOptional()
  @IsString()
  error?: string;

  @IsNotEmpty()
  timestamp!: number;

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