Files
calendar/packages/prisma/zod/webhook.ts
T
7e557889b6 feat: support for platform wide webhooks (#14092)
* db migration

* adjusted ui to include `platform` in dropdown for admin webhooks

* adjusted webhook/create.handler for platform

* adjusted `edit.handler` so that only ADMIN can update `platform` webhooks

* update `getWebhooks` for platform wide webhooks

* list platform webhooks if admin

* createFunction refactor

* update subscriberUrlReserved for platform webhooks

* fix delete webhook handler

* fix: added readOnly to WebhookListItem

* fix: admin cannot delete its own webhooks

* fix: ts error

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-03-18 13:42:28 -04:00

39 lines
1.3 KiB
TypeScript
Executable File

import * as z from "zod"
import * as imports from "../zod-utils"
import { WebhookTriggerEvents } from "@prisma/client"
import { CompleteUser, UserModel, CompleteTeam, TeamModel, CompleteEventType, EventTypeModel, CompleteApp, AppModel } from "./index"
export const _WebhookModel = z.object({
id: z.string(),
userId: z.number().int().nullish(),
teamId: z.number().int().nullish(),
eventTypeId: z.number().int().nullish(),
subscriberUrl: z.string().url(),
payloadTemplate: z.string().nullish(),
createdAt: z.date(),
active: z.boolean(),
eventTriggers: z.nativeEnum(WebhookTriggerEvents).array(),
appId: z.string().nullish(),
secret: z.string().nullish(),
platform: z.boolean(),
})
export interface CompleteWebhook extends z.infer<typeof _WebhookModel> {
user?: CompleteUser | null
team?: CompleteTeam | null
eventType?: CompleteEventType | null
app?: CompleteApp | null
}
/**
* 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(),
team: TeamModel.nullish(),
eventType: EventTypeModel.nullish(),
app: AppModel.nullish(),
}))