@azure/app-configuration-importer 2.0.0-preview → 3.0.0-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
@@ -527,7 +527,17 @@
527
527
  (function (ImportMode) {
528
528
  ImportMode[ImportMode["All"] = 0] = "All";
529
529
  ImportMode[ImportMode["IgnoreMatch"] = 1] = "IgnoreMatch";
530
- })(exports.ImportMode || (exports.ImportMode = {}));
530
+ })(exports.ImportMode || (exports.ImportMode = {}));
531
+ /**
532
+ * Enums of change type for configuration settings changes
533
+ */
534
+ exports.ChangeType = void 0;
535
+ (function (ChangeType) {
536
+ ChangeType[ChangeType["None"] = 0] = "None";
537
+ ChangeType[ChangeType["Create"] = 1] = "Create";
538
+ ChangeType[ChangeType["Delete"] = 2] = "Delete";
539
+ ChangeType[ChangeType["Update"] = 3] = "Update";
540
+ })(exports.ChangeType || (exports.ChangeType = {}));
531
541
 
532
542
  function isFunction(value) {
533
543
  return typeof value === 'function';
@@ -19056,7 +19066,13 @@
19056
19066
  }
19057
19067
  };
19058
19068
  const configurationChanges = await this.GetConfigurationChanges(configurationSettingsSource, options === null || options === void 0 ? void 0 : options.strict, options === null || options === void 0 ? void 0 : options.importMode, customHeadersOption);
19059
- return await this.applyUpdatesToServer([...configurationChanges.ToAdd, ...configurationChanges.ToModify, ...configurationChanges.ToRefresh], configurationChanges.ToDelete, options.timeout, customHeadersOption, options.progressCallback);
19069
+ const settingsToWrite = configurationChanges
19070
+ .filter(c => (c.changeType === exports.ChangeType.Create || c.changeType === exports.ChangeType.Update || c.changeType === exports.ChangeType.None) && c.newValue)
19071
+ .map(c => c.newValue);
19072
+ const settingsToDelete = configurationChanges
19073
+ .filter(c => c.changeType === exports.ChangeType.Delete && c.currentValue)
19074
+ .map(c => c.currentValue);
19075
+ return await this.applyUpdatesToServer(settingsToWrite, settingsToDelete, options.timeout, customHeadersOption, options.progressCallback);
19060
19076
  }
19061
19077
  /**
19062
19078
  * Get configuration changes between source settings and existing settings in Azure App Configuration service without applying any changes
@@ -19077,7 +19093,7 @@
19077
19093
  * 'All' will include all key-values.
19078
19094
  * 'Ignore-Match' will exclude settings that have matching key-values in App Configuration.
19079
19095
  * @param customHeadersOption - Custom headers for the operation.
19080
- * @returns ConfigurationChanges object containing Added, Modified, and Deleted settings
19096
+ * @returns Array of ConfigurationSettingChange objects representing the changes
19081
19097
  */
19082
19098
  async GetConfigurationChanges(configSettingsSource, strict = false, importMode = exports.ImportMode.IgnoreMatch, customHeadersOption) {
19083
19099
  var _a, e_1, _b, _c;
@@ -19100,10 +19116,8 @@
19100
19116
  return configSettingsResult;
19101
19117
  }
19102
19118
  const configSettings = configSettingsResult;
19103
- const configurationSettingToDelete = [];
19104
- const configurationSettingToModify = [];
19119
+ const configurationChanges = [];
19105
19120
  const configurationSettingToAdd = [];
19106
- const configurationSettingToRefresh = [];
19107
19121
  const srcKeyLabelLookUp = {};
19108
19122
  configSettings.forEach((config) => {
19109
19123
  if (!srcKeyLabelLookUp[config.key]) {
@@ -19120,19 +19134,29 @@
19120
19134
  const existing = _c;
19121
19135
  const isKeyLabelPresent = srcKeyLabelLookUp[existing.key] && srcKeyLabelLookUp[existing.key][existing.label || ""];
19122
19136
  if (strict && !isKeyLabelPresent) {
19123
- configurationSettingToDelete.push(existing);
19137
+ configurationChanges.push({
19138
+ changeType: exports.ChangeType.Delete,
19139
+ currentValue: existing,
19140
+ newValue: null
19141
+ });
19124
19142
  }
19125
19143
  const incoming = configSettings.find(configSetting => configSetting.key == existing.key && configSetting.label === existing.label);
19126
19144
  if (incoming) {
19127
19145
  // Remove from add list since it already exists
19128
19146
  configurationSettingToAdd.splice(configurationSettingToAdd.indexOf(incoming), 1);
19129
19147
  if (!isConfigSettingEqual(incoming, existing)) {
19130
- // Key-value has changed, add to ToModify
19131
- configurationSettingToModify.push(incoming);
19148
+ configurationChanges.push({
19149
+ changeType: exports.ChangeType.Update,
19150
+ currentValue: existing,
19151
+ newValue: incoming
19152
+ });
19132
19153
  }
19133
19154
  else if (importMode === exports.ImportMode.All) {
19134
- // Key-value is unchanged and importMode is All, add to ToRefresh
19135
- configurationSettingToRefresh.push(incoming);
19155
+ configurationChanges.push({
19156
+ changeType: exports.ChangeType.None,
19157
+ currentValue: existing,
19158
+ newValue: incoming
19159
+ });
19136
19160
  }
19137
19161
  }
19138
19162
  }
@@ -19148,12 +19172,14 @@
19148
19172
  }
19149
19173
  finally { if (e_1) throw e_1.error; }
19150
19174
  }
19151
- return {
19152
- ToAdd: configurationSettingToAdd,
19153
- ToModify: configurationSettingToModify,
19154
- ToDelete: configurationSettingToDelete,
19155
- ToRefresh: configurationSettingToRefresh
19156
- };
19175
+ for (const setting of configurationSettingToAdd) {
19176
+ configurationChanges.push({
19177
+ changeType: exports.ChangeType.Create,
19178
+ currentValue: null,
19179
+ newValue: setting
19180
+ });
19181
+ }
19182
+ return configurationChanges;
19157
19183
  }
19158
19184
  async applyUpdatesToServer(settingsToPut, settingsToDelete, timeout, options, progressCallback) {
19159
19185
  const deleteTaskManager = this.newAdaptiveTaskManager((setting) => this.configurationClient.deleteConfigurationSetting(setting, options), settingsToDelete);
@@ -19198,14 +19224,16 @@
19198
19224
  * @internal
19199
19225
  */
19200
19226
  isConfigurationChanges(obj) {
19201
- if (obj === null || typeof obj !== "object") {
19227
+ if (!Array.isArray(obj)) {
19202
19228
  return false;
19203
19229
  }
19204
- const configChanges = obj;
19205
- return Array.isArray(configChanges.ToAdd) &&
19206
- Array.isArray(configChanges.ToModify) &&
19207
- Array.isArray(configChanges.ToDelete) &&
19208
- Array.isArray(configChanges.ToRefresh);
19230
+ // Validate it's an array of ConfigurationSettingChange objects
19231
+ return obj.every(item => item &&
19232
+ typeof item === "object" &&
19233
+ "changeType" in item &&
19234
+ "currentValue" in item &&
19235
+ "newValue" in item &&
19236
+ Object.values(exports.ChangeType).includes(item.changeType));
19209
19237
  }
19210
19238
  }
19211
19239