@uniformdev/tms-sdk 20.58.0 → 20.59.1-alpha.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.d.mts CHANGED
@@ -29,13 +29,20 @@ type EntityTranslationResult<TResult = unknown> = {
29
29
  errorText?: string;
30
30
  };
31
31
  type MaybePromise<T> = T | Promise<T> | PromiseLike<T>;
32
+ type CollectTranslationConfig = {
33
+ /**
34
+ * By default, if target locale value exists and different from source locale value, it will be skipped for translation.
35
+ * If `true`, target locale value mismatch will be ignored.
36
+ */
37
+ ignoreTargetLocaleValueMismatch?: boolean;
38
+ };
32
39
 
33
40
  type CollectTranslationPayloadResult = {
34
41
  payload?: TranslationPayload;
35
42
  errorKind?: 'unknown' | 'invalid-args' | 'entity-source-locale-missing';
36
43
  errorText?: string;
37
44
  };
38
- declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocale, uniformTargetLocale, uniformReleaseId, targetLang, entity, entityType, }: {
45
+ declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocale, uniformTargetLocale, uniformReleaseId, targetLang, entity, entityType, config, }: {
39
46
  uniformProjectId: string;
40
47
  uniformSourceLocale: string;
41
48
  uniformTargetLocale: string;
@@ -43,6 +50,7 @@ declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocal
43
50
  targetLang: string;
44
51
  entity: RootComponentInstance | EntryData;
45
52
  entityType: EntityType;
53
+ config?: CollectTranslationConfig;
46
54
  }) => CollectTranslationPayloadResult;
47
55
 
48
56
  declare const getCompositionForTranslation: ({ canvasClient, compositionId, releaseId, state, }: {
@@ -118,4 +126,4 @@ declare const translateEntry: ({ entry, translationPayload, }: {
118
126
  translationPayload: TranslationPayload;
119
127
  }) => EntityTranslationResult<Entry>;
120
128
 
121
- export { type CollectTranslationPayloadResult, type ComponentTranslationPayload, type EntityTranslationResult, type EntityType, type MaybePromise, type MergeCompositionTranslationToUniformOptions, type MergeEntryTranslationToUniformOptions, type MergeTranslationToUniformOptions, type TranslationPayload, collectTranslationPayload, getCompositionForTranslation, getEntryForTranslation, mergeCompositionTranslationToUniform, mergeEntryTranslationToUniform, mergeTranslationToUniform, translateComposition, translateEntry };
129
+ export { type CollectTranslationConfig, type CollectTranslationPayloadResult, type ComponentTranslationPayload, type EntityTranslationResult, type EntityType, type MaybePromise, type MergeCompositionTranslationToUniformOptions, type MergeEntryTranslationToUniformOptions, type MergeTranslationToUniformOptions, type TranslationPayload, collectTranslationPayload, getCompositionForTranslation, getEntryForTranslation, mergeCompositionTranslationToUniform, mergeEntryTranslationToUniform, mergeTranslationToUniform, translateComposition, translateEntry };
package/dist/index.d.ts CHANGED
@@ -29,13 +29,20 @@ type EntityTranslationResult<TResult = unknown> = {
29
29
  errorText?: string;
30
30
  };
31
31
  type MaybePromise<T> = T | Promise<T> | PromiseLike<T>;
32
+ type CollectTranslationConfig = {
33
+ /**
34
+ * By default, if target locale value exists and different from source locale value, it will be skipped for translation.
35
+ * If `true`, target locale value mismatch will be ignored.
36
+ */
37
+ ignoreTargetLocaleValueMismatch?: boolean;
38
+ };
32
39
 
33
40
  type CollectTranslationPayloadResult = {
34
41
  payload?: TranslationPayload;
35
42
  errorKind?: 'unknown' | 'invalid-args' | 'entity-source-locale-missing';
36
43
  errorText?: string;
37
44
  };
38
- declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocale, uniformTargetLocale, uniformReleaseId, targetLang, entity, entityType, }: {
45
+ declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocale, uniformTargetLocale, uniformReleaseId, targetLang, entity, entityType, config, }: {
39
46
  uniformProjectId: string;
40
47
  uniformSourceLocale: string;
41
48
  uniformTargetLocale: string;
@@ -43,6 +50,7 @@ declare const collectTranslationPayload: ({ uniformProjectId, uniformSourceLocal
43
50
  targetLang: string;
44
51
  entity: RootComponentInstance | EntryData;
45
52
  entityType: EntityType;
53
+ config?: CollectTranslationConfig;
46
54
  }) => CollectTranslationPayloadResult;
47
55
 
48
56
  declare const getCompositionForTranslation: ({ canvasClient, compositionId, releaseId, state, }: {
@@ -118,4 +126,4 @@ declare const translateEntry: ({ entry, translationPayload, }: {
118
126
  translationPayload: TranslationPayload;
119
127
  }) => EntityTranslationResult<Entry>;
120
128
 
121
- export { type CollectTranslationPayloadResult, type ComponentTranslationPayload, type EntityTranslationResult, type EntityType, type MaybePromise, type MergeCompositionTranslationToUniformOptions, type MergeEntryTranslationToUniformOptions, type MergeTranslationToUniformOptions, type TranslationPayload, collectTranslationPayload, getCompositionForTranslation, getEntryForTranslation, mergeCompositionTranslationToUniform, mergeEntryTranslationToUniform, mergeTranslationToUniform, translateComposition, translateEntry };
129
+ export { type CollectTranslationConfig, type CollectTranslationPayloadResult, type ComponentTranslationPayload, type EntityTranslationResult, type EntityType, type MaybePromise, type MergeCompositionTranslationToUniformOptions, type MergeEntryTranslationToUniformOptions, type MergeTranslationToUniformOptions, type TranslationPayload, collectTranslationPayload, getCompositionForTranslation, getEntryForTranslation, mergeCompositionTranslationToUniform, mergeEntryTranslationToUniform, mergeTranslationToUniform, translateComposition, translateEntry };
package/dist/index.esm.js CHANGED
@@ -309,7 +309,7 @@ var processParameterTranslation = ({
309
309
  left: originalParameterSource,
310
310
  right: sourceValue
311
311
  });
312
- const isTargetValueUntouched = isSameParameterValue({
312
+ const isTargetValueUntouched = originalTargetValue === void 0 ? true : isSameParameterValue({
313
313
  parameterType: originalParameter.type,
314
314
  left: (_d = originalParameter.locales) == null ? void 0 : _d[uniformTargetLocale],
315
315
  right: originalTargetValue
@@ -453,7 +453,8 @@ var collectTranslationPayload = ({
453
453
  uniformReleaseId,
454
454
  targetLang,
455
455
  entity,
456
- entityType
456
+ entityType,
457
+ config = {}
457
458
  }) => {
458
459
  if (!uniformSourceLocale || !uniformTargetLocale || !targetLang || !entity) {
459
460
  return createErrorResult2("invalid-args");
@@ -486,7 +487,8 @@ var collectTranslationPayload = ({
486
487
  uniformSourceLocale,
487
488
  uniformTargetLocale,
488
489
  node,
489
- deep: false
490
+ deep: false,
491
+ config
490
492
  });
491
493
  if (parameters || _overrides) {
492
494
  payload.components[node._id] = {
@@ -503,7 +505,8 @@ var collectFromNode = ({
503
505
  uniformSourceLocale,
504
506
  uniformTargetLocale,
505
507
  node,
506
- deep
508
+ deep,
509
+ config
507
510
  }) => {
508
511
  var _a, _b, _c;
509
512
  const collectedParameters = {};
@@ -518,7 +521,7 @@ var collectFromNode = ({
518
521
  if (!canTranslateParameterValue(param, sourceLocaleValue)) {
519
522
  return;
520
523
  }
521
- if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
524
+ if (!config.ignoreTargetLocaleValueMismatch && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
522
525
  return;
523
526
  }
524
527
  collectedParameters[paramKey] = {
@@ -526,7 +529,7 @@ var collectFromNode = ({
526
529
  locales: {
527
530
  [TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
528
531
  [TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
529
- [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
532
+ [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: !config.ignoreTargetLocaleValueMismatch ? targetLocaleValue : void 0
530
533
  }
531
534
  };
532
535
  });
@@ -541,7 +544,8 @@ var collectFromNode = ({
541
544
  uniformSourceLocale,
542
545
  uniformTargetLocale,
543
546
  node: slotComponent,
544
- deep: true
547
+ deep: true,
548
+ config
545
549
  });
546
550
  const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
547
551
  if (hasContent) {
@@ -560,7 +564,7 @@ var collectFromNode = ({
560
564
  if (!canTranslateParameterValue(param, sourceLocaleValue)) {
561
565
  return;
562
566
  }
563
- if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
567
+ if (!config.ignoreTargetLocaleValueMismatch && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
564
568
  return;
565
569
  }
566
570
  (_c2 = collectedOverrides[overrideKey]) != null ? _c2 : collectedOverrides[overrideKey] = {};
@@ -570,7 +574,7 @@ var collectFromNode = ({
570
574
  locales: {
571
575
  [TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
572
576
  [TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
573
- [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
577
+ [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: !config.ignoreTargetLocaleValueMismatch ? targetLocaleValue : void 0
574
578
  }
575
579
  };
576
580
  });
@@ -586,7 +590,8 @@ var collectFromNode = ({
586
590
  node: slotComponent,
587
591
  // keep tree structure for `Slot Sections`
588
592
  // to store whole `override` content in scope of current component
589
- deep: true
593
+ deep: true,
594
+ config
590
595
  });
591
596
  const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
592
597
  if (hasContent) {
package/dist/index.js CHANGED
@@ -337,7 +337,7 @@ var processParameterTranslation = ({
337
337
  left: originalParameterSource,
338
338
  right: sourceValue
339
339
  });
340
- const isTargetValueUntouched = isSameParameterValue({
340
+ const isTargetValueUntouched = originalTargetValue === void 0 ? true : isSameParameterValue({
341
341
  parameterType: originalParameter.type,
342
342
  left: (_d = originalParameter.locales) == null ? void 0 : _d[uniformTargetLocale],
343
343
  right: originalTargetValue
@@ -481,7 +481,8 @@ var collectTranslationPayload = ({
481
481
  uniformReleaseId,
482
482
  targetLang,
483
483
  entity,
484
- entityType
484
+ entityType,
485
+ config = {}
485
486
  }) => {
486
487
  if (!uniformSourceLocale || !uniformTargetLocale || !targetLang || !entity) {
487
488
  return createErrorResult2("invalid-args");
@@ -514,7 +515,8 @@ var collectTranslationPayload = ({
514
515
  uniformSourceLocale,
515
516
  uniformTargetLocale,
516
517
  node,
517
- deep: false
518
+ deep: false,
519
+ config
518
520
  });
519
521
  if (parameters || _overrides) {
520
522
  payload.components[node._id] = {
@@ -531,7 +533,8 @@ var collectFromNode = ({
531
533
  uniformSourceLocale,
532
534
  uniformTargetLocale,
533
535
  node,
534
- deep
536
+ deep,
537
+ config
535
538
  }) => {
536
539
  var _a, _b, _c;
537
540
  const collectedParameters = {};
@@ -546,7 +549,7 @@ var collectFromNode = ({
546
549
  if (!canTranslateParameterValue(param, sourceLocaleValue)) {
547
550
  return;
548
551
  }
549
- if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
552
+ if (!config.ignoreTargetLocaleValueMismatch && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
550
553
  return;
551
554
  }
552
555
  collectedParameters[paramKey] = {
@@ -554,7 +557,7 @@ var collectFromNode = ({
554
557
  locales: {
555
558
  [TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
556
559
  [TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
557
- [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
560
+ [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: !config.ignoreTargetLocaleValueMismatch ? targetLocaleValue : void 0
558
561
  }
559
562
  };
560
563
  });
@@ -569,7 +572,8 @@ var collectFromNode = ({
569
572
  uniformSourceLocale,
570
573
  uniformTargetLocale,
571
574
  node: slotComponent,
572
- deep: true
575
+ deep: true,
576
+ config
573
577
  });
574
578
  const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
575
579
  if (hasContent) {
@@ -588,7 +592,7 @@ var collectFromNode = ({
588
592
  if (!canTranslateParameterValue(param, sourceLocaleValue)) {
589
593
  return;
590
594
  }
591
- if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
595
+ if (!config.ignoreTargetLocaleValueMismatch && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
592
596
  return;
593
597
  }
594
598
  (_c2 = collectedOverrides[overrideKey]) != null ? _c2 : collectedOverrides[overrideKey] = {};
@@ -598,7 +602,7 @@ var collectFromNode = ({
598
602
  locales: {
599
603
  [TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
600
604
  [TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
601
- [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
605
+ [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: !config.ignoreTargetLocaleValueMismatch ? targetLocaleValue : void 0
602
606
  }
603
607
  };
604
608
  });
@@ -614,7 +618,8 @@ var collectFromNode = ({
614
618
  node: slotComponent,
615
619
  // keep tree structure for `Slot Sections`
616
620
  // to store whole `override` content in scope of current component
617
- deep: true
621
+ deep: true,
622
+ config
618
623
  });
619
624
  const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
620
625
  if (hasContent) {
package/dist/index.mjs CHANGED
@@ -309,7 +309,7 @@ var processParameterTranslation = ({
309
309
  left: originalParameterSource,
310
310
  right: sourceValue
311
311
  });
312
- const isTargetValueUntouched = isSameParameterValue({
312
+ const isTargetValueUntouched = originalTargetValue === void 0 ? true : isSameParameterValue({
313
313
  parameterType: originalParameter.type,
314
314
  left: (_d = originalParameter.locales) == null ? void 0 : _d[uniformTargetLocale],
315
315
  right: originalTargetValue
@@ -453,7 +453,8 @@ var collectTranslationPayload = ({
453
453
  uniformReleaseId,
454
454
  targetLang,
455
455
  entity,
456
- entityType
456
+ entityType,
457
+ config = {}
457
458
  }) => {
458
459
  if (!uniformSourceLocale || !uniformTargetLocale || !targetLang || !entity) {
459
460
  return createErrorResult2("invalid-args");
@@ -486,7 +487,8 @@ var collectTranslationPayload = ({
486
487
  uniformSourceLocale,
487
488
  uniformTargetLocale,
488
489
  node,
489
- deep: false
490
+ deep: false,
491
+ config
490
492
  });
491
493
  if (parameters || _overrides) {
492
494
  payload.components[node._id] = {
@@ -503,7 +505,8 @@ var collectFromNode = ({
503
505
  uniformSourceLocale,
504
506
  uniformTargetLocale,
505
507
  node,
506
- deep
508
+ deep,
509
+ config
507
510
  }) => {
508
511
  var _a, _b, _c;
509
512
  const collectedParameters = {};
@@ -518,7 +521,7 @@ var collectFromNode = ({
518
521
  if (!canTranslateParameterValue(param, sourceLocaleValue)) {
519
522
  return;
520
523
  }
521
- if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
524
+ if (!config.ignoreTargetLocaleValueMismatch && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
522
525
  return;
523
526
  }
524
527
  collectedParameters[paramKey] = {
@@ -526,7 +529,7 @@ var collectFromNode = ({
526
529
  locales: {
527
530
  [TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
528
531
  [TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
529
- [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
532
+ [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: !config.ignoreTargetLocaleValueMismatch ? targetLocaleValue : void 0
530
533
  }
531
534
  };
532
535
  });
@@ -541,7 +544,8 @@ var collectFromNode = ({
541
544
  uniformSourceLocale,
542
545
  uniformTargetLocale,
543
546
  node: slotComponent,
544
- deep: true
547
+ deep: true,
548
+ config
545
549
  });
546
550
  const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
547
551
  if (hasContent) {
@@ -560,7 +564,7 @@ var collectFromNode = ({
560
564
  if (!canTranslateParameterValue(param, sourceLocaleValue)) {
561
565
  return;
562
566
  }
563
- if (!isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
567
+ if (!config.ignoreTargetLocaleValueMismatch && !isTargetLocaleUntouched(param.type, sourceLocaleValue, targetLocaleValue)) {
564
568
  return;
565
569
  }
566
570
  (_c2 = collectedOverrides[overrideKey]) != null ? _c2 : collectedOverrides[overrideKey] = {};
@@ -570,7 +574,7 @@ var collectFromNode = ({
570
574
  locales: {
571
575
  [TRANSLATION_PAYLOAD_SOURCE_KEY]: sourceLocaleValue,
572
576
  [TRANSLATION_PAYLOAD_TARGET_KEY]: preprocessTargetValue(param, sourceLocaleValue),
573
- [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: targetLocaleValue
577
+ [TRANSLATION_PAYLOAD_ORIGINAL_TARGET_KEY]: !config.ignoreTargetLocaleValueMismatch ? targetLocaleValue : void 0
574
578
  }
575
579
  };
576
580
  });
@@ -586,7 +590,8 @@ var collectFromNode = ({
586
590
  node: slotComponent,
587
591
  // keep tree structure for `Slot Sections`
588
592
  // to store whole `override` content in scope of current component
589
- deep: true
593
+ deep: true,
594
+ config
590
595
  });
591
596
  const hasContent = collectedNode.parameters || collectedNode._overrides || collectedNode.slots;
592
597
  if (hasContent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/tms-sdk",
3
- "version": "20.58.0",
3
+ "version": "20.59.1-alpha.1+7025e4ce05",
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": "20.58.0",
37
- "@uniformdev/mesh-sdk": "20.58.0",
38
- "@uniformdev/richtext": "20.58.0",
36
+ "@uniformdev/canvas": "20.59.1-alpha.1+7025e4ce05",
37
+ "@uniformdev/mesh-sdk": "20.59.1-alpha.1+7025e4ce05",
38
+ "@uniformdev/richtext": "20.59.1-alpha.1+7025e4ce05",
39
39
  "dequal": "2.0.3",
40
40
  "fast-xml-parser": "4.4.1",
41
41
  "immer": "10.1.3"
42
42
  },
43
- "gitHead": "26c7029ee6b30b8faed688c8b348a1c768b2e94b"
43
+ "gitHead": "7025e4ce052f67d73c0ee93cbf56104262cf190d"
44
44
  }