gt-sanity 1.0.11 → 1.1.1

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
@@ -643,13 +643,17 @@ async function initProject(uploadResult, options, secrets) {
643
643
  const { setupJobId } = setupResult, start = Date.now(), pollInterval = 2e3;
644
644
  let setupCompleted = !1, setupFailedMessage = null;
645
645
  for (; ; ) {
646
- const status = await gt.checkSetupStatus(setupJobId);
647
- if (status.status === "completed") {
646
+ const status = await gt.checkJobStatus([setupJobId]);
647
+ if (!status[0]) {
648
+ setupFailedMessage = "Unknown error";
649
+ break;
650
+ }
651
+ if (status[0].status === "completed") {
648
652
  setupCompleted = !0;
649
653
  break;
650
654
  }
651
- if (status.status === "failed") {
652
- setupFailedMessage = status.error?.message || "Unknown error";
655
+ if (status[0].status === "failed") {
656
+ setupFailedMessage = status[0].error?.message || "Unknown error";
653
657
  break;
654
658
  }
655
659
  if (Date.now() - start > setupTimeoutMs) {
@@ -671,22 +675,20 @@ async function createJobs(uploadResult, localeIds, secrets) {
671
675
  async function downloadTranslations(files, secrets, maxRetries = 3, retryDelay = 1e3) {
672
676
  overrideConfig(secrets);
673
677
  let retries = 0;
674
- const fileIds = files.map((file) => file.translationId), map = new Map(files.map((file) => [file.translationId, file])), result = [];
675
678
  for (; retries <= maxRetries; )
676
679
  try {
677
- const downloadedFiles = (await gt.downloadFileBatch(fileIds)).files || [];
678
- for (const file of downloadedFiles) {
679
- const documentData = map.get(file.id);
680
- documentData && result.push({
681
- docData: documentData,
682
- data: file.data
683
- });
684
- }
685
- return result;
680
+ return (await gt.downloadFileBatch(
681
+ files.map((file) => ({
682
+ fileId: file.fileId,
683
+ branchId: file.branchId,
684
+ versionId: file.versionId,
685
+ locale: file.locale
686
+ }))
687
+ )).files || [];
686
688
  } catch {
687
689
  retries++, await new Promise((resolve) => setTimeout(resolve, retryDelay));
688
690
  }
689
- return result;
691
+ return [];
690
692
  }
691
693
  async function checkTranslationStatus(fileQueryData, downloadStatus, secrets) {
692
694
  overrideConfig(secrets);
@@ -694,8 +696,10 @@ async function checkTranslationStatus(fileQueryData, downloadStatus, secrets) {
694
696
  const currentQueryData = fileQueryData.filter(
695
697
  (item) => !downloadStatus.downloaded.has(`${item.fileId}:${item.locale}`) && !downloadStatus.failed.has(`${item.fileId}:${item.locale}`) && !downloadStatus.skipped.has(`${item.fileId}:${item.locale}`)
696
698
  );
697
- return currentQueryData.length === 0 ? !0 : ((await gt.checkFileTranslations(currentQueryData)).translations || []).filter(
698
- (translation) => translation.isReady && translation.fileId
699
+ return currentQueryData.length === 0 ? !0 : ((await gt.queryFileData({
700
+ translatedFiles: currentQueryData
701
+ })).translatedFiles || []).filter(
702
+ (translation) => translation.completedAt
699
703
  );
700
704
  } catch (error) {
701
705
  return console.error("Error checking translation status", error), [];
@@ -1013,20 +1017,15 @@ async function processImportBatch(items, options = {}) {
1013
1017
  successfulImports
1014
1018
  };
1015
1019
  }
1016
- async function getReadyFilesForImport(documents, translationStatuses, options = {}) {
1020
+ async function getReadyFilesForImport(translationStatuses, options = {}) {
1017
1021
  const { filterReadyFiles = () => !0 } = options, readyFiles = [];
1018
1022
  for (const [key, status] of translationStatuses.entries())
1019
- if (status.isReady && status.translationId && filterReadyFiles(key, status)) {
1020
- const [documentId, locale] = key.split(":"), document2 = documents.find(
1021
- (doc) => (doc._id?.replace("drafts.", "") || doc._id) === documentId
1022
- );
1023
- document2 && readyFiles.push({
1024
- documentId,
1025
- versionId: document2._rev,
1026
- translationId: status.translationId,
1027
- locale
1028
- });
1029
- }
1023
+ status.isReady && filterReadyFiles(key, status) && readyFiles.push({
1024
+ fileId: status.fileData.fileId,
1025
+ versionId: status.fileData.versionId,
1026
+ branchId: status.fileData.branchId,
1027
+ locale: status.fileData.locale
1028
+ });
1030
1029
  return readyFiles;
1031
1030
  }
1032
1031
  async function importTranslations(readyFiles, secrets, translationContext, options = {}) {
@@ -1034,13 +1033,13 @@ async function importTranslations(readyFiles, secrets, translationContext, optio
1034
1033
  return { successCount: 0, failureCount: 0, successfulImports: [] };
1035
1034
  const importItems = (await downloadTranslations(readyFiles, secrets)).map((file) => ({
1036
1035
  docInfo: {
1037
- documentId: file.docData.documentId,
1038
- versionId: file.docData.versionId
1036
+ documentId: file.fileId,
1037
+ versionId: file.versionId
1039
1038
  },
1040
- locale: file.docData.locale,
1039
+ locale: file.locale,
1041
1040
  data: file.data,
1042
1041
  translationContext,
1043
- key: `${file.docData.documentId}:${file.docData.locale}`
1042
+ key: `${file.branchId}:${file.fileId}:${file.versionId}:${file.locale}`
1044
1043
  })), result = await processImportBatch(importItems, {
1045
1044
  onProgress: options.onProgress,
1046
1045
  onItemSuccess: (item, key) => {
@@ -1095,7 +1094,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1095
1094
  children,
1096
1095
  singleDocument
1097
1096
  }) => {
1098
- const [isBusy, setIsBusy] = o.useState(!1), [documents, setDocuments] = o.useState([]), [locales, setLocales] = o.useState([]), [autoRefresh, setAutoRefresh] = o.useState(!1), [loadingDocuments, setLoadingDocuments] = o.useState(!1), [importProgress, setImportProgress] = o.useState({
1097
+ const [isBusy, setIsBusy] = o.useState(!1), [documents, setDocuments] = o.useState([]), [locales, setLocales] = o.useState([]), [autoRefresh, setAutoRefresh] = o.useState(!1), [autoImport, setAutoImport] = o.useState(!1), [autoPatchReferences, setAutoPatchReferences] = o.useState(!1), [autoPublish, setAutoPublish] = o.useState(!1), [loadingDocuments, setLoadingDocuments] = o.useState(!1), [importProgress, setImportProgress] = o.useState({
1099
1098
  current: 0,
1100
1099
  total: 0,
1101
1100
  isImporting: !1
@@ -1109,7 +1108,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1109
1108
  skipped: /* @__PURE__ */ new Set()
1110
1109
  }), [translationStatuses, setTranslationStatuses] = o.useState(/* @__PURE__ */ new Map()), [isRefreshing, setIsRefreshing] = o.useState(!1), client = useClient(), schema2 = sanity.useSchema(), translationContext = { client, schema: schema2 }, toast = ui.useToast(), { loading: loadingSecrets, secrets } = useSecrets(
1111
1110
  pluginConfig.getSecretsNamespace()
1112
- ), fetchDocuments = o.useCallback(async () => {
1111
+ ), [branchId, setBranchId] = o.useState(void 0), fetchDocuments = o.useCallback(async () => {
1113
1112
  setLoadingDocuments(!0);
1114
1113
  try {
1115
1114
  if (singleDocument) {
@@ -1207,13 +1206,10 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1207
1206
  }
1208
1207
  }
1209
1208
  }, [secrets, documents, locales, schema2]), handleImportAll = o.useCallback(async () => {
1210
- if (!(!secrets || documents.length === 0)) {
1209
+ if (!(!secrets || documents.length === 0 || !branchId)) {
1211
1210
  setIsBusy(!0);
1212
1211
  try {
1213
- const readyFiles = await getReadyFilesForImport(
1214
- documents,
1215
- translationStatuses
1216
- );
1212
+ const readyFiles = await getReadyFilesForImport(translationStatuses);
1217
1213
  if (readyFiles.length === 0) {
1218
1214
  toast.push({
1219
1215
  title: "No ready translations to import",
@@ -1270,13 +1266,15 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1270
1266
  documents,
1271
1267
  translationStatuses,
1272
1268
  downloadStatus,
1273
- translationContext
1274
- ]), getMissingTranslations = o.useCallback(
1275
- async (documentIds, localeIds) => {
1269
+ translationContext,
1270
+ branchId
1271
+ ]), getExistingTranslations = o.useCallback(
1272
+ async (documentIds, localeIds, branchId2) => {
1276
1273
  const sourceLocale = pluginConfig.getSourceLocale(), existingMetadata = await client.fetch(`*[
1277
1274
  _type == 'translation.metadata' &&
1278
1275
  translations[_key == $sourceLocale][0].value._ref in $documentIds
1279
1276
  ] {
1277
+ _rev,
1280
1278
  'sourceDocId': translations[_key == $sourceLocale][0].value._ref,
1281
1279
  'existingTranslations': translations[_key in $localeIds]._key
1282
1280
  }`, {
@@ -1284,40 +1282,28 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1284
1282
  documentIds,
1285
1283
  localeIds
1286
1284
  }), existing = /* @__PURE__ */ new Set();
1287
- existingMetadata.forEach((metadata) => {
1285
+ return existingMetadata.forEach((metadata) => {
1288
1286
  metadata.existingTranslations?.forEach((localeId) => {
1289
- localeId !== sourceLocale && existing.add(`${metadata.sourceDocId}:${localeId}`);
1290
- });
1291
- });
1292
- const missing = /* @__PURE__ */ new Set();
1293
- return documentIds.forEach((docId) => {
1294
- localeIds.forEach((localeId) => {
1295
- if (localeId !== sourceLocale) {
1296
- const key = `${docId}:${localeId}`;
1297
- existing.has(key) || missing.add(key);
1298
- }
1287
+ localeId !== sourceLocale && existing.add(
1288
+ `${branchId2}:${metadata.sourceDocId}:${metadata._rev}:${localeId}`
1289
+ );
1299
1290
  });
1300
- }), missing;
1291
+ }), existing;
1301
1292
  },
1302
1293
  [client]
1303
1294
  ), handleImportMissing = o.useCallback(async () => {
1304
- if (!(!secrets || documents.length === 0)) {
1295
+ if (!(!secrets || documents.length === 0 || !branchId)) {
1305
1296
  setIsBusy(!0);
1306
1297
  try {
1307
1298
  const availableLocaleIds = locales.filter((locale) => locale.enabled !== !1).map((locale) => locale.localeId), documentIds = documents.map(
1308
1299
  (doc) => doc._id?.replace("drafts.", "") || doc._id
1309
- ), missingTranslations = await getMissingTranslations(
1300
+ ), existingTranslations2 = await getExistingTranslations(
1310
1301
  documentIds,
1311
- availableLocaleIds
1312
- );
1313
- console.log("missingTranslations", missingTranslations);
1314
- const readyFiles = await getReadyFilesForImport(
1315
- documents,
1316
- translationStatuses,
1317
- {
1318
- filterReadyFiles: (key) => missingTranslations.has(key)
1319
- }
1320
- );
1302
+ availableLocaleIds,
1303
+ branchId
1304
+ ), readyFiles = await getReadyFilesForImport(translationStatuses, {
1305
+ filterReadyFiles: (key) => !existingTranslations2.has(key)
1306
+ });
1321
1307
  if (readyFiles.length === 0) {
1322
1308
  toast.push({
1323
1309
  title: "No missing translations to import",
@@ -1376,9 +1362,20 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1376
1362
  translationStatuses,
1377
1363
  downloadStatus,
1378
1364
  translationContext,
1379
- getMissingTranslations
1380
- ]), handleRefreshAll = o.useCallback(async () => {
1381
- if (!(!secrets || documents.length === 0)) {
1365
+ getExistingTranslations,
1366
+ branchId
1367
+ ]), handleGetBranchId = o.useCallback(
1368
+ async (secrets2) => {
1369
+ overrideConfig(secrets2);
1370
+ const defaultBranch = await gt.createBranch({
1371
+ branchName: "main",
1372
+ defaultBranch: !0
1373
+ });
1374
+ setBranchId(defaultBranch.branch.id);
1375
+ },
1376
+ [secrets]
1377
+ ), handleRefreshAll = o.useCallback(async () => {
1378
+ if (!(!secrets || documents.length === 0 || !branchId)) {
1382
1379
  setIsRefreshing(!0);
1383
1380
  try {
1384
1381
  const availableLocaleIds = locales.filter((locale) => locale.enabled !== !1).map((locale) => locale.localeId), fileQueryData = [];
@@ -1388,6 +1385,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1388
1385
  fileQueryData.push({
1389
1386
  versionId: doc._rev,
1390
1387
  fileId: documentId,
1388
+ branchId,
1391
1389
  locale: localeId
1392
1390
  });
1393
1391
  }
@@ -1400,16 +1398,21 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1400
1398
  const newStatuses = /* @__PURE__ */ new Map();
1401
1399
  for (const doc of documents)
1402
1400
  for (const localeId of availableLocaleIds) {
1403
- const key = `${doc._id?.replace("drafts.", "") || doc._id}:${localeId}`;
1401
+ const documentId = doc._id?.replace("drafts.", "") || doc._id, versionId = doc._rev, key = `${branchId}:${documentId}:${versionId}:${localeId}`;
1404
1402
  newStatuses.set(key, { progress: 0, isReady: !1 });
1405
1403
  }
1406
1404
  if (Array.isArray(readyTranslations))
1407
1405
  for (const translation of readyTranslations) {
1408
- const key = `${translation.fileId}:${translation.locale}`;
1406
+ const key = `${branchId}:${translation.fileId}:${translation.versionId}:${translation.locale}`;
1409
1407
  newStatuses.set(key, {
1410
1408
  progress: 100,
1411
1409
  isReady: !0,
1412
- translationId: translation.id
1410
+ fileData: {
1411
+ versionId: translation.versionId,
1412
+ fileId: translation.fileId,
1413
+ branchId: translation.branchId,
1414
+ locale: translation.locale
1415
+ }
1413
1416
  });
1414
1417
  }
1415
1418
  return newStatuses;
@@ -1428,11 +1431,11 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1428
1431
  setIsRefreshing(!1);
1429
1432
  }
1430
1433
  }
1431
- }, [secrets, documents, locales]), handleImportDocument = o.useCallback(
1432
- async (documentId, localeId) => {
1434
+ }, [secrets, documents, locales, branchId]), handleImportDocument = o.useCallback(
1435
+ async (documentId, versionId, localeId) => {
1433
1436
  if (!secrets) return;
1434
- const key = `${documentId}:${localeId}`, status = translationStatuses.get(key);
1435
- if (!status?.isReady || !status.translationId) {
1437
+ const key = `${branchId}:${documentId}:${versionId}:${localeId}`, status = translationStatuses.get(key);
1438
+ if (!status?.isReady || !status.fileData) {
1436
1439
  toast.push({
1437
1440
  title: `Translation not ready for ${documentId} (${localeId})`,
1438
1441
  status: "warning",
@@ -1455,10 +1458,10 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1455
1458
  const downloadedFiles = await downloadTranslations(
1456
1459
  [
1457
1460
  {
1458
- documentId,
1459
- versionId: document2._rev,
1460
- translationId: status.translationId,
1461
- locale: localeId
1461
+ fileId: status.fileData.fileId,
1462
+ branchId: status.fileData.branchId,
1463
+ versionId: status.fileData.versionId,
1464
+ locale: status.fileData.locale
1462
1465
  }
1463
1466
  ],
1464
1467
  secrets
@@ -1504,7 +1507,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1504
1507
  });
1505
1508
  }
1506
1509
  },
1507
- [secrets, documents, translationContext, translationStatuses]
1510
+ [secrets, documents, translationContext, translationStatuses, branchId]
1508
1511
  ), handlePatchDocumentReferences = o.useCallback(async () => {
1509
1512
  if (!secrets || documents.length === 0) return 0;
1510
1513
  setIsBusy(!0);
@@ -1579,7 +1582,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1579
1582
  } finally {
1580
1583
  setIsBusy(!1), setImportProgress({ current: 0, total: 0, isImporting: !1 });
1581
1584
  }
1582
- }, [secrets, documents, locales, client]), handlePublishAllTranslations = o.useCallback(async () => {
1585
+ }, [secrets, documents, locales, client, branchId]), handlePublishAllTranslations = o.useCallback(async () => {
1583
1586
  if (!secrets || documents.length === 0) return 0;
1584
1587
  setIsBusy(!0);
1585
1588
  try {
@@ -1631,7 +1634,7 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1631
1634
  } finally {
1632
1635
  setIsBusy(!1);
1633
1636
  }
1634
- }, [secrets, documents, client]);
1637
+ }, [secrets, documents, client, branchId]);
1635
1638
  o.useEffect(() => {
1636
1639
  fetchDocuments();
1637
1640
  }, [fetchDocuments]), o.useEffect(() => {
@@ -1648,13 +1651,16 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1648
1651
  return () => clearInterval(interval);
1649
1652
  }, [autoRefresh, documents.length, secrets, handleRefreshAll]), o.useEffect(() => {
1650
1653
  setImportedTranslations(new Set(downloadStatus.downloaded));
1651
- }, [downloadStatus.downloaded]);
1654
+ }, [downloadStatus.downloaded]), secrets && handleGetBranchId(secrets);
1652
1655
  const contextValue = {
1653
1656
  // State
1654
1657
  isBusy,
1655
1658
  documents,
1656
1659
  locales,
1657
1660
  autoRefresh,
1661
+ autoImport,
1662
+ autoPatchReferences,
1663
+ autoPublish,
1658
1664
  loadingDocuments,
1659
1665
  importProgress,
1660
1666
  importedTranslations,
@@ -1664,9 +1670,13 @@ const getLocales = async (secrets) => pluginConfig.getLocales().map((locale) =>
1664
1670
  isRefreshing,
1665
1671
  loadingSecrets,
1666
1672
  secrets,
1673
+ branchId,
1667
1674
  // Actions
1668
1675
  setLocales,
1669
1676
  setAutoRefresh,
1677
+ setAutoImport,
1678
+ setAutoPatchReferences,
1679
+ setAutoPublish,
1670
1680
  handleTranslateAll,
1671
1681
  handleImportAll,
1672
1682
  handleImportMissing,
@@ -2930,6 +2940,7 @@ const WrapText = dt(ui.Box)`
2930
2940
  documents,
2931
2941
  locales,
2932
2942
  translationStatuses,
2943
+ branchId,
2933
2944
  isBusy,
2934
2945
  handleTranslateAll,
2935
2946
  handleImportDocument,
@@ -2938,8 +2949,16 @@ const WrapText = dt(ui.Box)`
2938
2949
  importedTranslations,
2939
2950
  setLocales,
2940
2951
  handlePatchDocumentReferences,
2941
- handlePublishAllTranslations
2942
- } = useTranslations(), [autoImport, setAutoImport] = o.useState(!1), [isImporting, setIsImporting] = o.useState(!1), [autoRefresh, setAutoRefresh] = o.useState(!0), [autoPatchReferences, setAutoPatchReferences] = o.useState(!0), [autoPublish, setAutoPublish] = o.useState(!0), [isPublishing, setIsPublishing] = o.useState(!1), toast = ui.useToast(), document2 = documents[0], currentDocumentLanguage = o.useMemo(() => {
2952
+ handlePublishAllTranslations,
2953
+ autoRefresh,
2954
+ setAutoRefresh,
2955
+ autoImport,
2956
+ setAutoImport,
2957
+ autoPatchReferences,
2958
+ setAutoPatchReferences,
2959
+ autoPublish,
2960
+ setAutoPublish
2961
+ } = useTranslations(), [isImporting, setIsImporting] = o.useState(!1), [isPublishing, setIsPublishing] = o.useState(!1), toast = ui.useToast(), document2 = documents[0], currentDocumentLanguage = o.useMemo(() => {
2943
2962
  if (!document2) return null;
2944
2963
  const languageField = pluginConfig.getLanguageField();
2945
2964
  return document2[languageField] || pluginConfig.getSourceLocale();
@@ -2953,7 +2972,7 @@ const WrapText = dt(ui.Box)`
2953
2972
  const { autoOnly = !1 } = options;
2954
2973
  if (isImporting || !documentId || autoOnly && !autoImport) return;
2955
2974
  const readyTranslations = availableLocales.filter((locale) => {
2956
- const key = `${documentId}:${locale.localeId}`;
2975
+ const key = `${branchId}:${documentId}:${document2._rev}:${locale.localeId}`;
2957
2976
  return translationStatuses.get(key)?.isReady && !importedTranslations.has(key);
2958
2977
  });
2959
2978
  if (readyTranslations.length !== 0) {
@@ -2961,7 +2980,7 @@ const WrapText = dt(ui.Box)`
2961
2980
  try {
2962
2981
  await Promise.all(
2963
2982
  readyTranslations.map(
2964
- (locale) => handleImportDocument(documentId, locale.localeId)
2983
+ (locale) => handleImportDocument(documentId, document2._rev, locale.localeId)
2965
2984
  )
2966
2985
  ), autoPatchReferences && await handlePatchDocumentReferences(), autoPublish && await handlePublishAllTranslations();
2967
2986
  } finally {
@@ -2987,20 +3006,8 @@ const WrapText = dt(ui.Box)`
2987
3006
  o.useEffect(() => {
2988
3007
  handleImportTranslations({ autoOnly: !0 });
2989
3008
  }, [handleImportTranslations]), o.useEffect(() => {
2990
- if (!autoRefresh || !documentId || availableLocales.length === 0) return;
2991
- const interval = setInterval(async () => {
2992
- await handleRefreshAll(), await handleImportTranslations({ autoOnly: !0 });
2993
- }, 1e4);
2994
- return () => clearInterval(interval);
2995
- }, [
2996
- autoRefresh,
2997
- documentId,
2998
- availableLocales.length,
2999
- handleRefreshAll,
3000
- handleImportTranslations
3001
- ]), o.useEffect(() => {
3002
- (async () => (await handleRefreshAll(), await handleImportTranslations({ autoOnly: !0 })))();
3003
- }, []);
3009
+ setAutoRefresh(!0), setAutoPatchReferences(!0), setAutoPublish(!0);
3010
+ }, [setAutoRefresh, setAutoPatchReferences, setAutoPublish]);
3004
3011
  const toggleLocale = o.useCallback(
3005
3012
  (localeId, shouldEnable) => {
3006
3013
  const updatedLocales = locales.map(
@@ -3080,13 +3087,13 @@ const WrapText = dt(ui.Box)`
3080
3087
  padding: 2,
3081
3088
  text: "Refresh Status",
3082
3089
  onClick: handleRefreshAll,
3083
- disabled: isRefreshing
3090
+ disabled: isRefreshing || isBusy
3084
3091
  }
3085
3092
  )
3086
3093
  ] })
3087
3094
  ] }),
3088
3095
  /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: availableLocales.map((locale) => {
3089
- const key = `${documentId}:${locale.localeId}`, status = translationStatuses.get(key), progress = status?.progress || 0, isImported = importedTranslations.has(key);
3096
+ const key = `${branchId}:${documentId}:${document2._rev}:${locale.localeId}`, status = translationStatuses.get(key), progress = status?.progress || 0, isImported = importedTranslations.has(key);
3090
3097
  return /* @__PURE__ */ jsxRuntime.jsx(
3091
3098
  LanguageStatus,
3092
3099
  {
@@ -3094,7 +3101,11 @@ const WrapText = dt(ui.Box)`
3094
3101
  progress,
3095
3102
  isImported,
3096
3103
  importFile: async () => {
3097
- !isImported && status?.isReady && await handleImportDocument(documentId, locale.localeId);
3104
+ !isImported && status?.isReady && await handleImportDocument(
3105
+ documentId,
3106
+ document2._rev,
3107
+ locale.localeId
3108
+ );
3098
3109
  }
3099
3110
  },
3100
3111
  key
@@ -3112,7 +3123,7 @@ const WrapText = dt(ui.Box)`
3112
3123
  text: isImporting ? "Importing..." : "Import All",
3113
3124
  icon: icons.DownloadIcon,
3114
3125
  disabled: isImporting || availableLocales.every((locale) => {
3115
- const key = `${documentId}:${locale.localeId}`;
3126
+ const key = `${branchId}:${documentId}:${document2._rev}:${locale.localeId}`;
3116
3127
  return !translationStatuses.get(key)?.isReady || importedTranslations.has(key);
3117
3128
  }),
3118
3129
  style: { minWidth: "180px" }
@@ -3134,12 +3145,12 @@ const WrapText = dt(ui.Box)`
3134
3145
  "Imported",
3135
3146
  " ",
3136
3147
  availableLocales.filter((locale) => {
3137
- const key = `${documentId}:${locale.localeId}`;
3148
+ const key = `${branchId}:${documentId}:${document2._rev}:${locale.localeId}`;
3138
3149
  return importedTranslations.has(key);
3139
3150
  }).length,
3140
3151
  "/",
3141
3152
  availableLocales.filter((locale) => {
3142
- const key = `${documentId}:${locale.localeId}`;
3153
+ const key = `${branchId}:${documentId}:${document2._rev}:${locale.localeId}`;
3143
3154
  return translationStatuses.get(key)?.isReady;
3144
3155
  }).length
3145
3156
  ] })
@@ -3251,7 +3262,8 @@ const WrapText = dt(ui.Box)`
3251
3262
  translationStatuses,
3252
3263
  downloadStatus,
3253
3264
  importedTranslations,
3254
- handleImportDocument
3265
+ handleImportDocument,
3266
+ branchId
3255
3267
  } = useTranslations();
3256
3268
  return loadingDocuments ? /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", justify: "center", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { maxHeight: "60vh", overflowY: "auto" }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: documents.map((document2) => /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { shadow: 1, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
3257
3269
  /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "space-between", align: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { flex: 1, children: [
@@ -3259,7 +3271,7 @@ const WrapText = dt(ui.Box)`
3259
3271
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 0, muted: !0, style: { marginTop: "2px" }, children: document2._type })
3260
3272
  ] }) }),
3261
3273
  /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: locales.length > 0 ? locales.filter((locale) => locale.enabled !== !1).map((locale) => {
3262
- const documentId = document2._id?.replace("drafts.", "") || document2._id, key = `${documentId}:${locale.localeId}`, status = translationStatuses.get(key), isDownloaded = downloadStatus.downloaded.has(key), isImported = importedTranslations.has(key);
3274
+ const documentId = document2._id?.replace("drafts.", "") || document2._id, key = `${branchId}:${documentId}:${document2._rev}:${locale.localeId}`, status = translationStatuses.get(key), isDownloaded = downloadStatus.downloaded.has(key), isImported = importedTranslations.has(key);
3263
3275
  return /* @__PURE__ */ jsxRuntime.jsx(
3264
3276
  LanguageStatus,
3265
3277
  {
@@ -3269,11 +3281,12 @@ const WrapText = dt(ui.Box)`
3269
3281
  importFile: async () => {
3270
3282
  await handleImportDocument(
3271
3283
  documentId,
3284
+ document2._rev,
3272
3285
  locale.localeId
3273
3286
  );
3274
3287
  }
3275
3288
  },
3276
- `${document2._id}-${locale.localeId}`
3289
+ `${document2._id}-${document2._rev}-${locale.localeId}`
3277
3290
  );
3278
3291
  }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: !0, children: "No locales configured" }) })
3279
3292
  ] }) }, document2._id)) }) });