import{CodeBlock as r}from"@contractspec/lib.design-system";import a from"@contractspec/lib.ui-link";import{ChevronRight as o}from"lucide-react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function c(){return t("div",{className:"space-y-8",children:[t("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"Data & Backend"}),e("p",{className:"text-muted-foreground",children:"A collection of robust, platform-agnostic libraries for building the backend infrastructure of your LSSM applications."})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Libraries"}),t("div",{className:"space-y-6",children:[t("div",{className:"card-subtle p-6",children:[e("h3",{className:"font-bold text-lg",children:"@contractspec/app.cli-database"}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:[e("strong",{children:"Prisma Wrapper & CLI"}),". Provides a unified way to manage database schemas, migrations, and clients. Includes seeders and factory patterns for testing."]})]}),t("div",{className:"card-subtle p-6",children:[e("h3",{className:"font-bold text-lg",children:"@contractspec/lib.bus"}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:[e("strong",{children:"Type-Safe Event Bus"}),". Decouple your architecture with typed events. Supports in-memory dispatch for monoliths and can be extended for distributed message queues (Redis, SQS)."]})]}),t("div",{className:"card-subtle p-6",children:[e("h3",{className:"font-bold text-lg",children:"@contractspec/lib.logger"}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:[e("strong",{children:"High-Performance Logging"}),". Optimized for Bun and structured JSON output. Includes plugins for ElysiaJS to log HTTP requests automatically."]})]}),t("div",{className:"card-subtle p-6",children:[e("h3",{className:"font-bold text-lg",children:"@contractspec/lib.error"}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:[e("strong",{children:"Standardized Errors"}),". Use `AppError` with standard codes (NOT_FOUND, UNAUTHORIZED) to ensure consistent HTTP responses and error handling across services."]})]}),t("div",{className:"card-subtle p-6",children:[e("h3",{className:"font-bold text-lg",children:"@contractspec/lib.exporter"}),t("p",{className:"mt-2 text-muted-foreground text-sm",children:[e("strong",{children:"Data Export"}),". Generate CSV and XML files from your data. Platform-agnostic and streaming-friendly."]})]})]})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Example: Unified Backend Flow"}),e(r,{language:"typescript",code:`import { logger } from '@contractspec/lib.logger';
import { AppError } from '@contractspec/lib.error';
import { db } from '@contractspec/app.cli-database';
import { EventBus } from '@contractspec/lib.bus';

export async function createUser(email: string) {
  logger.info({ email }, 'Creating user');

  const existing = await db.user.findUnique({ where: { email } });
  if (existing) {
    throw new AppError('User already exists', 'CONFLICT');
  }

  const user = await db.user.create({ data: { email } });
  
  await EventBus.publish('user.created', { userId: user.id });
  
  return user;
}`})]}),t("div",{className:"flex items-center gap-4 pt-4",children:[t(a,{href:"/docs/libraries/runtime",className:"btn-primary",children:["Next: Runtime ",e(o,{size:16})]}),e(a,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"})]})]})}export{c as LibrariesDataBackendPage};
