Comprehensive refactoring across 70 files (net -298 lines) improving type safety, error handling, and code organization: - Replace .passthrough()/.catchall(z.unknown()) with .strip() in all Zod schemas - Tighten Record<string, unknown> to bounded union types where possible - Replace throw new Error with domain-specific exceptions (OrderException, FulfillmentException, WhmcsOperationException, SalesforceOperationException, etc.) - Split AuthTokenService (625 lines) into TokenGeneratorService and TokenRefreshService with thin orchestrator - Deduplicate FreebitClientService with shared makeRequest() method - Add typed interfaces to WHMCS facade, order service, and fulfillment mapper - Externalize hardcoded config values to ConfigService with env fallbacks - Consolidate duplicate billing cycle enums into shared billingCycleSchema - Standardize logger usage (nestjs-pino @Inject(Logger) everywhere) - Move shared WHMCS number coercion helpers to whmcs-utils/schema.ts
97 lines
2.4 KiB
TypeScript
97 lines
2.4 KiB
TypeScript
/**
|
|
* Services Domain - Contract
|
|
*
|
|
* Constants and types for the services domain.
|
|
* Most types are derived from schemas (see schema.ts).
|
|
*/
|
|
|
|
// ============================================================================
|
|
// Salesforce Field Mapping (Provider-Specific, Not Validated)
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Salesforce Product2 field mapping
|
|
* This is provider-specific and not validated at runtime
|
|
*/
|
|
export interface SalesforceProductFieldMap {
|
|
sku: string;
|
|
portalCategory: string;
|
|
portalCatalog: string;
|
|
portalAccessible: string;
|
|
itemClass: string;
|
|
billingCycle: string;
|
|
whmcsProductId: string;
|
|
whmcsProductName: string;
|
|
internetPlanTier: string;
|
|
internetOfferingType: string;
|
|
displayOrder: string;
|
|
bundledAddon: string;
|
|
isBundledAddon: string;
|
|
simDataSize: string;
|
|
simPlanType: string;
|
|
simHasFamilyDiscount: string;
|
|
vpnRegion: string;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Pricing and Filter Types
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Pricing tier for display purposes
|
|
*/
|
|
export interface PricingTier {
|
|
name: string;
|
|
price: number;
|
|
billingCycle: "Monthly" | "One-time" | "Annually";
|
|
description?: string;
|
|
features?: string[];
|
|
isRecommended?: boolean;
|
|
originalPrice?: number;
|
|
}
|
|
|
|
/**
|
|
* Standardized pricing display info
|
|
* Used for consistent price rendering across Frontend and BFF
|
|
*/
|
|
export interface CatalogPriceInfo {
|
|
display: string;
|
|
monthly: number | null;
|
|
oneTime: number | null;
|
|
currency: string;
|
|
}
|
|
|
|
/**
|
|
* Catalog filtering options
|
|
*/
|
|
export interface CatalogFilter {
|
|
category?: string;
|
|
priceMin?: number;
|
|
priceMax?: number;
|
|
search?: string;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Re-export Types from Schema (Schema-First Approach)
|
|
// ============================================================================
|
|
|
|
export type {
|
|
CatalogProductBase,
|
|
CatalogPricebookEntry,
|
|
// Internet products
|
|
InternetCatalogProduct,
|
|
InternetPlanTemplate,
|
|
InternetPlanCatalogItem,
|
|
InternetInstallationCatalogItem,
|
|
InternetAddonCatalogItem,
|
|
InternetEligibilityStatus,
|
|
InternetEligibilityDetails,
|
|
// SIM products
|
|
SimCatalogProduct,
|
|
SimActivationFeeCatalogItem,
|
|
// VPN products
|
|
VpnCatalogProduct,
|
|
// Union type
|
|
CatalogProduct,
|
|
} from "./schema.js";
|