@capillarytech/creatives-library 9.0.54-alpha.0 → 9.0.54-alpha.1
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
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
CCS_CHANNEL_CONTENT_KEY_MAP,
|
|
41
41
|
CCS_CHANNEL_DELIVERY_KEY_MAP,
|
|
42
42
|
CCS_CHANNEL_NAME_MAP,
|
|
43
|
+
CCS_CONTENT_TRANSFORMS,
|
|
43
44
|
} from './constants';
|
|
44
45
|
import { getEnabledSteps } from './utils/getEnabledSteps';
|
|
45
46
|
import messages from './messages';
|
|
@@ -191,6 +192,8 @@ const CommunicationFlow = ({
|
|
|
191
192
|
const channel = CCS_CHANNEL_NAME_MAP[rawChannel] || rawChannel;
|
|
192
193
|
const contentKey = CCS_CHANNEL_CONTENT_KEY_MAP[channel];
|
|
193
194
|
const deliveryKey = CCS_CHANNEL_DELIVERY_KEY_MAP[channel];
|
|
195
|
+
const contentTransform = CCS_CONTENT_TRANSFORMS[channel];
|
|
196
|
+
const contentPayload = contentTransform ? contentTransform(contentItem.templateData) : contentItem.templateData;
|
|
194
197
|
const { dynamicControls = {} } = aggregatedData;
|
|
195
198
|
const channelSettings = aggregatedData.deliverySetting?.channelSetting?.[channel] || {};
|
|
196
199
|
const referenceId = config?.context?.referenceId || buildCcsReferenceId(name);
|
|
@@ -212,7 +215,7 @@ const CommunicationFlow = ({
|
|
|
212
215
|
singleChannelStrategy: {
|
|
213
216
|
variant: {
|
|
214
217
|
channel,
|
|
215
|
-
...(contentKey && { [contentKey]:
|
|
218
|
+
...(contentKey && { [contentKey]: { channel, ...contentPayload } }),
|
|
216
219
|
...(deliveryKey && { [deliveryKey]: { channelSettings: { channel, ...channelSettings } } }),
|
|
217
220
|
},
|
|
218
221
|
},
|
|
@@ -391,7 +391,7 @@ describe('handleSave — CCS flow', () => {
|
|
|
391
391
|
singleChannelStrategy: expect.objectContaining({
|
|
392
392
|
variant: expect.objectContaining({
|
|
393
393
|
channel: 'SMS',
|
|
394
|
-
smsMessageContent: { message: 'Hello' },
|
|
394
|
+
smsMessageContent: { channel: 'SMS', message: 'Hello' },
|
|
395
395
|
}),
|
|
396
396
|
}),
|
|
397
397
|
}),
|
|
@@ -399,7 +399,40 @@ describe('handleSave — CCS flow', () => {
|
|
|
399
399
|
expect(onSave).toHaveBeenCalledTimes(1);
|
|
400
400
|
});
|
|
401
401
|
|
|
402
|
-
it('
|
|
402
|
+
it('transforms EMAIL content from the legacy editor shape (emailSubject) to CCS\'s messageSubject', async () => {
|
|
403
|
+
const onSave = jest.fn();
|
|
404
|
+
renderWithFlow({
|
|
405
|
+
features: {},
|
|
406
|
+
config: ccsConfig,
|
|
407
|
+
initialData: {
|
|
408
|
+
contentItems: [{
|
|
409
|
+
channel: 'EMAIL',
|
|
410
|
+
templateData: { emailSubject: 'Order Confirmed', messageBody: '<html>Hi</html>' },
|
|
411
|
+
}],
|
|
412
|
+
},
|
|
413
|
+
onSave,
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
await userEvent.click(screen.getByRole('button', { name: /^save$/i }));
|
|
417
|
+
|
|
418
|
+
await waitFor(() => expect(createCommDefinition).toHaveBeenCalledTimes(1));
|
|
419
|
+
expect(createCommDefinition).toHaveBeenCalledWith(
|
|
420
|
+
expect.objectContaining({
|
|
421
|
+
singleChannelStrategy: expect.objectContaining({
|
|
422
|
+
variant: expect.objectContaining({
|
|
423
|
+
channel: 'EMAIL',
|
|
424
|
+
emailMessageContent: {
|
|
425
|
+
channel: 'EMAIL',
|
|
426
|
+
messageSubject: 'Order Confirmed',
|
|
427
|
+
messageBody: '<html>Hi</html>',
|
|
428
|
+
},
|
|
429
|
+
}),
|
|
430
|
+
}),
|
|
431
|
+
}),
|
|
432
|
+
);
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('normalizes the internal MOBILEPUSH channel to CCS\'s PUSH enum (keys stay mpush*)', async () => {
|
|
403
436
|
const onSave = jest.fn();
|
|
404
437
|
renderWithFlow({
|
|
405
438
|
features: {},
|
|
@@ -417,8 +450,8 @@ describe('handleSave — CCS flow', () => {
|
|
|
417
450
|
expect.objectContaining({
|
|
418
451
|
singleChannelStrategy: expect.objectContaining({
|
|
419
452
|
variant: expect.objectContaining({
|
|
420
|
-
channel: '
|
|
421
|
-
mpushMessageContent: { messageSubject: 'Hi' },
|
|
453
|
+
channel: 'PUSH',
|
|
454
|
+
mpushMessageContent: { channel: 'PUSH', messageSubject: 'Hi' },
|
|
422
455
|
}),
|
|
423
456
|
}),
|
|
424
457
|
}),
|
|
@@ -51,7 +51,9 @@ export const CCS_CHANNEL_CONTENT_KEY_MAP = {
|
|
|
51
51
|
SMS: 'smsMessageContent',
|
|
52
52
|
EMAIL: 'emailMessageContent',
|
|
53
53
|
WHATSAPP: 'whatsappMessageContent',
|
|
54
|
-
|
|
54
|
+
// CCS's channel enum value for mobile push is 'PUSH' (verified against real
|
|
55
|
+
// create responses), even though the content/delivery keys stay 'mpush*'.
|
|
56
|
+
PUSH: 'mpushMessageContent',
|
|
55
57
|
INAPP: 'inAppMessageContent',
|
|
56
58
|
ANDROID: 'androidMessageContent',
|
|
57
59
|
IOS: 'iosMessageContent',
|
|
@@ -62,11 +64,26 @@ export const CCS_CHANNEL_CONTENT_KEY_MAP = {
|
|
|
62
64
|
RCS: 'rcsMessageContent',
|
|
63
65
|
};
|
|
64
66
|
|
|
67
|
+
// contentItem.templateData is built by the legacy CreativesContainer content
|
|
68
|
+
// editor (messageMeta-oriented field names) — for channels whose legacy field
|
|
69
|
+
// names don't match CCS's own content schema, transform before sending rather
|
|
70
|
+
// than dumping templateData as-is. EMAIL: legacy stores the subject as
|
|
71
|
+
// `emailSubject` (see getContentBody.js), CCS expects `messageSubject`;
|
|
72
|
+
// `messageBody` already matches CCS's name by coincidence. Channels absent
|
|
73
|
+
// here are passed through unchanged (their legacy/CCS field names already
|
|
74
|
+
// align, e.g. SMS's `message`/`messageBody`).
|
|
75
|
+
export const CCS_CONTENT_TRANSFORMS = {
|
|
76
|
+
EMAIL: (templateData = {}) => ({
|
|
77
|
+
messageSubject: templateData.emailSubject,
|
|
78
|
+
messageBody: templateData.messageBody,
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
|
|
65
82
|
export const CCS_CHANNEL_DELIVERY_KEY_MAP = {
|
|
66
83
|
SMS: 'smsDeliverySettings',
|
|
67
84
|
EMAIL: 'emailDeliverySettings',
|
|
68
85
|
WHATSAPP: 'whatsappDeliverySettings',
|
|
69
|
-
|
|
86
|
+
PUSH: 'mpushDeliverySettings',
|
|
70
87
|
INAPP: 'inAppDeliverySettings',
|
|
71
88
|
ANDROID: 'androidDeliverySettings',
|
|
72
89
|
IOS: 'iosDeliverySettings',
|
|
@@ -79,10 +96,12 @@ export const CCS_CHANNEL_DELIVERY_KEY_MAP = {
|
|
|
79
96
|
|
|
80
97
|
// The UI's own internal channel identifier for mobile push is 'MOBILEPUSH'
|
|
81
98
|
// (see CreativesContainer/constants.js MOBILE_PUSH), but CCS's channel enum
|
|
82
|
-
//
|
|
83
|
-
//
|
|
99
|
+
// value is 'PUSH' (verified against real create responses — the content/
|
|
100
|
+
// delivery KEYS still say 'mpush*', only the enum VALUE is 'PUSH') —
|
|
101
|
+
// normalize before building the CCS payload. Every other channel identifier
|
|
102
|
+
// matches CCS as-is.
|
|
84
103
|
export const CCS_CHANNEL_NAME_MAP = {
|
|
85
|
-
MOBILEPUSH: '
|
|
104
|
+
MOBILEPUSH: 'PUSH',
|
|
86
105
|
};
|
|
87
106
|
|
|
88
107
|
// Channel config - single source of truth for CreativesContainer and TemplatesV2
|