import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); const REGIONS = ["AMEA IT", "EMEA IT", "NABU IT", "PH IT", "JP IT"] as const; const YEARS = [2022, 2023, 2024, 2025, 2026]; // Cost item catalog. Each item defines its sub-cost line names and a base cost // per sub-item. Actual seeded sub-costs scale by region + year (below). const ITEMS: { name: string; subs: { name: string; base: number }[] }[] = [ { name: "Cloud Hosting", subs: [ { name: "Compute (VMs)", base: 40000 }, { name: "Storage", base: 18000 }, { name: "Networking / Egress", base: 9000 }, ], }, { name: "Software Licenses", subs: [ { name: "Productivity Suite", base: 22000 }, { name: "Design Tools", base: 8000 }, ], }, { name: "Security Tools", subs: [ { name: "Endpoint Protection", base: 15000 }, { name: "SIEM", base: 20000 }, { name: "Vulnerability Scanning", base: 6000 }, ], }, { name: "Support & Maintenance", subs: [{ name: "Vendor Support Contract", base: 30000 }], }, { name: "Network Infra", subs: [ { name: "Circuits / Bandwidth", base: 25000 }, { name: "Hardware Refresh", base: 12000 }, ], }, ]; // Region weighting so regions differ in magnitude (NABU largest, PH smallest). const REGION_WEIGHT: Record = { "NABU IT": 1.4, "EMEA IT": 1.2, "AMEA IT": 1.0, "JP IT": 0.9, "PH IT": 0.7, }; // TrendAI percentage per region grows over the years (AI adoption ramp). // Value at year Y for a region = base + (Y-2022)*step, clamped. const REGION_AI: Record = { "NABU IT": { base: 12, step: 6 }, "EMEA IT": { base: 10, step: 5 }, "AMEA IT": { base: 8, step: 5 }, "JP IT": { base: 15, step: 4 }, "PH IT": { base: 6, step: 4 }, }; function yearFactor(year: number): number { // Costs grow ~8%/yr off a 2022 base. return Math.pow(1.08, year - 2022); } async function main() { console.log("Clearing existing data..."); await prisma.subCostItem.deleteMany(); await prisma.costItem.deleteMany(); await prisma.trendAiPercentage.deleteMany(); await prisma.year.deleteMany(); console.log("Seeding years..."); for (const year of YEARS) { await prisma.year.create({ data: { year } }); } console.log("Seeding cost items + sub-costs..."); for (const region of REGIONS) { const weight = REGION_WEIGHT[region]; for (const year of YEARS) { const yf = yearFactor(year); for (const item of ITEMS) { await prisma.costItem.create({ data: { name: item.name, region, year, subItems: { create: item.subs.map((s) => ({ name: s.name, subCost: Math.round((s.base * weight * yf) / 100) * 100, })), }, }, }); } } } console.log("Seeding TrendAI percentages..."); for (const region of REGIONS) { const ai = REGION_AI[region]; for (const year of YEARS) { const pct = Math.min(60, ai.base + (year - 2022) * ai.step); await prisma.trendAiPercentage.create({ data: { region, year, percentage: pct }, }); } } const items = await prisma.costItem.count(); const subs = await prisma.subCostItem.count(); const pcts = await prisma.trendAiPercentage.count(); console.log(`Done. CostItems=${items}, SubCostItems=${subs}, TrendAiPercentage=${pcts}`); } main() .catch((e) => { console.error(e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });