import semver , { coerce } from 'semver' ; private interface VersionNumbers { major : number ; minor : number ; patch : number ; } /**
 * Checks for the compatibilitiy between OpenSearch and OpenSearchDashboards versions
 * 1. Major version differences will never work together.
 * 2. Older versions of OpenSearch won't work with newer versions of OpenSearch Dashboards.
 */ export function opensearchVersionCompatibleWithOpenSearchDashboards ( opensearchVersion , opensearchDashboardsVersion ) { const opensearchVersionNumbers = { major : semver . major ( opensearchVersion ) , minor : semver . minor ( opensearchVersion ) , patch : semver . patch ( opensearchVersion ) , } ; const opensearchDashboardsVersionNumbers = { major : semver . major ( opensearchDashboardsVersion ) , minor : semver . minor ( opensearchDashboardsVersion ) , patch : semver . patch ( opensearchDashboardsVersion ) , } ; if ( legacyVersionCompatibleWithOpenSearchDashboards ( opensearchVersionNumbers , opensearchDashboardsVersionNumbers ) ) { return true ; } if ( opensearchVersionNumbers . major !== opensearchDashboardsVersionNumbers . major ) { return false ; } if ( opensearchVersionNumbers . minor < opensearchDashboardsVersionNumbers . minor ) { return false ; } return true ; } export function opensearchVersionEqualsOpenSearchDashboards ( nodeVersion , opensearchDashboardsVersion ) { const nodeSemVer = coerce ( nodeVersion ) ; const opensearchDashboardsSemver = coerce ( opensearchDashboardsVersion ) ; return ( nodeSemVer && opensearchDashboardsSemver && nodeSemVer . version === opensearchDashboardsSemver . version ) ; } private param legacyVersionNumbers param opensearchDashboardsVersionNumbers returns { boolean } function legacyVersionCompatibleWithOpenSearchDashboards ( legacyVersionNumbers , opensearchDashboardsVersionNumbers ) { return ( legacyVersionNumbers . major === 7 && legacyVersionNumbers . minor === 10 && legacyVersionNumbers . patch === 2 && opensearchDashboardsVersionNumbers . major === 1 ) ; }