@retailrocketgroup/retailrocket-create.multicast-vue-email-template-render 5.0.384700 → 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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@retailrocketgroup/retailrocket-create.multicast-vue-email-template-render",
3
- "version": "5.0.384700",
3
+ "version": "6.0.388330-dev",
4
4
  "private": false
5
5
  }
@@ -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 { CreateEmailTemplateApp } from '@easy-wizzy/core';
8
+ import { TemplatesGallery } from '@easy-wizzy/core';
9
9
  import { createSimpleDataForm, matcherFactory } from '@easy-wizzy/core';
10
- import type { GeneralStringExpressionDataSource } from '@easy-wizzy/retailrocket-common';
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 { createEmailTemplateAppDepsFactory } from '@easy-wizzy/common-app';
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.parse(appTag!.getAttribute('data-multicast-favorites-templates')!) as [{ templateId: string, templateJson: string, favoriteTemplateName: string }],
64
- commonFavoritesTemplates: JSON.parse(appTag!.getAttribute('data-common-favorites-templates')!) as [{ templateId: string, templateJson: string, favoriteTemplateName: string }],
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>(arg: {
87
- template: EmailTemplateType<
88
- TListExpressionDataSource,
89
- TNumberExpressionDataSource,
90
- TStringExpressionDataSource>
91
- }): void => {
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 createEmailTemplatePreviewTile = (arg: {
116
- template: EmailTemplateType<
117
- MulticastListExpressionDataSource,
118
- MulticastNumberExpressionDataSource,
119
- MulticastStringExpressionDataSource
120
- >;
121
- templateName: string;
122
- }): EmailTemplatePreviewTileComponent => {
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: params.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: params.localeKey
191
+ localeKey: arg.localeKey
171
192
  });
172
193
 
173
194
  const dataStructExpressionEvaluator = dataStructBuilderExpressionEvaluatorFactory({
174
195
  expressionEvaluator: expressionEvaluator
175
196
  });
176
197
 
177
- return emailTemplatePreviewTileComponentFactory<
198
+ return templatePreviewCardDepsFactory<
178
199
  MulticastListExpressionDataSource,
179
200
  MulticastNumberExpressionDataSource,
180
201
  MulticastStringExpressionDataSource
181
202
  >({
182
- template: arg.template,
183
- templateName: arg.templateName,
184
- emailTemplatePreviewTileDeps: emailTemplatePreviewTileDepsFactory<
185
- MulticastListExpressionDataSource,
186
- MulticastNumberExpressionDataSource,
187
- MulticastStringExpressionDataSource
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
- CreateEmailTemplateApp,
235
+ TemplatesGallery,
228
236
  {
229
- onInitialTemplateSelected: () => {
230
- //eslint-disable-next-line no-console
231
- console.log('onInitialTemplateSelected');
237
+ onTemplateSelected: (template: EmailTemplateType<
238
+ MulticastListExpressionDataSource,
239
+ MulticastNumberExpressionDataSource,
240
+ MulticastStringExpressionDataSource
241
+ >) => {
232
242
  createTemplate({
233
- template: params.initialEmailTemplateJson.length
234
- ? JSON.parse(params.initialEmailTemplateJson)
235
- : initialEmailTemplate,
243
+ template: template
236
244
  });
237
245
  },
238
- deps:
239
- createEmailTemplateAppDepsFactory<
240
- MulticastListExpressionDataSource,
241
- MulticastNumberExpressionDataSource,
242
- MulticastStringExpressionDataSource
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
- localeKey: params.localeKey,
246
- emailTemplatePreviews:
247
- {
248
- custom: [
249
- ...params
250
- .commonFavoritesTemplates
251
- .map(o => ({
252
- templateName: o.favoriteTemplateName,
253
- previewTileComponent: createEmailTemplatePreviewTile({
254
- template: JSON.parse(o.templateJson),
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
 
package/vite.config.ts CHANGED
@@ -13,7 +13,6 @@ export default defineConfig({
13
13
  assetFileNames: 'assets/[name].[ext]',
14
14
  },
15
15
  },
16
- sourcemap: true,
17
16
  },
18
17
  plugins: [
19
18
  vue({