@capillarytech/creatives-library 8.0.74 → 8.0.75

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.74",
4
+ "version": "8.0.75",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -18,11 +18,13 @@ const SUBTAGS = 'subtags';
18
18
  * @param {Object} response - The response object to check.
19
19
  * @param {Object} tagObject - The tagLookupMap.
20
20
  */
21
- export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [], isLiquidFlow = false) => {
21
+ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [], isLiquidFlow = false, forwardedTags = {}) => {
22
22
  const supportedList = [];
23
23
  // Verifies the presence of the tag in the 'Add Labels' section.
24
24
  // Incase of journey event context the tags won't be available in the tagObject(tagLookupMap).
25
- const checkNameInTagObjectOrEventContext = (name) => !!tagObject[name] || eventContextTags?.some((tag) => tag?.tagName === name);
25
+ //Here forwardedTags only use in case of loyalty module
26
+ const mappedForwardedTags = handleForwardedTags(forwardedTags);
27
+ const checkNameInTagObjectOrEventContext = (name) => !!tagObject[name] || eventContextTags?.some((tag) => tag?.tagName === name) || mappedForwardedTags.includes(name);
26
28
 
27
29
  // Verify if childTag is a valid sub-tag of parentTag from the 'Add Labels' section or if it's unsupported.
28
30
  const checkSubtags = (parentTag, childName) => {
@@ -33,13 +35,18 @@ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [
33
35
  supportedList.push(childName);
34
36
  }
35
37
  }
36
- if (!tagObject?.[parentTag]) return false;
38
+ if (!tagObject?.[parentTag] && !mappedForwardedTags.includes(parentTag)) return false;
37
39
  let updatedChildName = childName;
40
+ let updatedWithoutDotChildName = childName;
38
41
  if (childName?.includes(".")) {
39
42
  updatedChildName = "." + childName?.split(".")?.[1];
43
+ updatedWithoutDotChildName = childName?.split(".")?.[1];
40
44
  }
41
- const subTags = tagObject?.[parentTag]?.definition?.subtags;
42
- return subTags?.includes(updatedChildName);
45
+ if (tagObject?.[parentTag]) {
46
+ const subTags = tagObject?.[parentTag]?.definition?.subtags;
47
+ return subTags?.includes(updatedChildName);
48
+ }
49
+ return mappedForwardedTags.includes(updatedChildName) || mappedForwardedTags.includes(updatedWithoutDotChildName) || mappedForwardedTags.includes(childName);
43
50
  };
44
51
 
45
52
  //Recursively checks if the childTag is actually a Sub-tag of the ParentTag
@@ -69,6 +76,22 @@ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [
69
76
  return supportedList;
70
77
  };
71
78
 
79
+ const handleForwardedTags = (forwardedTags) => {
80
+ const result = [];
81
+ Object.keys(forwardedTags).forEach(key => {
82
+ result.push(key); // Add the main key to the result array
83
+
84
+ // Check if there are subtags for the current key
85
+ if (forwardedTags[key].subtags) {
86
+ // If subtags exist, add all subtag keys to the result array
87
+ Object.keys(forwardedTags[key].subtags).forEach(subkey => {
88
+ result.push(subkey);
89
+ });
90
+ }
91
+ });
92
+ return result;
93
+ }
94
+
72
95
  /**
73
96
  * Extracts the names from the given data.
74
97
  * @param {Array} data - The data to extract names from.
@@ -404,6 +404,26 @@ describe("checkSupport", () => {
404
404
  const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
405
405
  expect(result).toEqual( [ 'leaderboard' ]);
406
406
  });
407
+
408
+ it("test for checking loyalty tags in that are coming in forwardedTags", () => {
409
+ const response = { data: [{ name: "leaderboard", children: [{name: "person.userId"}]}]};
410
+ const tagObject = {};
411
+ const isLiquidFlow = true;
412
+ // forwardedTags contains tag hierarchy with parent tags and their subtags
413
+ // needed for loyalty email liquid tag resolution
414
+ const forwardedTags = {
415
+ leaderboard: {
416
+ name: "Leaderboard",
417
+ subtags: {
418
+ "person.userId": {
419
+ name: "User ID",
420
+ },
421
+ },
422
+ },
423
+ };
424
+ const result = checkSupport(response, tagObject, [], isLiquidFlow, forwardedTags);
425
+ expect(result).toEqual( [ 'leaderboard', 'person.userId' ]);
426
+ });
407
427
  });
408
428
 
409
429
  describe('preprocessHtml', () => {
@@ -1123,6 +1123,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1123
1123
  this.props?.metaEntities?.tagLookupMap,
1124
1124
  this.props?.eventContextTags,
1125
1125
  this.liquidFlow,
1126
+ this.props?.isLoyaltyModule ? this.props?.forwardedTags : {}
1126
1127
  );
1127
1128
  const unsupportedLiquidTags = extractedLiquidTags?.filter(
1128
1129
  (tag) => !supportedLiquidTags?.includes(tag) && !this.skipTags(tag)
@@ -157,6 +157,7 @@ export function SlideBoxContent(props) {
157
157
  creativesMode,
158
158
  hostName = '',
159
159
  eventContextTags,
160
+ isLoyaltyModule,
160
161
  } = props;
161
162
  const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
162
163
  const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
@@ -613,6 +614,7 @@ export function SlideBoxContent(props) {
613
614
  moduleType={moduleType}
614
615
  showLiquidErrorInFooter={showLiquidErrorInFooter}
615
616
  eventContextTags={eventContextTags}
617
+ isLoyaltyModule={isLoyaltyModule}
616
618
  />
617
619
  )}
618
620
  {(isEditEmailWithId || isEmailEditWithContent) && (
@@ -642,6 +644,7 @@ export function SlideBoxContent(props) {
642
644
  moduleType={moduleType}
643
645
  showLiquidErrorInFooter={showLiquidErrorInFooter}
644
646
  eventContextTags={eventContextTags}
647
+ isLoyaltyModule={isLoyaltyModule}
645
648
  />
646
649
  )}
647
650
  {isEditMPush &&
@@ -1271,6 +1271,7 @@ export class Creatives extends React.Component {
1271
1271
  smsRegister,
1272
1272
  enableNewChannels,
1273
1273
  eventContextTags,
1274
+ isLoyaltyModule,
1274
1275
  } = this.props;
1275
1276
  const mapTemplateCreate =
1276
1277
  slidBoxContent === "createTemplate" &&
@@ -1375,6 +1376,7 @@ export class Creatives extends React.Component {
1375
1376
  creativesMode={creativesMode} // An existing prop that we're using here. Required to ensure correct account details in Edit or Preview in case of Embedded mode.
1376
1377
  hostName={this.props?.hostName || ''}
1377
1378
  eventContextTags={eventContextTags}
1379
+ isLoyaltyModule={isLoyaltyModule}
1378
1380
  />
1379
1381
  )}
1380
1382
  footer={this.shouldShowFooter() && (
@@ -2747,6 +2747,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2747
2747
  moduleType={moduleType}
2748
2748
  showLiquidErrorInFooter={this.props.showLiquidErrorInFooter}
2749
2749
  eventContextTags={this.props?.eventContextTags}
2750
+ forwardedTags={this.props?.forwardedTags}
2751
+ isLoyaltyModule={this.props?.isLoyaltyModule}
2750
2752
  /> : ''}
2751
2753
  </Col>
2752
2754
  </Row>