@retailrocketgroup/retailrocket-create.multicast-vue-email-template-render 5.0.384767 → 6.0.388429-dev
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/.turbo/turbo-build.log +5 -5
- package/dist/assets/index.css +1 -1
- package/dist/assets/index.js +236 -237
- package/dist/index.html +14 -1
- package/index.html +14 -1
- package/package.json +1 -1
- package/src/createMulticastEmailTemplateApp.ts +119 -123
package/package.json
CHANGED
|
@@ -5,9 +5,11 @@ import { createApp } from 'vue';
|
|
|
5
5
|
import { createVuetify } from 'vuetify';
|
|
6
6
|
import { ClickOutside } from 'vuetify/directives';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { TemplatesGallery } from '@easy-wizzy/core';
|
|
9
9
|
import { createSimpleDataForm, matcherFactory } from '@easy-wizzy/core';
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
GeneralStringExpressionDataSource
|
|
12
|
+
} from '@easy-wizzy/retailrocket-common';
|
|
11
13
|
import { expressionEvaluatorFactory } from '@easy-wizzy/core';
|
|
12
14
|
import { listExpressionEvaluatorFactory } from '@easy-wizzy/core';
|
|
13
15
|
import { numberExpressionEvaluatorDelegate } from '@easy-wizzy/core';
|
|
@@ -15,15 +17,11 @@ import { stringExpressionEvaluatorFactory } from '@easy-wizzy/core';
|
|
|
15
17
|
import { dataStructBuilderExpressionEvaluatorFactory } from '@easy-wizzy/core';
|
|
16
18
|
|
|
17
19
|
import type { EmailTemplateType } from '@easy-wizzy/core';
|
|
18
|
-
import type { EmailTemplatePreviewTileComponent } from '@easy-wizzy/core';
|
|
19
20
|
import type { LocaleKey } from '@easy-wizzy/core';
|
|
20
21
|
import type { StringExpressionEvaluatorDelegate } from '@easy-wizzy/core';
|
|
21
22
|
|
|
22
|
-
import {
|
|
23
|
-
import { emailTemplatePreviewTileComponentFactory } from '@easy-wizzy/common-app';
|
|
24
|
-
import { emailTemplatePreviewTileDepsFactory } from '@easy-wizzy/common-app';
|
|
23
|
+
import { templatesGalleryDepsFactory } from '@easy-wizzy/common-app';
|
|
25
24
|
import { productImageUrlBuilderExpressionEvaluatorFactory } from '@easy-wizzy/common-app';
|
|
26
|
-
import { defaultTemplateLibraryFactory } from '@easy-wizzy/common-app';
|
|
27
25
|
import { apiMachineFetchFactory } from '@easy-wizzy/common-app';
|
|
28
26
|
import { variableSelectorDepsFactory } from '@easy-wizzy/common-app';
|
|
29
27
|
|
|
@@ -46,6 +44,18 @@ import { multicastNumberExpressionDataSourceEvaluatorFactory } from '@/implement
|
|
|
46
44
|
import { multicastStringExpressionDataSourceEvaluatorFactory } from '@/implementation/DataSources/StringExpressionDataSource/multicastEvaluateStringExpressionDataSource';
|
|
47
45
|
|
|
48
46
|
import { createApi as listExpressionDataSourceBffClientFactory } from '@retailrocket/retailrocket.wysiwyg.bff.v2.apiclients.listexpressiondatasource';
|
|
47
|
+
import type { TemplatePreviewCardDeps } from '@easy-wizzy/core';
|
|
48
|
+
import type {
|
|
49
|
+
ListExpressionDataSourceBffClient
|
|
50
|
+
} from '@easy-wizzy/common-app';
|
|
51
|
+
import type { FavoriteTemplateParam } from '@easy-wizzy/common-app';
|
|
52
|
+
import type {
|
|
53
|
+
GeneralListExpressionDataSource,
|
|
54
|
+
GeneralNumberExpressionDataSource,
|
|
55
|
+
} from '@easy-wizzy/retailrocket-common/';
|
|
56
|
+
import {
|
|
57
|
+
templatePreviewCardDepsFactory
|
|
58
|
+
} from '@easy-wizzy/common-app';
|
|
49
59
|
|
|
50
60
|
const appTagId = '#app';
|
|
51
61
|
const appTag = document.querySelector(appTagId);
|
|
@@ -60,8 +70,14 @@ const params = {
|
|
|
60
70
|
antiForgeryFormTokenValue: appTag!.getAttribute('data-anti-forgery-form-token-value')!,
|
|
61
71
|
createEmailTemplateSubmitUrl: appTag!.getAttribute('data-create-email-template-submit-url')!,
|
|
62
72
|
initialEmailTemplateJson: appTag!.getAttribute('data-initial-multicast-template')!,
|
|
63
|
-
multicastFavoritesTemplates: JSON
|
|
64
|
-
|
|
73
|
+
multicastFavoritesTemplates: JSON
|
|
74
|
+
.parse(
|
|
75
|
+
appTag!.getAttribute('data-multicast-favorites-templates')!
|
|
76
|
+
) as FavoriteTemplateParam[],
|
|
77
|
+
commonFavoritesTemplates: JSON
|
|
78
|
+
.parse(
|
|
79
|
+
appTag!.getAttribute('data-common-favorites-templates')!
|
|
80
|
+
) as FavoriteTemplateParam[],
|
|
65
81
|
exitLink: appTag!.getAttribute('data-exit-link')!,
|
|
66
82
|
localeKey: appTag!.getAttribute('data-locale-key') as LocaleKey || 'en'
|
|
67
83
|
};
|
|
@@ -83,12 +99,14 @@ const listExpressionDataSourceBffClient = listExpressionDataSourceBffClientFacto
|
|
|
83
99
|
const createTemplate = <
|
|
84
100
|
TListExpressionDataSource,
|
|
85
101
|
TNumberExpressionDataSource,
|
|
86
|
-
TStringExpressionDataSource
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
TStringExpressionDataSource
|
|
103
|
+
>(arg: {
|
|
104
|
+
template: EmailTemplateType<
|
|
105
|
+
TListExpressionDataSource,
|
|
106
|
+
TNumberExpressionDataSource,
|
|
107
|
+
TStringExpressionDataSource
|
|
108
|
+
>
|
|
109
|
+
}): void => {
|
|
92
110
|
const formData = new FormData();
|
|
93
111
|
formData.append(
|
|
94
112
|
params.antiForgeryFormTokenName,
|
|
@@ -112,18 +130,21 @@ const nextCouponFromBatch: NextCouponFromBatchType = {
|
|
|
112
130
|
BatchId: ''
|
|
113
131
|
};
|
|
114
132
|
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
133
|
+
const _templatePreviewCardDepsFactory = (arg: {
|
|
134
|
+
partnerId: string,
|
|
135
|
+
listExpressionDataSourceBffClient: ListExpressionDataSourceBffClient,
|
|
136
|
+
contactCustomData: ContactCustomData,
|
|
137
|
+
nextCouponFromBatch: NextCouponFromBatchType,
|
|
138
|
+
localeKey: LocaleKey
|
|
139
|
+
}): TemplatePreviewCardDeps<
|
|
140
|
+
MulticastListExpressionDataSource,
|
|
141
|
+
MulticastNumberExpressionDataSource,
|
|
142
|
+
MulticastStringExpressionDataSource
|
|
143
|
+
> => {
|
|
123
144
|
|
|
124
145
|
const listExpressionDataSourceEvaluator = multicastEvaluateListExpressionDataSourceFactory({
|
|
125
|
-
partnerId:
|
|
126
|
-
listExpressionDataSourceBffClient: listExpressionDataSourceBffClient,
|
|
146
|
+
partnerId: arg.partnerId,
|
|
147
|
+
listExpressionDataSourceBffClient: arg.listExpressionDataSourceBffClient,
|
|
127
148
|
customerStockId: undefined
|
|
128
149
|
});
|
|
129
150
|
|
|
@@ -132,7 +153,7 @@ const createEmailTemplatePreviewTile = (arg: {
|
|
|
132
153
|
});
|
|
133
154
|
|
|
134
155
|
const numberExpressionDataSourceEvaluator = multicastNumberExpressionDataSourceEvaluatorFactory({
|
|
135
|
-
contactCustomData: contactCustomData
|
|
156
|
+
contactCustomData: arg.contactCustomData
|
|
136
157
|
});
|
|
137
158
|
|
|
138
159
|
const numberExpressionEvaluator = numberExpressionEvaluatorDelegate({
|
|
@@ -152,8 +173,8 @@ const createEmailTemplatePreviewTile = (arg: {
|
|
|
152
173
|
partnerId: params.partnerId,
|
|
153
174
|
numberExpressionEvaluator: numberExpressionEvaluator
|
|
154
175
|
}),
|
|
155
|
-
contactCustomData: contactCustomData,
|
|
156
|
-
nextCouponFromBatch: nextCouponFromBatch
|
|
176
|
+
contactCustomData: arg.contactCustomData,
|
|
177
|
+
nextCouponFromBatch: arg.nextCouponFromBatch
|
|
157
178
|
})
|
|
158
179
|
});
|
|
159
180
|
|
|
@@ -167,56 +188,43 @@ const createEmailTemplatePreviewTile = (arg: {
|
|
|
167
188
|
});
|
|
168
189
|
|
|
169
190
|
const stringExpressionBuilderPlugin = stringExpressionBuilderPluginFactory({
|
|
170
|
-
localeKey:
|
|
191
|
+
localeKey: arg.localeKey
|
|
171
192
|
});
|
|
172
193
|
|
|
173
194
|
const dataStructExpressionEvaluator = dataStructBuilderExpressionEvaluatorFactory({
|
|
174
195
|
expressionEvaluator: expressionEvaluator
|
|
175
196
|
});
|
|
176
197
|
|
|
177
|
-
return
|
|
198
|
+
return templatePreviewCardDepsFactory<
|
|
178
199
|
MulticastListExpressionDataSource,
|
|
179
200
|
MulticastNumberExpressionDataSource,
|
|
180
201
|
MulticastStringExpressionDataSource
|
|
181
202
|
>({
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
localeKey: params.localeKey,
|
|
190
|
-
dataSourceFieldNameDelegate: ({ dataSource }) => {
|
|
191
|
-
return matcherFactory(dataSource as GeneralStringExpressionDataSource).Match({
|
|
192
|
-
StringFromContactCustomData: (customData) => customData.FieldName,
|
|
193
|
-
StringFromContactCustomDataWithFallback: (customDataWithFallback) => customDataWithFallback.FallbackValue,
|
|
194
|
-
ProductImageUrlBuilderExpression: () => 'ImageResizer',
|
|
195
|
-
NextCouponFromBatch: () => 'Coupon'
|
|
196
|
-
});
|
|
197
|
-
},
|
|
198
|
-
richTextToolbarPlugins: [
|
|
199
|
-
richTextToolbarPluginFactory({
|
|
200
|
-
richTextToolbarPluginComponent: VariableSelector,
|
|
201
|
-
deps: variableSelectorDepsFactory({
|
|
202
|
-
localeKey: params.localeKey,
|
|
203
|
-
stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
|
|
204
|
-
})
|
|
205
|
-
})
|
|
206
|
-
],
|
|
207
|
-
listExpressionEvaluator: listExpressionEvaluator,
|
|
208
|
-
numberExpressionEvaluator: numberExpressionEvaluator,
|
|
209
|
-
stringExpressionEvaluator: stringExpressionEvaluator,
|
|
210
|
-
dataStructExpressionEvaluator: dataStructExpressionEvaluator,
|
|
211
|
-
expressionEvaluator: expressionEvaluator,
|
|
212
|
-
stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
|
|
213
|
-
}),
|
|
214
|
-
onFavoriteTemplateSelected: () => {
|
|
215
|
-
createTemplate({
|
|
216
|
-
template: arg.template
|
|
203
|
+
localeKey: params.localeKey,
|
|
204
|
+
dataSourceFieldNameDelegate: ({ dataSource }) => {
|
|
205
|
+
return matcherFactory(dataSource as GeneralStringExpressionDataSource).Match({
|
|
206
|
+
StringFromContactCustomData: (customData) => customData.FieldName,
|
|
207
|
+
StringFromContactCustomDataWithFallback: (customDataWithFallback) => customDataWithFallback.FallbackValue,
|
|
208
|
+
ProductImageUrlBuilderExpression: () => 'ImageResizer',
|
|
209
|
+
NextCouponFromBatch: () => 'Coupon'
|
|
217
210
|
});
|
|
218
211
|
},
|
|
219
|
-
|
|
212
|
+
richTextToolbarPlugins: [
|
|
213
|
+
richTextToolbarPluginFactory({
|
|
214
|
+
richTextToolbarPluginComponent: VariableSelector,
|
|
215
|
+
deps: variableSelectorDepsFactory({
|
|
216
|
+
localeKey: arg.localeKey,
|
|
217
|
+
stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
],
|
|
221
|
+
listExpressionEvaluator: listExpressionEvaluator,
|
|
222
|
+
numberExpressionEvaluator: numberExpressionEvaluator,
|
|
223
|
+
stringExpressionEvaluator: stringExpressionEvaluator,
|
|
224
|
+
dataStructExpressionEvaluator: dataStructExpressionEvaluator,
|
|
225
|
+
expressionEvaluator: expressionEvaluator,
|
|
226
|
+
stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
|
|
227
|
+
})
|
|
220
228
|
};
|
|
221
229
|
|
|
222
230
|
const initialEmailTemplate = params.localeKey === 'ru'
|
|
@@ -224,68 +232,56 @@ const initialEmailTemplate = params.localeKey === 'ru'
|
|
|
224
232
|
: initialEmailTemplateEn;
|
|
225
233
|
|
|
226
234
|
const app = createApp(
|
|
227
|
-
|
|
235
|
+
TemplatesGallery,
|
|
228
236
|
{
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
237
|
+
onTemplateSelected: (template: EmailTemplateType<
|
|
238
|
+
MulticastListExpressionDataSource,
|
|
239
|
+
MulticastNumberExpressionDataSource,
|
|
240
|
+
MulticastStringExpressionDataSource
|
|
241
|
+
>) => {
|
|
232
242
|
createTemplate({
|
|
233
|
-
template:
|
|
234
|
-
? JSON.parse(params.initialEmailTemplateJson)
|
|
235
|
-
: initialEmailTemplate,
|
|
243
|
+
template: template
|
|
236
244
|
});
|
|
237
245
|
},
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
commonFavoriteTemplates: params
|
|
247
|
+
.commonFavoritesTemplates
|
|
248
|
+
.map(t => ({
|
|
249
|
+
template: JSON.parse(t.templateJson) as EmailTemplateType<
|
|
250
|
+
GeneralListExpressionDataSource,
|
|
251
|
+
GeneralNumberExpressionDataSource,
|
|
252
|
+
GeneralStringExpressionDataSource
|
|
253
|
+
>,
|
|
254
|
+
templateName: t.favoriteTemplateName
|
|
255
|
+
})),
|
|
256
|
+
customFavoriteTemplates: params
|
|
257
|
+
.multicastFavoritesTemplates
|
|
258
|
+
.map(t => ({
|
|
259
|
+
template: JSON.parse(t.templateJson) as EmailTemplateType<
|
|
260
|
+
MulticastListExpressionDataSource,
|
|
261
|
+
MulticastNumberExpressionDataSource,
|
|
262
|
+
MulticastStringExpressionDataSource
|
|
263
|
+
>,
|
|
264
|
+
templateName: t.favoriteTemplateName
|
|
265
|
+
})),
|
|
266
|
+
deps: templatesGalleryDepsFactory<
|
|
267
|
+
MulticastListExpressionDataSource,
|
|
268
|
+
MulticastNumberExpressionDataSource,
|
|
269
|
+
MulticastStringExpressionDataSource
|
|
270
|
+
>({
|
|
271
|
+
partnerId: params.partnerId,
|
|
272
|
+
localeKey: params.localeKey,
|
|
273
|
+
templatePreviewCardDeps: _templatePreviewCardDepsFactory({
|
|
244
274
|
partnerId: params.partnerId,
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
templateName: o.favoriteTemplateName
|
|
256
|
-
})
|
|
257
|
-
})),
|
|
258
|
-
...params
|
|
259
|
-
.multicastFavoritesTemplates
|
|
260
|
-
.map(o => ({
|
|
261
|
-
templateName: o.favoriteTemplateName,
|
|
262
|
-
previewTileComponent: createEmailTemplatePreviewTile({
|
|
263
|
-
template: JSON.parse(o.templateJson),
|
|
264
|
-
templateName: o.favoriteTemplateName
|
|
265
|
-
})
|
|
266
|
-
})),
|
|
267
|
-
],
|
|
268
|
-
default: [
|
|
269
|
-
...defaultTemplateLibraryFactory(params.localeKey)
|
|
270
|
-
.map(o => ({
|
|
271
|
-
templateName: o.favoriteTemplateName,
|
|
272
|
-
previewTileComponent: createEmailTemplatePreviewTile({
|
|
273
|
-
template: o.defaultTemplate as EmailTemplateType<
|
|
274
|
-
MulticastListExpressionDataSource,
|
|
275
|
-
MulticastNumberExpressionDataSource,
|
|
276
|
-
MulticastStringExpressionDataSource
|
|
277
|
-
>,
|
|
278
|
-
templateName: o.favoriteTemplateName
|
|
279
|
-
})
|
|
280
|
-
}))
|
|
281
|
-
]
|
|
282
|
-
},
|
|
283
|
-
initialEmailTemplate: params.initialEmailTemplateJson.length
|
|
284
|
-
? JSON.parse(params.initialEmailTemplateJson)
|
|
285
|
-
: initialEmailTemplate,
|
|
286
|
-
exitLink: params.exitLink
|
|
287
|
-
}
|
|
288
|
-
)
|
|
275
|
+
listExpressionDataSourceBffClient: listExpressionDataSourceBffClient,
|
|
276
|
+
contactCustomData: contactCustomData,
|
|
277
|
+
nextCouponFromBatch: nextCouponFromBatch,
|
|
278
|
+
localeKey: params.localeKey
|
|
279
|
+
}),
|
|
280
|
+
initialEmailTemplate: params.initialEmailTemplateJson.length
|
|
281
|
+
? JSON.parse(params.initialEmailTemplateJson)
|
|
282
|
+
: initialEmailTemplate,
|
|
283
|
+
exitLink: params.exitLink
|
|
284
|
+
})
|
|
289
285
|
}
|
|
290
286
|
);
|
|
291
287
|
|