/**
 * Instantly Campaign Completed Trigger Definition
 *
 * Webhook trigger for Instantly campaign completion events.
 * Uses Instantly's native snake_case format - no transformation needed.
 */

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

/**
 * Instantly campaign completed webhook payload structure
 *
 * Uses snake_case matching Instantly's API. Workflows receive this directly.
 */
export interface InstantlyCampaignCompletedPayload {
  timestamp: string
  event_type: 'campaign_completed'
  workspace: string
  campaign_id: string
  campaign_name?: string
  total_leads?: number
  total_sent?: number
}

/**
 * Instantly Campaign Completed Trigger Definition
 *
 * Trigger type: webhook
 * Provider: instantly
 * Event: campaign_completed
 */
export const instantlyCampaignCompletedTrigger: TriggerDefinition = {
  resourceId: 'trigger-instantly-campaign-completed',
  type: 'trigger',
  triggerType: 'webhook',
  name: 'Instantly Campaign Completed',
  description: 'Webhook fired when an Instantly email campaign finishes sending to all leads',
  version: '1.0.0',
  status: 'dev',
  webhookPath: '/webhooks/instantly/campaign-completed',
  config: {
    provider: 'instantly',
    event: 'campaign_completed'
  } as WebhookTriggerConfig
}
