import { z } from 'zod'; export const callDirectionEnum = z.enum(['inbound', 'outbound']); export const callTriggerReasonEnum = z.enum([ 'critical_stock', 'large_sale', 'anomaly', 'daily_summary', ]); export const callGatewayEnum = z.enum(['africas_talking', 'webrtc_voip']); export const callSessionSchema = z.object({ id: z.string().uuid(), shopId: z.string().uuid(), direction: callDirectionEnum, callerPhone: z.string(), startedAt: z.coerce.date(), endedAt: z.coerce.date().nullable(), durationSeconds: z.number().int().nullable(), triggerReason: callTriggerReasonEnum.nullable(), transcriptSummary: z.string().nullable(), actionsTaken: z .array( z.object({ type: z.string(), product: z.string().optional(), amount: z.number().optional(), }), ) .nullable(), callCost: z.number().nullable(), ownerSatisfaction: z.enum(['helpful', 'not_helpful']).nullable(), gateway: callGatewayEnum, createdAt: z.coerce.date(), }); export const initiateCallSchema = z.object({ targetPhone: z.string(), triggerReason: callTriggerReasonEnum, shopContext: z .object({ criticalItems: z.array(z.string()).optional(), alertMessage: z.string().optional(), }) .optional(), }); export const callStatusSchema = z.object({ sessionId: z.string(), callSessionId: z.string().optional(), isActive: z.boolean(), direction: callDirectionEnum, callerNumber: z.string(), destinationNumber: z.string(), durationInSeconds: z.number().int(), currencyCode: z.string().optional(), amount: z.number().optional(), status: z.enum([ 'ringing', 'in_progress', 'completed', 'failed', 'busy', 'no_answer', ]), }); export const callLogQuerySchema = z.object({ from: z.coerce.date().optional(), to: z.coerce.date().optional(), direction: callDirectionEnum.optional(), page: z.coerce.number().int().min(1).default(1), limit: z.coerce.number().int().min(1).max(100).default(20), }); export type CallSession = z.infer; export type InitiateCallInput = z.infer; export type CallStatus = z.infer; export type CallLogQuery = z.infer;