gt-sanity 3.1.4 → 3.1.6

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.cjs CHANGED
@@ -475,14 +475,24 @@ async function patchI18nDoc(sourceDocumentId, i18nDocId, sourceDocument, mergedD
475
475
  pluginConfig.getIgnoreFields(),
476
476
  pluginConfig.getSkipFields()
477
477
  ), dedupeFields = pluginConfig.getDedupeFields();
478
- deleteMatchingFields(sourceDocumentId, appliedDocument, dedupeFields), existingDocument && forEachMatchingField(
478
+ if (deleteMatchingFields(sourceDocumentId, appliedDocument, dedupeFields), existingDocument && forEachMatchingField(
479
479
  sourceDocumentId,
480
480
  existingDocument,
481
481
  dedupeFields,
482
482
  (result) => {
483
483
  JSONPointer__default.default.set(appliedDocument, result.pointer, result.value);
484
484
  }
485
- ), await client.patch(i18nDocId, { set: appliedDocument }).commit();
485
+ ), i18nDocId.startsWith("drafts.")) {
486
+ await client.patch(i18nDocId, { set: appliedDocument }).commit();
487
+ return;
488
+ }
489
+ const seed = existingDocument ?? await client.getDocument(i18nDocId);
490
+ if (!seed) {
491
+ await client.patch(i18nDocId, { set: appliedDocument }).commit();
492
+ return;
493
+ }
494
+ const draftId = `drafts.${getPublishedId(i18nDocId)}`;
495
+ await client.transaction().createIfNotExists({ ...seed, _id: draftId }).patch(draftId, (patch) => patch.set(appliedDocument)).commit();
486
496
  }
487
497
  const documentLevelPatch = async (docInfo, translatedFields, localeId, client, languageField = "language", mergeWithTargetLocale = !1) => {
488
498
  const baseLanguage = pluginConfig.getSourceLocale();
@@ -2655,7 +2665,7 @@ const useTranslations = () => {
2655
2665
  ] }) })
2656
2666
  }
2657
2667
  ) : null;
2658
- var version = "3.1.4";
2668
+ var version = "3.1.6";
2659
2669
  function buildDebugInfo({
2660
2670
  secrets,
2661
2671
  preferences,