2025-09-11 14:52:26 +09:00
|
|
|
import { Injectable, Inject } from "@nestjs/common";
|
|
|
|
|
import { Logger } from "nestjs-pino";
|
2026-02-03 17:35:47 +09:00
|
|
|
import { FreebitFacade } from "@bff/integrations/freebit/facades/freebit.facade.js";
|
2026-01-30 18:22:00 +09:00
|
|
|
import { SalesforceSIMInventoryService } from "@bff/integrations/salesforce/services/salesforce-sim-inventory.service.js";
|
2025-10-08 16:31:42 +09:00
|
|
|
import type { OrderDetails, OrderItemDetails } from "@customer-portal/domain/orders";
|
2026-01-30 18:22:00 +09:00
|
|
|
import { mapProductToFreebitPlanCode } from "@customer-portal/domain/sim";
|
2025-12-29 15:07:11 +09:00
|
|
|
import { extractErrorMessage } from "@bff/core/utils/error.util.js";
|
2025-10-29 13:29:28 +09:00
|
|
|
import {
|
|
|
|
|
SimActivationException,
|
|
|
|
|
OrderValidationException,
|
2025-12-10 16:08:34 +09:00
|
|
|
} from "@bff/core/exceptions/domain-exceptions.js";
|
2026-02-24 19:05:30 +09:00
|
|
|
import type { FulfillmentConfigurations } from "./fulfillment-context-mapper.service.js";
|
2025-09-11 14:52:26 +09:00
|
|
|
|
2026-01-30 18:22:00 +09:00
|
|
|
/**
|
|
|
|
|
* Contact identity data for PA05-05 voice option registration
|
|
|
|
|
*/
|
|
|
|
|
export interface ContactIdentityData {
|
|
|
|
|
firstnameKanji: string;
|
|
|
|
|
lastnameKanji: string;
|
|
|
|
|
firstnameKana: string;
|
|
|
|
|
lastnameKana: string;
|
|
|
|
|
gender: "M" | "F";
|
|
|
|
|
birthday: string; // YYYYMMDD format
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-05 15:38:59 +09:00
|
|
|
/**
|
|
|
|
|
* Assignment details for Physical SIM inventory
|
|
|
|
|
*/
|
|
|
|
|
export interface SimAssignmentDetails {
|
|
|
|
|
/** Salesforce Account ID to assign the SIM to */
|
|
|
|
|
accountId?: string;
|
|
|
|
|
/** Salesforce Order ID that assigned the SIM */
|
|
|
|
|
orderId?: string;
|
|
|
|
|
/** SIM Type (eSIM or Physical SIM) */
|
|
|
|
|
simType?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-11 14:52:26 +09:00
|
|
|
export interface SimFulfillmentRequest {
|
2025-10-08 16:31:42 +09:00
|
|
|
orderDetails: OrderDetails;
|
2026-02-24 19:05:30 +09:00
|
|
|
configurations: FulfillmentConfigurations;
|
2026-01-30 18:22:00 +09:00
|
|
|
/** Salesforce ID of the assigned Physical SIM (from Assign_Physical_SIM__c) */
|
|
|
|
|
assignedPhysicalSimId?: string;
|
|
|
|
|
/** Voice Mail enabled from Order.SIM_Voice_Mail__c */
|
|
|
|
|
voiceMailEnabled?: boolean;
|
|
|
|
|
/** Call Waiting enabled from Order.SIM_Call_Waiting__c */
|
|
|
|
|
callWaitingEnabled?: boolean;
|
|
|
|
|
/** Contact identity data for PA05-05 */
|
|
|
|
|
contactIdentity?: ContactIdentityData;
|
2026-02-05 15:38:59 +09:00
|
|
|
/** Assignment details for SIM Inventory record (Physical SIM only) */
|
|
|
|
|
assignmentDetails?: SimAssignmentDetails;
|
2025-09-11 14:52:26 +09:00
|
|
|
}
|
|
|
|
|
|
2026-02-02 17:05:54 +09:00
|
|
|
/**
|
|
|
|
|
* Result from SIM fulfillment containing inventory data for WHMCS
|
|
|
|
|
*/
|
|
|
|
|
export interface SimFulfillmentResult {
|
|
|
|
|
/** Whether the SIM was successfully activated */
|
|
|
|
|
activated: boolean;
|
|
|
|
|
/** SIM type that was activated */
|
|
|
|
|
simType: "eSIM" | "Physical SIM";
|
|
|
|
|
/** Phone number from SIM inventory (for WHMCS custom fields) */
|
|
|
|
|
phoneNumber?: string;
|
|
|
|
|
/** PT Number / Serial number from SIM inventory (for WHMCS custom fields) */
|
|
|
|
|
serialNumber?: string;
|
|
|
|
|
/** Salesforce SIM Inventory ID */
|
|
|
|
|
simInventoryId?: string;
|
2026-02-05 15:38:59 +09:00
|
|
|
/** EID for eSIM (for WHMCS custom fields) */
|
|
|
|
|
eid?: string;
|
2026-02-02 17:05:54 +09:00
|
|
|
}
|
|
|
|
|
|
2026-02-17 18:04:13 +09:00
|
|
|
/**
|
|
|
|
|
* MNP configuration extracted from Salesforce order/porting fields
|
|
|
|
|
*/
|
|
|
|
|
interface MnpConfig {
|
|
|
|
|
reserveNumber?: string;
|
|
|
|
|
reserveExpireDate?: string;
|
|
|
|
|
account?: string;
|
|
|
|
|
firstnameKanji?: string;
|
|
|
|
|
lastnameKanji?: string;
|
|
|
|
|
firstnameZenKana?: string;
|
|
|
|
|
lastnameZenKana?: string;
|
|
|
|
|
gender?: string;
|
|
|
|
|
birthday?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-03-07 11:32:31 +09:00
|
|
|
* Map Salesforce gender value to Freebit gender code.
|
|
|
|
|
* Salesforce picklist: "Male", "Female", "Corporate/Other" (or legacy "M", "F")
|
|
|
|
|
* Freebit codes: "M" (Male), "W" (Weiblich/Female), "C" (Corporation)
|
2026-02-17 18:04:13 +09:00
|
|
|
*/
|
|
|
|
|
function mapGenderToFreebit(gender: string): string {
|
2026-03-07 11:32:31 +09:00
|
|
|
const normalized = gender.trim().toLowerCase();
|
|
|
|
|
if (normalized === "female" || normalized === "f") return "W";
|
|
|
|
|
if (normalized === "male" || normalized === "m") return "M";
|
|
|
|
|
if (normalized.startsWith("corporate") || normalized === "c") return "C";
|
2026-02-17 18:04:13 +09:00
|
|
|
return gender;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-11 14:52:26 +09:00
|
|
|
@Injectable()
|
|
|
|
|
export class SimFulfillmentService {
|
|
|
|
|
constructor(
|
2026-02-03 17:35:47 +09:00
|
|
|
private readonly freebitFacade: FreebitFacade,
|
2026-01-30 18:22:00 +09:00
|
|
|
private readonly simInventory: SalesforceSIMInventoryService,
|
2025-09-11 14:52:26 +09:00
|
|
|
@Inject(Logger) private readonly logger: Logger
|
|
|
|
|
) {}
|
|
|
|
|
|
2026-02-02 17:05:54 +09:00
|
|
|
async fulfillSimOrder(request: SimFulfillmentRequest): Promise<SimFulfillmentResult> {
|
2026-01-30 18:22:00 +09:00
|
|
|
const {
|
|
|
|
|
orderDetails,
|
|
|
|
|
configurations,
|
|
|
|
|
assignedPhysicalSimId,
|
|
|
|
|
voiceMailEnabled = false,
|
|
|
|
|
callWaitingEnabled = false,
|
|
|
|
|
contactIdentity,
|
2026-02-05 15:38:59 +09:00
|
|
|
assignmentDetails,
|
2026-01-30 18:22:00 +09:00
|
|
|
} = request;
|
|
|
|
|
|
2026-02-03 17:35:47 +09:00
|
|
|
const simType = this.readEnum(configurations["simType"], ["eSIM", "Physical SIM"]);
|
2025-09-17 18:43:43 +09:00
|
|
|
|
2025-09-11 14:52:26 +09:00
|
|
|
this.logger.log("Starting SIM fulfillment", {
|
|
|
|
|
orderId: orderDetails.id,
|
|
|
|
|
orderType: orderDetails.orderType,
|
2026-01-30 18:22:00 +09:00
|
|
|
simType: simType ?? "(not set)",
|
|
|
|
|
hasAssignedPhysicalSim: !!assignedPhysicalSimId,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
hasContactIdentity: !!contactIdentity,
|
2025-09-11 14:52:26 +09:00
|
|
|
});
|
|
|
|
|
|
2026-01-30 18:22:00 +09:00
|
|
|
// Validate SIM type is explicitly set - don't default to eSIM
|
|
|
|
|
if (!simType) {
|
|
|
|
|
throw new SimActivationException(
|
|
|
|
|
"SIM Type must be explicitly set to 'eSIM' or 'Physical SIM'",
|
|
|
|
|
{
|
|
|
|
|
orderId: orderDetails.id,
|
2026-02-03 17:35:47 +09:00
|
|
|
configuredSimType: configurations["simType"],
|
2026-01-30 18:22:00 +09:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 17:35:47 +09:00
|
|
|
const eid = this.readString(configurations["eid"]);
|
2025-09-25 15:11:28 +09:00
|
|
|
const activationType =
|
2026-02-03 17:35:47 +09:00
|
|
|
this.readEnum(configurations["activationType"], ["Immediate", "Scheduled"]) ?? "Immediate";
|
|
|
|
|
const scheduledAt = this.readString(configurations["scheduledAt"]);
|
|
|
|
|
const phoneNumber = this.readString(configurations["mnpPhone"]);
|
2025-09-11 14:52:26 +09:00
|
|
|
const mnp = this.extractMnpConfig(configurations);
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
const isMnp = !!mnp?.["reserveNumber"];
|
2026-02-17 18:04:13 +09:00
|
|
|
|
|
|
|
|
this.logger.log("MNP detection result", {
|
|
|
|
|
orderId: orderDetails.id,
|
|
|
|
|
isMnp,
|
|
|
|
|
simType,
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
mnpReserveNumber: mnp?.["reserveNumber"],
|
|
|
|
|
mnpHasIdentity: !!(mnp?.["lastnameKanji"] || mnp?.["firstnameKanji"]),
|
|
|
|
|
mnpGender: mnp?.["gender"],
|
2026-02-17 18:04:13 +09:00
|
|
|
});
|
2025-09-11 14:52:26 +09:00
|
|
|
|
2025-09-17 18:43:43 +09:00
|
|
|
const simPlanItem = orderDetails.items.find(
|
2025-10-08 16:31:42 +09:00
|
|
|
(item: OrderItemDetails) =>
|
2025-09-25 15:11:28 +09:00
|
|
|
item.product?.itemClass === "Plan" || item.product?.sku?.toLowerCase().includes("sim")
|
2025-09-11 14:52:26 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!simPlanItem) {
|
2025-10-27 16:53:19 +09:00
|
|
|
throw new OrderValidationException("No SIM plan found in order items", {
|
|
|
|
|
orderId: orderDetails.id,
|
|
|
|
|
});
|
2025-09-11 14:52:26 +09:00
|
|
|
}
|
|
|
|
|
|
2025-09-25 15:11:28 +09:00
|
|
|
const planSku = simPlanItem.product?.sku;
|
2026-01-30 18:22:00 +09:00
|
|
|
const planName = simPlanItem.product?.name;
|
2025-09-11 14:52:26 +09:00
|
|
|
if (!planSku) {
|
2025-10-27 16:53:19 +09:00
|
|
|
throw new OrderValidationException("SIM plan SKU not found", {
|
|
|
|
|
orderId: orderDetails.id,
|
|
|
|
|
itemId: simPlanItem.id,
|
|
|
|
|
});
|
2025-09-11 14:52:26 +09:00
|
|
|
}
|
|
|
|
|
|
2025-09-25 17:01:47 +09:00
|
|
|
if (simType === "eSIM") {
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
return this.fulfillEsim({
|
|
|
|
|
orderDetails,
|
2025-09-25 17:01:47 +09:00
|
|
|
eid,
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
phoneNumber,
|
2025-09-25 17:01:47 +09:00
|
|
|
planSku,
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
planName,
|
|
|
|
|
activationType,
|
|
|
|
|
scheduledAt,
|
|
|
|
|
mnp,
|
2025-09-25 17:01:47 +09:00
|
|
|
});
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
}
|
2026-02-02 17:05:54 +09:00
|
|
|
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
return this.fulfillPhysicalSim({
|
|
|
|
|
orderDetails,
|
|
|
|
|
assignedPhysicalSimId,
|
|
|
|
|
planSku,
|
|
|
|
|
planName,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
contactIdentity,
|
|
|
|
|
assignmentDetails,
|
|
|
|
|
isMnp,
|
|
|
|
|
mnp,
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-09-11 14:52:26 +09:00
|
|
|
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
private async fulfillEsim(params: {
|
|
|
|
|
orderDetails: OrderDetails;
|
|
|
|
|
eid: string | undefined;
|
|
|
|
|
phoneNumber: string | undefined;
|
|
|
|
|
planSku: string;
|
|
|
|
|
planName: string | undefined;
|
|
|
|
|
activationType: "Immediate" | "Scheduled";
|
|
|
|
|
scheduledAt: string | undefined;
|
|
|
|
|
mnp: MnpConfig | undefined;
|
|
|
|
|
}): Promise<SimFulfillmentResult> {
|
|
|
|
|
const { orderDetails, eid, phoneNumber, planSku, planName, activationType, scheduledAt, mnp } =
|
|
|
|
|
params;
|
|
|
|
|
|
|
|
|
|
if (!eid || eid.length < 15) {
|
|
|
|
|
throw new SimActivationException("EID is required for eSIM and must be valid", {
|
2026-01-30 18:22:00 +09:00
|
|
|
orderId: orderDetails.id,
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
simType: "eSIM",
|
|
|
|
|
eidLength: eid?.length,
|
2026-01-30 18:22:00 +09:00
|
|
|
});
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
}
|
2026-01-30 18:22:00 +09:00
|
|
|
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
if (!phoneNumber) {
|
|
|
|
|
throw new SimActivationException("Phone number is required for eSIM activation", {
|
2026-01-30 18:22:00 +09:00
|
|
|
orderId: orderDetails.id,
|
|
|
|
|
});
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
}
|
2026-02-02 17:05:54 +09:00
|
|
|
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
const planCode = mapProductToFreebitPlanCode(planSku, planName);
|
|
|
|
|
if (!planCode) {
|
|
|
|
|
throw new SimActivationException(
|
|
|
|
|
`Unable to map product to Freebit plan code. SKU: ${planSku}, Name: ${planName}`,
|
|
|
|
|
{ orderId: orderDetails.id, planSku, planName }
|
|
|
|
|
);
|
2026-01-30 18:22:00 +09:00
|
|
|
}
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
|
|
|
|
|
await this.activateEsim({
|
|
|
|
|
account: phoneNumber,
|
|
|
|
|
eid,
|
|
|
|
|
planCode,
|
|
|
|
|
activationType,
|
|
|
|
|
...(scheduledAt && { scheduledAt }),
|
|
|
|
|
...(mnp && { mnp }),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.logger.log("eSIM fulfillment completed successfully", {
|
|
|
|
|
orderId: orderDetails.id,
|
|
|
|
|
account: phoneNumber,
|
|
|
|
|
planSku,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
activated: true,
|
|
|
|
|
simType: "eSIM",
|
|
|
|
|
phoneNumber,
|
|
|
|
|
eid,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async fulfillPhysicalSim(params: {
|
|
|
|
|
orderDetails: OrderDetails;
|
|
|
|
|
assignedPhysicalSimId: string | undefined;
|
|
|
|
|
planSku: string;
|
|
|
|
|
planName: string | undefined;
|
|
|
|
|
voiceMailEnabled: boolean;
|
|
|
|
|
callWaitingEnabled: boolean;
|
|
|
|
|
contactIdentity: ContactIdentityData | undefined;
|
|
|
|
|
assignmentDetails: SimAssignmentDetails | undefined;
|
|
|
|
|
isMnp: boolean;
|
|
|
|
|
mnp: MnpConfig | undefined;
|
|
|
|
|
}): Promise<SimFulfillmentResult> {
|
|
|
|
|
const {
|
|
|
|
|
orderDetails,
|
|
|
|
|
assignedPhysicalSimId,
|
|
|
|
|
planSku,
|
|
|
|
|
planName,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
contactIdentity,
|
|
|
|
|
assignmentDetails,
|
|
|
|
|
isMnp,
|
|
|
|
|
mnp,
|
|
|
|
|
} = params;
|
|
|
|
|
|
|
|
|
|
if (!assignedPhysicalSimId) {
|
|
|
|
|
throw new SimActivationException(
|
|
|
|
|
"Physical SIM requires an assigned SIM from inventory (Assign_Physical_SIM__c)",
|
|
|
|
|
{ orderId: orderDetails.id }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const simData = await this.activatePhysicalSim({
|
|
|
|
|
orderId: orderDetails.id,
|
|
|
|
|
simInventoryId: assignedPhysicalSimId,
|
|
|
|
|
planSku,
|
|
|
|
|
planName,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
contactIdentity,
|
|
|
|
|
assignmentDetails,
|
|
|
|
|
isMnp,
|
|
|
|
|
...(mnp && { mnp }),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.logger.log("Physical SIM fulfillment completed successfully", {
|
|
|
|
|
orderId: orderDetails.id,
|
|
|
|
|
simInventoryId: assignedPhysicalSimId,
|
|
|
|
|
planSku,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
phoneNumber: simData.phoneNumber,
|
|
|
|
|
serialNumber: simData.serialNumber,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
activated: true,
|
|
|
|
|
simType: "Physical SIM",
|
|
|
|
|
phoneNumber: simData.phoneNumber,
|
|
|
|
|
serialNumber: simData.serialNumber,
|
|
|
|
|
simInventoryId: assignedPhysicalSimId,
|
|
|
|
|
};
|
2025-09-11 14:52:26 +09:00
|
|
|
}
|
|
|
|
|
|
2026-01-30 18:22:00 +09:00
|
|
|
/**
|
|
|
|
|
* Activate eSIM via Freebit PA05-41 API
|
|
|
|
|
*/
|
|
|
|
|
private async activateEsim(params: {
|
|
|
|
|
account: string;
|
|
|
|
|
eid: string;
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
planCode: string;
|
2026-01-30 18:22:00 +09:00
|
|
|
activationType: "Immediate" | "Scheduled";
|
|
|
|
|
scheduledAt?: string;
|
2026-02-17 18:04:13 +09:00
|
|
|
mnp?: MnpConfig;
|
2026-01-30 18:22:00 +09:00
|
|
|
}): Promise<void> {
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
const { account, eid, planCode, activationType, scheduledAt, mnp } = params;
|
2026-02-17 18:04:13 +09:00
|
|
|
const isMnp = !!mnp?.reserveNumber;
|
|
|
|
|
|
|
|
|
|
this.logger.log("eSIM activation starting", {
|
|
|
|
|
account,
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
planCode,
|
2026-02-17 18:04:13 +09:00
|
|
|
isMnp,
|
|
|
|
|
addKind: isMnp ? "M" : "N",
|
|
|
|
|
aladinOperated: isMnp ? "20" : "10",
|
|
|
|
|
mnpReserveNumber: mnp?.reserveNumber,
|
|
|
|
|
mnpHasIdentity: !!(mnp?.lastnameKanji || mnp?.firstnameKanji),
|
|
|
|
|
mnpGender: mnp?.gender,
|
|
|
|
|
});
|
2025-09-11 14:52:26 +09:00
|
|
|
|
|
|
|
|
try {
|
2026-02-17 18:04:13 +09:00
|
|
|
// Build unified MNP object with both reservation and identity data (all Level 2 per PA05-41)
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
const mnpPayload = isMnp ? this.buildMnpPayload(mnp) : undefined;
|
2026-02-17 18:04:13 +09:00
|
|
|
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
const addKind = isMnp ? ("M" as const) : ("N" as const);
|
|
|
|
|
const aladinOperated = isMnp ? ("20" as const) : ("10" as const);
|
|
|
|
|
const pa0541Params = {
|
2026-01-30 18:22:00 +09:00
|
|
|
account,
|
|
|
|
|
eid,
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
planCode,
|
|
|
|
|
contractLine: "5G" as const,
|
|
|
|
|
simKind: "E0" as const,
|
|
|
|
|
addKind,
|
|
|
|
|
aladinOperated,
|
2026-02-03 17:35:47 +09:00
|
|
|
...(activationType === "Scheduled" && scheduledAt && { shipDate: scheduledAt }),
|
2026-02-17 18:04:13 +09:00
|
|
|
...(mnpPayload && { mnp: mnpPayload }),
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.logger.log("PA05-41 full request payload", {
|
|
|
|
|
account: pa0541Params.account,
|
|
|
|
|
eid: pa0541Params.eid,
|
|
|
|
|
planCode: pa0541Params.planCode,
|
|
|
|
|
contractLine: pa0541Params.contractLine,
|
|
|
|
|
simKind: pa0541Params.simKind,
|
|
|
|
|
addKind: pa0541Params.addKind,
|
|
|
|
|
aladinOperated: pa0541Params.aladinOperated,
|
|
|
|
|
shipDate: pa0541Params.shipDate ?? "not-set",
|
|
|
|
|
hasMnpPayload: !!mnpPayload,
|
|
|
|
|
mnpPayloadFields: mnpPayload ? Object.keys(mnpPayload) : [],
|
|
|
|
|
mnpReserveNumber: mnpPayload?.reserveNumber ?? "not-set",
|
|
|
|
|
mnpGenderMapped: mnpPayload?.gender ?? "not-set",
|
2026-01-30 18:22:00 +09:00
|
|
|
});
|
2025-09-11 14:52:26 +09:00
|
|
|
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
await this.freebitFacade.activateEsimAccountNew(pa0541Params);
|
|
|
|
|
|
|
|
|
|
this.logger.log("eSIM activated successfully via PA05-41", {
|
2026-01-30 18:22:00 +09:00
|
|
|
account,
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
planCode,
|
2026-02-17 18:04:13 +09:00
|
|
|
isMnp,
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
addKind: pa0541Params.addKind,
|
2026-01-30 18:22:00 +09:00
|
|
|
scheduled: activationType === "Scheduled",
|
|
|
|
|
});
|
|
|
|
|
} catch (error: unknown) {
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
this.logger.error("eSIM activation failed via PA05-41", {
|
2026-01-30 18:22:00 +09:00
|
|
|
account,
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
planCode,
|
2026-02-17 18:04:13 +09:00
|
|
|
isMnp,
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
addKind: isMnp ? "M" : "N",
|
|
|
|
|
mnpReserveNumber: mnp?.reserveNumber ?? "not-set",
|
|
|
|
|
mnpFieldCount: mnp ? Object.keys(mnp).length : 0,
|
2026-01-30 18:22:00 +09:00
|
|
|
error: extractErrorMessage(error),
|
|
|
|
|
});
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-02-17 18:04:13 +09:00
|
|
|
* Activate Physical SIM (Black SIM) via Freebit APIs
|
2026-01-30 18:22:00 +09:00
|
|
|
*
|
2026-02-17 18:04:13 +09:00
|
|
|
* Non-MNP flow:
|
2026-01-30 18:22:00 +09:00
|
|
|
* 1. Fetch SIM Inventory details from Salesforce
|
|
|
|
|
* 2. Validate SIM status is "Available"
|
|
|
|
|
* 3. Map product SKU to Freebit plan code
|
2026-02-05 15:38:59 +09:00
|
|
|
* 4. Call Freebit PA02-01 (Account Registration) with createType="new"
|
|
|
|
|
* 5. Call Freebit PA05-05 (Voice Options) to configure voice features
|
|
|
|
|
* 6. Update SIM Inventory status to "Assigned"
|
2026-02-17 18:04:13 +09:00
|
|
|
*
|
|
|
|
|
* MNP flow:
|
|
|
|
|
* 1-3. Same as above
|
|
|
|
|
* 4. Call Freebit PA05-19 (Semi-Black MNP Registration) — replaces PA02-01
|
|
|
|
|
* 5. Call Freebit PA05-05 (Voice Options)
|
|
|
|
|
* 6. Update SIM Inventory status to "Assigned"
|
2026-01-30 18:22:00 +09:00
|
|
|
*/
|
|
|
|
|
private async activatePhysicalSim(params: {
|
|
|
|
|
orderId: string;
|
|
|
|
|
simInventoryId: string;
|
|
|
|
|
planSku: string;
|
2026-02-03 17:35:47 +09:00
|
|
|
planName?: string | undefined;
|
2026-01-30 18:22:00 +09:00
|
|
|
voiceMailEnabled: boolean;
|
|
|
|
|
callWaitingEnabled: boolean;
|
2026-02-03 17:35:47 +09:00
|
|
|
contactIdentity?: ContactIdentityData | undefined;
|
2026-02-05 15:38:59 +09:00
|
|
|
assignmentDetails?: SimAssignmentDetails | undefined;
|
2026-02-17 18:04:13 +09:00
|
|
|
isMnp?: boolean;
|
|
|
|
|
mnp?: MnpConfig;
|
2026-02-02 17:05:54 +09:00
|
|
|
}): Promise<{ phoneNumber: string; serialNumber: string }> {
|
2026-01-30 18:22:00 +09:00
|
|
|
const {
|
|
|
|
|
orderId,
|
|
|
|
|
simInventoryId,
|
|
|
|
|
planSku,
|
|
|
|
|
planName,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
contactIdentity,
|
2026-02-05 15:38:59 +09:00
|
|
|
assignmentDetails,
|
2026-02-17 18:04:13 +09:00
|
|
|
isMnp = false,
|
|
|
|
|
mnp,
|
2026-01-30 18:22:00 +09:00
|
|
|
} = params;
|
|
|
|
|
|
2026-02-17 18:04:13 +09:00
|
|
|
this.logger.log("Starting Physical SIM activation", {
|
2026-01-30 18:22:00 +09:00
|
|
|
orderId,
|
|
|
|
|
simInventoryId,
|
|
|
|
|
planSku,
|
2026-02-17 18:04:13 +09:00
|
|
|
isMnp,
|
|
|
|
|
path: isMnp ? "PA05-19 (MNP)" : "PA02-01 (new)",
|
2026-01-30 18:22:00 +09:00
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
hasContactIdentity: !!contactIdentity,
|
2026-02-17 18:04:13 +09:00
|
|
|
mnpReserveNumber: mnp?.reserveNumber,
|
2026-01-30 18:22:00 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Step 1 & 2: Fetch and validate SIM Inventory
|
|
|
|
|
const simRecord = await this.simInventory.getAndValidateForActivation(simInventoryId);
|
|
|
|
|
|
|
|
|
|
// Step 3: Map product to Freebit plan code
|
|
|
|
|
const planCode = mapProductToFreebitPlanCode(planSku, planName);
|
|
|
|
|
if (!planCode) {
|
|
|
|
|
throw new SimActivationException(
|
|
|
|
|
`Unable to map product to Freebit plan code. SKU: ${planSku}, Name: ${planName}`,
|
|
|
|
|
{ orderId, simInventoryId, planSku, planName }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use phone number from SIM inventory
|
|
|
|
|
const accountPhoneNumber = simRecord.phoneNumber;
|
|
|
|
|
|
|
|
|
|
this.logger.log("Physical SIM inventory validated", {
|
|
|
|
|
orderId,
|
|
|
|
|
simInventoryId,
|
|
|
|
|
accountPhoneNumber,
|
2026-02-17 18:04:13 +09:00
|
|
|
ptNumber: simRecord.ptNumber,
|
2026-01-30 18:22:00 +09:00
|
|
|
planCode,
|
2026-02-17 18:04:13 +09:00
|
|
|
isMnp,
|
2026-01-30 18:22:00 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
try {
|
2026-02-17 18:04:13 +09:00
|
|
|
if (isMnp) {
|
|
|
|
|
// Step 4 (MNP): Call Freebit PA05-19 (Semi-Black MNP Registration)
|
|
|
|
|
// PA05-19 replaces PA02-01 for MNP transfers — it registers the account
|
|
|
|
|
// and initiates the MNP transfer in a single call
|
|
|
|
|
this.logger.log("Calling PA05-19 Semi-Black MNP Registration", {
|
|
|
|
|
orderId,
|
|
|
|
|
account: accountPhoneNumber,
|
|
|
|
|
productNumber: simRecord.ptNumber,
|
|
|
|
|
planCode,
|
|
|
|
|
mnpMethod: "10",
|
|
|
|
|
});
|
2026-01-30 18:22:00 +09:00
|
|
|
|
2026-02-17 18:04:13 +09:00
|
|
|
await this.freebitFacade.registerSemiBlackAccount({
|
|
|
|
|
account: accountPhoneNumber,
|
|
|
|
|
productNumber: simRecord.ptNumber,
|
|
|
|
|
planCode,
|
|
|
|
|
});
|
2026-01-30 18:22:00 +09:00
|
|
|
|
2026-02-17 18:04:13 +09:00
|
|
|
this.logger.log("PA05-19 Semi-Black MNP Registration successful", {
|
|
|
|
|
orderId,
|
|
|
|
|
account: accountPhoneNumber,
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Step 4 (non-MNP): Call Freebit PA02-01 (Account Registration)
|
|
|
|
|
this.logger.log("Calling PA02-01 Account Registration", {
|
|
|
|
|
orderId,
|
|
|
|
|
account: accountPhoneNumber,
|
|
|
|
|
planCode,
|
|
|
|
|
createType: "new",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await this.freebitFacade.registerAccount({
|
|
|
|
|
account: accountPhoneNumber,
|
|
|
|
|
planCode,
|
|
|
|
|
createType: "new",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.logger.log("PA02-01 Account Registration successful", {
|
|
|
|
|
orderId,
|
|
|
|
|
account: accountPhoneNumber,
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-01-30 18:22:00 +09:00
|
|
|
|
2026-02-05 15:38:59 +09:00
|
|
|
// Step 5: Call Freebit PA05-05 (Voice Options Registration)
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
await this.registerVoiceOptionsIfAvailable({
|
|
|
|
|
orderId,
|
|
|
|
|
account: accountPhoneNumber,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
contactIdentity,
|
|
|
|
|
});
|
2026-01-30 18:22:00 +09:00
|
|
|
|
2026-02-05 15:38:59 +09:00
|
|
|
// Step 6: Update SIM Inventory status to "Assigned" with assignment details
|
|
|
|
|
await this.simInventory.markAsAssigned(simInventoryId, assignmentDetails);
|
2026-01-30 18:22:00 +09:00
|
|
|
|
|
|
|
|
this.logger.log("Physical SIM activated successfully", {
|
|
|
|
|
orderId,
|
|
|
|
|
simInventoryId,
|
|
|
|
|
accountPhoneNumber,
|
|
|
|
|
planCode,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
});
|
2026-02-02 17:05:54 +09:00
|
|
|
|
|
|
|
|
// Return SIM data for WHMCS custom fields
|
|
|
|
|
return {
|
|
|
|
|
phoneNumber: simRecord.phoneNumber,
|
|
|
|
|
serialNumber: simRecord.ptNumber,
|
|
|
|
|
};
|
2025-09-25 15:11:28 +09:00
|
|
|
} catch (error: unknown) {
|
2026-01-30 18:22:00 +09:00
|
|
|
this.logger.error("Physical SIM activation failed", {
|
|
|
|
|
orderId,
|
|
|
|
|
simInventoryId,
|
|
|
|
|
phoneNumber: simRecord.phoneNumber,
|
2025-12-29 15:07:11 +09:00
|
|
|
error: extractErrorMessage(error),
|
2025-09-11 14:52:26 +09:00
|
|
|
});
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
private buildMnpPayload(mnp?: MnpConfig) {
|
|
|
|
|
if (!mnp?.reserveNumber) return;
|
|
|
|
|
return {
|
|
|
|
|
reserveNumber: mnp.reserveNumber,
|
|
|
|
|
...(mnp.reserveExpireDate && { reserveExpireDate: mnp.reserveExpireDate }),
|
|
|
|
|
...(mnp.lastnameKanji && { lastnameKanji: mnp.lastnameKanji }),
|
|
|
|
|
...(mnp.firstnameKanji && { firstnameKanji: mnp.firstnameKanji }),
|
|
|
|
|
...(mnp.lastnameZenKana && { lastnameZenKana: mnp.lastnameZenKana }),
|
|
|
|
|
...(mnp.firstnameZenKana && { firstnameZenKana: mnp.firstnameZenKana }),
|
|
|
|
|
// Map Salesforce gender 'F' → Freebit gender 'W' (Weiblich)
|
|
|
|
|
...(mnp.gender && { gender: mapGenderToFreebit(mnp.gender) }),
|
|
|
|
|
...(mnp.birthday && { birthday: mnp.birthday }),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async registerVoiceOptionsIfAvailable(params: {
|
|
|
|
|
orderId: string;
|
|
|
|
|
account: string;
|
|
|
|
|
voiceMailEnabled: boolean;
|
|
|
|
|
callWaitingEnabled: boolean;
|
|
|
|
|
contactIdentity?: ContactIdentityData | undefined;
|
|
|
|
|
}): Promise<void> {
|
|
|
|
|
const { orderId, account, voiceMailEnabled, callWaitingEnabled, contactIdentity } = params;
|
|
|
|
|
|
|
|
|
|
if (!contactIdentity) {
|
|
|
|
|
this.logger.warn("Skipping PA05-05: No contact identity data provided", {
|
|
|
|
|
orderId,
|
|
|
|
|
account,
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.logger.log("Calling PA05-05 Voice Options Registration", {
|
|
|
|
|
orderId,
|
|
|
|
|
account,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await this.freebitFacade.registerVoiceOptions({
|
|
|
|
|
account,
|
|
|
|
|
voiceMailEnabled,
|
|
|
|
|
callWaitingEnabled,
|
|
|
|
|
identificationData: {
|
|
|
|
|
lastnameKanji: contactIdentity.lastnameKanji,
|
|
|
|
|
firstnameKanji: contactIdentity.firstnameKanji,
|
|
|
|
|
lastnameKana: contactIdentity.lastnameKana,
|
|
|
|
|
firstnameKana: contactIdentity.firstnameKana,
|
|
|
|
|
gender: contactIdentity.gender,
|
|
|
|
|
birthday: contactIdentity.birthday,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.logger.log("PA05-05 Voice Options Registration successful", {
|
|
|
|
|
orderId,
|
|
|
|
|
account,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-25 15:11:28 +09:00
|
|
|
private readString(value: unknown): string | undefined {
|
|
|
|
|
return typeof value === "string" ? value : undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readEnum<T extends string>(value: unknown, allowed: readonly T[]): T | undefined {
|
|
|
|
|
return typeof value === "string" && allowed.includes(value as T) ? (value as T) : undefined;
|
|
|
|
|
}
|
|
|
|
|
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
private static readonly MNP_FIELD_MAPPINGS = [
|
|
|
|
|
{ key: "reserveNumber", sources: ["mnpNumber", "reserveNumber"] },
|
|
|
|
|
{ key: "reserveExpireDate", sources: ["mnpExpiry", "reserveExpireDate"] },
|
|
|
|
|
{ key: "account", sources: ["mvnoAccountNumber", "account"] },
|
|
|
|
|
{ key: "firstnameKanji", sources: ["portingFirstName", "firstnameKanji"] },
|
|
|
|
|
{ key: "lastnameKanji", sources: ["portingLastName", "lastnameKanji"] },
|
|
|
|
|
{ key: "firstnameZenKana", sources: ["portingFirstNameKatakana", "firstnameZenKana"] },
|
|
|
|
|
{ key: "lastnameZenKana", sources: ["portingLastNameKatakana", "lastnameZenKana"] },
|
|
|
|
|
{ key: "gender", sources: ["portingGender", "gender"] },
|
|
|
|
|
{ key: "birthday", sources: ["portingDateOfBirth", "birthday"] },
|
|
|
|
|
] as const;
|
|
|
|
|
|
2026-02-24 19:05:30 +09:00
|
|
|
private extractMnpConfig(config: FulfillmentConfigurations) {
|
2026-02-03 17:35:47 +09:00
|
|
|
const nested = config["mnp"];
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
const hasNestedMnp = nested && typeof nested === "object";
|
2026-02-24 19:05:30 +09:00
|
|
|
const source = hasNestedMnp ? nested : config;
|
2025-09-25 15:11:28 +09:00
|
|
|
|
2026-02-03 17:35:47 +09:00
|
|
|
const isMnpFlag = this.readString(source["isMnp"] ?? config["isMnp"]);
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
if (isMnpFlag && isMnpFlag.toLowerCase() !== "true") {
|
|
|
|
|
this.logger.log("MNP extraction skipped: isMnp flag is not 'true'", {
|
|
|
|
|
isMnpFlag,
|
|
|
|
|
isMnpFlagType: typeof (source["isMnp"] ?? config["isMnp"]),
|
|
|
|
|
});
|
2026-02-03 17:35:47 +09:00
|
|
|
return;
|
2025-09-25 15:11:28 +09:00
|
|
|
}
|
|
|
|
|
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
const result: Record<string, string> = {};
|
|
|
|
|
for (const { key, sources } of SimFulfillmentService.MNP_FIELD_MAPPINGS) {
|
|
|
|
|
const value = this.readString(source[sources[0]] ?? source[sources[1]]);
|
|
|
|
|
if (value) result[key] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Object.keys(result).length === 0) {
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
this.logger.log("MNP extraction: no MNP fields found in config", {
|
|
|
|
|
hasNestedMnp,
|
|
|
|
|
isMnpFlag: isMnpFlag ?? "not-set",
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
checkedKeys: SimFulfillmentService.MNP_FIELD_MAPPINGS.flatMap(m => m.sources),
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
});
|
2026-02-03 17:35:47 +09:00
|
|
|
return;
|
2025-09-11 14:52:26 +09:00
|
|
|
}
|
|
|
|
|
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
this.logger.log("MNP config extracted", {
|
refactor: fix all lint errors and reduce warnings across BFF and domain
Eliminate all 12 ESLint errors (nested ternaries, any types) and reduce
warnings by 13 (duplicate strings, complexity). Key changes:
- Domain: extract helpers for nested ternaries in opportunity/contract and whmcs/mapper
- BFF core: fix any type in safe-operation.util, refactor exception filter to use
options objects, create shared CACHE_CONTROL and normalizeToArray utilities
- Freebit: replace nested ternaries with if/else in client and mapper services
- Sim fulfillment: extract helper methods to reduce complexity (fulfillEsim,
fulfillPhysicalSim, buildMnpPayload, registerVoiceOptionsIfAvailable, MNP_FIELD_MAPPINGS)
- Modules: fix 8 nested ternary violations across validators, services, controllers
- Constants: extract duplicate strings (CSRF, email, orchestrator, cache control)
2026-03-04 10:52:26 +09:00
|
|
|
hasReserveNumber: !!result["reserveNumber"],
|
|
|
|
|
reserveNumberLength: result["reserveNumber"]?.length,
|
|
|
|
|
hasReserveExpireDate: !!result["reserveExpireDate"],
|
|
|
|
|
hasAccount: !!result["account"],
|
|
|
|
|
hasIdentity: !!(result["firstnameKanji"] && result["lastnameKanji"]),
|
|
|
|
|
hasKana: !!(result["firstnameZenKana"] && result["lastnameZenKana"]),
|
|
|
|
|
gender: result["gender"] ?? "not-set",
|
|
|
|
|
hasBirthday: !!result["birthday"],
|
fix: comprehensive SIM audit fixes and MNP debug logging
Address critical, high, and medium issues found during SIM management audit:
Critical: fix eSIM plan code mapping (SKU→PASI), PA05-41 endpoint typo,
PA05-05 gender mapping (F→W) and katakana field names.
High: fix double authKey injection, add MNP/porting fields to SF getOrder
SOQL, add reissue params to eSIM addAcnt, remove console.error debug stmt.
Medium: fix KB/MB conversion (1000→1024), birthday UTC timezone bug, plan
code regex matching "5G" as 5GB, case-insensitive isMnp flag, domain schema
enums (addKind +M, simkind E0/E2/E3), move identity into mnp Level 2.
Frontend: fix SVG donut radius mismatch (r=88→96), fix FreebitError typo.
Add comprehensive MNP debug logging across the entire data flow pipeline:
SF order extraction, config mapping, MNP field parsing, API payload assembly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 18:48:50 +09:00
|
|
|
totalFieldsExtracted: Object.keys(result).length,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return result;
|
2025-09-11 14:52:26 +09:00
|
|
|
}
|
|
|
|
|
}
|