export type Json =
  | string
  | number
  | boolean
  | null
  | { [key: string]: Json | undefined }
  | Json[]

export type Database = {
  public: {
    Tables: {
      call_logs: {
        Row: {
          assistant_id: string | null
          assistant_name: string | null
          assistant_phone_number: string | null
          attempt_number: number
          call_outcome: Database["public"]["Enums"]["call_outcome_enum"] | null
          call_type: Database["public"]["Enums"]["call_type_enum"] | null
          callprovider_id: string | null
          contact_id: string
          cost_llm: number | null
          cost_stt: number | null
          cost_total: number | null
          cost_totals: number | null
          cost_tts: number | null
          cost_twilio: number | null
          created_at: string
          customer_number: string | null
          duration_seconds: number | null
          ended_at: string | null
          ended_reason: string | null
          id: string
          phone_number_id: string | null
          recording_url: string | null
          scheduled_at: string | null
          started_at: string | null
          status: Database["public"]["Enums"]["call_status_enum"]
          summary: string | null
          transcript: string | null
          updated_at: string
          user_id: string | null
          workspace_id: string
        }
        Insert: {
          assistant_id?: string | null
          assistant_name?: string | null
          assistant_phone_number?: string | null
          attempt_number: number
          call_outcome?: Database["public"]["Enums"]["call_outcome_enum"] | null
          call_type?: Database["public"]["Enums"]["call_type_enum"] | null
          callprovider_id?: string | null
          contact_id: string
          cost_llm?: number | null
          cost_stt?: number | null
          cost_total?: number | null
          cost_totals?: number | null
          cost_tts?: number | null
          cost_twilio?: number | null
          created_at: string
          customer_number?: string | null
          duration_seconds?: number | null
          ended_at?: string | null
          ended_reason?: string | null
          id: string
          phone_number_id?: string | null
          recording_url?: string | null
          scheduled_at?: string | null
          started_at?: string | null
          status: Database["public"]["Enums"]["call_status_enum"]
          summary?: string | null
          transcript?: string | null
          updated_at: string
          user_id?: string | null
          workspace_id: string
        }
        Update: {
          assistant_id?: string | null
          assistant_name?: string | null
          assistant_phone_number?: string | null
          attempt_number?: number
          call_outcome?: Database["public"]["Enums"]["call_outcome_enum"] | null
          call_type?: Database["public"]["Enums"]["call_type_enum"] | null
          callprovider_id?: string | null
          contact_id?: string
          cost_llm?: number | null
          cost_stt?: number | null
          cost_total?: number | null
          cost_totals?: number | null
          cost_tts?: number | null
          cost_twilio?: number | null
          created_at?: string
          customer_number?: string | null
          duration_seconds?: number | null
          ended_at?: string | null
          ended_reason?: string | null
          id?: string
          phone_number_id?: string | null
          recording_url?: string | null
          scheduled_at?: string | null
          started_at?: string | null
          status?: Database["public"]["Enums"]["call_status_enum"]
          summary?: string | null
          transcript?: string | null
          updated_at?: string
          user_id?: string | null
          workspace_id?: string
        }
        Relationships: []
      }
      profiles: {
        Row: {
          company_name: string | null
          created_at: string | null
          email: string | null
          full_name: string | null
          id: string
          is_verified: boolean | null
          updated_at: string | null
          username: string | null
        }
        Insert: {
          company_name?: string | null
          created_at?: string | null
          email?: string | null
          full_name?: string | null
          id: string
          is_verified?: boolean | null
          updated_at?: string | null
          username?: string | null
        }
        Update: {
          company_name?: string | null
          created_at?: string | null
          email?: string | null
          full_name?: string | null
          id?: string
          is_verified?: boolean | null
          updated_at?: string | null
          username?: string | null
        }
        Relationships: []
      }
      shoprenter_products_cache: {
        Row: {
          created_at: string | null
          id: string
          last_synced_at: string | null
          product_data: Json
          shoprenter_product_id: string
          store_id: string
          updated_at: string | null
        }
        Insert: {
          created_at?: string | null
          id?: string
          last_synced_at?: string | null
          product_data: Json
          shoprenter_product_id: string
          store_id: string
          updated_at?: string | null
        }
        Update: {
          created_at?: string | null
          id?: string
          last_synced_at?: string | null
          product_data?: Json
          shoprenter_product_id?: string
          store_id?: string
          updated_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "shoprenter_products_cache_store_id_fkey"
            columns: ["store_id"]
            isOneToOne: false
            referencedRelation: "stores"
            referencedColumns: ["id"]
          },
        ]
      }
      shoprenter_tokens: {
        Row: {
          access_token: string
          created_at: string | null
          expires_at: string | null
          id: string
          is_active: boolean | null
          last_sync_at: string | null
          refresh_token: string | null
          scopes: string[] | null
          shop_domain: string
          shopname: string
          store_id: string
          updated_at: string | null
        }
        Insert: {
          access_token: string
          created_at?: string | null
          expires_at?: string | null
          id?: string
          is_active?: boolean | null
          last_sync_at?: string | null
          refresh_token?: string | null
          scopes?: string[] | null
          shop_domain: string
          shopname: string
          store_id: string
          updated_at?: string | null
        }
        Update: {
          access_token?: string
          created_at?: string | null
          expires_at?: string | null
          id?: string
          is_active?: boolean | null
          last_sync_at?: string | null
          refresh_token?: string | null
          scopes?: string[] | null
          shop_domain?: string
          shopname?: string
          store_id?: string
          updated_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "shoprenter_tokens_store_id_fkey"
            columns: ["store_id"]
            isOneToOne: false
            referencedRelation: "stores"
            referencedColumns: ["id"]
          },
        ]
      }
      shoprenter_webhooks: {
        Row: {
          created_at: string | null
          id: string
          is_active: boolean | null
          store_id: string
          topic: string
          updated_at: string | null
          webhook_id: string
          webhook_url: string
        }
        Insert: {
          created_at?: string | null
          id?: string
          is_active?: boolean | null
          store_id: string
          topic: string
          updated_at?: string | null
          webhook_id: string
          webhook_url: string
        }
        Update: {
          created_at?: string | null
          id?: string
          is_active?: boolean | null
          store_id?: string
          topic?: string
          updated_at?: string | null
          webhook_id?: string
          webhook_url?: string
        }
        Relationships: [
          {
            foreignKeyName: "shoprenter_webhooks_store_id_fkey"
            columns: ["store_id"]
            isOneToOne: false
            referencedRelation: "stores"
            referencedColumns: ["id"]
          },
        ]
      }
      stores: {
        Row: {
          access_token: string | null
          alt_data: Json | null
          api_key: string | null
          api_secret: string | null
          connected_at: string | null
          created_at: string | null
          id: string
          is_active: boolean | null
          package: string | null
          phone_number: string | null
          platform_name: string
          refresh_token: string | null
          scopes: string[] | null
          store_name: string | null
          store_url: string | null
          token_expires_at: string | null
          updated_at: string | null
          user_id: string
        }
        Insert: {
          access_token?: string | null
          alt_data?: Json | null
          api_key?: string | null
          api_secret?: string | null
          connected_at?: string | null
          created_at?: string | null
          id?: string
          is_active?: boolean | null
          package?: string | null
          phone_number?: string | null
          platform_name: string
          refresh_token?: string | null
          scopes?: string[] | null
          store_name?: string | null
          store_url?: string | null
          token_expires_at?: string | null
          updated_at?: string | null
          user_id: string
        }
        Update: {
          access_token?: string | null
          alt_data?: Json | null
          api_key?: string | null
          api_secret?: string | null
          connected_at?: string | null
          created_at?: string | null
          id?: string
          is_active?: boolean | null
          package?: string | null
          phone_number?: string | null
          platform_name?: string
          refresh_token?: string | null
          scopes?: string[] | null
          store_name?: string | null
          store_url?: string | null
          token_expires_at?: string | null
          updated_at?: string | null
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "stores_user_id_fkey"
            columns: ["user_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
        ]
      }
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      [_ in never]: never
    }
    Enums: {
      call_outcome_enum:
        | "pending"
        | "resolved"
        | "interested"
        | "potential"
        | "not_interested"
        | "no_answer"
        | "voicemail"
        | "busy"
        | "callback_requested"
        | "false"
      call_status_enum:
        | "pending"
        | "scheduled"
        | "in_progress"
        | "completed"
        | "failed"
        | "cancelled"
      call_type_enum: "inbound" | "outbound" | "inbound_dummy"
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
}

// Type helpers for easier access
export type CallStatus = Database["public"]["Enums"]["call_status_enum"];
export type CallOutcome = Database["public"]["Enums"]["call_outcome_enum"];
export type CallType = Database["public"]["Enums"]["call_type_enum"];

export type CallLog = Database["public"]["Tables"]["call_logs"]["Row"];
export type CallLogInsert = Database["public"]["Tables"]["call_logs"]["Insert"];
export type CallLogUpdate = Database["public"]["Tables"]["call_logs"]["Update"];

export type Profile = Database["public"]["Tables"]["profiles"]["Row"];
export type Store = Database["public"]["Tables"]["stores"]["Row"];

export type ShopRenterToken = Database["public"]["Tables"]["shoprenter_tokens"]["Row"];
export type ShopRenterTokenInsert = Database["public"]["Tables"]["shoprenter_tokens"]["Insert"];
export type ShopRenterTokenUpdate = Database["public"]["Tables"]["shoprenter_tokens"]["Update"];

export type ShopRenterProduct = Database["public"]["Tables"]["shoprenter_products_cache"]["Row"];
export type ShopRenterProductInsert = Database["public"]["Tables"]["shoprenter_products_cache"]["Insert"];
export type ShopRenterProductUpdate = Database["public"]["Tables"]["shoprenter_products_cache"]["Update"];

export type ShopRenterWebhook = Database["public"]["Tables"]["shoprenter_webhooks"]["Row"];
export type ShopRenterWebhookInsert = Database["public"]["Tables"]["shoprenter_webhooks"]["Insert"];
export type ShopRenterWebhookUpdate = Database["public"]["Tables"]["shoprenter_webhooks"]["Update"];

// Constants for ENUM values
export const CALL_STATUS = {
  PENDING: "pending" as const,
  SCHEDULED: "scheduled" as const,
  IN_PROGRESS: "in_progress" as const,
  COMPLETED: "completed" as const,
  FAILED: "failed" as const,
  CANCELLED: "cancelled" as const,
} as const;

export const CALL_OUTCOME = {
  PENDING: "pending" as const,
  RESOLVED: "resolved" as const,
  INTERESTED: "interested" as const,
  POTENTIAL: "potential" as const,
  NOT_INTERESTED: "not_interested" as const,
  NO_ANSWER: "no_answer" as const,
  VOICEMAIL: "voicemail" as const,
  BUSY: "busy" as const,
  CALLBACK_REQUESTED: "callback_requested" as const,
  FALSE: "false" as const,
} as const;

export const CALL_TYPE = {
  INBOUND: "inbound" as const,
  OUTBOUND: "outbound" as const,
  INBOUND_DUMMY: "inbound_dummy" as const,
} as const;
