Files
leocrm/frontend/src/store/pluginStore.ts
T
Agent Zero 98eb1d0d89
Check Cross-Plugin Imports / check (push) Has been cancelled
feat: Plugin-System Umbau — 6 Phasen komplett abgeschlossen
Phase 1: Contracts konsequent nutzen
- 12 neue contracts.py erstellt (alle 19 Plugins haben jetzt contracts)
- 4 bestehende contracts.py an zentrale ContractRegistry angepasst
- Alle 19 Plugins haben on_deactivate mit Contract-Unregister
- 0 echte problematische INTER-Plugin Imports

Phase 2: Hooks/Filters-System
- app/core/hooks.py (HookRegistry mit actions + filters)
- 15 Hook-Punkte in Core-Services (contact, auth, mail, calendar, user, dms)
- BasePlugin.on_deactivate meldet alle Hooks ab

Phase 3: Plugin-Isolation
- scripts/check_cross_plugin_imports.py (Linting-Regel)
- .github/workflows/check-cross-plugin-imports.yml (CI/CD)
- .pre-commit-cross-plugin.yaml (Pre-commit Hook)
- 155 Dateien geprueft, 0 Verstoesse

Phase 4: Plugin-Versioning
- app/plugins/semver.py (SemVer mit Parse, Compare, Pre-release)
- migration_runner.py erweitert: run_migration_down, rollback_to_version
- manifest.py: min_app_version Feld
- registry.py: App-Version-Compatibility-Check bei Installation
- GET /api/v1/plugins/updates Endpoint

Phase 5: Marketplace-Vorbereitung
- app/plugins/signature.py (Ed25519 Signatur-Validierung)
- app/plugins/quarantine.py (Plugin-Quarantine mit Validierung)
- app/models/plugin_allowlist.py + Migration 0046
- manifest.py: author, license, homepage, icon, screenshots, changelog, marketplace_tags, price
- registry.py: discover_external(), discover_all()
- POST /api/v1/plugins/install-marketplace (deaktiviert)

Phase 6: Manifest-Anpassung
- manifest.py: 12 neue Felder + SemVer/Hook-Name Validierung
- MANIFEST_SCHEMA_DOC aktualisiert
- Alle 19 Plugin-Manifeste aktualisiert
- Frontend PluginUiManifest Typ erweitert

Zusaetzliche Bug-Fixes:
- test_sample-Modul erstellt
- conftest.py Deadlock-Prevention
- SESSION_COOKIE_SECURE=true
- dump.rdb aus Git entfernt + .gitignore
- backup.py datetime.utcnow -> func.now()
- system_settings.py JSONB-Import nach oben
- tax.py Mapped[float] -> Mapped[Decimal]
- notification.py type_key-Laengen vereinheitlicht

Tests: 91 neue Tests, alle bestanden
2026-07-26 23:15:34 +02:00

162 lines
4.0 KiB
TypeScript

import { create } from 'zustand';
export interface PluginMenuItem {
label_key: string;
label: string;
path: string;
icon: string;
group: string;
order: number;
badge_key: string;
}
export interface PluginPageRoute {
path: string;
component: string;
parent: string;
protected: boolean;
order: number;
}
export interface PluginDetailTab {
entity_type: string;
label_key: string;
label: string;
component: string;
icon: string;
order: number;
permission: string;
}
export interface PluginSettingsPage {
path: string;
label_key: string;
label: string;
component: string;
icon: string;
order: number;
permission: string;
}
export interface PluginDashboardWidget {
id: string;
label_key: string;
label: string;
component: string;
icon: string;
order: number;
col_span: number;
row_span: number;
permission: string;
}
export interface PluginCustomFieldDefinition {
name: string;
label: string;
label_key: string;
field_type: 'text' | 'number' | 'date' | 'select' | 'multiselect' | 'boolean';
options: string[];
default_value: any;
required: boolean;
entity: string;
}
export interface PluginUiManifest {
name: string;
display_name: string;
version: string;
is_core: boolean;
menu_items: PluginMenuItem[];
page_routes: PluginPageRoute[];
detail_tabs: PluginDetailTab[];
settings_pages: PluginSettingsPage[];
dashboard_widgets: PluginDashboardWidget[];
custom_fields: PluginCustomFieldDefinition[];
// ── Phase 4-6: Versioning + Marketplace + Manifest fields ──
min_app_version?: string;
author?: string;
author_email?: string;
homepage?: string;
license?: string;
icon?: string;
screenshots?: string[];
changelog?: string;
marketplace_tags?: string[];
price?: number;
hooks?: string[];
contract_version?: string;
}
interface PluginState {
manifests: PluginUiManifest[];
loading: boolean;
error: string | null;
loaded: boolean;
setManifests: (manifests: PluginUiManifest[]) => void;
setLoading: (loading: boolean) => void;
setError: (error: string | null) => void;
reset: () => void;
// Computed selectors
getAllMenuItems: () => PluginMenuItem[];
getAllPageRoutes: () => PluginPageRoute[];
getDetailTabsForEntity: (entityType: string) => PluginDetailTab[];
getAllSettingsPages: () => PluginSettingsPage[];
getAllDashboardWidgets: () => PluginDashboardWidget[];
getCustomFieldsForEntity: (entityType: string) => PluginCustomFieldDefinition[];
}
export const usePluginStore = create<PluginState>((set, get) => ({
manifests: [],
loading: false,
error: null,
loaded: false,
setManifests: (manifests) => set({ manifests, loaded: true, loading: false, error: null }),
setLoading: (loading) => set({ loading }),
setError: (error) => set({ error, loading: false }),
reset: () => set({ manifests: [], loading: false, error: null, loaded: false }),
getAllMenuItems: () => {
const { manifests } = get();
return manifests
.flatMap((m) => m.menu_items)
.sort((a, b) => a.order - b.order);
},
getAllPageRoutes: () => {
const { manifests } = get();
return manifests
.flatMap((m) => m.page_routes)
.sort((a, b) => a.order - b.order);
},
getDetailTabsForEntity: (entityType: string) => {
const { manifests } = get();
return manifests
.flatMap((m) => m.detail_tabs)
.filter((t) => t.entity_type === entityType)
.sort((a, b) => a.order - b.order);
},
getAllSettingsPages: () => {
const { manifests } = get();
return manifests
.flatMap((m) => m.settings_pages)
.sort((a, b) => a.order - b.order);
},
getAllDashboardWidgets: () => {
const { manifests } = get();
return manifests
.flatMap((m) => m.dashboard_widgets)
.sort((a, b) => a.order - b.order);
},
getCustomFieldsForEntity: (entityType: string) => {
const { manifests } = get();
return manifests
.flatMap((m) => m.custom_fields || [])
.filter((cf) => cf.entity === entityType);
},
}));