@capillarytech/creatives-library 7.17.194-alpha.2 → 7.17.194
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/config/app.js +0 -2
- package/containers/App/constants.js +0 -1
- package/initialState.js +0 -3
- package/package.json +1 -1
- package/services/api.js +0 -20
- package/services/tests/api.test.js +0 -148
- package/utils/common.js +0 -7
- package/utils/tagValidations.js +1 -97
- package/utils/tests/tagValidations.test.js +2 -381
- package/v2Components/Ckeditor/index.js +3 -3
- package/v2Components/FormBuilder/_formBuilder.scss +1 -4
- package/v2Components/FormBuilder/index.js +69 -170
- package/v2Components/FormBuilder/messages.js +0 -8
- package/v2Containers/Cap/actions.js +0 -8
- package/v2Containers/Cap/constants.js +0 -4
- package/v2Containers/Cap/reducer.js +0 -11
- package/v2Containers/Cap/sagas.js +1 -28
- package/v2Containers/Cap/selectors.js +0 -5
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
- package/v2Containers/Cap/tests/reducer.test.js +0 -50
- package/v2Containers/Cap/tests/saga.test.js +1 -81
- package/v2Containers/CreativesContainer/SlideBoxContent.js +3 -4
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +17 -28
- package/v2Containers/CreativesContainer/constants.js +0 -1
- package/v2Containers/CreativesContainer/index.js +6 -45
- package/v2Containers/CreativesContainer/index.scss +1 -13
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -16
- package/v2Containers/Email/_email.scss +0 -3
- package/v2Containers/Email/index.js +0 -2
- package/v2Containers/EmailWrapper/index.js +0 -3
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -3
- package/v2Containers/MobilePush/Edit/constants.js +2 -0
- package/v2Containers/MobilePush/Edit/index.js +71 -15
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -93
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -12
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +0 -12
- package/v2Components/ErrorInfoNote/index.js +0 -89
- package/v2Components/ErrorInfoNote/messages.js +0 -34
- package/v2Components/ErrorInfoNote/style.scss +0 -72
- package/v2Containers/Cap/mockData.js +0 -74
package/config/app.js
CHANGED
|
@@ -6,7 +6,6 @@ const config = {
|
|
|
6
6
|
api_endpoint: '/arya/api/v1/creatives',
|
|
7
7
|
campaigns_api_endpoint: '/iris/v2/campaigns',
|
|
8
8
|
campaigns_api_org_endpoint: '/iris/v2/org/campaign',
|
|
9
|
-
liquid_endpoint:'/iris/v2/template',
|
|
10
9
|
auth_endpoint: '/arya/api/v1/auth',
|
|
11
10
|
arya_endpoint: '/arya/api/v1',
|
|
12
11
|
login_url: '/auth/login',
|
|
@@ -26,7 +25,6 @@ const config = {
|
|
|
26
25
|
exports_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/export/data',
|
|
27
26
|
login_url: '/auth/login',
|
|
28
27
|
dashboard_url: '/sms',
|
|
29
|
-
liquid_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/template',
|
|
30
28
|
dashboard_url_v2: '/v2',
|
|
31
29
|
},
|
|
32
30
|
testing: {
|
|
@@ -9,7 +9,6 @@ export const HOSPITALITY_BASED_SCOPE = 'HOSPITALITY_BASED_SCOPE';
|
|
|
9
9
|
export const REGISTRATION_CUSTOM_FIELD = 'Registration custom fields';
|
|
10
10
|
export const GIFT_CARDS = 'GIFT_CARDS';
|
|
11
11
|
export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
12
|
-
export const LIQUID_SUPPORT = 'ENABLE_LIQUID_SUPPORT';
|
|
13
12
|
export const CUSTOM_TAG = 'CustomTagMessage';
|
|
14
13
|
export const CUSTOMER_EXTENDED_FIELD = 'Customer extended fields';
|
|
15
14
|
export const EXTENDED_TAG = 'ExtendedTagMessage';
|
package/initialState.js
CHANGED
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -14,7 +14,6 @@ let API_ENDPOINT = config.development.api_endpoint;
|
|
|
14
14
|
let EXPORT_API_ENDPOINT = config.development.exports_api_endpoint;
|
|
15
15
|
let CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_endpoint;
|
|
16
16
|
let CAMPAIGNS_API_ORG_ENDPOINT = config.development.campaigns_api_org_endpoint;
|
|
17
|
-
let LIQUID_API_ENDPOINT = config.development.liquid_endpoint;
|
|
18
17
|
|
|
19
18
|
let API_AUTH_ENDPOINT = config.development.auth_endpoint;
|
|
20
19
|
let ARYA_ENDPOINT = config.development.arya_endpoint;
|
|
@@ -27,7 +26,6 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
27
26
|
ARYA_ENDPOINT = config.production.arya_endpoint;
|
|
28
27
|
SUBSCRIPTION_API_ENDPOINT = config.production.subscription_api_endpoint;
|
|
29
28
|
EXPORT_API_ENDPOINT = config.production.exports_api_endpoint;
|
|
30
|
-
LIQUID_API_ENDPOINT = config.production.liquid_endpoint;
|
|
31
29
|
}
|
|
32
30
|
let requestCallerName = '';
|
|
33
31
|
const isProd = process.env.NODE_ENV === 'production';
|
|
@@ -446,19 +444,6 @@ export const getLocizMessage = async (locale) => {
|
|
|
446
444
|
return response;
|
|
447
445
|
};
|
|
448
446
|
|
|
449
|
-
export const askAiraForLiquid = async ({ templateContent, errorMessage }) => {
|
|
450
|
-
const url = `${ARYA_ENDPOINT}/ask-aira-service/creatives_ai/liquidValidation`;
|
|
451
|
-
const response = await request(
|
|
452
|
-
url,
|
|
453
|
-
getAPICallObject("POST", {
|
|
454
|
-
temperature: 0.8,
|
|
455
|
-
templateContent,
|
|
456
|
-
parserError: errorMessage,
|
|
457
|
-
})
|
|
458
|
-
);
|
|
459
|
-
return response;
|
|
460
|
-
};
|
|
461
|
-
|
|
462
447
|
export const getUnsubscribeUrl = () => {
|
|
463
448
|
const body = {
|
|
464
449
|
orgUnitId: -1,
|
|
@@ -564,9 +549,4 @@ export const getNavigationConfigApi = async () => {
|
|
|
564
549
|
return await request(url, getAPICallObject('GET'));
|
|
565
550
|
};
|
|
566
551
|
|
|
567
|
-
export const getLiquidTags = (content) => {
|
|
568
|
-
const url = `${LIQUID_API_ENDPOINT}/extractTags`;
|
|
569
|
-
return request(url, getAPICallObject("POST", { content }, false, true));
|
|
570
|
-
};
|
|
571
|
-
|
|
572
552
|
export {request, getAPICallObject};
|
|
@@ -9,8 +9,6 @@ import {
|
|
|
9
9
|
getAllTemplates,
|
|
10
10
|
getTemplateDetails,
|
|
11
11
|
getTemplateInfoById,
|
|
12
|
-
askAiraForLiquid,
|
|
13
|
-
getLiquidTags,
|
|
14
12
|
} from '../api';
|
|
15
13
|
import { mockData } from './mockData';
|
|
16
14
|
const sampleFile = require('../../assets/line.png');
|
|
@@ -293,149 +291,3 @@ describe('getTemplateInfoById -- Test with valid responses', () => {
|
|
|
293
291
|
});
|
|
294
292
|
});
|
|
295
293
|
});
|
|
296
|
-
|
|
297
|
-
describe('askAiraForLiquid -- Test with various responses', () => {
|
|
298
|
-
beforeEach(() => {
|
|
299
|
-
global.fetch = jest.fn(); // Mocking global fetch function
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
afterEach(() => {
|
|
303
|
-
jest.restoreAllMocks(); // Restore all mocks after each test
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it('Should return correct response when syntax errors are present', async () => {
|
|
307
|
-
global.fetch.mockReturnValue(
|
|
308
|
-
Promise.resolve({
|
|
309
|
-
status: 200,
|
|
310
|
-
json: () =>
|
|
311
|
-
Promise.resolve({
|
|
312
|
-
status: 200,
|
|
313
|
-
response: 'Error description here',
|
|
314
|
-
}),
|
|
315
|
-
})
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
const templateContent = 'Invalid Liquid Template';
|
|
319
|
-
const errorMessage = 'Parser error message';
|
|
320
|
-
const response = await askAiraForLiquid({ templateContent, errorMessage });
|
|
321
|
-
|
|
322
|
-
expect(response).toEqual({
|
|
323
|
-
status: 200,
|
|
324
|
-
response: 'Error description here',
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it('Should return empty string when no syntax errors are present', async () => {
|
|
329
|
-
global.fetch.mockReturnValue(
|
|
330
|
-
Promise.resolve({
|
|
331
|
-
status: 200,
|
|
332
|
-
json: () =>
|
|
333
|
-
Promise.resolve({
|
|
334
|
-
status: 200,
|
|
335
|
-
response: '',
|
|
336
|
-
}),
|
|
337
|
-
})
|
|
338
|
-
);
|
|
339
|
-
|
|
340
|
-
const templateContent = 'Valid Liquid Template';
|
|
341
|
-
const errorMessage = '';
|
|
342
|
-
const response = await askAiraForLiquid({ templateContent, errorMessage });
|
|
343
|
-
|
|
344
|
-
expect(response).toEqual({
|
|
345
|
-
status: 200,
|
|
346
|
-
response: '',
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('Should handle server errors gracefully', async () => {
|
|
351
|
-
global.fetch.mockReturnValue(
|
|
352
|
-
Promise.resolve({
|
|
353
|
-
status: 500,
|
|
354
|
-
json: () =>
|
|
355
|
-
Promise.resolve({
|
|
356
|
-
status: 500,
|
|
357
|
-
error: 'Internal Server Error',
|
|
358
|
-
}),
|
|
359
|
-
})
|
|
360
|
-
);
|
|
361
|
-
|
|
362
|
-
const templateContent = 'Any Template';
|
|
363
|
-
const errorMessage = 'Any Error Message';
|
|
364
|
-
const response = await askAiraForLiquid({ templateContent, errorMessage });
|
|
365
|
-
|
|
366
|
-
expect(response).toEqual({
|
|
367
|
-
status: 500,
|
|
368
|
-
error: 'Internal Server Error',
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
describe('getLiquidTags -- Test with various responses', () => {
|
|
374
|
-
beforeEach(() => {
|
|
375
|
-
global.fetch = jest.fn(); // Mocking global fetch function
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
afterEach(() => {
|
|
379
|
-
jest.restoreAllMocks(); // Restore all mocks after each test
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
it('Should return correct tags when content has Liquid syntax', async () => {
|
|
383
|
-
const mockResponse = {
|
|
384
|
-
status: 200,
|
|
385
|
-
json: () =>
|
|
386
|
-
Promise.resolve({
|
|
387
|
-
status: 200,
|
|
388
|
-
response: ['tag1', 'tag2'],
|
|
389
|
-
}),
|
|
390
|
-
};
|
|
391
|
-
global.fetch.mockReturnValue(Promise.resolve(mockResponse));
|
|
392
|
-
|
|
393
|
-
const content = 'Some Liquid content with tags';
|
|
394
|
-
const response = await getLiquidTags(content);
|
|
395
|
-
|
|
396
|
-
expect(response).toEqual({
|
|
397
|
-
status: 200,
|
|
398
|
-
response: ['tag1', 'tag2'],
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
it('Should return empty array when content has no Liquid tags', async () => {
|
|
403
|
-
const mockResponse = {
|
|
404
|
-
status: 200,
|
|
405
|
-
json: () =>
|
|
406
|
-
Promise.resolve({
|
|
407
|
-
status: 200,
|
|
408
|
-
response: [],
|
|
409
|
-
}),
|
|
410
|
-
};
|
|
411
|
-
global.fetch.mockReturnValue(Promise.resolve(mockResponse));
|
|
412
|
-
|
|
413
|
-
const content = 'Plain content without Liquid tags';
|
|
414
|
-
const response = await getLiquidTags(content);
|
|
415
|
-
|
|
416
|
-
expect(response).toEqual({
|
|
417
|
-
status: 200,
|
|
418
|
-
response: [],
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it('Should handle server errors gracefully', async () => {
|
|
423
|
-
const mockResponse = {
|
|
424
|
-
status: 500,
|
|
425
|
-
json: () =>
|
|
426
|
-
Promise.resolve({
|
|
427
|
-
status: 500,
|
|
428
|
-
error: 'Internal Server Error',
|
|
429
|
-
}),
|
|
430
|
-
};
|
|
431
|
-
global.fetch.mockReturnValue(Promise.resolve(mockResponse));
|
|
432
|
-
|
|
433
|
-
const content = 'Any content';
|
|
434
|
-
const response = await getLiquidTags(content);
|
|
435
|
-
|
|
436
|
-
expect(response).toEqual({
|
|
437
|
-
status: 500,
|
|
438
|
-
error: 'Internal Server Error',
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
});
|
package/utils/common.js
CHANGED
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
22
22
|
BADGES_ISSUE,
|
|
23
23
|
ENABLE_WECHAT,
|
|
24
|
-
LIQUID_SUPPORT,
|
|
25
24
|
} from '../containers/App/constants';
|
|
26
25
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
27
26
|
|
|
@@ -89,12 +88,6 @@ export const hasPromoFeature = Auth.hasFeatureAccess.bind(
|
|
|
89
88
|
PROMO_ENGINE,
|
|
90
89
|
);
|
|
91
90
|
|
|
92
|
-
export const hasLiquidSupportFeature = Auth.hasFeatureAccess.bind(
|
|
93
|
-
null,
|
|
94
|
-
LIQUID_SUPPORT,
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
|
|
98
91
|
export const hasGiftVoucherFeature = Auth.hasFeatureAccess.bind(
|
|
99
92
|
null,
|
|
100
93
|
GIFT_CARDS,
|
package/utils/tagValidations.js
CHANGED
|
@@ -12,80 +12,6 @@ import lodashCloneDeep from 'lodash/cloneDeep';
|
|
|
12
12
|
const DEFAULT = 'default';
|
|
13
13
|
const SUBTAGS = 'subtags';
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* Checks if the response object of Tags supports the Tags added in the Add Labels Section
|
|
17
|
-
* @param {Object} response - The response object to check.
|
|
18
|
-
* @param {Object} tagObject - The tagLookupMap.
|
|
19
|
-
*/
|
|
20
|
-
export const checkSupport = (response = {}, tagObject = {}) => {
|
|
21
|
-
const supportedList = [];
|
|
22
|
-
// Verifies the presence of the tag in the 'Add Labels' section.
|
|
23
|
-
const checkNameInTagObject = (name) => !!tagObject[name];
|
|
24
|
-
|
|
25
|
-
// Verify if childTag is a valid sub-tag of parentTag from the 'Add Labels' section or if it's unsupported.
|
|
26
|
-
const checkSubtags = (parentTag, childName) => {
|
|
27
|
-
if (!tagObject?.[parentTag]) return false;
|
|
28
|
-
let updatedChildName = childName;
|
|
29
|
-
if (childName?.includes(".")) {
|
|
30
|
-
updatedChildName = "." + childName?.split(".")?.[1];
|
|
31
|
-
}
|
|
32
|
-
const subTags = tagObject?.[parentTag]?.definition?.subtags;
|
|
33
|
-
return subTags?.includes(updatedChildName);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
//Recursively checks if the childTag is actually a Sub-tag of the ParentTag
|
|
37
|
-
const processChildren = (parentTag = "", children = []) => {
|
|
38
|
-
for (const child of children) {
|
|
39
|
-
if (checkSubtags(parentTag, child?.name)) {
|
|
40
|
-
supportedList.push(child?.name);
|
|
41
|
-
}
|
|
42
|
-
if (child?.children && child?.children?.length > 0) {
|
|
43
|
-
processChildren(child?.name, child?.children);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
//Checks if the tag is present in the Add Label Section
|
|
49
|
-
for (const item of response?.data || []) {
|
|
50
|
-
if (checkNameInTagObject(item?.name)) {
|
|
51
|
-
supportedList.push(item?.name);
|
|
52
|
-
}
|
|
53
|
-
//Repeat the process for subtags
|
|
54
|
-
if (item?.children?.length > 0) {
|
|
55
|
-
processChildren(item?.name, item?.children);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return supportedList;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Extracts the names from the given data.
|
|
64
|
-
* @param {Array} data - The data to extract names from.
|
|
65
|
-
* @returns {Array} - The extracted names.
|
|
66
|
-
*/
|
|
67
|
-
export function extractNames(data) {
|
|
68
|
-
let names = [];
|
|
69
|
-
|
|
70
|
-
function traverse(node) {
|
|
71
|
-
if (node?.name) {
|
|
72
|
-
names.push(node?.name);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (node?.children?.length > 0) {
|
|
76
|
-
node?.children?.forEach((child) => traverse(child));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
data?.forEach((item) => traverse(item));
|
|
81
|
-
|
|
82
|
-
return names;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Validates the tags based on the provided parameters.
|
|
87
|
-
* @param {Object} params - The parameters for tag validation.
|
|
88
|
-
*/
|
|
89
15
|
export const validateTags = ({
|
|
90
16
|
content,
|
|
91
17
|
tagsParam,
|
|
@@ -95,8 +21,7 @@ export const validateTags = ({
|
|
|
95
21
|
}) => {
|
|
96
22
|
const tags = tagsParam;
|
|
97
23
|
const injectedTags = transformInjectedTags(injectedTagsParams);
|
|
98
|
-
let currentModule = location
|
|
99
|
-
|
|
24
|
+
let currentModule = location.query.module ? location.query.module : DEFAULT;
|
|
100
25
|
if (tagModule) {
|
|
101
26
|
currentModule = tagModule;
|
|
102
27
|
}
|
|
@@ -161,12 +86,6 @@ export const validateTags = ({
|
|
|
161
86
|
return response;
|
|
162
87
|
}
|
|
163
88
|
|
|
164
|
-
/**
|
|
165
|
-
* Checks if the given tag is supported based on the injected tags.
|
|
166
|
-
* @param {string} checkingTag - The tag to check.
|
|
167
|
-
* @param {Array} injectedTags - The injected tags.
|
|
168
|
-
* @returns {boolean} - True if the tag is supported, false otherwise.
|
|
169
|
-
*/
|
|
170
89
|
export const checkIfSupportedTag = (checkingTag, injectedTags) => {
|
|
171
90
|
let result = false;
|
|
172
91
|
lodashForEach(injectedTags, (tag, key) => {
|
|
@@ -237,19 +156,4 @@ export const validateIfTagClosed = (value) => {
|
|
|
237
156
|
|
|
238
157
|
return (l1 == l2 && l2 == l3 && l1 == l3);
|
|
239
158
|
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
//replaces encoded string with their respective characters
|
|
243
|
-
export const preprocessHtml = (content) => {
|
|
244
|
-
|
|
245
|
-
const replacements = {
|
|
246
|
-
"'": "'",
|
|
247
|
-
""": '"',
|
|
248
|
-
"&": "&",
|
|
249
|
-
"<": "<",
|
|
250
|
-
">": ">",
|
|
251
|
-
"\n": "", // Handling newlines by replacing them with an empty string
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
return content.replace(/'|"|&|<|>|\n/g, match => replacements[match]);
|
|
255
159
|
};
|