1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import { z } from "zod";
const MAX_WEBHOOK_URL_LENGTH = 500;
const MAX_WEBHOOK_TOKEN_LENGTH = 100;
export const zWebhookEventSchema = z.enum([
"created",
"edited",
"crawled",
"ai tagged",
"deleted",
]);
export type ZWebhookEvent = z.infer<typeof zWebhookEventSchema>;
export const zWebhookSchema = z.object({
id: z.string(),
url: z.string().url(),
events: z.array(zWebhookEventSchema),
hasToken: z.boolean(),
createdAt: z.date(),
});
export type ZWebhook = z.infer<typeof zWebhookSchema>;
export const zNewWebhookSchema = z.object({
url: z.string().max(MAX_WEBHOOK_URL_LENGTH).url(),
events: z.array(zWebhookEventSchema).min(1),
token: z.string().max(MAX_WEBHOOK_TOKEN_LENGTH).optional(),
});
export const zUpdateWebhookSchema = z.object({
webhookId: z.string(),
url: z.string().max(MAX_WEBHOOK_URL_LENGTH).url().optional(),
events: z.array(zWebhookEventSchema).min(1).optional(),
token: z.string().max(MAX_WEBHOOK_TOKEN_LENGTH).nullish(),
});
|