/**
 * Instantly Email Bounced Trigger Definition
 *
 * Webhook trigger for Instantly email bounce events.
 * Uses Instantly's native snake_case format - no transformation needed.
 */

import type { TriggerDefinition, WebhookTriggerConfig } from '../../../../platform/registry/types'

/**
 * Instantly email bounced webhook payload structure
 *
 * Uses snake_case matching Instantly's API. Workflows receive this directly.
 */
export interface InstantlyEmailBouncedPayload {
  timestamp: string
  event_type: 'email_bounced'
  workspace: string
  campaign_id: string
  campaign_name?: string
  lead_email: string
  email_account: string
  bounce_type?: string
  bounce_reason?: string
  step?: number
  variant?: number
}

/**
 * Instantly Email Bounced Trigger Definition
 *
 * Trigger type: webhook
 * Provider: instantly
 * Event: email_bounced
 */
export const instantlyEmailBouncedTrigger: TriggerDefinition = {
  resourceId: 'trigger-instantly-email-bounced',
  type: 'trigger',
  triggerType: 'webhook',
  name: 'Instantly Email Bounced',
  description: 'Webhook fired when an email sent from an Instantly campaign bounces',
  version: '1.0.0',
  status: 'dev',
  webhookPath: '/webhooks/instantly/email-bounced',
  config: {
    provider: 'instantly',
    event: 'email_bounced'
  } as WebhookTriggerConfig
}
