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

export type Database = {
  // Allows to automatically instanciate createClient with right options
  // instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
  __InternalSupabase: {
    PostgrestVersion: "12.2.3 (519615d)";
  };
  public: {
    Tables: {
      devis: {
        Row: {
          client_email: string;
          created_at: string;
          date: string;
          due_date: string;
          id: string;
          items: Json;
          notes: string | null;
          number: string;
          status: Database["public"]["Enums"]["devis_status"];
          subtotal: number;
          tax: number;
          terms: string | null;
          total: number;
          updated_at: string;
          user_id: string;
        };
        Insert: {
          client_email: string;
          created_at?: string;
          date: string;
          due_date: string;
          id?: string;
          items?: Json;
          notes?: string | null;
          number: string;
          status?: Database["public"]["Enums"]["devis_status"];
          subtotal: number;
          tax: number;
          terms?: string | null;
          total: number;
          updated_at?: string;
          user_id: string;
        };
        Update: {
          client_email?: string;
          created_at?: string;
          date?: string;
          due_date?: string;
          id?: string;
          items?: Json;
          notes?: string | null;
          number?: string;
          status?: Database["public"]["Enums"]["devis_status"];
          subtotal?: number;
          tax?: number;
          terms?: string | null;
          total?: number;
          updated_at?: string;
          user_id?: string;
        };
        Relationships: [];
      };
      events: {
        Row: {
          created_at: string | null;
          created_by: string;
          deleted_at: string | null;
          description: string | null;
          end_time: string | null;
          id: string;
          start_date: string;
          start_time: string;
          tablo_id: string;
          title: string;
        };
        Insert: {
          created_at?: string | null;
          created_by: string;
          deleted_at?: string | null;
          description?: string | null;
          end_time?: string | null;
          id?: string;
          start_date: string;
          start_time: string;
          tablo_id: string;
          title: string;
        };
        Update: {
          created_at?: string | null;
          created_by?: string;
          deleted_at?: string | null;
          description?: string | null;
          end_time?: string | null;
          id?: string;
          start_date?: string;
          start_time?: string;
          tablo_id?: string;
          title?: string;
        };
        Relationships: [
          {
            foreignKeyName: "fk_events_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "events_and_tablos";
            referencedColumns: ["tablo_id"];
          },
          {
            foreignKeyName: "fk_events_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "tablos";
            referencedColumns: ["id"];
          },
          {
            foreignKeyName: "fk_events_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "user_tablos";
            referencedColumns: ["id"];
          },
        ];
      };
      feedbacks: {
        Row: {
          created_at: string | null;
          fd_type: string;
          id: number;
          message: string;
          user_id: string;
        };
        Insert: {
          created_at?: string | null;
          fd_type: string;
          id?: number;
          message: string;
          user_id: string;
        };
        Update: {
          created_at?: string | null;
          fd_type?: string;
          id?: number;
          message?: string;
          user_id?: string;
        };
        Relationships: [];
      };
      profiles: {
        Row: {
          avatar_url: string | null;
          email: string | null;
          id: string;
          name: string | null;
        };
        Insert: {
          avatar_url?: string | null;
          email?: string | null;
          id: string;
          name?: string | null;
        };
        Update: {
          avatar_url?: string | null;
          email?: string | null;
          id?: string;
          name?: string | null;
        };
        Relationships: [];
      };
      tablo_access: {
        Row: {
          created_at: string | null;
          granted_by: string;
          id: number;
          is_active: boolean | null;
          is_admin: boolean | null;
          tablo_id: string;
          user_id: string;
        };
        Insert: {
          created_at?: string | null;
          granted_by: string;
          id?: number;
          is_active?: boolean | null;
          is_admin?: boolean | null;
          tablo_id: string;
          user_id: string;
        };
        Update: {
          created_at?: string | null;
          granted_by?: string;
          id?: number;
          is_active?: boolean | null;
          is_admin?: boolean | null;
          tablo_id?: string;
          user_id?: string;
        };
        Relationships: [
          {
            foreignKeyName: "fk_tablo_access_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "events_and_tablos";
            referencedColumns: ["tablo_id"];
          },
          {
            foreignKeyName: "fk_tablo_access_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "tablos";
            referencedColumns: ["id"];
          },
          {
            foreignKeyName: "fk_tablo_access_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "user_tablos";
            referencedColumns: ["id"];
          },
          {
            foreignKeyName: "fk_tablo_access_user_id_from_profiles";
            columns: ["user_id"];
            isOneToOne: false;
            referencedRelation: "profiles";
            referencedColumns: ["id"];
          },
        ];
      };
      tablo_invites: {
        Row: {
          id: number;
          invite_token: string;
          invited_by: string;
          invited_email: string;
          tablo_id: string;
        };
        Insert: {
          id?: number;
          invite_token: string;
          invited_by: string;
          invited_email: string;
          tablo_id: string;
        };
        Update: {
          id?: number;
          invite_token?: string;
          invited_by?: string;
          invited_email?: string;
          tablo_id?: string;
        };
        Relationships: [
          {
            foreignKeyName: "fk_tablo_invitations_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "events_and_tablos";
            referencedColumns: ["tablo_id"];
          },
          {
            foreignKeyName: "fk_tablo_invitations_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "tablos";
            referencedColumns: ["id"];
          },
          {
            foreignKeyName: "fk_tablo_invitations_tablo_id";
            columns: ["tablo_id"];
            isOneToOne: false;
            referencedRelation: "user_tablos";
            referencedColumns: ["id"];
          },
        ];
      };
      tablos: {
        Row: {
          color: string | null;
          created_at: string | null;
          deleted_at: string | null;
          id: string;
          image: string | null;
          name: string;
          owner_id: string;
          position: number;
          status: string;
        };
        Insert: {
          color?: string | null;
          created_at?: string | null;
          deleted_at?: string | null;
          id?: string;
          image?: string | null;
          name: string;
          owner_id: string;
          position?: number;
          status?: string;
        };
        Update: {
          color?: string | null;
          created_at?: string | null;
          deleted_at?: string | null;
          id?: string;
          image?: string | null;
          name?: string;
          owner_id?: string;
          position?: number;
          status?: string;
        };
        Relationships: [];
      };
    };
    Views: {
      events_and_tablos: {
        Row: {
          description: string | null;
          end_time: string | null;
          event_id: string | null;
          start_date: string | null;
          start_time: string | null;
          tablo_color: string | null;
          tablo_id: string | null;
          tablo_name: string | null;
          tablo_status: string | null;
          title: string | null;
        };
        Relationships: [];
      };
      user_tablos: {
        Row: {
          access_level: string | null;
          color: string | null;
          created_at: string | null;
          deleted_at: string | null;
          id: string | null;
          image: string | null;
          is_admin: boolean | null;
          name: string | null;
          position: number | null;
          status: string | null;
          user_id: string | null;
        };
        Relationships: [
          {
            foreignKeyName: "fk_tablo_access_user_id_from_profiles";
            columns: ["user_id"];
            isOneToOne: false;
            referencedRelation: "profiles";
            referencedColumns: ["id"];
          },
        ];
      };
    };
    Functions: {
      generate_random_string: {
        Args: { length?: number };
        Returns: string;
      };
    };
    Enums: {
      devis_status: "draft" | "sent" | "accepted" | "rejected" | "expired";
    };
    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: {
      devis_status: ["draft", "sent", "accepted", "rejected", "expired"],
    },
  },
} as const;
