Add prepaid resource credits with prorated deploy billing.

When users delete an app before plan expiry, remaining resources become credits for a new deploy. The deploy calculator shows covered vs additional charges, prices optional services correctly, and prorates extras to days left on the credit.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
keyhan
2026-05-15 17:37:44 +03:30
parent 35dd771f63
commit 5239e8aa94
17 changed files with 1021 additions and 96 deletions
+38
View File
@@ -144,6 +144,25 @@ export type DeploymentStatus =
export type AppLifecycleStatus = 'active' | 'suspended' | 'pending_deletion' | 'deleted';
export interface ResourceCredit {
id: string;
sourceAppName?: string;
runtime: string;
databaseType: string;
cpuLimit: string;
memoryLimit: string;
replicas: number;
dbStorageSize?: string;
appStorageSize?: string;
enableRedis: boolean;
enableRabbitmq: boolean;
enableElasticsearch: boolean;
billingCycle?: string;
expiresAt: string;
remainingMs: number;
remainingLabel: string;
}
export interface Cluster {
id: string;
name: string;
@@ -399,6 +418,25 @@ export interface CostBreakdown {
breakdown: { label: string; hourly: number; monthly: number; yearly: number }[];
}
export interface DeployExtraChargeLine {
label: string;
amount: number;
fullPeriodAmount?: number;
}
export interface DeployCostPreview extends CostBreakdown {
cycle: BillingCycle;
fullAmount: number;
amountDue: number;
coveredAmount: number;
waivedAmount: number;
extrasBreakdown: DeployExtraChargeLine[];
creditApplied: ResourceCredit | null;
prepaidCreditUsed: boolean;
prorateRemainingDays?: number;
proratePeriodDays?: number;
}
// ─── Snapshot / Rollback types ──────────────────────
export type SnapshotType = 'pre_deploy' | 'manual';