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,63 @@
|
||||
{
|
||||
"id": "inventory_movements",
|
||||
"label": "Inventario",
|
||||
"description": "Movimientos de stock: entradas, salidas, ajustes.",
|
||||
"entities": [
|
||||
{
|
||||
"name": "stock_movement",
|
||||
"label": "Movimiento",
|
||||
"fields": [
|
||||
{ "name": "occurred_at", "label": "Fecha", "kind": "date", "required": true },
|
||||
{ "name": "movement_type", "label": "Tipo", "kind": "text", "required": true, "help": "in / out / adjustment" },
|
||||
{ "name": "product_sku", "label": "SKU producto", "kind": "text", "required": true },
|
||||
{ "name": "quantity", "label": "Cantidad", "kind": "number", "required": true },
|
||||
{ "name": "unit_cost", "label": "Costo unitario", "kind": "number", "default": "0" },
|
||||
{ "name": "reason", "label": "Motivo", "kind": "text", "help": "Compra, venta, merma, ajuste por inventario..." },
|
||||
{ "name": "reference", "label": "Doc. referencia", "kind": "text", "help": "Factura, orden, conteo..." }
|
||||
]
|
||||
}
|
||||
],
|
||||
"menu": [
|
||||
{ "label": "Movimientos", "view": "list", "icon": "📊" },
|
||||
{ "label": "Registrar", "view": "form", "icon": "✚" }
|
||||
],
|
||||
"views": {
|
||||
"list": {
|
||||
"kind": "list",
|
||||
"title": "Movimientos de stock",
|
||||
"entity": "stock_movement",
|
||||
"columns": [
|
||||
{ "field": "occurred_at", "label": "Fecha", "weight": 1.0 },
|
||||
{ "field": "movement_type", "label": "Tipo", "weight": 0.7 },
|
||||
{ "field": "product_sku", "label": "SKU", "weight": 1.0 },
|
||||
{ "field": "quantity", "label": "Cantidad", "weight": 0.8 },
|
||||
{ "field": "unit_cost", "label": "Costo", "weight": 0.8 },
|
||||
{ "field": "reason", "label": "Motivo", "weight": 1.5 },
|
||||
{ "field": "reference", "label": "Ref.", "weight": 1.0 }
|
||||
],
|
||||
"actions": [
|
||||
{ "kind": "open_view", "view": "form", "label": "✚ Registrar" }
|
||||
],
|
||||
"search_in": ["product_sku", "reason", "reference"]
|
||||
},
|
||||
"form": {
|
||||
"kind": "form",
|
||||
"title": "Registrar movimiento",
|
||||
"entity": "stock_movement",
|
||||
"fields": [
|
||||
{ "name": "occurred_at", "label": "Fecha", "kind": "date", "required": true },
|
||||
{ "name": "movement_type", "label": "Tipo (in/out/adjustment)", "kind": "text", "required": true, "default": "in" },
|
||||
{ "name": "product_sku", "label": "SKU producto", "kind": "text", "required": true },
|
||||
{ "name": "quantity", "label": "Cantidad", "kind": "number", "required": true },
|
||||
{ "name": "unit_cost", "label": "Costo unitario", "kind": "number", "default": "0" },
|
||||
{ "name": "reason", "label": "Motivo", "kind": "text" },
|
||||
{ "name": "reference", "label": "Documento de referencia", "kind": "text" }
|
||||
],
|
||||
"on_submit": {
|
||||
"kind": "seed_entity",
|
||||
"entity": "stock_movement",
|
||||
"next_view": "list"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user