All files / src/api/suppliers types.ts

100% Statements 55/55
100% Branches 0/0
100% Functions 0/0
100% Lines 55/55

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 561x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * @file types.ts
 * @module api/suppliers/types
 *
 * @summary
 * TypeScript type definitions for supplier API responses and list operations.
 * Centralizes all supplier-related types for consistent frontend handling.
 *
 * @enterprise
 * - No `any` types; all responses are fully typed
 * - Matches backend SupplierDTO structure
 * - Supports filtering, pagination, and sorting
 * - Comprehensive TypeDoc for all exports
 */
 
/** Supplier row shape displayed in grid. */
export interface SupplierRow {
  id: string;                    // Unique supplier identifier
  name: string;                  // Supplier company name
  contactName?: string | null;   // Contact person name (optional)
  phone?: string | null;         // Contact phone (optional)
  email?: string | null;         // Contact email (optional)
  createdBy?: string | null;     // Who created (audit trail)
  createdAt?: string | null;     // ISO datetime created
}
 
/** Paginated response from /api/suppliers list endpoint. */
export interface SupplierListResponse {
  items: SupplierRow[];
  total: number;                 // Total count across all pages
  page: number;                  // 1-based page index
  pageSize: number;              // Items per page
}
 
/** Filter & pagination params for supplier list endpoint. */
export interface SupplierListParams {
  page: number;                  // 1-based page index
  pageSize: number;              // Page size
  q?: string;                    // Search query (name/email)
  sort?: ServerSort;             // Sort expression, e.g., "name,asc"
}
 
/** Server-side sort expression. */
export type ServerSort = string;
 
/** Supplier DTO for create/update operations. */
export interface SupplierDTO {
  id?: string;                   // Absent for POST, required for PUT
  name: string;                  // Required
  contactName?: string | null;   // Optional
  phone?: string | null;         // Optional
  email?: string | null;         // Optional email (validated if provided)
  createdBy?: string;            // Auto-filled by backend
  createdAt?: string | null;     // Auto-filled by backend (ISO datetime)
}