Initial commit (Clean history)
This commit is contained in:
21
app/workflow_registry.py
Normal file
21
app/workflow_registry.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import Callable, Dict
|
||||
|
||||
ACTION_REGISTRY: Dict[str, Callable] = {}
|
||||
ACTION_SCHEMAS: Dict[str, dict] = {}
|
||||
|
||||
def register_action(name: str, schema=None):
|
||||
def decorator(func):
|
||||
ACTION_REGISTRY[name] = func
|
||||
ACTION_SCHEMAS[name] = schema or {}
|
||||
return func
|
||||
return decorator
|
||||
|
||||
def validate_action_schema(action_name, params):
|
||||
schema = ACTION_SCHEMAS.get(action_name, {})
|
||||
required = schema.get("required", [])
|
||||
|
||||
for key in required:
|
||||
if key not in params:
|
||||
raise Exception(f"Action '{action_name}' missing required param: {key}")
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user