Initial JARED implementation - Predefined flows manager for CORP

- Flask API with full CRUD for flows
- Execute flow with OK->FELDMAN / incidencia->MASON routing
- PostgreSQL integration with host DB
- Docker deployment on port 5052
- S-CONTRACT v2.1 compliant
This commit is contained in:
ARCHITECT
2025-12-24 10:25:10 +00:00
commit b4bb286396
7 changed files with 488 additions and 0 deletions

37
init.sql Normal file
View File

@@ -0,0 +1,37 @@
-- JARED database tables for CORP
CREATE TABLE IF NOT EXISTS flujos_predefinidos (
id VARCHAR(64) PRIMARY KEY,
h_instancia VARCHAR(64) NOT NULL,
nombre VARCHAR(100) NOT NULL,
descripcion TEXT,
pasos JSONB NOT NULL,
campos_fijos JSONB DEFAULT '{}',
campos_variables JSONB DEFAULT '[]',
activo BOOLEAN DEFAULT true,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS flujo_ejecuciones (
id BIGSERIAL PRIMARY KEY,
h_flujo VARCHAR(64) REFERENCES flujos_predefinidos(id),
h_instancia VARCHAR(64) NOT NULL,
h_ejecucion VARCHAR(64) NOT NULL UNIQUE,
datos JSONB NOT NULL,
estado VARCHAR(20) DEFAULT 'ok',
destino VARCHAR(20) DEFAULT 'feldman',
notas TEXT,
created_at TIMESTAMP DEFAULT NOW()
);
-- Indexes
CREATE INDEX IF NOT EXISTS idx_flujos_h_instancia ON flujos_predefinidos(h_instancia);
CREATE INDEX IF NOT EXISTS idx_ejecuciones_h_instancia ON flujo_ejecuciones(h_instancia);
CREATE INDEX IF NOT EXISTS idx_ejecuciones_estado ON flujo_ejecuciones(estado);
CREATE INDEX IF NOT EXISTS idx_ejecuciones_destino ON flujo_ejecuciones(destino);
-- Permissions (run as postgres superuser)
-- GRANT ALL PRIVILEGES ON TABLE flujos_predefinidos TO corp;
-- GRANT ALL PRIVILEGES ON TABLE flujo_ejecuciones TO corp;
-- GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO corp;