import { z } from "zod";
import { CreateAuthorizeUserSchema } from "../user/types";

export const CreateSessionRequestSchema = z.object({
  feature: z.string().optional(),
  locale: z.string(),
  timezone: z.string(),
  source: z.string(),
  sign: z.boolean(),
  signDate: z.string().optional(),
  utm: z.record(z.string(), z.string()).optional(),
  domain: z.string(),
});

export const UpdateSessionRequestSchema = z.object({
  sessionId: z.string(),
  data: z.object({
    feature: z.string().optional(),
    profile: CreateAuthorizeUserSchema.optional(),
    partner: CreateAuthorizeUserSchema.omit({
      relationship_status: true,
    }).optional(),
    answers: z.record(z.string(), z.unknown()).optional(),
    cookies: z.record(z.string(), z.string()).optional(),
  }),
});

export const CreateSessionResponseSchema = z.object({
  status: z.string(),
  sessionId: z.string(),
});

export const UpdateSessionResponseSchema = z.object({
  status: z.string(),
  message: z.string(),
});

export const GetPixelsRequestSchema = z.object({
  domain: z.string(),
  source: z.string(),
  locale: z.string(),
});

export const GetPixelsResponseSchema = z.object({
  status: z.string(),
  data: z.object({
    fb: z.array(z.string()).optional(),
  }),
});

export type ICreateSessionRequest = z.infer<typeof CreateSessionRequestSchema>;
export type IUpdateSessionRequest = z.infer<typeof UpdateSessionRequestSchema>;
export type ICreateSessionResponse = z.infer<
  typeof CreateSessionResponseSchema
>;
export type IUpdateSessionResponse = z.infer<
  typeof UpdateSessionResponseSchema
>;
export type IGetPixelsRequest = z.infer<typeof GetPixelsRequestSchema>;
export type IGetPixelsResponse = z.infer<typeof GetPixelsResponseSchema>;
