🔄 cleanup: order with 3 key relations, and ckflow now upto speeded

This commit is contained in:
user
2025-10-20 22:27:06 +03:00
parent 2ed74c267d
commit 10bcbf982a
28 changed files with 190 additions and 1360 deletions

View File

@@ -1,4 +1,5 @@
import { z } from "zod";
import { CheckoutStep } from "../../order/data/enums";
import {
CustomerInfo,
customerInfoModel,
@@ -7,7 +8,7 @@ import {
PaymentDetailsPayload,
paymentDetailsPayloadModel,
} from "../../paymentinfo/data/entities";
import { CheckoutStep } from "../../ticket/data/entities";
import { productModel } from "../../product/data";
// Define action types for the checkout flow
export enum CKActionType {
@@ -57,24 +58,6 @@ export type PendingAction = z.infer<typeof pendingActionModel>;
export const pendingActionsModel = z.array(pendingActionModel);
export type PendingActions = z.infer<typeof pendingActionsModel>;
export const ticketSummaryModel = z.object({
id: z.number().optional(),
ticketId: z.string().optional(),
departure: z.string(),
arrival: z.string(),
departureDate: z.string(),
returnDate: z.string().optional(),
flightType: z.string(),
cabinClass: z.string(),
priceDetails: z.object({
currency: z.string(),
displayPrice: z.number(),
basePrice: z.number().optional(),
discountAmount: z.number().optional(),
}),
});
export type TicketSummary = z.infer<typeof ticketSummaryModel>;
// Core flow information model - what's actually stored in Redis
export const flowInfoModel = z.object({
id: z.coerce.number().optional(),
@@ -87,8 +70,8 @@ export const flowInfoModel = z.object({
isActive: z.boolean().default(true),
lastSyncedAt: z.string().datetime(),
ticketInfo: ticketSummaryModel.optional(),
ticketId: z.number().nullable().optional(),
productInfo: productModel.optional(),
productId: z.number().nullable().optional(),
personalInfoLastSyncedAt: z.string().datetime().optional(),
paymentInfoLastSyncedAt: z.string().datetime().optional(),
@@ -119,7 +102,7 @@ export type FlowInfo = z.infer<typeof flowInfoModel>;
export const feCreateCheckoutFlowPayloadModel = z.object({
domain: z.string(),
refOIds: z.array(z.number()),
ticketId: z.number().optional(),
productId: z.number().optional(),
});
export type FECreateCheckoutFlowPayload = z.infer<
typeof feCreateCheckoutFlowPayloadModel
@@ -130,7 +113,7 @@ export const createCheckoutFlowPayloadModel = z.object({
flowId: z.string(),
domain: z.string(),
refOIds: z.array(z.number()),
ticketId: z.number().optional(),
productId: z.number().optional(),
ipAddress: z.string().default(""),
userAgent: z.string().default(""),
initialUrl: z.string().default(""),