2022-03-02 16:24:57 +00:00
|
|
|
import * as z from "zod"
|
|
|
|
import * as imports from "../zod-utils"
|
|
|
|
import { WebhookTriggerEvents } from "@prisma/client"
|
2022-05-03 23:16:59 +00:00
|
|
|
import { CompleteUser, UserModel, CompleteEventType, EventTypeModel, CompleteApp, AppModel } from "./index"
|
2022-03-02 16:24:57 +00:00
|
|
|
|
|
|
|
export const _WebhookModel = z.object({
|
|
|
|
id: z.string(),
|
|
|
|
userId: z.number().int().nullish(),
|
|
|
|
eventTypeId: z.number().int().nullish(),
|
|
|
|
subscriberUrl: z.string(),
|
|
|
|
payloadTemplate: z.string().nullish(),
|
|
|
|
createdAt: z.date(),
|
|
|
|
active: z.boolean(),
|
|
|
|
eventTriggers: z.nativeEnum(WebhookTriggerEvents).array(),
|
2022-05-03 23:16:59 +00:00
|
|
|
appId: z.string().nullish(),
|
2022-03-02 16:24:57 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
export interface CompleteWebhook extends z.infer<typeof _WebhookModel> {
|
|
|
|
user?: CompleteUser | null
|
|
|
|
eventType?: CompleteEventType | null
|
2022-05-03 23:16:59 +00:00
|
|
|
app?: CompleteApp | null
|
2022-03-02 16:24:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WebhookModel contains all relations on your model in addition to the scalars
|
|
|
|
*
|
|
|
|
* NOTE: Lazy required in case of potential circular dependencies within schema
|
|
|
|
*/
|
|
|
|
export const WebhookModel: z.ZodSchema<CompleteWebhook> = z.lazy(() => _WebhookModel.extend({
|
|
|
|
user: UserModel.nullish(),
|
|
|
|
eventType: EventTypeModel.nullish(),
|
2022-05-03 23:16:59 +00:00
|
|
|
app: AppModel.nullish(),
|
2022-03-02 16:24:57 +00:00
|
|
|
}))
|