41 lines
1023 B
Python
41 lines
1023 B
Python
"""DMS plugin contract — public interface for cross-plugin access."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from app.plugins.builtins.contracts import get_contract_registry
|
|
from app.plugins.builtins.dms.models import File as DmsFile
|
|
from app.plugins.builtins.dms.models import Folder
|
|
|
|
|
|
class DmsContract:
|
|
"""Public contract for the DMS plugin."""
|
|
|
|
contract_name = "dms"
|
|
|
|
DmsFile = DmsFile
|
|
Folder = Folder
|
|
|
|
@classmethod
|
|
def get_function(cls, name: str):
|
|
"""Return a callable exposed by this contract, or None if absent."""
|
|
return getattr(cls, name, None)
|
|
|
|
|
|
# ─── self-registration ───
|
|
|
|
_contract = DmsContract()
|
|
get_contract_registry().register("dms", _contract)
|
|
|
|
# Backward-compatible local accessor
|
|
_contract_instance: DmsContract | None = None
|
|
|
|
|
|
def get_contract() -> DmsContract:
|
|
global _contract_instance
|
|
if _contract_instance is None:
|
|
_contract_instance = DmsContract()
|
|
return _contract_instance
|
|
|
|
|
|
__all__ = ["DmsContract", "DmsFile", "Folder"]
|