import type { ScopeVector } from './scope';
import type { HandleKind, InteractionKind, MessagePartKind } from './enums';

/**
 * The ingest API contract (Data Model §11 OpenAPI `IngestInteractionRequest`).
 * A trusted host app or channel adapter posts this to `/v1/interactions/ingest`.
 */
export interface IngestInteractionRequest {
  scope: ScopeVector;
  channel: {
    type: string; // PORTAL, EMAIL, WHATSAPP, ...
    externalChannelId?: string;
    capabilityContract?: Record<string, unknown>;
  };
  source: {
    handleKind: HandleKind;
    externalId: string;
    displayName?: string;
  };
  kind?: InteractionKind;
  thread?: {
    externalThreadId?: string;
    subject?: string;
  };
  parts: Array<{
    kind: MessagePartKind;
    bodyText?: string;
    contentRef?: string;
    mimeType?: string;
    sizeBytes?: number;
  }>;
  occurredAt: string;
  providerEventId?: string;
  /** Optional trace id to carry onto the created interaction (e.g. from an adapter). */
  traceId?: string;
  metadata?: Record<string, unknown>;
}

export interface IngestInteractionResponse {
  interactionId: string;
  sourceHandleId: string;
  threadId: string;
  state: string;
  next: string[];
}
