sanity-plugin-studio-smartling 1.3.0 → 2.0.0
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/adapter/createTask.d.ts +7 -1
- package/dist/adapter/getTranslationTask.d.ts +6 -0
- package/dist/index.d.ts +10 -13
- package/dist/sanity-plugin-studio-smartling.cjs.development.js +61 -308
- package/dist/sanity-plugin-studio-smartling.cjs.development.js.map +1 -1
- package/dist/sanity-plugin-studio-smartling.cjs.production.min.js +1 -1
- package/dist/sanity-plugin-studio-smartling.cjs.production.min.js.map +1 -1
- package/dist/sanity-plugin-studio-smartling.esm.js +47 -298
- package/dist/sanity-plugin-studio-smartling.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/adapter/createTask.ts +27 -8
- package/src/adapter/getTranslation.ts +10 -1
- package/src/adapter/getTranslationTask.ts +4 -2
- package/src/index.ts +21 -32
- package/dist/helpers.d.ts +0 -5
- package/src/helpers.ts +0 -116
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Secrets } from 'sanity-translations-tab';
|
|
2
|
-
export declare const createTask: (documentId: string, document: Record<string, any>, localeIds: string[], secrets: Secrets) => Promise<{
|
|
2
|
+
export declare const createTask: (documentId: string, document: Record<string, any>, localeIds: string[], secrets: Secrets, workflowUid?: string) => Promise<{
|
|
3
|
+
documentId: string;
|
|
4
|
+
taskId: string;
|
|
5
|
+
locales: any[];
|
|
6
|
+
linkToVendorTask?: undefined;
|
|
7
|
+
} | {
|
|
3
8
|
documentId: string;
|
|
4
9
|
locales: any[];
|
|
5
10
|
taskId: string;
|
|
11
|
+
linkToVendorTask: string;
|
|
6
12
|
}>;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Secrets } from 'sanity-translations-tab';
|
|
2
2
|
export declare const getTranslationTask: (documentId: string, secrets: Secrets) => Promise<{
|
|
3
|
+
documentId: string;
|
|
4
|
+
taskId: string;
|
|
5
|
+
locales: any[];
|
|
6
|
+
linkToVendorTask?: undefined;
|
|
7
|
+
} | {
|
|
3
8
|
documentId: string;
|
|
4
9
|
locales: any[];
|
|
5
10
|
taskId: string;
|
|
11
|
+
linkToVendorTask: string;
|
|
6
12
|
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { TranslationsTab } from 'sanity-translations-tab';
|
|
2
|
-
import { BaseDocumentDeserializer, BaseDocumentSerializer, BaseDocumentMerger, defaultStopTypes, customSerializers } from 'sanity-naive-html-serializer';
|
|
1
|
+
import { TranslationsTab, findLatestDraft, BaseDocumentDeserializer, BaseDocumentSerializer, BaseDocumentMerger, defaultStopTypes, customSerializers, Adapter } from 'sanity-translations-tab';
|
|
3
2
|
import { SmartlingAdapter } from './adapter';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
export { TranslationsTab, BaseDocumentDeserializer, BaseDocumentSerializer, BaseDocumentMerger, defaultStopTypes, customSerializers, SmartlingAdapter, defaultDocumentLevelConfig, defaultFieldLevelConfig, };
|
|
3
|
+
interface ConfigOptions {
|
|
4
|
+
adapter: Adapter;
|
|
5
|
+
secretsNamespace: string | null;
|
|
6
|
+
exportForTranslation: (id: string) => Promise<Record<string, any>>;
|
|
7
|
+
importTranslation: (id: string, localeId: string, doc: string) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
declare const defaultDocumentLevelConfig: ConfigOptions;
|
|
10
|
+
declare const defaultFieldLevelConfig: ConfigOptions;
|
|
11
|
+
export { TranslationsTab, findLatestDraft, BaseDocumentDeserializer, BaseDocumentSerializer, BaseDocumentMerger, defaultStopTypes, customSerializers, SmartlingAdapter, defaultDocumentLevelConfig, defaultFieldLevelConfig, };
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
|
-
|
|
5
3
|
var sanityTranslationsTab = require('sanity-translations-tab');
|
|
6
|
-
var sanityNaiveHtmlSerializer = require('sanity-naive-html-serializer');
|
|
7
|
-
var sanityClient = _interopDefault(require('part:@sanity/base/client'));
|
|
8
4
|
|
|
9
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
6
|
try {
|
|
@@ -932,7 +928,7 @@ var getLocales = /*#__PURE__*/function () {
|
|
|
932
928
|
|
|
933
929
|
var getTranslationTask = /*#__PURE__*/function () {
|
|
934
930
|
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(documentId, secrets) {
|
|
935
|
-
var accessToken, taskId,
|
|
931
|
+
var accessToken, taskId, projectId, progressUrl, smartlingTask, locales;
|
|
936
932
|
return runtime_1.wrap(function _callee$(_context) {
|
|
937
933
|
while (1) {
|
|
938
934
|
switch (_context.prev = _context.next) {
|
|
@@ -960,18 +956,19 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
960
956
|
});
|
|
961
957
|
|
|
962
958
|
case 8:
|
|
963
|
-
|
|
964
|
-
|
|
959
|
+
projectId = secrets.project;
|
|
960
|
+
progressUrl = "https://api.smartling.com/jobs-api/v3/projects/" + projectId + "/jobs/" + taskId + "/progress";
|
|
961
|
+
_context.next = 12;
|
|
965
962
|
return fetch(smartlingProxy, {
|
|
966
963
|
method: 'POST',
|
|
967
|
-
headers: getHeaders(
|
|
964
|
+
headers: getHeaders(progressUrl, accessToken)
|
|
968
965
|
}).then(function (res) {
|
|
969
966
|
return res.json();
|
|
970
967
|
}).then(function (res) {
|
|
971
968
|
return res.response.data;
|
|
972
969
|
});
|
|
973
970
|
|
|
974
|
-
case
|
|
971
|
+
case 12:
|
|
975
972
|
smartlingTask = _context.sent;
|
|
976
973
|
locales = [];
|
|
977
974
|
|
|
@@ -988,10 +985,11 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
988
985
|
documentId: documentId,
|
|
989
986
|
locales: locales,
|
|
990
987
|
//since our download is tied to document id for smartling, keep track of it as a task
|
|
991
|
-
taskId: documentId
|
|
988
|
+
taskId: documentId,
|
|
989
|
+
linkToVendorTask: "https://dashboard.smartling.com/app/projects/" + projectId + "/account-jobs/" + projectId + ":" + taskId
|
|
992
990
|
});
|
|
993
991
|
|
|
994
|
-
case
|
|
992
|
+
case 16:
|
|
995
993
|
case "end":
|
|
996
994
|
return _context.stop();
|
|
997
995
|
}
|
|
@@ -1047,30 +1045,41 @@ var createJob = /*#__PURE__*/function () {
|
|
|
1047
1045
|
|
|
1048
1046
|
|
|
1049
1047
|
var createJobBatch = /*#__PURE__*/function () {
|
|
1050
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(jobId, projectId, documentName, accessToken) {
|
|
1051
|
-
var url;
|
|
1048
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(jobId, projectId, documentName, accessToken, localeIds, workflowUid) {
|
|
1049
|
+
var url, reqBody;
|
|
1052
1050
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1053
1051
|
while (1) {
|
|
1054
1052
|
switch (_context2.prev = _context2.next) {
|
|
1055
1053
|
case 0:
|
|
1056
1054
|
url = "https://api.smartling.com/job-batches-api/v2/projects/" + projectId + "/batches";
|
|
1055
|
+
reqBody = {
|
|
1056
|
+
authorize: true,
|
|
1057
|
+
translationJobUid: jobId,
|
|
1058
|
+
fileUris: [documentName]
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
if (workflowUid) {
|
|
1062
|
+
reqBody.localeWorkflows = localeIds.map(function (l) {
|
|
1063
|
+
return {
|
|
1064
|
+
targetLocaleId: l,
|
|
1065
|
+
workflowUid: workflowUid
|
|
1066
|
+
};
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1057
1070
|
return _context2.abrupt("return", fetch(smartlingProxy, {
|
|
1058
1071
|
method: 'POST',
|
|
1059
1072
|
headers: _extends({}, getHeaders(url, accessToken), {
|
|
1060
1073
|
'content-type': 'application/json'
|
|
1061
1074
|
}),
|
|
1062
|
-
body: JSON.stringify(
|
|
1063
|
-
authorize: true,
|
|
1064
|
-
translationJobUid: jobId,
|
|
1065
|
-
fileUris: [documentName]
|
|
1066
|
-
})
|
|
1075
|
+
body: JSON.stringify(reqBody)
|
|
1067
1076
|
}).then(function (res) {
|
|
1068
1077
|
return res.json();
|
|
1069
1078
|
}).then(function (res) {
|
|
1070
1079
|
return res.response.data.batchUid;
|
|
1071
1080
|
}));
|
|
1072
1081
|
|
|
1073
|
-
case
|
|
1082
|
+
case 4:
|
|
1074
1083
|
case "end":
|
|
1075
1084
|
return _context2.stop();
|
|
1076
1085
|
}
|
|
@@ -1078,7 +1087,7 @@ var createJobBatch = /*#__PURE__*/function () {
|
|
|
1078
1087
|
}, _callee2);
|
|
1079
1088
|
}));
|
|
1080
1089
|
|
|
1081
|
-
return function createJobBatch(_x5, _x6, _x7, _x8) {
|
|
1090
|
+
return function createJobBatch(_x5, _x6, _x7, _x8, _x9, _x10) {
|
|
1082
1091
|
return _ref2.apply(this, arguments);
|
|
1083
1092
|
};
|
|
1084
1093
|
}();
|
|
@@ -1115,13 +1124,13 @@ var uploadFileToBatch = /*#__PURE__*/function () {
|
|
|
1115
1124
|
}, _callee3);
|
|
1116
1125
|
}));
|
|
1117
1126
|
|
|
1118
|
-
return function uploadFileToBatch(
|
|
1127
|
+
return function uploadFileToBatch(_x11, _x12, _x13, _x14, _x15) {
|
|
1119
1128
|
return _ref3.apply(this, arguments);
|
|
1120
1129
|
};
|
|
1121
1130
|
}();
|
|
1122
1131
|
|
|
1123
1132
|
var createTask = /*#__PURE__*/function () {
|
|
1124
|
-
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(documentId, document, localeIds, secrets) {
|
|
1133
|
+
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(documentId, document, localeIds, secrets, workflowUid) {
|
|
1125
1134
|
var accessToken, taskId, batchUid, uploadFileRes;
|
|
1126
1135
|
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1127
1136
|
while (1) {
|
|
@@ -1151,7 +1160,7 @@ var createTask = /*#__PURE__*/function () {
|
|
|
1151
1160
|
|
|
1152
1161
|
case 10:
|
|
1153
1162
|
_context4.next = 12;
|
|
1154
|
-
return createJobBatch(taskId, secrets.project, document.name, accessToken);
|
|
1163
|
+
return createJobBatch(taskId, secrets.project, document.name, accessToken, localeIds, workflowUid);
|
|
1155
1164
|
|
|
1156
1165
|
case 12:
|
|
1157
1166
|
batchUid = _context4.sent;
|
|
@@ -1171,7 +1180,7 @@ var createTask = /*#__PURE__*/function () {
|
|
|
1171
1180
|
}, _callee4);
|
|
1172
1181
|
}));
|
|
1173
1182
|
|
|
1174
|
-
return function createTask(
|
|
1183
|
+
return function createTask(_x16, _x17, _x18, _x19, _x20) {
|
|
1175
1184
|
return _ref4.apply(this, arguments);
|
|
1176
1185
|
};
|
|
1177
1186
|
}();
|
|
@@ -1196,7 +1205,14 @@ var getTranslation = /*#__PURE__*/function () {
|
|
|
1196
1205
|
}).then(function (res) {
|
|
1197
1206
|
return res.json();
|
|
1198
1207
|
}).then(function (res) {
|
|
1199
|
-
|
|
1208
|
+
if (res.body) {
|
|
1209
|
+
return res.body;
|
|
1210
|
+
} else if (res.response.errors) {
|
|
1211
|
+
var _res$response$errors$;
|
|
1212
|
+
|
|
1213
|
+
var errMsg = ((_res$response$errors$ = res.response.errors[0]) == null ? void 0 : _res$response$errors$.message) || 'Error retrieving translation from Smartling';
|
|
1214
|
+
throw new Error(errMsg);
|
|
1215
|
+
}
|
|
1200
1216
|
});
|
|
1201
1217
|
|
|
1202
1218
|
case 6:
|
|
@@ -1223,317 +1239,54 @@ var SmartlingAdapter = {
|
|
|
1223
1239
|
getTranslation: getTranslation
|
|
1224
1240
|
};
|
|
1225
1241
|
|
|
1226
|
-
var
|
|
1227
|
-
apiVersion: '2021-03-25'
|
|
1228
|
-
}); //document fetch
|
|
1229
|
-
|
|
1230
|
-
var findLatestDraft = function findLatestDraft(documentId, ignoreI18n) {
|
|
1231
|
-
if (ignoreI18n === void 0) {
|
|
1232
|
-
ignoreI18n = true;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
//eliminates i18n versions
|
|
1236
|
-
var query = "*[_id match $id " + (ignoreI18n ? ' && (_id in path("drafts.*") || _id in path("*"))' : '') + "]";
|
|
1237
|
-
var params = {
|
|
1238
|
-
id: "*" + documentId
|
|
1239
|
-
};
|
|
1240
|
-
return client.fetch(query, params).then(function (docs) {
|
|
1241
|
-
var _docs$find;
|
|
1242
|
-
|
|
1243
|
-
return (_docs$find = docs.find(function (doc) {
|
|
1244
|
-
return doc._id.includes('draft');
|
|
1245
|
-
})) != null ? _docs$find : docs[0];
|
|
1246
|
-
});
|
|
1247
|
-
}; //revision fetch
|
|
1248
|
-
|
|
1249
|
-
var findDocumentAtRevision = /*#__PURE__*/function () {
|
|
1250
|
-
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(documentId, rev) {
|
|
1251
|
-
var dataset, baseUrl, url, revisionDoc;
|
|
1252
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1253
|
-
while (1) {
|
|
1254
|
-
switch (_context.prev = _context.next) {
|
|
1255
|
-
case 0:
|
|
1256
|
-
dataset = client.config().dataset;
|
|
1257
|
-
baseUrl = "/data/history/" + dataset + "/documents/" + documentId + "?revision=" + rev;
|
|
1258
|
-
url = client.getUrl(baseUrl);
|
|
1259
|
-
_context.next = 5;
|
|
1260
|
-
return fetch(url, {
|
|
1261
|
-
credentials: 'include'
|
|
1262
|
-
}).then(function (req) {
|
|
1263
|
-
return req.json();
|
|
1264
|
-
}).then(function (req) {
|
|
1265
|
-
return req.documents[0];
|
|
1266
|
-
});
|
|
1267
|
-
|
|
1268
|
-
case 5:
|
|
1269
|
-
revisionDoc = _context.sent;
|
|
1270
|
-
|
|
1271
|
-
if (!(!revisionDoc || revisionDoc._rev !== rev)) {
|
|
1272
|
-
_context.next = 12;
|
|
1273
|
-
break;
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
baseUrl = "/data/history/" + dataset + "/documents/drafts." + documentId + "?revision=" + rev;
|
|
1277
|
-
url = client.getUrl(baseUrl);
|
|
1278
|
-
_context.next = 11;
|
|
1279
|
-
return fetch(url, {
|
|
1280
|
-
credentials: 'include'
|
|
1281
|
-
}).then(function (req) {
|
|
1282
|
-
return req.json();
|
|
1283
|
-
}).then(function (req) {
|
|
1284
|
-
return req.documents[0];
|
|
1285
|
-
});
|
|
1286
|
-
|
|
1287
|
-
case 11:
|
|
1288
|
-
revisionDoc = _context.sent;
|
|
1289
|
-
|
|
1290
|
-
case 12:
|
|
1291
|
-
return _context.abrupt("return", revisionDoc);
|
|
1292
|
-
|
|
1293
|
-
case 13:
|
|
1294
|
-
case "end":
|
|
1295
|
-
return _context.stop();
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
}, _callee);
|
|
1299
|
-
}));
|
|
1300
|
-
|
|
1301
|
-
return function findDocumentAtRevision(_x, _x2) {
|
|
1302
|
-
return _ref.apply(this, arguments);
|
|
1303
|
-
};
|
|
1304
|
-
}(); //document-level patch
|
|
1305
|
-
|
|
1306
|
-
var documentLevelPatch = /*#__PURE__*/function () {
|
|
1307
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(documentId, translatedFields, localeId) {
|
|
1308
|
-
var baseDoc, merged, targetId, i18nDoc, cleanedMerge;
|
|
1309
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1310
|
-
while (1) {
|
|
1311
|
-
switch (_context2.prev = _context2.next) {
|
|
1312
|
-
case 0:
|
|
1313
|
-
if (!translatedFields._rev) {
|
|
1314
|
-
_context2.next = 6;
|
|
1315
|
-
break;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
_context2.next = 3;
|
|
1319
|
-
return findDocumentAtRevision(documentId, translatedFields._rev);
|
|
1320
|
-
|
|
1321
|
-
case 3:
|
|
1322
|
-
baseDoc = _context2.sent;
|
|
1323
|
-
_context2.next = 9;
|
|
1324
|
-
break;
|
|
1325
|
-
|
|
1326
|
-
case 6:
|
|
1327
|
-
_context2.next = 8;
|
|
1328
|
-
return findLatestDraft(documentId);
|
|
1329
|
-
|
|
1330
|
-
case 8:
|
|
1331
|
-
baseDoc = _context2.sent;
|
|
1332
|
-
|
|
1333
|
-
case 9:
|
|
1334
|
-
merged = sanityNaiveHtmlSerializer.BaseDocumentMerger.documentLevelMerge(translatedFields, baseDoc);
|
|
1335
|
-
targetId = "i18n." + documentId + "." + localeId;
|
|
1336
|
-
_context2.next = 13;
|
|
1337
|
-
return findLatestDraft(targetId, false);
|
|
1338
|
-
|
|
1339
|
-
case 13:
|
|
1340
|
-
i18nDoc = _context2.sent;
|
|
1341
|
-
|
|
1342
|
-
if (i18nDoc) {
|
|
1343
|
-
cleanedMerge = {}; //don't overwrite any existing values on the i18n doc
|
|
1344
|
-
|
|
1345
|
-
Object.entries(merged).forEach(function (_ref3) {
|
|
1346
|
-
var key = _ref3[0],
|
|
1347
|
-
value = _ref3[1];
|
|
1348
|
-
|
|
1349
|
-
if (Object.keys(translatedFields).includes(key) && !['_id', '_rev', '_updatedAt'].includes(key)) {
|
|
1350
|
-
cleanedMerge[key] = value;
|
|
1351
|
-
}
|
|
1352
|
-
});
|
|
1353
|
-
client.transaction() //@ts-ignore
|
|
1354
|
-
.patch(i18nDoc._id, function (p) {
|
|
1355
|
-
return p.set(cleanedMerge);
|
|
1356
|
-
}).commit();
|
|
1357
|
-
} else {
|
|
1358
|
-
merged._id = "drafts." + targetId; //account for legacy implementations of i18n plugin lang
|
|
1359
|
-
|
|
1360
|
-
if (baseDoc._lang) {
|
|
1361
|
-
merged._lang = localeId;
|
|
1362
|
-
} else if (baseDoc.__i18n_lang) {
|
|
1363
|
-
merged.__i18n_lang = localeId;
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
client.create(merged);
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
case 15:
|
|
1370
|
-
case "end":
|
|
1371
|
-
return _context2.stop();
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
}, _callee2);
|
|
1375
|
-
}));
|
|
1376
|
-
|
|
1377
|
-
return function documentLevelPatch(_x3, _x4, _x5) {
|
|
1378
|
-
return _ref2.apply(this, arguments);
|
|
1379
|
-
};
|
|
1380
|
-
}(); //field level patch
|
|
1381
|
-
|
|
1382
|
-
var fieldLevelPatch = /*#__PURE__*/function () {
|
|
1383
|
-
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(documentId, translatedFields, localeId) {
|
|
1384
|
-
var baseDoc, merged;
|
|
1385
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1386
|
-
while (1) {
|
|
1387
|
-
switch (_context3.prev = _context3.next) {
|
|
1388
|
-
case 0:
|
|
1389
|
-
if (!translatedFields._rev) {
|
|
1390
|
-
_context3.next = 6;
|
|
1391
|
-
break;
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
_context3.next = 3;
|
|
1395
|
-
return findDocumentAtRevision(documentId, translatedFields._rev);
|
|
1396
|
-
|
|
1397
|
-
case 3:
|
|
1398
|
-
baseDoc = _context3.sent;
|
|
1399
|
-
_context3.next = 9;
|
|
1400
|
-
break;
|
|
1401
|
-
|
|
1402
|
-
case 6:
|
|
1403
|
-
_context3.next = 8;
|
|
1404
|
-
return findLatestDraft(documentId);
|
|
1405
|
-
|
|
1406
|
-
case 8:
|
|
1407
|
-
baseDoc = _context3.sent;
|
|
1408
|
-
|
|
1409
|
-
case 9:
|
|
1410
|
-
merged = sanityNaiveHtmlSerializer.BaseDocumentMerger.fieldLevelMerge(translatedFields, baseDoc, localeId, 'en');
|
|
1411
|
-
client.patch(baseDoc._id).set(merged).commit();
|
|
1412
|
-
|
|
1413
|
-
case 11:
|
|
1414
|
-
case "end":
|
|
1415
|
-
return _context3.stop();
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
}, _callee3);
|
|
1419
|
-
}));
|
|
1420
|
-
|
|
1421
|
-
return function fieldLevelPatch(_x6, _x7, _x8) {
|
|
1422
|
-
return _ref4.apply(this, arguments);
|
|
1423
|
-
};
|
|
1424
|
-
}();
|
|
1425
|
-
|
|
1426
|
-
var defaultDocumentLevelConfig = {
|
|
1427
|
-
exportForTranslation: /*#__PURE__*/function () {
|
|
1428
|
-
var _exportForTranslation = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
|
|
1429
|
-
var doc, serialized;
|
|
1430
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1431
|
-
while (1) {
|
|
1432
|
-
switch (_context.prev = _context.next) {
|
|
1433
|
-
case 0:
|
|
1434
|
-
_context.next = 2;
|
|
1435
|
-
return findLatestDraft(id);
|
|
1436
|
-
|
|
1437
|
-
case 2:
|
|
1438
|
-
doc = _context.sent;
|
|
1439
|
-
serialized = sanityNaiveHtmlSerializer.BaseDocumentSerializer.serializeDocument(doc, 'document'); //needed for lookup by translation tab
|
|
1440
|
-
|
|
1441
|
-
serialized.name = id;
|
|
1442
|
-
return _context.abrupt("return", serialized);
|
|
1443
|
-
|
|
1444
|
-
case 6:
|
|
1445
|
-
case "end":
|
|
1446
|
-
return _context.stop();
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
}, _callee);
|
|
1450
|
-
}));
|
|
1451
|
-
|
|
1452
|
-
function exportForTranslation(_x) {
|
|
1453
|
-
return _exportForTranslation.apply(this, arguments);
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
return exportForTranslation;
|
|
1457
|
-
}(),
|
|
1458
|
-
importTranslation: function importTranslation(id, localeId, document) {
|
|
1459
|
-
var deserialized = sanityNaiveHtmlSerializer.BaseDocumentDeserializer.deserializeDocument(document);
|
|
1460
|
-
documentLevelPatch(id, deserialized, localeId);
|
|
1461
|
-
},
|
|
1242
|
+
var defaultDocumentLevelConfig = /*#__PURE__*/_extends({}, sanityTranslationsTab.baseDocumentLevelConfig, {
|
|
1462
1243
|
adapter: SmartlingAdapter
|
|
1463
|
-
};
|
|
1464
|
-
var defaultFieldLevelConfig = {
|
|
1465
|
-
exportForTranslation: /*#__PURE__*/function () {
|
|
1466
|
-
var _exportForTranslation2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(id) {
|
|
1467
|
-
var doc, serialized;
|
|
1468
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1469
|
-
while (1) {
|
|
1470
|
-
switch (_context2.prev = _context2.next) {
|
|
1471
|
-
case 0:
|
|
1472
|
-
_context2.next = 2;
|
|
1473
|
-
return findLatestDraft(id);
|
|
1474
|
-
|
|
1475
|
-
case 2:
|
|
1476
|
-
doc = _context2.sent;
|
|
1477
|
-
serialized = sanityNaiveHtmlSerializer.BaseDocumentSerializer.serializeDocument(doc, 'field'); //needed for lookup by translation tab
|
|
1478
|
-
|
|
1479
|
-
serialized.name = id;
|
|
1480
|
-
return _context2.abrupt("return", serialized);
|
|
1481
|
-
|
|
1482
|
-
case 6:
|
|
1483
|
-
case "end":
|
|
1484
|
-
return _context2.stop();
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
}, _callee2);
|
|
1488
|
-
}));
|
|
1489
|
-
|
|
1490
|
-
function exportForTranslation(_x2) {
|
|
1491
|
-
return _exportForTranslation2.apply(this, arguments);
|
|
1492
|
-
}
|
|
1244
|
+
});
|
|
1493
1245
|
|
|
1494
|
-
|
|
1495
|
-
}(),
|
|
1496
|
-
importTranslation: function importTranslation(id, localeId, document) {
|
|
1497
|
-
var deserialized = sanityNaiveHtmlSerializer.BaseDocumentDeserializer.deserializeDocument(document);
|
|
1498
|
-
fieldLevelPatch(id, deserialized, localeId);
|
|
1499
|
-
},
|
|
1246
|
+
var defaultFieldLevelConfig = /*#__PURE__*/_extends({}, sanityTranslationsTab.baseFieldLevelConfig, {
|
|
1500
1247
|
adapter: SmartlingAdapter
|
|
1501
|
-
};
|
|
1248
|
+
});
|
|
1502
1249
|
|
|
1503
|
-
Object.defineProperty(exports, '
|
|
1250
|
+
Object.defineProperty(exports, 'BaseDocumentDeserializer', {
|
|
1504
1251
|
enumerable: true,
|
|
1505
1252
|
get: function () {
|
|
1506
|
-
return sanityTranslationsTab.
|
|
1253
|
+
return sanityTranslationsTab.BaseDocumentDeserializer;
|
|
1507
1254
|
}
|
|
1508
1255
|
});
|
|
1509
|
-
Object.defineProperty(exports, '
|
|
1256
|
+
Object.defineProperty(exports, 'BaseDocumentMerger', {
|
|
1510
1257
|
enumerable: true,
|
|
1511
1258
|
get: function () {
|
|
1512
|
-
return
|
|
1259
|
+
return sanityTranslationsTab.BaseDocumentMerger;
|
|
1513
1260
|
}
|
|
1514
1261
|
});
|
|
1515
|
-
Object.defineProperty(exports, '
|
|
1262
|
+
Object.defineProperty(exports, 'BaseDocumentSerializer', {
|
|
1516
1263
|
enumerable: true,
|
|
1517
1264
|
get: function () {
|
|
1518
|
-
return
|
|
1265
|
+
return sanityTranslationsTab.BaseDocumentSerializer;
|
|
1519
1266
|
}
|
|
1520
1267
|
});
|
|
1521
|
-
Object.defineProperty(exports, '
|
|
1268
|
+
Object.defineProperty(exports, 'TranslationsTab', {
|
|
1522
1269
|
enumerable: true,
|
|
1523
1270
|
get: function () {
|
|
1524
|
-
return
|
|
1271
|
+
return sanityTranslationsTab.TranslationsTab;
|
|
1525
1272
|
}
|
|
1526
1273
|
});
|
|
1527
1274
|
Object.defineProperty(exports, 'customSerializers', {
|
|
1528
1275
|
enumerable: true,
|
|
1529
1276
|
get: function () {
|
|
1530
|
-
return
|
|
1277
|
+
return sanityTranslationsTab.customSerializers;
|
|
1531
1278
|
}
|
|
1532
1279
|
});
|
|
1533
1280
|
Object.defineProperty(exports, 'defaultStopTypes', {
|
|
1534
1281
|
enumerable: true,
|
|
1535
1282
|
get: function () {
|
|
1536
|
-
return
|
|
1283
|
+
return sanityTranslationsTab.defaultStopTypes;
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
Object.defineProperty(exports, 'findLatestDraft', {
|
|
1287
|
+
enumerable: true,
|
|
1288
|
+
get: function () {
|
|
1289
|
+
return sanityTranslationsTab.findLatestDraft;
|
|
1537
1290
|
}
|
|
1538
1291
|
});
|
|
1539
1292
|
exports.SmartlingAdapter = SmartlingAdapter;
|