/**
 * Webhook Repository Port
 *
 * Defines the interface for Webhook persistence operations.
 * This is a secondary port (output port) in hexagonal architecture.
 */

import { Webhook, WebhookEvent } from '../../entities/webhook.entity';

export const WEBHOOK_REPOSITORY = 'WebhookRepository';

export interface WebhookFilters {
  organizationId?: string;
  status?: string[];
  event?: WebhookEvent;
}

export interface WebhookRepository {
  /**
   * Save a webhook entity
   */
  save(webhook: Webhook): Promise<void>;

  /**
   * Find webhook by ID
   */
  findById(id: string): Promise<Webhook | null>;

  /**
   * Find all webhooks for an organization
   */
  findByOrganization(organizationId: string): Promise<Webhook[]>;

  /**
   * Find active webhooks by event and organization
   */
  findActiveByEvent(event: WebhookEvent, organizationId: string): Promise<Webhook[]>;

  /**
   * Find webhooks by filters
   */
  findByFilters(filters: WebhookFilters): Promise<Webhook[]>;

  /**
   * Delete a webhook
   */
  delete(id: string): Promise<void>;

  /**
   * Count webhooks for an organization
   */
  countByOrganization(organizationId: string): Promise<number>;
}
