// @bun
import{CodeBlock as a,InstallCommand as r}from"@contractspec/lib.design-system";import o from"@contractspec/lib.ui-link";import{ChevronRight as i}from"lucide-react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function l(){return t("div",{className:"space-y-8",children:[t("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"Cost Tracking Library"}),t("p",{className:"text-lg text-muted-foreground",children:[e("code",{children:"@contractspec/lib.cost-tracking"})," transforms raw telemetry into dollars: DB/API/compute costs per operation, budget alerts per tenant, and actionable optimization tips."]})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),e(r,{package:"@contractspec/lib.cost-tracking"})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Record Samples"}),e(a,{language:"typescript",code:`const tracker = new CostTracker();
tracker.recordSample({
  operation: 'orders.list',
  tenantId: 'acme',
  dbReads: 1200,
  dbWrites: 4,
  computeMs: 180,
  externalCalls: [{ provider: 'stripe', cost: 0.02 }],
});`})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Budget Alerts"}),e(a,{language:"typescript",code:`const budgets = new BudgetAlertManager({
  budgets: [{ tenantId: 'acme', monthlyLimit: 150 }],
  onAlert: ({ tenantId, total }) => notifyFinance(tenantId, total),
});

tracker.getTotals({ tenantId: 'acme' }).forEach((summary) => budgets.track(summary));`})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Optimization Suggestions"}),t("p",{className:"text-muted-foreground text-sm",children:["Feed summaries into ",e("code",{children:"OptimizationRecommender"})," to surface N+1 queries, compute-heavy steps, or expensive external calls. Store the generated suggestions in the new Prisma model to power Ops playbooks."]})]}),t("div",{className:"flex items-center gap-4 pt-4",children:[e(o,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),t(o,{href:"/docs/libraries/slo",className:"btn-primary",children:["Next: SLO ",e(i,{size:16})]})]})]})}export{l as LibrariesCostTrackingPage};
