Compare commits
1 Commits
edf9286071
...
014-file-s
| Author | SHA1 | Date | |
|---|---|---|---|
| 51e9ee3fcc |
@@ -28,6 +28,7 @@ class BeliefFormatter(logging.Formatter):
|
|||||||
# @POST: Returns formatted string.
|
# @POST: Returns formatted string.
|
||||||
# @PARAM: record (logging.LogRecord) - The log record to format.
|
# @PARAM: record (logging.LogRecord) - The log record to format.
|
||||||
# @RETURN: str - The formatted log message.
|
# @RETURN: str - The formatted log message.
|
||||||
|
# @SEMANTICS: logging, formatter, context
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
anchor_id = getattr(_belief_state, 'anchor_id', None)
|
anchor_id = getattr(_belief_state, 'anchor_id', None)
|
||||||
if anchor_id:
|
if anchor_id:
|
||||||
@@ -54,6 +55,7 @@ class LogEntry(BaseModel):
|
|||||||
# @PARAM: message (str) - Optional entry message.
|
# @PARAM: message (str) - Optional entry message.
|
||||||
# @PRE: anchor_id must be provided.
|
# @PRE: anchor_id must be provided.
|
||||||
# @POST: Thread-local belief state is updated and entry/exit logs are generated.
|
# @POST: Thread-local belief state is updated and entry/exit logs are generated.
|
||||||
|
# @SEMANTICS: logging, context, belief_state
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def belief_scope(anchor_id: str, message: str = ""):
|
def belief_scope(anchor_id: str, message: str = ""):
|
||||||
# Log Entry if enabled
|
# Log Entry if enabled
|
||||||
@@ -88,6 +90,7 @@ def belief_scope(anchor_id: str, message: str = ""):
|
|||||||
# @PRE: config is a valid LoggingConfig instance.
|
# @PRE: config is a valid LoggingConfig instance.
|
||||||
# @POST: Logger level, handlers, and belief state flag are updated.
|
# @POST: Logger level, handlers, and belief state flag are updated.
|
||||||
# @PARAM: config (LoggingConfig) - The logging configuration.
|
# @PARAM: config (LoggingConfig) - The logging configuration.
|
||||||
|
# @SEMANTICS: logging, configuration, initialization
|
||||||
def configure_logger(config):
|
def configure_logger(config):
|
||||||
global _enable_belief_state
|
global _enable_belief_state
|
||||||
_enable_belief_state = config.enable_belief_state
|
_enable_belief_state = config.enable_belief_state
|
||||||
@@ -140,6 +143,7 @@ class WebSocketLogHandler(logging.Handler):
|
|||||||
# @PRE: capacity is an integer.
|
# @PRE: capacity is an integer.
|
||||||
# @POST: Instance initialized with empty deque.
|
# @POST: Instance initialized with empty deque.
|
||||||
# @PARAM: capacity (int) - Maximum number of logs to keep in memory.
|
# @PARAM: capacity (int) - Maximum number of logs to keep in memory.
|
||||||
|
# @SEMANTICS: logging, initialization, buffer
|
||||||
def __init__(self, capacity: int = 1000):
|
def __init__(self, capacity: int = 1000):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.log_buffer: deque[LogEntry] = deque(maxlen=capacity)
|
self.log_buffer: deque[LogEntry] = deque(maxlen=capacity)
|
||||||
@@ -152,6 +156,7 @@ class WebSocketLogHandler(logging.Handler):
|
|||||||
# @PRE: record is a logging.LogRecord.
|
# @PRE: record is a logging.LogRecord.
|
||||||
# @POST: Log is added to the log_buffer.
|
# @POST: Log is added to the log_buffer.
|
||||||
# @PARAM: record (logging.LogRecord) - The log record to emit.
|
# @PARAM: record (logging.LogRecord) - The log record to emit.
|
||||||
|
# @SEMANTICS: logging, handler, buffer
|
||||||
def emit(self, record: logging.LogRecord):
|
def emit(self, record: logging.LogRecord):
|
||||||
try:
|
try:
|
||||||
log_entry = LogEntry(
|
log_entry = LogEntry(
|
||||||
@@ -179,6 +184,7 @@ class WebSocketLogHandler(logging.Handler):
|
|||||||
# @PRE: None.
|
# @PRE: None.
|
||||||
# @POST: Returns list of LogEntry objects.
|
# @POST: Returns list of LogEntry objects.
|
||||||
# @RETURN: List[LogEntry] - List of buffered log entries.
|
# @RETURN: List[LogEntry] - List of buffered log entries.
|
||||||
|
# @SEMANTICS: logging, buffer, retrieval
|
||||||
def get_recent_logs(self) -> List[LogEntry]:
|
def get_recent_logs(self) -> List[LogEntry]:
|
||||||
"""
|
"""
|
||||||
Returns a list of recent log entries from the buffer.
|
Returns a list of recent log entries from the buffer.
|
||||||
@@ -196,12 +202,18 @@ logger = logging.getLogger("superset_tools_app")
|
|||||||
# [DEF:believed:Function]
|
# [DEF:believed:Function]
|
||||||
# @PURPOSE: A decorator that wraps a function in a belief scope.
|
# @PURPOSE: A decorator that wraps a function in a belief scope.
|
||||||
# @PARAM: anchor_id (str) - The identifier for the semantic block.
|
# @PARAM: anchor_id (str) - The identifier for the semantic block.
|
||||||
|
# @PRE: anchor_id must be a string.
|
||||||
|
# @POST: Returns a decorator function.
|
||||||
def believed(anchor_id: str):
|
def believed(anchor_id: str):
|
||||||
# [DEF:decorator:Function]
|
# [DEF:decorator:Function]
|
||||||
# @PURPOSE: Internal decorator for belief scope.
|
# @PURPOSE: Internal decorator for belief scope.
|
||||||
|
# @PRE: func must be a callable.
|
||||||
|
# @POST: Returns the wrapped function.
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
# [DEF:wrapper:Function]
|
# [DEF:wrapper:Function]
|
||||||
# @PURPOSE: Internal wrapper that enters belief scope.
|
# @PURPOSE: Internal wrapper that enters belief scope.
|
||||||
|
# @PRE: None.
|
||||||
|
# @POST: Executes the function within a belief scope.
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
with belief_scope(anchor_id):
|
with belief_scope(anchor_id):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ from typing import Optional
|
|||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
# [DEF:FileCategory:Class]
|
# [DEF:FileCategory:Class]
|
||||||
|
# @PURPOSE: Enumeration of supported file categories in the storage system.
|
||||||
class FileCategory(str, Enum):
|
class FileCategory(str, Enum):
|
||||||
BACKUP = "backups"
|
BACKUP = "backups"
|
||||||
REPOSITORY = "repositorys"
|
REPOSITORY = "repositorys"
|
||||||
# [/DEF:FileCategory:Class]
|
# [/DEF:FileCategory:Class]
|
||||||
|
|
||||||
# [DEF:StorageConfig:Class]
|
# [DEF:StorageConfig:Class]
|
||||||
|
# @PURPOSE: Configuration model for the storage system, defining paths and naming patterns.
|
||||||
class StorageConfig(BaseModel):
|
class StorageConfig(BaseModel):
|
||||||
root_path: str = Field(default="backups", description="Absolute path to the storage root directory.")
|
root_path: str = Field(default="backups", description="Absolute path to the storage root directory.")
|
||||||
backup_structure_pattern: str = Field(default="{category}/", description="Pattern for backup directory structure.")
|
backup_structure_pattern: str = Field(default="{category}/", description="Pattern for backup directory structure.")
|
||||||
@@ -18,6 +20,7 @@ class StorageConfig(BaseModel):
|
|||||||
# [/DEF:StorageConfig:Class]
|
# [/DEF:StorageConfig:Class]
|
||||||
|
|
||||||
# [DEF:StoredFile:Class]
|
# [DEF:StoredFile:Class]
|
||||||
|
# @PURPOSE: Data model representing metadata for a file stored in the system.
|
||||||
class StoredFile(BaseModel):
|
class StoredFile(BaseModel):
|
||||||
name: str = Field(..., description="Name of the file (including extension).")
|
name: str = Field(..., description="Name of the file (including extension).")
|
||||||
path: str = Field(..., description="Relative path from storage root.")
|
path: str = Field(..., description="Relative path from storage root.")
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ class StoragePlugin(PluginBase):
|
|||||||
|
|
||||||
# [DEF:__init__:Function]
|
# [DEF:__init__:Function]
|
||||||
# @PURPOSE: Initializes the StoragePlugin and ensures required directories exist.
|
# @PURPOSE: Initializes the StoragePlugin and ensures required directories exist.
|
||||||
|
# @PRE: Configuration manager must be accessible.
|
||||||
|
# @POST: Storage root and category directories are created on disk.
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
with belief_scope("StoragePlugin:init"):
|
with belief_scope("StoragePlugin:init"):
|
||||||
self.ensure_directories()
|
self.ensure_directories()
|
||||||
@@ -39,39 +41,54 @@ class StoragePlugin(PluginBase):
|
|||||||
@property
|
@property
|
||||||
# [DEF:id:Function]
|
# [DEF:id:Function]
|
||||||
# @PURPOSE: Returns the unique identifier for the storage plugin.
|
# @PURPOSE: Returns the unique identifier for the storage plugin.
|
||||||
|
# @PRE: None.
|
||||||
|
# @POST: Returns the plugin ID string.
|
||||||
# @RETURN: str - "storage-manager"
|
# @RETURN: str - "storage-manager"
|
||||||
def id(self) -> str:
|
def id(self) -> str:
|
||||||
|
with belief_scope("StoragePlugin:id"):
|
||||||
return "storage-manager"
|
return "storage-manager"
|
||||||
# [/DEF:id:Function]
|
# [/DEF:id:Function]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
# [DEF:name:Function]
|
# [DEF:name:Function]
|
||||||
# @PURPOSE: Returns the human-readable name of the storage plugin.
|
# @PURPOSE: Returns the human-readable name of the storage plugin.
|
||||||
|
# @PRE: None.
|
||||||
|
# @POST: Returns the plugin name string.
|
||||||
# @RETURN: str - "Storage Manager"
|
# @RETURN: str - "Storage Manager"
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
with belief_scope("StoragePlugin:name"):
|
||||||
return "Storage Manager"
|
return "Storage Manager"
|
||||||
# [/DEF:name:Function]
|
# [/DEF:name:Function]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
# [DEF:description:Function]
|
# [DEF:description:Function]
|
||||||
# @PURPOSE: Returns a description of the storage plugin.
|
# @PURPOSE: Returns a description of the storage plugin.
|
||||||
|
# @PRE: None.
|
||||||
|
# @POST: Returns the plugin description string.
|
||||||
# @RETURN: str - Plugin description.
|
# @RETURN: str - Plugin description.
|
||||||
def description(self) -> str:
|
def description(self) -> str:
|
||||||
|
with belief_scope("StoragePlugin:description"):
|
||||||
return "Manages local file storage for backups and repositories."
|
return "Manages local file storage for backups and repositories."
|
||||||
# [/DEF:description:Function]
|
# [/DEF:description:Function]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
# [DEF:version:Function]
|
# [DEF:version:Function]
|
||||||
# @PURPOSE: Returns the version of the storage plugin.
|
# @PURPOSE: Returns the version of the storage plugin.
|
||||||
|
# @PRE: None.
|
||||||
|
# @POST: Returns the version string.
|
||||||
# @RETURN: str - "1.0.0"
|
# @RETURN: str - "1.0.0"
|
||||||
def version(self) -> str:
|
def version(self) -> str:
|
||||||
|
with belief_scope("StoragePlugin:version"):
|
||||||
return "1.0.0"
|
return "1.0.0"
|
||||||
# [/DEF:version:Function]
|
# [/DEF:version:Function]
|
||||||
|
|
||||||
# [DEF:get_schema:Function]
|
# [DEF:get_schema:Function]
|
||||||
# @PURPOSE: Returns the JSON schema for storage plugin parameters.
|
# @PURPOSE: Returns the JSON schema for storage plugin parameters.
|
||||||
|
# @PRE: None.
|
||||||
|
# @POST: Returns a dictionary representing the JSON schema.
|
||||||
# @RETURN: Dict[str, Any] - JSON schema.
|
# @RETURN: Dict[str, Any] - JSON schema.
|
||||||
def get_schema(self) -> Dict[str, Any]:
|
def get_schema(self) -> Dict[str, Any]:
|
||||||
|
with belief_scope("StoragePlugin:get_schema"):
|
||||||
return {
|
return {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -87,6 +104,8 @@ class StoragePlugin(PluginBase):
|
|||||||
|
|
||||||
# [DEF:execute:Function]
|
# [DEF:execute:Function]
|
||||||
# @PURPOSE: Executes storage-related tasks (placeholder for PluginBase compliance).
|
# @PURPOSE: Executes storage-related tasks (placeholder for PluginBase compliance).
|
||||||
|
# @PRE: params must match the plugin schema.
|
||||||
|
# @POST: Task is executed and logged.
|
||||||
async def execute(self, params: Dict[str, Any]):
|
async def execute(self, params: Dict[str, Any]):
|
||||||
with belief_scope("StoragePlugin:execute"):
|
with belief_scope("StoragePlugin:execute"):
|
||||||
logger.info(f"[StoragePlugin][Action] Executing with params: {params}")
|
logger.info(f"[StoragePlugin][Action] Executing with params: {params}")
|
||||||
@@ -94,6 +113,7 @@ class StoragePlugin(PluginBase):
|
|||||||
|
|
||||||
# [DEF:get_storage_root:Function]
|
# [DEF:get_storage_root:Function]
|
||||||
# @PURPOSE: Resolves the absolute path to the storage root.
|
# @PURPOSE: Resolves the absolute path to the storage root.
|
||||||
|
# @PRE: Settings must define a storage root path.
|
||||||
# @POST: Returns a Path object representing the storage root.
|
# @POST: Returns a Path object representing the storage root.
|
||||||
def get_storage_root(self) -> Path:
|
def get_storage_root(self) -> Path:
|
||||||
with belief_scope("StoragePlugin:get_storage_root"):
|
with belief_scope("StoragePlugin:get_storage_root"):
|
||||||
@@ -117,6 +137,8 @@ class StoragePlugin(PluginBase):
|
|||||||
# @PURPOSE: Resolves a dynamic path pattern using provided variables.
|
# @PURPOSE: Resolves a dynamic path pattern using provided variables.
|
||||||
# @PARAM: pattern (str) - The path pattern to resolve.
|
# @PARAM: pattern (str) - The path pattern to resolve.
|
||||||
# @PARAM: variables (Dict[str, str]) - Variables to substitute in the pattern.
|
# @PARAM: variables (Dict[str, str]) - Variables to substitute in the pattern.
|
||||||
|
# @PRE: pattern must be a valid format string.
|
||||||
|
# @POST: Returns the resolved path string.
|
||||||
# @RETURN: str - The resolved path.
|
# @RETURN: str - The resolved path.
|
||||||
def resolve_path(self, pattern: str, variables: Dict[str, str]) -> str:
|
def resolve_path(self, pattern: str, variables: Dict[str, str]) -> str:
|
||||||
with belief_scope("StoragePlugin:resolve_path"):
|
with belief_scope("StoragePlugin:resolve_path"):
|
||||||
@@ -137,6 +159,8 @@ class StoragePlugin(PluginBase):
|
|||||||
|
|
||||||
# [DEF:ensure_directories:Function]
|
# [DEF:ensure_directories:Function]
|
||||||
# @PURPOSE: Creates the storage root and category subdirectories if they don't exist.
|
# @PURPOSE: Creates the storage root and category subdirectories if they don't exist.
|
||||||
|
# @PRE: Storage root must be resolvable.
|
||||||
|
# @POST: Directories are created on the filesystem.
|
||||||
# @SIDE_EFFECT: Creates directories on the filesystem.
|
# @SIDE_EFFECT: Creates directories on the filesystem.
|
||||||
def ensure_directories(self):
|
def ensure_directories(self):
|
||||||
with belief_scope("StoragePlugin:ensure_directories"):
|
with belief_scope("StoragePlugin:ensure_directories"):
|
||||||
@@ -168,6 +192,8 @@ class StoragePlugin(PluginBase):
|
|||||||
# @PURPOSE: Lists all files and directories in a specific category and subpath.
|
# @PURPOSE: Lists all files and directories in a specific category and subpath.
|
||||||
# @PARAM: category (Optional[FileCategory]) - The category to list.
|
# @PARAM: category (Optional[FileCategory]) - The category to list.
|
||||||
# @PARAM: subpath (Optional[str]) - Nested path within the category.
|
# @PARAM: subpath (Optional[str]) - Nested path within the category.
|
||||||
|
# @PRE: Storage root must exist.
|
||||||
|
# @POST: Returns a list of StoredFile objects.
|
||||||
# @RETURN: List[StoredFile] - List of file and directory metadata objects.
|
# @RETURN: List[StoredFile] - List of file and directory metadata objects.
|
||||||
def list_files(self, category: Optional[FileCategory] = None, subpath: Optional[str] = None) -> List[StoredFile]:
|
def list_files(self, category: Optional[FileCategory] = None, subpath: Optional[str] = None) -> List[StoredFile]:
|
||||||
with belief_scope("StoragePlugin:list_files"):
|
with belief_scope("StoragePlugin:list_files"):
|
||||||
@@ -218,6 +244,8 @@ class StoragePlugin(PluginBase):
|
|||||||
# @PARAM: file (UploadFile) - The uploaded file.
|
# @PARAM: file (UploadFile) - The uploaded file.
|
||||||
# @PARAM: category (FileCategory) - The target category.
|
# @PARAM: category (FileCategory) - The target category.
|
||||||
# @PARAM: subpath (Optional[str]) - The target subpath.
|
# @PARAM: subpath (Optional[str]) - The target subpath.
|
||||||
|
# @PRE: file must be a valid UploadFile; category must be valid.
|
||||||
|
# @POST: File is written to disk and metadata is returned.
|
||||||
# @RETURN: StoredFile - Metadata of the saved file.
|
# @RETURN: StoredFile - Metadata of the saved file.
|
||||||
# @SIDE_EFFECT: Writes file to disk.
|
# @SIDE_EFFECT: Writes file to disk.
|
||||||
async def save_file(self, file: UploadFile, category: FileCategory, subpath: Optional[str] = None) -> StoredFile:
|
async def save_file(self, file: UploadFile, category: FileCategory, subpath: Optional[str] = None) -> StoredFile:
|
||||||
@@ -249,6 +277,8 @@ class StoragePlugin(PluginBase):
|
|||||||
# @PURPOSE: Deletes a file or directory from the specified category and path.
|
# @PURPOSE: Deletes a file or directory from the specified category and path.
|
||||||
# @PARAM: category (FileCategory) - The category.
|
# @PARAM: category (FileCategory) - The category.
|
||||||
# @PARAM: path (str) - The relative path of the file or directory.
|
# @PARAM: path (str) - The relative path of the file or directory.
|
||||||
|
# @PRE: path must belong to the specified category and exist on disk.
|
||||||
|
# @POST: The file or directory is removed from disk.
|
||||||
# @SIDE_EFFECT: Removes item from disk.
|
# @SIDE_EFFECT: Removes item from disk.
|
||||||
def delete_file(self, category: FileCategory, path: str):
|
def delete_file(self, category: FileCategory, path: str):
|
||||||
with belief_scope("StoragePlugin:delete_file"):
|
with belief_scope("StoragePlugin:delete_file"):
|
||||||
@@ -273,6 +303,8 @@ class StoragePlugin(PluginBase):
|
|||||||
# @PURPOSE: Returns the absolute path of a file for download.
|
# @PURPOSE: Returns the absolute path of a file for download.
|
||||||
# @PARAM: category (FileCategory) - The category.
|
# @PARAM: category (FileCategory) - The category.
|
||||||
# @PARAM: path (str) - The relative path of the file.
|
# @PARAM: path (str) - The relative path of the file.
|
||||||
|
# @PRE: path must belong to the specified category and be a file.
|
||||||
|
# @POST: Returns the absolute Path to the file.
|
||||||
# @RETURN: Path - Absolute path to the file.
|
# @RETURN: Path - Absolute path to the file.
|
||||||
def get_file_path(self, category: FileCategory, path: str) -> Path:
|
def get_file_path(self, category: FileCategory, path: str) -> Path:
|
||||||
with belief_scope("StoragePlugin:get_file_path"):
|
with belief_scope("StoragePlugin:get_file_path"):
|
||||||
|
|||||||
@@ -19,10 +19,23 @@
|
|||||||
export let files = [];
|
export let files = [];
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
|
// [DEF:isDirectory:Function]
|
||||||
|
/**
|
||||||
|
* @purpose Checks if a file object represents a directory.
|
||||||
|
* @param {Object} file - The file object to check.
|
||||||
|
* @return {boolean} True if it's a directory, false otherwise.
|
||||||
|
*/
|
||||||
function isDirectory(file) {
|
function isDirectory(file) {
|
||||||
return file.mime_type === 'directory';
|
return file.mime_type === 'directory';
|
||||||
}
|
}
|
||||||
|
// [/DEF:isDirectory:Function]
|
||||||
|
|
||||||
|
// [DEF:formatSize:Function]
|
||||||
|
/**
|
||||||
|
* @purpose Formats file size in bytes into a human-readable string.
|
||||||
|
* @param {number} bytes - The size in bytes.
|
||||||
|
* @return {string} Formatted size (e.g., "1.2 MB").
|
||||||
|
*/
|
||||||
function formatSize(bytes) {
|
function formatSize(bytes) {
|
||||||
if (bytes === 0) return '0 B';
|
if (bytes === 0) return '0 B';
|
||||||
const k = 1024;
|
const k = 1024;
|
||||||
@@ -30,10 +43,18 @@
|
|||||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||||
}
|
}
|
||||||
|
// [/DEF:formatSize:Function]
|
||||||
|
|
||||||
|
// [DEF:formatDate:Function]
|
||||||
|
/**
|
||||||
|
* @purpose Formats an ISO date string into a localized readable format.
|
||||||
|
* @param {string} dateStr - The date string to format.
|
||||||
|
* @return {string} Localized date and time.
|
||||||
|
*/
|
||||||
function formatDate(dateStr) {
|
function formatDate(dateStr) {
|
||||||
return new Date(dateStr).toLocaleString();
|
return new Date(dateStr).toLocaleString();
|
||||||
}
|
}
|
||||||
|
// [/DEF:formatDate:Function]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- [SECTION: TEMPLATE] -->
|
<!-- [SECTION: TEMPLATE] -->
|
||||||
|
|||||||
@@ -76,11 +76,21 @@
|
|||||||
}
|
}
|
||||||
// [/DEF:handleDelete:Function]
|
// [/DEF:handleDelete:Function]
|
||||||
|
|
||||||
|
// [DEF:handleNavigate:Function]
|
||||||
|
/**
|
||||||
|
* @purpose Updates the current path and reloads files when navigating into a directory.
|
||||||
|
* @param {CustomEvent} event - The navigation event containing the new path.
|
||||||
|
*/
|
||||||
function handleNavigate(event) {
|
function handleNavigate(event) {
|
||||||
currentPath = event.detail;
|
currentPath = event.detail;
|
||||||
loadFiles();
|
loadFiles();
|
||||||
}
|
}
|
||||||
|
// [/DEF:handleNavigate:Function]
|
||||||
|
|
||||||
|
// [DEF:navigateUp:Function]
|
||||||
|
/**
|
||||||
|
* @purpose Navigates one level up in the directory structure.
|
||||||
|
*/
|
||||||
function navigateUp() {
|
function navigateUp() {
|
||||||
if (!currentPath || currentPath === activeTab) return;
|
if (!currentPath || currentPath === activeTab) return;
|
||||||
const parts = currentPath.split('/');
|
const parts = currentPath.split('/');
|
||||||
@@ -88,6 +98,7 @@
|
|||||||
currentPath = parts.join('/') || '';
|
currentPath = parts.join('/') || '';
|
||||||
loadFiles();
|
loadFiles();
|
||||||
}
|
}
|
||||||
|
// [/DEF:navigateUp:Function]
|
||||||
|
|
||||||
onMount(loadFiles);
|
onMount(loadFiles);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* @purpose Frontend API client for file storage management.
|
* @purpose Frontend API client for file storage management.
|
||||||
* @layer Service
|
* @layer Service
|
||||||
* @relation DEPENDS_ON -> backend.api.storage
|
* @relation DEPENDS_ON -> backend.api.storage
|
||||||
|
* @SEMANTICS: storage, api, client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const API_BASE = '/api/storage';
|
const API_BASE = '/api/storage';
|
||||||
@@ -13,6 +14,8 @@ const API_BASE = '/api/storage';
|
|||||||
* @param {string} [category] - Optional category filter.
|
* @param {string} [category] - Optional category filter.
|
||||||
* @param {string} [path] - Optional subpath filter.
|
* @param {string} [path] - Optional subpath filter.
|
||||||
* @returns {Promise<Array>}
|
* @returns {Promise<Array>}
|
||||||
|
* @PRE category and path should be valid strings if provided.
|
||||||
|
* @POST Returns a promise resolving to an array of StoredFile objects.
|
||||||
*/
|
*/
|
||||||
export async function listFiles(category, path) {
|
export async function listFiles(category, path) {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
@@ -37,6 +40,8 @@ export async function listFiles(category, path) {
|
|||||||
* @param {string} category - Target category.
|
* @param {string} category - Target category.
|
||||||
* @param {string} [path] - Target subpath.
|
* @param {string} [path] - Target subpath.
|
||||||
* @returns {Promise<Object>}
|
* @returns {Promise<Object>}
|
||||||
|
* @PRE file must be a valid File object; category must be specified.
|
||||||
|
* @POST Returns a promise resolving to the metadata of the uploaded file.
|
||||||
*/
|
*/
|
||||||
export async function uploadFile(file, category, path) {
|
export async function uploadFile(file, category, path) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
@@ -65,6 +70,8 @@ export async function uploadFile(file, category, path) {
|
|||||||
* @param {string} category - File category.
|
* @param {string} category - File category.
|
||||||
* @param {string} path - Relative path of the item.
|
* @param {string} path - Relative path of the item.
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
|
* @PRE category and path must identify an existing file or directory.
|
||||||
|
* @POST The specified file or directory is removed from storage.
|
||||||
*/
|
*/
|
||||||
export async function deleteFile(category, path) {
|
export async function deleteFile(category, path) {
|
||||||
const response = await fetch(`${API_BASE}/files/${category}/${path}`, {
|
const response = await fetch(`${API_BASE}/files/${category}/${path}`, {
|
||||||
@@ -84,6 +91,8 @@ export async function deleteFile(category, path) {
|
|||||||
* @param {string} category - File category.
|
* @param {string} category - File category.
|
||||||
* @param {string} path - Relative path of the file.
|
* @param {string} path - Relative path of the file.
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
* @PRE category and path must identify an existing file.
|
||||||
|
* @POST Returns a valid API URL for file download.
|
||||||
*/
|
*/
|
||||||
export function downloadFileUrl(category, path) {
|
export function downloadFileUrl(category, path) {
|
||||||
return `${API_BASE}/download/${category}/${path}`;
|
return `${API_BASE}/download/${category}/${path}`;
|
||||||
|
|||||||
@@ -130,7 +130,8 @@ class SemanticEntity:
|
|||||||
self.compliance_issues.append(f"Missing Mandatory Tag: @{req_tag}")
|
self.compliance_issues.append(f"Missing Mandatory Tag: @{req_tag}")
|
||||||
|
|
||||||
# 3. Check for Belief State Logging (Python only)
|
# 3. Check for Belief State Logging (Python only)
|
||||||
if self.type == "Function" and self.file_path.endswith(".py"):
|
# Skip check for logger.py to avoid circular dependencies
|
||||||
|
if self.type == "Function" and self.file_path.endswith(".py") and "backend/src/core/logger.py" not in self.file_path:
|
||||||
if not getattr(self, 'has_belief_scope', False):
|
if not getattr(self, 'has_belief_scope', False):
|
||||||
self.compliance_issues.append("Missing Belief State Logging: Function should use belief_scope context manager.")
|
self.compliance_issues.append("Missing Belief State Logging: Function should use belief_scope context manager.")
|
||||||
|
|
||||||
|
|||||||
124
semantics/reports/semantic_report_20260126_112020.md
Normal file
124
semantics/reports/semantic_report_20260126_112020.md
Normal file
File diff suppressed because one or more lines are too long
117
semantics/reports/semantic_report_20260126_114128.md
Normal file
117
semantics/reports/semantic_report_20260126_114128.md
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
# Semantic Compliance Report
|
||||||
|
|
||||||
|
**Generated At:** 2026-01-26T11:41:28.355350
|
||||||
|
**Global Compliance Score:** 99.2%
|
||||||
|
**Scanned Files:** 108
|
||||||
|
|
||||||
|
## File Compliance Status
|
||||||
|
| File | Score | Issues |
|
||||||
|
|------|-------|--------|
|
||||||
|
| frontend/src/components/storage/FileList.svelte | 🟡 75% | [isDirectory] Missing Mandatory Tag: @PRE<br>[isDirectory] Missing Mandatory Tag: @POST<br>[isDirectory] Missing Mandatory Tag: @PRE<br>[isDirectory] Missing Mandatory Tag: @POST<br>[formatSize] Missing Mandatory Tag: @PRE<br>[formatSize] Missing Mandatory Tag: @POST<br>[formatSize] Missing Mandatory Tag: @PRE<br>[formatSize] Missing Mandatory Tag: @POST<br>[formatDate] Missing Mandatory Tag: @PRE<br>[formatDate] Missing Mandatory Tag: @POST<br>[formatDate] Missing Mandatory Tag: @PRE<br>[formatDate] Missing Mandatory Tag: @POST |
|
||||||
|
| frontend/src/routes/tools/storage/+page.svelte | 🟡 77% | [loadFiles] Missing Mandatory Tag: @PRE<br>[loadFiles] Missing Mandatory Tag: @PRE<br>[handleDelete] Missing Mandatory Tag: @PRE<br>[handleDelete] Missing Mandatory Tag: @POST<br>[handleDelete] Missing Mandatory Tag: @PRE<br>[handleDelete] Missing Mandatory Tag: @POST<br>[handleNavigate] Missing Mandatory Tag: @PRE<br>[handleNavigate] Missing Mandatory Tag: @POST<br>[handleNavigate] Missing Mandatory Tag: @PRE<br>[handleNavigate] Missing Mandatory Tag: @POST<br>[navigateUp] Missing Mandatory Tag: @PRE<br>[navigateUp] Missing Mandatory Tag: @POST<br>[navigateUp] Missing Mandatory Tag: @PRE<br>[navigateUp] Missing Mandatory Tag: @POST |
|
||||||
|
| frontend/src/components/storage/FileUpload.svelte | 🟡 89% | [handleDrop] Missing Mandatory Tag: @PRE<br>[handleDrop] Missing Mandatory Tag: @POST<br>[handleDrop] Missing Mandatory Tag: @PRE<br>[handleDrop] Missing Mandatory Tag: @POST |
|
||||||
|
| frontend/src/components/git/CommitModal.svelte | 🟡 94% | [loadStatus] Missing Mandatory Tag: @POST<br>[loadStatus] Missing Mandatory Tag: @POST |
|
||||||
|
| frontend/src/components/DashboardGrid.svelte | 🟡 94% | [openGit] Missing Mandatory Tag: @PRE<br>[openGit] Missing Mandatory Tag: @POST<br>[openGit] Missing Mandatory Tag: @PRE<br>[openGit] Missing Mandatory Tag: @POST |
|
||||||
|
| backend/src/api/routes/settings.py | 🟡 95% | [get_storage_settings] Missing Mandatory Tag: @PRE<br>[get_storage_settings] Missing Mandatory Tag: @POST<br>[get_storage_settings] Missing Mandatory Tag: @PRE<br>[get_storage_settings] Missing Mandatory Tag: @POST<br>[update_storage_settings] Missing Mandatory Tag: @PRE<br>[update_storage_settings] Missing Mandatory Tag: @PRE |
|
||||||
|
| frontend/src/components/git/DeploymentModal.svelte | 🟡 96% | [loadEnvironments] Missing Mandatory Tag: @PRE<br>[loadEnvironments] Missing Mandatory Tag: @PRE |
|
||||||
|
| frontend/src/components/git/BranchSelector.svelte | 🟡 97% | [handleCheckout] Missing Mandatory Tag: @PRE<br>[handleCheckout] Missing Mandatory Tag: @PRE |
|
||||||
|
| backend/src/core/utils/dataset_mapper.py | 🟡 97% | [__init__] Missing Mandatory Tag: @PRE<br>[__init__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__init__] Missing Mandatory Tag: @PRE<br>[__init__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__init__] Missing Mandatory Tag: @PRE<br>[__init__] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| generate_semantic_map.py | 🟢 100% | [__init__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__init__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__enter__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__enter__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__exit__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__exit__] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| frontend/src/lib/stores.js | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/toasts.js | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/api.js | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/ui/Select.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/ui/index.ts | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/ui/PageHeader.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/ui/Card.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/ui/Button.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/ui/Input.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/ui/LanguageSwitcher.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/lib/i18n/index.ts | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/+page.ts | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/tasks/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/migration/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/migration/mappings/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/tools/search/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/tools/mapper/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/tools/debug/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/settings/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/settings/+page.ts | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/settings/connections/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/settings/git/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/routes/git/+page.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/pages/Dashboard.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/pages/Settings.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/services/connectionService.js | 🟢 100% | OK |
|
||||||
|
| frontend/src/services/gitService.js | 🟢 100% | OK |
|
||||||
|
| frontend/src/services/toolsService.js | 🟢 100% | OK |
|
||||||
|
| frontend/src/services/taskService.js | 🟢 100% | OK |
|
||||||
|
| frontend/src/services/storageService.js | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/PasswordPrompt.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/MappingTable.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/TaskLogViewer.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/Footer.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/MissingMappingModal.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/Navbar.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/TaskHistory.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/Toast.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/TaskRunner.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/TaskList.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/DynamicForm.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/EnvSelector.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/tools/ConnectionForm.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/tools/ConnectionList.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/tools/MapperTool.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/tools/DebugTool.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/tools/SearchTool.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/git/CommitHistory.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/git/ConflictResolver.svelte | 🟢 100% | OK |
|
||||||
|
| frontend/src/components/git/GitManager.svelte | 🟢 100% | OK |
|
||||||
|
| backend/delete_running_tasks.py | 🟢 100% | [delete_running_tasks] Missing Belief State Logging: Function should use belief_scope context manager.<br>[delete_running_tasks] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| backend/src/app.py | 🟢 100% | OK |
|
||||||
|
| backend/src/dependencies.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/superset_client.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/config_manager.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/scheduler.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/config_models.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/database.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/logger.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/plugin_loader.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/migration_engine.py | 🟢 100% | [_transform_yaml] Missing Belief State Logging: Function should use belief_scope context manager.<br>[_transform_yaml] Missing Belief State Logging: Function should use belief_scope context manager.<br>[_transform_yaml] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| backend/src/core/plugin_base.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/utils/fileio.py | 🟢 100% | [replacer] Missing Belief State Logging: Function should use belief_scope context manager.<br>[replacer] Missing Belief State Logging: Function should use belief_scope context manager.<br>[replacer] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| backend/src/core/utils/network.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/utils/matching.py | 🟢 100% | [suggest_mappings] Missing Belief State Logging: Function should use belief_scope context manager.<br>[suggest_mappings] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| backend/src/core/task_manager/persistence.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/task_manager/manager.py | 🟢 100% | OK |
|
||||||
|
| backend/src/core/task_manager/models.py | 🟢 100% | [__init__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__init__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__init__] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| backend/src/core/task_manager/cleanup.py | 🟢 100% | [__init__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__init__] Missing Belief State Logging: Function should use belief_scope context manager.<br>[__init__] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| backend/src/core/task_manager/__init__.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/auth.py | 🟢 100% | [get_current_user] Missing Belief State Logging: Function should use belief_scope context manager.<br>[get_current_user] Missing Belief State Logging: Function should use belief_scope context manager. |
|
||||||
|
| backend/src/api/routes/git.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/routes/connections.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/routes/environments.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/routes/migration.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/routes/plugins.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/routes/mappings.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/routes/git_schemas.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/routes/storage.py | 🟢 100% | OK |
|
||||||
|
| backend/src/api/routes/tasks.py | 🟢 100% | OK |
|
||||||
|
| backend/src/models/git.py | 🟢 100% | OK |
|
||||||
|
| backend/src/models/task.py | 🟢 100% | OK |
|
||||||
|
| backend/src/models/connection.py | 🟢 100% | OK |
|
||||||
|
| backend/src/models/mapping.py | 🟢 100% | OK |
|
||||||
|
| backend/src/models/storage.py | 🟢 100% | OK |
|
||||||
|
| backend/src/models/dashboard.py | 🟢 100% | OK |
|
||||||
|
| backend/src/services/git_service.py | 🟢 100% | OK |
|
||||||
|
| backend/src/services/mapping_service.py | 🟢 100% | OK |
|
||||||
|
| backend/src/plugins/backup.py | 🟢 100% | OK |
|
||||||
|
| backend/src/plugins/debug.py | 🟢 100% | OK |
|
||||||
|
| backend/src/plugins/search.py | 🟢 100% | OK |
|
||||||
|
| backend/src/plugins/mapper.py | 🟢 100% | OK |
|
||||||
|
| backend/src/plugins/git_plugin.py | 🟢 100% | OK |
|
||||||
|
| backend/src/plugins/migration.py | 🟢 100% | OK |
|
||||||
|
| backend/src/plugins/storage/plugin.py | 🟢 100% | OK |
|
||||||
|
| backend/tests/test_models.py | 🟢 100% | OK |
|
||||||
|
| backend/tests/test_logger.py | 🟢 100% | OK |
|
||||||
File diff suppressed because it is too large
Load Diff
1664
specs/project_map.md
1664
specs/project_map.md
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user