feat(api): proxy del Service Layer con registro de recursos
El frontend envía parámetros OData y cuerpo; el backend valida y ejecuta. - GET lista/por clave, POST y PATCH sobre /api/sl/:recurso, solo para recursos registrados (ventas, compras, inventario y maestros estándar); EmployeesInfo no se registra nunca (contiene U_WEB_PASS). - Permisos de menú por recurso (lectura/escritura); catálogos de consulta abiertos a cualquier sesión. Evaluador de patrones compartible (/inventario/* ya no habilita /inventario-x). - Parámetros OData validados con lista cerrada, $top máx. 500, $expand solo si el recurso lo declara, claves validadas y escapadas por tipo, cabeceras B1S-* con lista blanca. $inlinecount y B1S-PageSize automáticos. - configureApp() compartido entre main.ts y e2e (prefijo y límite de 5 mb). - Verificado contra SAP real: los 27 recursos existen; listado con total, filtro, paginación y claves. InventoryRequests no existe en el SL: se registra InventoryTransferRequests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
73fffee2f7
commit
c0990ca83e
15 files changed
+683
-6
No files matched your search
@@ -2,6 +2,7 @@ import { Test } from '@nestjs/testing';
|
||||
import type { INestApplication } from '@nestjs/common';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
import { SapClientService } from '../src/sap/sap-client.service.js';
|
||||
import { SL_RESOURCES } from '../src/sl/sl-resources.js';
|
||||
|
||||
// Prueba contra un Service Layer real (usa apps/api/.env). Solo con SAP_LIVE=1:
|
||||
// SAP_LIVE=1 npm run test:e2e
|
||||
@@ -26,4 +27,11 @@ describe.skipIf(!process.env.SAP_LIVE)('SAP Service Layer (live)', () => {
|
||||
);
|
||||
expect(res.every((r) => r.status === 200 && Array.isArray(r.data.value))).toBe(true);
|
||||
}, 30000);
|
||||
|
||||
// Detecta nombres de entidad mal escritos o no disponibles en este Service Layer.
|
||||
it.each(SL_RESOURCES.map((r) => r.name))('el recurso registrado %s existe en el Service Layer', async (name) => {
|
||||
const res = await sap.get<{ value: unknown[] }>(name, { $top: 1 });
|
||||
expect(res.status).toBe(200);
|
||||
expect(Array.isArray(res.data.value)).toBe(true);
|
||||
}, 30000);
|
||||
});
|
||||
Reference in new issue
Block a user