All files / src/platform/calendar/schemas reminder.schema.ts

0% Statements 0/16
100% Branches 0/0
100% Functions 0/0
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                                               
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'calendar_reminder_definitions' })
export class ReminderDefinition extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true, unique: true, index: true })
  reminderId: string;
 
  @Prop({ required: true, index: true })
  eventId: string; // Links to calendar_events
 
  @Prop({ required: true })
  triggerMinutesBefore: number; // e.g. 15, 60, 1440 (24h), or negative for after event
 
  @Prop({ type: [String], default: ['email', 'in-app'] })
  deliveryChannels: string[]; // 'email' | 'in-app' | 'push' | 'sms' | 'whatsapp'
 
  @Prop({ default: 'pending', enum: ['pending', 'sent', 'failed', 'suppressed'] })
  status: string;
 
  @Prop()
  recipientId?: string; // If specific recipient, else defaults to event participants
}
 
export const ReminderDefinitionSchema = SchemaFactory.createForClass(ReminderDefinition);
ReminderDefinitionSchema.index({ tenantId: 1, reminderId: 1 }, { unique: true });
ReminderDefinitionSchema.index({ tenantId: 1, eventId: 1 });
ReminderDefinitionSchema.index({ status: 1 });