2025-10-03 14:26:55 +09:00
|
|
|
/**
|
|
|
|
|
* Orders Domain - Contract
|
2025-12-25 13:20:45 +09:00
|
|
|
*
|
2025-10-08 10:33:33 +09:00
|
|
|
* Business types and provider-specific mapping types.
|
|
|
|
|
* Validated types are derived from schemas (see schema.ts).
|
2025-10-03 14:26:55 +09:00
|
|
|
*/
|
|
|
|
|
|
2025-12-10 15:22:10 +09:00
|
|
|
import type { UserIdMapping } from "../mappings/contract.js";
|
|
|
|
|
import type { SalesforceOrderRecord } from "./providers/salesforce/raw.types.js";
|
|
|
|
|
import type { OrderConfigurations } from "./schema.js";
|
2025-10-03 14:26:55 +09:00
|
|
|
|
2025-10-08 11:11:05 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
// Order Type Constants
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Order types available in the system
|
|
|
|
|
*/
|
|
|
|
|
export const ORDER_TYPE = {
|
|
|
|
|
INTERNET: "Internet",
|
|
|
|
|
SIM: "SIM",
|
|
|
|
|
VPN: "VPN",
|
|
|
|
|
OTHER: "Other",
|
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
export type OrderTypeValue = (typeof ORDER_TYPE)[keyof typeof ORDER_TYPE];
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
// Order Status Constants
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Possible order statuses
|
|
|
|
|
*/
|
|
|
|
|
export const ORDER_STATUS = {
|
|
|
|
|
DRAFT: "Draft",
|
|
|
|
|
ACTIVATED: "Activated",
|
|
|
|
|
PENDING: "Pending",
|
|
|
|
|
FAILED: "Failed",
|
|
|
|
|
CANCELLED: "Cancelled",
|
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
export type OrderStatusValue = (typeof ORDER_STATUS)[keyof typeof ORDER_STATUS];
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
// Activation Type Constants
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Order activation types
|
|
|
|
|
*/
|
|
|
|
|
export const ACTIVATION_TYPE = {
|
|
|
|
|
IMMEDIATE: "Immediate",
|
|
|
|
|
SCHEDULED: "Scheduled",
|
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
export type ActivationTypeValue = (typeof ACTIVATION_TYPE)[keyof typeof ACTIVATION_TYPE];
|
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
// SIM Type Constants
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SIM card types
|
|
|
|
|
*/
|
|
|
|
|
export const SIM_TYPE = {
|
|
|
|
|
ESIM: "eSIM",
|
|
|
|
|
PHYSICAL: "Physical SIM",
|
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
export type SimTypeValue = (typeof SIM_TYPE)[keyof typeof SIM_TYPE];
|
|
|
|
|
|
2025-10-27 16:53:19 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
// Internet Access Mode Constants
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Internet access mode types for connection configuration
|
|
|
|
|
*/
|
|
|
|
|
export const ACCESS_MODE = {
|
|
|
|
|
IPOE_BYOR: "IPoE-BYOR",
|
|
|
|
|
IPOE_HGW: "IPoE-HGW",
|
|
|
|
|
PPPOE: "PPPoE",
|
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
export type AccessModeValue = (typeof ACCESS_MODE)[keyof typeof ACCESS_MODE];
|
|
|
|
|
|
2025-10-08 13:46:23 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
// Order Fulfillment Error Codes
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Error codes for order fulfillment operations
|
|
|
|
|
* These represent business-level error categories
|
|
|
|
|
*/
|
|
|
|
|
export const ORDER_FULFILLMENT_ERROR_CODE = {
|
|
|
|
|
PAYMENT_METHOD_MISSING: "PAYMENT_METHOD_MISSING",
|
|
|
|
|
ORDER_NOT_FOUND: "ORDER_NOT_FOUND",
|
|
|
|
|
WHMCS_ERROR: "WHMCS_ERROR",
|
|
|
|
|
MAPPING_ERROR: "MAPPING_ERROR",
|
|
|
|
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
|
|
|
SALESFORCE_ERROR: "SALESFORCE_ERROR",
|
|
|
|
|
PROVISIONING_ERROR: "PROVISIONING_ERROR",
|
|
|
|
|
} as const;
|
|
|
|
|
|
2025-12-25 13:20:45 +09:00
|
|
|
export type OrderFulfillmentErrorCode =
|
2025-10-08 13:46:23 +09:00
|
|
|
(typeof ORDER_FULFILLMENT_ERROR_CODE)[keyof typeof ORDER_FULFILLMENT_ERROR_CODE];
|
|
|
|
|
|
2025-10-03 14:26:55 +09:00
|
|
|
// ============================================================================
|
2025-10-08 10:33:33 +09:00
|
|
|
// Business Types (used internally, not validated at API boundary)
|
2025-10-03 14:26:55 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
|
2025-10-08 10:33:33 +09:00
|
|
|
/**
|
|
|
|
|
* Order creation type used for order creation flows
|
|
|
|
|
*/
|
|
|
|
|
export type OrderCreationType = "Internet" | "SIM" | "VPN" | "Other";
|
2025-10-03 14:26:55 +09:00
|
|
|
|
2025-10-08 10:33:33 +09:00
|
|
|
/**
|
|
|
|
|
* Order status (string literal for flexibility)
|
|
|
|
|
*/
|
|
|
|
|
export type OrderStatus = string;
|
2025-10-03 14:26:55 +09:00
|
|
|
|
2025-10-08 10:33:33 +09:00
|
|
|
/**
|
|
|
|
|
* Order type (string literal for flexibility)
|
|
|
|
|
*/
|
|
|
|
|
export type OrderType = string;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User mapping for order creation (subset of UserIdMapping)
|
|
|
|
|
*/
|
|
|
|
|
export type UserMapping = Pick<UserIdMapping, "userId" | "whmcsClientId" | "sfAccountId">;
|
2025-10-03 14:26:55 +09:00
|
|
|
|
2025-10-22 11:33:23 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
// Checkout Types
|
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Individual item in checkout cart
|
|
|
|
|
*/
|
|
|
|
|
export interface CheckoutItem {
|
|
|
|
|
id: string;
|
|
|
|
|
sku: string;
|
|
|
|
|
name: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
monthlyPrice?: number;
|
|
|
|
|
oneTimePrice?: number;
|
|
|
|
|
quantity: number;
|
2025-12-25 13:20:45 +09:00
|
|
|
itemType: "plan" | "installation" | "addon" | "activation" | "vpn";
|
2025-10-22 11:33:23 +09:00
|
|
|
autoAdded?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checkout totals calculation
|
|
|
|
|
*/
|
|
|
|
|
export interface CheckoutTotals {
|
|
|
|
|
monthlyTotal: number;
|
|
|
|
|
oneTimeTotal: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Complete checkout cart with items, totals, and configuration
|
|
|
|
|
*/
|
|
|
|
|
export interface CheckoutCart {
|
|
|
|
|
items: CheckoutItem[];
|
|
|
|
|
totals: CheckoutTotals;
|
|
|
|
|
configuration: OrderConfigurations;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Order creation response from BFF
|
|
|
|
|
*/
|
|
|
|
|
export interface OrderCreateResponse {
|
|
|
|
|
sfOrderId: string;
|
|
|
|
|
status: string;
|
|
|
|
|
message: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Order fulfillment validation result
|
|
|
|
|
*/
|
|
|
|
|
export interface OrderFulfillmentValidationResult {
|
|
|
|
|
sfOrder: SalesforceOrderRecord;
|
|
|
|
|
clientId: number;
|
|
|
|
|
isAlreadyProvisioned: boolean;
|
|
|
|
|
whmcsOrderId?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-03 14:26:55 +09:00
|
|
|
// ============================================================================
|
2025-10-08 10:33:33 +09:00
|
|
|
// Re-export Types from Schema (Schema-First Approach)
|
2025-10-03 14:26:55 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
|
2025-10-08 10:33:33 +09:00
|
|
|
export type {
|
|
|
|
|
// Order item types
|
|
|
|
|
OrderItemSummary,
|
|
|
|
|
OrderItemDetails,
|
|
|
|
|
// Order types
|
|
|
|
|
OrderSummary,
|
|
|
|
|
OrderDetails,
|
|
|
|
|
// Query and creation types
|
|
|
|
|
OrderQueryParams,
|
|
|
|
|
OrderConfigurationsAddress,
|
|
|
|
|
OrderConfigurations,
|
|
|
|
|
CreateOrderRequest,
|
|
|
|
|
OrderBusinessValidation,
|
|
|
|
|
SfOrderIdParam,
|
2025-12-25 13:20:45 +09:00
|
|
|
} from "./schema.js";
|