@capillarytech/creatives-library 7.12.109 → 7.12.111
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
|
@@ -5,9 +5,13 @@ import isNumber from "lodash/isNumber";
|
|
|
5
5
|
/* eslint-disable no-unused-expressions */
|
|
6
6
|
import { parse } from "node-html-parser";
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// example cdn url
|
|
9
|
+
// https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=100,height=100,quality=75,format=auto/intouch_creative_assets/005710a7-6412-44fe-a19f-e72456b1.jpg
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
/**
|
|
12
|
+
* regex tests presence of intouch_creative_assets in the url.
|
|
13
|
+
* We are not testing for extensions such as jpg/png because some channels like LINE - IMAGEMAP url doesn't contain extension.
|
|
14
|
+
*/
|
|
11
15
|
const regex = /https:\/\/.*intouch_creative_assets.*$/;
|
|
12
16
|
const INTOUCH_CREATIVE_ASSETS = "intouch_creative_assets";
|
|
13
17
|
const SPECIFIED = "specified";
|
|
@@ -16,7 +20,15 @@ const QUALITY_TYPE = {
|
|
|
16
20
|
DECREASE: "decrease",
|
|
17
21
|
PRESERVE: "preserve",
|
|
18
22
|
};
|
|
23
|
+
const CREATIVES_CDN_BASE_URL_KEY = 'CREATIVES_CDN_BASE_URL';
|
|
24
|
+
const CREATIVES_CDN_QUALITY_CONFIG_KEY = 'CREATIVES_CDN_QUALITY_CONFIG';
|
|
25
|
+
const CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX_KEY = 'CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX';
|
|
19
26
|
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* CHANNEL_CONFIGS maintains the transformation details for each channel (and optionally subchannel ex. FACEBOOK/LINE)
|
|
30
|
+
* In case of SUBCHANNELS, they are nested inside CHANNEL.
|
|
31
|
+
*/
|
|
20
32
|
const CHANNEL_CONFIGS = {
|
|
21
33
|
EMAIL: {
|
|
22
34
|
transformations: {
|
|
@@ -85,19 +97,35 @@ const CHANNEL_CONFIGS = {
|
|
|
85
97
|
},
|
|
86
98
|
WECHAT: {
|
|
87
99
|
transformations: {
|
|
88
|
-
width: 360,
|
|
89
|
-
height: 200,
|
|
90
100
|
quality: QUALITY_TYPE.DECREASE,
|
|
91
|
-
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
};
|
|
95
104
|
|
|
96
|
-
const CREATIVES_CDN_BASE_URL_KEY = 'CREATIVES_CDN_BASE_URL';
|
|
97
|
-
const CREATIVES_CDN_QUALITY_CONFIG_KEY = 'CREATIVES_CDN_QUALITY_CONFIG';
|
|
98
|
-
const CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX_KEY = 'CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX';
|
|
99
105
|
/**
|
|
106
|
+
*
|
|
107
|
+
* @param {string} url : required
|
|
108
|
+
* @param {number} height : optional | required when height needs to be manually specified for channels such as email.
|
|
109
|
+
* @param {number} width : optional | required when width needs to be manually specified for channels such as email.
|
|
110
|
+
* @param {string} channelName : required
|
|
111
|
+
* @param {string} channelSubType : optional | required when channel has multiple subtypes
|
|
112
|
+
*
|
|
113
|
+
* @returns
|
|
100
114
|
* getCdnUrl : utility function to replace and return s3/cdn url with cdn url.
|
|
115
|
+
* Step 1. Basic validations:
|
|
116
|
+
* a) If data type of cdn items stored in local storage is incorrect(maybe as a result of manual modification), the received url in param is returned.
|
|
117
|
+
* b) If cdn local storage items are emtpy then received url in param is returned.
|
|
118
|
+
* c) If url doesn't match with regex.
|
|
119
|
+
* d) Channel/Subchannel not present in CHANNEL_CONFIGS
|
|
120
|
+
* e) No quality and default quality mentioned in CHANNEL_CONFIGS for given channel.
|
|
121
|
+
* f) If channels quality is non numeric(maybe as a result of manual modification) then quality=100 is returned.
|
|
122
|
+
*
|
|
123
|
+
* Step 2. The CHANNEL_CONFIGS determine the applicableTransformations.
|
|
124
|
+
* Step 3. If applicable transformations are present `CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX` is appended to cdn url and transformation properties are added.
|
|
125
|
+
* Step 4. The original s3 file name is appened at the end of the url to get complete cdn url and value is returned.
|
|
126
|
+
*
|
|
127
|
+
* Error handling:
|
|
128
|
+
* In case of any unknown exception, url received in param is returned.
|
|
101
129
|
*/
|
|
102
130
|
export const getCdnUrl = ({
|
|
103
131
|
url,
|
|
@@ -202,7 +230,7 @@ export const getCdnUrl = ({
|
|
|
202
230
|
|
|
203
231
|
/**
|
|
204
232
|
*
|
|
205
|
-
* @param {
|
|
233
|
+
* @param {string} htmlContents accepts htmlContents - strigified.
|
|
206
234
|
* @returns htmlContents with updated urls in image tag
|
|
207
235
|
*/
|
|
208
236
|
export const updateImagesInHtml = (htmlContents) => {
|
|
@@ -235,6 +263,7 @@ export const updateImagesInHtml = (htmlContents) => {
|
|
|
235
263
|
*
|
|
236
264
|
* @param {*} contents
|
|
237
265
|
* @returns
|
|
266
|
+
* Transforms the email template's html by images replacing the s3 url / cdn url with cdn url.
|
|
238
267
|
*/
|
|
239
268
|
export const transformEmailTemplates = (contents) => {
|
|
240
269
|
const contentsCopy = cloneDeep(contents);
|
|
@@ -254,7 +283,12 @@ export const transformEmailTemplates = (contents) => {
|
|
|
254
283
|
};
|
|
255
284
|
|
|
256
285
|
|
|
257
|
-
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @param {*} key
|
|
289
|
+
* @param {*} parse
|
|
290
|
+
* @returns Localstorage item with mentioned key. Parses the value if second param `parse` is true.
|
|
291
|
+
*/
|
|
258
292
|
export function getLocalStorageItem(key, parse = false){
|
|
259
293
|
const val = localStorage.getItem(key);
|
|
260
294
|
if(parse){
|
|
@@ -263,11 +297,17 @@ export function getLocalStorageItem(key, parse = false){
|
|
|
263
297
|
return val;
|
|
264
298
|
}
|
|
265
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Removes specified key from local storage.
|
|
302
|
+
*/
|
|
266
303
|
export function removeLocalStorageItem(key) {
|
|
267
304
|
localStorage.removeItem(key);
|
|
268
305
|
return;
|
|
269
306
|
}
|
|
270
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Util function. Removes all cdn related local storage items.
|
|
310
|
+
*/
|
|
271
311
|
export function removeAllCdnLocalStorageItems() {
|
|
272
312
|
try{
|
|
273
313
|
removeLocalStorageItem(CREATIVES_CDN_BASE_URL_KEY);
|
|
@@ -278,6 +318,19 @@ export function removeAllCdnLocalStorageItems() {
|
|
|
278
318
|
}
|
|
279
319
|
}
|
|
280
320
|
|
|
321
|
+
/**
|
|
322
|
+
*
|
|
323
|
+
* @param {*} configsResponse
|
|
324
|
+
* This util function saves the getCdnConfigs response into the local storage.
|
|
325
|
+
* The following response items are mapped into the following keys in local storage:
|
|
326
|
+
* hostname -> CREATIVES_CDN_BASE_URL
|
|
327
|
+
* qualityCfg ->CREATIVES_CDN_QUALITY_CONFIG
|
|
328
|
+
* transformationUrlSuffix -> CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX
|
|
329
|
+
*
|
|
330
|
+
* 1. If configsReponse is empty. All above mentioned keys are deleted from localstorage.
|
|
331
|
+
* 2. If any one of the above keys is missing. The respective keys are deleted from localstorage.
|
|
332
|
+
* 3. Else it is saved into the localstorage.
|
|
333
|
+
*/
|
|
281
334
|
export function saveCdnConfigs(configsResponse) {
|
|
282
335
|
try {
|
|
283
336
|
//If no response from api, then remove localStorage items if they were set previously
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
} from '../../v2Containers/App/constants';
|
|
14
14
|
// import {makeSelectOrgId} from './selectors';
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
function* authorize(user) {
|
|
18
17
|
try {
|
|
19
18
|
const res = yield call(Api.authorize, user);
|
|
@@ -42,7 +41,6 @@ function* switchOrg({orgID}) {
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
|
|
46
44
|
function* loginFlow() {
|
|
47
45
|
const condition = true;
|
|
48
46
|
while (condition) {
|
|
@@ -177,7 +175,6 @@ function* watchGetTopbarMenuData() {
|
|
|
177
175
|
yield takeLatest(types.GET_TOPBAR_MENU_DATA_REQUEST, getTopbarMenuData);
|
|
178
176
|
}
|
|
179
177
|
|
|
180
|
-
|
|
181
178
|
export default [
|
|
182
179
|
loginFlow,
|
|
183
180
|
watchForOrgChange,
|
|
@@ -22,4 +22,4 @@ export const RCS = "RCS";
|
|
|
22
22
|
export const SHOW_CONTANER_LOADER = "app/CreativesContainer/SHOW_CONTANER_LOADER";
|
|
23
23
|
export const HIDE_CONTAINER_LOADER = "app/CreativesContainer/HIDE_CONTAINER_LOADER";
|
|
24
24
|
|
|
25
|
-
export const WHATSAPP_HELP_DOC_LINK = "https://support.capillarytech.com/en/support/solutions/articles/4000180620-create-whatsapp-template";
|
|
25
|
+
export const WHATSAPP_HELP_DOC_LINK = "https://support.capillarytech.com/en/support/solutions/articles/4000180620-create-whatsapp-template";
|