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 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; @Schema({ timestamps: true, collection: 'calendar_external_connections' }) export class ExternalCalendarConnection extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true, index: true }) userId: string; @Prop({ required: true, enum: ['Google', 'Outlook', 'Apple', 'CalDAV'] }) provider: string; @Prop({ required: true }) providerEmail: string; @Prop({ required: true }) accessToken: string; @Prop({ required: true }) refreshToken: string; @Prop({ required: true }) expiresAt: Date; @Prop({ type: MongooseSchema.Types.Mixed, default: {} }) providerMetadata: any; } export const ExternalCalendarConnectionSchema = SchemaFactory.createForClass(ExternalCalendarConnection); ExternalCalendarConnectionSchema.index({ tenantId: 1, userId: 1, provider: 1 }, { unique: true }); @Schema({ timestamps: true, collection: 'calendar_sync_cursors' }) export class CalendarSyncCursor extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true, index: true }) calendarId: string; @Prop({ required: true }) syncCursor: string; @Prop({ required: true }) lastSyncedAt: Date; } export const CalendarSyncCursorSchema = SchemaFactory.createForClass(CalendarSyncCursor); CalendarSyncCursorSchema.index({ tenantId: 1, calendarId: 1 }, { unique: true }); @Schema({ timestamps: true, collection: 'calendar_webhook_subscriptions' }) export class CalendarWebhookSubscription extends Document { @Prop({ required: true, index: true }) tenantId: string; @Prop({ required: true }) provider: string; @Prop({ required: true, unique: true, index: true }) subscriptionId: string; @Prop({ required: true }) resourceUri: string; @Prop({ required: true }) expiration: Date; } export const CalendarWebhookSubscriptionSchema = SchemaFactory.createForClass(CalendarWebhookSubscription); CalendarWebhookSubscriptionSchema.index({ subscriptionId: 1 }, { unique: true }); CalendarWebhookSubscriptionSchema.index({ expiration: 1 }, { expireAfterSeconds: 0 }); // Auto-expire expired webhooks |