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