Files
permit-api/src/notification/notification.schema.ts
2025-04-03 12:38:24 +05:30

62 lines
1.5 KiB
TypeScript

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<typeof createNotificationInput>;
export type UpdateNotificationInput = z.infer<typeof updateNotificationInput>;
export const { schemas: notificationSchemas, $ref: $notification } =
buildJsonSchemas(
{
createNotificationInput,
updateNotificationInput,
pageQueryParams,
},
{ $id: "notification" }
);