/** * Mono-tenant: el bot opera con un único tenant resuelto al boot. * * Toda la infra DB sigue con columnas `tenant_id` (queda lista para * multi-tenant futuro) pero la app se inicializa con un único ID * y todas las llamadas a "resolver el tenant" devuelven ese mismo. * * Setup en boot (index.js): `setTenantId(uuid)` después de ensureTenant. * Lectura en cualquier capa: `getTenantId()`. */ let _tenantId = null; let _tenantKey = null; export function setTenant({ id, key }) { if (!id) throw new Error("setTenant requires id"); _tenantId = id; _tenantKey = key || null; } export function getTenantId() { if (!_tenantId) { throw new Error("tenant not initialized: call setTenant() at boot"); } return _tenantId; } export function getTenantKey() { return _tenantKey; }