/**
 * Instantly Account Error Trigger Definition
 *
 * Webhook trigger for Instantly email account error events.
 * Uses Instantly's native snake_case format - no transformation needed.
 */

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

/**
 * Instantly account error webhook payload structure
 *
 * Uses snake_case matching Instantly's API. Workflows receive this directly.
 */
export interface InstantlyAccountErrorPayload {
  timestamp: string
  event_type: 'account_error'
  workspace: string
  email_account: string
  error_type?: string
  error_message?: string
}

/**
 * Instantly Account Error Trigger Definition
 *
 * Trigger type: webhook
 * Provider: instantly
 * Event: account_error
 */
export const instantlyAccountErrorTrigger: TriggerDefinition = {
  resourceId: 'trigger-instantly-account-error',
  type: 'trigger',
  triggerType: 'webhook',
  name: 'Instantly Account Error',
  description: 'Webhook fired when an Instantly sending account encounters an error',
  version: '1.0.0',
  status: 'dev',
  webhookPath: '/webhooks/instantly/account-error',
  config: {
    provider: 'instantly',
    event: 'account_error'
  } as WebhookTriggerConfig
}
