import{CodeBlock as i,InstallCommand as r}from"@contractspec/lib.design-system";import t from"@contractspec/lib.ui-link";import{ChevronRight as o}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function m(){return a("div",{className:"space-y-8",children:[a("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"Multi-Tenancy Library"}),a("p",{className:"text-lg text-muted-foreground",children:["The ",e("code",{children:"@contractspec/lib.multi-tenancy"})," library provides the core building blocks for secure SaaS applications."]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),e(r,{package:"@contractspec/lib.multi-tenancy"})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Prisma RLS Middleware"}),a("p",{className:"text-muted-foreground",children:["Automatically injects ",e("code",{children:"tenantId"})," into all queries."]}),e(i,{language:"typescript",code:`import { createRlsMiddleware } from '@contractspec/lib.multi-tenancy/rls';
import { prisma } from './db';
import { getTenantId } from './context';

prisma.$use(createRlsMiddleware(() => getTenantId()));`})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Provisioning Service"}),e("p",{className:"text-muted-foreground",children:"Automates the creation of new tenants, including database setup and default user creation."}),e(i,{language:"typescript",code:`import { TenantProvisioningService } from '@contractspec/lib.multi-tenancy/provisioning';

const service = new TenantProvisioningService({ db: prisma });
await service.provision({
  id: 'acme',
  name: 'Acme Corp',
  slug: 'acme',
  ownerEmail: 'admin@acme.com'
});`})]}),a("div",{className:"flex items-center gap-4 pt-4",children:[e(t,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),a(t,{href:"/docs/libraries/progressive-delivery",className:"btn-primary",children:["Next: Progressive Delivery ",e(o,{size:16})]})]})]})}export{m as LibrariesMultiTenancyPage};
