Files
metabuilder/scripts/check-dbal-prisma-sync.py
johndoe6345789 92c280b0e6 feat: Add PageConfig and ComponentNode entities with CRUD operations
- Introduced `PageConfig` entity for page configuration and layout definition.
- Introduced `ComponentNode` entity for managing component hierarchy within pages.
- Implemented operations for creating, reading, updating, and deleting both entities.
- Updated Prisma schema to reflect new entities and relationships.
- Enhanced ACL rules for new entities to manage access control.
- Added conformance cases to test page and component hierarchy management.
- Created a script to check synchronization between DBAL and Prisma schemas.
2026-01-07 13:31:26 +00:00

59 lines
1.6 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import pathlib
import re
import sys
def parse_prisma_models(schema_path: pathlib.Path) -> list[str]:
text = schema_path.read_text()
return re.findall(r"^model\s+(\w+)\s+\{", text, re.M)
def parse_dbal_types(types_path: pathlib.Path) -> list[str]:
text = types_path.read_text()
match = re.search(r"export type \{([^}]+)\}", text)
if not match:
return []
return [name.strip() for name in match.group(1).split(",") if name.strip()]
def main() -> int:
root = pathlib.Path(__file__).resolve().parents[1]
prisma_schema = root / "prisma" / "schema.prisma"
dbal_types = root / "dbal" / "development" / "src" / "core" / "validation" / "entities" / "types.ts"
if not prisma_schema.exists():
print(f"Missing Prisma schema: {prisma_schema}", file=sys.stderr)
return 2
if not dbal_types.exists():
print(f"Missing DBAL types: {dbal_types}", file=sys.stderr)
return 2
prisma_models = parse_prisma_models(prisma_schema)
dbal_model_types = parse_dbal_types(dbal_types)
missing = [model for model in prisma_models if model not in dbal_model_types]
extra = [model for model in dbal_model_types if model not in prisma_models]
if missing:
print("Missing in DBAL:")
for model in missing:
print(f"- {model}")
if extra:
print("Extra in DBAL:")
for model in extra:
print(f"- {model}")
if not missing and not extra:
print("DBAL and Prisma models are in sync.")
return 0
return 1
if __name__ == "__main__":
raise SystemExit(main())