| |
| """ |
| Complete Phase 3 Part B - Refactor all remaining API routes |
| |
| This script generates the refactored versions of the remaining 8 API files. |
| """ |
| import os |
| from pathlib import Path |
|
|
| |
| NEW_IMPORTS = """from core.api_governance import require_governance, ActionComplexity |
| from sqlalchemy.orm import Session |
| from core.database import get_db""" |
|
|
| |
| FILES_TO_REFACTOR = [ |
| 'api/project_routes.py', |
| 'api/memory_routes.py', |
| 'api/workflow_template_routes.py', |
| 'api/financial_ops_routes.py', |
| 'api/operations_api.py', |
| 'api/admin_routes.py', |
| 'api/document_routes.py', |
| 'api/data_ingestion_routes.py', |
| ] |
|
|
| print("Phase 3 Part B - Remaining Files") |
| print("=" * 80) |
| print(f"\nFiles to refactor: {len(FILES_TO_REFACTOR)}") |
| for i, f in enumerate(FILES_TO_REFACTOR, 1): |
| exists = "✅" if Path(f).exists() else "❌" |
| print(f"{i:2}. {exists} {f}") |
|
|
| print("\n" + "=" * 80) |
| print("Next steps:") |
| print("1. Each file needs manual refactoring due to unique patterns") |
| print("2. Use the established pattern from connection_routes.py") |
| print("3. Key changes per file:") |
| print(" - Add NEW_IMPORTS") |
| print(" - Replace inline governance with @require_governance decorator") |
| print(" - Add Request and db parameters") |
| print(" - Remove manual db.close() calls") |
| print("\nEstimated time: 30-45 minutes for all 8 files") |
|
|