#!/usr/bin/env python3 import json import os import subprocess # Paths API_VENV = "/home/scott/OSIT_dev/aether_api_fastapi/environment/bin/python3" SCHEMA_SCRIPT = "/home/scott/agents_sync/scripts/schema_sync.py" OUTPUT_FILE = "/home/scott/agents_sync/technical/aether_interfaces.ts" def main(): print(f"Starting E2E Schema Sync...") # Run schema_sync.py without arguments to get JSON try: result = subprocess.run( [API_VENV, SCHEMA_SCRIPT], capture_output=True, text=True, check=True ) full_schema = json.loads(result.stdout) except Exception as e: print(f"Error getting schema JSON: {e}") print(f"Stdout: {result.stdout if 'result' in locals() else 'N/A'}") print(f"Stderr: {result.stderr if 'result' in locals() else 'N/A'}") return ts_content = [ "/**", " * Aether Unified Type Definitions", " * Generated by backend_fastapi agent", " */", "" ] for obj_type, data in full_schema.items(): interface_name = data['interface_name'] ts_content.append(f"export interface {interface_name} {{") for f in data['fields']: opt = "?" if f['optional'] else "" ts_content.append(f" {f['name']}{opt}: {f['type']};") ts_content.append("}") ts_content.append("") # Ensure output dir exists os.makedirs(os.path.dirname(OUTPUT_FILE), exist_ok=True) with open(OUTPUT_FILE, "w") as f: f.write("\n".join(ts_content)) print(f"Successfully exported {len(full_schema)} interfaces to {OUTPUT_FILE}") if __name__ == "__main__": main()