Phase 1: Portal Duplication Cleanup - Delete apps/portal/src/lib/ directory (12 duplicate files) - Update imports to use canonical locations (core/, shared/) Phase 2: Domain Package Standardization - Add contract.ts to notifications and checkout modules - Update billing schema to derive enums from contract Phase 3: BFF Error Handling - Remove hardcoded test SIM number from SimValidationService - Use ConfigService for TEST_SIM_ACCOUNT env variable Phase 4: Circular Dependency Resolution - Create VoiceOptionsModule to break FreebitModule <-> SimManagementModule cycle - Remove forwardRef usage between these modules - Move SimVoiceOptionsService to new voice-options module Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
59 lines
2.1 KiB
TypeScript
59 lines
2.1 KiB
TypeScript
/**
|
|
* Checkout Domain - Schemas
|
|
*
|
|
* Zod validation schemas for checkout flow.
|
|
* Supports authenticated checkout.
|
|
*/
|
|
|
|
import { z } from "zod";
|
|
import { CHECKOUT_ORDER_TYPE } from "./contract.js";
|
|
|
|
// ============================================================================
|
|
// Order Type Schema
|
|
// ============================================================================
|
|
|
|
const CHECKOUT_ORDER_TYPE_VALUES = Object.values(CHECKOUT_ORDER_TYPE) as [string, ...string[]];
|
|
|
|
/**
|
|
* Checkout order types - uses PascalCase to match Salesforce/BFF contracts
|
|
* @see packages/domain/orders/contract.ts ORDER_TYPE for canonical values
|
|
*/
|
|
export const checkoutOrderTypeSchema = z.enum(CHECKOUT_ORDER_TYPE_VALUES);
|
|
|
|
// ============================================================================
|
|
// Price Breakdown Schema
|
|
// ============================================================================
|
|
|
|
export const priceBreakdownItemSchema = z.object({
|
|
label: z.string(),
|
|
sku: z.string().optional(),
|
|
monthlyPrice: z.number().optional(),
|
|
oneTimePrice: z.number().optional(),
|
|
quantity: z.number().optional().default(1),
|
|
});
|
|
|
|
// ============================================================================
|
|
// Cart Item Schema
|
|
// ============================================================================
|
|
|
|
export const cartItemSchema = z.object({
|
|
orderType: checkoutOrderTypeSchema,
|
|
planSku: z.string().min(1, "Plan SKU is required"),
|
|
planName: z.string().min(1, "Plan name is required"),
|
|
addonSkus: z.array(z.string()).default([]),
|
|
configuration: z.record(z.string(), z.unknown()).default({}),
|
|
pricing: z.object({
|
|
monthlyTotal: z.number().nonnegative(),
|
|
oneTimeTotal: z.number().nonnegative(),
|
|
breakdown: z.array(priceBreakdownItemSchema).default([]),
|
|
}),
|
|
});
|
|
|
|
// ============================================================================
|
|
// Inferred Types
|
|
// ============================================================================
|
|
|
|
export type OrderType = z.infer<typeof checkoutOrderTypeSchema>;
|
|
export type PriceBreakdownItem = z.infer<typeof priceBreakdownItemSchema>;
|
|
export type CartItem = z.infer<typeof cartItemSchema>;
|