cal.pub0.org/lib/validations/webhook.ts

44 lines
1017 B
TypeScript
Raw Normal View History

import { z } from "zod";
import { _WebhookModel as Webhook } from "@calcom/prisma/zod";
const schemaWebhookBaseBodyParams = Webhook.pick({
id: true,
userId: true,
eventTypeId: true,
eventTriggers: true,
active: true,
subscriberUrl: true,
payloadTemplate: true,
}).partial();
const schemaWebhookCreateParams = z
.object({
id: z.string(),
subscriberUrl: z.string(),
})
.strict();
export const schemaWebhookCreateBodyParams = schemaWebhookBaseBodyParams.merge(schemaWebhookCreateParams);
const schemaWebhookEditParams = z
.object({
2022-05-19 11:08:44 +00:00
payloadTemplate: z.string().optional(),
eventTriggers: z.string().optional(),
2022-05-19 11:10:27 +00:00
subscriberUrl: z.string().optional(),
})
.strict();
export const schemaWebhookEditBodyParams = schemaWebhookBaseBodyParams.merge(schemaWebhookEditParams);
export const schemaWebhookReadPublic = Webhook.pick({
id: true,
userId: true,
eventTypeId: true,
2022-05-19 11:05:25 +00:00
payloadTemplate: true,
eventTriggers: true,
eventType: true,
app: true,
appId: true,
});