@@ -14,34 +14,34 @@ export interface IModlServer extends Document {
1414 emailVerificationToken ?: string ;
1515
1616 // Provisioning & Status
17- provisioningStatus : 'pending ' | 'in-progress ' | 'completed ' | 'failed ' ;
17+ provisioningStatus : 'PENDING ' | 'IN_PROGRESS ' | 'COMPLETED ' | 'FAILED ' ;
1818 provisioningNotes ?: string ;
1919 provisioningSignInToken ?: string ;
2020 provisioningSignInTokenExpiresAt ?: Date ;
2121
2222 // Plan & Billing
23- plan : 'free ' | 'premium ' ;
24- subscription_status : 'active ' | 'canceled ' | 'past_due ' | 'inactive ' | 'trialing ' | 'incomplete ' | 'incomplete_expired ' | 'unpaid ' | 'paused ' ;
25- current_period_start ?: Date ;
26- current_period_end ?: Date ;
27- stripe_customer_id ?: string ;
28- stripe_subscription_id ?: string ;
23+ plan : 'FREE ' | 'PREMIUM ' ;
24+ subscriptionStatus ? : 'ACTIVE ' | 'CANCELED ' | 'PAST_DUE ' | 'INACTIVE ' | 'TRIALING ' | 'INCOMPLETE ' | 'INCOMPLETE_EXPIRED ' | 'UNPAID ' | 'PAUSED ' ;
25+ currentPeriodStart ?: Date ;
26+ currentPeriodEnd ?: Date ;
27+ stripeCustomerId ?: string ;
28+ stripeSubscriptionId ?: string ;
2929
3030 // Usage Tracking & Billing
31- cdn_usage_current_period ?: number ; // GB used in current billing period
32- ai_requests_current_period ?: number ; // AI requests used in current billing period
33- usage_billing_enabled ?: boolean ; // Whether to charge for overages
34- usage_billing_updated_at ?: Date ;
31+ cdnUsageCurrentPeriod ?: number ; // GB used in current billing period
32+ aiRequestsCurrentPeriod ?: number ; // AI requests used in current billing period
33+ usageBillingEnabled ?: boolean ; // Whether to charge for overages
34+ usageBillingUpdatedAt ?: Date ;
3535
3636 // Migration Settings
3737 migrationFileSizeLimit ?: number ; // Custom migration file size limit in bytes (optional, defaults to 5GB)
3838
3939 // Custom Domain
40- customDomain_override ?: string ;
41- customDomain_status ?: 'pending ' | 'active ' | 'error ' | 'verifying ' ;
42- customDomain_lastChecked ?: Date ;
43- customDomain_error ?: string ;
44- customDomain_cloudflareId ?: string ;
40+ customDomainOverride ?: string ;
41+ customDomainStatus ?: 'PENDING ' | 'ACTIVE ' | 'ERROR ' | 'VERIFYING ' ;
42+ customDomainLastChecked ?: Date ;
43+ customDomainError ?: string ;
44+ customDomainCloudflareId ?: string ;
4545
4646 // Analytics/Stats from modl-admin
4747 userCount : number ;
@@ -63,32 +63,32 @@ export const ModlServerSchema = new Schema<IModlServer>({
6363 emailVerified : { type : Boolean , default : false , index : true } ,
6464 emailVerificationToken : { type : String , unique : true , sparse : true } ,
6565
66- provisioningStatus : { type : String , enum : [ 'pending ' , 'in-progress ' , 'completed ' , 'failed ' ] , default : 'pending ' , index : true } ,
66+ provisioningStatus : { type : String , enum : [ 'PENDING ' , 'IN_PROGRESS ' , 'COMPLETED ' , 'FAILED ' ] , default : 'PENDING ' , index : true } ,
6767 provisioningNotes : { type : String } ,
6868 provisioningSignInToken : { type : String , unique : true , sparse : true } ,
6969 provisioningSignInTokenExpiresAt : { type : Date } ,
7070
71- plan : { type : String , enum : [ 'free ' , 'premium ' ] , default : 'free ' , index : true } ,
72- subscription_status : { type : String , enum : [ 'active ' , 'canceled ' , 'past_due ' , 'inactive ' , 'trialing ' , 'incomplete ' , 'incomplete_expired ' , 'unpaid ' , 'paused ' ] , default : 'inactive ' , index : true } ,
73- current_period_start : { type : Date , sparse : true } ,
74- current_period_end : { type : Date , sparse : true } ,
75- stripe_customer_id : { type : String , unique : true , sparse : true } ,
76- stripe_subscription_id : { type : String , unique : true , sparse : true } ,
71+ plan : { type : String , enum : [ 'FREE ' , 'PREMIUM ' ] , default : 'FREE ' , index : true } ,
72+ subscriptionStatus : { type : String , enum : [ 'ACTIVE ' , 'CANCELED ' , 'PAST_DUE ' , 'INACTIVE ' , 'TRIALING ' , 'INCOMPLETE ' , 'INCOMPLETE_EXPIRED ' , 'UNPAID ' , 'PAUSED ' ] , default : 'INACTIVE ' , index : true } ,
73+ currentPeriodStart : { type : Date , sparse : true } ,
74+ currentPeriodEnd : { type : Date , sparse : true } ,
75+ stripeCustomerId : { type : String , unique : true , sparse : true } ,
76+ stripeSubscriptionId : { type : String , unique : true , sparse : true } ,
7777
7878 // Usage Tracking & Billing
79- cdn_usage_current_period : { type : Number , default : 0 } ,
80- ai_requests_current_period : { type : Number , default : 0 } ,
81- usage_billing_enabled : { type : Boolean , default : false } ,
82- usage_billing_updated_at : { type : Date , sparse : true } ,
79+ cdnUsageCurrentPeriod : { type : Number , default : 0 } ,
80+ aiRequestsCurrentPeriod : { type : Number , default : 0 } ,
81+ usageBillingEnabled : { type : Boolean , default : false } ,
82+ usageBillingUpdatedAt : { type : Date , sparse : true } ,
8383
8484 // Migration Settings
8585 migrationFileSizeLimit : { type : Number , sparse : true } ,
8686
87- customDomain_override : { type : String , unique : true , sparse : true } ,
88- customDomain_status : { type : String , enum : [ 'pending ' , 'active ' , 'error ' , 'verifying ' ] , sparse : true } ,
89- customDomain_lastChecked : { type : Date , sparse : true } ,
90- customDomain_error : { type : String , sparse : true } ,
91- customDomain_cloudflareId : { type : String , unique : true , sparse : true } ,
87+ customDomainOverride : { type : String , unique : true , sparse : true } ,
88+ customDomainStatus : { type : String , enum : [ 'PENDING ' , 'ACTIVE ' , 'ERROR ' , 'VERIFYING ' ] , sparse : true } ,
89+ customDomainLastChecked : { type : Date , sparse : true } ,
90+ customDomainError : { type : String , sparse : true } ,
91+ customDomainCloudflareId : { type : String , unique : true , sparse : true } ,
9292
9393 userCount : { type : Number , default : 0 } ,
9494 ticketCount : { type : Number , default : 0 } ,
@@ -104,11 +104,11 @@ export const ModlServerSchema = new Schema<IModlServer>({
104104
105105// Indexes for common queries
106106ModlServerSchema . index ( { adminEmail : 1 } ) ;
107- ModlServerSchema . index ( { plan : 1 , subscription_status : 1 } ) ;
107+ ModlServerSchema . index ( { plan : 1 , subscriptionStatus : 1 } ) ;
108108ModlServerSchema . index ( { provisioningStatus : 1 , emailVerified : 1 } ) ;
109109ModlServerSchema . index ( { serverName : 'text' , customDomain : 'text' , adminEmail : 'text' } ) ;
110110
111111// Only create the model on server-side (Node.js environment)
112112export const ModlServerModel = typeof window === 'undefined' && mongoose ?. models
113113 ? ( mongoose . models . ModlServer || model < IModlServer > ( 'ModlServer' , ModlServerSchema ) )
114- : null ;
114+ : null ;
0 commit comments