xbp 0.4.1

XBP is a build pack and deployment management tool to deploy, rust, nextjs etc and manage the NGINX configs below it
Documentation
from pydantic import BaseModel, ValidationError
from typing import Optional, Dict, Any

import os
from supabase import create_client, Client

# Initialize Supabase client
supabase_url: str = os.environ.get("XLX_SUPABASE_URL")
supabase_key: str = os.environ.get("XLX_SUPABASE_ANON_KEY")
if not supabase_url or not supabase_key:
    raise ValueError("Supabase URL or Key is missing in environment variables.")
supabase: Client = create_client(supabase_url, supabase_key)


class XbpLog(BaseModel):
    time: int
    request: Optional[Dict[str, Any]]
    http_status: Optional[int]
    method: Optional[str]
    payload: Optional[Dict[str, Any]]
    status: str
    message: str
    deployment_id: str
    commit_id: str
    project_id: str
    action: str
    host: str
    user_agent: str
    content_type: Optional[str]
    repository_url: str
    error: bool
    runtime_version: str
    runtime: str
    framework: str
    total_pages: Optional[int]
    build_time: Optional[int]
    time_start: Optional[int]
    time_finish: Optional[int]
    lint_time: Optional[int]
    routes_sourcemap: Optional[Dict[str, Any]]
    build_duration: Optional[int]
    lint_duration: Optional[int]
    routes_duration: Optional[int]
    routes: Optional[Dict[str, Any]]
    routes_count: Optional[int]
    routes_time: Optional[int]
    

    @staticmethod
    def add_xbp_log_to_supabase(log: "XbpLog"):
        """
        Adds a log entry to the 'xbp_logs' table in Supabase.

        Args:
            log (XbpLog): An instance of the XbpLog class containing the log data.
        """
        try:
            # Convert the XbpLog instance to a dictionary
            log_data = log.dict()

         

            # Insert the log data into the 'xbp_logs' table
            response = supabase.table("xbp_logs").insert(log_data).execute()

            # Check if the insertion was successful
            if response.data:
                print("Log entry successfully added to Supabase.")
            else:
                print(f"Failed to add log entry: {response.data}")
        except ValidationError as ve:
            print(f"Validation error occurred: {ve}")
        except Exception as e:
            print(f"An error occurred while adding the log entry: {str(e)}")