@capillarytech/creatives-library 8.0.309 → 8.0.310

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 (79) hide show
  1. package/constants/unified.js +1 -5
  2. package/initialState.js +2 -0
  3. package/package.json +1 -1
  4. package/services/api.js +0 -17
  5. package/services/tests/api.test.js +0 -85
  6. package/utils/common.js +8 -5
  7. package/utils/commonUtils.js +93 -46
  8. package/utils/tagValidations.js +223 -83
  9. package/utils/tests/commonUtil.test.js +124 -316
  10. package/utils/tests/tagValidations.test.js +358 -441
  11. package/v2Components/CommonTestAndPreview/SendTestMessage.js +49 -78
  12. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +34 -134
  13. package/v2Components/CommonTestAndPreview/actions.js +0 -10
  14. package/v2Components/CommonTestAndPreview/constants.js +1 -15
  15. package/v2Components/CommonTestAndPreview/index.js +19 -80
  16. package/v2Components/CommonTestAndPreview/messages.js +0 -94
  17. package/v2Components/CommonTestAndPreview/reducer.js +0 -10
  18. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -53
  19. package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -31
  20. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -36
  21. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -71
  22. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -377
  23. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -17
  24. package/v2Components/ErrorInfoNote/index.js +5 -2
  25. package/v2Components/FormBuilder/index.js +203 -137
  26. package/v2Components/FormBuilder/messages.js +8 -0
  27. package/v2Components/HtmlEditor/HTMLEditor.js +5 -0
  28. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -0
  29. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +15 -0
  30. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +2 -1
  31. package/v2Containers/Cap/mockData.js +14 -0
  32. package/v2Containers/Cap/reducer.js +55 -3
  33. package/v2Containers/Cap/tests/reducer.test.js +102 -0
  34. package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -5
  35. package/v2Containers/CreativesContainer/SlideBoxFooter.js +5 -13
  36. package/v2Containers/CreativesContainer/constants.js +0 -6
  37. package/v2Containers/CreativesContainer/index.js +7 -47
  38. package/v2Containers/Email/index.js +5 -1
  39. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +70 -23
  40. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +120 -20
  41. package/v2Containers/FTP/index.js +51 -2
  42. package/v2Containers/FTP/messages.js +4 -0
  43. package/v2Containers/InApp/index.js +107 -35
  44. package/v2Containers/InApp/tests/index.test.js +6 -17
  45. package/v2Containers/InappAdvance/index.js +112 -4
  46. package/v2Containers/InappAdvance/tests/index.test.js +0 -2
  47. package/v2Containers/Line/Container/Text/index.js +1 -0
  48. package/v2Containers/MobilePush/Create/index.js +19 -59
  49. package/v2Containers/MobilePush/Edit/index.js +20 -48
  50. package/v2Containers/MobilePushNew/index.js +32 -12
  51. package/v2Containers/MobilepushWrapper/index.js +1 -3
  52. package/v2Containers/Rcs/index.js +37 -12
  53. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1276 -1408
  54. package/v2Containers/Sms/Create/index.js +3 -39
  55. package/v2Containers/Sms/Create/messages.js +0 -4
  56. package/v2Containers/Sms/Edit/index.js +3 -35
  57. package/v2Containers/Sms/commonMethods.js +6 -3
  58. package/v2Containers/SmsTrai/Edit/index.js +47 -11
  59. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +294 -327
  60. package/v2Containers/SmsWrapper/index.js +0 -2
  61. package/v2Containers/TemplatesV2/index.js +13 -28
  62. package/v2Containers/Viber/index.js +1 -0
  63. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +3 -1
  64. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +7 -0
  65. package/v2Containers/WebPush/Create/index.js +2 -2
  66. package/v2Containers/WebPush/Create/utils/validation.js +8 -17
  67. package/v2Containers/WebPush/Create/utils/validation.test.js +24 -44
  68. package/v2Containers/Whatsapp/index.js +17 -9
  69. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4872 -5246
  70. package/v2Containers/Zalo/index.js +11 -3
  71. package/v2Components/CommonTestAndPreview/AddTestCustomer.js +0 -42
  72. package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +0 -284
  73. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +0 -72
  74. package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +0 -66
  75. package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -657
  76. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +0 -172
  77. package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +0 -466
  78. package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +0 -114
  79. package/v2Containers/Sms/tests/commonMethods.test.js +0 -122
@@ -77,6 +77,7 @@ import { getContent } from "../MobilePush/commonMethods";
77
77
  import { getMessageObject } from "../../utils/messageUtils";
78
78
  import { gtmPush } from "../../utils/gtmTrackers";
79
79
  import mobilePushReducer from "./reducer";
80
+ import { hasLiquidSupportFeature } from "../../utils/common";
80
81
  import formBuilderMessages from "../../v2Components/FormBuilder/messages";
81
82
  import { validateMobilePushContent } from "../../utils/commonUtils";
82
83
  import { getSingleTab } from "../InApp/utils";
@@ -802,9 +803,10 @@ const MobilePushNew = ({
802
803
  (value) => {
803
804
  let errorTemplateDescMessage = "";
804
805
 
805
- const { isBraceError } = validateTags({
806
+ const { unsupportedTags, isBraceError } = validateTags({
806
807
  content: value,
807
808
  tagsParam: tags,
809
+ injectedTagsParams: injectedTags,
808
810
  location,
809
811
  tagModule: getDefaultTags,
810
812
  isFullMode,
@@ -814,6 +816,14 @@ const MobilePushNew = ({
814
816
  messages.emptyTemplateDescErrorMessage
815
817
  );
816
818
  }
819
+ if (unsupportedTags?.length > 0) {
820
+ errorTemplateDescMessage = formatMessage(
821
+ globalMessages.unsupportedTagsValidationError,
822
+ {
823
+ unsupportedTags,
824
+ }
825
+ );
826
+ }
817
827
  if (isBraceError) {
818
828
  errorTemplateDescMessage = formatMessage(
819
829
  globalMessages.unbalanacedCurlyBraces
@@ -2655,6 +2665,20 @@ const MobilePushNew = ({
2655
2665
  getLiquidTags: globalActionsProps.getLiquidTags,
2656
2666
  formatMessage,
2657
2667
  messages: formBuilderMessages,
2668
+ tagLookupMap: metaEntities?.tagLookupMap || {},
2669
+ eventContextTags: metaEntities?.eventContextTags || [],
2670
+ isLiquidFlow: hasLiquidSupportFeature(),
2671
+ forwardedTags: {},
2672
+ skipTags: (tag) => {
2673
+ const skipRegexes = [
2674
+ /dynamic_expiry_date_after_\d+_days\.FORMAT_\d/,
2675
+ /unsubscribe\(#[a-zA-Z\d]{6}\)/,
2676
+ /Link_to_[a-zA-z]/,
2677
+ /SURVEY.*\.TOKEN/,
2678
+ /^[A-Za-z].*\([a-zA-Z\d]*\)/,
2679
+ ];
2680
+ return skipRegexes.some((regex) => regex.test(tag));
2681
+ },
2658
2682
  singleTab: getSingleTab(accountData),
2659
2683
  });
2660
2684
  }, [
@@ -2663,10 +2687,13 @@ const MobilePushNew = ({
2663
2687
  activeTab,
2664
2688
  globalActionsProps,
2665
2689
  formatMessage,
2690
+ metaEntities,
2666
2691
  accountData,
2667
2692
  isFullMode,
2668
2693
  ]);
2669
2694
 
2695
+ const isLiquidFlow = hasLiquidSupportFeature();
2696
+
2670
2697
  useEffect(() => {
2671
2698
  // Always map to { label } for both platforms
2672
2699
  const newButtons = Array.isArray(ctaData)
@@ -2913,22 +2940,16 @@ const MobilePushNew = ({
2913
2940
  setShowTestAndPreviewSlidebox(false);
2914
2941
  }, []);
2915
2942
 
2916
- // Add useEffect to handle isGetFormData prop changes (e.g. Done clicked in footer)
2917
- // In library mode: run liquid validation (extractTags) first; on success liquidMiddleWare calls handleSave
2918
- // In full mode: call handleSave directly
2943
+ // Add useEffect to handle isGetFormData prop changes
2919
2944
  useEffect(() => {
2920
2945
  if (isGetFormData) {
2921
- if (!isFullMode) {
2922
- liquidMiddleWare();
2923
- } else {
2924
- handleSave();
2925
- }
2946
+ handleSave();
2926
2947
  // Reset the flag to prevent infinite loop
2927
2948
  if (onValidationFail) {
2928
2949
  onValidationFail();
2929
2950
  }
2930
2951
  }
2931
- }, [isGetFormData, handleSave, onValidationFail, isFullMode, liquidMiddleWare]);
2952
+ }, [isGetFormData, handleSave, onValidationFail]);
2932
2953
 
2933
2954
  // Add message event listener to handle parent communication (like old MobilePush components)
2934
2955
  useEffect(() => {
@@ -3069,8 +3090,7 @@ const MobilePushNew = ({
3069
3090
  <CapButton
3070
3091
  type="primary"
3071
3092
  onClick={() => {
3072
- // Liquid validation (extractTags) only in library mode
3073
- if (!isFullMode) {
3093
+ if (isLiquidFlow) {
3074
3094
  liquidMiddleWare();
3075
3095
  } else {
3076
3096
  handleSave();
@@ -72,7 +72,7 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
72
72
  }
73
73
 
74
74
  render() {
75
- const {mobilePushCreateMode, step, getFormData, getLiquidTags, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail, onPreviewContentClicked, onTestContentClicked, templateData, eventContextTags = [], showTestAndPreviewSlidebox, handleTestAndPreview, handleCloseTestAndPreview, restrictPersonalization, isAnonymousType, onPersonalizationTokensChange} = this.props;
75
+ const {mobilePushCreateMode, step, getFormData, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail, onPreviewContentClicked, onTestContentClicked, templateData, eventContextTags = [], showTestAndPreviewSlidebox, handleTestAndPreview, handleCloseTestAndPreview, restrictPersonalization, isAnonymousType, onPersonalizationTokensChange} = this.props;
76
76
  const {templateName} = this.state;
77
77
  const isShowMobilepushCreate = !isEmpty(mobilePushCreateMode);
78
78
  return (
@@ -102,7 +102,6 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
102
102
  <div>
103
103
  {isShowMobilepushCreate && <MobilepushCreate
104
104
  getFormLibraryData={getFormData}
105
- getLiquidTags={getLiquidTags}
106
105
  setIsLoadingContent={setIsLoadingContent}
107
106
  defaultData={{"template-name": templateName}}
108
107
  location={{
@@ -144,7 +143,6 @@ MobilepushWrapper.propTypes = {
144
143
  mobilePushCreateMode: PropTypes.string,
145
144
  step: PropTypes.string,
146
145
  getFormData: PropTypes.string,
147
- getLiquidTags: PropTypes.func,
148
146
  setIsLoadingContent: PropTypes.func,
149
147
  onEnterTemplateName: PropTypes.func,
150
148
  onRemoveTemplateName: PropTypes.func,
@@ -394,15 +394,23 @@ export const Rcs = (props) => {
394
394
  const validationResponse =
395
395
  validateTags({
396
396
  content: contentForValidation,
397
- tagsParam: tags,
398
- location,
399
- tagModule: getDefaultTags,
400
- isFullMode,
401
- }) || {};
402
- const errorMsg =
403
- (validationResponse?.isBraceError &&
404
- formatMessage(globalMessages.unbalanacedCurlyBraces)) ||
405
- false;
397
+ tagsParam: tags,
398
+ injectedTagsParams: injectedTags,
399
+ location,
400
+ tagModule: getDefaultTags,
401
+ eventContextTags,
402
+ isFullMode,
403
+ }) || {};
404
+ const unsupportedTagsLengthCheck =
405
+ validationResponse?.unsupportedTags?.length > 0;
406
+ const errorMsg =
407
+ (unsupportedTagsLengthCheck &&
408
+ formatMessage(globalMessages.unsupportedTagsValidationError, {
409
+ unsupportedTags: validationResponse.unsupportedTags,
410
+ })) ||
411
+ (validationResponse.isBraceError &&
412
+ formatMessage(globalMessages.unbalanacedCurlyBraces)) ||
413
+ false;
406
414
  if (type === TITLE_TEXT) setTemplateTitleError(errorMsg);
407
415
  if (type === MESSAGE_TEXT) setTemplateDescError(errorMsg);
408
416
  };
@@ -827,9 +835,10 @@ export const Rcs = (props) => {
827
835
 
828
836
  const templateDescErrorHandler = (value) => {
829
837
  let errorMessage = false;
830
- const { isBraceError } = validateTags({
838
+ const { unsupportedTags, isBraceError } = validateTags({
831
839
  content: value,
832
840
  tagsParam: tags,
841
+ injectedTagsParams: injectedTags,
833
842
  location,
834
843
  tagModule: getDefaultTags,
835
844
  isFullMode,
@@ -859,10 +868,26 @@ export const Rcs = (props) => {
859
868
  };
860
869
 
861
870
  const fallbackMessageErrorHandler = (value) => {
871
+ let errorMessage = false;
872
+ const { unsupportedTags } = validateTags({
873
+ content: value,
874
+ tagsParam: tags,
875
+ injectedTagsParams: injectedTags,
876
+ location,
877
+ tagModule: getDefaultTags,
878
+ isFullMode,
879
+ }) || {};
862
880
  if (value?.length > FALLBACK_MESSAGE_MAX_LENGTH) {
863
- return formatMessage(messages.fallbackMsgLenError);
881
+ errorMessage = formatMessage(messages.fallbackMsgLenError);
882
+ } else if (unsupportedTags?.length > 0) {
883
+ errorMessage = formatMessage(
884
+ globalMessages.unsupportedTagsValidationError,
885
+ {
886
+ unsupportedTags,
887
+ },
888
+ );
864
889
  }
865
- return false;
890
+ return errorMessage;
866
891
  };
867
892
 
868
893
  // Check for forbidden characters: square brackets [] and single curly braces {}