// ╔═══════╗╔═══════╗╔═══════╗╔═══════╗╔═══════╗╔═══════╗╔═══════╗ // ╚══╗ ╔══╝║ ╔╗ ╔╗ ║║ ╔═══╗ ║║ ╔═══╗ ║║ ╔═══╗ ║╚══╗ ╔══╝║ ╔═════╝ // ║ ║ ║ ║║ ║║ ║║ ╚═══╝ ║║ ║ ║ ║║ ╚═══╝ ║ ║ ║ ║ ╚═════╗ // ║ ║ ║ ║║ ║║ ║║ ╔═════╝║ ║ ║ ║║ ╔═╗ ╔═╝ ║ ║ ╚═════╗ ║ // ╔══╝ ╚══╗║ ║║ ║║ ║║ ║ ║ ╚═══╝ ║║ ║ ║ ╚═╗ ║ ║ ╔═════╝ ║ // ╚═══════╝╚═╝╚═╝╚═╝╚═╝ ╚═══════╝╚═╝ ╚═══╝ ╚═╝ ╚═══════╝ import * as connectionValidators from '../validators/connection-validators.js'; import * as connectionClasses from '../classes/connection-classes.js'; // ╔═══════╗╔═══════╗╔═══════╗╔═╗ ╔═╗╔═══════╗╔═══════╗╔═══════╗ // ║ ╔═══╗ ║║ ╔═══╗ ║╚══╗ ╔══╝║ ║ ║ ║║ ╔═══╗ ║╚══╗ ╔══╝║ ╔═════╝ // ║ ╚═══╝ ║║ ╚═══╝ ║ ║ ║ ║ ╚╗ ╔╝ ║║ ╚═══╝ ║ ║ ║ ║ ╚═════╗ // ║ ╔═════╝║ ╔═╗ ╔═╝ ║ ║ ╚╗ ║ ║ ╔╝║ ╔═══╗ ║ ║ ║ ║ ╔═════╝ // ║ ║ ║ ║ ║ ╚═╗╔══╝ ╚══╗ ║ ╚═╝ ║ ║ ║ ║ ║ ║ ║ ║ ╚═════╗ // ╚═╝ ╚═╝ ╚═══╝╚═══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═══════╝ const _connectionByLabel = new Map(); // ╔═══════╗╔═══════╗╔═══════╗╔═╗ ╔═╗╔═══════╗ // ║ ╔═════╝║ ╔═══╗ ║║ ╔═════╝║ ║ ║ ║║ ╔═════╝ // ║ ║ ║ ╚═══╝ ║║ ║ ║ ╚═══╝ ║║ ╚═════╗ // ║ ║ ║ ╔═══╗ ║║ ║ ║ ╔═══╗ ║║ ╔═════╝ // ║ ╚═════╗║ ║ ║ ║║ ╚═════╗║ ║ ║ ║║ ╚═════╗ // ╚═══════╝╚═╝ ╚═╝╚═══════╝╚═╝ ╚═╝╚═══════╝ export function cacheConnection(connection: connectionClasses.Connection) { connectionValidators.validateConnection(connection); _connectionByLabel.set(connection.getLabel(), connection); return connection; } // ╔═══════╗╔═══════╗╔═══════╗╔═╗ ╔═╗╔═══════╗╔═══════╗ // ║ ╔═════╝║ ╔═══╗ ║║ ╔═════╝║ ║ ║ ║║ ╔═════╝╚╗ ╔══╗ ║ // ║ ║ ║ ╚═══╝ ║║ ║ ║ ╚═══╝ ║║ ╚═════╗ ║ ║ ║ ║ // ║ ║ ║ ╔═══╗ ║║ ║ ║ ╔═══╗ ║║ ╔═════╝ ║ ║ ║ ║ // ║ ╚═════╗║ ║ ║ ║║ ╚═════╗║ ║ ║ ║║ ╚═════╗╔╝ ╚══╝ ║ // ╚═══════╝╚═╝ ╚═╝╚═══════╝╚═╝ ╚═╝╚═══════╝╚═══════╝ export function getCachedConnectionByLabel(connectionLabel: any) { connectionValidators.validateRegisteredConnectionLabel(connectionLabel); return _connectionByLabel.get(connectionLabel) as connectionClasses.Connection; } export function getCachedConnections() { return [..._connectionByLabel.values()]; } export function isCachedConnectionLabel(connectionLabel: any) { return _connectionByLabel.has(connectionLabel); }