32 lines
1.7 KiB
Python
32 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate the data-property object index and common property schema."""
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
source_path = ROOT / "docs/p6/object-contract-matrix.json"
|
|
rows = json.loads(source_path.read_text(encoding="utf-8"))["records"]
|
|
selected = [row for row in rows if row["adapterFamily"] == "data-property"]
|
|
schema = [
|
|
{"name": "Label", "type": "string", "mutable": True},
|
|
{"name": "Visibility", "type": "boolean", "mutable": True},
|
|
{"name": "Placement", "type": "vector3", "mutable": True},
|
|
{"name": "Color", "type": "color", "mutable": True},
|
|
{"name": "Link", "type": "link", "mutable": True},
|
|
]
|
|
output = {
|
|
"schema": "freecad-web-property-runtime-index/v1",
|
|
"source": {"matrix": "docs/p6/object-contract-matrix.json", "matrixSha256": hashlib.sha256(source_path.read_bytes()).hexdigest()},
|
|
"count": len(selected),
|
|
"propertySchema": schema,
|
|
"records": [{"id": row["id"], "module": row["module"], "objectType": row["name"], "status": row["status"], "capabilities": row["capabilities"], "propertySchema": "common-document-properties/v1"} for row in selected],
|
|
"boundaries": ["common schema covers high-frequency document properties", "module-specific enum/map/expression properties remain family extensions"],
|
|
}
|
|
out = ROOT / "web/public/api/property-runtime-index.json"
|
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
out.write_text(json.dumps(output, ensure_ascii=False, separators=(",", ":")) + "\n", encoding="utf-8")
|
|
print(json.dumps({"output": str(out.relative_to(ROOT)), "count": len(selected), "bytes": out.stat().st_size, "sha256": hashlib.sha256(out.read_bytes()).hexdigest()}, ensure_ascii=False))
|