mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-03 19:40:08 -05:00
chore: adds webhook types (#4606)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com>
This commit is contained in:
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
import { Webhook } from "@prisma/client";
|
||||
import { revalidateTag } from "next/cache";
|
||||
|
||||
interface RevalidateProps {
|
||||
id?: string;
|
||||
environmentId?: string;
|
||||
source?: Webhook["source"];
|
||||
}
|
||||
|
||||
export const webhookCache = {
|
||||
tag: {
|
||||
byId(id: string) {
|
||||
return `webhooks-${id}`;
|
||||
},
|
||||
byEnvironmentId(environmentId: string) {
|
||||
return `environments-${environmentId}-webhooks`;
|
||||
},
|
||||
byEnvironmentIdAndSource(environmentId: string, source?: Webhook["source"]) {
|
||||
return `environments-${environmentId}-sources-${source}-webhooks`;
|
||||
},
|
||||
},
|
||||
revalidate({ id, environmentId, source }: RevalidateProps): void {
|
||||
if (id) {
|
||||
revalidateTag(this.tag.byId(id));
|
||||
}
|
||||
|
||||
if (environmentId) {
|
||||
revalidateTag(this.tag.byEnvironmentId(environmentId));
|
||||
}
|
||||
|
||||
if (environmentId && source) {
|
||||
revalidateTag(this.tag.byEnvironmentIdAndSource(environmentId, source));
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user