@azure/app-configuration-importer 3.0.0-preview → 3.0.1-preview

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19097,6 +19097,7 @@
19097
19097
  */
19098
19098
  async GetConfigurationChanges(configSettingsSource, strict = false, importMode = exports.ImportMode.IgnoreMatch, customHeadersOption) {
19099
19099
  var _a, e_1, _b, _c;
19100
+ var _d, _e;
19100
19101
  this.validateImportMode(importMode);
19101
19102
  // Generate correlationRequestId for operations in the same activity
19102
19103
  if (!customHeadersOption) {
@@ -19117,33 +19118,33 @@
19117
19118
  }
19118
19119
  const configSettings = configSettingsResult;
19119
19120
  const configurationChanges = [];
19120
- const configurationSettingToAdd = [];
19121
- const srcKeyLabelLookUp = {};
19122
- configSettings.forEach((config) => {
19123
- if (!srcKeyLabelLookUp[config.key]) {
19124
- srcKeyLabelLookUp[config.key] = {};
19125
- }
19126
- srcKeyLabelLookUp[config.key][config.label || ""] = true;
19127
- });
19128
- configurationSettingToAdd.push(...configSettings);
19121
+ // Build O(1) lookup structures keyed by "key\0label" composite.
19122
+ const srcMap = new Map();
19123
+ const toAddKeys = new Set();
19124
+ for (const config of configSettings) {
19125
+ const composite = `${config.key}\u0000${(_d = config.label) !== null && _d !== void 0 ? _d : ""}`;
19126
+ srcMap.set(composite, config);
19127
+ toAddKeys.add(composite);
19128
+ }
19129
19129
  try {
19130
- for (var _d = true, _e = __asyncValues(this.configurationClient.listConfigurationSettings(Object.assign(Object.assign({}, configSettingsSource.FilterOptions), customHeadersOption))), _f; _f = await _e.next(), _a = _f.done, !_a;) {
19131
- _c = _f.value;
19132
- _d = false;
19130
+ // Stream target settings so we don't hold the entire remote store in memory.
19131
+ for (var _f = true, _g = __asyncValues(this.configurationClient.listConfigurationSettings(Object.assign(Object.assign({}, configSettingsSource.FilterOptions), customHeadersOption))), _h; _h = await _g.next(), _a = _h.done, !_a;) {
19132
+ _c = _h.value;
19133
+ _f = false;
19133
19134
  try {
19134
19135
  const existing = _c;
19135
- const isKeyLabelPresent = srcKeyLabelLookUp[existing.key] && srcKeyLabelLookUp[existing.key][existing.label || ""];
19136
- if (strict && !isKeyLabelPresent) {
19136
+ const composite = `${existing.key}\u0000${(_e = existing.label) !== null && _e !== void 0 ? _e : ""}`;
19137
+ const incoming = srcMap.get(composite);
19138
+ if (strict && !incoming) {
19137
19139
  configurationChanges.push({
19138
19140
  changeType: exports.ChangeType.Delete,
19139
19141
  currentValue: existing,
19140
19142
  newValue: null
19141
19143
  });
19142
19144
  }
19143
- const incoming = configSettings.find(configSetting => configSetting.key == existing.key && configSetting.label === existing.label);
19144
19145
  if (incoming) {
19145
19146
  // Remove from add list since it already exists
19146
- configurationSettingToAdd.splice(configurationSettingToAdd.indexOf(incoming), 1);
19147
+ toAddKeys.delete(composite);
19147
19148
  if (!isConfigSettingEqual(incoming, existing)) {
19148
19149
  configurationChanges.push({
19149
19150
  changeType: exports.ChangeType.Update,
@@ -19161,22 +19162,22 @@
19161
19162
  }
19162
19163
  }
19163
19164
  finally {
19164
- _d = true;
19165
+ _f = true;
19165
19166
  }
19166
19167
  }
19167
19168
  }
19168
19169
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
19169
19170
  finally {
19170
19171
  try {
19171
- if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
19172
+ if (!_f && !_a && (_b = _g.return)) await _b.call(_g);
19172
19173
  }
19173
19174
  finally { if (e_1) throw e_1.error; }
19174
19175
  }
19175
- for (const setting of configurationSettingToAdd) {
19176
+ for (const composite of toAddKeys) {
19176
19177
  configurationChanges.push({
19177
19178
  changeType: exports.ChangeType.Create,
19178
19179
  currentValue: null,
19179
- newValue: setting
19180
+ newValue: srcMap.get(composite)
19180
19181
  });
19181
19182
  }
19182
19183
  return configurationChanges;