ec81940178
- 0.7: UI-Design-Richtlinien (docs/ui-design-guidelines.md, 535 lines) - 0.8: Theme-Customization Backend (4 theme fields, migration 0023) - 0.9: Theme-Customization Frontend (SettingsTheme.tsx, themeStore.ts, live preview) - 0.10: RBAC-Audit (4 plugins secured, 53 routes with require_permission) - 0.11: LiteLLM-Cleanup (llm_client.py migrated from httpx to litellm) - 0.12: KI-Agent-Framework docs (plugin-development-guide.md, agent_capabilities field) - 0.13: Heartbeat configurable (ProactiveSettings, migration 0024, frontend UI) - 0.14: Unified Search Field-Level RBAC (resolve_permissions + filter_fields_by_permission) - 0.15: Undo/History-System (EntityHistory model, service, routes, migration 0025, HistoryViewer) - 0.16: Storage Backend (LocalStorage + S3Storage, DMS/attachments/mail updated) - 0.17: Import/Export unified Contact fields (firstname, surname, email_1, phone_1) - 0.18: .gitignore & Config-Cleanup (webui→frontend, python-jose removed, .env untracked) - 0.19: Mail-Salt Security-Fix (per-account random salt, migration 0026) - 0.20: AGPL replaced (PyMuPDF→pypdf, OnlyOffice→Collabora, LICENSE + THIRD_PARTY_LICENSES.md)
136 lines
4.8 KiB
Python
136 lines
4.8 KiB
Python
"""Plugin manifest schema (Pydantic v2)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field, field_validator
|
|
|
|
|
|
class PluginRouteDef(BaseModel):
|
|
"""Route definition within a plugin manifest."""
|
|
|
|
path: str = Field(..., description="URL path prefix, e.g. /api/v1/plugin-mail")
|
|
module: str = Field(..., description="Dotted path to the module containing the APIRouter")
|
|
router_attr: str = Field(
|
|
default="router", description="Attribute name of the APIRouter in the module"
|
|
)
|
|
|
|
|
|
class FieldDefinition(BaseModel):
|
|
"""Field definition for field-level permissions."""
|
|
|
|
module: str = Field(..., description="Module name (e.g. 'companies', 'contacts')")
|
|
field: str = Field(..., description="Field name (e.g. 'annual_revenue')")
|
|
label: str = Field(..., description="Human-readable label")
|
|
sensitivity: str = Field(default="normal", description="normal|sensitive|critical")
|
|
|
|
|
|
class PluginManifest(BaseModel):
|
|
"""Manifest describing a plugin's metadata, dependencies, and capabilities."""
|
|
|
|
name: str = Field(
|
|
..., min_length=1, max_length=80, description="Unique plugin identifier (snake_case)"
|
|
)
|
|
version: str = Field(..., min_length=1, max_length=40, description="Semantic version string")
|
|
display_name: str = Field(..., min_length=1, max_length=120)
|
|
description: str = Field(default="", max_length=500)
|
|
dependencies: list[str] = Field(
|
|
default_factory=list, description="Other plugin names this plugin depends on"
|
|
)
|
|
routes: list[PluginRouteDef] = Field(
|
|
default_factory=list, description="Route definitions to register on activation"
|
|
)
|
|
events: list[str] = Field(
|
|
default_factory=list, description="Event names this plugin listens to"
|
|
)
|
|
migrations: list[str] = Field(
|
|
default_factory=list, description="Migration file names (ordered, e.g. 0001_initial.sql)"
|
|
)
|
|
permissions: list[str] = Field(
|
|
default_factory=list, description="Required permissions for this plugin"
|
|
)
|
|
is_core: bool = Field(
|
|
default=False, description="Whether this is a core plugin that cannot be deactivated"
|
|
)
|
|
field_definitions: list[FieldDefinition] = Field(
|
|
default_factory=list, description="Field definitions for field-level permissions"
|
|
)
|
|
agent_capabilities: list[str] = Field(
|
|
default_factory=list,
|
|
description="AI agent capabilities this plugin provides (e.g. 'contact_search', 'email_draft')",
|
|
)
|
|
|
|
@field_validator("name")
|
|
@classmethod
|
|
def validate_name(cls, v: str) -> str:
|
|
if not v.replace("_", "").isalnum():
|
|
raise ValueError("Plugin name must be alphanumeric with underscores only")
|
|
return v.lower()
|
|
|
|
model_config = {"extra": "forbid"}
|
|
|
|
|
|
class ManifestSchemaResponse(BaseModel):
|
|
"""Response model describing the manifest schema for API consumers."""
|
|
|
|
fields: dict[str, dict[str, str]]
|
|
example: PluginManifest
|
|
|
|
|
|
# Pre-built schema documentation for GET /api/v1/plugins/manifest endpoint
|
|
MANIFEST_SCHEMA_DOC = ManifestSchemaResponse(
|
|
fields={
|
|
"name": {
|
|
"type": "str",
|
|
"required": "true",
|
|
"description": "Unique plugin identifier (snake_case, max 80 chars)",
|
|
},
|
|
"version": {"type": "str", "required": "true", "description": "Semantic version string"},
|
|
"display_name": {
|
|
"type": "str",
|
|
"required": "true",
|
|
"description": "Human-readable plugin name",
|
|
},
|
|
"description": {
|
|
"type": "str",
|
|
"required": "false",
|
|
"description": "Plugin description (max 500 chars)",
|
|
},
|
|
"dependencies": {
|
|
"type": "list[str]",
|
|
"required": "false",
|
|
"description": "Other plugin names required",
|
|
},
|
|
"routes": {
|
|
"type": "list[PluginRouteDef]",
|
|
"required": "false",
|
|
"description": "Route definitions to register",
|
|
},
|
|
"events": {
|
|
"type": "list[str]",
|
|
"required": "false",
|
|
"description": "Event names to listen to",
|
|
},
|
|
"migrations": {
|
|
"type": "list[str]",
|
|
"required": "false",
|
|
"description": "Migration file names (ordered)",
|
|
},
|
|
"permissions": {
|
|
"type": "list[str]",
|
|
"required": "false",
|
|
"description": "Required permissions",
|
|
},
|
|
},
|
|
example=PluginManifest(
|
|
name="example_plugin",
|
|
version="1.0.0",
|
|
display_name="Example Plugin",
|
|
description="An example plugin demonstrating the manifest schema.",
|
|
dependencies=[],
|
|
routes=[],
|
|
events=["company.created", "contact.created"],
|
|
migrations=["0001_initial.sql"],
|
|
permissions=["companies.read"],
|
|
),
|
|
)
|