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.1"
  }
  public: {
    Tables: {
      addresses: {
        Row: {
          adresse_formatee: string | null
          caracteristique_adresse: string | null
          categorie: string | null
          code_arrondissement: string | null
          code_communaute_metropolitaine: string | null
          code_mrc: string | null
          code_municipalite: string | null
          code_postal: string | null
          code_region_administrative: string | null
          code_utilisation: string | null
          cote_route: string | null
          date_creation: string | null
          date_diffusion_version: string | null
          date_fin: string | null
          date_modification: string | null
          discriminant_odonyme: string | null
          etat: string | null
          generique_odonyme: string | null
          id: number
          identifiant_reseau_routier: string | null
          identifiant_unique_adresse: string
          latitude: number | null
          longitude: number | null
          matricule_unite_evaluation: string | null
          nom_arrondissement: string | null
          nom_communaute_metropolitaine: string | null
          nom_mrc: string | null
          nom_municipalite: string | null
          nom_municipalite_complet: string | null
          nom_region_administrative: string | null
          nombre_unite: number | null
          nosqnocivq: string | null
          numero_lot: string | null
          numero_municipal: string | null
          numero_municipal_suffixe: string | null
          numero_unite: string | null
          odonyme_officiel_ctop: string | null
          odonyme_recompose_court: string | null
          odonyme_recompose_long: string | null
          odonyme_recompose_normal: string | null
          particule_odonyme: string | null
          point_cardinal_odonyme: string | null
          qualite_positionnement_geometrique: string | null
          seqodo: string | null
          specifique_odonyme: string | null
          type_unite: string | null
        }
        Insert: {
          adresse_formatee?: string | null
          caracteristique_adresse?: string | null
          categorie?: string | null
          code_arrondissement?: string | null
          code_communaute_metropolitaine?: string | null
          code_mrc?: string | null
          code_municipalite?: string | null
          code_postal?: string | null
          code_region_administrative?: string | null
          code_utilisation?: string | null
          cote_route?: string | null
          date_creation?: string | null
          date_diffusion_version?: string | null
          date_fin?: string | null
          date_modification?: string | null
          discriminant_odonyme?: string | null
          etat?: string | null
          generique_odonyme?: string | null
          id?: never
          identifiant_reseau_routier?: string | null
          identifiant_unique_adresse: string
          latitude?: number | null
          longitude?: number | null
          matricule_unite_evaluation?: string | null
          nom_arrondissement?: string | null
          nom_communaute_metropolitaine?: string | null
          nom_mrc?: string | null
          nom_municipalite?: string | null
          nom_municipalite_complet?: string | null
          nom_region_administrative?: string | null
          nombre_unite?: number | null
          nosqnocivq?: string | null
          numero_lot?: string | null
          numero_municipal?: string | null
          numero_municipal_suffixe?: string | null
          numero_unite?: string | null
          odonyme_officiel_ctop?: string | null
          odonyme_recompose_court?: string | null
          odonyme_recompose_long?: string | null
          odonyme_recompose_normal?: string | null
          particule_odonyme?: string | null
          point_cardinal_odonyme?: string | null
          qualite_positionnement_geometrique?: string | null
          seqodo?: string | null
          specifique_odonyme?: string | null
          type_unite?: string | null
        }
        Update: {
          adresse_formatee?: string | null
          caracteristique_adresse?: string | null
          categorie?: string | null
          code_arrondissement?: string | null
          code_communaute_metropolitaine?: string | null
          code_mrc?: string | null
          code_municipalite?: string | null
          code_postal?: string | null
          code_region_administrative?: string | null
          code_utilisation?: string | null
          cote_route?: string | null
          date_creation?: string | null
          date_diffusion_version?: string | null
          date_fin?: string | null
          date_modification?: string | null
          discriminant_odonyme?: string | null
          etat?: string | null
          generique_odonyme?: string | null
          id?: never
          identifiant_reseau_routier?: string | null
          identifiant_unique_adresse?: string
          latitude?: number | null
          longitude?: number | null
          matricule_unite_evaluation?: string | null
          nom_arrondissement?: string | null
          nom_communaute_metropolitaine?: string | null
          nom_mrc?: string | null
          nom_municipalite?: string | null
          nom_municipalite_complet?: string | null
          nom_region_administrative?: string | null
          nombre_unite?: number | null
          nosqnocivq?: string | null
          numero_lot?: string | null
          numero_municipal?: string | null
          numero_municipal_suffixe?: string | null
          numero_unite?: string | null
          odonyme_officiel_ctop?: string | null
          odonyme_recompose_court?: string | null
          odonyme_recompose_long?: string | null
          odonyme_recompose_normal?: string | null
          particule_odonyme?: string | null
          point_cardinal_odonyme?: string | null
          qualite_positionnement_geometrique?: string | null
          seqodo?: string | null
          specifique_odonyme?: string | null
          type_unite?: string | null
        }
        Relationships: []
      }
      fiber_availability: {
        Row: {
          appartement: string | null
          civique: string | null
          code_postal: string | null
          commentaire: string | null
          id: number
          id_appart: string | null
          id_placemark: string | null
          lien_googlemap: string | null
          max_speed: number
          nom: string | null
          rue: string | null
          uuidadresse: string
          ville: string | null
          zone_tarifaire: number
        }
        Insert: {
          appartement?: string | null
          civique?: string | null
          code_postal?: string | null
          commentaire?: string | null
          id?: never
          id_appart?: string | null
          id_placemark?: string | null
          lien_googlemap?: string | null
          max_speed?: number
          nom?: string | null
          rue?: string | null
          uuidadresse: string
          ville?: string | null
          zone_tarifaire?: number
        }
        Update: {
          appartement?: string | null
          civique?: string | null
          code_postal?: string | null
          commentaire?: string | null
          id?: never
          id_appart?: string | null
          id_placemark?: string | null
          lien_googlemap?: string | null
          max_speed?: number
          nom?: string | null
          rue?: string | null
          uuidadresse?: string
          ville?: string | null
          zone_tarifaire?: number
        }
        Relationships: []
      }
      import_jobs: {
        Row: {
          byte_offset: number
          created_at: string
          current_batch_size: number | null
          error_messages: string[] | null
          headers_cache: Json | null
          id: string
          indexes_dropped: boolean | null
          logs: string[] | null
          skip_rows: number
          source_url: string | null
          status: string
          total_errors: number
          total_inserted: number
          type: string
          updated_at: string
          user_id: string
        }
        Insert: {
          byte_offset?: number
          created_at?: string
          current_batch_size?: number | null
          error_messages?: string[] | null
          headers_cache?: Json | null
          id?: string
          indexes_dropped?: boolean | null
          logs?: string[] | null
          skip_rows?: number
          source_url?: string | null
          status?: string
          total_errors?: number
          total_inserted?: number
          type: string
          updated_at?: string
          user_id: string
        }
        Update: {
          byte_offset?: number
          created_at?: string
          current_batch_size?: number | null
          error_messages?: string[] | null
          headers_cache?: Json | null
          id?: string
          indexes_dropped?: boolean | null
          logs?: string[] | null
          skip_rows?: number
          source_url?: string | null
          status?: string
          total_errors?: number
          total_inserted?: number
          type?: string
          updated_at?: string
          user_id?: string
        }
        Relationships: []
      }
      search_logs: {
        Row: {
          contact_email: string | null
          contact_phone: string | null
          created_at: string
          fiber_available: boolean | null
          id: string
          max_speed: number | null
          search_term: string
          selected_address_formatted: string | null
          selected_address_id: string | null
        }
        Insert: {
          contact_email?: string | null
          contact_phone?: string | null
          created_at?: string
          fiber_available?: boolean | null
          id?: string
          max_speed?: number | null
          search_term: string
          selected_address_formatted?: string | null
          selected_address_id?: string | null
        }
        Update: {
          contact_email?: string | null
          contact_phone?: string | null
          created_at?: string
          fiber_available?: boolean | null
          id?: string
          max_speed?: number | null
          search_term?: string
          selected_address_formatted?: string | null
          selected_address_id?: string | null
        }
        Relationships: []
      }
      user_roles: {
        Row: {
          id: string
          role: Database["public"]["Enums"]["app_role"]
          user_id: string
        }
        Insert: {
          id?: string
          role: Database["public"]["Enums"]["app_role"]
          user_id: string
        }
        Update: {
          id?: string
          role?: Database["public"]["Enums"]["app_role"]
          user_id?: string
        }
        Relationships: []
      }
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      exec_sql: { Args: { query: string }; Returns: undefined }
      f_unaccent: { Args: { "": string }; Returns: string }
      has_role: {
        Args: {
          _role: Database["public"]["Enums"]["app_role"]
          _user_id: string
        }
        Returns: boolean
      }
      search_addresses: {
        Args: { result_limit?: number; search_term: string }
        Returns: {
          adresse_formatee: string
          code_postal: string
          fiber_available: boolean
          identifiant_unique_adresse: string
          latitude: number
          longitude: number
          max_speed: number
          nom_municipalite: string
          numero_municipal: string
          numero_unite: string
          odonyme_recompose_normal: string
          similarity_score: number
          zone_tarifaire: number
        }[]
      }
      show_limit: { Args: never; Returns: number }
      show_trgm: { Args: { "": string }; Returns: string[] }
      unaccent: { Args: { "": string }; Returns: string }
    }
    Enums: {
      app_role: "admin" | "moderator" | "user"
    }
    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: {
      app_role: ["admin", "moderator", "user"],
    },
  },
} as const
