All files / src/platform/calendar/schemas calendar-config.schema.ts

0% Statements 0/62
0% Branches 0/4
100% Functions 0/0
0% Lines 0/54

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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147                                                                                                                                                                                                                                                                                                     
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'calendar_platform_configurations' })
export class CalendarPlatformConfiguration extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ default: true })
  calendarPlatformEnabled: boolean;
 
  @Prop({ default: 'UTC' })
  defaultTimezone: string;
 
  @Prop({ default: 'en' })
  defaultLocale: string;
 
  @Prop({ default: 1 }) // 1 = Monday
  defaultWeekStartDay: number;
 
  @Prop({ default: '09:00' })
  defaultWorkingDayStart: string;
 
  @Prop({ default: '17:00' })
  defaultWorkingDayEnd: string;
 
  @Prop({ default: 30 })
  defaultMeetingDurationMinutes: number;
 
  @Prop({ default: 15 })
  defaultReminderMinutes: number;
 
  @Prop({ default: false })
  allowDoubleBooking: boolean;
 
  @Prop({ default: true })
  externalSyncEnabled: boolean;
 
  @Prop({ default: true })
  icsImportEnabled: boolean;
 
  @Prop({ default: true })
  icsExportEnabled: boolean;
 
  @Prop({ default: false })
  bookingApprovalEnabled: boolean;
 
  @Prop({ default: true })
  recurringEventsEnabled: boolean;
 
  @Prop({ default: true })
  conflictDetectionEnabled: boolean;
 
  @Prop({ default: true })
  tentativeBookingsEnabled: boolean;
 
  @Prop({ default: true })
  resourceBookingEnabled: boolean;
 
  @Prop({ default: true })
  privateEventsEnabled: boolean;
 
  @Prop({ default: true })
  calendarSharingEnabled: boolean;
 
  @Prop({ default: 365 })
  eventRetentionDays: number;
 
  @Prop({ default: 30 })
  synchronizationWindowPastDays: number;
 
  @Prop({ default: 90 })
  synchronizationWindowFutureDays: number;
 
  @Prop({ default: 3 })
  syncFailureRetryLimit: number;
 
  @Prop({ default: 'GoogleMeet' })
  defaultVideoProvider: string; // 'GoogleMeet' | 'MSTeams' | 'Zoom'
 
  @Prop({ default: 'Google' })
  defaultCalendarProvider: string; // 'Google' | 'Outlook' | 'CalDAV'
}
 
export const CalendarPlatformConfigurationSchema = SchemaFactory.createForClass(CalendarPlatformConfiguration);
CalendarPlatformConfigurationSchema.index({ tenantId: 1 }, { unique: true });
 
@Schema({ timestamps: true, collection: 'calendar_platform_config_versions' })
export class CalendarPlatformConfigurationVersion extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true })
  version: number;
 
  @Prop({ type: MongooseSchema.Types.Mixed, required: true })
  configData: any;
}
 
export const CalendarPlatformConfigurationVersionSchema = SchemaFactory.createForClass(CalendarPlatformConfigurationVersion);
CalendarPlatformConfigurationVersionSchema.index({ tenantId: 1, version: 1 }, { unique: true });
 
@Schema({ timestamps: true, collection: 'calendar_tenant_preferences' })
export class CalendarTenantPreference extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ type: MongooseSchema.Types.Map, of: String, default: {} })
  preferences: Map<string, string>;
}
 
export const CalendarTenantPreferenceSchema = SchemaFactory.createForClass(CalendarTenantPreference);
CalendarTenantPreferenceSchema.index({ tenantId: 1 }, { unique: true });
 
@Schema({ timestamps: true, collection: 'calendar_user_preferences' })
export class CalendarUserPreference extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true, index: true })
  userId: string;
 
  @Prop({ default: 'UTC' })
  timezone: string;
 
  @Prop({ default: 'en' })
  locale: string;
 
  @Prop({ default: 15 })
  defaultReminderMinutes: number;
 
  @Prop({ type: [String], default: ['email', 'in-app'] })
  reminderChannels: string[];
 
  @Prop({ default: '09:00' })
  workingHoursStart: string;
 
  @Prop({ default: '17:00' })
  workingHoursEnd: string;
 
  @Prop({ type: [Number], default: [1, 2, 3, 4, 5] }) // Mon-Fri
  workingDays: number[];
}
 
export const CalendarUserPreferenceSchema = SchemaFactory.createForClass(CalendarUserPreference);
CalendarUserPreferenceSchema.index({ tenantId: 1, userId: 1 }, { unique: true });