// @bun
// src/components/docs/libraries/LibrariesDataBackendPage.tsx
import Link from "@contractspec/lib.ui-link";
import { ChevronRight } from "lucide-react";
import { CodeBlock } from "@contractspec/lib.design-system";
import { jsx, jsxs } from "react/jsx-runtime";
function LibrariesDataBackendPage() {
  return /* @__PURE__ */ jsxs("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h1", {
            className: "text-4xl font-bold",
            children: "Data & Backend"
          }),
          /* @__PURE__ */ jsx("p", {
            className: "text-muted-foreground",
            children: "A collection of robust, platform-agnostic libraries for building the backend infrastructure of your LSSM applications."
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Libraries"
          }),
          /* @__PURE__ */ jsxs("div", {
            className: "space-y-6",
            children: [
              /* @__PURE__ */ jsxs("div", {
                className: "card-subtle p-6",
                children: [
                  /* @__PURE__ */ jsx("h3", {
                    className: "text-lg font-bold",
                    children: "@contractspec/app.cli-database"
                  }),
                  /* @__PURE__ */ jsxs("p", {
                    className: "text-muted-foreground mt-2 text-sm",
                    children: [
                      /* @__PURE__ */ jsx("strong", {
                        children: "Prisma Wrapper & CLI"
                      }),
                      ". Provides a unified way to manage database schemas, migrations, and clients. Includes seeders and factory patterns for testing."
                    ]
                  })
                ]
              }),
              /* @__PURE__ */ jsxs("div", {
                className: "card-subtle p-6",
                children: [
                  /* @__PURE__ */ jsx("h3", {
                    className: "text-lg font-bold",
                    children: "@contractspec/lib.bus"
                  }),
                  /* @__PURE__ */ jsxs("p", {
                    className: "text-muted-foreground mt-2 text-sm",
                    children: [
                      /* @__PURE__ */ jsx("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)."
                    ]
                  })
                ]
              }),
              /* @__PURE__ */ jsxs("div", {
                className: "card-subtle p-6",
                children: [
                  /* @__PURE__ */ jsx("h3", {
                    className: "text-lg font-bold",
                    children: "@contractspec/lib.logger"
                  }),
                  /* @__PURE__ */ jsxs("p", {
                    className: "text-muted-foreground mt-2 text-sm",
                    children: [
                      /* @__PURE__ */ jsx("strong", {
                        children: "High-Performance Logging"
                      }),
                      ". Optimized for Bun and structured JSON output. Includes plugins for ElysiaJS to log HTTP requests automatically."
                    ]
                  })
                ]
              }),
              /* @__PURE__ */ jsxs("div", {
                className: "card-subtle p-6",
                children: [
                  /* @__PURE__ */ jsx("h3", {
                    className: "text-lg font-bold",
                    children: "@contractspec/lib.error"
                  }),
                  /* @__PURE__ */ jsxs("p", {
                    className: "text-muted-foreground mt-2 text-sm",
                    children: [
                      /* @__PURE__ */ jsx("strong", {
                        children: "Standardized Errors"
                      }),
                      ". Use `AppError` with standard codes (NOT_FOUND, UNAUTHORIZED) to ensure consistent HTTP responses and error handling across services."
                    ]
                  })
                ]
              }),
              /* @__PURE__ */ jsxs("div", {
                className: "card-subtle p-6",
                children: [
                  /* @__PURE__ */ jsx("h3", {
                    className: "text-lg font-bold",
                    children: "@contractspec/lib.exporter"
                  }),
                  /* @__PURE__ */ jsxs("p", {
                    className: "text-muted-foreground mt-2 text-sm",
                    children: [
                      /* @__PURE__ */ jsx("strong", {
                        children: "Data Export"
                      }),
                      ". Generate CSV and XML files from your data. Platform-agnostic and streaming-friendly."
                    ]
                  })
                ]
              })
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Example: Unified Backend Flow"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            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;
}`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsxs(Link, {
            href: "/docs/libraries/runtime",
            className: "btn-primary",
            children: [
              "Next: Runtime ",
              /* @__PURE__ */ jsx(ChevronRight, {
                size: 16
              })
            ]
          }),
          /* @__PURE__ */ jsx(Link, {
            href: "/docs/libraries",
            className: "btn-ghost",
            children: "Back to Libraries"
          })
        ]
      })
    ]
  });
}
export {
  LibrariesDataBackendPage
};
