refactor: simplify pricing tables to USD-only

- Remove KRW pricing calculations from all pricing tables
- Simplify pricing table to store only wholesale USD prices
- Simplify anvil_pricing to store only retail USD prices
- Remove KRW environment variables (KRW_EXCHANGE_RATE, KRW_MARGIN_RATE)
- Remove KRW functions from constants.ts
- Update GPU/G8/VPU pricing repositories to match
- Add Anvil tables and repositories for branded product support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-25 21:16:25 +09:00
parent a2133ae5c9
commit 9f3d3a245a
21 changed files with 1952 additions and 197 deletions

View File

@@ -88,8 +88,6 @@ export interface Pricing {
region_id: number;
hourly_price: number;
monthly_price: number;
hourly_price_krw: number | null;
monthly_price_krw: number | null;
currency: string;
available: number; // SQLite boolean (0/1)
created_at: string;
@@ -128,8 +126,6 @@ export interface GpuPricing {
region_id: number;
hourly_price: number;
monthly_price: number;
hourly_price_krw: number | null;
monthly_price_krw: number | null;
currency: string;
available: number; // SQLite boolean (0/1)
created_at: string;
@@ -157,8 +153,6 @@ export interface G8Pricing {
region_id: number;
hourly_price: number;
monthly_price: number;
hourly_price_krw: number | null;
monthly_price_krw: number | null;
currency: string;
available: number; // SQLite boolean (0/1)
created_at: string;
@@ -187,8 +181,6 @@ export interface VpuPricing {
region_id: number;
hourly_price: number;
monthly_price: number;
hourly_price_krw: number | null;
monthly_price_krw: number | null;
currency: string;
available: number; // SQLite boolean (0/1)
created_at: string;
@@ -202,13 +194,13 @@ export interface VpuPricing {
export type ProviderInput = Omit<Provider, 'id' | 'created_at' | 'updated_at'>;
export type RegionInput = Omit<Region, 'id' | 'created_at' | 'updated_at'>;
export type InstanceTypeInput = Omit<InstanceType, 'id' | 'created_at' | 'updated_at'>;
export type PricingInput = Omit<Pricing, 'id' | 'created_at' | 'updated_at' | 'hourly_price_krw' | 'monthly_price_krw'>;
export type PricingInput = Omit<Pricing, 'id' | 'created_at' | 'updated_at'>;
export type GpuInstanceInput = Omit<GpuInstance, 'id' | 'created_at' | 'updated_at'>;
export type GpuPricingInput = Omit<GpuPricing, 'id' | 'created_at' | 'updated_at' | 'hourly_price_krw' | 'monthly_price_krw'>;
export type GpuPricingInput = Omit<GpuPricing, 'id' | 'created_at' | 'updated_at' | 'hourly_price_krw' | 'monthly_price_krw' | 'hourly_price_retail' | 'monthly_price_retail'>;
export type G8InstanceInput = Omit<G8Instance, 'id' | 'created_at' | 'updated_at'>;
export type G8PricingInput = Omit<G8Pricing, 'id' | 'created_at' | 'updated_at' | 'hourly_price_krw' | 'monthly_price_krw'>;
export type G8PricingInput = Omit<G8Pricing, 'id' | 'created_at' | 'updated_at' | 'hourly_price_krw' | 'monthly_price_krw' | 'hourly_price_retail' | 'monthly_price_retail'>;
export type VpuInstanceInput = Omit<VpuInstance, 'id' | 'created_at' | 'updated_at'>;
export type VpuPricingInput = Omit<VpuPricing, 'id' | 'created_at' | 'updated_at' | 'hourly_price_krw' | 'monthly_price_krw'>;
export type VpuPricingInput = Omit<VpuPricing, 'id' | 'created_at' | 'updated_at' | 'hourly_price_krw' | 'monthly_price_krw' | 'hourly_price_retail' | 'monthly_price_retail'>;
// ============================================================
// Error Types
@@ -452,12 +444,6 @@ export interface Env {
LOG_LEVEL?: string;
/** CORS origin for Access-Control-Allow-Origin header (default: '*') */
CORS_ORIGIN?: string;
/** KRW exchange rate (USD to KRW conversion, default: 1450) */
KRW_EXCHANGE_RATE?: string;
/** KRW VAT rate multiplier (default: 1.1 for 10% VAT) */
KRW_VAT_RATE?: string;
/** KRW markup rate multiplier (default: 1.1 for 10% markup) */
KRW_MARKUP_RATE?: string;
}
// ============================================================
@@ -610,3 +596,77 @@ export interface RecommendationResponse {
/** List of recommended instances (sorted by match score) */
recommendations: InstanceRecommendation[];
}
// ============================================================
// Anvil Product Types
// ============================================================
/**
* Anvil Region - Anvil-branded regional datacenters
*/
export interface AnvilRegion {
id: number;
name: string; // "anvil-tyo1", "anvil-sel1"
display_name: string; // "Tokyo 1", "Seoul 1"
country_code: string; // "JP", "KR"
source_provider: string; // "linode", "vultr"
source_region_code: string; // "jp-tyo-3", "nrt"
source_region_id: number; // FK to regions.id
active: number; // SQLite boolean (0/1)
created_at: string;
updated_at: string;
}
/**
* Anvil Instance - Anvil-branded instance specifications
*/
export interface AnvilInstance {
id: number;
name: string; // "anvil-1g-1c"
display_name: string; // "Basic 1GB"
category: 'vm' | 'gpu' | 'g8' | 'vpu';
vcpus: number;
memory_gb: number;
disk_gb: number;
transfer_tb: number | null;
network_gbps: number | null;
gpu_model: string | null; // GPU-specific
gpu_vram_gb: number | null; // GPU-specific
active: number; // SQLite boolean (0/1)
created_at: string;
updated_at: string;
}
/**
* Anvil Pricing - Anvil retail pricing (USD only)
*/
export interface AnvilPricing {
id: number;
anvil_instance_id: number;
anvil_region_id: number;
hourly_price: number; // Retail price (USD)
monthly_price: number; // Retail price (USD)
source_instance_id: number | null; // FK to source tables
created_at: string;
updated_at: string;
}
/**
* Anvil Transfer Pricing - Data transfer pricing per region (USD only)
*/
export interface AnvilTransferPricing {
id: number;
anvil_region_id: number;
price_per_gb: number; // USD/GB
created_at: string;
updated_at: string;
}
// ============================================================
// Anvil Input Types (auto-derived, excluding id and timestamps)
// ============================================================
export type AnvilRegionInput = Omit<AnvilRegion, 'id' | 'created_at' | 'updated_at'>;
export type AnvilInstanceInput = Omit<AnvilInstance, 'id' | 'created_at' | 'updated_at'>;
export type AnvilPricingInput = Omit<AnvilPricing, 'id' | 'created_at' | 'updated_at'>;
export type AnvilTransferPricingInput = Omit<AnvilTransferPricing, 'id' | 'created_at' | 'updated_at'>;