@braze/sanity-plugin-ai-translation 0.2.24 → 0.2.26

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
@@ -1714,7 +1714,8 @@ const fetchTranslationPrompts = async ({
1714
1714
  const refIds = refs.map((r) => getPublishedId(r.value)), translations = await client.fetch(
1715
1715
  `*[_type == $translationMetadataSchemaType && array::intersects(translations[].value._ref, $refIds)] {
1716
1716
  "sourceId": translations[_key == $sourceLanguage][0].value._ref,
1717
- "targetId": translations[_key == $targetLanguage][0].value._ref
1717
+ "targetId": translations[_key == $targetLanguage][0].value._ref,
1718
+ "targetType": translations[_key == $sourceLanguage][0].value -> _type
1718
1719
  }`,
1719
1720
  {
1720
1721
  translationMetadataSchemaType: TRANSLATION_METADATA_TYPE,
@@ -1729,7 +1730,11 @@ const fetchTranslationPrompts = async ({
1729
1730
  let hasChanges = !1;
1730
1731
  for (const ref of refs) {
1731
1732
  const sourceId = getPublishedId(ref.value), newId = translationMap.get(sourceId);
1732
- newId && (patch.set({ [pathToString(ref.path)]: getPublishedId(newId) }), hasChanges = !0);
1733
+ newId && (patch.set({ [pathToString(ref.path)]: getPublishedId(newId) }), patch.set({
1734
+ [`${pathToString(ref.path.slice(0, -1))}._strengthenOnPublish`]: {
1735
+ type: translations.find((t) => t.targetId === getPublishedId(newId))?.targetType || void 0
1736
+ }
1737
+ }), hasChanges = !0);
1733
1738
  }
1734
1739
  hasChanges && (await patch.commit(), devLog.info("Updated references in batch", {
1735
1740
  documentId,
@@ -2227,7 +2232,9 @@ const fetchTranslationPrompts = async ({
2227
2232
  ],
2228
2233
  model: openaiConfig.model,
2229
2234
  reasoningEffort: openaiConfig.reasoningEffort
2230
- }), result = deserializeDocument(sourceDocument, response.content), validation = validateStructureIntegrity(sourceDocument, result);
2235
+ }), result = deserializeDocument(sourceDocument, response.content);
2236
+ result[languageFieldName] = targetLanguage;
2237
+ const validation = validateStructureIntegrity(sourceDocument, result);
2231
2238
  if (!validation.valid) {
2232
2239
  devLog.error("Structure validation failed", {
2233
2240
  ...logContext,