2022-05-11 13:57:00 +00:00
|
|
|
import { z } from "zod";
|
|
|
|
|
2022-03-30 15:37:51 +00:00
|
|
|
import { _WebhookModel as Webhook } from "@calcom/prisma/zod";
|
2022-03-26 23:58:22 +00:00
|
|
|
|
2022-05-11 13:57:00 +00:00
|
|
|
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({
|
|
|
|
uid: z.string().optional(),
|
|
|
|
title: z.string().optional(),
|
|
|
|
startTime: z.date().optional(),
|
|
|
|
endTime: z.date().optional(),
|
|
|
|
})
|
|
|
|
.strict();
|
|
|
|
|
|
|
|
export const schemaWebhookEditBodyParams = schemaWebhookBaseBodyParams.merge(schemaWebhookEditParams);
|
2022-03-30 15:37:51 +00:00
|
|
|
|
2022-05-11 13:57:00 +00:00
|
|
|
export const schemaWebhookReadPublic = Webhook.pick({
|
|
|
|
id: true,
|
|
|
|
userId: true,
|
|
|
|
eventTypeId: true,
|
|
|
|
uid: true,
|
|
|
|
title: true,
|
|
|
|
startTime: true,
|
|
|
|
endTime: true,
|
|
|
|
});
|