2024-02-09 16:07:33 +02:00
|
|
|
import { z } from 'zod';
|
|
|
|
|
|
|
|
|
|
import { WebhookTriggerEvents } from '@documenso/prisma/client';
|
|
|
|
|
|
2024-02-27 16:56:32 +11:00
|
|
|
export const ZGetTeamWebhooksQuerySchema = z.object({
|
|
|
|
|
teamId: z.number(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type TGetTeamWebhooksQuerySchema = z.infer<typeof ZGetTeamWebhooksQuerySchema>;
|
|
|
|
|
|
|
|
|
|
export const ZCreateWebhookMutationSchema = z.object({
|
2024-02-09 16:07:33 +02:00
|
|
|
webhookUrl: z.string().url(),
|
|
|
|
|
eventTriggers: z
|
|
|
|
|
.array(z.nativeEnum(WebhookTriggerEvents))
|
|
|
|
|
.min(1, { message: 'At least one event trigger is required' }),
|
|
|
|
|
secret: z.string().nullable(),
|
|
|
|
|
enabled: z.boolean(),
|
2024-02-27 16:56:32 +11:00
|
|
|
teamId: z.number().optional(),
|
2024-02-09 16:07:33 +02:00
|
|
|
});
|
|
|
|
|
|
2024-02-27 16:56:32 +11:00
|
|
|
export type TCreateWebhookFormSchema = z.infer<typeof ZCreateWebhookMutationSchema>;
|
2024-02-27 12:13:56 +11:00
|
|
|
|
2024-02-14 14:38:58 +02:00
|
|
|
export const ZGetWebhookByIdQuerySchema = z.object({
|
2024-02-27 12:13:56 +11:00
|
|
|
id: z.string(),
|
2024-02-27 16:56:32 +11:00
|
|
|
teamId: z.number().optional(),
|
2024-02-14 14:38:58 +02:00
|
|
|
});
|
|
|
|
|
|
2024-02-27 12:13:56 +11:00
|
|
|
export type TGetWebhookByIdQuerySchema = z.infer<typeof ZGetWebhookByIdQuerySchema>;
|
|
|
|
|
|
2024-02-27 16:56:32 +11:00
|
|
|
export const ZEditWebhookMutationSchema = ZCreateWebhookMutationSchema.extend({
|
2024-02-27 12:13:56 +11:00
|
|
|
id: z.string(),
|
2024-02-14 14:38:58 +02:00
|
|
|
});
|
|
|
|
|
|
2024-02-27 12:13:56 +11:00
|
|
|
export type TEditWebhookMutationSchema = z.infer<typeof ZEditWebhookMutationSchema>;
|
|
|
|
|
|
2024-02-14 14:38:58 +02:00
|
|
|
export const ZDeleteWebhookMutationSchema = z.object({
|
2024-02-27 12:13:56 +11:00
|
|
|
id: z.string(),
|
2024-02-27 16:56:32 +11:00
|
|
|
teamId: z.number().optional(),
|
2024-02-09 16:28:18 +02:00
|
|
|
});
|
|
|
|
|
|
2024-02-14 14:38:58 +02:00
|
|
|
export type TDeleteWebhookMutationSchema = z.infer<typeof ZDeleteWebhookMutationSchema>;
|