@retailrocketgroup/retailrocket-create.transactional-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 +4 -4
- package/dist/FavoriteTransactionalTemplateParam.d.ts +5 -0
- package/dist/assets/index.css +1 -1
- package/dist/assets/index.js +236 -237
- package/package.json +1 -1
- package/src/FavoriteTransactionalTemplateParam.ts +5 -0
- package/src/createTransactionalEmailTemplateApp.ts +119 -143
package/package.json
CHANGED
|
@@ -5,33 +5,37 @@ 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
|
+
GeneralListExpressionDataSource,
|
|
12
|
+
GeneralNumberExpressionDataSource,
|
|
13
|
+
GeneralStringExpressionDataSource
|
|
14
|
+
} from '@easy-wizzy/retailrocket-common';
|
|
11
15
|
import { expressionEvaluatorFactory } from '@easy-wizzy/core';
|
|
12
16
|
import { listExpressionEvaluatorFactory } from '@easy-wizzy/core';
|
|
13
17
|
import { numberExpressionEvaluatorDelegate } from '@easy-wizzy/core';
|
|
14
18
|
import { stringExpressionEvaluatorFactory } from '@easy-wizzy/core';
|
|
15
19
|
import { dataStructBuilderExpressionEvaluatorFactory } from '@easy-wizzy/core';
|
|
16
20
|
|
|
17
|
-
import type { DataType } from '@easy-wizzy/core';
|
|
18
21
|
import type { EmailTemplateType } from '@easy-wizzy/core';
|
|
19
|
-
import type { EmailTemplatePreviewTileComponent } from '@easy-wizzy/core';
|
|
20
22
|
import type { LocaleKey } from '@easy-wizzy/core';
|
|
21
23
|
import type { StringExpressionEvaluatorDelegate } from '@easy-wizzy/core';
|
|
22
24
|
|
|
23
|
-
import {
|
|
24
|
-
import { emailTemplatePreviewTileComponentFactory } from '@easy-wizzy/common-app';
|
|
25
|
-
import { emailTemplatePreviewTileDepsFactory } from '@easy-wizzy/common-app';
|
|
25
|
+
import { templatesGalleryDepsFactory } from '@easy-wizzy/common-app';
|
|
26
26
|
import { productImageUrlBuilderExpressionEvaluatorFactory } from '@easy-wizzy/common-app';
|
|
27
|
-
import { defaultTemplateLibraryFactory } from '@easy-wizzy/common-app';
|
|
28
27
|
import { apiMachineFetchFactory } from '@easy-wizzy/common-app';
|
|
29
28
|
import { variableSelectorDepsFactory } from '@easy-wizzy/common-app';
|
|
30
29
|
|
|
31
30
|
import type { ApiMachineFetchDelegate } from '@easy-wizzy/common-app';
|
|
31
|
+
import type { FavoriteTemplateParam } from '@easy-wizzy/common-app';
|
|
32
|
+
import type {
|
|
33
|
+
ListExpressionDataSourceBffClient
|
|
34
|
+
} from '@easy-wizzy/common-app';
|
|
32
35
|
|
|
33
36
|
import { stringExpressionBuilderPluginFactory, richTextToolbarPluginFactory, VariableSelector } from '@easy-wizzy/retailrocket-common';
|
|
34
37
|
|
|
38
|
+
import type { ContactCustomData } from '@easy-wizzy/retailrocket-common';
|
|
35
39
|
import type { NextCouponFromBatchType } from '@easy-wizzy/retailrocket-common';
|
|
36
40
|
|
|
37
41
|
import type { TransactionalListExpressionDataSource } from '@easy-wizzy/retailrocket-transactional';
|
|
@@ -46,6 +50,12 @@ import { transactionalNumberExpressionDataSourceEvaluatorFactory } from '@/imple
|
|
|
46
50
|
import { transactionalStringExpressionDataSourceEvaluatorFactory } from '@/implementation/DataSources/StringExpressionDataSource/transactionalEvaluateStringExpressionDataSource';
|
|
47
51
|
|
|
48
52
|
import { createApi as listExpressionDataSourceBffClientFactory } from '@retailrocket/retailrocket.wysiwyg.bff.v2.apiclients.listexpressiondatasource';
|
|
53
|
+
import type { TemplatePreviewCardDeps } from '@easy-wizzy/core';
|
|
54
|
+
import type { DataType } from '@easy-wizzy/core';
|
|
55
|
+
import type { FavoriteTransactionalTemplateParam } from '@/FavoriteTransactionalTemplateParam.ts';
|
|
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,15 +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-transactional-template')!,
|
|
63
|
-
transactionalFavoritesTemplates: JSON
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}],
|
|
73
|
+
transactionalFavoritesTemplates: JSON
|
|
74
|
+
.parse(
|
|
75
|
+
appTag!.getAttribute('data-transactional-favorites-templates')!
|
|
76
|
+
) as FavoriteTransactionalTemplateParam[],
|
|
77
|
+
commonFavoritesTemplates: JSON
|
|
78
|
+
.parse(
|
|
79
|
+
appTag!.getAttribute('data-common-favorites-templates')!
|
|
80
|
+
) as FavoriteTemplateParam[],
|
|
72
81
|
exitLink: appTag!.getAttribute('data-exit-link')!,
|
|
73
82
|
localeKey: appTag!.getAttribute('data-locale-key') as LocaleKey || 'en'
|
|
74
83
|
};
|
|
@@ -90,12 +99,12 @@ const listExpressionDataSourceBffClient = listExpressionDataSourceBffClientFacto
|
|
|
90
99
|
const createTemplate = <
|
|
91
100
|
TListExpressionDataSource,
|
|
92
101
|
TNumberExpressionDataSource,
|
|
93
|
-
TStringExpressionDataSource
|
|
102
|
+
TStringExpressionDataSource
|
|
103
|
+
>(arg: {
|
|
94
104
|
template: EmailTemplateType<
|
|
95
105
|
TListExpressionDataSource,
|
|
96
106
|
TNumberExpressionDataSource,
|
|
97
|
-
TStringExpressionDataSource
|
|
98
|
-
previewData: unknown,
|
|
107
|
+
TStringExpressionDataSource>
|
|
99
108
|
}): void => {
|
|
100
109
|
const formData = new FormData();
|
|
101
110
|
formData.append(
|
|
@@ -104,9 +113,6 @@ const createTemplate = <
|
|
|
104
113
|
formData.append(
|
|
105
114
|
'template',
|
|
106
115
|
JSON.stringify(arg.template));
|
|
107
|
-
formData.append(
|
|
108
|
-
'previewData',
|
|
109
|
-
JSON.stringify(arg.previewData));
|
|
110
116
|
|
|
111
117
|
const form = createSimpleDataForm({
|
|
112
118
|
method: 'POST',
|
|
@@ -118,19 +124,23 @@ const createTemplate = <
|
|
|
118
124
|
form.submit();
|
|
119
125
|
};
|
|
120
126
|
|
|
127
|
+
const contactCustomData: ContactCustomData = {};
|
|
121
128
|
const nextCouponFromBatch: NextCouponFromBatchType = {
|
|
122
129
|
BatchId: ''
|
|
123
130
|
};
|
|
124
131
|
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
templateData: DataType
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
const _templatePreviewCardDepsFactory = (arg: {
|
|
133
|
+
partnerId: string,
|
|
134
|
+
listExpressionDataSourceBffClient: ListExpressionDataSourceBffClient,
|
|
135
|
+
contactCustomData: ContactCustomData,
|
|
136
|
+
nextCouponFromBatch: NextCouponFromBatchType,
|
|
137
|
+
localeKey: LocaleKey,
|
|
138
|
+
templateData: DataType
|
|
139
|
+
}): TemplatePreviewCardDeps<
|
|
140
|
+
TransactionalListExpressionDataSource,
|
|
141
|
+
TransactionalNumberExpressionDataSource,
|
|
142
|
+
TransactionalStringExpressionDataSource
|
|
143
|
+
> => {
|
|
134
144
|
|
|
135
145
|
const listExpressionDataSourceEvaluator = transactionalListExpressionDataSourceEvaluatorFactory({
|
|
136
146
|
partnerId: params.partnerId,
|
|
@@ -144,7 +154,7 @@ const createEmailTemplatePreviewTile = (arg: {
|
|
|
144
154
|
});
|
|
145
155
|
|
|
146
156
|
const numberExpressionDataSourceEvaluator = transactionalNumberExpressionDataSourceEvaluatorFactory({
|
|
147
|
-
getTransactionalTemplateData: () => arg.templateData
|
|
157
|
+
getTransactionalTemplateData: () => arg.templateData,
|
|
148
158
|
});
|
|
149
159
|
|
|
150
160
|
const numberExpressionEvaluator = numberExpressionEvaluatorDelegate({
|
|
@@ -160,12 +170,12 @@ const createEmailTemplatePreviewTile = (arg: {
|
|
|
160
170
|
listExpressionEvaluator: listExpressionEvaluator,
|
|
161
171
|
numberExpressionEvaluator: numberExpressionEvaluator,
|
|
162
172
|
stringExpressionDataSourceEvaluatorFactory: () => transactionalStringExpressionDataSourceEvaluatorFactory({
|
|
163
|
-
getTransactionalTemplateData: () => arg.templateData,
|
|
164
173
|
productImageUrlBuilderExpressionEvaluator: productImageUrlBuilderExpressionEvaluatorFactory({
|
|
165
174
|
partnerId: params.partnerId,
|
|
166
175
|
numberExpressionEvaluator: numberExpressionEvaluator
|
|
167
176
|
}),
|
|
168
|
-
|
|
177
|
+
getTransactionalTemplateData: () => arg.templateData,
|
|
178
|
+
nextCouponFromBatch: arg.nextCouponFromBatch
|
|
169
179
|
})
|
|
170
180
|
});
|
|
171
181
|
|
|
@@ -178,62 +188,44 @@ const createEmailTemplatePreviewTile = (arg: {
|
|
|
178
188
|
})
|
|
179
189
|
});
|
|
180
190
|
|
|
181
|
-
const
|
|
182
|
-
|
|
191
|
+
const stringExpressionBuilderPlugin = stringExpressionBuilderPluginFactory({
|
|
192
|
+
localeKey: arg.localeKey
|
|
183
193
|
});
|
|
184
194
|
|
|
185
|
-
const
|
|
186
|
-
|
|
195
|
+
const dataStructExpressionEvaluator = dataStructBuilderExpressionEvaluatorFactory({
|
|
196
|
+
expressionEvaluator: expressionEvaluator
|
|
187
197
|
});
|
|
188
198
|
|
|
189
|
-
return
|
|
199
|
+
return templatePreviewCardDepsFactory<
|
|
190
200
|
TransactionalListExpressionDataSource,
|
|
191
201
|
TransactionalNumberExpressionDataSource,
|
|
192
202
|
TransactionalStringExpressionDataSource
|
|
193
203
|
>({
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
localeKey: params.localeKey,
|
|
202
|
-
dataSourceFieldNameDelegate: ({ dataSource }) => {
|
|
203
|
-
return matcherFactory(dataSource as GeneralStringExpressionDataSource).Match({
|
|
204
|
-
StringFromContactCustomData: (customData) => customData.FieldName,
|
|
205
|
-
StringFromContactCustomDataWithFallback: (customDataWithFallback) => customDataWithFallback.FallbackValue,
|
|
206
|
-
ProductImageUrlBuilderExpression: () => 'ImageResizer',
|
|
207
|
-
NextCouponFromBatch: () => 'Coupon'
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
richTextToolbarPlugins: [
|
|
211
|
-
richTextToolbarPluginFactory({
|
|
212
|
-
richTextToolbarPluginComponent: VariableSelector,
|
|
213
|
-
deps: variableSelectorDepsFactory({
|
|
214
|
-
localeKey: params.localeKey,
|
|
215
|
-
stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
|
|
216
|
-
})
|
|
217
|
-
})
|
|
218
|
-
],
|
|
219
|
-
listExpressionEvaluator: listExpressionEvaluator,
|
|
220
|
-
numberExpressionEvaluator: numberExpressionEvaluator,
|
|
221
|
-
stringExpressionEvaluator: stringExpressionEvaluator,
|
|
222
|
-
dataStructExpressionEvaluator: dataStructExpressionEvaluator!,
|
|
223
|
-
expressionEvaluator: expressionEvaluator,
|
|
224
|
-
stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
|
|
225
|
-
}),
|
|
226
|
-
onFavoriteTemplateSelected: () => {
|
|
227
|
-
//eslint-disable-next-line no-console
|
|
228
|
-
console.log('onFavoriteTemplateSelected');
|
|
229
|
-
// create email template
|
|
230
|
-
createTemplate({
|
|
231
|
-
template: arg.template,
|
|
232
|
-
previewData: arg.templateData,
|
|
204
|
+
localeKey: params.localeKey,
|
|
205
|
+
dataSourceFieldNameDelegate: ({ dataSource }) => {
|
|
206
|
+
return matcherFactory(dataSource as GeneralStringExpressionDataSource).Match({
|
|
207
|
+
StringFromContactCustomData: (customData) => customData.FieldName,
|
|
208
|
+
StringFromContactCustomDataWithFallback: (customDataWithFallback) => customDataWithFallback.FallbackValue,
|
|
209
|
+
ProductImageUrlBuilderExpression: () => 'ImageResizer',
|
|
210
|
+
NextCouponFromBatch: () => 'Coupon'
|
|
233
211
|
});
|
|
234
|
-
// redirect
|
|
235
212
|
},
|
|
236
|
-
|
|
213
|
+
richTextToolbarPlugins: [
|
|
214
|
+
richTextToolbarPluginFactory({
|
|
215
|
+
richTextToolbarPluginComponent: VariableSelector,
|
|
216
|
+
deps: variableSelectorDepsFactory({
|
|
217
|
+
localeKey: arg.localeKey,
|
|
218
|
+
stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
],
|
|
222
|
+
listExpressionEvaluator: listExpressionEvaluator,
|
|
223
|
+
numberExpressionEvaluator: numberExpressionEvaluator,
|
|
224
|
+
stringExpressionEvaluator: stringExpressionEvaluator,
|
|
225
|
+
dataStructExpressionEvaluator: dataStructExpressionEvaluator,
|
|
226
|
+
expressionEvaluator: expressionEvaluator,
|
|
227
|
+
stringExpressionBuilderPlugin: stringExpressionBuilderPlugin
|
|
228
|
+
})
|
|
237
229
|
};
|
|
238
230
|
|
|
239
231
|
const initialEmailTemplate = params.localeKey === 'ru'
|
|
@@ -241,73 +233,57 @@ const initialEmailTemplate = params.localeKey === 'ru'
|
|
|
241
233
|
: initialEmailTemplateEn;
|
|
242
234
|
|
|
243
235
|
const app = createApp(
|
|
244
|
-
|
|
236
|
+
TemplatesGallery,
|
|
245
237
|
{
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
238
|
+
onTemplateSelected: (template: EmailTemplateType<
|
|
239
|
+
TransactionalListExpressionDataSource,
|
|
240
|
+
TransactionalNumberExpressionDataSource,
|
|
241
|
+
TransactionalStringExpressionDataSource
|
|
242
|
+
>) => {
|
|
249
243
|
createTemplate({
|
|
250
|
-
template:
|
|
251
|
-
? JSON.parse(params.initialEmailTemplateJson)
|
|
252
|
-
: initialEmailTemplate,
|
|
253
|
-
previewData: {}
|
|
244
|
+
template: template
|
|
254
245
|
});
|
|
255
246
|
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
247
|
+
commonFavoriteTemplates: params
|
|
248
|
+
.commonFavoritesTemplates
|
|
249
|
+
.map(t => ({
|
|
250
|
+
template: JSON.parse(t.templateJson) as EmailTemplateType<
|
|
251
|
+
GeneralListExpressionDataSource,
|
|
252
|
+
GeneralNumberExpressionDataSource,
|
|
253
|
+
GeneralStringExpressionDataSource
|
|
254
|
+
>,
|
|
255
|
+
templateName: t.favoriteTemplateName
|
|
256
|
+
})),
|
|
257
|
+
customFavoriteTemplates: params
|
|
258
|
+
.transactionalFavoritesTemplates
|
|
259
|
+
.map(t => ({
|
|
260
|
+
template: JSON.parse(t.templateJson) as EmailTemplateType<
|
|
261
|
+
TransactionalListExpressionDataSource,
|
|
262
|
+
TransactionalNumberExpressionDataSource,
|
|
263
|
+
TransactionalStringExpressionDataSource
|
|
264
|
+
>,
|
|
265
|
+
templateName: t.favoriteTemplateName
|
|
266
|
+
})),
|
|
267
|
+
deps: templatesGalleryDepsFactory<
|
|
268
|
+
TransactionalListExpressionDataSource,
|
|
269
|
+
TransactionalNumberExpressionDataSource,
|
|
270
|
+
TransactionalStringExpressionDataSource
|
|
271
|
+
>({
|
|
272
|
+
partnerId: params.partnerId,
|
|
273
|
+
localeKey: params.localeKey,
|
|
274
|
+
templatePreviewCardDeps: _templatePreviewCardDepsFactory({
|
|
263
275
|
partnerId: params.partnerId,
|
|
276
|
+
listExpressionDataSourceBffClient: listExpressionDataSourceBffClient,
|
|
277
|
+
contactCustomData: contactCustomData,
|
|
278
|
+
nextCouponFromBatch: nextCouponFromBatch,
|
|
264
279
|
localeKey: params.localeKey,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
template: JSON.parse(o.templateJson),
|
|
273
|
-
templateName: o.favoriteTemplateName,
|
|
274
|
-
templateData: {}
|
|
275
|
-
})
|
|
276
|
-
})),
|
|
277
|
-
...params
|
|
278
|
-
.transactionalFavoritesTemplates
|
|
279
|
-
.map(o => ({
|
|
280
|
-
templateName: o.favoriteTemplateName,
|
|
281
|
-
previewTileComponent: createEmailTemplatePreviewTile({
|
|
282
|
-
template: JSON.parse(o.templateJson),
|
|
283
|
-
templateName: o.favoriteTemplateName,
|
|
284
|
-
templateData: {}
|
|
285
|
-
})
|
|
286
|
-
}))
|
|
287
|
-
],
|
|
288
|
-
default: [
|
|
289
|
-
...defaultTemplateLibraryFactory(params.localeKey)
|
|
290
|
-
.map(o => ({
|
|
291
|
-
templateName: o.favoriteTemplateName,
|
|
292
|
-
previewTileComponent: createEmailTemplatePreviewTile({
|
|
293
|
-
template: o.defaultTemplate as EmailTemplateType<
|
|
294
|
-
TransactionalListExpressionDataSource,
|
|
295
|
-
TransactionalNumberExpressionDataSource,
|
|
296
|
-
TransactionalStringExpressionDataSource
|
|
297
|
-
>,
|
|
298
|
-
templateName: o.favoriteTemplateName,
|
|
299
|
-
templateData: {}
|
|
300
|
-
})
|
|
301
|
-
}))
|
|
302
|
-
]
|
|
303
|
-
}
|
|
304
|
-
,
|
|
305
|
-
initialEmailTemplate: params.initialEmailTemplateJson.length
|
|
306
|
-
? JSON.parse(params.initialEmailTemplateJson)
|
|
307
|
-
: initialEmailTemplate,
|
|
308
|
-
exitLink: params.exitLink
|
|
309
|
-
}
|
|
310
|
-
)
|
|
280
|
+
templateData: {}
|
|
281
|
+
}),
|
|
282
|
+
initialEmailTemplate: params.initialEmailTemplateJson.length
|
|
283
|
+
? JSON.parse(params.initialEmailTemplateJson)
|
|
284
|
+
: initialEmailTemplate,
|
|
285
|
+
exitLink: params.exitLink
|
|
286
|
+
})
|
|
311
287
|
}
|
|
312
288
|
);
|
|
313
289
|
|
|
@@ -318,4 +294,4 @@ app.use(createVuetify({
|
|
|
318
294
|
}
|
|
319
295
|
}));
|
|
320
296
|
|
|
321
|
-
app.mount(appTagId);
|
|
297
|
+
app.mount(appTagId);
|