var J=Object.defineProperty;var K=(w)=>w;function M(w,A){this[w]=K.bind(null,A)}var Q=(w,A)=>{for(var G in A)J(w,G,{get:A[G],enumerable:!0,configurable:!0,set:M.bind(A,G)})};var T=(w,A)=>()=>(w&&(A=w(w=0)),A);import{specDrivenDevelopmentBrief as F}from"@contractspec/bundle.library/components/docs/intent/intent-pages.docblocks";import{SeoOptimizer as N}from"@contractspec/lib.content-gen/seo";import{CodeBlock as H}from"@contractspec/lib.design-system";import I from"@contractspec/lib.ui-link";import{ChevronRight as P}from"lucide-react";import{jsx as q,jsxs as E}from"react/jsx-runtime";var _=new N().optimize(F);function $(){return E("div",{className:"space-y-8",children:[E("div",{className:"space-y-3",children:[q("h1",{className:"font-bold text-4xl",children:F.title}),q("p",{className:"text-lg text-muted-foreground",children:F.summary})]}),E("div",{className:"card-subtle space-y-4 p-6",children:[q("h2",{className:"font-bold text-2xl",children:"Why Spec-driven?"}),q("ul",{className:"space-y-2 text-muted-foreground text-sm",children:F.problems.map((w,A)=>q("li",{children:w},A))})]}),E("div",{className:"card-subtle space-y-4 p-6",children:[q("h2",{className:"font-bold text-2xl",children:"Benefits"}),q("ul",{className:"space-y-2 text-muted-foreground text-sm",children:F.solutions.map((w,A)=>q("li",{children:w},A))})]}),E("div",{className:"space-y-6",children:[E("div",{className:"space-y-3",children:[q("h2",{className:"font-bold text-2xl",children:"Feature Specification Example"}),q("p",{className:"text-muted-foreground text-sm",children:"Define a complete feature with operations, events, and data models."}),q(H,{language:"typescript",filename:"src/contracts/user-management.feature.ts",code:`import { defineFeature } from '@contractspec/lib.contracts-spec/features';
import { defineOperation } from '@contractspec/lib.contracts-spec/operations';
import { defineEvent } from '@contractspec/lib.contracts-spec/events';
import { SchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';

export const UserManagementFeature = defineFeature({
  goal: 'Complete user management system with CRUD operations',
  context: 'Handles user lifecycle from creation to deletion with proper authorization',
  operations: {
    createUser: defineOperation({
      goal: 'Create a new user account',
      input: new SchemaModel({
        type: 'object',
        properties: {
          email: { type: 'string', format: 'email', required: true },
          name: { type: 'string', minLength: 1, required: true },
        },
      }),
      output: new SchemaModel({
        type: 'object',
        properties: {
          id: { type: 'string', required: true },
          email: { type: 'string', required: true },
          name: { type: 'string', required: true },
        },
      }),
    }),
    updateUser: defineOperation({
      goal: 'Update existing user information',
      input: new SchemaModel({
        type: 'object',
        properties: {
          name: { type: 'string', minLength: 1 },
        },
      }),
      output: new SchemaModel({
        type: 'object',
        properties: {
          id: { type: 'string', required: true },
          email: { type: 'string', required: true },
          name: { type: 'string', required: true },
        },
      }),
    }),
  },
  events: {
    userCreated: defineEvent({
      goal: 'Emit when a new user is created',
      payload: new SchemaModel({
        type: 'object',
        properties: {
          userId: { type: 'string', required: true },
          email: { type: 'string', required: true },
        },
      }),
    }),
    userUpdated: defineEvent({
      goal: 'Emit when user information changes',
      payload: new SchemaModel({
        type: 'object',
        properties: {
          userId: { type: 'string', required: true },
          changes: { type: 'array', items: { type: 'string' }, required: true },
        },
      }),
    }),
  },
  metadata: {
    name: 'user-management',
    version: '1.0.0',
    description: 'Complete user management with operations and events',
  },
});`})]}),E("div",{className:"space-y-3",children:[q("h2",{className:"font-bold text-2xl",children:"Generate Type-safe Implementations"}),q("p",{className:"text-muted-foreground text-sm",children:"Generate validation, types, and API handlers from your feature."}),q(H,{language:"bash",filename:"generate-from-feature",code:"contractspec generate \\\n  --input ./src/contracts/user-management.feature.ts \\\n  --output ./generated/user-management"})]})]}),E("div",{className:"flex items-center gap-4 pt-4",children:[E(I,{href:"/docs/guides/spec-validation-and-typing",className:"btn-primary",children:["Type Safety Guide ",q(P,{size:16})]}),q(I,{href:"/docs/intent/deterministic-codegen",className:"btn-ghost",children:"Deterministic Codegen"})]})]})}export{_ as metadata,$ as SpecDrivenDevelopmentPage};
