@transcommerce/cwm-shared 1.1.69 → 1.1.74

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.
@@ -27756,23 +27756,35 @@ class ConfigService {
27756
27756
  }
27757
27757
  return setting.value;
27758
27758
  }
27759
- async setConfigurationSettingAsync(templateName, label, setting, contentType = "Text") {
27759
+ async setConfigurationSettingAsync(templateName, label, setting, contentType = "application/json") {
27760
27760
  this.logger.methodName = "setConfigurationSettingAsync()";
27761
27761
  if (this.mockData) {
27762
27762
  this.logger.info("Mock Data Enabled, Skipping setConfigurationSettingAsync()");
27763
27763
  this.logger.methodName = "";
27764
27764
  return;
27765
27765
  }
27766
+ this.logger.debug(`Saving this value to app config ${setting}`, setting, contentType);
27766
27767
  // --- FIX: Ensure JSON objects are stringified before saving ---
27767
27768
  let valueToSave;
27768
- if (contentType === "JSON") {
27769
+ if (contentType === "application/json") {
27769
27770
  // If it's already a string, trust it. Otherwise stringify.
27770
- valueToSave = typeof setting === "string"
27771
- ? setting
27772
- : JSON.stringify(setting);
27771
+ if (typeof setting === "string") {
27772
+ contentType = "text/plain";
27773
+ valueToSave = setting;
27774
+ this.logger.trace("This is just a sting marked as JSON so we are correcting the contentType");
27775
+ }
27776
+ else {
27777
+ valueToSave = JSON.stringify(setting);
27778
+ this.logger.trace("This is a valid JSON configuration");
27779
+ }
27780
+ }
27781
+ else if (contentType !== "text/html" && contentType !== "text/markdown") {
27782
+ this.logger.trace("This is just a string so marking it contentType correctly");
27783
+ contentType = "text/plain";
27784
+ valueToSave = String(setting);
27773
27785
  }
27774
27786
  else {
27775
- // Non‑JSON settings must still be strings
27787
+ this.logger.trace("This is a string");
27776
27788
  valueToSave = String(setting);
27777
27789
  }
27778
27790
  const configurationSetting = {
@@ -27817,7 +27829,7 @@ class ConfigService {
27817
27829
  return;
27818
27830
  }
27819
27831
  this.logger.info("Saving Configuration to Azure App Configuration");
27820
- await this.setConfigurationSettingAsync("App.Config.Json", company, config, "JSON");
27832
+ await this.setConfigurationSettingAsync("App.Config.Json", company, config, "application/json");
27821
27833
  this.logger.info("Saved Configuration to Azure App Configuration");
27822
27834
  this.logger.methodName = "";
27823
27835
  }