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 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; @Schema({ timestamps: true, collection: 'subscription_plans' }) export class SubscriptionPlan extends Document { @Prop({ required: true, unique: true, index: true }) key: string; // starter, growth, business, enterprise @Prop({ required: true }) name: string; @Prop({ required: true, default: 'trial' }) type: string; // trial, paid, partner, custom @Prop({ default: true }) isActive: boolean; @Prop({ default: 1 }) version: number; } export const SubscriptionPlanSchema = SchemaFactory.createForClass(SubscriptionPlan); @Schema({ timestamps: true, collection: 'subscription_plan_versions' }) export class SubscriptionPlanVersion extends Document { @Prop({ required: true, index: true }) planId: string; @Prop({ required: true }) version: number; @Prop({ required: true, default: () => new Date() }) effectiveFrom: Date; @Prop({ type: [String], default: [] }) allowedModuleKeys: string[]; @Prop({ type: MongooseSchema.Types.Mixed, default: {} }) limits: any; // { maxUsers, maxEmployees, maxBranches, maxStorageBytes, maxApiRequestsMonthly } @Prop({ default: 14 }) trialDurationDays: number; @Prop({ default: 7 }) gracePeriodDays: number; } export const SubscriptionPlanVersionSchema = SchemaFactory.createForClass( SubscriptionPlanVersion, ); @Schema({ timestamps: true, collection: 'plan_prices' }) export class PlanPrice extends Document { @Prop({ required: true, index: true }) planVersionId: string; @Prop({ required: true }) billingCycle: string; // monthly, quarterly, yearly @Prop({ required: true }) amount: number; // in minor units (cents / paise) @Prop({ required: true, default: 'INR' }) currency: string; // ISO Currency @Prop({ default: true }) isActive: boolean; } export const PlanPriceSchema = SchemaFactory.createForClass(PlanPrice); PlanPriceSchema.index({ planVersionId: 1, billingCycle: 1, currency: 1 }); |