1
0
Fork 0
mirror of https://github.com/s-frick/effigenix.git synced 2026-03-28 15:29:34 +01:00
effigenix/frontend/packages/types
Sebastian Frick a77f0ec5df feat(shared): Länderauswahl mit ISO 3166-1 Mapping und CountryPicker
Backend: Country-Record (Shared Kernel), InMemoryCountryRepository mit
~249 Ländern und DACH-Priorisierung, ListCountries-UseCase,
GET /api/countries?q= Endpoint.

Frontend: CountryPicker-Komponente mit Fuzzy-Suche, DACH-Favoriten bei
leerem Query. SupplierCreate-, CustomerCreate- und AddDeliveryAddress-
Screens verwenden jetzt den CountryPicker statt Freitext. Detail-Screens
zeigen den Ländercode in der Adressanzeige.

Closes #71
2026-02-24 09:28:56 +01:00
..
src feat(shared): Länderauswahl mit ISO 3166-1 Mapping und CountryPicker 2026-02-24 09:28:56 +01:00
package.json chore(types): OpenAPI-Spec update 2026-02-18 21:36:20 +01:00
README.md feat: initialize frontend monorepo with pnpm workspace and types package 2026-02-17 22:13:18 +01:00
tsconfig.json feat(frontend): TypeScript-Monorepo mit Terminal-UI für Effigenix ERP 2026-02-18 12:28:16 +01:00

@effigenix/types

TypeScript types for the Effigenix ERP system. Types are automatically generated from the backend OpenAPI specification and extended with UI-specific types.

Features

  • Auto-generated from OpenAPI - Types are generated from the backend's OpenAPI spec
  • Type-safe - Compile-time type checking for all API interactions
  • Custom UI types - Additional types for UI state management
  • Clean exports - Organized wrapper files for easy consumption

Installation

This package is part of the Effigenix frontend monorepo and is not published separately.

pnpm add @effigenix/types --filter my-package

Usage

Importing Types

import {
  // Auth types
  LoginRequest,
  LoginResponse,
  TokenStorage,

  // User types
  UserDTO,
  CreateUserRequest,
  UpdateUserRequest,

  // Role types
  RoleDTO,
  Permission,

  // Common types
  ApiError,
  ValidationError,

  // Enums
  UserStatus,
  LoadingState,
  Screen
} from '@effigenix/types';

Example: Type-safe API request

import { LoginRequest, LoginResponse } from '@effigenix/types';

async function login(request: LoginRequest): Promise<LoginResponse> {
  // TypeScript ensures the request matches the backend's expected structure
  const response = await fetch('/api/auth/login', {
    method: 'POST',
    body: JSON.stringify(request),
  });

  return response.json() as Promise<LoginResponse>;
}

Type Generation

Types are automatically generated from the backend's OpenAPI specification.

Prerequisites

  1. Backend must be running at http://localhost:8080
  2. OpenAPI spec must be available at http://localhost:8080/api-docs

Generate Types

# Start backend first
cd ../../../backend
mvn spring-boot:run

# In another terminal, generate types
cd frontend/packages/types
pnpm run generate:types

This will:

  1. Fetch the OpenAPI spec from the backend
  2. Generate TypeScript types in src/generated/api.ts
  3. Types are automatically used by wrapper files (auth.ts, user.ts, etc.)

Build Process

# Generate types + build package
pnpm run build

# Type check only
pnpm run typecheck

# Watch mode for development
pnpm run dev

Structure

src/
├── generated/
│   └── api.ts           # AUTO-GENERATED from OpenAPI (DO NOT EDIT)
├── auth.ts              # Authentication types (wrapper + custom)
├── user.ts              # User management types (wrapper + custom)
├── role.ts              # Role and permission types (wrapper + custom)
├── common.ts            # Common types (wrapper + custom)
├── enums.ts             # Enums and constants
└── index.ts             # Main export file

Type Categories

Generated Types (from OpenAPI)

These types are automatically generated and should not be edited manually:

  • LoginRequest, LoginResponse
  • UserDTO, CreateUserRequest, UpdateUserRequest
  • RoleDTO, Permission
  • ErrorResponse

Custom UI Types

These types are defined manually for UI-specific needs:

  • TokenStorage - Token storage structure
  • UserListFilters - User list filtering options
  • UserFormData - Form data for user creation/editing
  • LoadingState - UI loading states
  • Screen - TUI screen navigation

CI/CD

In CI/CD pipelines, ensure types are generated before building:

# Start backend in background
docker-compose up -d backend

# Wait for backend to be ready
./scripts/wait-for-backend.sh

# Generate types
cd frontend/packages/types
pnpm run generate:types

# Build
pnpm run build

Development Workflow

  1. Make changes to backend DTOs
  2. Restart backend
  3. Run pnpm run generate:types in this package
  4. TypeScript will catch any breaking changes in dependent packages
  5. Update wrapper files if needed (add new custom types)

Notes

  • The generated/api.ts file should never be edited manually
  • Wrapper files (auth.ts, user.ts, etc.) re-export types with clean names
  • Custom types should be added to wrapper files, not generated/api.ts
  • Run type generation before building to ensure types are up-to-date