@miso.ai/client-sdk-ui 1.10.0-beta.6 → 1.10.0-beta.8
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/actor/utils.js +3 -1
- package/dist/cjs/affiliation/index.js +14 -2
- package/dist/cjs/layout/affiliation/affiliation.js +10 -12
- package/dist/cjs/layout/list/carousel.js +4 -2
- package/dist/cjs/layout/list/collection.js +6 -3
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/ask.js +1 -0
- package/package.json +2 -2
- package/src/actor/utils.js +3 -1
- package/src/affiliation/index.js +10 -1
- package/src/layout/affiliation/affiliation.js +9 -5
- package/src/layout/list/carousel.js +4 -2
- package/src/layout/list/collection.js +7 -3
- package/src/version.js +1 -1
- package/src/workflow/ask.js +1 -0
package/dist/cjs/actor/utils.js
CHANGED
|
@@ -35,7 +35,8 @@ function toInteraction(_ref, _ref2) {
|
|
|
35
35
|
const question_source = request && request._meta && request._meta.question_source;
|
|
36
36
|
const isProductType = isProduct(property);
|
|
37
37
|
const product_ids = isProductType ? values.map(v => v.product_id).filter(v => v) : [];
|
|
38
|
-
const items = isProductType ? undefined : values.map(v => v.text || v);
|
|
38
|
+
const items = isProductType ? undefined : values.map(v => v.text || v.id || v);
|
|
39
|
+
const channel = property === _constants.ROLE.AFFILIATION ? values[0] && values[0].channel : undefined;
|
|
39
40
|
const payload = (0, _commons.trimObj)({
|
|
40
41
|
type: event === 'viewable' ? 'viewable_impression' : event,
|
|
41
42
|
product_ids,
|
|
@@ -44,6 +45,7 @@ function toInteraction(_ref, _ref2) {
|
|
|
44
45
|
custom_context: (0, _commons.trimObj)({
|
|
45
46
|
api_ts,
|
|
46
47
|
property,
|
|
48
|
+
channel,
|
|
47
49
|
items,
|
|
48
50
|
trigger: manual ? 'manual' : 'auto',
|
|
49
51
|
question_source
|
|
@@ -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", "headline", "currency", "retailPrice", "salePrice", "discountRate", "image", "thumbnail", "merchant"];
|
|
11
|
+
_excluded3 = ["id", "deeplink", "headline", "description", "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) {
|
|
@@ -27,10 +27,20 @@ function processValue(value) {
|
|
|
27
27
|
sovrn_aff
|
|
28
28
|
} = value,
|
|
29
29
|
rest = _objectWithoutPropertiesLoose(value, _excluded);
|
|
30
|
-
|
|
30
|
+
value = Object.assign({}, rest, {
|
|
31
31
|
affiliation: processSovrnData(sovrn_aff)
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
// put channel info to items
|
|
36
|
+
const {
|
|
37
|
+
channel
|
|
38
|
+
} = value;
|
|
39
|
+
if (channel) {
|
|
40
|
+
value.products = value.products.map(product => Object.assign({
|
|
41
|
+
channel
|
|
42
|
+
}, product));
|
|
43
|
+
}
|
|
34
44
|
return value;
|
|
35
45
|
}
|
|
36
46
|
function processSovrnData(_ref) {
|
|
@@ -50,6 +60,7 @@ function processSovrnProduct(_ref2) {
|
|
|
50
60
|
id,
|
|
51
61
|
deeplink: url,
|
|
52
62
|
headline: title,
|
|
63
|
+
description,
|
|
53
64
|
currency,
|
|
54
65
|
retailPrice: original_price,
|
|
55
66
|
salePrice: sale_price,
|
|
@@ -65,6 +76,7 @@ function processSovrnProduct(_ref2) {
|
|
|
65
76
|
id: `sovrn-${id}`,
|
|
66
77
|
channel: 'sovrn',
|
|
67
78
|
title,
|
|
79
|
+
description,
|
|
68
80
|
cover_image,
|
|
69
81
|
url,
|
|
70
82
|
currency,
|
|
@@ -30,10 +30,8 @@ function ready(layout, state) {
|
|
|
30
30
|
const {
|
|
31
31
|
templates
|
|
32
32
|
} = layout;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
} = state.value || {};
|
|
36
|
-
if (products && products.length > 0) {
|
|
33
|
+
const items = layout._getItems(state);
|
|
34
|
+
if (items && items.length > 0) {
|
|
37
35
|
return templates.body(layout, state);
|
|
38
36
|
} else {
|
|
39
37
|
return templates.empty(layout, state);
|
|
@@ -44,14 +42,8 @@ function body(layout, state) {
|
|
|
44
42
|
className,
|
|
45
43
|
templates
|
|
46
44
|
} = layout;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
products
|
|
50
|
-
} = state.value;
|
|
51
|
-
products = products.map(product => Object.assign({
|
|
52
|
-
channel
|
|
53
|
-
}, product));
|
|
54
|
-
return `<div class="${className}__body">${templates.header(layout, state)}${templates.list(layout, state, products)}</div>`;
|
|
45
|
+
const items = layout._getItems(state);
|
|
46
|
+
return `<div class="${className}__body">${templates.header(layout, state)}${templates.list(layout, state, items)}</div>`;
|
|
55
47
|
}
|
|
56
48
|
function header(layout, state) {
|
|
57
49
|
const {
|
|
@@ -105,5 +97,11 @@ class AffiliationLayout extends _collection.default {
|
|
|
105
97
|
templates: Object.assign({}, DEFAULT_TEMPLATES, templates)
|
|
106
98
|
}, options));
|
|
107
99
|
}
|
|
100
|
+
_getItems(state) {
|
|
101
|
+
const {
|
|
102
|
+
products
|
|
103
|
+
} = state.value || {};
|
|
104
|
+
return products;
|
|
105
|
+
}
|
|
108
106
|
}
|
|
109
107
|
exports.default = AffiliationLayout;
|
|
@@ -21,7 +21,8 @@ function ready(layout, state) {
|
|
|
21
21
|
const {
|
|
22
22
|
templates
|
|
23
23
|
} = layout;
|
|
24
|
-
const
|
|
24
|
+
const items = layout._getItems(state);
|
|
25
|
+
const nonEmpty = items && items.length > 0;
|
|
25
26
|
const html = Object.getPrototypeOf(layout.constructor).defaultTemplates.ready(layout, state);
|
|
26
27
|
return nonEmpty ? templates.carousel(layout, state, html) : html;
|
|
27
28
|
}
|
|
@@ -71,7 +72,8 @@ class CarouselLayout extends _collection.default {
|
|
|
71
72
|
const {
|
|
72
73
|
state
|
|
73
74
|
} = states;
|
|
74
|
-
|
|
75
|
+
const items = this._getItems(state);
|
|
76
|
+
this._itemCount = items ? items.length : undefined;
|
|
75
77
|
this.syncSize();
|
|
76
78
|
}
|
|
77
79
|
get page() {
|
|
@@ -28,7 +28,7 @@ function ready(layout, state) {
|
|
|
28
28
|
const {
|
|
29
29
|
templates
|
|
30
30
|
} = layout;
|
|
31
|
-
const values = state
|
|
31
|
+
const values = layout._getItems(state);
|
|
32
32
|
|
|
33
33
|
// TODO: handle categories, attributes, etc. by introducing sublayout
|
|
34
34
|
if (values && values.length > 0 || state.ongoing) {
|
|
@@ -149,7 +149,7 @@ class CollectionLayout extends _template.default {
|
|
|
149
149
|
_html(state, rendered, incremental) {
|
|
150
150
|
if (incremental) {
|
|
151
151
|
const offset = rendered.value.length;
|
|
152
|
-
const values = state.
|
|
152
|
+
const values = (this._getItems(state) || []).slice(offset);
|
|
153
153
|
return values.length > 0 ? this.templates.items(this, state, values, {
|
|
154
154
|
offset
|
|
155
155
|
}) : '';
|
|
@@ -184,12 +184,15 @@ class CollectionLayout extends _template.default {
|
|
|
184
184
|
if (!element) {
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
|
-
const values = state
|
|
187
|
+
const values = this._getItems(state) || [];
|
|
188
188
|
let i = 0;
|
|
189
189
|
for (const itemElement of this._listItemElements(element)) {
|
|
190
190
|
itemElement[VALUE] = values[i++];
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
+
_getItems(state) {
|
|
194
|
+
return state.value;
|
|
195
|
+
}
|
|
193
196
|
_getListElement(element) {
|
|
194
197
|
return element.querySelector(`.${this.className}__list`);
|
|
195
198
|
}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/workflow/ask.js
CHANGED
|
@@ -66,6 +66,7 @@ const DEFAULT_LAYOUTS = Object.freeze({
|
|
|
66
66
|
const DEFAULT_TRACKERS = Object.freeze({
|
|
67
67
|
[_constants.ROLE.SOURCES]: {},
|
|
68
68
|
[_constants.ROLE.RELATED_RESOURCES]: {},
|
|
69
|
+
[_constants.ROLE.AFFILIATION]: {},
|
|
69
70
|
[_constants.ROLE.QUERY_SUGGESTIONS]: {
|
|
70
71
|
active: true,
|
|
71
72
|
// we are tracking events at initial stage, when session is not active yet
|
package/package.json
CHANGED
package/src/actor/utils.js
CHANGED
|
@@ -23,7 +23,8 @@ export function toInteraction({ property, misoId, request }, { event, values, ma
|
|
|
23
23
|
const question_source = request && request._meta && request._meta.question_source;
|
|
24
24
|
const isProductType = isProduct(property);
|
|
25
25
|
const product_ids = isProductType ? values.map(v => v.product_id).filter(v => v) : [];
|
|
26
|
-
const items = isProductType ? undefined : values.map(v => v.text || v);
|
|
26
|
+
const items = isProductType ? undefined : values.map(v => v.text || v.id || v);
|
|
27
|
+
const channel = property === ROLE.AFFILIATION ? values[0] && values[0].channel : undefined;
|
|
27
28
|
const payload = trimObj({
|
|
28
29
|
type: event === 'viewable' ? 'viewable_impression' : event,
|
|
29
30
|
product_ids,
|
|
@@ -32,6 +33,7 @@ export function toInteraction({ property, misoId, request }, { event, values, ma
|
|
|
32
33
|
custom_context: trimObj({
|
|
33
34
|
api_ts,
|
|
34
35
|
property,
|
|
36
|
+
channel,
|
|
35
37
|
items,
|
|
36
38
|
trigger: manual ? 'manual' : 'auto',
|
|
37
39
|
question_source,
|
package/src/affiliation/index.js
CHANGED
|
@@ -14,11 +14,18 @@ export function processData(data) {
|
|
|
14
14
|
function processValue(value) {
|
|
15
15
|
if (value.sovrn_aff) {
|
|
16
16
|
const { sovrn_aff, ...rest } = value;
|
|
17
|
-
|
|
17
|
+
value = {
|
|
18
18
|
...rest,
|
|
19
19
|
affiliation: processSovrnData(sovrn_aff),
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
// put channel info to items
|
|
24
|
+
const { channel } = value;
|
|
25
|
+
if (channel) {
|
|
26
|
+
value.products = value.products.map(product => ({ channel, ...product }));
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
return value;
|
|
23
30
|
}
|
|
24
31
|
|
|
@@ -35,6 +42,7 @@ export function processSovrnProduct({
|
|
|
35
42
|
id,
|
|
36
43
|
deeplink: url,
|
|
37
44
|
headline: title,
|
|
45
|
+
description,
|
|
38
46
|
currency,
|
|
39
47
|
retailPrice: original_price,
|
|
40
48
|
salePrice: sale_price,
|
|
@@ -50,6 +58,7 @@ export function processSovrnProduct({
|
|
|
50
58
|
id: `sovrn-${id}`,
|
|
51
59
|
channel: 'sovrn',
|
|
52
60
|
title,
|
|
61
|
+
description,
|
|
53
62
|
cover_image,
|
|
54
63
|
url,
|
|
55
64
|
currency,
|
|
@@ -16,9 +16,9 @@ function root(layout, state) {
|
|
|
16
16
|
|
|
17
17
|
function ready(layout, state) {
|
|
18
18
|
const { templates } = layout;
|
|
19
|
-
const
|
|
19
|
+
const items = layout._getItems(state);
|
|
20
20
|
|
|
21
|
-
if (
|
|
21
|
+
if (items && items.length > 0) {
|
|
22
22
|
return templates.body(layout, state);
|
|
23
23
|
} else {
|
|
24
24
|
return templates.empty(layout, state);
|
|
@@ -27,9 +27,8 @@ function ready(layout, state) {
|
|
|
27
27
|
|
|
28
28
|
function body(layout, state) {
|
|
29
29
|
const { className, templates } = layout;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return `<div class="${className}__body">${templates.header(layout, state)}${templates.list(layout, state, products)}</div>`;
|
|
30
|
+
const items = layout._getItems(state);
|
|
31
|
+
return `<div class="${className}__body">${templates.header(layout, state)}${templates.list(layout, state, items)}</div>`;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
function header(layout, state) {
|
|
@@ -81,4 +80,9 @@ export default class AffiliationLayout extends CollectionLayout {
|
|
|
81
80
|
super({ className, itemType: 'affiliation', templates: { ...DEFAULT_TEMPLATES, ...templates }, ...options });
|
|
82
81
|
}
|
|
83
82
|
|
|
83
|
+
_getItems(state) {
|
|
84
|
+
const { products } = state.value || {};
|
|
85
|
+
return products;
|
|
86
|
+
}
|
|
87
|
+
|
|
84
88
|
}
|
|
@@ -17,7 +17,8 @@ const INHERITED_DEFAULT_TEMPLATES = Object.freeze({
|
|
|
17
17
|
|
|
18
18
|
function ready(layout, state) {
|
|
19
19
|
const { templates } = layout;
|
|
20
|
-
const
|
|
20
|
+
const items = layout._getItems(state);
|
|
21
|
+
const nonEmpty = items && items.length > 0;
|
|
21
22
|
const html = Object.getPrototypeOf(layout.constructor).defaultTemplates.ready(layout, state);
|
|
22
23
|
return nonEmpty ? templates.carousel(layout, state, html) : html;
|
|
23
24
|
}
|
|
@@ -60,7 +61,8 @@ export default class CarouselLayout extends CollectionLayout {
|
|
|
60
61
|
_render(element, states, controls) {
|
|
61
62
|
super._render(element, states, controls);
|
|
62
63
|
const { state } = states;
|
|
63
|
-
|
|
64
|
+
const items = this._getItems(state);
|
|
65
|
+
this._itemCount = items ? items.length : undefined;
|
|
64
66
|
this.syncSize();
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -14,7 +14,7 @@ function root(layout, state) {
|
|
|
14
14
|
|
|
15
15
|
function ready(layout, state) {
|
|
16
16
|
const { templates } = layout;
|
|
17
|
-
const values = state
|
|
17
|
+
const values = layout._getItems(state);
|
|
18
18
|
|
|
19
19
|
// TODO: handle categories, attributes, etc. by introducing sublayout
|
|
20
20
|
if ((values && values.length > 0) || state.ongoing) {
|
|
@@ -125,7 +125,7 @@ export default class CollectionLayout extends TemplateBasedLayout {
|
|
|
125
125
|
_html(state, rendered, incremental) {
|
|
126
126
|
if (incremental) {
|
|
127
127
|
const offset = rendered.value.length;
|
|
128
|
-
const values = state.
|
|
128
|
+
const values = (this._getItems(state) || []).slice(offset);
|
|
129
129
|
return values.length > 0 ? this.templates.items(this, state, values, { offset }) : '';
|
|
130
130
|
} else {
|
|
131
131
|
return this.templates.root(this, state);
|
|
@@ -151,13 +151,17 @@ export default class CollectionLayout extends TemplateBasedLayout {
|
|
|
151
151
|
if (!element) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
|
-
const values = state
|
|
154
|
+
const values = this._getItems(state) || [];
|
|
155
155
|
let i = 0;
|
|
156
156
|
for (const itemElement of this._listItemElements(element)) {
|
|
157
157
|
itemElement[VALUE] = values[i++];
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
_getItems(state) {
|
|
162
|
+
return state.value;
|
|
163
|
+
}
|
|
164
|
+
|
|
161
165
|
_getListElement(element) {
|
|
162
166
|
return element.querySelector(`.${this.className}__list`);
|
|
163
167
|
}
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.10.0-beta.
|
|
1
|
+
export default '1.10.0-beta.8';
|
package/src/workflow/ask.js
CHANGED
|
@@ -42,6 +42,7 @@ const DEFAULT_LAYOUTS = Object.freeze({
|
|
|
42
42
|
const DEFAULT_TRACKERS = Object.freeze({
|
|
43
43
|
[ROLE.SOURCES]: {},
|
|
44
44
|
[ROLE.RELATED_RESOURCES]: {},
|
|
45
|
+
[ROLE.AFFILIATION]: {},
|
|
45
46
|
[ROLE.QUERY_SUGGESTIONS]: {
|
|
46
47
|
active: true, // we are tracking events at initial stage, when session is not active yet
|
|
47
48
|
click: {
|