@miso.ai/client-sdk-ui 1.13.0-beta.4 → 1.13.0-beta.6
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/tracker.js +9 -16
- package/dist/cjs/constants.js +4 -2
- package/dist/cjs/defaults/hybrid-search/phrases.js +1 -1
- package/dist/cjs/layout/text/text.js +10 -6
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/explore.js +1 -0
- package/dist/cjs/workflow/processors.js +12 -5
- package/dist/cjs/workflow/search-based.js +16 -1
- package/package.json +7 -3
- package/src/actor/feedback.js +1 -1
- package/src/actor/tracker.js +10 -18
- package/src/constants.js +7 -0
- package/src/defaults/hybrid-search/phrases.js +1 -1
- package/src/layout/text/text.js +8 -3
- package/src/version.js +1 -1
- package/src/workflow/explore.js +1 -0
- package/src/workflow/processors.js +6 -1
- package/src/workflow/search-based.js +11 -1
|
@@ -59,21 +59,6 @@ class Tracker {
|
|
|
59
59
|
items: itemless ? undefined : items
|
|
60
60
|
}, meta));
|
|
61
61
|
}
|
|
62
|
-
submit({
|
|
63
|
-
value
|
|
64
|
-
}) {
|
|
65
|
-
this._syncSession();
|
|
66
|
-
this._sendToHub({
|
|
67
|
-
type: _constants.EVENT_TYPE.SUBMIT,
|
|
68
|
-
value
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
heartbeat() {
|
|
72
|
-
this._syncSession();
|
|
73
|
-
this._sendToHub({
|
|
74
|
-
type: _constants.EVENT_TYPE.HEARTBEAT
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
62
|
_sendToHub(args) {
|
|
78
63
|
this._hub.trigger(fields.tracker(), Object.freeze((0, _commons.trimObj)(Object.assign({
|
|
79
64
|
role: this._role
|
|
@@ -110,7 +95,15 @@ class Tracker {
|
|
|
110
95
|
}
|
|
111
96
|
exports.default = Tracker;
|
|
112
97
|
for (const type of _constants.PERFORMANCE_EVENT_TYPES) {
|
|
113
|
-
Tracker.prototype[type] = function (items, meta) {
|
|
98
|
+
Tracker.prototype[(0, _commons.snakeToLowerCamel)(type)] = function (items, meta) {
|
|
114
99
|
this._trigger(type, items, meta);
|
|
115
100
|
};
|
|
101
|
+
}
|
|
102
|
+
for (const type of _constants.DIRECT_TRACKING_EVENT_TYPES) {
|
|
103
|
+
Tracker.prototype[(0, _commons.snakeToLowerCamel)(type)] = function (args) {
|
|
104
|
+
this._syncSession();
|
|
105
|
+
this._sendToHub(Object.assign({}, args, {
|
|
106
|
+
type
|
|
107
|
+
}));
|
|
108
|
+
};
|
|
116
109
|
}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WORKFLOW_CONFIGURABLE = exports.TRACKING_STATUS = exports.TRACKING_EVENT_TYPES = exports.STATUS = exports.ROLE = exports.REQUEST_TYPE = exports.QUESTION_SOURCE = exports.PERFORMANCE_EVENT_TYPES = exports.EVENT_TYPE = exports.DEFAULT_UNIT_ID = exports.ATTR_DATA_MISO_UNIT_ID = exports.ATTR_DATA_MISO_PRODUCT_ID = void 0;
|
|
6
|
+
exports.WORKFLOW_CONFIGURABLE = exports.TRACKING_STATUS = exports.TRACKING_EVENT_TYPES = exports.STATUS = exports.ROLE = exports.REQUEST_TYPE = exports.QUESTION_SOURCE = exports.PERFORMANCE_EVENT_TYPES = exports.EVENT_TYPE = exports.DIRECT_TRACKING_EVENT_TYPES = exports.DEFAULT_UNIT_ID = exports.ATTR_DATA_MISO_UNIT_ID = exports.ATTR_DATA_MISO_PRODUCT_ID = void 0;
|
|
7
7
|
exports.isDataRole = isDataRole;
|
|
8
8
|
exports.isPerformanceEventType = isPerformanceEventType;
|
|
9
9
|
exports.isProductRole = isProductRole;
|
|
@@ -53,10 +53,12 @@ const EVENT_TYPE = exports.EVENT_TYPE = Object.freeze({
|
|
|
53
53
|
CLICK: 'click',
|
|
54
54
|
SUBMIT: 'submit',
|
|
55
55
|
FEEDBACK: 'feedback',
|
|
56
|
-
HEARTBEAT: 'heartbeat'
|
|
56
|
+
HEARTBEAT: 'heartbeat',
|
|
57
|
+
GENERIC_CLICK: 'generic_click'
|
|
57
58
|
});
|
|
58
59
|
const TRACKING_EVENT_TYPES = exports.TRACKING_EVENT_TYPES = [EVENT_TYPE.IMPRESSION, EVENT_TYPE.VIEWABLE, EVENT_TYPE.CLICK, EVENT_TYPE.SUBMIT, EVENT_TYPE.FEEDBACK, EVENT_TYPE.HEARTBEAT];
|
|
59
60
|
const PERFORMANCE_EVENT_TYPES = exports.PERFORMANCE_EVENT_TYPES = [EVENT_TYPE.IMPRESSION, EVENT_TYPE.VIEWABLE, EVENT_TYPE.CLICK];
|
|
61
|
+
const DIRECT_TRACKING_EVENT_TYPES = exports.DIRECT_TRACKING_EVENT_TYPES = [EVENT_TYPE.SUBMIT, EVENT_TYPE.HEARTBEAT, EVENT_TYPE.GENERIC_CLICK];
|
|
60
62
|
const PERFORMANCE_EVENT_TYPE_SET = new Set(PERFORMANCE_EVENT_TYPES);
|
|
61
63
|
function isPerformanceEventType(type) {
|
|
62
64
|
return PERFORMANCE_EVENT_TYPE_SET.has(type);
|
|
@@ -22,6 +22,6 @@ const keywords = exports.keywords = 'You searched for “${value}”';
|
|
|
22
22
|
/**
|
|
23
23
|
* The phrase to display <miso-total>
|
|
24
24
|
*/
|
|
25
|
-
const total = exports.total = '${value}
|
|
25
|
+
const total = exports.total = '${value}';
|
|
26
26
|
const showMore = exports.showMore = 'Show more';
|
|
27
27
|
const showLess = exports.showLess = 'Show less';
|
|
@@ -11,9 +11,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
11
11
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
12
12
|
const TYPE = 'text';
|
|
13
13
|
const DEFAULT_CLASSNAME = 'miso-text';
|
|
14
|
-
function root(layout, {
|
|
15
|
-
value
|
|
16
|
-
}) {
|
|
14
|
+
function root(layout, state) {
|
|
17
15
|
const {
|
|
18
16
|
className,
|
|
19
17
|
role,
|
|
@@ -23,8 +21,13 @@ function root(layout, {
|
|
|
23
21
|
}
|
|
24
22
|
} = layout;
|
|
25
23
|
const roleAttr = role ? `data-role="${role}"` : '';
|
|
26
|
-
const
|
|
27
|
-
return raw ?
|
|
24
|
+
const text = layout.templates.content(layout, state);
|
|
25
|
+
return raw ? text : `<${tag} class="${className}" ${roleAttr}>${text}</${tag}>`;
|
|
26
|
+
}
|
|
27
|
+
function content(layout, {
|
|
28
|
+
value
|
|
29
|
+
}) {
|
|
30
|
+
return value !== undefined ? (0, _commons.escapeHtml)(getFormatFunction(layout)(value)) : '';
|
|
28
31
|
}
|
|
29
32
|
function getFormatFunction(layout) {
|
|
30
33
|
let {
|
|
@@ -55,7 +58,8 @@ function getFormatFunction(layout) {
|
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
const DEFAULT_TEMPLATES = Object.freeze({
|
|
58
|
-
root
|
|
61
|
+
root,
|
|
62
|
+
content
|
|
59
63
|
});
|
|
60
64
|
class TextLayout extends _template.default {
|
|
61
65
|
static get type() {
|
package/dist/cjs/version.js
CHANGED
|
@@ -187,6 +187,7 @@ class Explore extends _unit.default {
|
|
|
187
187
|
}));
|
|
188
188
|
}
|
|
189
189
|
_getSubmitUrl(args) {
|
|
190
|
+
// TODO: if trending_questions -> qs = '_trending'
|
|
190
191
|
let url = _useLink.UseLinkMixin.prototype._getSubmitUrl.call(this, args);
|
|
191
192
|
if (!args.generated || !this._productId) {
|
|
192
193
|
return url;
|
|
@@ -35,7 +35,8 @@ exports.writeUnanswerableToMeta = writeUnanswerableToMeta;
|
|
|
35
35
|
var _commons = require("@miso.ai/commons");
|
|
36
36
|
var _constants = require("../constants.js");
|
|
37
37
|
var _index = require("../actor/index.js");
|
|
38
|
-
const _excluded = ["qs"]
|
|
38
|
+
const _excluded = ["qs"],
|
|
39
|
+
_excluded2 = ["role", "type", "items"];
|
|
39
40
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
40
41
|
// role mappings //
|
|
41
42
|
function mappingSortData(_, {
|
|
@@ -401,10 +402,11 @@ function carryOverQuestionIdToData(data, oldData) {
|
|
|
401
402
|
// interactions //
|
|
402
403
|
function buildBaseInteraction(args) {
|
|
403
404
|
const {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
405
|
+
role,
|
|
406
|
+
type,
|
|
407
|
+
items
|
|
408
|
+
} = args,
|
|
409
|
+
rest = _objectWithoutPropertiesLoose(args, _excluded2);
|
|
408
410
|
const payload = {
|
|
409
411
|
type: type === 'viewable' ? 'viewable_impression' : type,
|
|
410
412
|
context: {
|
|
@@ -433,6 +435,11 @@ function buildBaseInteraction(args) {
|
|
|
433
435
|
payload.type = 'custom';
|
|
434
436
|
payload.custom_action_name = 'heartbeat';
|
|
435
437
|
break;
|
|
438
|
+
case _constants.EVENT_TYPE.GENERIC_CLICK:
|
|
439
|
+
payload.type = 'custom';
|
|
440
|
+
payload.custom_action_name = 'generic_click';
|
|
441
|
+
payload.context.custom_context.href = args.href;
|
|
442
|
+
break;
|
|
436
443
|
}
|
|
437
444
|
return (0, _commons.trimObj)(payload);
|
|
438
445
|
}
|
|
@@ -22,6 +22,19 @@ const DEFAULT_API_OPTIONS = Object.freeze(Object.assign({}, _base.default.DEFAUL
|
|
|
22
22
|
rows: DEFAULT_ROWS
|
|
23
23
|
})
|
|
24
24
|
}));
|
|
25
|
+
function totalContent(layout, {
|
|
26
|
+
value
|
|
27
|
+
}) {
|
|
28
|
+
if (value === undefined) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
const {
|
|
32
|
+
formatNumber
|
|
33
|
+
} = layout.templates.helpers;
|
|
34
|
+
const formatted = formatNumber(value);
|
|
35
|
+
const label = value === 1 ? 'result' : 'results';
|
|
36
|
+
return `${formatted} ${label}`;
|
|
37
|
+
}
|
|
25
38
|
const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _base.default.DEFAULT_LAYOUTS, {
|
|
26
39
|
[_constants.ROLE.QUERY]: [_index2.SearchBoxLayout.type],
|
|
27
40
|
[_constants.ROLE.PRODUCTS]: [_index2.ListLayout.type, {
|
|
@@ -33,7 +46,9 @@ const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _base.default.DEFAULT_LA
|
|
|
33
46
|
}],
|
|
34
47
|
[_constants.ROLE.TOTAL]: [_index2.TextLayout.type, {
|
|
35
48
|
raw: true,
|
|
36
|
-
|
|
49
|
+
templates: {
|
|
50
|
+
content: totalContent
|
|
51
|
+
}
|
|
37
52
|
}],
|
|
38
53
|
[_constants.ROLE.FACETS]: [_index2.FacetsLayout.type],
|
|
39
54
|
[_constants.ROLE.SORT]: [_index2.SelectLayout.type],
|
package/package.json
CHANGED
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
"build:cjs": "BABEL_ENV=cjs npx babel src --root-mode upward --out-dir dist/cjs",
|
|
17
17
|
"build": "npm run build:clean && npm run build:cjs"
|
|
18
18
|
},
|
|
19
|
-
"repository":
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/MisoAI/miso-client-js-sdk.git",
|
|
22
|
+
"directory": "packages/client-sdk-ui"
|
|
23
|
+
},
|
|
20
24
|
"homepage": "https://misoai.github.io/miso-client-js-sdk/sdk",
|
|
21
25
|
"license": "MIT",
|
|
22
26
|
"contributors": [
|
|
@@ -26,7 +30,7 @@
|
|
|
26
30
|
"url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
|
|
27
31
|
},
|
|
28
32
|
"dependencies": {
|
|
29
|
-
"@miso.ai/commons": "1.13.0-beta.
|
|
33
|
+
"@miso.ai/commons": "1.13.0-beta.6"
|
|
30
34
|
},
|
|
31
|
-
"version": "1.13.0-beta.
|
|
35
|
+
"version": "1.13.0-beta.6"
|
|
32
36
|
}
|
package/src/actor/feedback.js
CHANGED
package/src/actor/tracker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { asArray, trimObj } from '@miso.ai/commons';
|
|
2
|
-
import { PERFORMANCE_EVENT_TYPES, TRACKING_STATUS, EVENT_TYPE, validateEventType } from '../constants.js';
|
|
1
|
+
import { asArray, trimObj, snakeToLowerCamel } from '@miso.ai/commons';
|
|
2
|
+
import { PERFORMANCE_EVENT_TYPES, DIRECT_TRACKING_EVENT_TYPES, TRACKING_STATUS, EVENT_TYPE, validateEventType } from '../constants.js';
|
|
3
3
|
import * as fields from './fields.js';
|
|
4
4
|
import States from '../util/states.js';
|
|
5
5
|
|
|
@@ -55,21 +55,6 @@ export default class Tracker {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
submit({ value }) {
|
|
59
|
-
this._syncSession();
|
|
60
|
-
this._sendToHub({
|
|
61
|
-
type: EVENT_TYPE.SUBMIT,
|
|
62
|
-
value,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
heartbeat() {
|
|
67
|
-
this._syncSession();
|
|
68
|
-
this._sendToHub({
|
|
69
|
-
type: EVENT_TYPE.HEARTBEAT,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
58
|
_sendToHub(args) {
|
|
74
59
|
this._hub.trigger(fields.tracker(), Object.freeze(trimObj({ role: this._role, ...args })));
|
|
75
60
|
}
|
|
@@ -106,7 +91,14 @@ export default class Tracker {
|
|
|
106
91
|
}
|
|
107
92
|
|
|
108
93
|
for (const type of PERFORMANCE_EVENT_TYPES) {
|
|
109
|
-
Tracker.prototype[type] = function(items, meta) {
|
|
94
|
+
Tracker.prototype[snakeToLowerCamel(type)] = function(items, meta) {
|
|
110
95
|
this._trigger(type, items, meta);
|
|
111
96
|
};
|
|
112
97
|
}
|
|
98
|
+
|
|
99
|
+
for (const type of DIRECT_TRACKING_EVENT_TYPES) {
|
|
100
|
+
Tracker.prototype[snakeToLowerCamel(type)] = function(args) {
|
|
101
|
+
this._syncSession();
|
|
102
|
+
this._sendToHub({ ...args, type });
|
|
103
|
+
};
|
|
104
|
+
}
|
package/src/constants.js
CHANGED
|
@@ -72,6 +72,7 @@ export const EVENT_TYPE = Object.freeze({
|
|
|
72
72
|
SUBMIT: 'submit',
|
|
73
73
|
FEEDBACK: 'feedback',
|
|
74
74
|
HEARTBEAT: 'heartbeat',
|
|
75
|
+
GENERIC_CLICK: 'generic_click',
|
|
75
76
|
});
|
|
76
77
|
|
|
77
78
|
export const TRACKING_EVENT_TYPES = [
|
|
@@ -89,6 +90,12 @@ export const PERFORMANCE_EVENT_TYPES = [
|
|
|
89
90
|
EVENT_TYPE.CLICK,
|
|
90
91
|
];
|
|
91
92
|
|
|
93
|
+
export const DIRECT_TRACKING_EVENT_TYPES = [
|
|
94
|
+
EVENT_TYPE.SUBMIT,
|
|
95
|
+
EVENT_TYPE.HEARTBEAT,
|
|
96
|
+
EVENT_TYPE.GENERIC_CLICK,
|
|
97
|
+
];
|
|
98
|
+
|
|
92
99
|
const PERFORMANCE_EVENT_TYPE_SET = new Set(PERFORMANCE_EVENT_TYPES);
|
|
93
100
|
|
|
94
101
|
export function isPerformanceEventType(type) {
|
|
@@ -16,7 +16,7 @@ export const keywords = 'You searched for “${value}”';
|
|
|
16
16
|
/**
|
|
17
17
|
* The phrase to display <miso-total>
|
|
18
18
|
*/
|
|
19
|
-
export const total = '${value}
|
|
19
|
+
export const total = '${value}';
|
|
20
20
|
|
|
21
21
|
export const showMore = 'Show more';
|
|
22
22
|
export const showLess = 'Show less';
|
package/src/layout/text/text.js
CHANGED
|
@@ -4,11 +4,15 @@ import TemplateBasedLayout from '../template.js';
|
|
|
4
4
|
const TYPE = 'text';
|
|
5
5
|
const DEFAULT_CLASSNAME = 'miso-text';
|
|
6
6
|
|
|
7
|
-
function root(layout,
|
|
7
|
+
function root(layout, state) {
|
|
8
8
|
const { className, role, options: { raw = false, tag } } = layout;
|
|
9
9
|
const roleAttr = role ? `data-role="${role}"` : '';
|
|
10
|
-
const
|
|
11
|
-
return raw ?
|
|
10
|
+
const text = layout.templates.content(layout, state);
|
|
11
|
+
return raw ? text : `<${tag} class="${className}" ${roleAttr}>${text}</${tag}>`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function content(layout, { value }) {
|
|
15
|
+
return value !== undefined ? escapeHtml(getFormatFunction(layout)(value)) : '';
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
function getFormatFunction(layout) {
|
|
@@ -37,6 +41,7 @@ function getFormatFunction(layout) {
|
|
|
37
41
|
|
|
38
42
|
const DEFAULT_TEMPLATES = Object.freeze({
|
|
39
43
|
root,
|
|
44
|
+
content,
|
|
40
45
|
});
|
|
41
46
|
|
|
42
47
|
export default class TextLayout extends TemplateBasedLayout {
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.13.0-beta.
|
|
1
|
+
export default '1.13.0-beta.6';
|
package/src/workflow/explore.js
CHANGED
|
@@ -170,6 +170,7 @@ export default class Explore extends UnitWorkflow {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
_getSubmitUrl(args) {
|
|
173
|
+
// TODO: if trending_questions -> qs = '_trending'
|
|
173
174
|
let url = UseLinkMixin.prototype._getSubmitUrl.call(this, args);
|
|
174
175
|
if (!args.generated || !this._productId) {
|
|
175
176
|
return url;
|
|
@@ -302,7 +302,7 @@ export function carryOverQuestionIdToData(data, oldData) {
|
|
|
302
302
|
|
|
303
303
|
// interactions //
|
|
304
304
|
export function buildBaseInteraction(args) {
|
|
305
|
-
const { role, type, items } = args;
|
|
305
|
+
const { role, type, items, ...rest } = args;
|
|
306
306
|
const payload = {
|
|
307
307
|
type: type === 'viewable' ? 'viewable_impression' : type,
|
|
308
308
|
context: {
|
|
@@ -333,6 +333,11 @@ export function buildBaseInteraction(args) {
|
|
|
333
333
|
payload.type = 'custom';
|
|
334
334
|
payload.custom_action_name = 'heartbeat';
|
|
335
335
|
break;
|
|
336
|
+
case EVENT_TYPE.GENERIC_CLICK:
|
|
337
|
+
payload.type = 'custom';
|
|
338
|
+
payload.custom_action_name = 'generic_click';
|
|
339
|
+
payload.context.custom_context.href = args.href;
|
|
340
|
+
break;
|
|
336
341
|
}
|
|
337
342
|
|
|
338
343
|
return trimObj(payload);
|
|
@@ -20,12 +20,22 @@ const DEFAULT_API_OPTIONS = Object.freeze({
|
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
function totalContent(layout, { value }) {
|
|
24
|
+
if (value === undefined) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
const { formatNumber } = layout.templates.helpers;
|
|
28
|
+
const formatted = formatNumber(value);
|
|
29
|
+
const label = value === 1 ? 'result' : 'results';
|
|
30
|
+
return `${formatted} ${label}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
23
33
|
const DEFAULT_LAYOUTS = Object.freeze({
|
|
24
34
|
...Workflow.DEFAULT_LAYOUTS,
|
|
25
35
|
[ROLE.QUERY]: [SearchBoxLayout.type],
|
|
26
36
|
[ROLE.PRODUCTS]: [ListLayout.type, { incremental: true, infiniteScroll: true }],
|
|
27
37
|
[ROLE.KEYWORDS]: [TextLayout.type, { raw: true }],
|
|
28
|
-
[ROLE.TOTAL]: [TextLayout.type, { raw: true,
|
|
38
|
+
[ROLE.TOTAL]: [TextLayout.type, { raw: true, templates: { content: totalContent } }],
|
|
29
39
|
[ROLE.FACETS]: [FacetsLayout.type],
|
|
30
40
|
[ROLE.SORT]: [SelectLayout.type],
|
|
31
41
|
[ROLE.MORE]: [MoreButtonLayout.type],
|