@braze/sanity-plugin-ai-translation 0.2.62 → 0.2.64

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
@@ -1682,7 +1682,24 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
1682
1682
  parent && parent.children.push(node);
1683
1683
  } else
1684
1684
  root.push(node);
1685
- else if (attributes.type === "string" && !content) {
1685
+ else if (attributes.type === "string" && content && !content.includes(closingTag)) {
1686
+ const contentLines = [content];
1687
+ for (i++; i < lines.length; ) {
1688
+ const currentLine = lines[i];
1689
+ if (currentLine.includes(closingTag)) {
1690
+ const closingIndex = currentLine.indexOf(closingTag), remainingContent = currentLine.substring(0, closingIndex);
1691
+ remainingContent && contentLines.push(remainingContent);
1692
+ break;
1693
+ }
1694
+ contentLines.push(currentLine), i++;
1695
+ }
1696
+ if (node.text = unescapeXml(contentLines.join(`
1697
+ `)), stack.length > 0) {
1698
+ const parent = stack[stack.length - 1];
1699
+ parent && parent.children.push(node);
1700
+ } else
1701
+ root.push(node);
1702
+ } else if (attributes.type === "string" && !content) {
1686
1703
  const contentLines = [];
1687
1704
  for (i++; i < lines.length; ) {
1688
1705
  const currentLine = lines[i];
@@ -1849,8 +1866,28 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
1849
1866
  return;
1850
1867
  }
1851
1868
  if (node.attributes.type === "object") {
1852
- for (const child of node.children)
1853
- child.name && applyFieldChanges(doc, [...path, child.name], child);
1869
+ const currentValue = get(doc, path);
1870
+ if (currentValue && typeof currentValue == "object" && !Array.isArray(currentValue)) {
1871
+ const currentValueObj = currentValue;
1872
+ for (const child of node.children)
1873
+ if (child.name) {
1874
+ const childValue = currentValueObj[child.name];
1875
+ if (/^\d+$/.test(child.name) && childValue === void 0) {
1876
+ devLog.warn("Skipping numeric child name in object field - field does not exist (likely parsing error)", {
1877
+ path: path.join("."),
1878
+ childName: child.name,
1879
+ availableKeys: Object.keys(currentValueObj),
1880
+ childType: child.attributes.type
1881
+ });
1882
+ continue;
1883
+ }
1884
+ applyFieldChanges(doc, [...path, child.name], child);
1885
+ }
1886
+ } else
1887
+ devLog.warn("Object field type but value is not an object", {
1888
+ path: path.join("."),
1889
+ actualType: Array.isArray(currentValue) ? "array" : typeof currentValue
1890
+ });
1854
1891
  return;
1855
1892
  }
1856
1893
  if (node.children.some((c) => c.type === "block")) {