Skip to content

The Open Source DocuSign Alternative.

chore: add webhook-call model

Mythie1ec549b8693e
diff --git a/apps/web/src/app/(dashboard)/settings/webhooks/[id]/page.tsx b/apps/web/src/app/(dashboard)/settings/webhooks/[id]/page.tsx
index c451482d4..53ec24827 100644
--- a/apps/web/src/app/(dashboard)/settings/webhooks/[id]/page.tsx
+++ b/apps/web/src/app/(dashboard)/settings/webhooks/[id]/page.tsx
@@ -89,11 +89,13 @@ export default function WebhookPage({ params }: WebhookPageOptions) {
title="Edit webhook"
subtitle="On this page, you can edit the webhook and its settings."
/>
+
{isLoading && (
<div className="absolute inset-0 z-50 flex items-center justify-center bg-white/50">
<Loader className="h-8 w-8 animate-spin text-gray-500" />
</div>
)}
+
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<fieldset
diff --git a/packages/prisma/migrations/20240227015420_add_webhook_call_table/migration.sql b/packages/prisma/migrations/20240227015420_add_webhook_call_table/migration.sql
new file mode 100644
index 000000000..5abac6d6a
--- /dev/null
+++ b/packages/prisma/migrations/20240227015420_add_webhook_call_table/migration.sql
@@ -0,0 +1,20 @@
+-- CreateEnum
+CREATE TYPE "WebhookCallStatus" AS ENUM ('SUCCESS', 'FAILED');
+
+-- CreateTable
+CREATE TABLE "WebhookCall" (
+ "id" TEXT NOT NULL,
+ "status" "WebhookCallStatus" NOT NULL,
+ "url" TEXT NOT NULL,
+ "requestBody" JSONB NOT NULL,
+ "responseCode" INTEGER NOT NULL,
+ "responseHeaders" JSONB,
+ "responseBody" JSONB,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "webhookId" TEXT NOT NULL,
+
+ CONSTRAINT "WebhookCall_pkey" PRIMARY KEY ("id")
+);
+
+-- AddForeignKey
+ALTER TABLE "WebhookCall" ADD CONSTRAINT "WebhookCall_webhookId_fkey" FOREIGN KEY ("webhookId") REFERENCES "Webhook"("id") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma
index bac5de1b7..3dd1a1997 100644
--- a/packages/prisma/schema.prisma
+++ b/packages/prisma/schema.prisma
@@ -115,6 +115,25 @@ model Webhook {
updatedAt DateTime @default(now()) @updatedAt
userId Int
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
+ WebhookCall WebhookCall[]
+}
+
+enum WebhookCallStatus {
+ SUCCESS
+ FAILED
+}
+
+model WebhookCall {
+ id String @id @default(cuid())
+ status WebhookCallStatus
+ url String
+ requestBody Json
+ responseCode Int
+ responseHeaders Json?
+ responseBody Json?
+ createdAt DateTime @default(now())
+ webhookId String
+ webhook Webhook @relation(fields: [webhookId], references: [id], onDelete: Cascade)
}
enum ApiTokenAlgorithm {