@braze/sanity-plugin-ai-translation 0.2.37 → 0.2.39
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 +6 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2592,7 +2592,6 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
|
|
|
2592
2592
|
}, getOpenAITranslation = async ({
|
|
2593
2593
|
dispatch,
|
|
2594
2594
|
sourceDocument,
|
|
2595
|
-
originalSourceDocument,
|
|
2596
2595
|
languageFieldName,
|
|
2597
2596
|
translationPrompts,
|
|
2598
2597
|
targetLanguage,
|
|
@@ -2633,9 +2632,9 @@ const globalTransformRegistry = new TransformRegistry(), callGPT5 = async (apiKe
|
|
|
2633
2632
|
responseLength: response.content.length,
|
|
2634
2633
|
responsePreview: response.content.substring(0, 500)
|
|
2635
2634
|
});
|
|
2636
|
-
const
|
|
2635
|
+
const result = deserializeDocument(sourceDocument, response.content);
|
|
2637
2636
|
result[languageFieldName] = targetLanguage;
|
|
2638
|
-
const validation = validateStructureIntegrity(
|
|
2637
|
+
const validation = validateStructureIntegrity(sourceDocument, result);
|
|
2639
2638
|
if (!validation.valid) {
|
|
2640
2639
|
devLog.error("Structure validation failed", {
|
|
2641
2640
|
...logContext,
|
|
@@ -2925,7 +2924,6 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
|
|
|
2925
2924
|
setJobStatus(dispatch, sourceDocument._id, targetLanguage, "translating_with_openai"), translatedDoc = await getOpenAITranslation({
|
|
2926
2925
|
dispatch,
|
|
2927
2926
|
sourceDocument: transformedDocument,
|
|
2928
|
-
originalSourceDocument: sourceDocument,
|
|
2929
2927
|
targetLanguage,
|
|
2930
2928
|
languageFieldName,
|
|
2931
2929
|
translationPrompts,
|
|
@@ -2949,15 +2947,16 @@ ${protectedPhrases.join(", ")}`, buildStyleGuideSection = (globalPrompt, localeP
|
|
|
2949
2947
|
originalStructure,
|
|
2950
2948
|
registry: globalTransformRegistry,
|
|
2951
2949
|
schemaType: sourceDocument._type
|
|
2952
|
-
});
|
|
2953
|
-
devLog.info("Before restoring excluded fields", {
|
|
2950
|
+
}), excludedValuesToRestore = { ...excludedValues };
|
|
2951
|
+
delete excludedValuesToRestore[languageFieldName], devLog.info("Before restoring excluded fields", {
|
|
2954
2952
|
documentId: sourceDocument._id,
|
|
2955
2953
|
excludedFieldCount: Object.keys(excludedValues).length,
|
|
2956
2954
|
excludedValuesKeys: Object.keys(excludedValues),
|
|
2955
|
+
languageFieldExcluded: languageFieldName in excludedValues,
|
|
2957
2956
|
transformedResultHasTitle: "title" in transformedResult,
|
|
2958
2957
|
transformedResultTitle: transformedResult.title
|
|
2959
2958
|
});
|
|
2960
|
-
const finalDoc = restoreExcludedFields(transformedResult,
|
|
2959
|
+
const finalDoc = restoreExcludedFields(transformedResult, excludedValuesToRestore);
|
|
2961
2960
|
devLog.info("After restoring excluded fields", {
|
|
2962
2961
|
documentId: sourceDocument._id,
|
|
2963
2962
|
finalDocHasTitle: "title" in finalDoc,
|