added ID
parent
92b011214c
commit
5e3b51c621
|
@ -1,15 +1,16 @@
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { _WebhookModel as Webhook } from "@calcom/prisma/zod";
|
import { _WebhookModel as Webhook } from "@calcom/prisma/zod";
|
||||||
// import { WebhookTriggerEvents } from "@calcom/prisma/client";
|
import { WebhookTriggerEvents } from "@calcom/prisma/client";
|
||||||
|
|
||||||
// export const WEBHOOK_TRIGGER_EVENTS = [
|
export const WEBHOOK_TRIGGER_EVENTS = [
|
||||||
// WebhookTriggerEvents.BOOKING_CANCELLED,
|
WebhookTriggerEvents.BOOKING_CANCELLED,
|
||||||
// WebhookTriggerEvents.BOOKING_CREATED,
|
WebhookTriggerEvents.BOOKING_CREATED,
|
||||||
// WebhookTriggerEvents.BOOKING_RESCHEDULED,
|
WebhookTriggerEvents.BOOKING_RESCHEDULED,
|
||||||
// ] as ["BOOKING_CANCELLED", "BOOKING_CREATED", "BOOKING_RESCHEDULED"];
|
] as ["BOOKING_CANCELLED", "BOOKING_CREATED", "BOOKING_RESCHEDULED"];
|
||||||
|
|
||||||
const schemaWebhookBaseBodyParams = Webhook.pick({
|
const schemaWebhookBaseBodyParams = Webhook.pick({
|
||||||
|
id: true,
|
||||||
userId: true,
|
userId: true,
|
||||||
eventTypeId: true,
|
eventTypeId: true,
|
||||||
eventTriggers: true,
|
eventTriggers: true,
|
||||||
|
@ -20,12 +21,13 @@ const schemaWebhookBaseBodyParams = Webhook.pick({
|
||||||
|
|
||||||
export const schemaWebhookCreateParams = z
|
export const schemaWebhookCreateParams = z
|
||||||
.object({
|
.object({
|
||||||
|
id: z.string(),
|
||||||
subscriberUrl: z.string().url(),
|
subscriberUrl: z.string().url(),
|
||||||
eventTriggers: z.any(),
|
eventTriggers: z.enum(WEBHOOK_TRIGGER_EVENTS).array(),
|
||||||
active: z.boolean(),
|
active: z.boolean(),
|
||||||
// payloadTemplate: z.string().optional().nullable(),
|
payloadTemplate: z.string().optional().nullable(),
|
||||||
// eventTypeId: z.number().optional(),
|
eventTypeId: z.number().optional(),
|
||||||
// appId: z.string().optional().nullable(),
|
appId: z.string().optional().nullable(),
|
||||||
})
|
})
|
||||||
.strict();
|
.strict();
|
||||||
|
|
||||||
|
@ -36,8 +38,7 @@ export const schemaWebhookCreateBodyParams = schemaWebhookBaseBodyParams.merge(
|
||||||
export const schemaWebhookEditBodyParams = schemaWebhookBaseBodyParams.merge(
|
export const schemaWebhookEditBodyParams = schemaWebhookBaseBodyParams.merge(
|
||||||
z.object({
|
z.object({
|
||||||
payloadTemplate: z.string().optional(),
|
payloadTemplate: z.string().optional(),
|
||||||
/** @todo: don't use 'any' here and validate eventTriggers proper */
|
eventTriggers: z.enum(WEBHOOK_TRIGGER_EVENTS).array().optional(),
|
||||||
eventTriggers: z.any().optional(),
|
|
||||||
subscriberUrl: z.string().optional(),
|
subscriberUrl: z.string().optional(),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue