403Webshell
Server IP : 3.147.158.171  /  Your IP : 216.73.216.216
Web Server : Apache/2.4.67 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-2-178.us-east-2.compute.internal 6.1.172-216.329.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Wed May 20 06:31:34 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.21
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /tsai/repo/builder/backend/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /tsai/repo/builder/backend/app/types.py
"""
Builder Types

Pydantic models for the build tool API.
"""

from enum import Enum
from typing import Optional, List, Dict
from pydantic import BaseModel


class Constants(str, Enum):
    """Application constants."""
    CB_END_STREAM = "__builder_end__"


class StepStatus(str, Enum):
    """Status of a build step."""
    PENDING = "pending"
    RUNNING = "running"
    SUCCESS = "success"
    FAILED = "failed"
    SKIPPED = "skipped"


class StepType(str, Enum):
    """Types of build steps."""
    SHELL = "shell"          # Execute a shell command
    GIT_PULL = "git_pull"    # Git pull operation
    SERVER_START = "server_start"  # Start a server
    SERVER_STOP = "server_stop"    # Stop a server
    SCRIPT = "script"        # Run a Python script
    WAIT = "wait"            # Wait for a condition
    INCLUDE = "include"      # Include and execute another config


class ColorOption(BaseModel):
    """Color option for color picker."""
    value: str   # Color name (e.g., "azure")
    hex: str     # Hex value (e.g., "#0074e9")
    label: str   # Display label (e.g., "Azure")


class ConfigParameter(BaseModel):
    """Parameter definition for configs that need user input."""
    name: str  # Environment variable name (e.g., 'PARAM_SLUG')
    label: str  # Display label for form
    type: str = "text"  # Input type: "text" or "color"
    required: bool = True
    options: Optional[List[ColorOption]] = None  # For color type


class BuildStep(BaseModel):
    """Definition of a single build step."""
    name: str
    step_type: StepType
    command: Optional[str] = None  # Shell command or script path
    working_dir: Optional[str] = None  # Directory to execute in
    timeout: int = 300  # Timeout in seconds (default 5 minutes)
    continue_on_failure: bool = False  # Continue to next step if this fails
    environment: Optional[dict] = None  # Additional environment variables
    enabled: bool = True  # Set to false to skip this step
    # For include step type:
    config: Optional[str] = None  # Config file to include (e.g., "build-angular.json")
    parameters: Optional[Dict[str, str]] = None  # Parameters to pass to included config


class StepResult(BaseModel):
    """Result of executing a build step."""
    step_name: str
    status: StepStatus
    output: Optional[str] = None
    error: Optional[str] = None
    duration: float = 0.0  # Duration in seconds
    return_code: Optional[int] = None


class BuildProgressEvent(BaseModel):
    """Progress event for SSE streaming."""
    status: str  # 'starting', 'running_step', 'step_complete', 'complete', 'error'
    progress: int  # 0-100
    message: str
    current_step: Optional[str] = None
    step_result: Optional[StepResult] = None
    build_id: Optional[str] = None
    error: Optional[str] = None


class BuildConfig(BaseModel):
    """Configuration for a build job."""
    name: str
    description: Optional[str] = None
    steps: List[BuildStep]
    stop_on_failure: bool = True  # Stop entire build if a step fails
    parameters: Optional[List[ConfigParameter]] = None  # Parameters needed from user


class BuildRequest(BaseModel):
    """Request to start a build."""
    config: BuildConfig
    dry_run: bool = False  # If true, just validate steps without executing
    parameters: Optional[Dict[str, str]] = None  # Runtime parameter values


class BuildResult(BaseModel):
    """Final result of a build."""
    build_id: str
    config_name: str
    success: bool
    total_steps: int
    completed_steps: int
    failed_steps: int
    skipped_steps: int
    disabled_steps: int = 0
    step_results: List[StepResult]
    total_duration: float
    error: Optional[str] = None

Youez - 2016 - github.com/yon3zu
LinuXploit