Files
calendar/packages/features/tasker/tasks/triggerNoShow/schema.ts
T
395381ddcc feat: automatic no show (#16727)
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: zomars <zomars@me.com>
2024-10-10 10:57:04 -07:00

58 lines
1.5 KiB
TypeScript

import { z } from "zod";
import { TIME_UNIT } from "@calcom/features/ee/workflows/lib/constants";
import { WebhookTriggerEvents } from "@calcom/prisma/enums";
const commonSchema = z.object({
triggerEvent: z.enum([
WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW,
WebhookTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW,
]),
bookingId: z.number(),
});
export const ZWebhook = z.object({
id: z.string(),
subscriberUrl: z.string().url(),
appId: z.string().nullable(),
secret: z.string().nullable(),
time: z.number(),
timeUnit: z.enum(TIME_UNIT),
eventTriggers: z.array(z.string()),
payloadTemplate: z.string().nullable(),
});
export type TWebhook = z.infer<typeof ZWebhook>;
export const triggerNoShowPayloadSchema = z.object({
total_count: z.number(),
data: z.array(
z
.object({
id: z.string(),
room: z.string(),
start_time: z.number(),
duration: z.number(),
max_participants: z.number(),
participants: z.array(
z.object({
user_id: z.string().nullable(),
participant_id: z.string(),
user_name: z.string(),
join_time: z.number(),
duration: z.number(),
})
),
})
.passthrough()
),
});
export type TTriggerNoShowPayloadSchema = z.infer<typeof triggerNoShowPayloadSchema>;
export const ZSendNoShowWebhookPayloadSchema = commonSchema.extend({
webhook: ZWebhook,
});
export type TSendNoShowWebhookPayloadSchema = z.infer<typeof ZSendNoShowWebhookPayloadSchema>;