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

export type Database = {
  // Allows to automatically instantiate createClient with right options
  // instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
  __InternalSupabase: {
    PostgrestVersion: "14.5"
  }
  public: {
    Tables: {
      activity_events: {
        Row: {
          amount: number | null
          created_at: string
          event_at: string
          event_type: string
          id: string
          metadata: Json
          order_id: string | null
          recipient_id: string | null
          subtitle: string
          title: string
          user_id: string
        }
        Insert: {
          amount?: number | null
          created_at?: string
          event_at?: string
          event_type: string
          id?: string
          metadata?: Json
          order_id?: string | null
          recipient_id?: string | null
          subtitle: string
          title: string
          user_id: string
        }
        Update: {
          amount?: number | null
          created_at?: string
          event_at?: string
          event_type?: string
          id?: string
          metadata?: Json
          order_id?: string | null
          recipient_id?: string | null
          subtitle?: string
          title?: string
          user_id?: string
        }
        Relationships: []
      }
      care_alerts: {
        Row: {
          alert_type: string
          body: string
          created_at: string
          dismissed_at: string | null
          due_at: string | null
          id: string
          recipient_id: string
          schedule_id: string | null
          service_type: string | null
          severity: string
          title: string
          user_id: string
        }
        Insert: {
          alert_type: string
          body: string
          created_at?: string
          dismissed_at?: string | null
          due_at?: string | null
          id?: string
          recipient_id: string
          schedule_id?: string | null
          service_type?: string | null
          severity: string
          title: string
          user_id: string
        }
        Update: {
          alert_type?: string
          body?: string
          created_at?: string
          dismissed_at?: string | null
          due_at?: string | null
          id?: string
          recipient_id?: string
          schedule_id?: string | null
          service_type?: string | null
          severity?: string
          title?: string
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "care_alerts_schedule_id_fkey"
            columns: ["schedule_id"]
            isOneToOne: false
            referencedRelation: "support_schedules"
            referencedColumns: ["id"]
          },
        ]
      }
      merchants: {
        Row: {
          branch_name: string | null
          city: string
          country: string
          created_at: string
          id: string
          is_active: boolean
          merchant_type: string
          name: string
        }
        Insert: {
          branch_name?: string | null
          city: string
          country: string
          created_at?: string
          id?: string
          is_active?: boolean
          merchant_type: string
          name: string
        }
        Update: {
          branch_name?: string | null
          city?: string
          country?: string
          created_at?: string
          id?: string
          is_active?: boolean
          merchant_type?: string
          name?: string
        }
        Relationships: []
      }
      notifications: {
        Row: {
          body: string
          created_at: string
          id: string
          order_id: string | null
          priority: string
          read_at: string | null
          recipient_id: string | null
          title: string
          type: string
          user_id: string
          voucher_id: string | null
        }
        Insert: {
          body: string
          created_at?: string
          id?: string
          order_id?: string | null
          priority: string
          read_at?: string | null
          recipient_id?: string | null
          title: string
          type: string
          user_id: string
          voucher_id?: string | null
        }
        Update: {
          body?: string
          created_at?: string
          id?: string
          order_id?: string | null
          priority?: string
          read_at?: string | null
          recipient_id?: string | null
          title?: string
          type?: string
          user_id?: string
          voucher_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "notifications_voucher_id_fkey"
            columns: ["voucher_id"]
            isOneToOne: false
            referencedRelation: "vouchers"
            referencedColumns: ["id"]
          },
        ]
      }
      payment_methods: {
        Row: {
          brand: string | null
          created_at: string
          expiry_month: number | null
          expiry_year: number | null
          id: string
          is_default: boolean
          last4: string | null
          provider: string
          user_id: string
        }
        Insert: {
          brand?: string | null
          created_at?: string
          expiry_month?: number | null
          expiry_year?: number | null
          id?: string
          is_default?: boolean
          last4?: string | null
          provider: string
          user_id: string
        }
        Update: {
          brand?: string | null
          created_at?: string
          expiry_month?: number | null
          expiry_year?: number | null
          id?: string
          is_default?: boolean
          last4?: string | null
          provider?: string
          user_id?: string
        }
        Relationships: []
      }
      profiles: {
        Row: {
          avatar_path: string | null
          country_of_residence: string
          created_at: string
          first_name: string
          full_name: string
          id: string
          last_name: string
          notification_email_enabled: boolean
          notification_push_enabled: boolean
          notification_sms_enabled: boolean
          phone: string
          updated_at: string
        }
        Insert: {
          avatar_path?: string | null
          country_of_residence: string
          created_at?: string
          first_name: string
          full_name: string
          id: string
          last_name: string
          notification_email_enabled?: boolean
          notification_push_enabled?: boolean
          notification_sms_enabled?: boolean
          phone: string
          updated_at?: string
        }
        Update: {
          avatar_path?: string | null
          country_of_residence?: string
          created_at?: string
          first_name?: string
          full_name?: string
          id?: string
          last_name?: string
          notification_email_enabled?: boolean
          notification_push_enabled?: boolean
          notification_sms_enabled?: boolean
          phone?: string
          updated_at?: string
        }
        Relationships: []
      }
      recipients: {
        Row: {
          city: string
          country: string
          created_at: string
          first_name: string
          id: string
          is_active: boolean
          last_name: string
          mobile_number: string
          photo_path: string | null
          relationship: string
          updated_at: string
          user_id: string
        }
        Insert: {
          city: string
          country: string
          created_at?: string
          first_name: string
          id?: string
          is_active?: boolean
          last_name: string
          mobile_number: string
          photo_path?: string | null
          relationship: string
          updated_at?: string
          user_id: string
        }
        Update: {
          city?: string
          country?: string
          created_at?: string
          first_name?: string
          id?: string
          is_active?: boolean
          last_name?: string
          mobile_number?: string
          photo_path?: string | null
          relationship?: string
          updated_at?: string
          user_id?: string
        }
        Relationships: []
      }
      support_orders: {
        Row: {
          amount: number
          created_at: string
          currency: string
          delivery_channel: string
          id: string
          merchant_id: string | null
          meter_number: string | null
          network: string | null
          note: string | null
          payment_method: string | null
          platform_fee: number
          recipient_id: string
          recurring_schedule_id: string | null
          service_type: string
          status: string
          total_amount: number
          updated_at: string
          user_id: string
        }
        Insert: {
          amount: number
          created_at?: string
          currency?: string
          delivery_channel?: string
          id?: string
          merchant_id?: string | null
          meter_number?: string | null
          network?: string | null
          note?: string | null
          payment_method?: string | null
          platform_fee: number
          recipient_id: string
          recurring_schedule_id?: string | null
          service_type: string
          status: string
          total_amount: number
          updated_at?: string
          user_id: string
        }
        Update: {
          amount?: number
          created_at?: string
          currency?: string
          delivery_channel?: string
          id?: string
          merchant_id?: string | null
          meter_number?: string | null
          network?: string | null
          note?: string | null
          payment_method?: string | null
          platform_fee?: number
          recipient_id?: string
          recurring_schedule_id?: string | null
          service_type?: string
          status?: string
          total_amount?: number
          updated_at?: string
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "support_orders_merchant_id_fkey"
            columns: ["merchant_id"]
            isOneToOne: false
            referencedRelation: "merchants"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "support_orders_recipient_id_fkey"
            columns: ["recipient_id"]
            isOneToOne: false
            referencedRelation: "recipients"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "support_orders_recurring_schedule_id_fkey"
            columns: ["recurring_schedule_id"]
            isOneToOne: false
            referencedRelation: "support_schedules"
            referencedColumns: ["id"]
          },
        ]
      }
      support_schedules: {
        Row: {
          created_at: string | null
          frequency_interval: number
          frequency_unit: string
          id: string
          is_active: boolean
          last_supported_at: string | null
          next_due_at: string
          recipient_id: string
          service_type: string
          updated_at: string | null
          user_id: string
        }
        Insert: {
          created_at?: string | null
          frequency_interval: number
          frequency_unit: string
          id?: string
          is_active?: boolean
          last_supported_at?: string | null
          next_due_at: string
          recipient_id: string
          service_type: string
          updated_at?: string | null
          user_id: string
        }
        Update: {
          created_at?: string | null
          frequency_interval?: number
          frequency_unit?: string
          id?: string
          is_active?: boolean
          last_supported_at?: string | null
          next_due_at?: string
          recipient_id?: string
          service_type?: string
          updated_at?: string | null
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "support_schedules_recipient_id_fkey"
            columns: ["recipient_id"]
            isOneToOne: false
            referencedRelation: "recipients"
            referencedColumns: ["id"]
          },
        ]
      }
      voucher_redemptions: {
        Row: {
          created_at: string
          id: string
          merchant_id: string
          order_id: string
          receipt_reference: string | null
          redeemed_amount: number
          redeemed_at: string
          voucher_id: string
        }
        Insert: {
          created_at?: string
          id?: string
          merchant_id: string
          order_id: string
          receipt_reference?: string | null
          redeemed_amount: number
          redeemed_at?: string
          voucher_id: string
        }
        Update: {
          created_at?: string
          id?: string
          merchant_id?: string
          order_id?: string
          receipt_reference?: string | null
          redeemed_amount?: number
          redeemed_at?: string
          voucher_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "voucher_redemptions_voucher_id_fkey"
            columns: ["voucher_id"]
            isOneToOne: false
            referencedRelation: "vouchers"
            referencedColumns: ["id"]
          },
        ]
      }
      vouchers: {
        Row: {
          created_at: string
          expires_at: string
          id: string
          order_id: string
          qr_payload: string
          redeemed_at: string | null
          redeemed_merchant_id: string | null
          status: string
          voucher_code: string
          voucher_type: string
        }
        Insert: {
          created_at?: string
          expires_at: string
          id?: string
          order_id: string
          qr_payload: string
          redeemed_at?: string | null
          redeemed_merchant_id?: string | null
          status: string
          voucher_code: string
          voucher_type: string
        }
        Update: {
          created_at?: string
          expires_at?: string
          id?: string
          order_id?: string
          qr_payload?: string
          redeemed_at?: string | null
          redeemed_merchant_id?: string | null
          status?: string
          voucher_code?: string
          voucher_type?: string
        }
        Relationships: []
      }
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      [_ in never]: never
    }
    Enums: {
      [_ in never]: never
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
}

type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">

type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]

export type Tables<
  DefaultSchemaTableNameOrOptions extends
    | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
        DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
      DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
      Row: infer R
    }
    ? R
    : never
  : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
        DefaultSchema["Views"])
    ? (DefaultSchema["Tables"] &
        DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
        Row: infer R
      }
      ? R
      : never
    : never

export type TablesInsert<
  DefaultSchemaTableNameOrOptions extends
    | keyof DefaultSchema["Tables"]
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Insert: infer I
    }
    ? I
    : never
  : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
    ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
        Insert: infer I
      }
      ? I
      : never
    : never

export type TablesUpdate<
  DefaultSchemaTableNameOrOptions extends
    | keyof DefaultSchema["Tables"]
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Update: infer U
    }
    ? U
    : never
  : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
    ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
        Update: infer U
      }
      ? U
      : never
    : never

export type Enums<
  DefaultSchemaEnumNameOrOptions extends
    | keyof DefaultSchema["Enums"]
    | { schema: keyof DatabaseWithoutInternals },
  EnumName extends DefaultSchemaEnumNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
    : never = never,
> = DefaultSchemaEnumNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
  : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
    ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
    : never

export type CompositeTypes<
  PublicCompositeTypeNameOrOptions extends
    | keyof DefaultSchema["CompositeTypes"]
    | { schema: keyof DatabaseWithoutInternals },
  CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
    : never = never,
> = PublicCompositeTypeNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
  : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
    ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
    : never

export const Constants = {
  public: {
    Enums: {},
  },
} as const
