diff --git a/apps/bff/src/integrations/freebit/freebit.module.ts b/apps/bff/src/integrations/freebit/freebit.module.ts index 07561900..14350766 100644 --- a/apps/bff/src/integrations/freebit/freebit.module.ts +++ b/apps/bff/src/integrations/freebit/freebit.module.ts @@ -1,27 +1,17 @@ import { Module } from "@nestjs/common"; -import { FreebitService } from "./freebit.service"; -import { - FreebitAuthService, - FreebitClientService, - FreebitMapperService, - FreebitOperationsService, - FreebitOrchestratorService, -} from "./services"; +import { FreebitOrchestratorService } from "./services/freebit-orchestrator.service"; +import { FreebitMapperService } from "./services/freebit-mapper.service"; +import { FreebitOperationsService } from "./services/freebit-operations.service"; @Module({ providers: [ // Core services - FreebitAuthService, - FreebitClientService, FreebitMapperService, FreebitOperationsService, FreebitOrchestratorService, - // Main service (for backward compatibility) - FreebitService, ], exports: [ - FreebitService, // Export orchestrator in case other services need direct access FreebitOrchestratorService, ], diff --git a/apps/bff/src/integrations/freebit/freebit.service.ts b/apps/bff/src/integrations/freebit/freebit.service.ts deleted file mode 100644 index e8bdc53d..00000000 --- a/apps/bff/src/integrations/freebit/freebit.service.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { Injectable } from "@nestjs/common"; -import { FreebitOrchestratorService } from "./services/freebit-orchestrator.service"; -import type { - SimDetails, - SimUsage, - SimTopUpHistory, -} from "./interfaces/freebit.types"; -import type { MnpData } from "@customer-portal/domain"; - -@Injectable() -export class FreebitService { - constructor( - private readonly orchestrator: FreebitOrchestratorService - ) {} - - /** - * Get SIM account details - */ - async getSimDetails(account: string): Promise { - return this.orchestrator.getSimDetails(account); - } - - /** - * Get SIM usage information - */ - async getSimUsage(account: string): Promise { - return this.orchestrator.getSimUsage(account); - } - - /** - * Top up SIM data quota - */ - async topUpSim( - account: string, - quotaMb: number, - options: { description?: string } = {} - ): Promise { - return this.orchestrator.topUpSim(account, quotaMb, options); - } - - /** - * Get SIM top-up history - */ - async getSimTopUpHistory( - account: string, - fromDate: string, - toDate: string - ): Promise { - return this.orchestrator.getSimTopUpHistory(account, fromDate, toDate); - } - - /** - * Change SIM plan - */ - async changeSimPlan( - account: string, - newPlanCode: string, - options: { assignGlobalIp?: boolean; scheduledAt?: string } = {} - ): Promise<{ ipv4?: string; ipv6?: string }> { - return this.orchestrator.changeSimPlan(account, newPlanCode, options); - } - - /** - * Update SIM features - */ - async updateSimFeatures( - account: string, - features: { - voiceMailEnabled?: boolean; - callWaitingEnabled?: boolean; - internationalRoamingEnabled?: boolean; - networkType?: "4G" | "5G"; - } - ): Promise { - return this.orchestrator.updateSimFeatures(account, features); - } - - /** - * Cancel SIM service - */ - async cancelSim(account: string, scheduledAt?: string): Promise { - return this.orchestrator.cancelSim(account, scheduledAt); - } - - /** - * Reissue eSIM profile (simple) - */ - async reissueEsimProfile(account: string): Promise { - return this.orchestrator.reissueEsimProfile(account); - } - - /** - * Reissue eSIM profile with enhanced options - */ - async reissueEsimProfileEnhanced( - account: string, - newEid: string, - options: { oldEid?: string; planCode?: string } = {} - ): Promise { - return this.orchestrator.reissueEsimProfileEnhanced(account, newEid, options); - } - - /** - * Health check - */ - async healthCheck(): Promise { - return this.orchestrator.healthCheck(); - } - - /** - * Activate eSIM account (for backward compatibility) - */ - async activateEsimAccountNew(params: { - account: string; - eid: string; - planSku: string; - simType: "eSIM" | "Physical SIM"; - activationType: "Immediate" | "Scheduled"; - scheduledAt?: string; - mnp?: MnpData; - }): Promise { - // For eSIM, use the enhanced reissue method - if (params.simType === "eSIM") { - return this.orchestrator.reissueEsimProfileEnhanced(params.account, params.eid, { - planCode: params.planSku, - }); - } - - // For Physical SIM, this would be a different operation - throw new Error("Physical SIM activation not implemented in this method"); - } -} \ No newline at end of file diff --git a/apps/bff/src/integrations/salesforce/salesforce.service.ts b/apps/bff/src/integrations/salesforce/salesforce.service.ts index 0be69dc9..6b3f8b2d 100644 --- a/apps/bff/src/integrations/salesforce/salesforce.service.ts +++ b/apps/bff/src/integrations/salesforce/salesforce.service.ts @@ -9,7 +9,7 @@ import { type AccountData, type UpsertResult, } from "./services/salesforce-account.service"; -import type { SalesforceAccountRecord } from "@customer-portal/domain"; +import type { SalesforceAccountRecord, SalesforceOrderRecord } from "@customer-portal/domain"; /** * Clean Salesforce Service - Only includes actually used functionality @@ -74,13 +74,13 @@ export class SalesforceService implements OnModuleInit { return this.accountService.getById(accountId); } - async updateAccount(accountId: string, updates: Record): Promise { + async updateAccount(accountId: string, updates: Partial): Promise { return this.accountService.update(accountId, updates); } // === ORDER METHODS (For Order Provisioning) === - async updateOrder(orderData: { Id: string; [key: string]: unknown }): Promise { + async updateOrder(orderData: Partial & { Id: string }): Promise { try { if (!this.connection.isConnected()) { throw new Error("Salesforce connection not available"); @@ -110,7 +110,7 @@ export class SalesforceService implements OnModuleInit { } } - async getOrder(orderId: string): Promise | null> { + async getOrder(orderId: string): Promise { try { if (!this.connection.isConnected()) { throw new Error("Salesforce connection not available"); @@ -124,7 +124,7 @@ export class SalesforceService implements OnModuleInit { FROM Order WHERE Id = '${orderId}' LIMIT 1` - )) as { records: Record[]; totalSize: number }; + )) as { records: SalesforceOrderRecord[]; totalSize: number }; return result.records?.[0] || null; } catch (error) { diff --git a/apps/bff/src/integrations/salesforce/services/salesforce-account.service.ts b/apps/bff/src/integrations/salesforce/services/salesforce-account.service.ts index e6c883d6..93cb8cf4 100644 --- a/apps/bff/src/integrations/salesforce/services/salesforce-account.service.ts +++ b/apps/bff/src/integrations/salesforce/services/salesforce-account.service.ts @@ -140,7 +140,7 @@ export class SalesforceAccountService { } } - async update(accountId: string, updates: Record): Promise { + async update(accountId: string, updates: Partial): Promise { const validAccountId = this.validateId(accountId); try { diff --git a/apps/bff/src/integrations/salesforce/services/salesforce-connection.service.ts b/apps/bff/src/integrations/salesforce/services/salesforce-connection.service.ts index aa688726..d3c1c1cb 100644 --- a/apps/bff/src/integrations/salesforce/services/salesforce-connection.service.ts +++ b/apps/bff/src/integrations/salesforce/services/salesforce-connection.service.ts @@ -218,7 +218,7 @@ export class SalesforceConnection { // Return a wrapper that handles session expiration for SObject operations return { - create: async (data: Record) => { + create: async (data: object) => { try { if (!this.isConnected()) { this.logger.warn("Salesforce not connected; attempting to establish connection"); @@ -247,7 +247,7 @@ export class SalesforceConnection { } }, - update: async (data: Record & { Id: string }) => { + update: async (data: object & { Id: string }) => { try { if (!this.isConnected()) { this.logger.warn("Salesforce not connected; attempting to establish connection"); diff --git a/apps/bff/src/integrations/whmcs/connection/services/whmcs-connection-orchestrator.service.ts b/apps/bff/src/integrations/whmcs/connection/services/whmcs-connection-orchestrator.service.ts index 15f3b076..639c7527 100644 --- a/apps/bff/src/integrations/whmcs/connection/services/whmcs-connection-orchestrator.service.ts +++ b/apps/bff/src/integrations/whmcs/connection/services/whmcs-connection-orchestrator.service.ts @@ -206,10 +206,6 @@ export class WhmcsConnectionOrchestratorService implements OnModuleInit { return this.apiMethods.getPaymentMethods(params); } - // Legacy method name for backward compatibility - async getPayMethods(params: WhmcsGetPayMethodsParams) { - return this.getPaymentMethods(params); - } async getPaymentGateways() { return this.apiMethods.getPaymentGateways(); diff --git a/apps/bff/src/integrations/whmcs/services/whmcs-client.service.ts b/apps/bff/src/integrations/whmcs/services/whmcs-client.service.ts index 14fd84c1..09603c74 100644 --- a/apps/bff/src/integrations/whmcs/services/whmcs-client.service.ts +++ b/apps/bff/src/integrations/whmcs/services/whmcs-client.service.ts @@ -1,7 +1,7 @@ import { Injectable, NotFoundException, Inject } from "@nestjs/common"; import { Logger } from "nestjs-pino"; import { getErrorMessage } from "@bff/core/utils/error.util"; -import { WhmcsConnectionService } from "./whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service"; import { WhmcsCacheService } from "../cache/whmcs-cache.service"; import { WhmcsValidateLoginParams, @@ -12,7 +12,7 @@ import { @Injectable() export class WhmcsClientService { constructor( - private readonly connectionService: WhmcsConnectionService, + private readonly connectionService: WhmcsConnectionOrchestratorService, private readonly cacheService: WhmcsCacheService, @Inject(Logger) private readonly logger: Logger ) {} diff --git a/apps/bff/src/integrations/whmcs/services/whmcs-connection.service.ts b/apps/bff/src/integrations/whmcs/services/whmcs-connection.service.ts deleted file mode 100644 index 3d510b5d..00000000 --- a/apps/bff/src/integrations/whmcs/services/whmcs-connection.service.ts +++ /dev/null @@ -1,197 +0,0 @@ -import { Injectable } from "@nestjs/common"; -import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service"; -import type { - WhmcsInvoicesResponse, - WhmcsInvoiceResponse, - WhmcsProductsResponse, - WhmcsClientResponse, - WhmcsSsoResponse, - WhmcsValidateLoginResponse, - WhmcsAddClientResponse, - WhmcsCatalogProductsResponse, - WhmcsPayMethodsResponse, - WhmcsPaymentGatewaysResponse, - WhmcsCreateInvoiceResponse, - WhmcsUpdateInvoiceResponse, - WhmcsCapturePaymentResponse, - WhmcsGetInvoicesParams, - WhmcsGetClientsProductsParams, - WhmcsCreateSsoTokenParams, - WhmcsValidateLoginParams, - WhmcsAddClientParams, - WhmcsGetPayMethodsParams, - WhmcsCreateInvoiceParams, - WhmcsUpdateInvoiceParams, - WhmcsCapturePaymentParams, -} from "../types/whmcs-api.types"; - -// Re-export the config interface for backward compatibility -export interface WhmcsApiConfig { - baseUrl: string; - identifier: string; - secret: string; - timeout?: number; - retryAttempts?: number; - retryDelay?: number; - adminUsername?: string; - adminPasswordHash?: string; -} - -/** - * WHMCS Connection Service - now acts as a facade to the orchestrator service - * Maintains backward compatibility while delegating to modular services - */ -@Injectable() -export class WhmcsConnectionService { - constructor( - private readonly orchestrator: WhmcsConnectionOrchestratorService - ) {} - - // ========================================== - // HEALTH CHECK METHODS - // ========================================== - - async healthCheck(): Promise { - return this.orchestrator.healthCheck(); - } - - async isAvailable(): Promise { - return this.orchestrator.isAvailable(); - } - - async getSystemInfo(): Promise { - return this.orchestrator.getSystemInfo(); - } - - // ========================================== - // CLIENT API METHODS - // ========================================== - - async getClientDetails(clientId: number): Promise { - return this.orchestrator.getClientDetails(clientId); - } - - async getClientDetailsByEmail(email: string): Promise { - return this.orchestrator.getClientDetailsByEmail(email); - } - - async updateClient( - clientId: number, - updateData: Partial - ): Promise<{ result: string }> { - return this.orchestrator.updateClient(clientId, updateData); - } - - async addClient(params: WhmcsAddClientParams): Promise { - return this.orchestrator.addClient(params); - } - - async validateLogin(params: WhmcsValidateLoginParams): Promise { - return this.orchestrator.validateLogin(params); - } - - // ========================================== - // INVOICE API METHODS - // ========================================== - - async getInvoices(params: WhmcsGetInvoicesParams = {}): Promise { - return this.orchestrator.getInvoices(params); - } - - async getInvoice(invoiceId: number): Promise { - return this.orchestrator.getInvoice(invoiceId); - } - - async createInvoice(params: WhmcsCreateInvoiceParams): Promise { - return this.orchestrator.createInvoice(params); - } - - async updateInvoice(params: WhmcsUpdateInvoiceParams): Promise { - return this.orchestrator.updateInvoice(params); - } - - async capturePayment(params: WhmcsCapturePaymentParams): Promise { - return this.orchestrator.capturePayment(params); - } - - - // ========================================== - // PRODUCT/SUBSCRIPTION API METHODS - // ========================================== - - async getClientsProducts(params: WhmcsGetClientsProductsParams): Promise { - return this.orchestrator.getClientsProducts(params); - } - - async getCatalogProducts(): Promise { - return this.orchestrator.getCatalogProducts(); - } - - // ========================================== - // PAYMENT API METHODS - // ========================================== - - async getPaymentMethods(params: WhmcsGetPayMethodsParams): Promise { - return this.orchestrator.getPaymentMethods(params); - } - - async getPaymentGateways(): Promise { - return this.orchestrator.getPaymentGateways(); - } - - // Legacy method name for backward compatibility - async getPayMethods(params: WhmcsGetPayMethodsParams): Promise { - return this.getPaymentMethods(params); - } - - async getProducts(): Promise { - return this.orchestrator.getProducts() as Promise; - } - - async addOrder(params: Record) { - return this.orchestrator.addOrder(params); - } - - async getOrders(params: Record = {}) { - return this.orchestrator.getOrders(params); - } - - async acceptOrder(orderId: number): Promise<{ result: string }> { - return this.orchestrator.acceptOrder(orderId); - } - - async cancelOrder(orderId: number): Promise<{ result: string }> { - return this.orchestrator.cancelOrder(orderId); - } - - getBaseUrl(): string { - return this.orchestrator.getBaseUrl(); - } - - // ========================================== - // SSO API METHODS - // ========================================== - - async createSsoToken(params: WhmcsCreateSsoTokenParams): Promise { - return this.orchestrator.createSsoToken(params); - } - - - // ========================================== - // UTILITY METHODS - // ========================================== - - /** - * Get connection statistics - */ - getConnectionStats() { - return this.orchestrator.getConnectionStats(); - } - - /** - * Get configuration (sanitized for logging) - */ - getConfig() { - return this.orchestrator.getConfig(); - } -} \ No newline at end of file diff --git a/apps/bff/src/integrations/whmcs/services/whmcs-invoice.service.ts b/apps/bff/src/integrations/whmcs/services/whmcs-invoice.service.ts index d35a566e..2aef06fc 100644 --- a/apps/bff/src/integrations/whmcs/services/whmcs-invoice.service.ts +++ b/apps/bff/src/integrations/whmcs/services/whmcs-invoice.service.ts @@ -2,7 +2,7 @@ import { getErrorMessage } from "@bff/core/utils/error.util"; import { Logger } from "nestjs-pino"; import { Injectable, NotFoundException, Inject } from "@nestjs/common"; import { Invoice, InvoiceList, invoiceListSchema, invoiceSchema } from "@customer-portal/domain"; -import { WhmcsConnectionService } from "./whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service"; import { InvoiceTransformerService } from "../transformers/services/invoice-transformer.service"; import { WhmcsCacheService } from "../cache/whmcs-cache.service"; import { @@ -26,7 +26,7 @@ export interface InvoiceFilters { export class WhmcsInvoiceService { constructor( @Inject(Logger) private readonly logger: Logger, - private readonly connectionService: WhmcsConnectionService, + private readonly connectionService: WhmcsConnectionOrchestratorService, private readonly invoiceTransformer: InvoiceTransformerService, private readonly cacheService: WhmcsCacheService ) {} diff --git a/apps/bff/src/integrations/whmcs/services/whmcs-order.service.ts b/apps/bff/src/integrations/whmcs/services/whmcs-order.service.ts index bbdd0aa3..d5bdff60 100644 --- a/apps/bff/src/integrations/whmcs/services/whmcs-order.service.ts +++ b/apps/bff/src/integrations/whmcs/services/whmcs-order.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { WhmcsConnectionService } from "./whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service"; import { getErrorMessage } from "@bff/core/utils/error.util"; export interface WhmcsOrderItem { @@ -32,7 +32,7 @@ export interface WhmcsOrderResult { @Injectable() export class WhmcsOrderService { constructor( - private readonly connection: WhmcsConnectionService, + private readonly connection: WhmcsConnectionOrchestratorService, @Inject(Logger) private readonly logger: Logger ) {} @@ -165,7 +165,7 @@ export class WhmcsOrderService { */ async hasPaymentMethod(clientId: number): Promise { try { - const response = (await this.connection.getPayMethods({ + const response = (await this.connection.getPaymentMethods({ clientid: clientId, })) as unknown as Record; diff --git a/apps/bff/src/integrations/whmcs/services/whmcs-payment.service.ts b/apps/bff/src/integrations/whmcs/services/whmcs-payment.service.ts index 5f78e41a..6a197e2a 100644 --- a/apps/bff/src/integrations/whmcs/services/whmcs-payment.service.ts +++ b/apps/bff/src/integrations/whmcs/services/whmcs-payment.service.ts @@ -7,7 +7,7 @@ import { PaymentGatewayList, PaymentMethod, } from "@customer-portal/domain"; -import { WhmcsConnectionService } from "./whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service"; import { PaymentTransformerService } from "../transformers/services/payment-transformer.service"; import { WhmcsCacheService } from "../cache/whmcs-cache.service"; import type { @@ -20,7 +20,7 @@ import type { export class WhmcsPaymentService { constructor( @Inject(Logger) private readonly logger: Logger, - private readonly connectionService: WhmcsConnectionService, + private readonly connectionService: WhmcsConnectionOrchestratorService, private readonly paymentTransformer: PaymentTransformerService, private readonly cacheService: WhmcsCacheService ) {} diff --git a/apps/bff/src/integrations/whmcs/services/whmcs-sso.service.ts b/apps/bff/src/integrations/whmcs/services/whmcs-sso.service.ts index 3a9a7bea..9f9aac3e 100644 --- a/apps/bff/src/integrations/whmcs/services/whmcs-sso.service.ts +++ b/apps/bff/src/integrations/whmcs/services/whmcs-sso.service.ts @@ -1,14 +1,14 @@ import { getErrorMessage } from "@bff/core/utils/error.util"; import { Logger } from "nestjs-pino"; import { Injectable, Inject } from "@nestjs/common"; -import { WhmcsConnectionService } from "./whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service"; import { WhmcsCreateSsoTokenParams } from "../types/whmcs-api.types"; @Injectable() export class WhmcsSsoService { constructor( @Inject(Logger) private readonly logger: Logger, - private readonly connectionService: WhmcsConnectionService + private readonly connectionService: WhmcsConnectionOrchestratorService ) {} /** diff --git a/apps/bff/src/integrations/whmcs/services/whmcs-subscription.service.ts b/apps/bff/src/integrations/whmcs/services/whmcs-subscription.service.ts index b9810f6d..095b57ea 100644 --- a/apps/bff/src/integrations/whmcs/services/whmcs-subscription.service.ts +++ b/apps/bff/src/integrations/whmcs/services/whmcs-subscription.service.ts @@ -2,7 +2,7 @@ import { getErrorMessage } from "@bff/core/utils/error.util"; import { Logger } from "nestjs-pino"; import { Injectable, NotFoundException, Inject } from "@nestjs/common"; import { Subscription, SubscriptionList } from "@customer-portal/domain"; -import { WhmcsConnectionService } from "./whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service"; import { SubscriptionTransformerService } from "../transformers/services/subscription-transformer.service"; import { WhmcsCacheService } from "../cache/whmcs-cache.service"; import { WhmcsGetClientsProductsParams } from "../types/whmcs-api.types"; @@ -15,7 +15,7 @@ export interface SubscriptionFilters { export class WhmcsSubscriptionService { constructor( @Inject(Logger) private readonly logger: Logger, - private readonly connectionService: WhmcsConnectionService, + private readonly connectionService: WhmcsConnectionOrchestratorService, private readonly subscriptionTransformer: SubscriptionTransformerService, private readonly cacheService: WhmcsCacheService ) {} diff --git a/apps/bff/src/integrations/whmcs/transformers/services/subscription-transformer.service.ts b/apps/bff/src/integrations/whmcs/transformers/services/subscription-transformer.service.ts index d8d6ad84..d5fa31f6 100644 --- a/apps/bff/src/integrations/whmcs/transformers/services/subscription-transformer.service.ts +++ b/apps/bff/src/integrations/whmcs/transformers/services/subscription-transformer.service.ts @@ -40,12 +40,12 @@ export class SubscriptionTransformerService { const subscription: Subscription = { id: Number(whmcsProduct.id), serviceId: Number(whmcsProduct.id), // In WHMCS, product ID is the service ID - productName: DataUtils.safeString(whmcsProduct.productname || whmcsProduct.name, "Unknown Product"), - domain: DataUtils.safeString(whmcsProduct.domain), + productName: whmcsProduct.productname || whmcsProduct.name, + domain: whmcsProduct.domain, status: StatusNormalizer.normalizeProductStatus(whmcsProduct.status), cycle: normalizedCycle, amount: this.getProductAmount(whmcsProduct), - currency: DataUtils.safeString(whmcsProduct.currencycode, "JPY"), + currency: whmcsProduct.currencycode, nextDue: DataUtils.formatDate(whmcsProduct.nextduedate), registrationDate: DataUtils.formatDate(whmcsProduct.regdate) || new Date().toISOString(), customFields: this.extractCustomFields(whmcsProduct.customfields), @@ -107,7 +107,7 @@ export class SubscriptionTransformerService { if (field && typeof field === "object" && field.name && field.value) { // Normalize field name (remove special characters, convert to camelCase) const normalizedName = this.normalizeFieldName(field.name); - fields[normalizedName] = DataUtils.safeString(field.value); + fields[normalizedName] = field.value; } } diff --git a/apps/bff/src/integrations/whmcs/transformers/utils/data-utils.ts b/apps/bff/src/integrations/whmcs/transformers/utils/data-utils.ts index 8af703ee..7c427b44 100644 --- a/apps/bff/src/integrations/whmcs/transformers/utils/data-utils.ts +++ b/apps/bff/src/integrations/whmcs/transformers/utils/data-utils.ts @@ -141,36 +141,4 @@ export class DataUtils { return undefined; } - /** - * Safe string conversion with fallback - */ - static safeString(value: unknown, fallback = ""): string { - if (value === null || value === undefined) return fallback; - return String(value); - } - - /** - * Safe number conversion with fallback - */ - static safeNumber(value: unknown, fallback = 0): number { - if (typeof value === "number") return value; - if (typeof value === "string") { - const parsed = parseFloat(value); - return isNaN(parsed) ? fallback : parsed; - } - return fallback; - } - - /** - * Safe boolean conversion - */ - static safeBoolean(value: unknown): boolean { - if (typeof value === "boolean") return value; - if (typeof value === "string") { - const lower = value.toLowerCase(); - return lower === "true" || lower === "1" || lower === "yes" || lower === "on"; - } - if (typeof value === "number") return value !== 0; - return false; - } } diff --git a/apps/bff/src/integrations/whmcs/whmcs.module.ts b/apps/bff/src/integrations/whmcs/whmcs.module.ts index b36b8286..e871ed32 100644 --- a/apps/bff/src/integrations/whmcs/whmcs.module.ts +++ b/apps/bff/src/integrations/whmcs/whmcs.module.ts @@ -2,7 +2,6 @@ import { Module } from "@nestjs/common"; import { ConfigModule } from "@nestjs/config"; import { WhmcsCacheService } from "./cache/whmcs-cache.service"; import { WhmcsService } from "./whmcs.service"; -import { WhmcsConnectionService } from "./services/whmcs-connection.service"; import { WhmcsInvoiceService } from "./services/whmcs-invoice.service"; import { WhmcsSubscriptionService } from "./services/whmcs-subscription.service"; import { WhmcsClientService } from "./services/whmcs-client.service"; @@ -31,8 +30,6 @@ import { WhmcsApiMethodsService } from "./connection/services/whmcs-api-methods. SubscriptionTransformerService, PaymentTransformerService, TransformationValidator, - // Legacy connection service (now facade) - WhmcsConnectionService, // New modular connection services WhmcsConnectionOrchestratorService, WhmcsConfigService, @@ -51,7 +48,6 @@ import { WhmcsApiMethodsService } from "./connection/services/whmcs-api-methods. ], exports: [ WhmcsService, - WhmcsConnectionService, WhmcsConnectionOrchestratorService, WhmcsTransformerOrchestratorService, WhmcsCacheService, diff --git a/apps/bff/src/integrations/whmcs/whmcs.service.ts b/apps/bff/src/integrations/whmcs/whmcs.service.ts index 46e86a5d..9b4a54e1 100644 --- a/apps/bff/src/integrations/whmcs/whmcs.service.ts +++ b/apps/bff/src/integrations/whmcs/whmcs.service.ts @@ -8,7 +8,7 @@ import type { PaymentMethodList, PaymentGatewayList, } from "@customer-portal/domain"; -import { WhmcsConnectionService } from "./services/whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "./connection/services/whmcs-connection-orchestrator.service"; import type { Address } from "@customer-portal/domain"; import { WhmcsInvoiceService, InvoiceFilters } from "./services/whmcs-invoice.service"; import { @@ -32,7 +32,7 @@ import { Logger } from "nestjs-pino"; @Injectable() export class WhmcsService { constructor( - private readonly connectionService: WhmcsConnectionService, + private readonly connectionService: WhmcsConnectionOrchestratorService, private readonly invoiceService: WhmcsInvoiceService, private readonly subscriptionService: WhmcsSubscriptionService, private readonly clientService: WhmcsClientService, diff --git a/apps/bff/src/modules/catalog/services/sim-catalog.service.ts b/apps/bff/src/modules/catalog/services/sim-catalog.service.ts index 0386829e..295d2cb1 100644 --- a/apps/bff/src/modules/catalog/services/sim-catalog.service.ts +++ b/apps/bff/src/modules/catalog/services/sim-catalog.service.ts @@ -12,7 +12,7 @@ import { import { MappingsService } from "@bff/modules/id-mappings/mappings.service"; import { SalesforceConnection } from "@bff/integrations/salesforce/services/salesforce-connection.service"; import { Logger } from "nestjs-pino"; -import { WhmcsConnectionService } from "@bff/integrations/whmcs/services/whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "@bff/integrations/whmcs/connection/services/whmcs-connection-orchestrator.service"; @Injectable() export class SimCatalogService extends BaseCatalogService { @@ -20,7 +20,7 @@ export class SimCatalogService extends BaseCatalogService { sf: SalesforceConnection, @Inject(Logger) logger: Logger, private mappingsService: MappingsService, - private whmcs: WhmcsConnectionService + private whmcs: WhmcsConnectionOrchestratorService ) { super(sf, logger); } diff --git a/apps/bff/src/modules/invoices/invoices.controller.ts b/apps/bff/src/modules/invoices/invoices.controller.ts index 42b4f33a..2cf00381 100644 --- a/apps/bff/src/modules/invoices/invoices.controller.ts +++ b/apps/bff/src/modules/invoices/invoices.controller.ts @@ -19,7 +19,9 @@ import { ApiBearerAuth, ApiParam, } from "@nestjs/swagger"; -import { InvoicesService } from "./invoices.service"; +import { InvoicesOrchestratorService } from "./services/invoices-orchestrator.service"; +import { WhmcsService } from "@bff/integrations/whmcs/whmcs.service"; +import { MappingsService } from "@bff/modules/id-mappings/mappings.service"; import type { Invoice, @@ -39,7 +41,11 @@ interface AuthenticatedRequest { @Controller("invoices") @ApiBearerAuth() export class InvoicesController { - constructor(private readonly invoicesService: InvoicesService) {} + constructor( + private readonly invoicesService: InvoicesOrchestratorService, + private readonly whmcsService: WhmcsService, + private readonly mappingsService: MappingsService + ) {} @Get() @ApiOperation({ @@ -104,7 +110,11 @@ export class InvoicesController { }) @ApiOkResponse({ description: "List of payment methods" }) async getPaymentMethods(@Request() req: AuthenticatedRequest): Promise { - return this.invoicesService.getPaymentMethods(req.user.id); + const mapping = await this.mappingsService.findByUserId(req.user.id); + if (!mapping?.whmcsClientId) { + throw new Error("WHMCS client mapping not found"); + } + return this.whmcsService.getPaymentMethods(mapping.whmcsClientId, req.user.id); } @Get("payment-gateways") @@ -114,7 +124,7 @@ export class InvoicesController { }) @ApiOkResponse({ description: "List of payment gateways" }) async getPaymentGateways(): Promise { - return this.invoicesService.getPaymentGateways(); + return this.whmcsService.getPaymentGateways(); } @Post("payment-methods/refresh") @@ -126,10 +136,14 @@ export class InvoicesController { @ApiOkResponse({ description: "Payment methods cache refreshed" }) async refreshPaymentMethods(@Request() req: AuthenticatedRequest): Promise { // Invalidate cache first - await this.invoicesService.invalidatePaymentMethodsCache(req.user.id); + await this.whmcsService.invalidatePaymentMethodsCache(req.user.id); // Return fresh payment methods - return this.invoicesService.getPaymentMethods(req.user.id); + const mapping = await this.mappingsService.findByUserId(req.user.id); + if (!mapping?.whmcsClientId) { + throw new Error("WHMCS client mapping not found"); + } + return this.whmcsService.getPaymentMethods(mapping.whmcsClientId, req.user.id); } @Get(":id") @@ -201,7 +215,20 @@ export class InvoicesController { throw new BadRequestException('Target must be "view", "download", or "pay"'); } - return this.invoicesService.createInvoiceSsoLink(req.user.id, invoiceId); + const mapping = await this.mappingsService.findByUserId(req.user.id); + if (!mapping?.whmcsClientId) { + throw new Error("WHMCS client mapping not found"); + } + + const ssoResult = await this.whmcsService.createSsoToken( + mapping.whmcsClientId, + invoiceId ? `index.php?rp=/invoice/${invoiceId}` : undefined + ); + + return { + url: ssoResult.url, + expiresAt: ssoResult.expiresAt, + }; } @Post(":id/payment-link") @@ -241,12 +268,23 @@ export class InvoicesController { throw new BadRequestException("Payment method ID must be a positive number"); } - return this.invoicesService.createInvoicePaymentLink( - req.user.id, + const mapping = await this.mappingsService.findByUserId(req.user.id); + if (!mapping?.whmcsClientId) { + throw new Error("WHMCS client mapping not found"); + } + + const ssoResult = await this.whmcsService.createPaymentSsoToken( + mapping.whmcsClientId, invoiceId, - gatewayName || "stripe", - "/" + paymentMethodIdNum, + gatewayName || "stripe" ); + + return { + url: ssoResult.url, + expiresAt: ssoResult.expiresAt, + gatewayName: gatewayName || "stripe", + }; } private validatePositiveInteger( diff --git a/apps/bff/src/modules/invoices/invoices.module.ts b/apps/bff/src/modules/invoices/invoices.module.ts index ab41646b..d79395a3 100644 --- a/apps/bff/src/modules/invoices/invoices.module.ts +++ b/apps/bff/src/modules/invoices/invoices.module.ts @@ -1,6 +1,5 @@ import { Module } from "@nestjs/common"; import { InvoicesController } from "./invoices.controller"; -import { InvoicesService } from "./invoices.service"; import { WhmcsModule } from "@bff/integrations/whmcs/whmcs.module"; import { MappingsModule } from "@bff/modules/id-mappings/mappings.module"; // New modular invoice services @@ -13,14 +12,12 @@ import { InvoiceValidatorService } from "./validators/invoice-validator.service" imports: [WhmcsModule, MappingsModule], controllers: [InvoicesController], providers: [ - // Legacy service (now facade) - InvoicesService, // New modular services InvoicesOrchestratorService, InvoiceRetrievalService, InvoiceHealthService, InvoiceValidatorService, ], - exports: [InvoicesService, InvoicesOrchestratorService], + exports: [InvoicesOrchestratorService], }) export class InvoicesModule {} diff --git a/apps/bff/src/modules/invoices/invoices.service.ts b/apps/bff/src/modules/invoices/invoices.service.ts deleted file mode 100644 index 4af0f296..00000000 --- a/apps/bff/src/modules/invoices/invoices.service.ts +++ /dev/null @@ -1,215 +0,0 @@ -import { Injectable } from "@nestjs/common"; -import { InvoicesOrchestratorService } from "./services/invoices-orchestrator.service"; -import { WhmcsService } from "@bff/integrations/whmcs/whmcs.service"; -import { MappingsService } from "@bff/modules/id-mappings/mappings.service"; -import type { - Invoice, - InvoiceList, - InvoiceSsoLink, - InvoicePaymentLink, - PaymentMethodList, - PaymentGatewayList, -} from "@customer-portal/domain"; - -// Re-export the interface for backward compatibility -export interface GetInvoicesOptions { - page?: number; - limit?: number; - status?: "Paid" | "Unpaid" | "Cancelled" | "Overdue" | "Collections"; -} - -/** - * Invoices Service - now acts as a facade to the orchestrator service - * Maintains backward compatibility while delegating to modular services - */ -@Injectable() -export class InvoicesService { - constructor( - private readonly orchestrator: InvoicesOrchestratorService, - private readonly whmcsService: WhmcsService, - private readonly mappingsService: MappingsService - ) {} - - /** - * Get paginated invoices for a user - */ - async getInvoices(userId: string, options: GetInvoicesOptions = {}): Promise { - return this.orchestrator.getInvoices(userId, options); - } - - /** - * Get individual invoice by ID - */ - async getInvoiceById(userId: string, invoiceId: number): Promise { - return this.orchestrator.getInvoiceById(userId, invoiceId); - } - - /** - * Create SSO link for invoice management - */ - async createInvoiceSsoLink(userId: string, invoiceId?: number): Promise { - const mapping = await this.mappingsService.findByUserId(userId); - if (!mapping?.whmcsClientId) { - throw new Error("WHMCS client mapping not found"); - } - - const ssoResult = await this.whmcsService.createSsoToken( - mapping.whmcsClientId, - invoiceId ? `index.php?rp=/invoice/${invoiceId}` : undefined - ); - - return { - url: ssoResult.url, - expiresAt: ssoResult.expiresAt, - }; - } - - /** - * Get invoices by status - */ - async getInvoicesByStatus( - userId: string, - status: "Paid" | "Unpaid" | "Cancelled" | "Overdue" | "Collections", - options: Pick = {} - ): Promise { - return this.orchestrator.getInvoicesByStatus(userId, status, options); - } - - /** - * Get unpaid invoices for a user - */ - async getUnpaidInvoices( - userId: string, - options: Pick = {} - ): Promise { - return this.orchestrator.getUnpaidInvoices(userId, options); - } - - /** - * Get overdue invoices for a user - */ - async getOverdueInvoices( - userId: string, - options: Pick = {} - ): Promise { - return this.orchestrator.getOverdueInvoices(userId, options); - } - - /** - * Get paid invoices for a user - */ - async getPaidInvoices( - userId: string, - options: Pick = {} - ): Promise { - return this.orchestrator.getPaidInvoices(userId, options); - } - - /** - * Get cancelled invoices for a user - */ - async getCancelledInvoices( - userId: string, - options: Pick = {} - ): Promise { - return this.orchestrator.getCancelledInvoices(userId, options); - } - - /** - * Get invoices in collections for a user - */ - async getCollectionsInvoices( - userId: string, - options: Pick = {} - ): Promise { - return this.orchestrator.getCollectionsInvoices(userId, options); - } - - /** - * Create payment link for a specific invoice - */ - async createInvoicePaymentLink( - userId: string, - invoiceId: number, - gatewayName: string, - returnUrl: string - ): Promise { - const mapping = await this.mappingsService.findByUserId(userId); - if (!mapping?.whmcsClientId) { - throw new Error("WHMCS client mapping not found"); - } - - const ssoResult = await this.whmcsService.createPaymentSsoToken( - mapping.whmcsClientId, - invoiceId, - undefined, - gatewayName - ); - - return { - url: ssoResult.url, - expiresAt: ssoResult.expiresAt, - gatewayName, - }; - } - - /** - * Get payment methods for a user - */ - async getPaymentMethods(userId: string): Promise { - const mapping = await this.mappingsService.findByUserId(userId); - if (!mapping?.whmcsClientId) { - throw new Error("WHMCS client mapping not found"); - } - return this.whmcsService.getPaymentMethods(mapping.whmcsClientId, userId); - } - - /** - * Get available payment gateways - */ - async getPaymentGateways(): Promise { - return this.whmcsService.getPaymentGateways(); - } - - /** - * Invalidate payment methods cache for a user - */ - async invalidatePaymentMethodsCache(userId: string): Promise { - return this.whmcsService.invalidatePaymentMethodsCache(userId); - } - - /** - * Health check for invoice service - */ - async healthCheck(): Promise<{ status: string; details: unknown }> { - const health = await this.orchestrator.healthCheck(); - return { - status: health.status, - details: health.details, - }; - } - - /** - * Get service statistics - */ - getServiceStats() { - return this.orchestrator.getServiceStats(); - } - - /** - * Check if user has any invoices - */ - async hasInvoices(userId: string): Promise { - return this.orchestrator.hasInvoices(userId); - } - - /** - * Get invoice count by status - */ - async getInvoiceCountByStatus( - userId: string, - status: "Paid" | "Unpaid" | "Cancelled" | "Overdue" | "Collections" - ): Promise { - return this.orchestrator.getInvoiceCountByStatus(userId, status); - } -} \ No newline at end of file diff --git a/apps/bff/src/modules/orders/services/order-validator.service.ts b/apps/bff/src/modules/orders/services/order-validator.service.ts index 5d6b4e32..d6403bad 100644 --- a/apps/bff/src/modules/orders/services/order-validator.service.ts +++ b/apps/bff/src/modules/orders/services/order-validator.service.ts @@ -2,7 +2,7 @@ import { Injectable, BadRequestException, Inject } from "@nestjs/common"; import { Logger } from "nestjs-pino"; import { ZodError } from "zod"; import { MappingsService } from "@bff/modules/id-mappings/mappings.service"; -import { WhmcsConnectionService } from "@bff/integrations/whmcs/services/whmcs-connection.service"; +import { WhmcsConnectionOrchestratorService } from "@bff/integrations/whmcs/connection/services/whmcs-connection-orchestrator.service"; import { getErrorMessage } from "@bff/core/utils/error.util"; import { createOrderRequestSchema, @@ -20,7 +20,7 @@ export class OrderValidator { constructor( @Inject(Logger) private readonly logger: Logger, private readonly mappings: MappingsService, - private readonly whmcs: WhmcsConnectionService, + private readonly whmcs: WhmcsConnectionOrchestratorService, private readonly pricebookService: OrderPricebookService ) {} diff --git a/apps/bff/src/modules/orders/services/sim-fulfillment.service.ts b/apps/bff/src/modules/orders/services/sim-fulfillment.service.ts index 182016b5..667c689f 100644 --- a/apps/bff/src/modules/orders/services/sim-fulfillment.service.ts +++ b/apps/bff/src/modules/orders/services/sim-fulfillment.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { FreebitService } from "@bff/integrations/freebit/freebit.service"; +import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service"; import type { FulfillmentOrderDetails, FulfillmentOrderItem } from "../types/fulfillment.types"; import { getErrorMessage } from "@bff/core/utils/error.util"; @@ -12,7 +12,7 @@ export interface SimFulfillmentRequest { @Injectable() export class SimFulfillmentService { constructor( - private readonly freebit: FreebitService, + private readonly freebit: FreebitOrchestratorService, @Inject(Logger) private readonly logger: Logger ) {} diff --git a/apps/bff/src/modules/subscriptions/sim-management/services/esim-management.service.ts b/apps/bff/src/modules/subscriptions/sim-management/services/esim-management.service.ts index 6bfd1d2c..da1583d1 100644 --- a/apps/bff/src/modules/subscriptions/sim-management/services/esim-management.service.ts +++ b/apps/bff/src/modules/subscriptions/sim-management/services/esim-management.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject, BadRequestException } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { FreebitService } from "@bff/integrations/freebit/freebit.service"; +import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service"; import { SimValidationService } from "./sim-validation.service"; import { SimNotificationService } from "./sim-notification.service"; import { getErrorMessage } from "@bff/core/utils/error.util"; @@ -8,7 +8,7 @@ import { getErrorMessage } from "@bff/core/utils/error.util"; @Injectable() export class EsimManagementService { constructor( - private readonly freebitService: FreebitService, + private readonly freebitService: FreebitOrchestratorService, private readonly simValidation: SimValidationService, private readonly simNotification: SimNotificationService, @Inject(Logger) private readonly logger: Logger diff --git a/apps/bff/src/modules/subscriptions/sim-management/services/sim-cancellation.service.ts b/apps/bff/src/modules/subscriptions/sim-management/services/sim-cancellation.service.ts index 1d85e9cb..d35fe3c6 100644 --- a/apps/bff/src/modules/subscriptions/sim-management/services/sim-cancellation.service.ts +++ b/apps/bff/src/modules/subscriptions/sim-management/services/sim-cancellation.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject, BadRequestException } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { FreebitService } from "@bff/integrations/freebit/freebit.service"; +import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service"; import { SimValidationService } from "./sim-validation.service"; import { SimNotificationService } from "./sim-notification.service"; import { getErrorMessage } from "@bff/core/utils/error.util"; @@ -9,7 +9,7 @@ import type { SimCancelRequest } from "../types/sim-requests.types"; @Injectable() export class SimCancellationService { constructor( - private readonly freebitService: FreebitService, + private readonly freebitService: FreebitOrchestratorService, private readonly simValidation: SimValidationService, private readonly simNotification: SimNotificationService, @Inject(Logger) private readonly logger: Logger diff --git a/apps/bff/src/modules/subscriptions/sim-management/services/sim-details.service.ts b/apps/bff/src/modules/subscriptions/sim-management/services/sim-details.service.ts index a4d9d760..679d63cd 100644 --- a/apps/bff/src/modules/subscriptions/sim-management/services/sim-details.service.ts +++ b/apps/bff/src/modules/subscriptions/sim-management/services/sim-details.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { FreebitService } from "@bff/integrations/freebit/freebit.service"; +import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service"; import { SimValidationService } from "./sim-validation.service"; import { getErrorMessage } from "@bff/core/utils/error.util"; import type { SimDetails } from "@bff/integrations/freebit/interfaces/freebit.types"; @@ -8,7 +8,7 @@ import type { SimDetails } from "@bff/integrations/freebit/interfaces/freebit.ty @Injectable() export class SimDetailsService { constructor( - private readonly freebitService: FreebitService, + private readonly freebitService: FreebitOrchestratorService, private readonly simValidation: SimValidationService, @Inject(Logger) private readonly logger: Logger ) {} diff --git a/apps/bff/src/modules/subscriptions/sim-management/services/sim-plan.service.ts b/apps/bff/src/modules/subscriptions/sim-management/services/sim-plan.service.ts index 2bce97b5..2df52c51 100644 --- a/apps/bff/src/modules/subscriptions/sim-management/services/sim-plan.service.ts +++ b/apps/bff/src/modules/subscriptions/sim-management/services/sim-plan.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject, BadRequestException } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { FreebitService } from "@bff/integrations/freebit/freebit.service"; +import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service"; import { SimValidationService } from "./sim-validation.service"; import { SimNotificationService } from "./sim-notification.service"; import { getErrorMessage } from "@bff/core/utils/error.util"; @@ -12,7 +12,7 @@ import type { @Injectable() export class SimPlanService { constructor( - private readonly freebitService: FreebitService, + private readonly freebitService: FreebitOrchestratorService, private readonly simValidation: SimValidationService, private readonly simNotification: SimNotificationService, @Inject(Logger) private readonly logger: Logger diff --git a/apps/bff/src/modules/subscriptions/sim-management/services/sim-topup.service.ts b/apps/bff/src/modules/subscriptions/sim-management/services/sim-topup.service.ts index c55d50c3..0fe1c3bd 100644 --- a/apps/bff/src/modules/subscriptions/sim-management/services/sim-topup.service.ts +++ b/apps/bff/src/modules/subscriptions/sim-management/services/sim-topup.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject, BadRequestException } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { FreebitService } from "@bff/integrations/freebit/freebit.service"; +import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service"; import { WhmcsService } from "@bff/integrations/whmcs/whmcs.service"; import { MappingsService } from "@bff/modules/id-mappings/mappings.service"; import { SimValidationService } from "./sim-validation.service"; @@ -11,7 +11,7 @@ import type { SimTopUpRequest } from "../types/sim-requests.types"; @Injectable() export class SimTopUpService { constructor( - private readonly freebitService: FreebitService, + private readonly freebitService: FreebitOrchestratorService, private readonly whmcsService: WhmcsService, private readonly mappingsService: MappingsService, private readonly simValidation: SimValidationService, diff --git a/apps/bff/src/modules/subscriptions/sim-management/services/sim-usage.service.ts b/apps/bff/src/modules/subscriptions/sim-management/services/sim-usage.service.ts index 2cea3563..bf045256 100644 --- a/apps/bff/src/modules/subscriptions/sim-management/services/sim-usage.service.ts +++ b/apps/bff/src/modules/subscriptions/sim-management/services/sim-usage.service.ts @@ -1,6 +1,6 @@ import { Injectable, Inject } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { FreebitService } from "@bff/integrations/freebit/freebit.service"; +import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service"; import { SimValidationService } from "./sim-validation.service"; import { SimUsageStoreService } from "../../sim-usage-store.service"; import { getErrorMessage } from "@bff/core/utils/error.util"; @@ -14,7 +14,7 @@ import { BadRequestException } from "@nestjs/common"; @Injectable() export class SimUsageService { constructor( - private readonly freebitService: FreebitService, + private readonly freebitService: FreebitOrchestratorService, private readonly simValidation: SimValidationService, private readonly usageStore: SimUsageStoreService, @Inject(Logger) private readonly logger: Logger diff --git a/apps/bff/src/modules/subscriptions/sim-order-activation.service.ts b/apps/bff/src/modules/subscriptions/sim-order-activation.service.ts index 9a2860f3..4ec279d6 100644 --- a/apps/bff/src/modules/subscriptions/sim-order-activation.service.ts +++ b/apps/bff/src/modules/subscriptions/sim-order-activation.service.ts @@ -1,6 +1,6 @@ import { Injectable, BadRequestException, Inject } from "@nestjs/common"; import { Logger } from "nestjs-pino"; -import { FreebitService } from "@bff/integrations/freebit/freebit.service"; +import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service"; import { WhmcsService } from "@bff/integrations/whmcs/whmcs.service"; import { MappingsService } from "@bff/modules/id-mappings/mappings.service"; import { getErrorMessage } from "@bff/core/utils/error.util"; @@ -31,7 +31,7 @@ export interface SimOrderActivationRequest { @Injectable() export class SimOrderActivationService { constructor( - private readonly freebit: FreebitService, + private readonly freebit: FreebitOrchestratorService, private readonly whmcs: WhmcsService, private readonly mappings: MappingsService, @Inject(Logger) private readonly logger: Logger diff --git a/apps/bff/src/modules/users/users.service.ts b/apps/bff/src/modules/users/users.service.ts index aff82ea8..00bcd011 100644 --- a/apps/bff/src/modules/users/users.service.ts +++ b/apps/bff/src/modules/users/users.service.ts @@ -53,7 +53,6 @@ export class UsersService { }; } - // Remove the old toUser method as we're using toDomainUser directly private validateEmail(email: string): string { return normalizeAndValidateEmail(email); diff --git a/packages/domain/src/validation/index.ts b/packages/domain/src/validation/index.ts index 22e483f0..d9bc89f4 100644 --- a/packages/domain/src/validation/index.ts +++ b/packages/domain/src/validation/index.ts @@ -128,7 +128,6 @@ export { contactFormToRequest, } from "./forms/profile"; -// Order and subscription form schemas were legacy-specific; remove exports if not in use // SIM configuration forms export {