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

export type Database = {
  graphql_public: {
    Tables: {
      [_ in never]: never
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      graphql: {
        Args: {
          extensions?: Json
          operationName?: string
          query?: string
          variables?: Json
        }
        Returns: Json
      }
    }
    Enums: {
      [_ in never]: never
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
  public: {
    Tables: {
      admin_audit_log: {
        Row: {
          action: string
          after: Json | null
          before: Json | null
          created_at: string
          id: number
          operator_email: string
          operator_id: string
          role: string
          target_id: string
          target_type: string
        }
        Insert: {
          action: string
          after?: Json | null
          before?: Json | null
          created_at?: string
          id?: number
          operator_email: string
          operator_id: string
          role: string
          target_id: string
          target_type: string
        }
        Update: {
          action?: string
          after?: Json | null
          before?: Json | null
          created_at?: string
          id?: number
          operator_email?: string
          operator_id?: string
          role?: string
          target_id?: string
          target_type?: string
        }
        Relationships: []
      }
      apple_customers: {
        Row: {
          created_at: string
          id: number
          last_seen_environment: string | null
          original_app_user_id: string | null
          revenuecat_app_user_id: string
          updated_at: string
          user_id: string
        }
        Insert: {
          created_at?: string
          id?: number
          last_seen_environment?: string | null
          original_app_user_id?: string | null
          revenuecat_app_user_id: string
          updated_at?: string
          user_id: string
        }
        Update: {
          created_at?: string
          id?: number
          last_seen_environment?: string | null
          original_app_user_id?: string | null
          revenuecat_app_user_id?: string
          updated_at?: string
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "apple_customers_user_id_fkey"
            columns: ["user_id"]
            isOneToOne: true
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
        ]
      }
      apple_subscription_events: {
        Row: {
          environment: string | null
          event_id: string
          event_type: string
          id: number
          payload: Json
          processed_at: string | null
          received_at: string
        }
        Insert: {
          environment?: string | null
          event_id: string
          event_type: string
          id?: number
          payload: Json
          processed_at?: string | null
          received_at?: string
        }
        Update: {
          environment?: string | null
          event_id?: string
          event_type?: string
          id?: number
          payload?: Json
          processed_at?: string | null
          received_at?: string
        }
        Relationships: []
      }
      apple_subscriptions: {
        Row: {
          cancel_at_period_end: boolean
          created_at: string
          current_period_end: string | null
          current_period_start: string | null
          environment: string
          id: number
          last_event_type: string | null
          original_transaction_id: string
          owner_user_id: string
          plan: string
          raw_customer_id: string | null
          revenuecat_app_user_id: string
          revoked_at: string | null
          status: string
          store: string
          store_product_id: string
          transaction_id: string | null
          updated_at: string
        }
        Insert: {
          cancel_at_period_end?: boolean
          created_at?: string
          current_period_end?: string | null
          current_period_start?: string | null
          environment: string
          id?: number
          last_event_type?: string | null
          original_transaction_id: string
          owner_user_id: string
          plan: string
          raw_customer_id?: string | null
          revenuecat_app_user_id: string
          revoked_at?: string | null
          status: string
          store?: string
          store_product_id: string
          transaction_id?: string | null
          updated_at?: string
        }
        Update: {
          cancel_at_period_end?: boolean
          created_at?: string
          current_period_end?: string | null
          current_period_start?: string | null
          environment?: string
          id?: number
          last_event_type?: string | null
          original_transaction_id?: string
          owner_user_id?: string
          plan?: string
          raw_customer_id?: string | null
          revenuecat_app_user_id?: string
          revoked_at?: string | null
          status?: string
          store?: string
          store_product_id?: string
          transaction_id?: string | null
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "apple_subscriptions_owner_user_id_fkey"
            columns: ["owner_user_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
        ]
      }
      availabilities: {
        Row: {
          availability_data: Json
          created_at: string
          exceptions: Json | null
          id: number
          updated_at: string
          user_id: string
        }
        Insert: {
          availability_data?: Json
          created_at?: string
          exceptions?: Json | null
          id?: number
          updated_at?: string
          user_id: string
        }
        Update: {
          availability_data?: Json
          created_at?: string
          exceptions?: Json | null
          id?: number
          updated_at?: string
          user_id?: string
        }
        Relationships: []
      }
      calendar_subscriptions: {
        Row: {
          created_at: string | null
          id: string
          tablo_id: string
          token: string
        }
        Insert: {
          created_at?: string | null
          id?: string
          tablo_id: string
          token: string
        }
        Update: {
          created_at?: string | null
          id?: string
          tablo_id?: string
          token?: string
        }
        Relationships: [
          {
            foreignKeyName: "calendar_subscriptions_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: true
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "calendar_subscriptions_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: true
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "calendar_subscriptions_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: true
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      channel_read_state: {
        Row: {
          channel_id: string
          last_read_at: string
          user_id: string
        }
        Insert: {
          channel_id: string
          last_read_at?: string
          user_id: string
        }
        Update: {
          channel_id?: string
          last_read_at?: string
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "channel_read_state_channel_id_fkey"
            columns: ["channel_id"]
            isOneToOne: false
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "channel_read_state_channel_id_fkey"
            columns: ["channel_id"]
            isOneToOne: false
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "channel_read_state_channel_id_fkey"
            columns: ["channel_id"]
            isOneToOne: false
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      client_access: {
        Row: {
          client_id: string
          created_at: string
          granted_at: string
          granted_by: string
          id: number
          revoked_at: string | null
          tablo_id: string
        }
        Insert: {
          client_id: string
          created_at?: string
          granted_at?: string
          granted_by: string
          id?: number
          revoked_at?: string | null
          tablo_id: string
        }
        Update: {
          client_id?: string
          created_at?: string
          granted_at?: string
          granted_by?: string
          id?: number
          revoked_at?: string | null
          tablo_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "client_access_client_id_fkey"
            columns: ["client_id"]
            isOneToOne: false
            referencedRelation: "clients"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "client_access_granted_by_fkey"
            columns: ["granted_by"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "client_access_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "client_access_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "client_access_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      client_invites: {
        Row: {
          cancelled_at: string | null
          created_at: string
          expires_at: string
          id: number
          invite_token: string
          invite_type: string
          invited_by: string
          invited_email: string
          is_pending: boolean
          setup_completed_at: string | null
          tablo_id: string
          used_at: string | null
        }
        Insert: {
          cancelled_at?: string | null
          created_at?: string
          expires_at?: string
          id?: number
          invite_token: string
          invite_type?: string
          invited_by: string
          invited_email: string
          is_pending?: boolean
          setup_completed_at?: string | null
          tablo_id: string
          used_at?: string | null
        }
        Update: {
          cancelled_at?: string | null
          created_at?: string
          expires_at?: string
          id?: number
          invite_token?: string
          invite_type?: string
          invited_by?: string
          invited_email?: string
          is_pending?: boolean
          setup_completed_at?: string | null
          tablo_id?: string
          used_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "client_invites_invited_by_fkey"
            columns: ["invited_by"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "client_invites_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "client_invites_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "client_invites_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      client_magic_links: {
        Row: {
          client_id: string
          consumed_at: string | null
          created_at: string
          created_by: string | null
          email: string
          expires_at: string
          id: number
          jti: string | null
          purpose: string
          redirect_to: string | null
          tablo_id: string | null
          token_hash: string | null
        }
        Insert: {
          client_id: string
          consumed_at?: string | null
          created_at?: string
          created_by?: string | null
          email: string
          expires_at: string
          id?: number
          jti?: string | null
          purpose: string
          redirect_to?: string | null
          tablo_id?: string | null
          token_hash?: string | null
        }
        Update: {
          client_id?: string
          consumed_at?: string | null
          created_at?: string
          created_by?: string | null
          email?: string
          expires_at?: string
          id?: number
          jti?: string | null
          purpose?: string
          redirect_to?: string | null
          tablo_id?: string | null
          token_hash?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "client_magic_links_client_id_fkey"
            columns: ["client_id"]
            isOneToOne: false
            referencedRelation: "clients"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "client_magic_links_created_by_fkey"
            columns: ["created_by"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "client_magic_links_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "client_magic_links_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "client_magic_links_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      clients: {
        Row: {
          created_at: string
          email: string
          first_name: string | null
          id: string
          last_login_at: string | null
          last_name: string | null
          normalized_email: string
          phone: string | null
          updated_at: string
        }
        Insert: {
          created_at?: string
          email: string
          first_name?: string | null
          id?: string
          last_login_at?: string | null
          last_name?: string | null
          normalized_email: string
          phone?: string | null
          updated_at?: string
        }
        Update: {
          created_at?: string
          email?: string
          first_name?: string | null
          id?: string
          last_login_at?: string | null
          last_name?: string | null
          normalized_email?: string
          phone?: string | null
          updated_at?: string
        }
        Relationships: []
      }
      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: []
      }
      event_types: {
        Row: {
          config: Json
          created_at: string | null
          deleted_at: string | null
          id: string
          is_active: boolean
          standard_name: string | null
          updated_at: string | null
          user_id: string
        }
        Insert: {
          config?: Json
          created_at?: string | null
          deleted_at?: string | null
          id?: string
          is_active?: boolean
          standard_name?: string | null
          updated_at?: string | null
          user_id: string
        }
        Update: {
          config?: Json
          created_at?: string | null
          deleted_at?: string | null
          id?: string
          is_active?: boolean
          standard_name?: string | null
          updated_at?: string | null
          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: []
      }
      messages: {
        Row: {
          channel_id: string
          created_at: string
          deleted_at: string | null
          id: string
          text: string
          updated_at: string | null
          user_id: string
        }
        Insert: {
          channel_id: string
          created_at?: string
          deleted_at?: string | null
          id?: string
          text: string
          updated_at?: string | null
          user_id: string
        }
        Update: {
          channel_id?: string
          created_at?: string
          deleted_at?: string | null
          id?: string
          text?: string
          updated_at?: string | null
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "messages_channel_id_fkey"
            columns: ["channel_id"]
            isOneToOne: false
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "messages_channel_id_fkey"
            columns: ["channel_id"]
            isOneToOne: false
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "messages_channel_id_fkey"
            columns: ["channel_id"]
            isOneToOne: false
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      note_access: {
        Row: {
          created_at: string | null
          id: number
          is_active: boolean | null
          note_id: string
          tablo_id: string | null
          updated_at: string | null
          user_id: string
        }
        Insert: {
          created_at?: string | null
          id?: number
          is_active?: boolean | null
          note_id: string
          tablo_id?: string | null
          updated_at?: string | null
          user_id: string
        }
        Update: {
          created_at?: string | null
          id?: number
          is_active?: boolean | null
          note_id?: string
          tablo_id?: string | null
          updated_at?: string | null
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "fk_note_access_note_id"
            columns: ["note_id"]
            isOneToOne: false
            referencedRelation: "notes"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "fk_note_access_tablo_id"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "fk_note_access_tablo_id"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "fk_note_access_tablo_id"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      notes: {
        Row: {
          content: string | null
          created_at: string | null
          deleted_at: string | null
          id: string
          title: string
          updated_at: string | null
          user_id: string
        }
        Insert: {
          content?: string | null
          created_at?: string | null
          deleted_at?: string | null
          id?: string
          title: string
          updated_at?: string | null
          user_id: string
        }
        Update: {
          content?: string | null
          created_at?: string | null
          deleted_at?: string | null
          id?: string
          title?: string
          updated_at?: string | null
          user_id?: string
        }
        Relationships: []
      }
      notifications: {
        Row: {
          action_type: string
          actor_id: string | null
          created_at: string
          entity_id: string
          entity_type: string
          id: string
          message: Json
          metadata: Json | null
          read_at: string | null
          user_id: string
        }
        Insert: {
          action_type: string
          actor_id?: string | null
          created_at?: string
          entity_id: string
          entity_type: string
          id?: string
          message?: Json
          metadata?: Json | null
          read_at?: string | null
          user_id: string
        }
        Update: {
          action_type?: string
          actor_id?: string | null
          created_at?: string
          entity_id?: string
          entity_type?: string
          id?: string
          message?: Json
          metadata?: Json | null
          read_at?: string | null
          user_id?: string
        }
        Relationships: []
      }
      organization_invites: {
        Row: {
          created_at: string
          id: number
          invited_by: string
          invited_email: string
          invited_user_id: string | null
          organization_id: number
        }
        Insert: {
          created_at?: string
          id?: number
          invited_by: string
          invited_email: string
          invited_user_id?: string | null
          organization_id: number
        }
        Update: {
          created_at?: string
          id?: number
          invited_by?: string
          invited_email?: string
          invited_user_id?: string | null
          organization_id?: number
        }
        Relationships: [
          {
            foreignKeyName: "organization_invites_invited_by_fkey"
            columns: ["invited_by"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "organization_invites_invited_user_id_fkey"
            columns: ["invited_user_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "organization_invites_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      organizations: {
        Row: {
          created_at: string
          deleted_at: string | null
          id: number
          internal_uuid: string
          logo_url: string | null
          name: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          deleted_at?: string | null
          id?: number
          internal_uuid?: string
          logo_url?: string | null
          name: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          deleted_at?: string | null
          id?: number
          internal_uuid?: string
          logo_url?: string | null
          name?: string
          updated_at?: string
        }
        Relationships: []
      }
      profiles: {
        Row: {
          avatar_url: string | null
          client_onboarded_at: string | null
          created_at: string | null
          email: string | null
          first_name: string | null
          id: string
          is_client: boolean
          last_name: string | null
          last_signed_in: string | null
          name: string | null
          organization_id: number
          plan: Database["public"]["Enums"]["subscription_plan"] | null
          short_user_id: string
        }
        Insert: {
          avatar_url?: string | null
          client_onboarded_at?: string | null
          created_at?: string | null
          email?: string | null
          first_name?: string | null
          id: string
          is_client?: boolean
          last_name?: string | null
          last_signed_in?: string | null
          name?: string | null
          organization_id: number
          plan?: Database["public"]["Enums"]["subscription_plan"] | null
          short_user_id: string
        }
        Update: {
          avatar_url?: string | null
          client_onboarded_at?: string | null
          created_at?: string | null
          email?: string | null
          first_name?: string | null
          id?: string
          is_client?: boolean
          last_name?: string | null
          last_signed_in?: string | null
          name?: string | null
          organization_id?: number
          plan?: Database["public"]["Enums"]["subscription_plan"] | null
          short_user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "profiles_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      shared_notes: {
        Row: {
          created_at: string | null
          is_public: boolean | null
          note_id: string
          updated_at: string | null
          user_id: string
        }
        Insert: {
          created_at?: string | null
          is_public?: boolean | null
          note_id: string
          updated_at?: string | null
          user_id: string
        }
        Update: {
          created_at?: string | null
          is_public?: boolean | null
          note_id?: string
          updated_at?: string | null
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "fk_shared_notes_note_id"
            columns: ["note_id"]
            isOneToOne: true
            referencedRelation: "notes"
            referencedColumns: ["id"]
          },
        ]
      }
      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: {
          created_at: string
          id: number
          invite_token: string
          invited_by: string
          invited_email: string
          is_pending: boolean
          tablo_id: string
        }
        Insert: {
          created_at?: string
          id?: number
          invite_token: string
          invited_by: string
          invited_email: string
          is_pending?: boolean
          tablo_id: string
        }
        Update: {
          created_at?: string
          id?: number
          invite_token?: string
          invited_by?: string
          invited_email?: string
          is_pending?: boolean
          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
          layout_overview_v1: Json | null
          name: string
          organization_id: number
          owner_id: string
          position: number
          status: string | null
          updated_at: string | null
        }
        Insert: {
          color?: string | null
          created_at?: string | null
          deleted_at?: string | null
          id?: string
          image?: string | null
          layout_overview_v1?: Json | null
          name: string
          organization_id: number
          owner_id: string
          position?: number
          status?: string | null
          updated_at?: string | null
        }
        Update: {
          color?: string | null
          created_at?: string | null
          deleted_at?: string | null
          id?: string
          image?: string | null
          layout_overview_v1?: Json | null
          name?: string
          organization_id?: number
          owner_id?: string
          position?: number
          status?: string | null
          updated_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "tablos_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      tasks: {
        Row: {
          assignee_id: string | null
          created_at: string
          deleted_at: string | null
          description: string | null
          due_date: string | null
          id: string
          is_parent: boolean
          parent_task_id: string | null
          position: number
          status: Database["public"]["Enums"]["task_status"]
          tablo_id: string
          title: string
          updated_at: string
        }
        Insert: {
          assignee_id?: string | null
          created_at?: string
          deleted_at?: string | null
          description?: string | null
          due_date?: string | null
          id?: string
          is_parent?: boolean
          parent_task_id?: string | null
          position?: number
          status?: Database["public"]["Enums"]["task_status"]
          tablo_id: string
          title: string
          updated_at?: string
        }
        Update: {
          assignee_id?: string | null
          created_at?: string
          deleted_at?: string | null
          description?: string | null
          due_date?: string | null
          id?: string
          is_parent?: boolean
          parent_task_id?: string | null
          position?: number
          status?: Database["public"]["Enums"]["task_status"]
          tablo_id?: string
          title?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "tasks_parent_task_id_fkey"
            columns: ["parent_task_id"]
            isOneToOne: false
            referencedRelation: "tasks"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tasks_parent_task_id_fkey"
            columns: ["parent_task_id"]
            isOneToOne: false
            referencedRelation: "tasks_with_assignee"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tasks_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "tasks_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tasks_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      user_introductions: {
        Row: {
          config: Json
          created_at: string | null
          updated_at: string | null
          user_id: string
        }
        Insert: {
          config?: Json
          created_at?: string | null
          updated_at?: string | null
          user_id: string
        }
        Update: {
          config?: Json
          created_at?: string | null
          updated_at?: string | null
          user_id?: 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: []
      }
      tasks_with_assignee: {
        Row: {
          assignee_avatar: string | null
          assignee_id: string | null
          assignee_name: string | null
          created_at: string | null
          description: string | null
          due_date: string | null
          id: string | null
          is_parent: boolean | null
          parent_task_id: string | null
          position: number | null
          status: Database["public"]["Enums"]["task_status"] | null
          tablo_id: string | null
          title: string | null
          updated_at: string | null
        }
        Relationships: [
          {
            foreignKeyName: "tasks_parent_task_id_fkey"
            columns: ["parent_task_id"]
            isOneToOne: false
            referencedRelation: "tasks"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tasks_parent_task_id_fkey"
            columns: ["parent_task_id"]
            isOneToOne: false
            referencedRelation: "tasks_with_assignee"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tasks_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "events_and_tablos"
            referencedColumns: ["tablo_id"]
          },
          {
            foreignKeyName: "tasks_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "tablos"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tasks_tablo_id_fkey"
            columns: ["tablo_id"]
            isOneToOne: false
            referencedRelation: "user_tablos"
            referencedColumns: ["id"]
          },
        ]
      }
      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: {
      compute_tablo_status: {
        Args: { tablo_id_param: string }
        Returns: string
      }
      create_personal_organization: { Args: never; Returns: number }
      current_user_organization_id: { Args: never; Returns: number }
      generate_cool_organization_name: { Args: never; Returns: string }
      generate_random_string: { Args: { length?: number }; Returns: string }
      get_my_active_subscription: {
        Args: never
        Returns: {
          billing_interval: string
          cancel_at_period_end: boolean
          currency: string
          current_period_end: string
          current_period_start: string
          first_name: string
          last_name: string
          plan: Database["public"]["Enums"]["subscription_plan"]
          product_name: string
          status: string
          subscription_id: string
          unit_amount: number
          user_email: string
          user_id: string
        }[]
      }
      get_stripe_prices: {
        Args: never
        Returns: {
          active: boolean
          created: number
          currency: string
          id: string
          metadata: Json
          product: string
          recurring: Json
          unit_amount: number
        }[]
      }
      get_stripe_products: {
        Args: never
        Returns: {
          active: boolean
          created: number
          description: string
          id: string
          metadata: Json
          name: string
        }[]
      }
      get_user_stripe_customer: {
        Args: never
        Returns: {
          created: number
          email: string
          id: string
          metadata: Json
          user_id: string
        }[]
      }
      get_user_stripe_customer_id: {
        Args: { user_uuid: string }
        Returns: string
      }
      get_user_stripe_subscriptions: {
        Args: never
        Returns: {
          cancel_at_period_end: boolean
          canceled_at: number
          created: number
          current_period_end: number
          current_period_start: number
          customer: string
          id: string
          metadata: Json
          price_id: string
          quantity: number
          status: string
          trial_end: Json
          trial_start: Json
          user_id: string
        }[]
      }
      get_user_subscription_status: {
        Args: { user_uuid: string }
        Returns: {
          cancel_at_period_end: boolean
          current_period_end: number
          current_period_start: number
          plan: Database["public"]["Enums"]["subscription_plan"]
          price_id: string
          product_name: string
          status: string
          subscription_id: string
        }[]
      }
      is_freemium_available: { Args: never; Returns: boolean }
      is_paying_user: { Args: { user_uuid: string }; Returns: boolean }
    }
    Enums: {
      devis_status: "draft" | "sent" | "accepted" | "rejected" | "expired"
      subscription_plan:
        | "none"
        | "trial"
        | "standard"
        | "beta"
        | "free"
        | "solo"
        | "team"
        | "annual"
      task_status: "todo" | "in_progress" | "in_review" | "done"
    }
    CompositeTypes: {
      time_range: {
        start_time: string | null
        end_time: string | null
      }
    }
  }
}

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 = {
  graphql_public: {
    Enums: {},
  },
  public: {
    Enums: {
      devis_status: ["draft", "sent", "accepted", "rejected", "expired"],
      subscription_plan: [
        "none",
        "trial",
        "standard",
        "beta",
        "free",
        "solo",
        "team",
        "annual",
      ],
      task_status: ["todo", "in_progress", "in_review", "done"],
    },
  },
} as const

