67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
|
|
"""Public contract for the tasks plugin.
|
||
|
|
|
||
|
|
Exposes only the symbols that other builtins plugins need.
|
||
|
|
Importers should use::
|
||
|
|
|
||
|
|
from app.plugins.builtins.contracts import get_contract
|
||
|
|
tasks = get_contract("tasks")
|
||
|
|
if tasks:
|
||
|
|
await tasks.create_task(db, tenant_id, user_id, data)
|
||
|
|
|
||
|
|
instead of importing from internal modules directly.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from app.plugins.builtins.contracts import get_contract_registry
|
||
|
|
from app.plugins.builtins.tasks.models import Task
|
||
|
|
from app.plugins.builtins.tasks.services import (
|
||
|
|
assign_task,
|
||
|
|
create_task,
|
||
|
|
delete_task,
|
||
|
|
get_due_tasks,
|
||
|
|
get_task,
|
||
|
|
list_tasks,
|
||
|
|
update_task,
|
||
|
|
update_task_status,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
class TasksContract:
|
||
|
|
"""Public API surface for the tasks plugin."""
|
||
|
|
|
||
|
|
contract_name = "tasks"
|
||
|
|
|
||
|
|
# ─── services ───
|
||
|
|
list_tasks = staticmethod(list_tasks)
|
||
|
|
get_task = staticmethod(get_task)
|
||
|
|
create_task = staticmethod(create_task)
|
||
|
|
update_task = staticmethod(update_task)
|
||
|
|
delete_task = staticmethod(delete_task)
|
||
|
|
assign_task = staticmethod(assign_task)
|
||
|
|
update_task_status = staticmethod(update_task_status)
|
||
|
|
get_due_tasks = staticmethod(get_due_tasks)
|
||
|
|
|
||
|
|
# ─── models (read-only for queries) ───
|
||
|
|
Task = Task
|
||
|
|
|
||
|
|
|
||
|
|
# ─── self-registration ───
|
||
|
|
|
||
|
|
_contract = TasksContract()
|
||
|
|
get_contract_registry().register("tasks", _contract)
|
||
|
|
|
||
|
|
|
||
|
|
__all__ = [
|
||
|
|
"TasksContract",
|
||
|
|
"Task",
|
||
|
|
"list_tasks",
|
||
|
|
"get_task",
|
||
|
|
"create_task",
|
||
|
|
"update_task",
|
||
|
|
"delete_task",
|
||
|
|
"assign_task",
|
||
|
|
"update_task_status",
|
||
|
|
"get_due_tasks",
|
||
|
|
]
|