# TypeScript Schema - FRD Data Types

> **Usage:** TypeScript interfaces for FRD documentation
> **Loaded in:** step-06-doc-html.md

---

## Type Definitions

```typescript
// web/smartstack-web/src/pages/docs/business/{app}/{module}/types.ts

/**
 * Use Case definition from FRD
 */
export interface UseCase {
  /** Unique identifier (e.g., "UC-001") */
  id: string;
  /** Use case name */
  name: string;
  /** Primary actor role */
  actor: string;
  /** Required permission path */
  permission: string;
  /** Brief description */
  description: string;
}

/**
 * Business Rule from BRD
 */
export interface BusinessRule {
  /** Unique identifier (e.g., "BR-001") */
  id: string;
  /** Rule description */
  rule: string;
  /** Category: Validation, Calculation, Workflow, Security, Data */
  category: 'Validation' | 'Calculation' | 'Workflow' | 'Security' | 'Data';
  /** MoSCoW priority */
  priority: 'Must' | 'Should' | 'Could';
}

/**
 * Permission definition
 */
export interface Permission {
  /** Full permission path (e.g., "business.sales.orders.read") */
  path: string;
  /** Human-readable description */
  description: string;
  /** Roles that have this permission */
  roles: string[];
}

/**
 * Complete FRD data structure
 */
export interface FrdData {
  /** Feature identifier (e.g., "FEAT-001") */
  featureId: string;
  /** Module name in PascalCase */
  moduleName: string;
  /** Application name in PascalCase */
  applicationName: string;
  /** Document version */
  version: string;
  /** List of use cases */
  useCases: UseCase[];
  /** List of business rules */
  businessRules: BusinessRule[];
  /** List of permissions */
  permissions: Permission[];
}
```

---

## Data File Template

```typescript
// web/smartstack-web/src/pages/docs/business/{app}/{module}/frdData.ts

import type { FrdData } from './types';

/**
 * FRD data extracted from 3-functional-specification.md
 * Generated by /business-analyse:6-doc-html
 */
export const frdData: FrdData = {
  featureId: '{{feature_id}}',
  moduleName: '{{module_name}}',
  applicationName: '{{application_name}}',
  version: '1.0',

  useCases: [
    {
      id: 'UC-001',
      name: '{{use_case_name}}',
      actor: '{{actor}}',
      permission: 'business.{{app}}.{{module}}.{{action}}',
      description: '{{description}}'
    }
    // Add more use cases...
  ],

  businessRules: [
    {
      id: 'BR-001',
      rule: '{{rule_description}}',
      category: 'Validation',
      priority: 'Must'
    }
    // Add more business rules...
  ],

  permissions: [
    {
      path: 'business.{{app}}.{{module}}.read',
      description: 'View {{module}} data',
      roles: ['Admin', 'Manager', 'User', 'ReadOnly']
    },
    {
      path: 'business.{{app}}.{{module}}.create',
      description: 'Create new {{module}}',
      roles: ['Admin', 'Manager']
    },
    {
      path: 'business.{{app}}.{{module}}.update',
      description: 'Update existing {{module}}',
      roles: ['Admin', 'Manager']
    },
    {
      path: 'business.{{app}}.{{module}}.delete',
      description: 'Delete {{module}}',
      roles: ['Admin']
    }
  ]
};
```

---

## Index Export

```typescript
// web/smartstack-web/src/pages/docs/business/{app}/{module}/index.ts

export { {ModuleName}FrdDocPage } from './FrdDocPage';
export type { FrdData, UseCase, BusinessRule, Permission } from './types';
export { frdData } from './frdData';
```
