@capillarytech/creatives-library 9.0.38 → 9.0.39

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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/translations/en.json +2 -2
  3. package/utils/permissions.js +59 -0
  4. package/utils/tests/permissions.test.js +116 -0
  5. package/v2Components/AccessForbidden/_accessForbidden.scss +14 -0
  6. package/v2Components/AccessForbidden/index.js +5 -3
  7. package/v2Components/AccessForbidden/messages.js +3 -2
  8. package/v2Components/NoPermissionWrapper/_noPermissionWrapper.scss +12 -0
  9. package/v2Components/NoPermissionWrapper/index.js +26 -0
  10. package/v2Containers/App/constants.js +5 -0
  11. package/v2Containers/Assets/Gallery/_gallery.scss +6 -0
  12. package/v2Containers/Assets/Gallery/index.js +34 -10
  13. package/v2Containers/Cap/index.js +5 -2
  14. package/v2Containers/Cap/messages.js +4 -0
  15. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +2 -2
  16. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +6 -6
  17. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +4 -4
  18. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +32 -32
  19. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +36 -36
  20. package/v2Containers/Rcs/carouselUtils.js +46 -73
  21. package/v2Containers/Rcs/components/CarouselCard.js +6 -9
  22. package/v2Containers/Rcs/constants.js +2 -7
  23. package/v2Containers/Rcs/index.js +72 -126
  24. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +5 -42
  25. package/v2Containers/Rcs/tests/CarouselCard.test.js +1 -2
  26. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +118 -118
  27. package/v2Containers/Rcs/tests/carouselUtils.test.js +15 -15
  28. package/v2Containers/Rcs/tests/index.test.js +10 -232
  29. package/v2Containers/Rcs/tests/utils.test.js +0 -17
  30. package/v2Containers/Rcs/utils.js +12 -51
  31. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +8 -8
  32. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +18 -18
  33. package/v2Containers/Templates/ChannelTypeIllustration.js +13 -2
  34. package/v2Containers/Templates/_templates.scss +6 -0
  35. package/v2Containers/Templates/index.js +141 -100
  36. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +1 -1
  37. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +174 -121
  38. package/v2Containers/TemplatesV2/index.js +16 -5
  39. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +268 -268
@@ -585,8 +585,8 @@ describe('buildCarouselCardsForPreview', () => {
585
585
  expect(out[0].bodyText).toBe('Bye {{b}}');
586
586
  });
587
587
 
588
- it('resolves title/description through resolveCarouselTemplateWithMap, scoped per card index and field', () => {
589
- const resolveCarouselTemplateWithMap = jest.fn((str, cardIndex, isDescField) => `R(${str}|${cardIndex}|${isDescField})`);
588
+ it('resolves title/description through resolveCarouselTemplateWithMap, scoped per card index', () => {
589
+ const resolveCarouselTemplateWithMap = jest.fn((str, cardIndex) => `R(${str}|${cardIndex})`);
590
590
  const out = buildCarouselCardsForPreview(
591
591
  [
592
592
  { title: 'Hi {{a}}', description: 'Bye {{b}} {{c}}' },
@@ -594,14 +594,14 @@ describe('buildCarouselCardsForPreview', () => {
594
594
  ],
595
595
  { isFullMode: false, resolveCarouselTemplateWithMap },
596
596
  );
597
- expect(resolveCarouselTemplateWithMap).toHaveBeenNthCalledWith(1, 'Hi {{a}}', 0, false);
598
- expect(resolveCarouselTemplateWithMap).toHaveBeenNthCalledWith(2, 'Bye {{b}} {{c}}', 0, true);
599
- expect(resolveCarouselTemplateWithMap).toHaveBeenNthCalledWith(3, 'Solo {{d}}', 1, false);
600
- expect(resolveCarouselTemplateWithMap).toHaveBeenNthCalledWith(4, 'none', 1, true);
601
- expect(out[0].title).toBe('R(Hi {{a}}|0|false)');
602
- expect(out[0].bodyText).toBe('R(Bye {{b}} {{c}}|0|true)');
603
- expect(out[1].title).toBe('R(Solo {{d}}|1|false)');
604
- expect(out[1].bodyText).toBe('R(none|1|true)');
597
+ expect(resolveCarouselTemplateWithMap).toHaveBeenNthCalledWith(1, 'Hi {{a}}', 0);
598
+ expect(resolveCarouselTemplateWithMap).toHaveBeenNthCalledWith(2, 'Bye {{b}} {{c}}', 0);
599
+ expect(resolveCarouselTemplateWithMap).toHaveBeenNthCalledWith(3, 'Solo {{d}}', 1);
600
+ expect(resolveCarouselTemplateWithMap).toHaveBeenNthCalledWith(4, 'none', 1);
601
+ expect(out[0].title).toBe('R(Hi {{a}}|0)');
602
+ expect(out[0].bodyText).toBe('R(Bye {{b}} {{c}}|0)');
603
+ expect(out[1].title).toBe('R(Solo {{d}}|1)');
604
+ expect(out[1].bodyText).toBe('R(none|1)');
605
605
  });
606
606
 
607
607
  it('defaults missing card fields, including a default {} for a missing array item', () => {
@@ -853,17 +853,17 @@ describe('buildCarouselCardContentForPayload', () => {
853
853
  expect(out[0].cardVarMapped).toBeUndefined();
854
854
  });
855
855
 
856
- it('builds cardVarMapped from title and description tokens, keyed by global position, sanitizing values', () => {
856
+ it('builds cardVarMapped from title and description tokens, sanitizing values', () => {
857
857
  const out = buildCarouselCardContentForPayload(
858
858
  [{ title: 'Hi {{name}}', description: 'Pts {{points}}', mediaType: RCS_MEDIA_TYPES.NONE }],
859
859
  {
860
860
  isSlotMappingMode: true,
861
- cardVarMapped: { 1: 'Bob', 2: '{{2}}' },
861
+ cardVarMapped: { name: 'Bob', points: '{{2}}' },
862
862
  selectedCarouselHeight: 'SHORT',
863
863
  rcsVarRegex,
864
864
  },
865
865
  );
866
- expect(out[0].cardVarMapped).toEqual({ 1: 'Bob', 2: '' });
866
+ expect(out[0].cardVarMapped).toEqual({ name: 'Bob', points: '' });
867
867
  });
868
868
 
869
869
  it('defaults an unmapped token value to empty string via sanitizeCardVarMappedValue', () => {
@@ -871,7 +871,7 @@ describe('buildCarouselCardContentForPayload', () => {
871
871
  [{ title: 'Hi {{missing}}', description: 'D', mediaType: RCS_MEDIA_TYPES.NONE }],
872
872
  { isSlotMappingMode: true, cardVarMapped: {}, selectedCarouselHeight: 'SHORT', rcsVarRegex },
873
873
  );
874
- expect(out[0].cardVarMapped).toEqual({ 1: '' });
874
+ expect(out[0].cardVarMapped).toEqual({ missing: '' });
875
875
  });
876
876
 
877
877
  it('handles a missing cardVarMapped object entirely', () => {
@@ -879,7 +879,7 @@ describe('buildCarouselCardContentForPayload', () => {
879
879
  [{ title: 'Hi {{name}}', description: 'D', mediaType: RCS_MEDIA_TYPES.NONE }],
880
880
  { isSlotMappingMode: true, cardVarMapped: undefined, selectedCarouselHeight: 'SHORT', rcsVarRegex },
881
881
  );
882
- expect(out[0].cardVarMapped).toEqual({ 1: '' });
882
+ expect(out[0].cardVarMapped).toEqual({ name: '' });
883
883
  });
884
884
 
885
885
  it('skips a matched token that strips down to an empty variable name', () => {
@@ -475,7 +475,7 @@ describe('Creatives rcs test/>', () => {
475
475
  });
476
476
 
477
477
  describe('RCS carousel label resolution in non-full mode', () => {
478
- it('keeps every carousel variable slot independent, even when they share a literal tag name, in both inline preview and Test&Preview slidebox', async () => {
478
+ it('keeps each carousel card\'s same-named variable independently scoped in both inline preview and Test&Preview slidebox', async () => {
479
479
  const templateData = {
480
480
  name: 'CarouselVarsTemplate',
481
481
  versions: {
@@ -564,10 +564,8 @@ describe('RCS carousel label resolution in non-full mode', () => {
564
564
  return id.includes('{{name}}_') || key.includes('{{name}}_');
565
565
  });
566
566
 
567
- // Card 0 has two `{{name}}` occurrences — title's, then description's, in DOM order — and
568
- // each is now its own independent slot despite sharing the literal name.
569
567
  const card0NameAreas = nameVarAreaForCard(0);
570
- expect(card0NameAreas.length).toBe(2);
568
+ expect(card0NameAreas.length).toBeGreaterThanOrEqual(1);
571
569
 
572
570
  act(() => {
573
571
  const slotId = card0NameAreas.at(0).prop('id') || card0NameAreas.at(0).key();
@@ -575,264 +573,44 @@ describe('RCS carousel label resolution in non-full mode', () => {
575
573
  });
576
574
  wrapper.update();
577
575
 
578
- // Only the title resolvesdescription's own `{{name}}` slot is untouched (independent slot).
576
+ // Inline preview should resolve card 0 only card 1's own `{{name}}` slot is untouched.
579
577
  const updatedInlinePreview = wrapper.find('UnifiedPreview').filterWhere((n) => n.prop('content')?.carouselData).at(0);
580
578
  const inlineCards = updatedInlinePreview.props().content.carouselData;
581
579
  expect(inlineCards[0].title).toBe('Hi madhavi');
582
- expect(inlineCards[0].bodyText).toBe('Welcome {{name}}');
580
+ expect(inlineCards[0].bodyText).toBe('Welcome madhavi');
583
581
  expect(inlineCards[1].title).toBe('Offer for {{name}}');
584
582
  expect(inlineCards[1].bodyText).toBe('Dear {{name}}');
585
583
 
586
- // Filling card 0's description slot separately resolves it without disturbing the title.
587
- act(() => {
588
- const descSlotId = nameVarAreaForCard(0).at(1).prop('id') || nameVarAreaForCard(0).at(1).key();
589
- nameVarAreaForCard(0).at(1).props().onChange({ target: { id: descSlotId, value: 'lakshmi' } });
590
- });
591
- wrapper.update();
592
-
593
- const afterDescInlinePreview = wrapper.find('UnifiedPreview').filterWhere((n) => n.prop('content')?.carouselData).at(0);
594
- const afterDescInlineCards = afterDescInlinePreview.props().content.carouselData;
595
- expect(afterDescInlineCards[0].title).toBe('Hi madhavi');
596
- expect(afterDescInlineCards[0].bodyText).toBe('Welcome lakshmi');
597
-
598
- // Slidebox content should mirror the same independent-slot resolution.
584
+ // Slidebox content should mirror the same per-card scoping (same underlying mapping)
599
585
  const slidebox = wrapper.find('TestAndPreviewSlidebox').at(0);
600
586
  expect(slidebox.exists()).toBe(true);
601
587
  const slideboxContent = slidebox.props().content;
602
588
  expect(slideboxContent?.carouselData?.length).toBeGreaterThanOrEqual(2);
603
589
  expect(slideboxContent.carouselData[0].title).toBe('Hi madhavi');
604
- expect(slideboxContent.carouselData[0].bodyText).toBe('Welcome lakshmi');
590
+ expect(slideboxContent.carouselData[0].bodyText).toBe('Welcome madhavi');
605
591
  expect(slideboxContent.carouselData[1].title).toBe('Offer for {{name}}');
606
592
  expect(slideboxContent.carouselData[1].bodyText).toBe('Dear {{name}}');
607
593
 
608
- // Setting card 1's own `{{name}}` slots independently resolves card 1 without disturbing card 0.
594
+ // Setting card 1's own `{{name}}` slot independently resolves card 1 without disturbing card 0.
609
595
  // Inactive tab panes aren't mounted until switched to, so activate card 1's tab first.
610
596
  act(() => {
611
597
  wrapper.find('CapTab').prop('onChange')('1');
612
598
  });
613
599
  wrapper.update();
614
600
  const card1NameAreas = nameVarAreaForCard(1);
615
- expect(card1NameAreas.length).toBe(2);
601
+ expect(card1NameAreas.length).toBeGreaterThanOrEqual(1);
616
602
  act(() => {
617
603
  const slotId = card1NameAreas.at(0).prop('id') || card1NameAreas.at(0).key();
618
604
  card1NameAreas.at(0).props().onChange({ target: { id: slotId, value: 'raghav' } });
619
605
  });
620
606
  wrapper.update();
621
- act(() => {
622
- const descSlotId = nameVarAreaForCard(1).at(1).prop('id') || nameVarAreaForCard(1).at(1).key();
623
- nameVarAreaForCard(1).at(1).props().onChange({ target: { id: descSlotId, value: 'suresh' } });
624
- });
625
- wrapper.update();
626
607
 
627
608
  const finalInlinePreview = wrapper.find('UnifiedPreview').filterWhere((n) => n.prop('content')?.carouselData).at(0);
628
609
  const finalInlineCards = finalInlinePreview.props().content.carouselData;
629
610
  expect(finalInlineCards[0].title).toBe('Hi madhavi');
630
- expect(finalInlineCards[0].bodyText).toBe('Welcome lakshmi');
611
+ expect(finalInlineCards[0].bodyText).toBe('Welcome madhavi');
631
612
  expect(finalInlineCards[1].title).toBe('Offer for raghav');
632
- expect(finalInlineCards[1].bodyText).toBe('Dear suresh');
633
- });
634
-
635
- it('picking a tag from "Add Labels" for card 2\'s description (a bare semantic token with no numeric backing) shows the value live, without touching card 2\'s title slot', async () => {
636
- const templateData = {
637
- name: 'CarouselTagPickTemplate',
638
- versions: {
639
- base: {
640
- content: {
641
- RCS: {
642
- rcsContent: {
643
- cardType: 'CAROUSEL',
644
- cardSettings: { cardOrientation: 'VERTICAL', cardWidth: 'SMALL' },
645
- cardContent: [
646
- {
647
- title: 'Hi {{name}}',
648
- description: 'Welcome {{name}}',
649
- mediaType: 'IMAGE',
650
- media: { mediaUrl: 'https://cdn.example.com/c1.png', height: 'MEDIUM' },
651
- cardVarMapped: {},
652
- suggestions: [],
653
- },
654
- {
655
- title: 'sdvsdvs {{first_name_capital}}',
656
- description: 'dssdfv {{adv}}',
657
- mediaType: 'IMAGE',
658
- media: { mediaUrl: 'https://cdn.example.com/c2.png', height: 'MEDIUM' },
659
- cardVarMapped: {},
660
- suggestions: [],
661
- },
662
- ],
663
- contentType: 'RICHCARD',
664
- },
665
- },
666
- },
667
- },
668
- },
669
- type: 'RCS',
670
- };
671
-
672
- const wrapper = mountWithIntl(
673
- <Provider store={store}>
674
- <Rcs
675
- actions={{
676
- uploadRcsAsset,
677
- clearRcsMediaAsset,
678
- createTemplate,
679
- clearCreateResponse,
680
- getTemplateDetails,
681
- editTemplate,
682
- clearEditResponse,
683
- }}
684
- globalActions={{ fetchSchemaForEntity }}
685
- onCreateComplete={onCreateComplete}
686
- handleClose={handleClose}
687
- intl={{ formatMessage }}
688
- location={{ pathname: '/rcs/edit', query: { type: false, module: 'default' }, search: '' }}
689
- params={params}
690
- templateData={templateData}
691
- rcsData={{}}
692
- isFullMode={false}
693
- isEditFlow={false}
694
- loadingTags={false}
695
- metaEntities={[]}
696
- isDltEnabled={false}
697
- smsRegister={'DLT'}
698
- />
699
- </Provider>,
700
- );
701
-
702
- // Flush hydration useEffects
703
- await act(async () => {
704
- await Promise.resolve();
705
- });
706
- wrapper.update();
707
-
708
- // Card 2 is inactive until switched to.
709
- act(() => {
710
- wrapper.find('CapTab').prop('onChange')('1');
711
- });
712
- wrapper.update();
713
-
714
- const card2 = wrapper.find('CarouselCard').filterWhere((n) => n.prop('cardIndex') === 1);
715
-
716
- const descVarArea = card2
717
- .find('CapInputTextArea')
718
- .filterWhere((n) => String(n.prop('id') || '').includes('{{adv}}_'));
719
- expect(descVarArea.length).toBeGreaterThanOrEqual(1);
720
-
721
- // Focus card 2's description var slot, exactly like a user clicking into that box.
722
- act(() => {
723
- const id = descVarArea.at(0).prop('id');
724
- descVarArea.at(0).props().onFocus({ target: { id } });
725
- });
726
- wrapper.update();
727
-
728
- // Card 2's description TagList (the second .tag-mock under this card) picks "adv".
729
- const card2AfterFocus = wrapper.find('CarouselCard').filterWhere((n) => n.prop('cardIndex') === 1);
730
- const descTagList = card2AfterFocus.find('.tag-mock').at(1);
731
- act(() => {
732
- descTagList.props().onTagSelect('adv');
733
- });
734
- wrapper.update();
735
-
736
- // Live (no save/reload) — the description's own box should now show the picked tag as its value.
737
- const card2Final = wrapper.find('CarouselCard').filterWhere((n) => n.prop('cardIndex') === 1);
738
- const descVarAreaAfterPick = card2Final
739
- .find('CapInputTextArea')
740
- .filterWhere((n) => String(n.prop('id') || '').includes('{{adv}}_'));
741
- expect(descVarAreaAfterPick.at(0).prop('value')).toBe('{{adv}}');
742
-
743
- // Title's own slot must be untouched by the description's tag pick.
744
- const titleVarAreaAfterPick = card2Final
745
- .find('CapInputTextArea')
746
- .filterWhere((n) => String(n.prop('id') || '').includes('{{first_name_capital}}_'));
747
- expect(titleVarAreaAfterPick.at(0).prop('value')).toBe('');
748
- });
749
-
750
- it('reopening a carousel after a prior save shows card 2\'s description value (persisted under its global positional key), not empty', async () => {
751
- // Shape of a template that was already saved once: card 2 (index 1) picked "adv" for its
752
- // description slot in an earlier session. Card 0 has 2 var tokens (title + desc), so card 2's
753
- // title is global position 3 and its description is global position 4 — key "4".
754
- const templateData = {
755
- name: 'CarouselReopenTemplate',
756
- versions: {
757
- base: {
758
- content: {
759
- RCS: {
760
- rcsContent: {
761
- cardType: 'CAROUSEL',
762
- cardSettings: { cardOrientation: 'VERTICAL', cardWidth: 'SMALL' },
763
- cardContent: [
764
- {
765
- title: 'Hi {{name}}',
766
- description: 'Welcome {{name}}',
767
- mediaType: 'IMAGE',
768
- media: { mediaUrl: 'https://cdn.example.com/c1.png', height: 'MEDIUM' },
769
- cardVarMapped: {},
770
- suggestions: [],
771
- },
772
- {
773
- title: 'sdvsdvs {{first_name_capital}}',
774
- description: 'dssdfv {{adv}}',
775
- mediaType: 'IMAGE',
776
- media: { mediaUrl: 'https://cdn.example.com/c2.png', height: 'MEDIUM' },
777
- cardVarMapped: { '4': '{{adv}}' },
778
- suggestions: [],
779
- },
780
- ],
781
- contentType: 'RICHCARD',
782
- },
783
- },
784
- },
785
- },
786
- },
787
- type: 'RCS',
788
- };
789
-
790
- const wrapper = mountWithIntl(
791
- <Provider store={store}>
792
- <Rcs
793
- actions={{
794
- uploadRcsAsset,
795
- clearRcsMediaAsset,
796
- createTemplate,
797
- clearCreateResponse,
798
- getTemplateDetails,
799
- editTemplate,
800
- clearEditResponse,
801
- }}
802
- globalActions={{ fetchSchemaForEntity }}
803
- onCreateComplete={onCreateComplete}
804
- handleClose={handleClose}
805
- intl={{ formatMessage }}
806
- location={{ pathname: '/rcs/edit', query: { type: false, module: 'default' }, search: '' }}
807
- params={params}
808
- templateData={templateData}
809
- rcsData={{}}
810
- isFullMode={false}
811
- isEditFlow={false}
812
- loadingTags={false}
813
- metaEntities={[]}
814
- isDltEnabled={false}
815
- smsRegister={'DLT'}
816
- />
817
- </Provider>,
818
- );
819
-
820
- await act(async () => {
821
- await Promise.resolve();
822
- });
823
- wrapper.update();
824
-
825
- act(() => {
826
- wrapper.find('CapTab').prop('onChange')('1');
827
- });
828
- wrapper.update();
829
-
830
- const card2 = wrapper.find('CarouselCard').filterWhere((n) => n.prop('cardIndex') === 1);
831
- const descVarArea = card2
832
- .find('CapInputTextArea')
833
- .filterWhere((n) => String(n.prop('id') || '').includes('{{adv}}_'));
834
- expect(descVarArea.length).toBeGreaterThanOrEqual(1);
835
- expect(descVarArea.at(0).prop('value')).toBe('{{adv}}');
613
+ expect(finalInlineCards[1].bodyText).toBe('Dear raghav');
836
614
  });
837
615
  });
838
616
 
@@ -669,23 +669,6 @@ describe('RCS utils', () => {
669
669
  expect(out[0].description).toBe('This is Bird with colorful feathers {{voucher(1190738)}}');
670
670
  });
671
671
 
672
- it('substitutes plain text typed into a numeric personalization slot (not a tag pick)', () => {
673
- const out = mapRcsCardContentForConsumerWithResolvedTags(
674
- [
675
- {
676
- title: 'Hello {{1}}',
677
- description: 'Visit us at {{2}} today',
678
- mediaType: 'IMAGE',
679
- cardVarMapped: { 1: 'World', 2: 'Downtown Store' },
680
- },
681
- ],
682
- {},
683
- false,
684
- );
685
- expect(out[0].title).toBe('Hello World');
686
- expect(out[0].description).toBe('Visit us at Downtown Store today');
687
- });
688
-
689
672
  it('BUG REPRO: 2-card carousel — card 1 description resolves to card 0\'s value instead of its own tag pick', () => {
690
673
  // Mirrors CreativesContainer/index.js ~1448-1461: rootRcsCardVarMapped is derived ONLY from
691
674
  // cardContentFromSubmit[0] (the FIRST card's own cardVarMapped) and reused for every card.
@@ -197,50 +197,6 @@ export function coalesceCardVarMappedToTemplate(
197
197
  templateVarTokens.forEach((token, slotIndexZeroBased) => {
198
198
  const semanticVarName = getVarNameFromToken(token);
199
199
  if (!semanticVarName) return;
200
-
201
- if (RCS_NUMERIC_VAR_NAME_REGEX.test(semanticVarName)) {
202
- // Carousel numeric placeholder ({{3}}, {{4}}, …): the slot key IS the token digit itself —
203
- // numbers are allocated globally across the whole carousel (getNextCarouselVarToken), not
204
- // re-numbered per card, so the position-based `slotIndexZeroBased + 1` key below would target
205
- // the wrong slot for every card after the first (e.g. card 2's first token is digit "3", not "1").
206
- const numericSlotKey = semanticVarName;
207
- const trimmedSlotValue = String(lookupSourceMap[numericSlotKey] ?? '').trim();
208
- coalescedMap[numericSlotKey] = trimmedSlotValue;
209
- // The slot's value may itself be a mustache-wrapped tag reference (e.g. "3" -> "{{last_name}}")
210
- // — mirror it onto the bare semantic key too so VarSegment editors keyed by tag name also
211
- // prepopulate (same rule as syncCardVarMappedSemanticsFromSlots).
212
- const mustacheInnerMatch = trimmedSlotValue.match(/^\{\{([^}]+)\}\}$/);
213
- const innerSemanticName = mustacheInnerMatch?.[1]?.trim();
214
- if (innerSemanticName && innerSemanticName !== numericSlotKey) {
215
- const existingInnerValue = String(coalescedMap[innerSemanticName] ?? '').trim();
216
- if (!existingInnerValue) {
217
- coalescedMap[innerSemanticName] = trimmedSlotValue;
218
- }
219
- }
220
- return;
221
- }
222
-
223
- // A numeric slot may already self-reference this exact tag (e.g. "4" -> "{{last_name}}") when
224
- // the template's own numeric placeholder has since been resolved to this tag in the text (see
225
- // mapRcsCardContentForConsumerWithResolvedTags). That numeric key is the source of truth — don't
226
- // fall through to the position-based legacy lookup below, which targets an unrelated (or
227
- // nonexistent) slot and would clobber the real value with an empty string.
228
- const mustacheSelfReference = `{{${semanticVarName}}}`;
229
- const existingNumericKeyForSemantic = Object.keys(lookupSourceMap).find((key) => (
230
- RCS_NUMERIC_VAR_NAME_REGEX.test(key) && lookupSourceMap[key] === mustacheSelfReference
231
- ));
232
- if (existingNumericKeyForSemantic) {
233
- const trimmedSlotValue = String(lookupSourceMap[existingNumericKeyForSemantic] ?? '').trim();
234
- coalescedMap[existingNumericKeyForSemantic] = trimmedSlotValue;
235
- if (!seenSemanticVarNames.has(semanticVarName)) {
236
- seenSemanticVarNames.add(semanticVarName);
237
- coalescedMap[semanticVarName] = trimmedSlotValue;
238
- }
239
- return;
240
- }
241
-
242
- // Legacy: template embeds the semantic token directly ({{user_name}}); older payloads stored
243
- // the resolved value under a position-based numeric key ("1", "2", …) by order of appearance.
244
200
  const numericSlotKey = String(slotIndexZeroBased + 1);
245
201
  const isRepeatOfSemanticName = seenSemanticVarNames.has(semanticVarName);
246
202
  const skipSharedSemanticLookup =
@@ -251,6 +207,12 @@ export function coalesceCardVarMappedToTemplate(
251
207
  valueFromSource = lookupSourceMap[semanticVarName];
252
208
  }
253
209
  }
210
+ if (valueFromSource === undefined || valueFromSource === null) {
211
+ valueFromSource = lookupSourceMap[String(slotIndexZeroBased + 1)];
212
+ }
213
+ if (valueFromSource === undefined || valueFromSource === null) {
214
+ valueFromSource = lookupSourceMap[slotIndexZeroBased + 1];
215
+ }
254
216
  const trimmedSlotValue = valueFromSource == null ? '' : String(valueFromSource).trim();
255
217
  coalescedMap[numericSlotKey] = trimmedSlotValue;
256
218
  if (!seenSemanticVarNames.has(semanticVarName)) {
@@ -329,6 +291,11 @@ export function isRcsTextOnlyCardMediaType(mediaType) {
329
291
  *
330
292
  * @param {boolean} [preserveLiteralValueTokens=false] When true, a slot value that is NOT itself a
331
293
  * `{{...}}`-wrapped tag (e.g. a literal preview string like "SAVE20" typed for a voucher/offer tag)
294
+ * is left as the raw token instead of being baked into the returned string. Personalization-style
295
+ * values (themselves another mustache tag, e.g. `{{loyalty_points}}`) still resolve either way — those
296
+ * are internal-alias renames, not literal content. Pass true for payloads that get persisted/replayed
297
+ * (see `mapRcsCardContentForConsumerWithResolvedTags`) so a voucher's saved token survives for the
298
+ * editor to re-render an editable slot from, and for the backend to resolve per-recipient at send time.
332
299
  *
333
300
  * @param {number} [cardSlotOffset=0] Starting global slot index for this card's title. Carousel cards
334
301
  * beyond index 0 must pass the running total of every prior card's var count — numeric `{{N}}` tokens
@@ -372,12 +339,7 @@ export function resolveRcsCardPreviewStrings(
372
339
  );
373
340
  if (slotValue == null || String(slotValue).trim() === '') return elem;
374
341
  const trimmedSlotValue = String(slotValue).trim();
375
- const isPlainNumericSlot = RCS_NUMERIC_VAR_NAME_REGEX.test(key);
376
- if (
377
- preserveLiteralValueTokens
378
- && !isPlainNumericSlot
379
- && !RCS_MUSTACHE_WRAPPED_REGEX.test(trimmedSlotValue)
380
- ) {
342
+ if (preserveLiteralValueTokens && !RCS_MUSTACHE_WRAPPED_REGEX.test(trimmedSlotValue)) {
381
343
  return elem;
382
344
  }
383
345
  return String(slotValue);
@@ -441,7 +403,6 @@ export function mapRcsCardContentForConsumerWithResolvedTags(
441
403
  const descVarCount = (String(cardDescription).match(rcsVarRegex) || []).length;
442
404
  carouselSlotOffset += titleVarCount + descVarCount;
443
405
  const { cardVarMapped: _drop, ...cardRest } = card;
444
-
445
406
  return {
446
407
  ...cardRest,
447
408
  title: rcsTitle,
@@ -112,8 +112,8 @@ exports[`Creatives SmsTraiCreate test/> done button should be disabled if blank
112
112
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
113
113
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
114
114
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
115
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
116
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
115
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
116
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
117
117
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
118
118
  "creatives.components.CapTagList.Cancel": "Cancel",
119
119
  "creatives.components.CapTagList.Ok": "Ok",
@@ -3273,8 +3273,8 @@ exports[`Creatives SmsTraiCreate test/> invalid file drop 1`] = `
3273
3273
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
3274
3274
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
3275
3275
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
3276
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
3277
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
3276
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
3277
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
3278
3278
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
3279
3279
  "creatives.components.CapTagList.Cancel": "Cancel",
3280
3280
  "creatives.components.CapTagList.Ok": "Ok",
@@ -6417,8 +6417,8 @@ exports[`Creatives SmsTraiCreate test/> renders UI 1`] = `
6417
6417
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
6418
6418
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
6419
6419
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
6420
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
6421
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
6420
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
6421
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
6422
6422
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
6423
6423
  "creatives.components.CapTagList.Cancel": "Cancel",
6424
6424
  "creatives.components.CapTagList.Ok": "Ok",
@@ -9578,8 +9578,8 @@ exports[`Creatives SmsTraiCreate test/> valid file drop 1`] = `
9578
9578
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
9579
9579
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
9580
9580
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
9581
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
9582
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
9581
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
9582
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
9583
9583
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
9584
9584
  "creatives.components.CapTagList.Cancel": "Cancel",
9585
9585
  "creatives.components.CapTagList.Ok": "Ok",
@@ -87,8 +87,8 @@ exports[`Creatives SmsTraiEdit test/> should render 1`] = `
87
87
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
88
88
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
89
89
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
90
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
91
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
90
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
91
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
92
92
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
93
93
  "creatives.components.CapTagList.Cancel": "Cancel",
94
94
  "creatives.components.CapTagList.Ok": "Ok",
@@ -7411,8 +7411,8 @@ FREE GIFTS-
7411
7411
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
7412
7412
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
7413
7413
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
7414
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
7415
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
7414
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
7415
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
7416
7416
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
7417
7417
  "creatives.components.CapTagList.Cancel": "Cancel",
7418
7418
  "creatives.components.CapTagList.Ok": "Ok",
@@ -9749,8 +9749,8 @@ FREE GIFTS-
9749
9749
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
9750
9750
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
9751
9751
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
9752
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
9753
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
9752
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
9753
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
9754
9754
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
9755
9755
  "creatives.components.CapTagList.Cancel": "Cancel",
9756
9756
  "creatives.components.CapTagList.Ok": "Ok",
@@ -12238,8 +12238,8 @@ exports[`Creatives SmsTraiEdit test/> should render 2`] = `
12238
12238
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
12239
12239
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
12240
12240
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
12241
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
12242
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
12241
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
12242
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
12243
12243
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
12244
12244
  "creatives.components.CapTagList.Cancel": "Cancel",
12245
12245
  "creatives.components.CapTagList.Ok": "Ok",
@@ -20936,8 +20936,8 @@ FREE GIFTS-
20936
20936
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
20937
20937
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
20938
20938
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
20939
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
20940
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
20939
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
20940
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
20941
20941
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
20942
20942
  "creatives.components.CapTagList.Cancel": "Cancel",
20943
20943
  "creatives.components.CapTagList.Ok": "Ok",
@@ -23274,8 +23274,8 @@ FREE GIFTS-
23274
23274
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
23275
23275
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
23276
23276
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
23277
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
23278
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
23277
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
23278
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
23279
23279
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
23280
23280
  "creatives.components.CapTagList.Cancel": "Cancel",
23281
23281
  "creatives.components.CapTagList.Ok": "Ok",
@@ -25763,8 +25763,8 @@ exports[`Creatives SmsTraiEdit test/> should save 1`] = `
25763
25763
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
25764
25764
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
25765
25765
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
25766
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
25767
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
25766
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
25767
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
25768
25768
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
25769
25769
  "creatives.components.CapTagList.Cancel": "Cancel",
25770
25770
  "creatives.components.CapTagList.Ok": "Ok",
@@ -33087,8 +33087,8 @@ FREE GIFTS-
33087
33087
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
33088
33088
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
33089
33089
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
33090
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
33091
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
33090
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
33091
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
33092
33092
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
33093
33093
  "creatives.components.CapTagList.Cancel": "Cancel",
33094
33094
  "creatives.components.CapTagList.Ok": "Ok",
@@ -35425,8 +35425,8 @@ FREE GIFTS-
35425
35425
  "app.v2containers.SmsTrai.Edit.traiEditTitle": "Message",
35426
35426
  "app.v2containers.SmsTrai.Edit.unicodeLabel": "Allow unicode characters",
35427
35427
  "app.v2containers.SmsTrai.Edit.unsupportedTagsValidationError": "Unsupported tags: {unsupportedTags}. Please remove them from this message.",
35428
- "creatives.components.AccessForbidden.forbiddenDesc": "This page access has not been provided to you.",
35429
- "creatives.components.AccessForbidden.forbiddenHeader": "Access Forbidden",
35428
+ "creatives.components.AccessForbidden.forbiddenDesc": "Please contact your organisation administrator to request access.",
35429
+ "creatives.components.AccessForbidden.forbiddenHeader": "You don't have permission to view this page.",
35430
35430
  "creatives.components.BreadCrumbs.header": "This is the BreadCrumbs component !",
35431
35431
  "creatives.components.CapTagList.Cancel": "Cancel",
35432
35432
  "creatives.components.CapTagList.Ok": "Ok",