@capillarytech/creatives-library 8.0.345-alpha.12 → 8.0.345-alpha.14
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/constants/unified.js +0 -29
- package/package.json +1 -1
- package/services/tests/api.test.js +0 -13
- package/utils/commonUtils.js +1 -19
- package/v2Components/CapActionButton/constants.js +0 -7
- package/v2Components/CapActionButton/index.js +109 -167
- package/v2Components/CapActionButton/index.scss +6 -157
- package/v2Components/CapActionButton/messages.js +3 -19
- package/v2Components/CapActionButton/tests/index.test.js +17 -41
- package/v2Components/CapTagList/index.js +0 -10
- package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +49 -70
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -207
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +10 -85
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -79
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +5 -10
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +15 -160
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +76 -341
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +4 -133
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +0 -11
- package/v2Components/CommonTestAndPreview/constants.js +2 -38
- package/v2Components/CommonTestAndPreview/index.js +186 -676
- package/v2Components/CommonTestAndPreview/messages.js +3 -49
- package/v2Components/CommonTestAndPreview/sagas.js +6 -15
- package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +284 -308
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +65 -231
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +5 -118
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -341
- package/v2Components/CommonTestAndPreview/tests/PreviewSection.test.js +1 -8
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +13 -34
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +283 -281
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
- package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -132
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
- package/v2Components/FormBuilder/index.js +10 -8
- package/v2Components/TemplatePreview/_templatePreview.scss +23 -33
- package/v2Components/TemplatePreview/index.js +28 -143
- package/v2Components/TemplatePreview/tests/index.test.js +0 -142
- package/v2Components/TestAndPreviewSlidebox/index.js +1 -13
- package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
- package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -36
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -10
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +4 -29
- package/v2Containers/CreativesContainer/constants.js +0 -9
- package/v2Containers/CreativesContainer/index.js +103 -300
- package/v2Containers/CreativesContainer/index.scss +1 -51
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -78
- package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +16 -79
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -8
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -357
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +15 -20
- package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
- package/v2Containers/Email/reducer.js +11 -3
- package/v2Containers/Email/sagas.js +9 -5
- package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +4 -0
- package/v2Containers/Email/tests/sagas.test.js +21 -3
- package/v2Containers/Rcs/constants.js +8 -119
- package/v2Containers/Rcs/index.js +812 -2375
- package/v2Containers/Rcs/index.scss +6 -276
- package/v2Containers/Rcs/messages.js +3 -38
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +70345 -98302
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +5 -0
- package/v2Containers/Rcs/tests/index.test.js +121 -152
- package/v2Containers/Rcs/tests/mockData.js +0 -38
- package/v2Containers/Rcs/tests/utils.test.js +30 -646
- package/v2Containers/Rcs/utils.js +11 -478
- package/v2Containers/Sms/Create/index.js +40 -100
- package/v2Containers/SmsTrai/Create/index.js +4 -9
- package/v2Containers/SmsTrai/Edit/constants.js +0 -2
- package/v2Containers/SmsTrai/Edit/index.js +130 -636
- package/v2Containers/SmsTrai/Edit/messages.js +4 -14
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2296 -4249
- package/v2Containers/SmsWrapper/index.js +8 -37
- package/v2Containers/TagList/index.js +0 -6
- package/v2Containers/Templates/_templates.scss +2 -163
- package/v2Containers/Templates/actions.js +0 -11
- package/v2Containers/Templates/constants.js +0 -2
- package/v2Containers/Templates/index.js +54 -119
- package/v2Containers/Templates/sagas.js +12 -57
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1079 -1043
- package/v2Containers/Templates/tests/sagas.test.js +123 -193
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -72
- package/v2Containers/TemplatesV2/index.js +23 -86
- package/v2Containers/Whatsapp/index.js +20 -3
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34 -578
- package/utils/rcsPayloadUtils.js +0 -92
- package/utils/templateVarUtils.js +0 -201
- package/utils/tests/templateVarUtils.test.js +0 -204
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js.rej +0 -18
- package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
- package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
- package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -87
- package/v2Components/SmsFallback/constants.js +0 -73
- package/v2Components/SmsFallback/index.js +0 -955
- package/v2Components/SmsFallback/index.scss +0 -265
- package/v2Components/SmsFallback/messages.js +0 -78
- package/v2Components/SmsFallback/smsFallbackUtils.js +0 -118
- package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +0 -50
- package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +0 -147
- package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +0 -304
- package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +0 -197
- package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -277
- package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
- package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
- package/v2Components/TemplatePreview/constants.js +0 -2
- package/v2Components/VarSegmentMessageEditor/constants.js +0 -2
- package/v2Components/VarSegmentMessageEditor/index.js +0 -125
- package/v2Components/VarSegmentMessageEditor/index.scss +0 -46
- package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +0 -43
- package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -67
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +0 -90
- package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +0 -258
- package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +0 -125
- package/v2Containers/Rcs/index.js.rej +0 -1336
- package/v2Containers/Rcs/index.scss.rej +0 -74
- package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +0 -225
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap.rej +0 -128
- package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -318
- package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
- package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
- package/v2Containers/SmsTrai/Edit/index.scss +0 -121
- package/v2Containers/Templates/TemplatesActionBar.js +0 -101
- package/v2Containers/Templates/tests/TemplatesActionBar.test.js +0 -120
- package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +0 -180
- package/v2Containers/Templates/utils/smsTemplatesListApi.js +0 -79
- package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +0 -131
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
diff a/app/v2Containers/Rcs/index.scss b/app/v2Containers/Rcs/index.scss (rejected hunks)
|
|
2
|
-
@@ -5,109 +5,54 @@
|
|
3
|
-
position: fixed;
|
|
4
|
-
bottom: 0;
|
|
5
|
-
width: 100%;
|
|
6
|
-
+ margin-left: -32px;
|
|
7
|
-
padding: $CAP_SPACE_32 $CAP_SPACE_24;
|
|
8
|
-
+ margin-top: 40px;
|
|
9
|
-
z-index: 1;
|
|
10
|
-
.ant-btn {
|
|
11
|
-
margin-right: $CAP_SPACE_16;
|
|
12
|
-
}
|
|
13
|
-
-
|
|
14
|
-
.rcs-test-preview-btn {
|
|
15
|
-
margin-left: $CAP_SPACE_08;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.cap-rcs-creatives {
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
+ .template-status-container {
|
|
25
|
-
+ width: 100%;
|
|
26
|
-
+ display: flex;
|
|
27
|
-
+ flex-direction: column;
|
|
28
|
-
+ align-items: flex-start;
|
|
29
|
-
+ margin-bottom: 1.25rem; // match spacing used across label sections (eg title/message labels)
|
|
30
|
-
|
|
31
|
-
+ .ant-alert {
|
|
32
|
-
+ width: 100%;
|
|
33
|
-
+ margin-top: $CAP_SPACE_08; // match label -> field spacing like other sections
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
+ .rcs-scroll-div {
|
|
38
|
-
+ margin-bottom: 150px;
|
|
39
|
-
}
|
|
40
|
-
+ // Match WhatsApp visual spacing between editor column and preview column
|
|
41
|
-
.rcs-preview-container {
|
|
42
|
-
+ padding-left: $CAP_SPACE_24;
|
|
43
|
-
+ display: flex;
|
|
44
|
-
+ justify-content: center;
|
|
45
|
-
}
|
|
46
|
-
.rcs-optional-label {
|
|
47
|
-
+ margin-left: 8px;
|
|
48
|
-
color: $FONT_COLOR_03;
|
|
49
|
-
font-weight: normal;
|
|
50
|
-
}
|
|
51
|
-
.rcs_text_area_wrapper {
|
|
52
|
-
position: relative;
|
|
53
|
-
}
|
|
54
|
-
.rcs-button{
|
|
55
|
-
display: inline-grid;
|
|
56
|
-
}
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
+ .rcs-button-label{
|
|
62
|
-
+ margin-bottom: 17px;
|
|
63
|
-
}
|
|
64
|
-
.disabled-button{
|
|
65
|
-
opacity: 0.5;
|
|
66
|
-
@@ -202,12 +288,6 @@
|
|
67
|
-
width: 430px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
.rcs-fallback-preview {
|
|
73
|
-
&__header {
|
|
74
|
-
color: $CAP_G01;
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import isEmpty from 'lodash/isEmpty';
|
|
2
|
-
import get from 'lodash/get';
|
|
3
|
-
import { RCS_SMS_FALLBACK_VAR_MAPPED_PROP } from '../../v2Components/CommonTestAndPreview/constants';
|
|
4
|
-
import {
|
|
5
|
-
RCS_NUMERIC_VAR_NAME_REGEX,
|
|
6
|
-
RCS_CARD_VAR_MAPPED_SEMANTIC_KEY_REGEX,
|
|
7
|
-
} from './constants';
|
|
8
|
-
|
|
9
|
-
/** RCS card `cardVarMapped` / `rcsCardVarMapped` only (SMS fallback slot keys stay on `smsFallBackContent`). */
|
|
10
|
-
export function pickRcsCardVarMappedEntries(record) {
|
|
11
|
-
if (record == null || typeof record !== 'object' || Array.isArray(record)) return {};
|
|
12
|
-
return Object.fromEntries(
|
|
13
|
-
Object.entries(record).filter(([k]) => {
|
|
14
|
-
const key = String(k);
|
|
15
|
-
return (
|
|
16
|
-
RCS_NUMERIC_VAR_NAME_REGEX.test(key)
|
|
17
|
-
|| RCS_CARD_VAR_MAPPED_SEMANTIC_KEY_REGEX.test(key)
|
|
18
|
-
);
|
|
19
|
-
}),
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Nested `versions…smsFallBackContent` and root `smsFallBackContent` (CreativesContainer mirror)
|
|
25
|
-
* can diverge. Merge explicitly (avoid `get(..., {}) || root` — `{}` is truthy and blocks fallback).
|
|
26
|
-
*
|
|
27
|
-
* When both exist, **nested wins on overlap**: the canonical RCS path is what `createPayload` / submit
|
|
28
|
-
* update; the root mirror can lag behind campaign parent state and would otherwise keep old
|
|
29
|
-
* `message` / `rcsSmsFallbackVarMapped` in hydration and approval payloads.
|
|
30
|
-
*/
|
|
31
|
-
export function mergeRcsSmsFallBackContentFromDetails(details) {
|
|
32
|
-
if (!details || typeof details !== 'object') return {};
|
|
33
|
-
const nestedSmsFallback = details?.versions?.base?.content?.RCS?.smsFallBackContent;
|
|
34
|
-
const rootSmsFallback = details?.smsFallBackContent;
|
|
35
|
-
const nestedRecord =
|
|
36
|
-
nestedSmsFallback != null && typeof nestedSmsFallback === 'object' ? nestedSmsFallback : {};
|
|
37
|
-
const rootRecord =
|
|
38
|
-
rootSmsFallback != null && typeof rootSmsFallback === 'object' ? rootSmsFallback : {};
|
|
39
|
-
return { ...rootRecord, ...nestedRecord };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Merge SMS fallback slot maps from API/templateData (`apiShape`) and editor state (`localShape`).
|
|
44
|
-
* Spreading `{ ...api, ...local }` lets `rcsSmsFallbackVarMapped: {}` on local wipe a populated API map,
|
|
45
|
-
* which keeps Done disabled in DLT campaigns until fixed.
|
|
46
|
-
*/
|
|
47
|
-
export function mergeRcsSmsFallbackVarMapLayers(apiShape = {}, localShape = {}) {
|
|
48
|
-
const readMap = (o) => {
|
|
49
|
-
if (!o || typeof o !== 'object') return {};
|
|
50
|
-
const camel = o.rcsSmsFallbackVarMapped;
|
|
51
|
-
const kebab = o['rcs-sms-fallback-var-mapped'];
|
|
52
|
-
const src =
|
|
53
|
-
camel && typeof camel === 'object'
|
|
54
|
-
? camel
|
|
55
|
-
: kebab && typeof kebab === 'object'
|
|
56
|
-
? kebab
|
|
57
|
-
: {};
|
|
58
|
-
return { ...src };
|
|
59
|
-
};
|
|
60
|
-
return { ...readMap(apiShape), ...readMap(localShape) };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* First non-empty trimmed string for SMS fallback body used in DLT slot checks / payload `templateContent`.
|
|
65
|
-
* Prefer **raw** template fields before resolved `message` so `{#…#}` / `{{…}}` tokens are not lost
|
|
66
|
-
* when `message` is consumer-resolved text (campaigns).
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* Whether an SMS fallback object carries template body, name, or var-map data (same rule as Rcs `createPayload`).
|
|
70
|
-
*/
|
|
71
|
-
export function hasMeaningfulSmsFallbackShape(s) {
|
|
72
|
-
return !!(
|
|
73
|
-
s
|
|
74
|
-
&& (
|
|
75
|
-
String(
|
|
76
|
-
s.content
|
|
77
|
-
|| s.templateContent
|
|
78
|
-
|| s.message
|
|
79
|
-
|| s.smsContent
|
|
80
|
-
|| s.smsTemplateContent
|
|
81
|
-
|| '',
|
|
82
|
-
).trim() !== ''
|
|
83
|
-
|| String(s.templateName || s.smsTemplateName || '').trim() !== ''
|
|
84
|
-
|| (s.rcsSmsFallbackVarMapped && Object.keys(s.rcsSmsFallbackVarMapped).length > 0)
|
|
85
|
-
|| (s[RCS_SMS_FALLBACK_VAR_MAPPED_PROP]
|
|
86
|
-
&& Object.keys(s[RCS_SMS_FALLBACK_VAR_MAPPED_PROP]).length > 0)
|
|
87
|
-
)
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Library `templateData`: merged root + nested `smsFallBackContent` (nested wins), matching `createPayload`.
|
|
93
|
-
*/
|
|
94
|
-
export function getLibrarySmsFallbackApiBaselineFromTemplateData(templateData) {
|
|
95
|
-
const smsFromTemplateRoot = get(
|
|
96
|
-
templateData,
|
|
97
|
-
'versions.base.content.RCS.smsFallBackContent',
|
|
98
|
-
);
|
|
99
|
-
return {
|
|
100
|
-
...(templateData?.smsFallBackContent && typeof templateData.smsFallBackContent === 'object'
|
|
101
|
-
? templateData.smsFallBackContent
|
|
102
|
-
: {}),
|
|
103
|
-
...(smsFromTemplateRoot && typeof smsFromTemplateRoot === 'object'
|
|
104
|
-
? smsFromTemplateRoot
|
|
105
|
-
: {}),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export { extractRegisteredSenderIdsFromSmsFallbackRecord } from '../../utils/commonUtils';
|
|
110
|
-
|
|
111
|
-
export function pickFirstSmsFallbackTemplateString(sms = {}) {
|
|
112
|
-
if (!sms || typeof sms !== 'object') return '';
|
|
113
|
-
const keys = [
|
|
114
|
-
'templateContent',
|
|
115
|
-
'smsTemplateContent',
|
|
116
|
-
'content',
|
|
117
|
-
'smsContent',
|
|
118
|
-
'message',
|
|
119
|
-
];
|
|
120
|
-
for (let i = 0; i < keys.length; i += 1) {
|
|
121
|
-
const v = sms[keys[i]];
|
|
122
|
-
if (v == null) continue;
|
|
123
|
-
const s = String(v).trim();
|
|
124
|
-
if (s) return s;
|
|
125
|
-
}
|
|
126
|
-
return '';
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Campaign reopen: payloads often keep tag/label values on numeric keys (`"1"`, `"2"`, …) while
|
|
131
|
-
* semantic keys (`user_name`, …) stay `""`. Copy non-empty slot values onto empty semantic keys so
|
|
132
|
-
* VarSegment editors prepopulate after Done → Edit without changing global resolve behavior.
|
|
133
|
-
*/
|
|
134
|
-
export function syncCardVarMappedSemanticsFromSlots(
|
|
135
|
-
cardVarMappedInput,
|
|
136
|
-
templateTitle,
|
|
137
|
-
templateDesc,
|
|
138
|
-
rcsVarRegex,
|
|
139
|
-
) {
|
|
140
|
-
const cardVarMappedSynced =
|
|
141
|
-
cardVarMappedInput != null && typeof cardVarMappedInput === 'object'
|
|
142
|
-
? { ...cardVarMappedInput }
|
|
143
|
-
: {};
|
|
144
|
-
const getVarNameFromToken = (token = '') => token.replace(/^\{\{|\}\}$/g, '');
|
|
145
|
-
const templateVarTokens = [
|
|
146
|
-
...(templateTitle?.match(rcsVarRegex) ?? []),
|
|
147
|
-
...(templateDesc?.match(rcsVarRegex) ?? []),
|
|
148
|
-
];
|
|
149
|
-
templateVarTokens.forEach((token, slotIndexZeroBased) => {
|
|
150
|
-
const semanticVarName = getVarNameFromToken(token);
|
|
151
|
-
if (!semanticVarName) return;
|
|
152
|
-
const numericSlotKey = String(slotIndexZeroBased + 1);
|
|
153
|
-
const semanticValueTrimmed = String(cardVarMappedSynced[semanticVarName] ?? '').trim();
|
|
154
|
-
const numericSlotValueTrimmed = String(cardVarMappedSynced[numericSlotKey] ?? '').trim();
|
|
155
|
-
if (!semanticValueTrimmed && numericSlotValueTrimmed) {
|
|
156
|
-
cardVarMappedSynced[semanticVarName] = cardVarMappedSynced[numericSlotKey];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
return cardVarMappedSynced;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Maps resolved campaign values back to `{{semanticKey}}` using `cardVarMapped` keys.
|
|
164
|
-
* Used when hydrating library/journey RCS edit from payloads without existing `{{…}}` tokens.
|
|
165
|
-
*/
|
|
166
|
-
export function getUnmappedDesc(str, mapping) {
|
|
167
|
-
if (!str) return '';
|
|
168
|
-
if (!mapping || Object.keys(mapping).length === 0) return str;
|
|
169
|
-
let result = str;
|
|
170
|
-
const replacements = [];
|
|
171
|
-
Object.entries(mapping).forEach(([key, value]) => {
|
|
172
|
-
const raw = (value ?? '').toString();
|
|
173
|
-
if (!raw || raw?.trim?.() === '') return;
|
|
174
|
-
const braced = /^\{\{[\s\S]*\}\}$/.test(raw) ? raw : `{{${raw}}}`;
|
|
175
|
-
replacements.push({ key, needle: raw });
|
|
176
|
-
if (braced !== raw) replacements.push({ key, needle: braced });
|
|
177
|
-
});
|
|
178
|
-
const seen = new Set();
|
|
179
|
-
const uniq = replacements
|
|
180
|
-
.filter(({ key, needle }) => {
|
|
181
|
-
const id = `${key}::${needle}`;
|
|
182
|
-
if (seen.has(id)) return false;
|
|
183
|
-
seen.add(id);
|
|
184
|
-
return true;
|
|
185
|
-
})
|
|
186
|
-
.sort((a, b) => (b.needle.length - a.needle.length));
|
|
187
|
-
|
|
188
|
-
uniq.forEach(({ key, needle }) => {
|
|
189
|
-
if (!needle) return;
|
|
190
|
-
const escaped = needle.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
191
|
-
const regex = new RegExp(escaped, 'g');
|
|
192
|
-
result = result.replace(regex, `{{${key}}}`);
|
|
193
|
-
});
|
|
194
|
-
return result;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function hasRcsVarTokens(s, rcsVarRegex) {
|
|
198
|
-
return (s?.match(rcsVarRegex) ?? []).length > 0;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Library / journey: only run `getUnmappedDesc` when the loaded copy has no `{{…}}` tokens
|
|
203
|
-
* (e.g. fully resolved campaign text). If the API already has numeric or named slots, keep as-is.
|
|
204
|
-
*/
|
|
205
|
-
export function normalizeLibraryLoadedTitleDesc({
|
|
206
|
-
loadedTitle,
|
|
207
|
-
loadedDesc,
|
|
208
|
-
isFullMode,
|
|
209
|
-
cardVarMappedAfterHydration,
|
|
210
|
-
rcsVarRegex,
|
|
211
|
-
}) {
|
|
212
|
-
const normalizedTitle =
|
|
213
|
-
!isFullMode
|
|
214
|
-
&& !isEmpty(cardVarMappedAfterHydration)
|
|
215
|
-
&& !hasRcsVarTokens(loadedTitle, rcsVarRegex)
|
|
216
|
-
? getUnmappedDesc(loadedTitle, cardVarMappedAfterHydration)
|
|
217
|
-
: loadedTitle;
|
|
218
|
-
const normalizedDesc =
|
|
219
|
-
!isFullMode
|
|
220
|
-
&& !isEmpty(cardVarMappedAfterHydration)
|
|
221
|
-
&& !hasRcsVarTokens(loadedDesc, rcsVarRegex)
|
|
222
|
-
? getUnmappedDesc(loadedDesc, cardVarMappedAfterHydration)
|
|
223
|
-
: loadedDesc;
|
|
224
|
-
return { normalizedTitle, normalizedDesc };
|
|
225
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
diff a/app/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap b/app/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap (rejected hunks)
|
|
2
|
-
@@ -2,41 +2,50 @@
|
|
3
|
-
|
|
4
|
-
exports[`RCS utils getRCSContent renders RCS content with empty template 1`] = `
|
|
5
|
-
<div
|
|
6
|
-
+ className="whatsapp-container"
|
|
7
|
-
>
|
|
8
|
-
+ <span
|
|
9
|
-
+ className="whatsapp-message-without-media"
|
|
10
|
-
+ >
|
|
11
|
-
+ <div
|
|
12
|
-
+ className="CapLabel-n7zsf5-0 kXNxry"
|
|
13
|
-
+ type="label9"
|
|
14
|
-
+ >
|
|
15
|
-
+ <div
|
|
16
|
-
+ className="CapLabel-n7zsf5-0 kXNxry rcs-listing-title"
|
|
17
|
-
+ type="label9"
|
|
18
|
-
+ />
|
|
19
|
-
+ </div>
|
|
20
|
-
+ </span>
|
|
21
|
-
</div>
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
exports[`RCS utils getRCSContent renders RCS content with image and CTA suggestion 1`] = `
|
|
25
|
-
<div
|
|
26
|
-
+ className="whatsapp-container"
|
|
27
|
-
>
|
|
28
|
-
<img
|
|
29
|
-
+ className="cap-image-v2 whatsapp-image"
|
|
30
|
-
src="https://cdn.example.com/img.png"
|
|
31
|
-
/>
|
|
32
|
-
+ <span
|
|
33
|
-
+ className="whatsapp-message-with-media"
|
|
34
|
-
>
|
|
35
|
-
+ <div
|
|
36
|
-
+ className="CapLabel-n7zsf5-0 kXNxry"
|
|
37
|
-
+ type="label9"
|
|
38
|
-
+ >
|
|
39
|
-
+ <div
|
|
40
|
-
+ className="CapLabel-n7zsf5-0 kXNxry rcs-listing-title"
|
|
41
|
-
+ type="label9"
|
|
42
|
-
+ >
|
|
43
|
-
+ Big Sale
|
|
44
|
-
+ </div>
|
|
45
|
-
+ <div>
|
|
46
|
-
+ Up to 50% off
|
|
47
|
-
+ </div>
|
|
48
|
-
+ </div>
|
|
49
|
-
+ </span>
|
|
50
|
-
<div
|
|
51
|
-
className="cap-divider-v2 whatsapp-divider ant-divider ant-divider-horizontal"
|
|
52
|
-
role="separator"
|
|
53
|
-
@@ -138,41 +147,50 @@ exports[`RCS utils getRCSContent renders RCS content with image and CTA suggesti
|
|
54
|
-
|
|
55
|
-
exports[`RCS utils getRCSContent renders RCS content with missing cardContent 1`] = `
|
|
56
|
-
<div
|
|
57
|
-
+ className="whatsapp-container"
|
|
58
|
-
>
|
|
59
|
-
+ <span
|
|
60
|
-
+ className="whatsapp-message-without-media"
|
|
61
|
-
+ >
|
|
62
|
-
+ <div
|
|
63
|
-
+ className="CapLabel-n7zsf5-0 kXNxry"
|
|
64
|
-
+ type="label9"
|
|
65
|
-
+ >
|
|
66
|
-
+ <div
|
|
67
|
-
+ className="CapLabel-n7zsf5-0 kXNxry rcs-listing-title"
|
|
68
|
-
+ type="label9"
|
|
69
|
-
+ />
|
|
70
|
-
+ </div>
|
|
71
|
-
+ </span>
|
|
72
|
-
</div>
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
|
-
exports[`RCS utils getRCSContent renders RCS content with multiple suggestion types 1`] = `
|
|
76
|
-
<div
|
|
77
|
-
+ className="whatsapp-container"
|
|
78
|
-
>
|
|
79
|
-
<img
|
|
80
|
-
+ className="cap-image-v2 whatsapp-image"
|
|
81
|
-
src="https://cdn.example.com/img.png"
|
|
82
|
-
/>
|
|
83
|
-
+ <span
|
|
84
|
-
+ className="whatsapp-message-with-media"
|
|
85
|
-
>
|
|
86
|
-
+ <div
|
|
87
|
-
+ className="CapLabel-n7zsf5-0 kXNxry"
|
|
88
|
-
+ type="label9"
|
|
89
|
-
+ >
|
|
90
|
-
+ <div
|
|
91
|
-
+ className="CapLabel-n7zsf5-0 kXNxry rcs-listing-title"
|
|
92
|
-
+ type="label9"
|
|
93
|
-
+ >
|
|
94
|
-
+ Big Sale
|
|
95
|
-
+ </div>
|
|
96
|
-
+ <div>
|
|
97
|
-
+ Up to 50% off
|
|
98
|
-
+ </div>
|
|
99
|
-
+ </div>
|
|
100
|
-
+ </span>
|
|
101
|
-
<div
|
|
102
|
-
className="cap-divider-v2 whatsapp-divider ant-divider ant-divider-horizontal"
|
|
103
|
-
role="separator"
|
|
104
|
-
@@ -299,14 +317,24 @@ exports[`RCS utils getRCSContent renders RCS content with multiple suggestion ty
|
|
105
|
-
|
|
106
|
-
exports[`RCS utils getRCSContent renders RCS content with no media 1`] = `
|
|
107
|
-
<div
|
|
108
|
-
+ className="whatsapp-container"
|
|
109
|
-
>
|
|
110
|
-
+ <span
|
|
111
|
-
+ className="whatsapp-message-without-media"
|
|
112
|
-
>
|
|
113
|
-
+ <div
|
|
114
|
-
+ className="CapLabel-n7zsf5-0 kXNxry"
|
|
115
|
-
+ type="label9"
|
|
116
|
-
+ >
|
|
117
|
-
+ <div
|
|
118
|
-
+ className="CapLabel-n7zsf5-0 kXNxry rcs-listing-title"
|
|
119
|
-
+ type="label9"
|
|
120
|
-
+ />
|
|
121
|
-
+ <div>
|
|
122
|
-
+ This is a text message body.
|
|
123
|
-
+ </div>
|
|
124
|
-
+ </div>
|
|
125
|
-
+ </span>
|
|
126
|
-
<div
|
|
127
|
-
className="cap-divider-v2 whatsapp-divider ant-divider ant-divider-horizontal"
|
|
128
|
-
role="separator"
|