Files
cloud-host/backend/src/common/enums.ts
T
keyhan 695e05f948 Add managed databases and services with billing-aligned upgrades.
Introduce product types for managed PostgreSQL, Redis, and RabbitMQ with a dedicated dashboard, Helm-only deploy pipeline, external access, snapshots with progress, and prorated resource or storage upgrades matching application billing rules. PVCs use an expandable StorageClass with automatic migration when legacy disks cannot resize in place.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 19:00:09 +03:30

177 lines
4.5 KiB
TypeScript

// Shared enums used across the platform
export enum UserRole {
USER = 'user',
ADMIN = 'admin',
TECHNICAL = 'technical',
SALES = 'sales',
}
export enum TicketDepartment {
TECHNICAL = 'technical',
SALES = 'sales',
}
export enum TicketStatus {
OPEN = 'open',
ANSWERED = 'answered',
WAITING = 'waiting', // waiting for staff reply
CLOSED = 'closed',
}
export enum TicketPriority {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
}
export enum AppRuntime {
NODEJS = 'nodejs',
LARAVEL = 'laravel',
WORDPRESS = 'wordpress',
GO = 'go',
PHP = 'php',
PYTHON = 'python',
DJANGO = 'django',
DOTNET = 'dotnet',
}
export enum DatabaseType {
MYSQL = 'mysql',
POSTGRESQL = 'postgresql',
MONGODB = 'mongodb',
MARIADB = 'mariadb',
NONE = 'none',
}
/** Standalone managed offerings vs full application deploy. */
export enum ProductType {
APPLICATION = 'application',
MANAGED_DATABASE = 'managed_database',
MANAGED_REDIS = 'managed_redis',
MANAGED_RABBITMQ = 'managed_rabbitmq',
}
export function isManagedProductType(productType?: ProductType | string): boolean {
return (
productType === ProductType.MANAGED_DATABASE ||
productType === ProductType.MANAGED_REDIS ||
productType === ProductType.MANAGED_RABBITMQ
);
}
/** Stored in latestImageTag after a managed service is provisioned via Helm (no app image build). */
export const MANAGED_DEPLOY_MARKER = 'helm-managed';
// Optional services that can be attached to an application
export enum OptionalService {
REDIS = 'redis',
RABBITMQ = 'rabbitmq',
ELASTICSEARCH = 'elasticsearch',
}
/** Targets for time-limited external access via temporary NodePort */
export enum ServiceAccessTarget {
DATABASE = 'database',
REDIS = 'redis',
RABBITMQ_AMQP = 'rabbitmq_amqp',
RABBITMQ_MANAGEMENT = 'rabbitmq_management',
}
export enum ServiceAccessGrantStatus {
ACTIVE = 'active',
EXPIRED = 'expired',
REVOKED = 'revoked',
}
export enum DeploymentStatus {
PENDING = 'pending',
BUILDING = 'building',
BUILD_FAILED = 'build_failed',
DEPLOYING = 'deploying',
RUNNING = 'running',
FAILED = 'failed',
CANCELLED = 'cancelled',
STOPPED = 'stopped',
DELETING = 'deleting',
}
export enum ClusterStatus {
ACTIVE = 'active',
INACTIVE = 'inactive',
MAINTENANCE = 'maintenance',
}
export enum BuildStatus {
QUEUED = 'queued',
IN_PROGRESS = 'in_progress',
SUCCESS = 'success',
FAILED = 'failed',
}
export enum BillingCycle {
HOURLY = 'hourly',
MONTHLY = 'monthly',
YEARLY = 'yearly',
}
export enum PricingResourceType {
BASE_FEE = 'base_fee', // Base fee per runtime type
CPU_PER_CORE = 'cpu_per_core', // Price per CPU core
MEMORY_PER_GB = 'memory_per_gb', // Price per GB RAM
STORAGE_PER_GB = 'storage_per_gb', // Price per GB disk
DATABASE_ADDON = 'database_addon', // Price for database addon
REDIS_ADDON = 'redis_addon', // Price for Redis addon
RABBITMQ_ADDON = 'rabbitmq_addon', // Price for RabbitMQ addon
ELASTICSEARCH_ADDON = 'elasticsearch_addon', // Price for Elasticsearch addon
CUSTOM_DOMAIN_ADDON = 'custom_domain_addon', // Price for custom domain with SSL
}
export enum TransactionType {
CHARGE = 'charge', // Top-up / deposit
DEDUCTION = 'deduction', // Payment for service
REFUND = 'refund', // Refund
GATEWAY_PAYMENT = 'gateway_payment', // Direct payment through a gateway
}
export enum InvoiceStatus {
DRAFT = 'draft',
ISSUED = 'issued',
PARTIALLY_PAID = 'partially_paid',
PAID = 'paid',
VOID = 'void',
FAILED = 'failed',
}
export enum PaymentMethod {
WALLET = 'wallet',
GATEWAY = 'gateway',
MIXED = 'mixed',
}
export enum InvoiceReason {
DEPLOY = 'deploy',
RENEWAL = 'renewal',
UPGRADE = 'upgrade',
WALLET_TOPUP = 'wallet_topup',
MANUAL = 'manual',
}
// ── Custom Domain ────────────────────────────────────
export enum CustomDomainStatus {
NONE = 'none',
PENDING_DNS = 'pending_dns',
VERIFIED = 'verified',
}
// ── Application Lifecycle ─────────────────────────────
export enum AppLifecycleStatus {
ACTIVE = 'active', // Paid & running
SUSPENDED = 'suspended', // Plan expired, pods scaled to 0, data retained
PENDING_DELETION = 'pending_deletion', // Grace period — will be deleted if no payment
DOCKED = 'docked', // User removed service; data retained until plan expires
DELETED = 'deleted', // Fully removed from K8s and DB
}