@braze/sanity-plugin-ai-translation 0.2.57 → 0.2.58
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 +17 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1539,7 +1539,12 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
|
|
|
1539
1539
|
cleanedLength: cleanedText.length,
|
|
1540
1540
|
preview: cleanedText.substring(0, 500)
|
|
1541
1541
|
});
|
|
1542
|
-
const parsed = parseReviewFormat(cleanedText, originalDoc)
|
|
1542
|
+
const parsed = parseReviewFormat(cleanedText, originalDoc);
|
|
1543
|
+
devLog.debug("Parsed response structure", {
|
|
1544
|
+
rootNodeCount: parsed.length,
|
|
1545
|
+
rootNodeNames: parsed.map((n) => n.type === "field" && n.name ? n.name : "unknown")
|
|
1546
|
+
});
|
|
1547
|
+
const result = cloneDeep(originalDoc);
|
|
1543
1548
|
return applyTextChanges(result, parsed), result;
|
|
1544
1549
|
}, preprocessResponse = (text) => {
|
|
1545
1550
|
const originalLength = text.length;
|
|
@@ -1691,10 +1696,20 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
|
|
|
1691
1696
|
attrs[match[1]] = unescapeXml(match[2]), match = attrRegex.exec(attrStr);
|
|
1692
1697
|
return attrs;
|
|
1693
1698
|
}, unescapeXml = (str) => str.replace(/'/g, "'").replace(/"/g, '"').replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&"), applyTextChanges = (doc, parsedNodes) => {
|
|
1699
|
+
devLog.debug("Applying text changes from parsed nodes", {
|
|
1700
|
+
nodeCount: parsedNodes.length,
|
|
1701
|
+
nodeNames: parsedNodes.map((n) => n.type === "field" && n.name ? n.name : "unknown")
|
|
1702
|
+
});
|
|
1694
1703
|
for (const node of parsedNodes)
|
|
1695
1704
|
if (node.type === "field" && node.name) {
|
|
1696
|
-
const path = [node.name];
|
|
1705
|
+
const path = [node.name], beforeValue = get(doc, path);
|
|
1697
1706
|
applyFieldChanges(doc, path, node);
|
|
1707
|
+
const afterValue = get(doc, path);
|
|
1708
|
+
beforeValue !== afterValue && devLog.debug("Field updated during deserialization", {
|
|
1709
|
+
path: path.join("."),
|
|
1710
|
+
before: typeof beforeValue == "string" ? beforeValue.substring(0, 50) : beforeValue,
|
|
1711
|
+
after: typeof afterValue == "string" ? afterValue.substring(0, 50) : afterValue
|
|
1712
|
+
});
|
|
1698
1713
|
}
|
|
1699
1714
|
}, applyFieldChanges = (doc, path, node) => {
|
|
1700
1715
|
const nodeType = node.attributes.type;
|