@capillarytech/creatives-library 8.0.223 → 8.0.225

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.223",
4
+ "version": "8.0.225",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -16,7 +16,7 @@ import {
16
16
  IOS,
17
17
  } from "../v2Containers/CreativesContainer/constants";
18
18
  import { GLOBAL_CONVERT_OPTIONS } from "../v2Components/FormBuilder/constants";
19
- import { checkSupport, extractNames, skipTags as defaultSkipTags } from "./tagValidations";
19
+ import { checkSupport, extractNames } from "./tagValidations";
20
20
  import { SMS_TRAI_VAR } from '../v2Containers/SmsTrai/Edit/constants';
21
21
  export const apiMessageFormatHandler = (id, fallback) => (
22
22
  <FormattedMessage id={id} defaultMessage={fallback} />
@@ -146,7 +146,7 @@ export const validateLiquidTemplateContent = async (
146
146
  isLiquidFlow,
147
147
  forwardedTags = {},
148
148
  tabType,
149
- skipTags = defaultSkipTags,
149
+ skipTags = () => false,
150
150
  } = options;
151
151
  const emptyBodyError = formatMessage(messages?.emailBodyEmptyError);
152
152
  const somethingWrongMsg = formatMessage(messages?.somethingWentWrong);
@@ -221,7 +221,7 @@ export const validateTags = ({
221
221
  /**
222
222
  * Checks if the given tag is supported based on the injected tags.
223
223
  * @param {string} checkingTag - The tag to check.
224
- * @param {Object} injectedTags - The injected tags.
224
+ * @param {Array} injectedTags - The injected tags.
225
225
  * @returns {boolean} - True if the tag is supported, false otherwise.
226
226
  */
227
227
  export const checkIfSupportedTag = (checkingTag, injectedTags) => {
@@ -235,7 +235,7 @@ export const checkIfSupportedTag = (checkingTag, injectedTags) => {
235
235
  });
236
236
 
237
237
  return result;
238
- };
238
+ }
239
239
 
240
240
  const indexOfEnd = (targetString, string) => {
241
241
  let io = targetString.indexOf(string);
@@ -247,14 +247,19 @@ export const skipTags = (tag) => {
247
247
  if (tag?.match(ENTRY_TRIGGER_TAG_REGEX)) {
248
248
  return false;
249
249
  }
250
- const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)", "Link_to_[a-zA-z]", "SURVEY.*.TOKEN", "^[A-Za-z].*\\([a-zA-Z\\d]*\\)", "referral_unique_(code|url).*userid"];
251
- // Use some() to check if any pattern matches (stops on first match)
252
- return regexGroups.some((group) => {
253
- // Create a new RegExp for each test to avoid state issues with global flag
254
- const groupRegex = new RegExp(group);
255
- return groupRegex.test(tag);
250
+ const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)","Link_to_[a-zA-z]","SURVEY.*.TOKEN", "^[A-Za-z].*\\([a-zA-Z\\d]*\\)"];
251
+ let skipped = false;
252
+ lodashForEach(regexGroups, (group) => {
253
+ const groupRegex = new RegExp(group, "g");
254
+ let match = groupRegex.exec(tag);
255
+ if (match !== null ) {
256
+ skipped = true;
257
+ return true;
258
+ }
259
+ return true;
256
260
  });
257
- };
261
+ return skipped;
262
+ }
258
263
 
259
264
  export const transformInjectedTags = (tags) => {
260
265
  lodashForEach(tags, (tag) => {
@@ -7,7 +7,6 @@ import {
7
7
  addBaseToTemplate,
8
8
  validateCarouselCards,
9
9
  } from "../commonUtils";
10
- import { skipTags } from "../tagValidations";
11
10
  import { SMS_TRAI_VAR } from '../../v2Containers/SmsTrai/Edit/constants';
12
11
  import { ANDROID, IOS } from '../../v2Containers/CreativesContainer/constants';
13
12
 
@@ -123,150 +122,6 @@ describe("validateLiquidTemplateContent", () => {
123
122
  expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
124
123
  });
125
124
 
126
- it("should skip referral_unique_code tags and not trigger unsupported tag error", async () => {
127
- const getLiquidTags = jest.fn((content, cb) =>
128
- cb({ askAiraResponse: { errors: [], data: [{ name: "referral_unique_code_C6SOE_userid" }] }, isError: false })
129
- );
130
- await validateLiquidTemplateContent("foo", {
131
- getLiquidTags,
132
- formatMessage,
133
- messages,
134
- onError,
135
- onSuccess,
136
- tagLookupMap,
137
- eventContextTags,
138
- skipTags
139
- });
140
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
141
- expect(onError).not.toHaveBeenCalled();
142
- });
143
-
144
- it("should skip referral_unique_url tags and not trigger unsupported tag error", async () => {
145
- const getLiquidTags = jest.fn((content, cb) =>
146
- cb({ askAiraResponse: { errors: [], data: [{ name: "referral_unique_url_C6SOE_userid" }] }, isError: false })
147
- );
148
- await validateLiquidTemplateContent("foo", {
149
- getLiquidTags,
150
- formatMessage,
151
- messages,
152
- onError,
153
- onSuccess,
154
- tagLookupMap,
155
- eventContextTags,
156
- skipTags
157
- });
158
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
159
- expect(onError).not.toHaveBeenCalled();
160
- });
161
-
162
- it("should skip referral_unique_code tags with different codes", async () => {
163
- const getLiquidTags = jest.fn((content, cb) =>
164
- cb({ askAiraResponse: { errors: [], data: [{ name: "referral_unique_code_ABC123_userid" }] }, isError: false })
165
- );
166
- await validateLiquidTemplateContent("foo", {
167
- getLiquidTags,
168
- formatMessage,
169
- messages,
170
- onError,
171
- onSuccess,
172
- tagLookupMap,
173
- eventContextTags,
174
- skipTags
175
- });
176
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
177
- expect(onError).not.toHaveBeenCalled();
178
- });
179
-
180
- it("should skip referral_unique_url tags with different codes", async () => {
181
- const getLiquidTags = jest.fn((content, cb) =>
182
- cb({ askAiraResponse: { errors: [], data: [{ name: "referral_unique_url_ABC123_userid" }] }, isError: false })
183
- );
184
- await validateLiquidTemplateContent("foo", {
185
- getLiquidTags,
186
- formatMessage,
187
- messages,
188
- onError,
189
- onSuccess,
190
- tagLookupMap,
191
- eventContextTags,
192
- skipTags
193
- });
194
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
195
- expect(onError).not.toHaveBeenCalled();
196
- });
197
-
198
- it("should skip referral_unique_code tags with alphanumeric codes", async () => {
199
- const getLiquidTags = jest.fn((content, cb) =>
200
- cb({ askAiraResponse: { errors: [], data: [{ name: "referral_unique_code_XYZ789_userid" }] }, isError: false })
201
- );
202
- await validateLiquidTemplateContent("foo", {
203
- getLiquidTags,
204
- formatMessage,
205
- messages,
206
- onError,
207
- onSuccess,
208
- tagLookupMap,
209
- eventContextTags,
210
- skipTags
211
- });
212
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
213
- expect(onError).not.toHaveBeenCalled();
214
- });
215
-
216
- it("should skip referral_unique_url tags with alphanumeric codes", async () => {
217
- const getLiquidTags = jest.fn((content, cb) =>
218
- cb({ askAiraResponse: { errors: [], data: [{ name: "referral_unique_url_XYZ789_userid" }] }, isError: false })
219
- );
220
- await validateLiquidTemplateContent("foo", {
221
- getLiquidTags,
222
- formatMessage,
223
- messages,
224
- onError,
225
- onSuccess,
226
- tagLookupMap,
227
- eventContextTags,
228
- skipTags
229
- });
230
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
231
- expect(onError).not.toHaveBeenCalled();
232
- });
233
-
234
- it("should skip both referral_unique_code and referral_unique_url tags in the same content", async () => {
235
- const getLiquidTags = jest.fn((content, cb) =>
236
- cb({ askAiraResponse: { errors: [], data: [{ name: "referral_unique_code_C6SOE_userid" }, { name: "referral_unique_url_C6SOE_userid" }] }, isError: false })
237
- );
238
- await validateLiquidTemplateContent("foo", {
239
- getLiquidTags,
240
- formatMessage,
241
- messages,
242
- onError,
243
- onSuccess,
244
- tagLookupMap,
245
- eventContextTags,
246
- skipTags
247
- });
248
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
249
- expect(onError).not.toHaveBeenCalled();
250
- });
251
-
252
- it("should skip referral_unique_code_632L7_userid tag (real-world example)", async () => {
253
- const getLiquidTags = jest.fn((content, cb) =>
254
- cb({ askAiraResponse: { errors: [], data: [{ name: "referral_unique_code_632L7_userid" }] }, isError: false })
255
- );
256
- await validateLiquidTemplateContent("foo", {
257
- getLiquidTags,
258
- formatMessage,
259
- messages,
260
- onError,
261
- onSuccess,
262
- tagLookupMap,
263
- eventContextTags,
264
- skipTags
265
- });
266
- expect(onSuccess).toHaveBeenCalledWith("foo", undefined);
267
- expect(onError).not.toHaveBeenCalled();
268
- });
269
-
270
125
  it("calls onError with emailBodyEmptyError when validString is falsy", async () => {
271
126
  const getLiquidTags = jest.fn((content, cb) => cb({ askAiraResponse: { errors: [], data: [] }, isError: false }));
272
127
  const formatMessage = jest.fn((msg) => msg.id);
@@ -952,92 +952,6 @@ describe("skipTags", () => {
952
952
  const result = skipTags(tag);
953
953
  expect(result).toEqual(true);
954
954
  });
955
-
956
- it("should return true for referral unique code tags with userid", () => {
957
- const tag = "referral_unique_code_C6SOE_userid";
958
- const result = skipTags(tag);
959
- expect(result).toEqual(true);
960
- });
961
-
962
- it("should return true for referral unique url tags with userid", () => {
963
- const tag = "referral_unique_url_C6SOE_userid";
964
- const result = skipTags(tag);
965
- expect(result).toEqual(true);
966
- });
967
-
968
- it("should return true for referral unique code tags with different codes", () => {
969
- const tag = "referral_unique_code_ABC123_userid";
970
- const result = skipTags(tag);
971
- expect(result).toEqual(true);
972
- });
973
-
974
- it("should return true for referral unique url tags with different codes", () => {
975
- const tag = "referral_unique_url_ABC123_userid";
976
- const result = skipTags(tag);
977
- expect(result).toEqual(true);
978
- });
979
-
980
- it("should return true for referral unique code tags with alphanumeric codes", () => {
981
- const tag = "referral_unique_code_XYZ789_userid";
982
- const result = skipTags(tag);
983
- expect(result).toEqual(true);
984
- });
985
-
986
- it("should return true for referral unique url tags with alphanumeric codes", () => {
987
- const tag = "referral_unique_url_XYZ789_userid";
988
- const result = skipTags(tag);
989
- expect(result).toEqual(true);
990
- });
991
-
992
- it("should return false for tags that don't match referral pattern", () => {
993
- const tag = "referral_code_userid";
994
- const result = skipTags(tag);
995
- expect(result).toEqual(false);
996
- });
997
-
998
- it("should return false for tags with referral but missing unique_code or unique_url", () => {
999
- const tag = "referral_C6SOE_userid";
1000
- const result = skipTags(tag);
1001
- expect(result).toEqual(false);
1002
- });
1003
-
1004
- it("should return false for tags with referral_unique_code but missing userid", () => {
1005
- const tag = "referral_unique_code_C6SOE";
1006
- const result = skipTags(tag);
1007
- expect(result).toEqual(false);
1008
- });
1009
-
1010
- it("should return false for tags with referral_unique_url but missing userid", () => {
1011
- const tag = "referral_unique_url_C6SOE";
1012
- const result = skipTags(tag);
1013
- expect(result).toEqual(false);
1014
- });
1015
-
1016
- it("should return true for referral_unique_code tags with numeric codes like 632L7", () => {
1017
- const tag = "referral_unique_code_632L7_userid";
1018
- const result = skipTags(tag);
1019
- expect(result).toEqual(true);
1020
- });
1021
-
1022
- it("should return true for referral_unique_url tags with numeric codes like 632L7", () => {
1023
- const tag = "referral_unique_url_632L7_userid";
1024
- const result = skipTags(tag);
1025
- expect(result).toEqual(true);
1026
- });
1027
-
1028
- it("should return true for referral tags with various token formats", () => {
1029
- const tags = [
1030
- "referral_unique_code_123_userid",
1031
- "referral_unique_code_ABC_userid",
1032
- "referral_unique_code_123ABC_userid",
1033
- "referral_unique_url_456_userid",
1034
- "referral_unique_url_DEF_userid",
1035
- "referral_unique_url_456DEF_userid",
1036
- ];
1037
- tags.forEach((tag) => {
1038
- expect(skipTags(tag)).toEqual(true);
1039
- });
1040
- });
1041
955
  });
1042
956
 
1043
957
 
@@ -4,10 +4,11 @@ export const UPLOAD = 'upload';
4
4
  export const USE_EDITOR = 'useEditor';
5
5
  export const COPY_PRIMARY_LANGUAGE = 'copyPrimaryLanguage';
6
6
  export const GLOBAL_CONVERT_OPTIONS = {
7
- selectors: [
8
- ...[1, 2, 3, 4, 5, 6].map(level => ({
9
- selector: `h${level}`,
10
- options: { uppercase: false }
11
- }))
12
- ]
13
- };
7
+ wordwrap: null,
8
+ selectors: [
9
+ ...[1, 2, 3, 4, 5, 6].map((level) => ({
10
+ selector: `h${level}`,
11
+ options: { uppercase: false },
12
+ })),
13
+ ],
14
+ };
@@ -54,7 +54,7 @@ import { containsBase64Images } from '../../utils/content';
54
54
  import { SMS, MOBILE_PUSH, LINE, ENABLE_AI_SUGGESTIONS,AI_CONTENT_BOT_DISABLED, EMAIL, LIQUID_SUPPORTED_CHANNELS, INAPP } from '../../v2Containers/CreativesContainer/constants';
55
55
  import globalMessages from '../../v2Containers/Cap/messages';
56
56
  import { convert } from 'html-to-text';
57
- import { OUTBOUND, ADD_LANGUAGE, UPLOAD, USE_EDITOR, COPY_PRIMARY_LANGUAGE } from './constants';
57
+ import { OUTBOUND, ADD_LANGUAGE, UPLOAD, USE_EDITOR, COPY_PRIMARY_LANGUAGE, GLOBAL_CONVERT_OPTIONS } from './constants';
58
58
  import { GET_TRANSLATION_MAPPED } from '../../constants/unified';
59
59
  import moment from 'moment';
60
60
  import { CUSTOMER_BARCODE_TAG , COPY_OF, ENTRY_TRIGGER_TAG_REGEX} from '../../constants/unified';
@@ -1491,13 +1491,20 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1491
1491
  if (tag?.match(ENTRY_TRIGGER_TAG_REGEX)) {
1492
1492
  return false;
1493
1493
  }
1494
- const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)", "Link_to_[a-zA-z]", "SURVEY.*.TOKEN", "^[A-Za-z].*\\([a-zA-Z\\d]*\\)", "referral_unique_(code|url).*userid"];
1495
- // Use some() to check if any pattern matches (stops on first match)
1496
- return regexGroups.some((group) => {
1497
- // Create a new RegExp for each test to avoid state issues with global flag
1498
- const groupRegex = new RegExp(group);
1499
- return groupRegex.test(tag);
1494
+ const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)","Link_to_[a-zA-z]","SURVEY.*.TOKEN","^[A-Za-z].*\\([a-zA-Z\\d]*\\)"];
1495
+ //const regexGroups = [];
1496
+ let skipped = false;
1497
+ _.forEach(regexGroups, (group) => {
1498
+ //const groupRegex = /dynamic_expiry_date_after_\(\d+\)_days.FORMAT_\d/g;
1499
+ const groupRegex = new RegExp(group, "g");
1500
+ let match = groupRegex.exec(tag);
1501
+ if (match !== null ) {
1502
+ skipped = true;
1503
+ return true;
1504
+ }
1505
+ return true;
1500
1506
  });
1507
+ return skipped;
1501
1508
  }
1502
1509
 
1503
1510
  validateTags(content, tagsParam, injectedTagsParams, isEmail = false) {
@@ -1517,7 +1524,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1517
1524
  response.unsupportedTags = [];
1518
1525
  response.isBraceError = false;
1519
1526
  response.isContentEmpty = false;
1520
- const contentForValidation = isEmail ? convert(content) : content ;
1527
+ const contentForValidation = isEmail ? convert(content, GLOBAL_CONVERT_OPTIONS) : content ;
1521
1528
  if(tags && tags.length) {
1522
1529
  _.forEach(tags, (tag) => {
1523
1530
  _.forEach(tag.definition.supportedModules, (module) => {