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