/**
 * Common Domain - Types
 * 
 * Shared utility types and branded types used across all domains.
 */

// ============================================================================
// Primitive Utility Types
// ============================================================================

export type IsoDateTimeString = string;

export type EmailAddress = string;

export type PhoneNumber = string;

export type Currency = "JPY" | "USD" | "EUR";

// ============================================================================
// Branded Types (for type safety)
// ============================================================================

export type UserId = string & { readonly __brand: "UserId" };
export type AccountId = string & { readonly __brand: "AccountId" };
export type OrderId = string & { readonly __brand: "OrderId" };
export type InvoiceId = string & { readonly __brand: "InvoiceId" };
export type ProductId = string & { readonly __brand: "ProductId" };
export type SimId = string & { readonly __brand: "SimId" };

export type WhmcsClientId = number & { readonly __brand: "WhmcsClientId" };
export type WhmcsInvoiceId = number & { readonly __brand: "WhmcsInvoiceId" };
export type WhmcsProductId = number & { readonly __brand: "WhmcsProductId" };

export type SalesforceContactId = string & { readonly __brand: "SalesforceContactId" };
export type SalesforceAccountId = string & { readonly __brand: "SalesforceAccountId" };
export type SalesforceCaseId = string & { readonly __brand: "SalesforceCaseId" };

// ============================================================================
// Address
// ============================================================================

// ============================================================================
// API Response Wrappers
// ============================================================================

export interface ApiSuccessResponse<T> {
  success: true;
  data: T;
}

export interface ApiErrorResponse {
  success: false;
  error: {
    code: string;
    message: string;
    details?: unknown;
  };
}

export type ApiResponse<T> = ApiSuccessResponse<T> | ApiErrorResponse;

// ============================================================================
// Pagination
// ============================================================================

export interface PaginationParams {
  page?: number;
  limit?: number;
  offset?: number;
}

export interface PaginatedResponse<T> {
  items: T[];
  total: number;
  page: number;
  limit: number;
  hasMore: boolean;
}

// ============================================================================
// Query Parameters
// ============================================================================

export interface FilterParams {
  search?: string;
  sortBy?: string;
  sortOrder?: "asc" | "desc";
}

export type QueryParams = PaginationParams & FilterParams;
