chore: add webhook-call model

This commit is contained in:
Mythie
2024-02-27 12:54:37 +11:00
parent c2daa964c0
commit 1ec549b869
3 changed files with 41 additions and 0 deletions

View File

@ -89,11 +89,13 @@ export default function WebhookPage({ params }: WebhookPageOptions) {
title="Edit webhook" title="Edit webhook"
subtitle="On this page, you can edit the webhook and its settings." subtitle="On this page, you can edit the webhook and its settings."
/> />
{isLoading && ( {isLoading && (
<div className="absolute inset-0 z-50 flex items-center justify-center bg-white/50"> <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" /> <Loader className="h-8 w-8 animate-spin text-gray-500" />
</div> </div>
)} )}
<Form {...form}> <Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}> <form onSubmit={form.handleSubmit(onSubmit)}>
<fieldset <fieldset

View File

@ -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;

View File

@ -115,6 +115,25 @@ model Webhook {
updatedAt DateTime @default(now()) @updatedAt updatedAt DateTime @default(now()) @updatedAt
userId Int userId Int
User User @relation(fields: [userId], references: [id], onDelete: Cascade) 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 { enum ApiTokenAlgorithm {