@capillarytech/creatives-library 9.2.2 → 9.2.4-beta.sprint-cap-214027-tags-ux-changes.48
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 +2 -0
- package/constants/unified.js +11 -1
- package/package.json +1 -1
- package/services/api.js +27 -8
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/utils/common.js +7 -6
- package/utils/createMobilePushPayload.js +50 -56
- package/utils/history.js +9 -3
- package/utils/mfeHistory.js +14 -0
- package/utils/mockGroupedTags.js +44 -0
- package/utils/tagValidations.js +37 -4
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- package/utils/tests/mfeHistory.test.js +53 -0
- package/utils/tests/mockGroupedTags.test.js +59 -0
- package/utils/tests/tagValidations.test.js +63 -0
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CapTagList/TagFallbackPanel.js +126 -0
- package/v2Components/CapTagList/constants.js +21 -0
- package/v2Components/CapTagList/index.js +238 -58
- package/v2Components/CapTagList/messages.js +68 -0
- package/v2Components/CapTagList/style.scss +263 -1
- package/v2Components/CapTagList/tests/TagDescription.test.js +268 -0
- package/v2Components/CapTagList/tests/TagFallback.test.js +255 -0
- package/v2Components/CapTagList/utils.js +74 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +51 -12
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +100 -0
- package/v2Components/ErrorInfoNote/ErrorInfoNote.test.js +53 -0
- package/v2Components/ErrorInfoNote/index.js +33 -11
- package/v2Components/ErrorInfoNote/messages.js +4 -0
- package/v2Components/ErrorInfoNote/style.scss +4 -0
- package/v2Components/ErrorInfoNote/utils.js +3 -0
- package/v2Components/FormBuilder/Classic.js +29 -16
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +69 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +17 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +18 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
- package/v2Components/FormBuilder/Functional/renderers/smsRenderers.js +5 -2
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
- package/v2Components/FormBuilder/Functional/tests/smsRenderers.test.js +1 -1
- package/v2Components/HighlightedTextArea/MessageTextArea.js +16 -0
- package/v2Components/HighlightedTextArea/constants.js +25 -0
- package/v2Components/HighlightedTextArea/index.js +148 -0
- package/v2Components/HighlightedTextArea/messages.js +18 -0
- package/v2Components/HighlightedTextArea/smsCounter.js +11 -0
- package/v2Components/HighlightedTextArea/style.scss +105 -0
- package/v2Components/HighlightedTextArea/tests/HighlightedTextArea.test.js +97 -0
- package/v2Components/HighlightedTextArea/utils.js +17 -0
- package/v2Components/HtmlEditor/components/ValidationTabs/__tests__/ValidationTabs.test.js +42 -0
- package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +4 -0
- package/v2Components/HtmlEditor/components/ValidationTabs/index.js +17 -3
- package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +4 -0
- package/v2Components/HtmlEditor/utils/__tests__/renderIssueMessage.test.js +32 -40
- package/v2Components/HtmlEditor/utils/renderIssueMessage.js +31 -24
- package/v2Components/HtmlEditor/utils/renderLegacyIssueMessage.js +56 -0
- package/v2Components/HtmlEditor/utils/validationConstants.js +2 -0
- package/v2Components/LiquidGenerator/constants.js +5 -0
- package/v2Components/LiquidGenerator/index.js +154 -0
- package/v2Components/LiquidGenerator/messages.js +50 -0
- package/v2Components/LiquidGenerator/style.scss +160 -0
- package/v2Components/LiquidGenerator/tests/LiquidGenerator.test.js +107 -0
- package/v2Components/LiquidGenerator/utils.js +42 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/NavigationBar/index.js +2 -2
- package/v2Components/NavigationBar/mfeModuleHeader.config.js +15 -0
- package/v2Components/NavigationBar/tests/mfeModuleHeader.config.test.js +19 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Containers/Cap/index.js +14 -10
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/mockdata/groupedStandardTags.json +17386 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +2 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/Facebook/Advertisement/index.js +2 -1
- package/v2Containers/InApp/index.js +4 -1
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Text/index.js +5 -2
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +177 -125
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +502 -290
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Rcs/index.js +10 -2
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1258 -1034
- package/v2Containers/Sms/Create/index.js +5 -1
- package/v2Containers/Sms/Edit/index.js +5 -1
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/index.js +13 -5
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +15 -0
- package/v2Containers/TagList/index.js +6 -0
- package/v2Containers/TagList/tests/TagList.test.js +10 -4
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +86 -81
- package/v2Containers/Templates/tests/index.test.js +81 -0
- package/v2Containers/Viber/index.js +5 -2
- package/v2Containers/WebPush/Create/tests/contentValidity.test.js +1 -0
- package/v2Containers/WebPush/Create/tests/stayOpenOnSave.test.js +1 -0
- package/v2Containers/WebPush/Create/utils/validation.js +6 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
- package/v2Containers/Whatsapp/index.js +11 -6
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +4 -1
package/config/app.js
CHANGED
|
@@ -17,10 +17,12 @@ const config = {
|
|
|
17
17
|
dashboard_url_v2: '/v2',
|
|
18
18
|
subscription_api_endpoint: '/arya/api/v1/org-settings/subscription',
|
|
19
19
|
exports_api_endpoint: '/arya/api/v1/export/data',
|
|
20
|
+
gateways_api_endpoint: '/arya/api/v1/creatives/gateways',
|
|
20
21
|
accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
|
|
21
22
|
},
|
|
22
23
|
development: {
|
|
23
24
|
api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
25
|
+
gateways_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives/gateways',
|
|
24
26
|
campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
|
|
25
27
|
campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
|
|
26
28
|
auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
|
package/constants/unified.js
CHANGED
|
@@ -46,7 +46,6 @@ export const HOSPITALITY_BASED_SCOPE = 'HOSPITALITY_BASED_SCOPE';
|
|
|
46
46
|
export const REGISTRATION_CUSTOM_FIELD = 'Registration custom fields';
|
|
47
47
|
export const GIFT_CARDS = 'GIFT_CARDS';
|
|
48
48
|
export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
49
|
-
export const ENABLE_NEW_MPUSH = 'ENABLE_NEW_MPUSH';
|
|
50
49
|
export const ENABLE_NEW_EDITOR_FLOW_INAPP = 'ENABLE_NEW_EDITOR_FLOW_INAPP';
|
|
51
50
|
// Per-channel flags for the FormBuilder V3 migration. Each routes its channel to
|
|
52
51
|
// the new functional FormBuilder; later channels get their own flags (…_EMAIL).
|
|
@@ -161,6 +160,9 @@ export const UNSUBSCRIBE_TAG = 'unsubscribe';
|
|
|
161
160
|
export const UNSUBSCRIBE_TAG_REGEX = new RegExp(`\\{\\{\\s*${UNSUBSCRIBE_TAG}\\s*\\}\\}`);
|
|
162
161
|
/** Matches {{ ... }} and captures the inner tag content (for scanning content for tags). */
|
|
163
162
|
export const TAG_CONTENT_REGEX = /{{([^}]+)}}/g;
|
|
163
|
+
// `default:` filter inside a tag, and the same filter with a quoted value e.g. default: 'x'
|
|
164
|
+
export const DEFAULT_FILTER_REGEX = /^\s*default\s*:/;
|
|
165
|
+
export const QUOTED_DEFAULT_REGEX = /^\s*default\s*:\s*('[^']*'|"[^"]*")\s*$/;
|
|
164
166
|
export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger\.\w+(?:\.\w+)?(?:\(\w+\))?/g;
|
|
165
167
|
/** Strips characters not allowed in a downloaded file name, keeping alphanumerics, `-`, `_` and spaces. */
|
|
166
168
|
export const SAFE_FILE_NAME_REGEX = /[^a-zA-Z0-9-_ ]/g;
|
|
@@ -240,3 +242,11 @@ export const HTTP_METHODS = Object.freeze({
|
|
|
240
242
|
PATCH: 'PATCH',
|
|
241
243
|
DELETE: 'DELETE',
|
|
242
244
|
});
|
|
245
|
+
|
|
246
|
+
// Temporary org feature flag for the personalization tags revamp (CAP-214027); remove once the backend support is released.
|
|
247
|
+
export const ENABLE_TAGS_REVAMP = 'ENABLE_TAGS_REVAMP';
|
|
248
|
+
|
|
249
|
+
// Development-only: local storage key that turns on the mock of the regrouped standard tags (see utils/mockGroupedTags.js)
|
|
250
|
+
export const MOCK_GROUPED_TAGS_STORAGE_KEY = 'MOCK_GROUPED_TAGS';
|
|
251
|
+
export const TIMELINE_CONTEXT = 'timeline';
|
|
252
|
+
export const OUTBOUND_CONTEXT = 'outbound';
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -13,6 +13,7 @@ import * as API from '../utils/ApiCaller';
|
|
|
13
13
|
import { addBaseToTemplate, transformCustomFieldsData } from '../utils/commonUtils';
|
|
14
14
|
import { EMAIL, SMS, TRANSACTION } from '../v2Containers/CreativesContainer/constants';
|
|
15
15
|
import { HTTP_METHODS } from '../constants/unified';
|
|
16
|
+
import { isMockGroupedTagsEnabled, getMockStandardTags, buildMockTagsResponse } from '../utils/mockGroupedTags';
|
|
16
17
|
let API_ENDPOINT = config.development.api_endpoint;
|
|
17
18
|
let EXPORT_API_ENDPOINT = config.development.exports_api_endpoint;
|
|
18
19
|
let CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_endpoint;
|
|
@@ -462,6 +463,31 @@ export const getUserList = () => {
|
|
|
462
463
|
return API.get(url);// request(url, getAPICallObject('GET'));
|
|
463
464
|
};
|
|
464
465
|
|
|
466
|
+
const requestTagMeta = async (queryParams) => {
|
|
467
|
+
const url = `${API_ENDPOINT}/meta/${queryParams.type}?query=${JSON.stringify(queryParams)}`;
|
|
468
|
+
const useMockTags = queryParams.type === 'TAG' && isMockGroupedTagsEnabled();
|
|
469
|
+
let result;
|
|
470
|
+
try {
|
|
471
|
+
result = await request(url, getAPICallObject('GET'));// request(url, getAPICallObject('GET'));
|
|
472
|
+
} catch (error) {
|
|
473
|
+
if (!useMockTags) throw error;
|
|
474
|
+
}
|
|
475
|
+
if (useMockTags) {
|
|
476
|
+
// development only: the regrouped standard tags are not deployed yet (see utils/mockGroupedTags.js)
|
|
477
|
+
if (result?.response?.metaEntities) {
|
|
478
|
+
result.response.metaEntities.standard = await getMockStandardTags(queryParams);
|
|
479
|
+
} else {
|
|
480
|
+
result = await buildMockTagsResponse(queryParams);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
const customFields = get(result, 'response.metaEntities.custom', {});
|
|
484
|
+
if (customFields && Object.keys(customFields)?.length > 0) {
|
|
485
|
+
const transformedData = transformCustomFieldsData(customFields);
|
|
486
|
+
result.response.metaEntities.custom = transformedData;
|
|
487
|
+
}
|
|
488
|
+
return result;
|
|
489
|
+
};
|
|
490
|
+
|
|
465
491
|
export const fetchSchemaForEntity = async ({queryParams}) => {
|
|
466
492
|
if (queryParams.version === "v2" && queryParams.type === "LAYOUT") {
|
|
467
493
|
const schema = getSchema(queryParams.layout);
|
|
@@ -470,14 +496,7 @@ export const fetchSchemaForEntity = async ({queryParams}) => {
|
|
|
470
496
|
console.error(err);
|
|
471
497
|
});
|
|
472
498
|
}
|
|
473
|
-
|
|
474
|
-
const result = await request(url, getAPICallObject('GET'));// request(url, getAPICallObject('GET'));
|
|
475
|
-
const customFields = get(result, 'response.metaEntities.custom', {});
|
|
476
|
-
if (customFields && Object.keys(customFields)?.length > 0) {
|
|
477
|
-
const transformedData = transformCustomFieldsData(customFields);
|
|
478
|
-
result.response.metaEntities.custom = transformedData;
|
|
479
|
-
}
|
|
480
|
-
return result;
|
|
499
|
+
return requestTagMeta(queryParams);
|
|
481
500
|
};
|
|
482
501
|
|
|
483
502
|
export const fetchWeCrmAccounts = (sourceName) => {
|
package/translations/en.json
CHANGED
|
@@ -317,6 +317,7 @@
|
|
|
317
317
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
318
318
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
319
319
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
320
|
+
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
320
321
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
321
322
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
322
323
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
package/translations/ja-JP.json
CHANGED
|
@@ -316,6 +316,7 @@
|
|
|
316
316
|
"creatives.componentsV2.TopBar.profile": "",
|
|
317
317
|
"creatives.componentsV2.TopBar.settings": "",
|
|
318
318
|
"creatives.componentsV2.unbalanacedCurlyBraces": "",
|
|
319
|
+
"creatives.componentsV2.unquotedTagDefaultValue": "",
|
|
319
320
|
"creatives.componentsv2.MobilePushPreviewV2.header": "",
|
|
320
321
|
"creatives.containers.Assets.Gallery.alphabetically": "",
|
|
321
322
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "",
|
package/translations/zh.json
CHANGED
|
@@ -316,6 +316,7 @@
|
|
|
316
316
|
"creatives.componentsV2.TopBar.profile": "",
|
|
317
317
|
"creatives.componentsV2.TopBar.settings": "",
|
|
318
318
|
"creatives.componentsV2.unbalanacedCurlyBraces": "",
|
|
319
|
+
"creatives.componentsV2.unquotedTagDefaultValue": "",
|
|
319
320
|
"creatives.componentsv2.MobilePushPreviewV2.header": "",
|
|
320
321
|
"creatives.containers.Assets.Gallery.alphabetically": "",
|
|
321
322
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "",
|
package/utils/common.js
CHANGED
|
@@ -24,11 +24,11 @@ import {
|
|
|
24
24
|
ENABLE_WECHAT,
|
|
25
25
|
ENABLE_WEBPUSH,
|
|
26
26
|
SUPPORT_CK_EDITOR,
|
|
27
|
-
ENABLE_NEW_MPUSH,
|
|
28
27
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
29
28
|
ENABLE_NEW_FORMBUILDER_SMS,
|
|
30
29
|
ENABLE_NEW_FORMBUILDER_MPUSH,
|
|
31
30
|
SUPPORT_ENGAGEMENT_MODULE,
|
|
31
|
+
ENABLE_TAGS_REVAMP,
|
|
32
32
|
} from '../constants/unified';
|
|
33
33
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
34
34
|
|
|
@@ -115,6 +115,12 @@ export const hasJPLocaleHideFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
|
115
115
|
JP_LOCALE_HIDE_FEATURE,
|
|
116
116
|
);
|
|
117
117
|
|
|
118
|
+
export const hasTagsRevampEnabled = Auth.hasFeatureAccess.bind(
|
|
119
|
+
null,
|
|
120
|
+
ENABLE_TAGS_REVAMP,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
|
|
118
124
|
export const hasWechatFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
119
125
|
null,
|
|
120
126
|
ENABLE_WECHAT,
|
|
@@ -144,11 +150,6 @@ export const isEmailUnsubscribeTagOptional = Auth.hasFeatureAccess.bind(
|
|
|
144
150
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
145
151
|
);
|
|
146
152
|
|
|
147
|
-
export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
148
|
-
null,
|
|
149
|
-
ENABLE_NEW_MPUSH,
|
|
150
|
-
);
|
|
151
|
-
|
|
152
153
|
export const hasNewEditorFlowInAppEnabled = Auth.hasFeatureAccess.bind(
|
|
153
154
|
null,
|
|
154
155
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
TEXT,
|
|
12
12
|
} from "../v2Containers/MobilePushNew/constants";
|
|
13
13
|
import messages from '../v2Containers/MobilePushNew/messages';
|
|
14
|
+
import { appendDeepLinkParams } from '../v2Containers/MobilePushNew/utils';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Constructs the payload for Mobile Push, supporting both legacy and rich media as per backend contract.
|
|
@@ -27,6 +28,7 @@ import messages from '../v2Containers/MobilePushNew/messages';
|
|
|
27
28
|
* @param {Object} params.accountData - Account data for the payload
|
|
28
29
|
* @param {boolean} params.sameContent - Whether content is shared between platforms
|
|
29
30
|
* @param {Object} params.options - Additional options
|
|
31
|
+
* @param {string} [params.options.skipPlatform] - ANDROID or IOS: leave out a supported platform the user chose not to configure
|
|
30
32
|
* @param {Object} params.intl - Internationalization object for messages
|
|
31
33
|
*/
|
|
32
34
|
const createMobilePushPayload = ({
|
|
@@ -41,8 +43,8 @@ const createMobilePushPayload = ({
|
|
|
41
43
|
intl,
|
|
42
44
|
}) => {
|
|
43
45
|
// Platform support checks must be at the top
|
|
44
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
45
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
46
|
+
const isAndroidSupported = accountData?.configs?.android === '1' && options?.skipPlatform !== ANDROID;
|
|
47
|
+
const isIosSupported = accountData?.configs?.ios === '1' && options?.skipPlatform !== IOS;
|
|
46
48
|
|
|
47
49
|
const {
|
|
48
50
|
accountId: accountIdFromAccountData, id, licenseCode: licenseCodeFromAccountData, sourceAccountIdentifier, sourceType: sourceTypeFromAccountData, sourceTypeName,
|
|
@@ -121,6 +123,33 @@ const createMobilePushPayload = ({
|
|
|
121
123
|
return payload;
|
|
122
124
|
};
|
|
123
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Carousel cards as Save sends them (also used by the Test & Preview payload)
|
|
128
|
+
* @param {Array} carouselData - Editor carousel cards
|
|
129
|
+
* @returns {Array} Cards with media only
|
|
130
|
+
*/
|
|
131
|
+
export function buildCarouselCards(carouselData = []) {
|
|
132
|
+
return (carouselData || []).map((card) => {
|
|
133
|
+
const {
|
|
134
|
+
mediaType,
|
|
135
|
+
imageUrl,
|
|
136
|
+
videoSrc,
|
|
137
|
+
videoPreviewImg,
|
|
138
|
+
} = card || {};
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
mediaType: mediaType || IMAGE.toLowerCase(),
|
|
142
|
+
imageUrl: imageUrl || '',
|
|
143
|
+
videoSrc: videoSrc || '',
|
|
144
|
+
// Thumbnail, so the phone preview can show the video card when editing
|
|
145
|
+
...(videoPreviewImg && { videoPreviewImg }),
|
|
146
|
+
// No per-card tap: the notification tap is for the whole notification.
|
|
147
|
+
// Dropping old card links also stops them refilling that tap on reopen.
|
|
148
|
+
buttons: [],
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
124
153
|
/**
|
|
125
154
|
* Builds platform-specific content for the payload
|
|
126
155
|
* @param {Object} content - Platform content (Android/iOS)
|
|
@@ -129,7 +158,7 @@ const createMobilePushPayload = ({
|
|
|
129
158
|
* @param {string} platform - Platform (ANDROID/IOS)
|
|
130
159
|
* @returns {Object} Platform-specific content
|
|
131
160
|
*/
|
|
132
|
-
function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
161
|
+
export function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
133
162
|
const {
|
|
134
163
|
title = '',
|
|
135
164
|
message = '',
|
|
@@ -148,18 +177,16 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
148
177
|
custom: buildCustomFields(content),
|
|
149
178
|
};
|
|
150
179
|
|
|
151
|
-
// Handle
|
|
180
|
+
// Handle media types
|
|
181
|
+
const style = content?.mediaType || expandableDetails?.style;
|
|
182
|
+
const isCarousel = [CAROUSEL, MANUAL_CAROUSEL, AUTO_CAROUSEL, FILMSTRIP_CAROUSEL].includes(style);
|
|
183
|
+
|
|
184
|
+
// Handle CTA (notification tap, for the whole notification, carousel included)
|
|
152
185
|
if (actionOnClick) {
|
|
153
186
|
let finalDeepLinkValue = deepLinkValue;
|
|
154
187
|
|
|
155
188
|
if (linkType === DEEP_LINK && deepLinkKeysValue?.length > 0) {
|
|
156
|
-
|
|
157
|
-
const urlHasKeys = deepLinkKeysValue?.some((key) => deepLinkValue?.includes(`${key}=${key}`));
|
|
158
|
-
|
|
159
|
-
// Only append keys if they're not already in the URL
|
|
160
|
-
if (!urlHasKeys) {
|
|
161
|
-
finalDeepLinkValue = appendDeepLinkKeysToUrl(deepLinkValue, deepLinkKeysValue);
|
|
162
|
-
}
|
|
189
|
+
finalDeepLinkValue = appendDeepLinkKeysToUrl(deepLinkValue, deepLinkKeysValue);
|
|
163
190
|
}
|
|
164
191
|
|
|
165
192
|
platformContent.cta = {
|
|
@@ -168,9 +195,6 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
168
195
|
};
|
|
169
196
|
}
|
|
170
197
|
|
|
171
|
-
// Handle media types
|
|
172
|
-
const style = content?.mediaType || expandableDetails?.style;
|
|
173
|
-
|
|
174
198
|
// Determine the type field based on media type
|
|
175
199
|
let templateType = TEXT; // Default type for NONE or BIG_TEXT
|
|
176
200
|
|
|
@@ -184,7 +208,8 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
184
208
|
platformContent.expandableDetails.style = VIDEO;
|
|
185
209
|
platformContent.expandableDetails.message = message;
|
|
186
210
|
platformContent.expandableDetails.media = [{
|
|
187
|
-
|
|
211
|
+
// This platform's own video; mpushVideoSrcAndPreview is shared by both tabs
|
|
212
|
+
url: content?.videoSrc || content?.mediaList?.[0]?.url || '',
|
|
188
213
|
text: content?.mediaList?.[0]?.text || '',
|
|
189
214
|
type: VIDEO,
|
|
190
215
|
}];
|
|
@@ -201,50 +226,26 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
201
226
|
type: type.toLowerCase(),
|
|
202
227
|
}];
|
|
203
228
|
} else {
|
|
204
|
-
//
|
|
229
|
+
// No mediaList: use this platform's own GIF
|
|
205
230
|
platformContent.expandableDetails.style = GIF;
|
|
206
231
|
platformContent.expandableDetails.message = message;
|
|
207
232
|
platformContent.expandableDetails.media = [{
|
|
208
|
-
url:
|
|
233
|
+
url: content?.videoSrc || '',
|
|
209
234
|
text: '',
|
|
210
235
|
type: GIF, // Backend expects GIF type for GIFs
|
|
211
236
|
}];
|
|
212
237
|
}
|
|
213
238
|
templateType = GIF;
|
|
214
|
-
} else if (
|
|
239
|
+
} else if (isCarousel) { // Handle CAROUSEL media types
|
|
215
240
|
platformContent.expandableDetails.style = MANUAL_CAROUSEL;
|
|
216
241
|
platformContent.expandableDetails.message = message;
|
|
242
|
+
// A carousel tab hides the Buttons section; buttons added before switching aren't sent
|
|
243
|
+
platformContent.expandableDetails.ctas = [];
|
|
217
244
|
templateType = CAROUSEL;
|
|
218
245
|
|
|
219
246
|
// Handle carouselData
|
|
220
247
|
if (content?.carouselData?.length > 0) {
|
|
221
|
-
platformContent.expandableDetails.carouselData = content.carouselData
|
|
222
|
-
const {
|
|
223
|
-
mediaType,
|
|
224
|
-
imageUrl,
|
|
225
|
-
videoSrc,
|
|
226
|
-
buttons,
|
|
227
|
-
} = card || {};
|
|
228
|
-
|
|
229
|
-
return {
|
|
230
|
-
mediaType: mediaType || IMAGE.toLowerCase(),
|
|
231
|
-
imageUrl: imageUrl || '',
|
|
232
|
-
videoSrc: videoSrc || '',
|
|
233
|
-
buttons: buttons ? buttons.map((button) => {
|
|
234
|
-
const { linkType: buttonLinkType, deepLinkKeys, deepLinkValue: buttonDeepLinkValue } = button || {};
|
|
235
|
-
if (buttonLinkType === DEEP_LINK && deepLinkKeys && buttonDeepLinkValue) {
|
|
236
|
-
const deepLinkKeysArray = Array.isArray(deepLinkKeys) ? deepLinkKeys : [deepLinkKeys];
|
|
237
|
-
const updatedDeepLinkValue = appendDeepLinkKeysToUrl(buttonDeepLinkValue, deepLinkKeysArray);
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
...button,
|
|
241
|
-
deepLinkValue: updatedDeepLinkValue,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
return button;
|
|
245
|
-
}) : [],
|
|
246
|
-
};
|
|
247
|
-
});
|
|
248
|
+
platformContent.expandableDetails.carouselData = buildCarouselCards(content.carouselData);
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
// Handle mediaList
|
|
@@ -305,21 +306,14 @@ function buildCustomFields(content) {
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
/**
|
|
308
|
-
* Appends deep link
|
|
309
|
+
* Appends deep link params to URL
|
|
309
310
|
* @param {string} url - Base URL
|
|
310
|
-
* @param {Array} keys -
|
|
311
|
-
* @returns {string} URL with
|
|
311
|
+
* @param {Array} keys - "key=value" entries (an old entry without "=" means key=key)
|
|
312
|
+
* @returns {string} URL with the params
|
|
312
313
|
*/
|
|
313
314
|
export function appendDeepLinkKeysToUrl(url, keys) {
|
|
314
315
|
if (!url || !keys || !Array.isArray(keys) || keys?.length === 0) return url;
|
|
315
|
-
|
|
316
|
-
const separator = url.includes('?') ? '&' : '?';
|
|
317
|
-
const validKeys = keys.filter((key) => typeof key === 'string' && key?.length > 0);
|
|
318
|
-
if (validKeys?.length === 0) return url;
|
|
319
|
-
|
|
320
|
-
const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
|
|
321
|
-
|
|
322
|
-
return `${url}${separator}${keyParams}`;
|
|
316
|
+
return appendDeepLinkParams(url, keys);
|
|
323
317
|
}
|
|
324
318
|
|
|
325
319
|
export default createMobilePushPayload;
|
package/utils/history.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { createBrowserHistory } from 'history';
|
|
2
2
|
import pathConfig from '../config/path';
|
|
3
|
+
import rebaseHistory from './mfeHistory';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// Local development uses the same prefix handling as the MFE build, so addresses registered
|
|
6
|
+
// with registerOwnedPath (served outside the public path) work locally too. Production
|
|
7
|
+
// standalone is the v1 build, which keeps the plain basename history.
|
|
8
|
+
const history = process.env.NODE_ENV === 'development'
|
|
9
|
+
? rebaseHistory(createBrowserHistory(), pathConfig.publicPath)
|
|
10
|
+
: createBrowserHistory({
|
|
11
|
+
basename: pathConfig.publicPath,
|
|
12
|
+
});
|
|
7
13
|
|
|
8
14
|
export default history;
|
package/utils/mfeHistory.js
CHANGED
|
@@ -11,10 +11,24 @@
|
|
|
11
11
|
* while delegating all actual navigation to the shared instance. Net effect: relative
|
|
12
12
|
* routing keeps working unchanged, and navigation still flows through the single shared
|
|
13
13
|
* history. Standalone (no host history) is unaffected; the remote keeps creating its own.
|
|
14
|
+
*
|
|
15
|
+
* Top-level addresses the app serves outside its prefix are registered with registerOwnedPath
|
|
16
|
+
* (by app-only code); they are left as they are both ways: never prefixed on navigation, and
|
|
17
|
+
* never stripped when read (stripBase only strips the prefix).
|
|
14
18
|
*/
|
|
19
|
+
const ownedPaths = new Set();
|
|
20
|
+
|
|
21
|
+
export const registerOwnedPath = (path) => {
|
|
22
|
+
ownedPaths.add(String(path || '').replace(/\/+$/, ''));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const isOwnedPath = (pathname = '') => [...ownedPaths]
|
|
26
|
+
.some((owned) => owned && (pathname === owned || pathname.startsWith(`${owned}/`)));
|
|
27
|
+
|
|
15
28
|
const addBase = (base, to) => {
|
|
16
29
|
if (typeof to === 'string') {
|
|
17
30
|
if (!to.startsWith('/')) return to; // already relative to current location
|
|
31
|
+
if (isOwnedPath(to.split(/[?#]/)[0])) return to;
|
|
18
32
|
return to === '/' ? base : `${base}${to}`;
|
|
19
33
|
}
|
|
20
34
|
if (to && typeof to === 'object') {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development-only mock of the regrouped standard tags (CAP-214027).
|
|
3
|
+
*
|
|
4
|
+
* The grouping lives in the cc-crm-bootstrap seed, which cannot be deployed to the shared environments yet.
|
|
5
|
+
* On the local dev server the standard tags of GET /meta/TAG are replaced by the tags of
|
|
6
|
+
* groupedStandardTags.json (generated from the seed by docs/personalization-tags-revamp/tools/make_mock_tags.py).
|
|
7
|
+
* Custom, extended and loyalty tags stay real when the API answers. If the API does not answer, the mock alone
|
|
8
|
+
* is used. `localStorage.setItem('MOCK_GROUPED_TAGS', 'false')` turns the mock off.
|
|
9
|
+
*/
|
|
10
|
+
import { MOCK_GROUPED_TAGS_STORAGE_KEY, TIMELINE_CONTEXT, OUTBOUND_CONTEXT } from '../constants/unified';
|
|
11
|
+
|
|
12
|
+
export const isMockGroupedTagsEnabled = () => {
|
|
13
|
+
if (process.env.NODE_ENV !== 'development') return false;
|
|
14
|
+
try {
|
|
15
|
+
return window.localStorage.getItem(MOCK_GROUPED_TAGS_STORAGE_KEY) !== 'false';
|
|
16
|
+
} catch (error) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Same filter the tag API applies: the tag must support the requested context and layout
|
|
22
|
+
export const filterTagsBySupportedModules = (tags = [], context = '', layout = '') => {
|
|
23
|
+
const requestedContext = context.toLowerCase() === TIMELINE_CONTEXT ? OUTBOUND_CONTEXT : context.toLowerCase();
|
|
24
|
+
const requestedLayout = layout.toLowerCase();
|
|
25
|
+
return tags.filter((tag) => tag?.definition?.supportedModules?.some((moduleInfo) => (
|
|
26
|
+
moduleInfo?.context?.toLowerCase() === requestedContext && moduleInfo?.layout?.toLowerCase() === requestedLayout
|
|
27
|
+
)));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const getMockStandardTags = async ({ context, layout }) => {
|
|
31
|
+
// loaded on demand so that the mock never ends up in the main bundle
|
|
32
|
+
const { default: mockTags } = await import(/* webpackChunkName: "mock-grouped-tags" */ '../v2Containers/Cap/mockdata/groupedStandardTags.json');
|
|
33
|
+
return filterTagsBySupportedModules(mockTags, context, layout);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// What the tag API returns when only the standard tags are available
|
|
37
|
+
export const buildMockTagsResponse = async (queryParams) => ({
|
|
38
|
+
success: true,
|
|
39
|
+
response: {
|
|
40
|
+
metaEntities: {
|
|
41
|
+
standard: await getMockStandardTags(queryParams), custom: {}, extended: {}, loyaltyTags: {},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
package/utils/tagValidations.js
CHANGED
|
@@ -8,7 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
import lodashForEach from 'lodash/forEach';
|
|
10
10
|
import lodashCloneDeep from 'lodash/cloneDeep';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
ENTRY_TRIGGER_TAG_REGEX,
|
|
13
|
+
SKIP_TAGS_REGEX_GROUPS,
|
|
14
|
+
TAG_CONTENT_REGEX,
|
|
15
|
+
UNSUBSCRIBE_TAG,
|
|
16
|
+
UNSUBSCRIBE_TAG_REGEX,
|
|
17
|
+
DEFAULT_FILTER_REGEX,
|
|
18
|
+
QUOTED_DEFAULT_REGEX,
|
|
19
|
+
} from '../constants/unified';
|
|
20
|
+
import { hasTagsRevampEnabled } from './common';
|
|
12
21
|
|
|
13
22
|
const DEFAULT = 'default';
|
|
14
23
|
const SUBTAGS = 'subtags';
|
|
@@ -89,9 +98,9 @@ export const validateTagsCore = ({
|
|
|
89
98
|
}
|
|
90
99
|
|
|
91
100
|
response.isBraceError = !validateIfTagClosed(contentForBraceCheck);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
// the `default:` filter check belongs to the tags revamp (fallback), so it is skipped when the revamp is off
|
|
102
|
+
response.isDefaultQuoteError = hasTagsRevampEnabled() && !response.isBraceError && hasUnquotedTagDefault(contentForBraceCheck);
|
|
103
|
+
if (response.isBraceError || response.isDefaultQuoteError || response?.missingTags?.length > 0) {
|
|
95
104
|
response.valid = false;
|
|
96
105
|
}
|
|
97
106
|
return response;
|
|
@@ -203,6 +212,30 @@ export const validateIfTagClosed = (value) => {
|
|
|
203
212
|
return (l1 == l2 && l2 == l3 && l1 == l3);
|
|
204
213
|
};
|
|
205
214
|
|
|
215
|
+
// Splits a tag body into filters on `|` outside quotes (Liquid has no escaped quotes).
|
|
216
|
+
const splitTagFilters = (body) => {
|
|
217
|
+
const filters = [''];
|
|
218
|
+
let quote = null;
|
|
219
|
+
[...body].forEach((char) => {
|
|
220
|
+
if (quote) {
|
|
221
|
+
if (char === quote) quote = null;
|
|
222
|
+
} else if (char === "'" || char === '"') {
|
|
223
|
+
quote = char;
|
|
224
|
+
} else if (char === '|') {
|
|
225
|
+
filters.push('');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
filters[filters.length - 1] += char;
|
|
229
|
+
});
|
|
230
|
+
return filters;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// `default:` inside a {{ }} tag must be followed by a quoted value, e.g. {{tag | default: 'x'}}
|
|
234
|
+
export const hasUnquotedTagDefault = (value = '') =>
|
|
235
|
+
(String(value).match(/{{.*?}}/g) || []).some((tag) => splitTagFilters(tag.slice(2, -2))
|
|
236
|
+
.slice(1)
|
|
237
|
+
.some((filter) => DEFAULT_FILTER_REGEX.test(filter) && !QUOTED_DEFAULT_REGEX.test(filter)));
|
|
238
|
+
|
|
206
239
|
//replaces encoded string with their respective characters
|
|
207
240
|
export const preprocessHtml = (content) => {
|
|
208
241
|
const replacements = {
|