import { Log } from '@servicetitan/log-service'; import { ExposedDependencies } from '@servicetitan/startup-utils'; import { ExposedInstanceDependencies } from '../common'; import { BundleInfo } from './get-bundle-info'; interface Context { exposedDependencies?: ExposedDependencies; exposedInstanceDependencies?: ExposedInstanceDependencies; logService?: Log; packageUrl: string; } export function validateBundleInfo( { mismatch, mfeHasCompatibleLaunchDarklyVersion }: BundleInfo, { exposedDependencies = {}, exposedInstanceDependencies, logService, packageUrl }: Context ) { if (!logService) { return; } if (mismatch) { const data = { package: packageUrl, dependencies: JSON.stringify(mismatch) }; if (Object.keys(exposedDependencies).length === 0) { logService.warning({ category: 'MicroFrontends.NoExposedDependencies', message: 'Cannot use light bundle because the host is not exposing dependencies or the list of shared dependencies is empty.', data, }); } else { logService.warning({ category: 'MicroFrontends.DependenciesMismatch', message: 'Some of the package dependencies have incompatible versions.', data, }); } } /** * Note, only checking false here because the value is undefined when the host * or the MFE isn't using LaunchDarkly at all. */ if (mfeHasCompatibleLaunchDarklyVersion === false) { const data = { package: packageUrl, hostVersion: exposedInstanceDependencies?.launchDarkly?.version ?? '', }; logService.warning({ category: 'MicroFrontends.LaunchDarklyMismatch', message: 'LaunchDarkly versions are incompatible', data, }); } }