@o3r/components
Version:
This module contains component-related features (Component replacement, CMS compatibility, helpers, pipes, debugging developer tools...) It comes with an integrated ng builder to help you generate components compatible with Otter features (CMS integration
32 lines • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.configMetadataComparator = void 0;
/**
* Returns an array of config metadata from a metadata file.
* To be easily parseable, the properties will be split in separate items of the array.
* @param content Content of a migration metadata files
* @example Array conversion
* ```javascript
* [{ library: '@o3r/demo', properties: [{name : 'property1', type: 'string'}, {name : 'property2', type: 'number'}] }]
* ```
* will become :
* ```javascript
* [{ library: '@o3r/demo', properties: [{name : 'property1', type: 'string'}] }, { library: '@o3r/demo', properties: [{name : 'property2', type: 'number'}] }]
* ```
*/
const getConfigurationArray = (content) => content.flatMap((config) => config.properties.map((prop) => ({ ...config, properties: [prop] })));
const getConfigurationPropertyName = (config) => `${config.library}#${config.name}` + (config.properties.length > 0 ? ` ${config.properties[0].name}` : '');
const isRelevantContentType = (contentType) => contentType === 'CONFIG';
const isMigrationConfigurationDataMatch = (config, migrationData) => migrationData.libraryName === config.library
&& (!migrationData.configName || migrationData.configName === config.name)
&& (!migrationData.propertyName || config.properties[0]?.name === migrationData.propertyName);
/**
* Comparator used to compare one version of config metadata with another
*/
exports.configMetadataComparator = {
getArray: getConfigurationArray,
getIdentifier: getConfigurationPropertyName,
isRelevantContentType,
isMigrationDataMatch: isMigrationConfigurationDataMatch
};
//# sourceMappingURL=config-metadata-comparison.helper.js.map