@capillarytech/creatives-library 8.0.87-alpha.13 → 8.0.87-alpha.15

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.87-alpha.13",
4
+ "version": "8.0.87-alpha.15",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -21,17 +21,19 @@ export const transformSmsPayload = (smsData, options = {}) => {
21
21
  const { smsDeliverySettings } = transformedMessageDetails;
22
22
 
23
23
  return {
24
- ouId: ouId || -1,
25
- sourceEntityId: actionId,
26
- channel: "SMS",
27
- module,
28
- smsMessageContent: {
24
+ centralCommsPayload: {
25
+ ouId: ouId || -1,
26
+ sourceEntityId: actionId,
29
27
  channel: "SMS",
30
- message: smsData.messageBody || ""
31
- },
32
- smsDeliverySettings: smsDeliverySettings || {},
33
- executionParams: {},
34
- clientName: clientName || "EMF"
28
+ module,
29
+ smsMessageContent: {
30
+ channel: "SMS",
31
+ message: smsData.messageBody || ""
32
+ },
33
+ smsDeliverySettings: smsDeliverySettings || {},
34
+ executionParams: {},
35
+ clientName: clientName || "EMF"
36
+ }
35
37
  };
36
38
  };
37
39
 
@@ -58,18 +60,20 @@ export const transformEmailPayload = (emailData, options = {}) => {
58
60
  const { emailDeliverySettings = {} } = transformedMessageDetails;
59
61
 
60
62
  return {
61
- ouId: ouId || -1,
62
- sourceEntityId: actionId,
63
- channel: "EMAIL",
64
- module,
65
- emailMessageContent: {
63
+ centralCommsPayload: {
64
+ ouId: ouId || -1,
65
+ sourceEntityId: actionId,
66
66
  channel: "EMAIL",
67
- messageBody: emailData.emailBody || "",
68
- messageSubject: emailData.emailSubject || ""
69
- },
70
- emailDeliverySettings: emailDeliverySettings || {},
71
- executionParams: {},
72
- clientName: clientName || "EMF"
67
+ module,
68
+ emailMessageContent: {
69
+ channel: "EMAIL",
70
+ messageBody: emailData.emailBody || "",
71
+ messageSubject: emailData.emailSubject || ""
72
+ },
73
+ emailDeliverySettings: emailDeliverySettings || {},
74
+ executionParams: {},
75
+ clientName: clientName || "EMF"
76
+ }
73
77
  };
74
78
  };
75
79
 
@@ -107,67 +111,124 @@ export const transformMpushPayload = (mpushData, options = {}) => {
107
111
  };
108
112
 
109
113
  return {
110
- channel: "PUSH",
111
- ouId: ouId || -1,
112
- sourceEntityId: actionId,
113
- clientName: clientName || "VENENO",
114
- module,
115
- mpushMessageContent: {
114
+ centralCommsPayload: {
116
115
  channel: "PUSH",
117
- messageSubject: mpushData.messageSubject || "",
118
- androidContent: {
119
- type: androidContent.type || "TEXT",
120
- deviceType: "ANDROID",
121
- title: androidContent.title || "",
122
- message: androidContent.message || "",
123
- cta: {
124
- type: "EXTERNAL_URL",
125
- actionText: null,
126
- templateCtaId: null,
127
- actionLink: androidContent.cta?.actionLink || ""
116
+ ouId: ouId || -1,
117
+ sourceEntityId: actionId,
118
+ clientName: clientName || "VENENO",
119
+ module,
120
+ mpushMessageContent: {
121
+ channel: "PUSH",
122
+ messageSubject: mpushData.messageSubject || "",
123
+ androidContent: {
124
+ type: androidContent.type || "TEXT",
125
+ deviceType: "ANDROID",
126
+ title: androidContent.title || "",
127
+ message: androidContent.message || "",
128
+ cta: {
129
+ type: "EXTERNAL_URL",
130
+ actionText: null,
131
+ templateCtaId: null,
132
+ actionLink: androidContent.cta?.actionLink || ""
133
+ },
134
+ expandableDetails: {
135
+ style: androidContent.expandableDetails?.style || "BIG_TEXT",
136
+ message: androidContent.expandableDetails?.message || "",
137
+ ctas: androidContent.expandableDetails?.ctas || [],
138
+ image: androidContent.expandableDetails?.image || "",
139
+ categoryId: androidContent.expandableDetails?.categoryId || ""
140
+ },
141
+ customProperties: androidContent.custom || {}
128
142
  },
129
- expandableDetails: {
130
- style: androidContent.expandableDetails?.style || "BIG_TEXT",
131
- message: androidContent.expandableDetails?.message || "",
132
- ctas: androidContent.expandableDetails?.ctas || [],
133
- image: androidContent.expandableDetails?.image || "",
134
- categoryId: androidContent.expandableDetails?.categoryId || ""
143
+ iosContent: {
144
+ type: iosContent.type || "TEXT",
145
+ deviceType: "IOS",
146
+ title: iosContent.title || "",
147
+ message: iosContent.message || "",
148
+ cta: {
149
+ type: "EXTERNAL_URL",
150
+ actionText: null,
151
+ templateCtaId: null,
152
+ actionLink: iosContent.cta?.actionLink || ""
153
+ },
154
+ expandableDetails: {
155
+ style: iosContent.expandableDetails?.style || "BIG_TEXT",
156
+ message: iosContent.expandableDetails?.message || "",
157
+ ctas: iosContent.expandableDetails?.ctas || [],
158
+ image: iosContent.expandableDetails?.image || "",
159
+ categoryId: iosContent.expandableDetails?.categoryId || ""
160
+ },
161
+ customProperties: iosContent.custom || {}
135
162
  },
136
- customProperties: androidContent.custom || {}
163
+ accountId: mpushData.accountId || 0
137
164
  },
138
- iosContent: {
139
- type: iosContent.type || "TEXT",
140
- deviceType: "IOS",
141
- title: iosContent.title || "",
142
- message: iosContent.message || "",
143
- cta: {
144
- type: "EXTERNAL_URL",
145
- actionText: null,
146
- templateCtaId: null,
147
- actionLink: iosContent.cta?.actionLink || ""
148
- },
149
- expandableDetails: {
150
- style: iosContent.expandableDetails?.style || "BIG_TEXT",
151
- message: iosContent.expandableDetails?.message || "",
152
- ctas: iosContent.expandableDetails?.ctas || [],
153
- image: iosContent.expandableDetails?.image || "",
154
- categoryId: iosContent.expandableDetails?.categoryId || ""
165
+ mpushDeliverySettings: mobilePushDeliverySettings || {
166
+ additionalSettings: {
167
+ useTinyUrl: false,
168
+ encryptUrl: false,
169
+ linkTrackingEnabled: false,
170
+ userSubscriptionDisabled: false
155
171
  },
156
- customProperties: iosContent.custom || {}
172
+ channelSettings: {
173
+ channel: "PUSH",
174
+ domainGatewayMapId: options.domainGatewayMapId || 1
175
+ }
176
+ }
177
+ }
178
+ };
179
+ };
180
+
181
+ /**
182
+ * Transforms WhatsApp data to the required payload format
183
+ * @param {Object} whatsappData - Current WhatsApp data
184
+ * @param {Object} options - Additional options (ouId, sourceEntityId, etc.)
185
+ * @returns {Object} - Transformed WhatsApp payload
186
+ */
187
+ export const transformWhatsappPayload = (whatsappData, options = {}) => {
188
+ const { loyaltyMetaData = {} } = options;
189
+
190
+ const {
191
+ actionId,
192
+ actionName,
193
+ ouId,
194
+ clientName,
195
+ module,
196
+ metaId,
197
+ setMetaId = () => {},
198
+ transformedMessageDetails = {}
199
+ } = loyaltyMetaData;
200
+
201
+ const { whatsappDeliverySettings = {} } = transformedMessageDetails;
202
+
203
+ // Get template configurations or set defaults
204
+ const templateConfigs = whatsappData.templateConfigs || {};
205
+
206
+ return {
207
+ centralCommsPayload: {
208
+ ouId: ouId || -1,
209
+ sourceEntityId: actionId,
210
+ channel: "WHATSAPP",
211
+ module,
212
+ whatsappMessageContent: {
213
+ messageBody: whatsappData.messageBody || "",
214
+ accountId: whatsappData.accountId || 0,
215
+ templateConfigs,
216
+ channel: "WHATSAPP"
157
217
  },
158
- accountId: mpushData.accountId || 0
159
- },
160
- mpushDeliverySettings: mobilePushDeliverySettings || {
161
- additionalSettings: {
162
- useTinyUrl: false,
163
- encryptUrl: false,
164
- linkTrackingEnabled: false,
165
- userSubscriptionDisabled: false
218
+ whatsappDeliverySettings: whatsappDeliverySettings || {
219
+ additionalSettings: {
220
+ encryptUrl: false,
221
+ linkTrackingEnabled: false,
222
+ useTinyUrl: false
223
+ },
224
+ channelSettings: {
225
+ channel: "WHATSAPP",
226
+ senderMobNum: whatsappData.senderMobNum || "",
227
+ domainId: whatsappData.domainId || 0
228
+ }
166
229
  },
167
- channelSettings: {
168
- channel: "PUSH",
169
- domainGatewayMapId: options.domainGatewayMapId || 1
170
- }
230
+ executionParams: {},
231
+ clientName: clientName || "VENENO"
171
232
  }
172
233
  };
173
234
  };
@@ -188,6 +249,8 @@ export const transformChannelPayload = (data, options = {}) => {
188
249
  return transformMpushPayload(data, options);
189
250
  case "EMAIL":
190
251
  return transformEmailPayload(data, options);
252
+ case "WHATSAPP":
253
+ return transformWhatsappPayload(data, options);
191
254
  default:
192
255
  return data; // Return unchanged for unsupported channels
193
256
  }
@@ -17,6 +17,7 @@ export const FTP = "FTP";
17
17
  export const NO_COMMUNICATION = "NO_COMMUNICATION";
18
18
  export const VIBER = "VIBER";
19
19
  export const WHATSAPP = "WHATSAPP";
20
+ export const SMALL_CASE_WHATSAPP = "whatsapp";
20
21
  export const RCS = "RCS";
21
22
  export const ZALO = "ZALO";
22
23
  export const INAPP = "INAPP";
@@ -460,6 +460,7 @@ export class Creatives extends React.Component {
460
460
  };
461
461
  break;
462
462
  }
463
+ case constants.SMALL_CASE_WHATSAPP:
463
464
  case constants.WHATSAPP: {
464
465
  const {
465
466
  messageBody = '',
@@ -98,6 +98,11 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
98
98
  }
99
99
  const commonChannels = ['sms', 'email', 'wechat', 'mobilepush', 'line', 'viber', 'facebook', 'call_task', 'ftp', 'assets'];
100
100
 
101
+ // TODO: Add feature flag here
102
+ if (true) {
103
+ commonChannels.push('whatsapp');
104
+ }
105
+
101
106
  // we only show channels which other than commonChannels
102
107
  // if it is coming in enableNewChannels array
103
108
  filteredPanes = filteredPanes.filter((item) => {