@braze/sanity-plugin-ai-translation 0.2.36 → 0.2.37
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 +5 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2592,6 +2592,7 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
|
|
|
2592
2592
|
}, getOpenAITranslation = async ({
|
|
2593
2593
|
dispatch,
|
|
2594
2594
|
sourceDocument,
|
|
2595
|
+
originalSourceDocument,
|
|
2595
2596
|
languageFieldName,
|
|
2596
2597
|
translationPrompts,
|
|
2597
2598
|
targetLanguage,
|
|
@@ -2632,9 +2633,9 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
|
|
|
2632
2633
|
responseLength: response.content.length,
|
|
2633
2634
|
responsePreview: response.content.substring(0, 500)
|
|
2634
2635
|
});
|
|
2635
|
-
const result = deserializeDocument(
|
|
2636
|
+
const baseDocument = originalSourceDocument || sourceDocument, result = deserializeDocument(baseDocument, response.content);
|
|
2636
2637
|
result[languageFieldName] = targetLanguage;
|
|
2637
|
-
const validation = validateStructureIntegrity(
|
|
2638
|
+
const validation = validateStructureIntegrity(baseDocument, result);
|
|
2638
2639
|
if (!validation.valid) {
|
|
2639
2640
|
devLog.error("Structure validation failed", {
|
|
2640
2641
|
...logContext,
|
|
@@ -2924,6 +2925,7 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
|
|
|
2924
2925
|
setJobStatus(dispatch, sourceDocument._id, targetLanguage, "translating_with_openai"), translatedDoc = await getOpenAITranslation({
|
|
2925
2926
|
dispatch,
|
|
2926
2927
|
sourceDocument: transformedDocument,
|
|
2928
|
+
originalSourceDocument: sourceDocument,
|
|
2927
2929
|
targetLanguage,
|
|
2928
2930
|
languageFieldName,
|
|
2929
2931
|
translationPrompts,
|
|
@@ -3623,7 +3625,7 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
|
|
|
3623
3625
|
/* @__PURE__ */ jsxs(Code, { size: 1, children: [
|
|
3624
3626
|
job._type,
|
|
3625
3627
|
" \u2014 ",
|
|
3626
|
-
job._id
|
|
3628
|
+
job._id?.slice(-6) || "unknown"
|
|
3627
3629
|
] }),
|
|
3628
3630
|
!["completed", "skipped", "error"].includes(job.status) && /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: getStatusLabel(job.status) }),
|
|
3629
3631
|
job.status === "completed" && job.tokensUsed ? /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|