- Remove validation wrapper functions from common/validation.ts (use Zod schemas directly) - Delete duplicate CheckoutItem/CheckoutTotals/CheckoutCart/OrderCreateResponse from orders/contract.ts - Delete empty orders/checkout.ts - Remove unused MIGRATION_STEPS/MIGRATION_TRANSFER_ITEMS UI constants from auth/forms.ts - Standardize checkout/contract.ts to not re-export schema types - Fix customer/providers/index.ts to not re-export contract types through providers barrel
139 lines
4.0 KiB
TypeScript
139 lines
4.0 KiB
TypeScript
/**
|
|
* Orders Domain - Contract
|
|
*
|
|
* Business types and provider-specific mapping types.
|
|
* Validated types are derived from schemas (see schema.ts).
|
|
*/
|
|
|
|
// ============================================================================
|
|
// 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];
|
|
|
|
// ============================================================================
|
|
// 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];
|
|
|
|
// ============================================================================
|
|
// 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;
|
|
|
|
export type OrderFulfillmentErrorCode =
|
|
(typeof ORDER_FULFILLMENT_ERROR_CODE)[keyof typeof ORDER_FULFILLMENT_ERROR_CODE];
|
|
|
|
// ============================================================================
|
|
// Business Types (used internally, not validated at API boundary)
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Order creation type used for order creation flows
|
|
*/
|
|
export type OrderCreationType = "Internet" | "SIM" | "VPN" | "Other";
|
|
|
|
/**
|
|
* Order status (string literal for flexibility)
|
|
*/
|
|
export type OrderStatus = string;
|
|
|
|
/**
|
|
* Order type (string literal for flexibility)
|
|
*/
|
|
export type OrderType = string;
|
|
|
|
/**
|
|
* User mapping for order creation
|
|
*/
|
|
export interface UserMapping {
|
|
userId: string;
|
|
whmcsClientId: number;
|
|
sfAccountId?: string | null | undefined;
|
|
}
|
|
|
|
// NOTE: Provider-specific fulfillment types are intentionally not part of the public orders contract.
|
|
// BFF integration code should import them from:
|
|
// @customer-portal/domain/orders/providers
|
|
//
|
|
// Checkout types (CheckoutItem, CheckoutTotals, CheckoutCart, OrderCreateResponse)
|
|
// and other schema-derived types are exported from schema.ts directly.
|