All files / db/entities mail-event.entity.ts

100% Statements 21/21
100% Branches 0/0
100% Functions 4/4
100% Lines 21/21

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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 575x   5x             5x   5x   5x     5x         5x   15x 5x     5x     5x 10x 5x   10x 5x           5x       5x   5x 5x     5x     5x    
import { Severity, prop } from '@typegoose/typegoose'
import { ObjectId } from 'mongoose'
import {
  MailTemplateContent,
  MailTemplates,
} from '../../mail/interfaces/mail.interface'
 
class MailContent {
  @prop()
  subject: string
  @prop()
  contentRaw?: string
  @prop()
  contentTemplate?: MailTemplates
  // Allow mixed to support various template forms
  @prop({ allowMixed: Severity.ALLOW })
  templateContent?: MailTemplateContent
}
 
class MailRecipient {
  @prop()
  recipient: string
 
  @prop({ type: () => [String] })
  cc?: string[]
 
  @prop()
  from?: string
}
 
export class MailData {
  @prop({ type: () => MailRecipient, _id: false })
  recipient: MailRecipient
 
  @prop({ type: () => MailContent, _id: false })
  content: MailContent
}
 
/**
 * @description Entity with all user information
 */
export class MailEvent {
  _id: ObjectId
 
  @prop({ required: true })
  scheduledAt: Date
 
  @prop({ required: true, type: () => MailData, _id: false })
  content: MailData
 
  @prop({ required: true })
  hasBeenSent: boolean
 
  @prop({ required: true })
  hasBeenRescheduled: boolean
}