// Inboxes module types aligned with core targetSchema
import type { inboxesEntriesInsertOpenAPISchema } from "@folo-services/drizzle"
import type { InboxOpenApiSchema } from "@folo-services/shared"
import type z from "zod"

import type {
  EmptyResponse,
  SerializedModel,
  StructuredSuccessResponse,
} from "../../types"

// Target schema used by core responses
export type InboxSchema = SerializedModel<InboxOpenApiSchema>

// Inbox get query
export interface InboxGetQuery {
  handle: string
}

export type InboxGetResponse = StructuredSuccessResponse<InboxSchema>

// Inbox list response (array, not paginated)
export type InboxListResponse = StructuredSuccessResponse<InboxSchema[]>

// Inbox create request/response
export interface InboxCreateRequest {
  handle: string
  title?: string
}

export type InboxCreateResponse = EmptyResponse

// Inbox update request/response
export interface InboxUpdateRequest {
  handle: string
  title: string
}

export type InboxUpdateResponse = EmptyResponse

// Inbox delete request/response
export interface InboxDeleteRequest {
  handle: string
}

export type InboxDeleteResponse = EmptyResponse

export type InboxEmailRequest = {
  from: {
    name?: string
    address?: string
  }
  to: {
    address: string
  }
  subject?: string
  messageId: string
  date: string
  html?: string
}
export type InboxEmailResponse = EmptyResponse

export type InboxWebhookRequest = z.infer<
  typeof inboxesEntriesInsertOpenAPISchema
>
export type InboxWebhookResponse = EmptyResponse
