import { buildJsonSchemas } from "fastify-zod"; import mongoose from "mongoose"; import { TypeOf, z } from "zod"; import { pageQueryParams } from "../pagination"; const notificationSchema = new mongoose.Schema({ pid: { type: String, unique: true, }, permitId: String, tenantId: String, permitNumber: String, link: String, status: String, accelaStatus: String, changes: Object, county: Object, client: mongoose.Types.ObjectId, clientData: Object, createdAt: Date, updatedAt: Date, }); export const notificationFields = Object.keys(notificationSchema.paths).filter( (path) => path !== "__v" ); export const notificationModel = mongoose.model( "notification", notificationSchema ); const createNotificationInput = z.object({ permitId: z.string(), permitNumber: z.string(), link: z.string(), status: z.string(), accelaStatus: z.string(), changes: z.object({}).passthrough(), county: z.object({}).passthrough(), client: z.string(), clientData: z.object({}).passthrough(), }); const updateNotificationInput = z.object({ status: z.string(), }); export type CreateNotificationInput = z.infer; export type UpdateNotificationInput = z.infer; export const { schemas: notificationSchemas, $ref: $notification } = buildJsonSchemas( { createNotificationInput, updateNotificationInput, pageQueryParams, }, { $id: "notification" } );