64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
|
import { PlanRepository } from '../repositories/plan.repository';
|
|
|
|
const SEED_PLANS = [
|
|
{
|
|
name: 'free',
|
|
displayName: 'Free',
|
|
monthlyPriceUsdCents: 0,
|
|
monthlyPriceCny: 0,
|
|
includedTokensPerMonth: 100_000,
|
|
overageRateCentsPerMToken: 0,
|
|
maxServers: 5,
|
|
maxUsers: 3,
|
|
maxStandingOrders: 10,
|
|
hardLimitPercent: 100,
|
|
trialDays: 0,
|
|
isActive: true,
|
|
},
|
|
{
|
|
name: 'pro',
|
|
displayName: 'Pro',
|
|
monthlyPriceUsdCents: 4999, // $49.99
|
|
monthlyPriceCny: 34900, // ¥349.00
|
|
includedTokensPerMonth: 1_000_000,
|
|
overageRateCentsPerMToken: 800, // $8.00 per MTok
|
|
maxServers: 50,
|
|
maxUsers: 20,
|
|
maxStandingOrders: 100,
|
|
hardLimitPercent: 150,
|
|
trialDays: 14,
|
|
isActive: true,
|
|
},
|
|
{
|
|
name: 'enterprise',
|
|
displayName: 'Enterprise',
|
|
monthlyPriceUsdCents: 19999, // $199.99
|
|
monthlyPriceCny: 139900, // ¥1399.00
|
|
includedTokensPerMonth: 10_000_000,
|
|
overageRateCentsPerMToken: 500, // $5.00 per MTok
|
|
maxServers: -1,
|
|
maxUsers: -1,
|
|
maxStandingOrders: -1,
|
|
hardLimitPercent: 0, // no hard limit
|
|
trialDays: 14,
|
|
isActive: true,
|
|
},
|
|
];
|
|
|
|
@Injectable()
|
|
export class PlanSeedService implements OnModuleInit {
|
|
private readonly logger = new Logger(PlanSeedService.name);
|
|
|
|
constructor(private readonly planRepo: PlanRepository) {}
|
|
|
|
async onModuleInit() {
|
|
try {
|
|
await this.planRepo.upsertSeedPlans(SEED_PLANS);
|
|
this.logger.log('Plan seed completed');
|
|
} catch (err) {
|
|
this.logger.error(`Plan seed failed: ${err.message}`);
|
|
}
|
|
}
|
|
}
|