Refactor import paths across various services and controllers to align with the new domain structure, enhancing type safety and maintainability. Update Freebit integration to utilize provider methods for account normalization and schema validation. Streamline order-related services by importing types from the updated domain package, improving organization and consistency in data handling.
This commit is contained in:
parent
9740814c10
commit
71df9add8a
@ -310,7 +310,7 @@ export interface FreebitEsimAccountActivationResponse {
|
||||
}
|
||||
|
||||
// Portal-specific types for SIM management
|
||||
export type { SimDetails, SimUsage, SimTopUpHistory } from "@customer-portal/contracts/sim";
|
||||
export type { SimDetails, SimUsage, SimTopUpHistory } from "@customer-portal/domain/sim";
|
||||
|
||||
// Error handling
|
||||
export interface FreebitError extends Error {
|
||||
|
||||
@ -6,7 +6,6 @@ import type {
|
||||
} from "../interfaces/freebit.types";
|
||||
import type { SimDetails, SimTopUpHistory, SimUsage } from "@customer-portal/domain/sim";
|
||||
import { Providers } from "@customer-portal/domain/sim";
|
||||
import { normalizeAccount as normalizeAccountUtil } from "@customer-portal/integrations-freebit/utils";
|
||||
|
||||
@Injectable()
|
||||
export class FreebitMapperService {
|
||||
@ -35,7 +34,7 @@ export class FreebitMapperService {
|
||||
* Normalize account identifier (remove formatting)
|
||||
*/
|
||||
normalizeAccount(account: string): string {
|
||||
return normalizeAccountUtil(account);
|
||||
return Providers.Freebit.normalizeAccount(account);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -221,7 +221,7 @@ export class FreebitOperationsService {
|
||||
): Promise<{ ipv4?: string; ipv6?: string }> {
|
||||
// Import and validate with the schema
|
||||
const { freebitPlanChangeRequestSchema } = await import(
|
||||
"@customer-portal/schemas/integrations/freebit/requests/plan-change.schema"
|
||||
"@customer-portal/domain/sim/providers/freebit/requests"
|
||||
);
|
||||
|
||||
try {
|
||||
@ -281,7 +281,7 @@ export class FreebitOperationsService {
|
||||
try {
|
||||
// Import and validate with the new schema
|
||||
const { freebitSimFeaturesRequestSchema } = await import(
|
||||
"@customer-portal/schemas/integrations/freebit/requests/features.schema"
|
||||
"@customer-portal/domain/sim/providers/freebit/requests"
|
||||
);
|
||||
|
||||
const validatedFeatures = freebitSimFeaturesRequestSchema.parse({
|
||||
@ -481,7 +481,7 @@ export class FreebitOperationsService {
|
||||
|
||||
// Import schemas dynamically to avoid circular dependencies
|
||||
const { freebitEsimActivationParamsSchema, freebitEsimActivationRequestSchema } = await import(
|
||||
"@customer-portal/schemas/integrations/freebit/requests/esim-activation.schema"
|
||||
"@customer-portal/domain/sim/providers/freebit/requests"
|
||||
);
|
||||
|
||||
// Validate input parameters
|
||||
|
||||
@ -8,7 +8,7 @@ import {
|
||||
sfOrderIdParamSchema,
|
||||
type CreateOrderRequest,
|
||||
type SfOrderIdParam,
|
||||
} from "@customer-portal/domain";
|
||||
} from "@customer-portal/domain/orders";
|
||||
|
||||
@Controller("orders")
|
||||
export class OrdersController {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import type { OrderBusinessValidation, UserMapping } from "@customer-portal/domain";
|
||||
import type { OrderBusinessValidation, UserMapping } from "@customer-portal/domain/orders";
|
||||
import { SalesforceFieldMapService, type SalesforceFieldMap } from "@bff/core/config/field-map";
|
||||
import { UsersService } from "@bff/modules/users/users.service";
|
||||
type OrderBuilderFieldKey =
|
||||
|
||||
@ -16,7 +16,15 @@ import { SimFulfillmentService } from "./sim-fulfillment.service";
|
||||
import { DistributedTransactionService } from "@bff/core/database/services/distributed-transaction.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
import { SalesforceFieldMapService } from "@bff/core/config/field-map";
|
||||
import type { OrderDetailsResponse } from "@customer-portal/domain";
|
||||
import type { OrderDetailsResponse } from "@customer-portal/domain/orders";
|
||||
import {
|
||||
orderSummarySchema,
|
||||
orderStatusSchema,
|
||||
z,
|
||||
type OrderSummary,
|
||||
type SalesforceOrderRecord,
|
||||
type SalesforceOrderItemRecord,
|
||||
} from "@customer-portal/domain/orders";
|
||||
import type { FulfillmentOrderDetails, FulfillmentOrderItem } from "../types/fulfillment.types";
|
||||
|
||||
export interface OrderFulfillmentStep {
|
||||
|
||||
@ -4,9 +4,9 @@ import { SalesforceService } from "@bff/integrations/salesforce/salesforce.servi
|
||||
import { WhmcsPaymentService } from "@bff/integrations/whmcs/services/whmcs-payment.service";
|
||||
import { MappingsService } from "@bff/modules/id-mappings/mappings.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
import type { SalesforceOrderRecord } from "@customer-portal/domain";
|
||||
import type { SalesforceOrderRecord } from "@customer-portal/domain/orders";
|
||||
import { SalesforceFieldMapService, type SalesforceFieldMap } from "@bff/core/config/field-map";
|
||||
import { sfOrderIdParamSchema } from "@customer-portal/domain";
|
||||
import { sfOrderIdParamSchema } from "@customer-portal/domain/orders";
|
||||
type OrderStringFieldKey = "activationStatus";
|
||||
|
||||
export interface OrderFulfillmentValidationResult {
|
||||
|
||||
@ -3,7 +3,7 @@ import { Logger } from "nestjs-pino";
|
||||
import { SalesforceConnection } from "@bff/integrations/salesforce/services/salesforce-connection.service";
|
||||
import { OrderPricebookService } from "./order-pricebook.service";
|
||||
import { PrismaService } from "@bff/infra/database/prisma.service";
|
||||
import { createOrderRequestSchema } from "@customer-portal/domain";
|
||||
import { createOrderRequestSchema } from "@customer-portal/domain/orders";
|
||||
|
||||
/**
|
||||
* Handles building order items from SKU data
|
||||
|
||||
@ -13,7 +13,7 @@ import {
|
||||
type SalesforceOrderItemRecord,
|
||||
type SalesforceQueryResult,
|
||||
type SalesforceProduct2Record,
|
||||
} from "@customer-portal/domain";
|
||||
} from "@customer-portal/domain/orders";
|
||||
import { SalesforceFieldMapService, type SalesforceFieldMap } from "@bff/core/config/field-map";
|
||||
import { assertSalesforceId, buildInClause } from "@bff/integrations/salesforce/utils/soql.util";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
|
||||
@ -4,11 +4,12 @@ import { Logger } from "nestjs-pino";
|
||||
import { SalesforceConnection } from "@bff/integrations/salesforce/services/salesforce-connection.service";
|
||||
import { SalesforceFieldMapService } from "@bff/core/config/field-map";
|
||||
import { getStringField } from "@bff/modules/catalog/utils/salesforce-product.mapper";
|
||||
import type {
|
||||
SalesforcePricebookEntryRecord,
|
||||
SalesforceProduct2Record,
|
||||
SalesforceQueryResult,
|
||||
} from "@customer-portal/domain";
|
||||
import {
|
||||
z,
|
||||
type SalesforceProduct2Record,
|
||||
type SalesforceQueryResult,
|
||||
type SalesforceQueryRecord,
|
||||
} from "@customer-portal/domain/orders";
|
||||
import {
|
||||
assertSalesforceId,
|
||||
buildInClause,
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
orderBusinessValidationSchema,
|
||||
type CreateOrderRequest,
|
||||
type OrderBusinessValidation,
|
||||
} from "@customer-portal/domain";
|
||||
} from "@customer-portal/domain/orders";
|
||||
import type { WhmcsProduct } from "@bff/integrations/whmcs/types/whmcs-api.types";
|
||||
import { OrderPricebookService } from "./order-pricebook.service";
|
||||
|
||||
|
||||
@ -146,3 +146,7 @@ export function transformFreebitQuotaHistory(raw: unknown): SimTopUpHistory {
|
||||
return simTopUpHistorySchema.parse(history);
|
||||
}
|
||||
|
||||
export function normalizeAccount(account: string): string {
|
||||
return account.replace(/\D/g, "");
|
||||
}
|
||||
|
||||
|
||||
@ -168,8 +168,8 @@ export declare const orderConfigurationsSchema: z.ZodObject<{
|
||||
}, z.core.$strip>;
|
||||
export declare const createOrderRequestSchema: z.ZodObject<{
|
||||
orderType: z.ZodEnum<{
|
||||
Internet: "Internet";
|
||||
SIM: "SIM";
|
||||
Internet: "Internet";
|
||||
VPN: "VPN";
|
||||
Other: "Other";
|
||||
}>;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { z } from "zod";
|
||||
export declare const orderBusinessValidationSchema: z.ZodObject<{
|
||||
orderType: z.ZodEnum<{
|
||||
Internet: "Internet";
|
||||
SIM: "SIM";
|
||||
Internet: "Internet";
|
||||
VPN: "VPN";
|
||||
Other: "Other";
|
||||
}>;
|
||||
@ -54,8 +54,8 @@ export declare const skuValidationSchema: z.ZodObject<{
|
||||
sku: z.ZodString;
|
||||
isActive: z.ZodBoolean;
|
||||
productType: z.ZodEnum<{
|
||||
Internet: "Internet";
|
||||
SIM: "SIM";
|
||||
Internet: "Internet";
|
||||
VPN: "VPN";
|
||||
Addon: "Addon";
|
||||
Fee: "Fee";
|
||||
|
||||
@ -31,9 +31,9 @@ export declare const casePrioritySchema: z.ZodEnum<{
|
||||
}>;
|
||||
export declare const paymentStatusSchema: z.ZodEnum<{
|
||||
pending: "pending";
|
||||
processing: "processing";
|
||||
completed: "completed";
|
||||
failed: "failed";
|
||||
processing: "processing";
|
||||
cancelled: "cancelled";
|
||||
refunded: "refunded";
|
||||
}>;
|
||||
@ -164,9 +164,9 @@ export declare const paymentSchema: z.ZodObject<{
|
||||
currency: z.ZodOptional<z.ZodString>;
|
||||
status: z.ZodEnum<{
|
||||
pending: "pending";
|
||||
processing: "processing";
|
||||
completed: "completed";
|
||||
failed: "failed";
|
||||
processing: "processing";
|
||||
cancelled: "cancelled";
|
||||
refunded: "refunded";
|
||||
}>;
|
||||
|
||||
@ -31,9 +31,9 @@ export declare const genderEnum: z.ZodEnum<{
|
||||
other: "other";
|
||||
}>;
|
||||
export declare const statusEnum: z.ZodEnum<{
|
||||
pending: "pending";
|
||||
active: "active";
|
||||
inactive: "inactive";
|
||||
pending: "pending";
|
||||
suspended: "suspended";
|
||||
}>;
|
||||
export declare const priorityEnum: z.ZodEnum<{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user