@uniformdev/tms-sdk 19.165.2-alpha.0 → 19.167.2-alpha.3
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.esm.js +27 -12
- package/dist/index.js +27 -12
- package/dist/index.mjs +27 -12
- package/package.json +5 -5
package/dist/index.esm.js
CHANGED
|
@@ -290,40 +290,52 @@ var processParameterTranslation = ({
|
|
|
290
290
|
originalParameter,
|
|
291
291
|
parameter
|
|
292
292
|
}) => {
|
|
293
|
-
var _a, _b, _c;
|
|
294
|
-
if (
|
|
293
|
+
var _a, _b, _c, _d;
|
|
294
|
+
if (originalParameter.type !== parameter.type) {
|
|
295
295
|
return { updated: false };
|
|
296
296
|
}
|
|
297
|
-
if (originalParameter.
|
|
297
|
+
if (!originalParameter.locales && originalParameter.value === void 0) {
|
|
298
298
|
return { updated: false };
|
|
299
299
|
}
|
|
300
300
|
const sourceValue = (_a = parameter.locales) == null ? void 0 : _a[TRANSLATION_PAYLOAD_SOURCE_KEY];
|
|
301
301
|
const targetValue = (_b = parameter.locales) == null ? void 0 : _b[TRANSLATION_PAYLOAD_TARGET_KEY];
|
|
302
302
|
const originalTargetValue = (_c = parameter.locales) == null ? void 0 : _c[TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY];
|
|
303
|
+
const originalParameterSource = originalParameter.locales ? originalParameter.locales[uniformSourceLocale] : originalParameter.value;
|
|
303
304
|
const isSourceValueUntouched = isSameParameterValue({
|
|
304
305
|
parameterType: originalParameter.type,
|
|
305
|
-
left:
|
|
306
|
+
left: originalParameterSource,
|
|
306
307
|
right: sourceValue
|
|
307
308
|
});
|
|
308
309
|
const isTargetValueUntouched = isSameParameterValue({
|
|
309
310
|
parameterType: originalParameter.type,
|
|
310
|
-
left: originalParameter.locales[uniformTargetLocale],
|
|
311
|
+
left: (_d = originalParameter.locales) == null ? void 0 : _d[uniformTargetLocale],
|
|
311
312
|
right: originalTargetValue
|
|
312
313
|
});
|
|
313
314
|
if (targetValue !== void 0 && isSourceValueUntouched && isTargetValueUntouched) {
|
|
314
315
|
if (parameter.type == SUPPORTED_PARAM_TYPES.richText && isTranslatableRichTextValue(targetValue)) {
|
|
315
316
|
try {
|
|
316
317
|
const richTextValue = parseTranslatableXml(targetValue);
|
|
317
|
-
|
|
318
|
+
updateOriginalParameterValue(richTextValue);
|
|
318
319
|
return { updated: true };
|
|
319
320
|
} catch (e) {
|
|
320
321
|
return { updated: false };
|
|
321
322
|
}
|
|
322
323
|
} else if (parameter.type == SUPPORTED_PARAM_TYPES.text) {
|
|
323
|
-
|
|
324
|
+
updateOriginalParameterValue(targetValue);
|
|
324
325
|
return { updated: true };
|
|
325
326
|
}
|
|
326
327
|
}
|
|
328
|
+
function updateOriginalParameterValue(value) {
|
|
329
|
+
if (originalParameter.locales) {
|
|
330
|
+
originalParameter.locales[uniformTargetLocale] = value;
|
|
331
|
+
} else if (originalParameter.value !== void 0) {
|
|
332
|
+
originalParameter.locales = {
|
|
333
|
+
[uniformSourceLocale]: originalParameter.value,
|
|
334
|
+
[uniformTargetLocale]: value
|
|
335
|
+
};
|
|
336
|
+
originalParameter.value = void 0;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
327
339
|
return { updated: false };
|
|
328
340
|
};
|
|
329
341
|
var processOverrideTranslation = ({
|
|
@@ -716,18 +728,21 @@ var translateComposition = ({
|
|
|
716
728
|
if (composition.composition._id !== translationPayload.metadata.entity.id) {
|
|
717
729
|
return createErrorResult("entity-id-mismatch");
|
|
718
730
|
}
|
|
719
|
-
const compositionLocales = (_a = composition.composition._locales) != null ? _a : [];
|
|
720
731
|
const uniformSourceLocale = translationPayload.metadata.uniformSourceLocale;
|
|
721
732
|
const uniformTargetLocale = translationPayload.metadata.uniformTargetLocale;
|
|
722
|
-
|
|
733
|
+
const compositionLocales = (_a = composition.composition._locales) != null ? _a : [];
|
|
734
|
+
if (compositionLocales.length > 0 && !compositionLocales.includes(uniformSourceLocale)) {
|
|
723
735
|
return createErrorResult("entity-locales-mismatch");
|
|
724
736
|
}
|
|
725
737
|
let updated = false;
|
|
726
738
|
const translatedComposition = produce(composition, (draft) => {
|
|
727
|
-
var _a2, _b;
|
|
739
|
+
var _a2, _b, _c;
|
|
728
740
|
draft.state = CANVAS_DRAFT_STATE3;
|
|
729
|
-
if (!
|
|
730
|
-
(
|
|
741
|
+
if (!((_a2 = draft.composition._locales) == null ? void 0 : _a2.length)) {
|
|
742
|
+
(_c = (_b = draft.composition)._locales) != null ? _c : _b._locales = [];
|
|
743
|
+
draft.composition._locales.push(uniformSourceLocale);
|
|
744
|
+
}
|
|
745
|
+
if (!draft.composition._locales.includes(uniformTargetLocale)) {
|
|
731
746
|
draft.composition._locales.push(uniformTargetLocale);
|
|
732
747
|
}
|
|
733
748
|
walkNodeTree3(draft.composition, ({ node: component, type, actions }) => {
|
package/dist/index.js
CHANGED
|
@@ -318,40 +318,52 @@ var processParameterTranslation = ({
|
|
|
318
318
|
originalParameter,
|
|
319
319
|
parameter
|
|
320
320
|
}) => {
|
|
321
|
-
var _a, _b, _c;
|
|
322
|
-
if (
|
|
321
|
+
var _a, _b, _c, _d;
|
|
322
|
+
if (originalParameter.type !== parameter.type) {
|
|
323
323
|
return { updated: false };
|
|
324
324
|
}
|
|
325
|
-
if (originalParameter.
|
|
325
|
+
if (!originalParameter.locales && originalParameter.value === void 0) {
|
|
326
326
|
return { updated: false };
|
|
327
327
|
}
|
|
328
328
|
const sourceValue = (_a = parameter.locales) == null ? void 0 : _a[TRANSLATION_PAYLOAD_SOURCE_KEY];
|
|
329
329
|
const targetValue = (_b = parameter.locales) == null ? void 0 : _b[TRANSLATION_PAYLOAD_TARGET_KEY];
|
|
330
330
|
const originalTargetValue = (_c = parameter.locales) == null ? void 0 : _c[TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY];
|
|
331
|
+
const originalParameterSource = originalParameter.locales ? originalParameter.locales[uniformSourceLocale] : originalParameter.value;
|
|
331
332
|
const isSourceValueUntouched = isSameParameterValue({
|
|
332
333
|
parameterType: originalParameter.type,
|
|
333
|
-
left:
|
|
334
|
+
left: originalParameterSource,
|
|
334
335
|
right: sourceValue
|
|
335
336
|
});
|
|
336
337
|
const isTargetValueUntouched = isSameParameterValue({
|
|
337
338
|
parameterType: originalParameter.type,
|
|
338
|
-
left: originalParameter.locales[uniformTargetLocale],
|
|
339
|
+
left: (_d = originalParameter.locales) == null ? void 0 : _d[uniformTargetLocale],
|
|
339
340
|
right: originalTargetValue
|
|
340
341
|
});
|
|
341
342
|
if (targetValue !== void 0 && isSourceValueUntouched && isTargetValueUntouched) {
|
|
342
343
|
if (parameter.type == SUPPORTED_PARAM_TYPES.richText && isTranslatableRichTextValue(targetValue)) {
|
|
343
344
|
try {
|
|
344
345
|
const richTextValue = parseTranslatableXml(targetValue);
|
|
345
|
-
|
|
346
|
+
updateOriginalParameterValue(richTextValue);
|
|
346
347
|
return { updated: true };
|
|
347
348
|
} catch (e) {
|
|
348
349
|
return { updated: false };
|
|
349
350
|
}
|
|
350
351
|
} else if (parameter.type == SUPPORTED_PARAM_TYPES.text) {
|
|
351
|
-
|
|
352
|
+
updateOriginalParameterValue(targetValue);
|
|
352
353
|
return { updated: true };
|
|
353
354
|
}
|
|
354
355
|
}
|
|
356
|
+
function updateOriginalParameterValue(value) {
|
|
357
|
+
if (originalParameter.locales) {
|
|
358
|
+
originalParameter.locales[uniformTargetLocale] = value;
|
|
359
|
+
} else if (originalParameter.value !== void 0) {
|
|
360
|
+
originalParameter.locales = {
|
|
361
|
+
[uniformSourceLocale]: originalParameter.value,
|
|
362
|
+
[uniformTargetLocale]: value
|
|
363
|
+
};
|
|
364
|
+
originalParameter.value = void 0;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
355
367
|
return { updated: false };
|
|
356
368
|
};
|
|
357
369
|
var processOverrideTranslation = ({
|
|
@@ -744,18 +756,21 @@ var translateComposition = ({
|
|
|
744
756
|
if (composition.composition._id !== translationPayload.metadata.entity.id) {
|
|
745
757
|
return createErrorResult("entity-id-mismatch");
|
|
746
758
|
}
|
|
747
|
-
const compositionLocales = (_a = composition.composition._locales) != null ? _a : [];
|
|
748
759
|
const uniformSourceLocale = translationPayload.metadata.uniformSourceLocale;
|
|
749
760
|
const uniformTargetLocale = translationPayload.metadata.uniformTargetLocale;
|
|
750
|
-
|
|
761
|
+
const compositionLocales = (_a = composition.composition._locales) != null ? _a : [];
|
|
762
|
+
if (compositionLocales.length > 0 && !compositionLocales.includes(uniformSourceLocale)) {
|
|
751
763
|
return createErrorResult("entity-locales-mismatch");
|
|
752
764
|
}
|
|
753
765
|
let updated = false;
|
|
754
766
|
const translatedComposition = (0, import_immer.produce)(composition, (draft) => {
|
|
755
|
-
var _a2, _b;
|
|
767
|
+
var _a2, _b, _c;
|
|
756
768
|
draft.state = import_canvas5.CANVAS_DRAFT_STATE;
|
|
757
|
-
if (!
|
|
758
|
-
(
|
|
769
|
+
if (!((_a2 = draft.composition._locales) == null ? void 0 : _a2.length)) {
|
|
770
|
+
(_c = (_b = draft.composition)._locales) != null ? _c : _b._locales = [];
|
|
771
|
+
draft.composition._locales.push(uniformSourceLocale);
|
|
772
|
+
}
|
|
773
|
+
if (!draft.composition._locales.includes(uniformTargetLocale)) {
|
|
759
774
|
draft.composition._locales.push(uniformTargetLocale);
|
|
760
775
|
}
|
|
761
776
|
(0, import_canvas5.walkNodeTree)(draft.composition, ({ node: component, type, actions }) => {
|
package/dist/index.mjs
CHANGED
|
@@ -290,40 +290,52 @@ var processParameterTranslation = ({
|
|
|
290
290
|
originalParameter,
|
|
291
291
|
parameter
|
|
292
292
|
}) => {
|
|
293
|
-
var _a, _b, _c;
|
|
294
|
-
if (
|
|
293
|
+
var _a, _b, _c, _d;
|
|
294
|
+
if (originalParameter.type !== parameter.type) {
|
|
295
295
|
return { updated: false };
|
|
296
296
|
}
|
|
297
|
-
if (originalParameter.
|
|
297
|
+
if (!originalParameter.locales && originalParameter.value === void 0) {
|
|
298
298
|
return { updated: false };
|
|
299
299
|
}
|
|
300
300
|
const sourceValue = (_a = parameter.locales) == null ? void 0 : _a[TRANSLATION_PAYLOAD_SOURCE_KEY];
|
|
301
301
|
const targetValue = (_b = parameter.locales) == null ? void 0 : _b[TRANSLATION_PAYLOAD_TARGET_KEY];
|
|
302
302
|
const originalTargetValue = (_c = parameter.locales) == null ? void 0 : _c[TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY];
|
|
303
|
+
const originalParameterSource = originalParameter.locales ? originalParameter.locales[uniformSourceLocale] : originalParameter.value;
|
|
303
304
|
const isSourceValueUntouched = isSameParameterValue({
|
|
304
305
|
parameterType: originalParameter.type,
|
|
305
|
-
left:
|
|
306
|
+
left: originalParameterSource,
|
|
306
307
|
right: sourceValue
|
|
307
308
|
});
|
|
308
309
|
const isTargetValueUntouched = isSameParameterValue({
|
|
309
310
|
parameterType: originalParameter.type,
|
|
310
|
-
left: originalParameter.locales[uniformTargetLocale],
|
|
311
|
+
left: (_d = originalParameter.locales) == null ? void 0 : _d[uniformTargetLocale],
|
|
311
312
|
right: originalTargetValue
|
|
312
313
|
});
|
|
313
314
|
if (targetValue !== void 0 && isSourceValueUntouched && isTargetValueUntouched) {
|
|
314
315
|
if (parameter.type == SUPPORTED_PARAM_TYPES.richText && isTranslatableRichTextValue(targetValue)) {
|
|
315
316
|
try {
|
|
316
317
|
const richTextValue = parseTranslatableXml(targetValue);
|
|
317
|
-
|
|
318
|
+
updateOriginalParameterValue(richTextValue);
|
|
318
319
|
return { updated: true };
|
|
319
320
|
} catch (e) {
|
|
320
321
|
return { updated: false };
|
|
321
322
|
}
|
|
322
323
|
} else if (parameter.type == SUPPORTED_PARAM_TYPES.text) {
|
|
323
|
-
|
|
324
|
+
updateOriginalParameterValue(targetValue);
|
|
324
325
|
return { updated: true };
|
|
325
326
|
}
|
|
326
327
|
}
|
|
328
|
+
function updateOriginalParameterValue(value) {
|
|
329
|
+
if (originalParameter.locales) {
|
|
330
|
+
originalParameter.locales[uniformTargetLocale] = value;
|
|
331
|
+
} else if (originalParameter.value !== void 0) {
|
|
332
|
+
originalParameter.locales = {
|
|
333
|
+
[uniformSourceLocale]: originalParameter.value,
|
|
334
|
+
[uniformTargetLocale]: value
|
|
335
|
+
};
|
|
336
|
+
originalParameter.value = void 0;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
327
339
|
return { updated: false };
|
|
328
340
|
};
|
|
329
341
|
var processOverrideTranslation = ({
|
|
@@ -716,18 +728,21 @@ var translateComposition = ({
|
|
|
716
728
|
if (composition.composition._id !== translationPayload.metadata.entity.id) {
|
|
717
729
|
return createErrorResult("entity-id-mismatch");
|
|
718
730
|
}
|
|
719
|
-
const compositionLocales = (_a = composition.composition._locales) != null ? _a : [];
|
|
720
731
|
const uniformSourceLocale = translationPayload.metadata.uniformSourceLocale;
|
|
721
732
|
const uniformTargetLocale = translationPayload.metadata.uniformTargetLocale;
|
|
722
|
-
|
|
733
|
+
const compositionLocales = (_a = composition.composition._locales) != null ? _a : [];
|
|
734
|
+
if (compositionLocales.length > 0 && !compositionLocales.includes(uniformSourceLocale)) {
|
|
723
735
|
return createErrorResult("entity-locales-mismatch");
|
|
724
736
|
}
|
|
725
737
|
let updated = false;
|
|
726
738
|
const translatedComposition = produce(composition, (draft) => {
|
|
727
|
-
var _a2, _b;
|
|
739
|
+
var _a2, _b, _c;
|
|
728
740
|
draft.state = CANVAS_DRAFT_STATE3;
|
|
729
|
-
if (!
|
|
730
|
-
(
|
|
741
|
+
if (!((_a2 = draft.composition._locales) == null ? void 0 : _a2.length)) {
|
|
742
|
+
(_c = (_b = draft.composition)._locales) != null ? _c : _b._locales = [];
|
|
743
|
+
draft.composition._locales.push(uniformSourceLocale);
|
|
744
|
+
}
|
|
745
|
+
if (!draft.composition._locales.includes(uniformTargetLocale)) {
|
|
731
746
|
draft.composition._locales.push(uniformTargetLocale);
|
|
732
747
|
}
|
|
733
748
|
walkNodeTree3(draft.composition, ({ node: component, type, actions }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/tms-sdk",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.167.2-alpha.3+d42f32a982",
|
|
4
4
|
"description": "Uniform Translation Management System SDK",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@uniformdev/canvas": "19.
|
|
37
|
-
"@uniformdev/mesh-sdk": "19.
|
|
38
|
-
"@uniformdev/richtext": "19.
|
|
36
|
+
"@uniformdev/canvas": "19.167.2-alpha.3+d42f32a982",
|
|
37
|
+
"@uniformdev/mesh-sdk": "19.167.2-alpha.3+d42f32a982",
|
|
38
|
+
"@uniformdev/richtext": "19.167.2-alpha.3+d42f32a982",
|
|
39
39
|
"dequal": "2.0.3",
|
|
40
40
|
"fast-xml-parser": "4.4.0",
|
|
41
41
|
"immer": "10.0.4"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "d42f32a98294c96f55a29c10c7c461c5327f56f3"
|
|
44
44
|
}
|