// ╔═══════╗╔═══════╗╔═══════╗╔═══════╗╔═══════╗╔═══════╗╔═══════╗ // ╚══╗ ╔══╝║ ╔╗ ╔╗ ║║ ╔═══╗ ║║ ╔═══╗ ║║ ╔═══╗ ║╚══╗ ╔══╝║ ╔═════╝ // ║ ║ ║ ║║ ║║ ║║ ╚═══╝ ║║ ║ ║ ║║ ╚═══╝ ║ ║ ║ ║ ╚═════╗ // ║ ║ ║ ║║ ║║ ║║ ╔═════╝║ ║ ║ ║║ ╔═╗ ╔═╝ ║ ║ ╚═════╗ ║ // ╔══╝ ╚══╗║ ║║ ║║ ║║ ║ ║ ╚═══╝ ║║ ║ ║ ╚═╗ ║ ║ ╔═════╝ ║ // ╚═══════╝╚═╝╚═╝╚═╝╚═╝ ╚═══════╝╚═╝ ╚═══╝ ╚═╝ ╚═══════╝ import * as connectionTypings from '../../typings/connection-typings.js'; import * as connectionErrors from '../../errors/connection-errors.js'; import * as credentialModule from '../../../credential/credential-module.js'; import * as hostnameModule from '../../../hostname/hostname-module.js'; import * as utilityEngine from '@xyz.warpmatter.com/utility-engine'; // ╔═══════╗╔═══════╗╔═══════╗╔═══════╗╔═╗ ╔═╗╔═══════╗╔═══════╗╔═══════╗ // ║ ╔═══╗ ║║ ╔═════╝║ ╔═════╝║ ╔═══╗ ║║ ║ ║ ║║ ╔═══╗ ║║ ╔═════╝║ ╔═════╝ // ║ ╚═══╝ ║║ ╚═════╗║ ╚═════╗║ ║ ║ ║║ ║ ║ ║║ ╚═══╝ ║║ ║ ║ ╚═════╗ // ║ ╔═╗ ╔═╝║ ╔═════╝╚═════╗ ║║ ║ ║ ║║ ║ ║ ║║ ╔═╗ ╔═╝║ ║ ║ ╔═════╝ // ║ ║ ║ ╚═╗║ ╚═════╗╔═════╝ ║║ ╚═══╝ ║║ ╚═══╝ ║║ ║ ║ ╚═╗║ ╚═════╗║ ╚═════╗ // ╚═╝ ╚═══╝╚═══════╝╚═══════╝╚═══════╝╚═══════╝╚═╝ ╚═══╝╚═══════╝╚═══════╝ export function validateConnectionResources( values: any[], minimumCount?: number, maximumCount?: number, ) { if (!areValidConnectionResources(values, minimumCount, maximumCount)) { connectionErrors.throwInvalidAbsorbLmsConnectionResourceError(); } } export function validateConnectionResource( value: any, ) { if (!isValidConnectionResource(value)) { connectionErrors.throwInvalidAbsorbLmsConnectionResourceError(); } } export function areValidConnectionResources( values: any[], minimumCount?: number, maximumCount?: number, ): values is connectionTypings.ConnectionResource[] { return utilityEngine.isArray(values, minimumCount, maximumCount) && values.every(isValidConnectionResource); } export function isValidConnectionResource( value: any, ): value is connectionTypings.ConnectionResource { return utilityEngine.isObjectLiteral(value) && hostnameModule.isValidHostname(value.hostname) && credentialModule.isValidUsername(value.username) && credentialModule.isValidPassword(value.password) && credentialModule.isValidPrivateKey(value.privateKey); }