@braze/sanity-plugin-ai-translation 0.2.67 → 0.2.68

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
@@ -1921,10 +1921,17 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
1921
1921
  });
1922
1922
  return;
1923
1923
  }
1924
- node.text !== void 0 && !node.attributes.readonly && (get(doc, path) !== void 0 ? set(doc, path, node.text) : devLog.debug("Skipping field not present in original document", {
1925
- path: path.join("."),
1926
- attemptedValue: node.text
1927
- }));
1924
+ if (node.text !== void 0 && !node.attributes.readonly) {
1925
+ const existingValue = get(doc, path);
1926
+ existingValue !== void 0 && typeof existingValue == "string" ? set(doc, path, node.text) : existingValue !== void 0 ? devLog.debug("Skipping field - existing value is not a string (would corrupt structure)", {
1927
+ path: path.join("."),
1928
+ existingType: typeof existingValue,
1929
+ attemptedValue: node.text?.substring(0, 50)
1930
+ }) : devLog.debug("Skipping field not present in original document", {
1931
+ path: path.join("."),
1932
+ attemptedValue: node.text
1933
+ });
1934
+ }
1928
1935
  }, applyBlockChanges = (block, blockNode) => {
1929
1936
  if (blockNode.attributes._key && block._key !== blockNode.attributes._key) {
1930
1937
  devLog.warn("Block key mismatch, skipping", {
@@ -1955,7 +1962,11 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
1955
1962
  });
1956
1963
  return;
1957
1964
  }
1958
- fieldNode.text !== void 0 && !fieldNode.attributes.readonly && (fieldName in block ? block[fieldName] = fieldNode.text : devLog.debug("Skipping block field not present in original", {
1965
+ fieldNode.text !== void 0 && !fieldNode.attributes.readonly && (fieldName in block && typeof block[fieldName] == "string" ? block[fieldName] = fieldNode.text : fieldName in block ? devLog.debug("Skipping block field - existing value is not a string (would corrupt structure)", {
1966
+ fieldName,
1967
+ existingType: typeof block[fieldName],
1968
+ attemptedValue: fieldNode.text?.substring(0, 50)
1969
+ }) : devLog.debug("Skipping block field not present in original", {
1959
1970
  fieldName,
1960
1971
  attemptedValue: fieldNode.text
1961
1972
  }));