mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 06:04:44 +00:00
Refactor to Store-based architecture
- Create base Store class with private backend and protected getBackend() - Add SettingsStore, ProviderKeysStore, SessionsStore - Each store defines its own schema via getConfig() - AppStorage now takes stores + backend in constructor - Remove SessionsRepository (logic moved to SessionsStore) - Update all consumers to use store API (storage.settings.get/set, storage.providerKeys.get/set) - Update example app to follow new pattern: create stores, gather configs, create backend, wire - Benefits: stores own their schema, no circular deps, cleaner separation
This commit is contained in:
parent
bbbc232c7c
commit
0de89a750e
13 changed files with 243 additions and 126 deletions
34
packages/web-ui/src/storage/stores/settings-store.ts
Normal file
34
packages/web-ui/src/storage/stores/settings-store.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { Store } from "../store.js";
|
||||
import type { StoreConfig } from "../types.js";
|
||||
|
||||
/**
|
||||
* Store for application settings (theme, proxy config, etc.).
|
||||
*/
|
||||
export class SettingsStore extends Store {
|
||||
getConfig(): StoreConfig {
|
||||
return {
|
||||
name: "settings",
|
||||
// No keyPath - uses out-of-line keys
|
||||
};
|
||||
}
|
||||
|
||||
async get<T>(key: string): Promise<T | null> {
|
||||
return this.getBackend().get("settings", key);
|
||||
}
|
||||
|
||||
async set<T>(key: string, value: T): Promise<void> {
|
||||
await this.getBackend().set("settings", key, value);
|
||||
}
|
||||
|
||||
async delete(key: string): Promise<void> {
|
||||
await this.getBackend().delete("settings", key);
|
||||
}
|
||||
|
||||
async list(): Promise<string[]> {
|
||||
return this.getBackend().keys("settings");
|
||||
}
|
||||
|
||||
async clear(): Promise<void> {
|
||||
await this.getBackend().clear("settings");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue