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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user