Files
ss-tools/frontend/src/lib/stores.js
busya 10803a5019 fix(llm): add fetch-models endpoint, fix SQL Lab INSERT (client_id truncation, sync mode, target_column, timestamp normalization)
- Add POST /api/llm/providers/fetch-models route with LLMClient.fetch_models()
- Add target_column to TranslationJob model/schema/service/orchestrator
- Fix SQL Lab execute: truncate client_id to 11 chars (varchar(11))
- Switch SQL Lab to sync mode (runAsync: false) — no Celery workers
- Fix polling: unwrap nested result from Superset query API
- Fix ClickHouse timestamp: normalize float timestamps to YYYY-MM-DD
2026-05-13 20:06:15 +03:00

76 lines
2.9 KiB
JavaScript
Executable File

// #region StoresModule [C:3] [TYPE Module] [SEMANTICS store, state, writable, plugins, tasks]
// @BRIEF Global Svelte writable stores for plugins, tasks, and UI page state management.
// @RELATION DEPENDS_ON -> [ApiModule]
// #region stores_module:Module [TYPE Function]
// @RELATION: USES -> App
// @SEMANTICS: state, stores, svelte, plugins, tasks
// @PURPOSE: Global state management using Svelte stores.
// @LAYER: UI-State
import { writable } from 'svelte/store';
import { api } from './api.js';
// #region plugins:Data [TYPE Function]
// @PURPOSE: Store for the list of available plugins.
export const plugins = writable([]);
// #endregion plugins:Data
// #region tasks:Data [TYPE Function]
// @PURPOSE: Store for the list of tasks.
export const tasks = writable([]);
// #endregion tasks:Data
// #region selectedPlugin:Data [TYPE Function]
// @PURPOSE: Store for the currently selected plugin.
export const selectedPlugin = writable(null);
// #endregion selectedPlugin:Data
// #region selectedTask:Data [TYPE Function]
// @PURPOSE: Store for the currently selected task.
export const selectedTask = writable(null);
// #endregion selectedTask:Data
// #region currentPage:Data [TYPE Function]
// @PURPOSE: Store for the current page.
export const currentPage = writable('dashboard');
// #endregion currentPage:Data
// #region taskLogs:Data [TYPE Function]
// @PURPOSE: Store for the logs of the currently selected task.
export const taskLogs = writable([]);
// #endregion taskLogs:Data
// #region fetchPlugins:Function [TYPE Function]
// @PURPOSE: Fetches plugins from the API and updates the plugins store.
// @PRE: None.
// @POST: plugins store is updated with data from the API.
export async function fetchPlugins() {
try {
console.log("[stores.fetchPlugins][Action] Fetching plugins.");
const data = await api.getPlugins();
console.log("[stores.fetchPlugins][Coherence:OK] Plugins fetched context={{'count': " + data.length + "}}");
plugins.set(data);
} catch (error) {
console.error(`[stores.fetchPlugins][Coherence:Failed] Error fetching plugins context={{'error': '${error}'}}`);
}
}
// #endregion fetchPlugins:Function
// #region fetchTasks:Function [TYPE Function]
// @PURPOSE: Fetches tasks from the API and updates the tasks store.
// @PRE: None.
// @POST: tasks store is updated with data from the API.
export async function fetchTasks() {
try {
console.log("[stores.fetchTasks][Action] Fetching tasks.");
const data = await api.getTasks();
console.log("[stores.fetchTasks][Coherence:OK] Tasks fetched context={{'count': " + data.length + "}}");
tasks.set(data);
} catch (error) {
console.error(`[stores.fetchTasks][Coherence:Failed] Error fetching tasks context={{'error': '${error}'}}`);
}
}
// #endregion fetchTasks:Function
// #endregion stores_module:Module
// #endregion StoresModule