import { RepositoryBase, recordInfo, UUID, Flavor, } from "common"; /* * Webhook * * A webhook allows external services to be notified when a recorded call is available */ export type WebhookId = Flavor; export interface HttpHeaders { header: string; value: string; } export interface UnsavedWebhook { name: string; voiceLineId: string; endpointUrl: string; httpMethod: "post" | "put"; headers?: HttpHeaders[]; } export interface SavedWebhook extends UnsavedWebhook { id: WebhookId; createdAt: Date; updatedAt: Date; } export const WebhookRecord = recordInfo( "app_public", "webhooks" ); export class WebhookRecordRepository extends RepositoryBase(WebhookRecord) { async findAllByBackendId( backendType: string, backendId: string ): Promise { return this.db.any( "select * from $1 where backend_type = $2 and backend_id = $3", [this.schemaTable, backendType, backendId] ); } }