mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
fix(dbal): add tenantId auto-add to loadFromDirectory, fix ComponentNode schema
loadFromDirectory() was missing the tenantId field auto-add logic that loadFromFile() already had, causing "Unknown field: tenantId" on all entities using the shorthand `"tenantId": true` convention. Also corrected ComponentNode schema to match the C++ struct fields (pageId, parentId, childIds, order) instead of the wrong Redux shape. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -259,6 +259,22 @@ public:
|
|||||||
entity.fields.push_back(field);
|
entity.fields.push_back(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Auto-add tenantId field if top-level tenantId: true is set
|
||||||
|
if (json.contains("tenantId") && json["tenantId"].is_boolean()) {
|
||||||
|
if (json["tenantId"].get<bool>()) {
|
||||||
|
bool has_tenant = false;
|
||||||
|
for (const auto& f : entity.fields)
|
||||||
|
if (f.name == "tenantId") { has_tenant = true; break; }
|
||||||
|
if (!has_tenant) {
|
||||||
|
FieldDefinition tenant_field;
|
||||||
|
tenant_field.name = "tenantId";
|
||||||
|
tenant_field.type = "string";
|
||||||
|
tenant_field.required = false;
|
||||||
|
tenant_field.nullable = true;
|
||||||
|
entity.fields.push_back(tenant_field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (json.contains("indexes")) {
|
if (json.contains("indexes")) {
|
||||||
for (const auto& idx : json["indexes"]) {
|
for (const auto& idx : json["indexes"]) {
|
||||||
IndexDefinition index;
|
IndexDefinition index;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"entity": "ComponentNode",
|
"entity": "ComponentNode",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"description": "Visual component definition with props and child hierarchy",
|
"description": "Visual component node in a page tree with parent-child hierarchy and ordering",
|
||||||
"tenantId": true,
|
"tenantId": true,
|
||||||
"fields": {
|
"fields": {
|
||||||
"id": {
|
"id": {
|
||||||
@@ -10,34 +10,34 @@
|
|||||||
"generated": true,
|
"generated": true,
|
||||||
"description": "Unique component node identifier"
|
"description": "Unique component node identifier"
|
||||||
},
|
},
|
||||||
"name": {
|
"pageId": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": true,
|
"required": true,
|
||||||
"max_length": 255,
|
"description": "Page this component belongs to"
|
||||||
"description": "Component display name"
|
},
|
||||||
|
"parentId": {
|
||||||
|
"type": "string",
|
||||||
|
"optional": true,
|
||||||
|
"nullable": true,
|
||||||
|
"description": "Parent component ID (null for root components)"
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"type": "enum",
|
"type": "string",
|
||||||
"required": true,
|
"required": true,
|
||||||
"values": ["atom", "molecule", "organism"],
|
"min_length": 1,
|
||||||
"description": "Component classification tier"
|
"max_length": 100,
|
||||||
|
"description": "Component type name"
|
||||||
},
|
},
|
||||||
"code": {
|
"childIds": {
|
||||||
"type": "text",
|
"type": "string",
|
||||||
"required": true,
|
"required": true,
|
||||||
"description": "Component source code"
|
"description": "Serialized list of child component IDs"
|
||||||
},
|
},
|
||||||
"props": {
|
"order": {
|
||||||
"type": "json",
|
"type": "integer",
|
||||||
"description": "Array of prop definitions [{name, type, required, defaultValue, description}]"
|
"required": true,
|
||||||
},
|
"default": 0,
|
||||||
"metadata": {
|
"description": "Display order within parent scope (non-negative)"
|
||||||
"type": "json",
|
|
||||||
"description": "Additional component metadata"
|
|
||||||
},
|
|
||||||
"updatedAt": {
|
|
||||||
"type": "bigint",
|
|
||||||
"generated": true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": [
|
"indexes": [
|
||||||
@@ -45,9 +45,22 @@
|
|||||||
"fields": ["tenantId"]
|
"fields": ["tenantId"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fields": ["type"]
|
"fields": ["pageId"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fields": ["parentId"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fields": ["pageId", "parentId", "order"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"relations": {
|
||||||
|
"page": {
|
||||||
|
"type": "belongs-to",
|
||||||
|
"entity": "UiPage",
|
||||||
|
"foreign_key": "pageId"
|
||||||
|
}
|
||||||
|
},
|
||||||
"acl": {
|
"acl": {
|
||||||
"create": { "user": true },
|
"create": { "user": true },
|
||||||
"read": { "self": true, "admin": true },
|
"read": { "self": true, "admin": true },
|
||||||
|
|||||||
Reference in New Issue
Block a user