feat(nakui): metainterfaz declarativa + 6 modulos ERP estandar
Salto cualitativo: Nakui pasa de "library + demos + read-only viewer
del event log" a plataforma ERP con UI dirigida por datos. Cada
modulo de negocio se declara como un module.json (sin codigo Rust
nuevo) y el runtime GPUI lo carga dinamicamente: sidebar de menus,
listas con columnas configurables, formularios de alta.
3 entregables:
1. Crate nakui-ui-schema (datos puros): Module, View::List/Form,
FieldSpec con FieldKind {Text|Multiline|Number|Boolean|Date},
Action {OpenView|SeedEntity|Morphism}. Module::from_path,
Module::validate, load_modules_from_dir(dir). 6 tests unit + 4
integration.
2. Crate nakui-ui (binario GPUI): carga modulos desde
NAKUI_MODULES_DIR. Sidebar + main panel. List view con tabla
weighted; form view con campos labeled + submit que ejecuta
SeedEntity contra MemoryStore in-process compartido. Toast +
error banner. 6 tests unit.
3. 6 modulos demo en examples/nakui-modules/:
- customers (nombre, email, telefono, credito, notas)
- products (SKU, nombre, categoria, precio, stock)
- suppliers (razon social, ID fiscal, contacto, terminos pago)
- inventory_movements (fecha, tipo, SKU, cantidad, costo, motivo)
- sales_orders (numero, cliente, fechas, estado, totales)
- invoices (numero, cliente, fechas, totales, pagado, moneda)
Filosofia: UI como datos. Persistencia universal (MemoryStore hoy,
SurrealStore manana, sin tocar module.json). Schema primero, semantica
despues.
Activacion:
NAKUI_MODULES_DIR=examples/nakui-modules cargo run -p nakui-ui
Limitaciones conocidas (proximos iters):
- Inputs sin teclado (GPUI no lo trae nativo; integrar
yahweh-widget-text-input).
- Click handlers no propagan mutacion al estado (refactor con
cx.listener pendiente).
- Action::Morphism queda como TODO hasta cargar Manifest junto al
Module.
- Sin persistencia entre runs (wire con EventLog/SurrealStore para
cuando el daemon Nakui exista).
Tests: 16 totales nuevos. Lo que esto desbloquea: cualquiera puede
escribir un module.json para su dominio (pacientes, alumnos,
reservaciones) y aparece en la UI sin recompilar.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"id": "products",
|
||||
"label": "Productos",
|
||||
"description": "Catálogo de productos y precios.",
|
||||
"entities": [
|
||||
{
|
||||
"name": "product",
|
||||
"label": "Producto",
|
||||
"fields": [
|
||||
{ "name": "sku", "label": "SKU", "kind": "text", "required": true, "help": "Código único" },
|
||||
{ "name": "name", "label": "Nombre", "kind": "text", "required": true },
|
||||
{ "name": "category", "label": "Categoría", "kind": "text", "required": false },
|
||||
{ "name": "price", "label": "Precio unitario", "kind": "number", "required": true, "default": "0" },
|
||||
{ "name": "stock", "label": "Stock disponible", "kind": "number", "default": "0" },
|
||||
{ "name": "active", "label": "En venta", "kind": "boolean", "default": "true" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"menu": [
|
||||
{ "label": "Catálogo", "view": "list", "icon": "📦" },
|
||||
{ "label": "Nuevo producto", "view": "form", "icon": "✚" }
|
||||
],
|
||||
"views": {
|
||||
"list": {
|
||||
"kind": "list",
|
||||
"title": "Catálogo de productos",
|
||||
"entity": "product",
|
||||
"columns": [
|
||||
{ "field": "sku", "label": "SKU", "weight": 1.0 },
|
||||
{ "field": "name", "label": "Nombre", "weight": 2.5 },
|
||||
{ "field": "category", "label": "Categoría", "weight": 1.5 },
|
||||
{ "field": "price", "label": "Precio", "weight": 1.0 },
|
||||
{ "field": "stock", "label": "Stock", "weight": 0.8 },
|
||||
{ "field": "active", "label": "Activo", "weight": 0.6 }
|
||||
],
|
||||
"actions": [
|
||||
{ "kind": "open_view", "view": "form", "label": "✚ Nuevo" }
|
||||
],
|
||||
"search_in": ["sku", "name", "category"]
|
||||
},
|
||||
"form": {
|
||||
"kind": "form",
|
||||
"title": "Nuevo producto",
|
||||
"entity": "product",
|
||||
"fields": [
|
||||
{ "name": "sku", "label": "SKU", "kind": "text", "required": true },
|
||||
{ "name": "name", "label": "Nombre", "kind": "text", "required": true },
|
||||
{ "name": "category", "label": "Categoría", "kind": "text" },
|
||||
{ "name": "price", "label": "Precio", "kind": "number", "required": true, "default": "0" },
|
||||
{ "name": "stock", "label": "Stock inicial", "kind": "number", "default": "0" },
|
||||
{ "name": "active", "label": "En venta", "kind": "boolean", "default": "true" }
|
||||
],
|
||||
"on_submit": {
|
||||
"kind": "seed_entity",
|
||||
"entity": "product",
|
||||
"next_view": "list"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user