2016-07-02 16:25:30 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function addOldFields (feature) {
|
2016-09-05 16:50:52 +02:00
|
|
|
const modifiedFeature = Object.assign({}, feature);
|
2016-07-02 16:25:30 +02:00
|
|
|
modifiedFeature.strategy = feature.strategies[0].name;
|
|
|
|
modifiedFeature.parameters = Object.assign({}, feature.strategies[0].parameters);
|
|
|
|
return modifiedFeature;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isOldFomrat (feature) {
|
|
|
|
return feature.strategy && !feature.strategies;
|
|
|
|
}
|
|
|
|
|
|
|
|
function toNewFormat (feature) {
|
|
|
|
if (isOldFomrat(feature)) {
|
|
|
|
return {
|
|
|
|
name: feature.name,
|
|
|
|
description: feature.description,
|
|
|
|
enabled: feature.enabled,
|
|
|
|
strategies: [
|
|
|
|
{
|
|
|
|
name: feature.strategy,
|
|
|
|
parameters: Object.assign({}, feature.parameters),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return feature;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { addOldFields, toNewFormat };
|