3.0 KiB
3.0 KiB
Customer Domain Cleanup Plan
Problems Identified
1. Too Many Aliases
// Current mess:
User, UserProfile, AuthenticatedUser // 3 names for same thing!
UserAuth, PortalUser // 2 names for same thing!
CustomerAddress, Address // 2 names for same thing!
CustomerData, CustomerProfile // CustomerProfile is manually defined, not from schema!
2. Manual Interface (BAD)
// This bypasses schema-first approach!
export interface CustomerProfile {
id: string;
email: string;
// ... manually duplicated fields
}
3. Unnecessary Schema Type Exports
export type CustomerAddressSchema = typeof customerAddressSchema; // Unused
export type CustomerSchema = typeof customerSchema; // Unused
// ... etc
4. Confusing Naming
Customer= Full WHMCS customer schema (internal use only)CustomerData= Profile subsetCustomerProfile= Duplicate manual interface (deprecated)
Cleanup Plan
Keep Only These Core Types:
// === User Entity Types ===
UserAuth // Auth state from portal DB
User // Complete user (auth + profile)
// === WHMCS Data Types ===
CustomerAddress // Address structure
CustomerData // Profile data from WHMCS (internal provider use)
// === Supporting Types ===
CustomerEmailPreferences
CustomerUser // Sub-users
CustomerStats // Billing stats
AddressFormData // Form validation
// === Internal Provider Types ===
Customer // Full WHMCS schema (only used in WHMCS mapper)
// === Role ===
UserRole
Remove These:
- ❌
PortalUser(useUserAuth) - ❌
UserProfile(useUser) - ❌
AuthenticatedUser(useUser) - ❌
CustomerProfileinterface (useUserorCustomerData) - ❌
Addressalias (useCustomerAddress) - ❌ All schema type exports (
CustomerAddressSchema, etc.) - ❌
addressSchemaconst alias (usecustomerAddressSchema)
Implementation
1. Clean types.ts
Remove:
- All deprecated alias types
- Manual
CustomerProfileinterface - Schema type exports
addressSchemaalias
2. Clean index.ts
Export only:
- Core types:
User,UserAuth,UserRole - Supporting types:
CustomerAddress,CustomerData,CustomerEmailPreferences,CustomerUser,CustomerStats,AddressFormData - Internal:
Customer(for WHMCS mapper only)
3. Update BFF imports (only 9 occurrences!)
Replace any remaining:
CustomerProfile→User- Other deprecated → proper type
Result: Clean & Clear
// Customer Domain Exports (CLEAN!)
// === User Types ===
User // Complete user for APIs
UserAuth // Auth state for JWT
UserRole // "USER" | "ADMIN"
// === WHMCS Types ===
CustomerAddress // Address structure
CustomerData // Profile data (internal)
// === Supporting ===
CustomerEmailPreferences
CustomerUser
CustomerStats
AddressFormData
// === Internal ===
Customer // Full WHMCS schema (mapper only)
No aliases. No confusion. Schema-first.