in libraries/azure-app-configuration-importer/src/internal/parsers/defaultConfigurationSettingsConverter.ts [34:110]
public Convert(
config: object,
options: SourceOptions
): SetConfigurationSettingParam<string | SecretReferenceValue>[] {
let configurationSettings = new Array<
SetConfigurationSettingParam<string>
>();
let featureFlagsConfigSettings = new Array<SetConfigurationSettingParam<string>>();
let foundMsFmSchema = false;
let foundDotnetFmSchema = false;
let dotnetFmSchemaKeyWord = "";
const featureFlagsDict: any = {};
if (options.format == ConfigurationFormat.Properties && !options.skipFeatureFlags) {
this.checkFeatureManagementExist(config);
}
for (let i = 0; i < Constants.FeatureManagementKeyWords.length - 1; i++) {
if (Constants.FeatureManagementKeyWords[i] in config) {
if (foundDotnetFmSchema) {
throw new ArgumentError(
`Unable to proceed because data contains multiple sections corresponding to Feature Management. with the key, ${Constants.FeatureManagementKeyWords[i]}`
);
}
foundDotnetFmSchema = true;
dotnetFmSchemaKeyWord = Constants.FeatureManagementKeyWords[i];
const dotnetFmSchemaKey = dotnetFmSchemaKeyWord as keyof object;
featureFlagsDict[dotnetFmSchemaKey] = config[dotnetFmSchemaKey];
delete config[dotnetFmSchemaKey];
}
}
const msFeatureManagementKeyWord = Constants.FeatureManagementKeyWords[3];
if (msFeatureManagementKeyWord in config) {
if (foundDotnetFmSchema &&
Object.keys(config[msFeatureManagementKeyWord as keyof object]).some(key => key !== Constants.FeatureFlagsKeyWord)) {
throw new ArgumentError(
`Unable to proceed because data contains an already defined dotnet schema section with the key, ${dotnetFmSchemaKeyWord}.`
);
}
if (Object.keys(config[msFeatureManagementKeyWord as keyof object]).includes(Constants.FeatureFlagsKeyWord)) {
foundMsFmSchema = true;
}
if (Object.keys(config[msFeatureManagementKeyWord as keyof object]).some(key => key !== Constants.FeatureFlagsKeyWord)){
foundDotnetFmSchema = true;
dotnetFmSchemaKeyWord = msFeatureManagementKeyWord;
}
const featureManagementKey = msFeatureManagementKeyWord as keyof object;
featureFlagsDict[featureManagementKey] = config[featureManagementKey];
delete config[featureManagementKey];
}
if ((foundDotnetFmSchema || foundMsFmSchema) && !options.skipFeatureFlags) {
const featureFlagConverter = new FeatureFlagConfigurationSettingsConverter(
dotnetFmSchemaKeyWord,
foundMsFmSchema
);
featureFlagsConfigSettings = featureFlagConverter.Convert(featureFlagsDict, options);
}
const flattenedConfigurationSettings: object = flat.flatten(config, {
delimiter: options.separator,
maxDepth: options.depth,
safe: isJsonContentType(options.contentType) // preserve array for json content type
});
configurationSettings = this.toConfigurationSettings(flattenedConfigurationSettings, options);
configurationSettings = configurationSettings.concat(featureFlagsConfigSettings);
return configurationSettings;
}