import mongoose, { type InferSchemaType } from 'mongoose'; const notificationTemplateSchema = new mongoose.Schema( { name: { type: String }, keywords: { type: [String], default: [] }, category: { type: String }, type: { type: String, enum: ['income', 'expense'] }, amountPattern: { type: String } }, { _id: false } ); const notificationChannelSchema = new mongoose.Schema( { packageName: { type: String, required: true, unique: true }, displayName: { type: String, required: true }, enabled: { type: Boolean, default: true }, templates: { type: [notificationTemplateSchema], default: [] } }, { timestamps: true } ); export type NotificationChannelDocument = InferSchemaType; export const NotificationChannelModel = mongoose.models.NotificationChannel ?? mongoose.model('NotificationChannel', notificationChannelSchema);