@miso.ai/client-sdk-ui 1.10.0-beta.3 → 1.10.0-beta.5
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/dist/cjs/affiliation/index.js +3 -4
- package/dist/cjs/defaults/ask/phrases.js +1 -1
- package/dist/cjs/layout/list/collection.js +2 -0
- package/dist/cjs/layout/templates.js +29 -19
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/ask.js +0 -1
- package/package.json +2 -2
- package/src/affiliation/index.js +2 -3
- package/src/defaults/ask/phrases.js +1 -1
- package/src/layout/list/collection.js +3 -1
- package/src/layout/templates.js +13 -4
- package/src/version.js +1 -1
- package/src/workflow/ask.js +0 -1
|
@@ -8,7 +8,7 @@ exports.processSovrnProduct = processSovrnProduct;
|
|
|
8
8
|
var _commons = require("@miso.ai/commons");
|
|
9
9
|
const _excluded = ["sovrn_aff"],
|
|
10
10
|
_excluded2 = ["products"],
|
|
11
|
-
_excluded3 = ["id", "deeplink", "
|
|
11
|
+
_excluded3 = ["id", "deeplink", "headline", "currency", "retailPrice", "salePrice", "discountRate", "image", "thumbnail", "merchant"];
|
|
12
12
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
13
13
|
function processData(data) {
|
|
14
14
|
if (!data || !data.value) {
|
|
@@ -38,6 +38,7 @@ function processSovrnData(_ref) {
|
|
|
38
38
|
products
|
|
39
39
|
} = _ref,
|
|
40
40
|
sovrn_aff = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
41
|
+
products = products.slice(0, 1);
|
|
41
42
|
return Object.assign({
|
|
42
43
|
channel: 'sovrn'
|
|
43
44
|
}, sovrn_aff, {
|
|
@@ -48,8 +49,7 @@ function processSovrnProduct(_ref2) {
|
|
|
48
49
|
let {
|
|
49
50
|
id,
|
|
50
51
|
deeplink: url,
|
|
51
|
-
|
|
52
|
-
headline: description,
|
|
52
|
+
headline: title,
|
|
53
53
|
currency,
|
|
54
54
|
retailPrice: original_price,
|
|
55
55
|
salePrice: sale_price,
|
|
@@ -65,7 +65,6 @@ function processSovrnProduct(_ref2) {
|
|
|
65
65
|
id: `sovrn-${id}`,
|
|
66
66
|
channel: 'sovrn',
|
|
67
67
|
title,
|
|
68
|
-
description,
|
|
69
68
|
cover_image,
|
|
70
69
|
url,
|
|
71
70
|
currency,
|
|
@@ -12,7 +12,7 @@ const question = exports.question = 'You asked...';
|
|
|
12
12
|
/**
|
|
13
13
|
* The phrase displayed right before <miso-sources>
|
|
14
14
|
*/
|
|
15
|
-
const sources = exports.sources = '
|
|
15
|
+
const sources = exports.sources = 'This reply is based on the following articles';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The phrase displayed right before <miso-query-suggestions>
|
|
@@ -87,10 +87,12 @@ const DEFAULT_TEMPLATES = Object.freeze({
|
|
|
87
87
|
item,
|
|
88
88
|
productInfoBlock: _templates.productInfoBlock,
|
|
89
89
|
articleInfoBlock: _templates.articleInfoBlock,
|
|
90
|
+
brandBlock: _templates.brandBlock,
|
|
90
91
|
titleBlock: _templates.titleBlock,
|
|
91
92
|
descriptionBlock: _templates.descriptionBlock,
|
|
92
93
|
dateBlock: _templates.dateBlock,
|
|
93
94
|
priceBlock: _templates.priceBlock,
|
|
95
|
+
discountRateText: _templates.discountRateText,
|
|
94
96
|
ctaBlock: _templates.ctaBlock,
|
|
95
97
|
cta: _templates.cta,
|
|
96
98
|
imageBlock: _templates.imageBlock,
|
|
@@ -12,6 +12,7 @@ exports.cta = cta;
|
|
|
12
12
|
exports.ctaBlock = ctaBlock;
|
|
13
13
|
exports.dateBlock = dateBlock;
|
|
14
14
|
exports.descriptionBlock = descriptionBlock;
|
|
15
|
+
exports.discountRateText = discountRateText;
|
|
15
16
|
exports.helpers = void 0;
|
|
16
17
|
exports.imageBlock = imageBlock;
|
|
17
18
|
exports.indexBlock = indexBlock;
|
|
@@ -104,7 +105,6 @@ function brandBlock(_ref3, _ref4) {
|
|
|
104
105
|
if (!brand && !brand_logo) {
|
|
105
106
|
return '';
|
|
106
107
|
}
|
|
107
|
-
brand_logo = undefined;
|
|
108
108
|
const content = brand_logo ? `<img class="${className}__item-brand-logo" src="${brand_logo}"${brand ? ` alt="${brand}"` : ''}>` : `<div class="${className}__item-brand">${brand}</div>`;
|
|
109
109
|
return `<div class="${className}__item-brand-container">${content}</div>`;
|
|
110
110
|
}
|
|
@@ -131,52 +131,62 @@ function dateBlock(_ref7, _ref8) {
|
|
|
131
131
|
const date = published_at || created_at || updated_at;
|
|
132
132
|
return date ? `<div class="${className}__item-date">${formatDate(date, templates.date)}</div>` : '';
|
|
133
133
|
}
|
|
134
|
-
function priceBlock(
|
|
135
|
-
|
|
136
|
-
className
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
function priceBlock(layout, data) {
|
|
135
|
+
const {
|
|
136
|
+
className,
|
|
137
|
+
templates
|
|
138
|
+
} = layout;
|
|
139
|
+
const {
|
|
139
140
|
sale_price,
|
|
140
141
|
original_price,
|
|
141
|
-
discount_rate_percent,
|
|
142
142
|
currency = 'USD'
|
|
143
|
-
} =
|
|
143
|
+
} = data;
|
|
144
144
|
const price = sale_price || original_price;
|
|
145
145
|
if (!price) {
|
|
146
146
|
return '';
|
|
147
147
|
}
|
|
148
148
|
const has_price_difference = original_price !== undefined && sale_price !== undefined && sale_price < original_price;
|
|
149
|
-
discount_rate_percent = discount_rate_percent || (has_price_difference ? Math.floor((1 - sale_price / original_price) * 100) : undefined);
|
|
149
|
+
const discount_rate_percent = data.discount_rate_percent || (has_price_difference ? Math.floor((1 - sale_price / original_price) * 100) : undefined);
|
|
150
150
|
let content = '';
|
|
151
|
+
// original price
|
|
151
152
|
if (has_price_difference) {
|
|
152
153
|
content += `<span class="${className}__item-original-price miso-price" data-currency="${currency}">${original_price}</span><br>`;
|
|
153
154
|
}
|
|
155
|
+
// current price
|
|
154
156
|
content += `<span class="${className}__item-price miso-price" data-currency="${currency}">${price}</span>`;
|
|
157
|
+
// discount rate
|
|
155
158
|
if (discount_rate_percent) {
|
|
156
|
-
|
|
159
|
+
const text = (templates.discountRateText || discountRateText)(layout, data);
|
|
160
|
+
content += ` <span class="${className}__item-discount-rate">${text}</span>`;
|
|
157
161
|
}
|
|
158
162
|
return `<div class="${className}__item-price-container">${content}</div>`;
|
|
159
163
|
}
|
|
160
|
-
function
|
|
164
|
+
function discountRateText(layout, _ref9) {
|
|
165
|
+
let {
|
|
166
|
+
discount_rate_percent
|
|
167
|
+
} = _ref9;
|
|
168
|
+
return `(${discount_rate_percent}% off)`;
|
|
169
|
+
}
|
|
170
|
+
function imageBlock(_ref10, _ref11) {
|
|
161
171
|
let {
|
|
162
172
|
className
|
|
163
|
-
} =
|
|
173
|
+
} = _ref10;
|
|
164
174
|
let {
|
|
165
175
|
cover_image
|
|
166
|
-
} =
|
|
176
|
+
} = _ref11;
|
|
167
177
|
if (!cover_image) {
|
|
168
178
|
return '';
|
|
169
179
|
}
|
|
170
180
|
const img = `<img class="${className}__item-cover-image" src="${cover_image}">`;
|
|
171
181
|
return `<div class="${className}__item-cover-image-container">${img}</div>`;
|
|
172
182
|
}
|
|
173
|
-
function indexBlock(
|
|
183
|
+
function indexBlock(_ref12, data, _ref13) {
|
|
174
184
|
let {
|
|
175
185
|
className
|
|
176
|
-
} =
|
|
186
|
+
} = _ref12;
|
|
177
187
|
let {
|
|
178
188
|
index
|
|
179
|
-
} =
|
|
189
|
+
} = _ref13;
|
|
180
190
|
return `<div class="${className}__item-index-container"><span class="${className}__item-index miso-citation-index" data-index="${index + 1}"></span></div>`;
|
|
181
191
|
}
|
|
182
192
|
function ctaBlock(layout, data, meta) {
|
|
@@ -203,15 +213,15 @@ function cta(layout, data, meta) {
|
|
|
203
213
|
}
|
|
204
214
|
|
|
205
215
|
// helpers //
|
|
206
|
-
function tagPair(
|
|
216
|
+
function tagPair(_ref14, _ref15) {
|
|
207
217
|
let {
|
|
208
218
|
className,
|
|
209
219
|
options = {}
|
|
210
|
-
} =
|
|
220
|
+
} = _ref14;
|
|
211
221
|
let {
|
|
212
222
|
product_id,
|
|
213
223
|
url
|
|
214
|
-
} =
|
|
224
|
+
} = _ref15;
|
|
215
225
|
let {
|
|
216
226
|
classSuffix = 'item-body',
|
|
217
227
|
role = 'item'
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/workflow/ask.js
CHANGED
package/package.json
CHANGED
package/src/affiliation/index.js
CHANGED
|
@@ -23,6 +23,7 @@ function processValue(value) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function processSovrnData({ products, ...sovrn_aff }) {
|
|
26
|
+
products = products.slice(0, 1);
|
|
26
27
|
return {
|
|
27
28
|
channel: 'sovrn',
|
|
28
29
|
...sovrn_aff,
|
|
@@ -33,8 +34,7 @@ function processSovrnData({ products, ...sovrn_aff }) {
|
|
|
33
34
|
export function processSovrnProduct({
|
|
34
35
|
id,
|
|
35
36
|
deeplink: url,
|
|
36
|
-
|
|
37
|
-
headline: description,
|
|
37
|
+
headline: title,
|
|
38
38
|
currency,
|
|
39
39
|
retailPrice: original_price,
|
|
40
40
|
salePrice: sale_price,
|
|
@@ -50,7 +50,6 @@ export function processSovrnProduct({
|
|
|
50
50
|
id: `sovrn-${id}`,
|
|
51
51
|
channel: 'sovrn',
|
|
52
52
|
title,
|
|
53
|
-
description,
|
|
54
53
|
cover_image,
|
|
55
54
|
url,
|
|
56
55
|
currency,
|
|
@@ -6,7 +6,7 @@ export const question = 'You asked...';
|
|
|
6
6
|
/**
|
|
7
7
|
* The phrase displayed right before <miso-sources>
|
|
8
8
|
*/
|
|
9
|
-
export const sources = '
|
|
9
|
+
export const sources = 'This reply is based on the following articles';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The phrase displayed right before <miso-query-suggestions>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineValues } from '@miso.ai/commons';
|
|
2
2
|
import { STATUS, LAYOUT_CATEGORY } from '../../constants.js';
|
|
3
3
|
import TemplateBasedLayout from '../template.js';
|
|
4
|
-
import { product, article, question, productInfoBlock, articleInfoBlock, titleBlock, brandBlock, descriptionBlock, dateBlock, priceBlock, ctaBlock, cta, imageBlock, indexBlock, helpers } from '../templates.js';
|
|
4
|
+
import { product, article, question, productInfoBlock, articleInfoBlock, titleBlock, brandBlock, descriptionBlock, dateBlock, priceBlock, discountRateText, ctaBlock, cta, imageBlock, indexBlock, helpers } from '../templates.js';
|
|
5
5
|
|
|
6
6
|
const VALUE = Symbol.for('miso.value');
|
|
7
7
|
|
|
@@ -59,10 +59,12 @@ const DEFAULT_TEMPLATES = Object.freeze({
|
|
|
59
59
|
item,
|
|
60
60
|
productInfoBlock,
|
|
61
61
|
articleInfoBlock,
|
|
62
|
+
brandBlock,
|
|
62
63
|
titleBlock,
|
|
63
64
|
descriptionBlock,
|
|
64
65
|
dateBlock,
|
|
65
66
|
priceBlock,
|
|
67
|
+
discountRateText,
|
|
66
68
|
ctaBlock,
|
|
67
69
|
cta,
|
|
68
70
|
imageBlock,
|
package/src/layout/templates.js
CHANGED
|
@@ -91,7 +91,6 @@ export function brandBlock({ className }, { brand, brand_logo }) {
|
|
|
91
91
|
if (!brand && !brand_logo) {
|
|
92
92
|
return '';
|
|
93
93
|
}
|
|
94
|
-
brand_logo = undefined;
|
|
95
94
|
const content = brand_logo ? `<img class="${className}__item-brand-logo" src="${brand_logo}"${brand ? ` alt="${brand}"` : ''}>` : `<div class="${className}__item-brand">${brand}</div>`;
|
|
96
95
|
return `<div class="${className}__item-brand-container">${content}</div>`;
|
|
97
96
|
}
|
|
@@ -105,25 +104,35 @@ export function dateBlock({ className, templates }, { created_at, updated_at, pu
|
|
|
105
104
|
return date ? `<div class="${className}__item-date">${formatDate(date, templates.date)}</div>` : '';
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
export function priceBlock(
|
|
107
|
+
export function priceBlock(layout, data) {
|
|
108
|
+
const { className, templates } = layout;
|
|
109
|
+
const { sale_price, original_price, currency = 'USD' } = data;
|
|
109
110
|
const price = sale_price || original_price;
|
|
110
111
|
if (!price) {
|
|
111
112
|
return '';
|
|
112
113
|
}
|
|
113
114
|
const has_price_difference = original_price !== undefined && sale_price !== undefined && sale_price < original_price;
|
|
114
|
-
discount_rate_percent = discount_rate_percent || (has_price_difference ? Math.floor((1 - sale_price / original_price) * 100) : undefined);
|
|
115
|
+
const discount_rate_percent = data.discount_rate_percent || (has_price_difference ? Math.floor((1 - sale_price / original_price) * 100) : undefined);
|
|
115
116
|
|
|
116
117
|
let content = '';
|
|
118
|
+
// original price
|
|
117
119
|
if (has_price_difference) {
|
|
118
120
|
content += `<span class="${className}__item-original-price miso-price" data-currency="${currency}">${original_price}</span><br>`;
|
|
119
121
|
}
|
|
122
|
+
// current price
|
|
120
123
|
content += `<span class="${className}__item-price miso-price" data-currency="${currency}">${price}</span>`;
|
|
124
|
+
// discount rate
|
|
121
125
|
if (discount_rate_percent) {
|
|
122
|
-
|
|
126
|
+
const text = (templates.discountRateText || discountRateText)(layout, data);
|
|
127
|
+
content += ` <span class="${className}__item-discount-rate">${text}</span>`;
|
|
123
128
|
}
|
|
124
129
|
return `<div class="${className}__item-price-container">${content}</div>`;
|
|
125
130
|
}
|
|
126
131
|
|
|
132
|
+
export function discountRateText(layout, { discount_rate_percent }) {
|
|
133
|
+
return `(${discount_rate_percent}% off)`;
|
|
134
|
+
}
|
|
135
|
+
|
|
127
136
|
export function imageBlock({ className }, { cover_image }) {
|
|
128
137
|
if (!cover_image) {
|
|
129
138
|
return '';
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.10.0-beta.
|
|
1
|
+
export default '1.10.0-beta.5';
|