fix(ci): fix black/ruff failures, add CoC and PR template

- Fix Python formatting (sync no longer strips blank lines from .py files)
- Remove test_community_build.py (tests private sync module)
- Fix ruff warnings in test files
- Add CODE_OF_CONDUCT.md
- Add .github/PULL_REQUEST_TEMPLATE.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
airano
2026-02-17 18:19:39 +03:30
parent c9083d86b1
commit c73e39f6e4
135 changed files with 1185 additions and 317 deletions

View File

@@ -15,6 +15,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
"""Parse a parameter that may be a JSON string or already a native type."""
if value is None:
@@ -30,6 +31,7 @@ def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
raise ValueError(f"Invalid JSON in '{param_name}': {e}")
return value
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (12 tools)"""
return [
@@ -267,10 +269,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def list_roles(
client: DirectusClient,
filter: dict | None = None,
@@ -291,6 +295,7 @@ async def list_roles(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_role(client: DirectusClient, id: str) -> str:
"""Get role by ID."""
try:
@@ -301,6 +306,7 @@ async def get_role(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_role(
client: DirectusClient,
name: str,
@@ -326,6 +332,7 @@ async def create_role(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_role(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update role."""
try:
@@ -340,6 +347,7 @@ async def update_role(client: DirectusClient, id: str, data: dict[str, Any]) ->
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_role(client: DirectusClient, id: str) -> str:
"""Delete a role."""
try:
@@ -348,6 +356,7 @@ async def delete_role(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_permissions(
client: DirectusClient, filter: dict | None = None, limit: int = 100
) -> str:
@@ -365,6 +374,7 @@ async def list_permissions(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_permission(client: DirectusClient, id: str) -> str:
"""Get permission by ID."""
try:
@@ -375,6 +385,7 @@ async def get_permission(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_permission(
client: DirectusClient,
collection: str,
@@ -416,6 +427,7 @@ async def create_permission(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_permission(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update permission."""
try:
@@ -430,6 +442,7 @@ async def update_permission(client: DirectusClient, id: str, data: dict[str, Any
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_permission(client: DirectusClient, id: str) -> str:
"""Delete a permission."""
try:
@@ -438,6 +451,7 @@ async def delete_permission(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_my_permissions(client: DirectusClient) -> str:
"""Get current user's permissions."""
try:
@@ -448,6 +462,7 @@ async def get_my_permissions(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_policies(
client: DirectusClient, filter: dict | None = None, limit: int = 100
) -> str:

View File

@@ -12,6 +12,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
"""Parse a parameter that may be a JSON string or already a native type."""
if value is None:
@@ -27,6 +28,7 @@ def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
raise ValueError(f"Invalid JSON in '{param_name}': {e}")
return value
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (12 tools)"""
return [
@@ -303,10 +305,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def list_flows(
client: DirectusClient,
filter: dict | None = None,
@@ -327,6 +331,7 @@ async def list_flows(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_flow(client: DirectusClient, id: str) -> str:
"""Get flow by ID."""
try:
@@ -337,6 +342,7 @@ async def get_flow(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_flow(
client: DirectusClient,
name: str,
@@ -369,6 +375,7 @@ async def create_flow(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_flow(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update flow."""
try:
@@ -383,6 +390,7 @@ async def update_flow(client: DirectusClient, id: str, data: dict[str, Any]) ->
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_flow(client: DirectusClient, id: str) -> str:
"""Delete a flow."""
try:
@@ -391,6 +399,7 @@ async def delete_flow(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def trigger_flow(client: DirectusClient, id: str, data: dict | None = None) -> str:
"""Trigger a flow manually."""
try:
@@ -409,6 +418,7 @@ async def trigger_flow(client: DirectusClient, id: str, data: dict | None = None
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_operations(
client: DirectusClient, filter: dict | None = None, limit: int = 100
) -> str:
@@ -426,6 +436,7 @@ async def list_operations(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_operation(
client: DirectusClient,
flow: str,
@@ -462,6 +473,7 @@ async def create_operation(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_webhooks(
client: DirectusClient, filter: dict | None = None, limit: int = 100
) -> str:
@@ -484,6 +496,7 @@ async def list_webhooks(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_webhook(
client: DirectusClient,
name: str,
@@ -531,6 +544,7 @@ async def create_webhook(
indent=2,
)
async def update_webhook(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update webhook. DEPRECATED: Use Flows instead in Directus 10+."""
try:
@@ -557,6 +571,7 @@ async def update_webhook(client: DirectusClient, id: str, data: dict[str, Any])
indent=2,
)
async def delete_webhook(client: DirectusClient, id: str) -> str:
"""Delete a webhook. DEPRECATED: Use Flows instead in Directus 10+."""
try:

View File

@@ -12,6 +12,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
"""
Parse a parameter that may be a JSON string or already a native type.
@@ -45,6 +46,7 @@ def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
return value
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (14 tools)"""
return [
@@ -294,10 +296,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def list_collections(client: DirectusClient) -> str:
"""List all collections."""
try:
@@ -311,6 +315,7 @@ async def list_collections(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_collection(client: DirectusClient, collection: str) -> str:
"""Get collection details."""
try:
@@ -321,6 +326,7 @@ async def get_collection(client: DirectusClient, collection: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_collection(
client: DirectusClient,
collection: str,
@@ -358,6 +364,7 @@ async def create_collection(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_collection(client: DirectusClient, collection: str, meta: dict) -> str:
"""Update collection meta."""
try:
@@ -376,6 +383,7 @@ async def update_collection(client: DirectusClient, collection: str, meta: dict)
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_collection(client: DirectusClient, collection: str) -> str:
"""Delete a collection."""
try:
@@ -386,6 +394,7 @@ async def delete_collection(client: DirectusClient, collection: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_fields(client: DirectusClient, collection: str | None = None) -> str:
"""List fields."""
try:
@@ -399,6 +408,7 @@ async def list_fields(client: DirectusClient, collection: str | None = None) ->
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_field(client: DirectusClient, collection: str, field: str) -> str:
"""Get field details."""
try:
@@ -409,6 +419,7 @@ async def get_field(client: DirectusClient, collection: str, field: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_field(
client: DirectusClient,
collection: str,
@@ -438,6 +449,7 @@ async def create_field(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_field(
client: DirectusClient,
collection: str,
@@ -462,6 +474,7 @@ async def update_field(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_field(client: DirectusClient, collection: str, field: str) -> str:
"""Delete a field."""
try:
@@ -472,6 +485,7 @@ async def delete_field(client: DirectusClient, collection: str, field: str) -> s
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_relations(client: DirectusClient, collection: str | None = None) -> str:
"""List relations."""
try:
@@ -490,6 +504,7 @@ async def list_relations(client: DirectusClient, collection: str | None = None)
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_relation(client: DirectusClient, collection: str, field: str) -> str:
"""Get relation details."""
try:
@@ -500,6 +515,7 @@ async def get_relation(client: DirectusClient, collection: str, field: str) -> s
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_relation(
client: DirectusClient,
collection: str,
@@ -533,6 +549,7 @@ async def create_relation(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_relation(client: DirectusClient, collection: str, field: str) -> str:
"""Delete a relation."""
try:

View File

@@ -12,6 +12,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
"""Parse a parameter that may be a JSON string or already a native type."""
if value is None:
@@ -27,6 +28,7 @@ def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
raise ValueError(f"Invalid JSON in '{param_name}': {e}")
return value
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (10 tools)"""
return [
@@ -211,10 +213,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def list_revisions(
client: DirectusClient,
filter: dict | None = None,
@@ -237,6 +241,7 @@ async def list_revisions(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_revision(client: DirectusClient, id: str) -> str:
"""Get revision by ID."""
try:
@@ -247,6 +252,7 @@ async def get_revision(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_versions(
client: DirectusClient,
filter: dict | None = None,
@@ -269,6 +275,7 @@ async def list_versions(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_version(client: DirectusClient, id: str) -> str:
"""Get version by ID."""
try:
@@ -279,6 +286,7 @@ async def get_version(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_version(
client: DirectusClient, name: str, collection: str, item: str, key: str
) -> str:
@@ -297,6 +305,7 @@ async def create_version(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_version(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update version."""
try:
@@ -311,6 +320,7 @@ async def update_version(client: DirectusClient, id: str, data: dict[str, Any])
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_version(client: DirectusClient, id: str) -> str:
"""Delete a version."""
try:
@@ -319,6 +329,7 @@ async def delete_version(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def promote_version(client: DirectusClient, id: str, mainHash: str | None = None) -> str:
"""Promote version to main."""
try:
@@ -335,6 +346,7 @@ async def promote_version(client: DirectusClient, id: str, mainHash: str | None
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_comments(
client: DirectusClient,
filter: dict | None = None,
@@ -357,6 +369,7 @@ async def list_comments(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_comment(client: DirectusClient, collection: str, item: str, comment: str) -> str:
"""Create a comment."""
try:

View File

@@ -11,6 +11,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (8 tools)"""
return [
@@ -201,10 +202,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def list_dashboards(
client: DirectusClient,
filter: dict | None = None,
@@ -223,6 +226,7 @@ async def list_dashboards(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_dashboard(client: DirectusClient, id: str) -> str:
"""Get dashboard by ID."""
try:
@@ -233,6 +237,7 @@ async def get_dashboard(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_dashboard(
client: DirectusClient,
name: str,
@@ -255,6 +260,7 @@ async def create_dashboard(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_dashboard(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update dashboard."""
try:
@@ -267,6 +273,7 @@ async def update_dashboard(client: DirectusClient, id: str, data: dict[str, Any]
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_dashboard(client: DirectusClient, id: str) -> str:
"""Delete a dashboard."""
try:
@@ -275,6 +282,7 @@ async def delete_dashboard(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_panels(client: DirectusClient, filter: dict | None = None, limit: int = 100) -> str:
"""List panels."""
try:
@@ -286,6 +294,7 @@ async def list_panels(client: DirectusClient, filter: dict | None = None, limit:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_panel(
client: DirectusClient,
dashboard: str,
@@ -323,6 +332,7 @@ async def create_panel(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_panel(client: DirectusClient, id: str) -> str:
"""Delete a panel."""
try:

View File

@@ -12,6 +12,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
"""Parse a parameter that may be a JSON string or already a native type."""
if value is None:
@@ -27,6 +28,7 @@ def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
raise ValueError(f"Invalid JSON in '{param_name}': {e}")
return value
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (12 tools)"""
return [
@@ -241,10 +243,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def list_files(
client: DirectusClient,
filter: dict | None = None,
@@ -269,6 +273,7 @@ async def list_files(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_file(client: DirectusClient, id: str) -> str:
"""Get file metadata."""
try:
@@ -279,6 +284,7 @@ async def get_file(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_file(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update file metadata."""
try:
@@ -293,6 +299,7 @@ async def update_file(client: DirectusClient, id: str, data: dict[str, Any]) ->
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_file(client: DirectusClient, id: str) -> str:
"""Delete a file."""
try:
@@ -301,6 +308,7 @@ async def delete_file(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_files(client: DirectusClient, ids: list[str]) -> str:
"""Delete multiple files."""
try:
@@ -311,6 +319,7 @@ async def delete_files(client: DirectusClient, ids: list[str]) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def import_file_url(client: DirectusClient, url: str, data: dict | None = None) -> str:
"""Import file from URL."""
try:
@@ -325,6 +334,7 @@ async def import_file_url(client: DirectusClient, url: str, data: dict | None =
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_file_url(client: DirectusClient, id: str, download: bool = False) -> str:
"""Get file URL."""
try:
@@ -336,6 +346,7 @@ async def get_file_url(client: DirectusClient, id: str, download: bool = False)
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_folders(
client: DirectusClient,
filter: dict | None = None,
@@ -361,6 +372,7 @@ async def list_folders(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_folder(client: DirectusClient, id: str) -> str:
"""Get folder details."""
try:
@@ -371,6 +383,7 @@ async def get_folder(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_folder(client: DirectusClient, name: str, parent: str | None = None) -> str:
"""Create a folder."""
try:
@@ -383,6 +396,7 @@ async def create_folder(client: DirectusClient, name: str, parent: str | None =
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_folder(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update folder."""
try:
@@ -397,6 +411,7 @@ async def update_folder(client: DirectusClient, id: str, data: dict[str, Any]) -
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_folder(client: DirectusClient, id: str) -> str:
"""Delete a folder."""
try:

View File

@@ -12,6 +12,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
"""Parse a parameter that may be a JSON string or already a native type."""
if value is None:
@@ -27,6 +28,7 @@ def _parse_json_param(value: Any, param_name: str = "parameter") -> Any:
raise ValueError(f"Invalid JSON in '{param_name}': {e}")
return value
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (12 tools)"""
return [
@@ -301,10 +303,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def list_items(
client: DirectusClient,
collection: str,
@@ -340,6 +344,7 @@ async def list_items(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_item(
client: DirectusClient, collection: str, id: str, fields: list[str] | None = None
) -> str:
@@ -354,6 +359,7 @@ async def get_item(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_item(
client: DirectusClient, collection: str, data: dict[str, Any], fields: list[str] | None = None
) -> str:
@@ -375,6 +381,7 @@ async def create_item(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_items(
client: DirectusClient,
collection: str,
@@ -400,6 +407,7 @@ async def create_items(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_item(
client: DirectusClient,
collection: str,
@@ -421,6 +429,7 @@ async def update_item(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_items(
client: DirectusClient,
collection: str,
@@ -450,6 +459,7 @@ async def update_items(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_item(client: DirectusClient, collection: str, id: str) -> str:
"""Delete an item."""
try:
@@ -460,6 +470,7 @@ async def delete_item(client: DirectusClient, collection: str, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_items(client: DirectusClient, collection: str, keys: list[str]) -> str:
"""Delete multiple items."""
try:
@@ -472,6 +483,7 @@ async def delete_items(client: DirectusClient, collection: str, keys: list[str])
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def search_items(
client: DirectusClient,
collection: str,
@@ -495,6 +507,7 @@ async def search_items(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def aggregate_items(
client: DirectusClient,
collection: str,
@@ -520,6 +533,7 @@ async def aggregate_items(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def export_items(
client: DirectusClient,
collection: str,
@@ -556,6 +570,7 @@ async def export_items(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def import_items(client: DirectusClient, collection: str, data: list[dict[str, Any]]) -> str:
"""Import items into a collection."""
try:

View File

@@ -13,6 +13,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (10 tools)"""
return [
@@ -135,10 +136,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def get_settings(client: DirectusClient) -> str:
"""Get system settings."""
try:
@@ -149,6 +152,7 @@ async def get_settings(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_settings(client: DirectusClient, data: dict[str, Any]) -> str:
"""Update system settings."""
try:
@@ -161,6 +165,7 @@ async def update_settings(client: DirectusClient, data: dict[str, Any]) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_server_info(client: DirectusClient) -> str:
"""Get server info."""
try:
@@ -171,6 +176,7 @@ async def get_server_info(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def health_check(client: DirectusClient) -> str:
"""Check server health."""
try:
@@ -183,6 +189,7 @@ async def health_check(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_graphql_sdl(client: DirectusClient) -> str:
"""Get GraphQL SDL."""
try:
@@ -196,6 +203,7 @@ async def get_graphql_sdl(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_openapi_spec(client: DirectusClient) -> str:
"""Get OpenAPI specification."""
try:
@@ -204,6 +212,7 @@ async def get_openapi_spec(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_schema_snapshot(client: DirectusClient) -> str:
"""Get schema snapshot."""
try:
@@ -214,6 +223,7 @@ async def get_schema_snapshot(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def schema_diff(client: DirectusClient, snapshot: dict[str, Any]) -> str:
"""Get schema diff."""
try:
@@ -224,6 +234,7 @@ async def schema_diff(client: DirectusClient, snapshot: dict[str, Any]) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def schema_apply(client: DirectusClient, diff: dict[str, Any]) -> str:
"""Apply schema diff."""
try:
@@ -240,6 +251,7 @@ async def schema_apply(client: DirectusClient, diff: dict[str, Any]) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def list_activity(
client: DirectusClient,
filter: dict | None = None,

View File

@@ -12,6 +12,7 @@ from typing import Any
from plugins.directus.client import DirectusClient
def get_tool_specifications() -> list[dict[str, Any]]:
"""Return tool specifications for ToolGenerator (10 tools)"""
return [
@@ -192,10 +193,12 @@ def get_tool_specifications() -> list[dict[str, Any]]:
},
]
# =====================
# HANDLER FUNCTIONS
# =====================
async def list_users(
client: DirectusClient,
filter: dict | None = None,
@@ -216,6 +219,7 @@ async def list_users(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_user(client: DirectusClient, id: str) -> str:
"""Get user by ID."""
try:
@@ -226,6 +230,7 @@ async def get_user(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_current_user(client: DirectusClient) -> str:
"""Get current user."""
try:
@@ -236,6 +241,7 @@ async def get_current_user(client: DirectusClient) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def create_user(
client: DirectusClient,
email: str,
@@ -263,6 +269,7 @@ async def create_user(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_user(client: DirectusClient, id: str, data: dict[str, Any]) -> str:
"""Update user."""
try:
@@ -275,6 +282,7 @@ async def update_user(client: DirectusClient, id: str, data: dict[str, Any]) ->
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_user(client: DirectusClient, id: str) -> str:
"""Delete a user."""
try:
@@ -283,6 +291,7 @@ async def delete_user(client: DirectusClient, id: str) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def delete_users(client: DirectusClient, ids: list[str]) -> str:
"""Delete multiple users."""
try:
@@ -291,6 +300,7 @@ async def delete_users(client: DirectusClient, ids: list[str]) -> str:
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def invite_user(
client: DirectusClient, email: str, role: str, invite_url: str | None = None
) -> str:
@@ -309,6 +319,7 @@ async def invite_user(
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def update_current_user(client: DirectusClient, data: dict[str, Any]) -> str:
"""Update current user profile."""
try:
@@ -329,6 +340,7 @@ async def update_current_user(client: DirectusClient, data: dict[str, Any]) -> s
except Exception as e:
return json.dumps({"success": False, "error": str(e)}, indent=2)
async def get_user_role(client: DirectusClient, id: str) -> str:
"""Get user's role."""
try: