@miso.ai/client-sdk-ui 1.10.0-beta.1 → 1.10.0-beta.11
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/data.js +1 -1
- package/dist/cjs/actor/tracker.js +46 -70
- package/dist/cjs/actor/trackers.js +5 -1
- package/dist/cjs/actor/utils.js +6 -2
- package/dist/cjs/actor/view.js +14 -3
- package/dist/cjs/actor/views.js +9 -1
- package/dist/cjs/affiliation/index.js +126 -0
- package/dist/cjs/combo/ask/options.js +1 -1
- package/dist/cjs/combo/base.js +1 -1
- package/dist/cjs/constants.js +6 -3
- package/dist/cjs/defaults/ask/controls.js +1 -1
- package/dist/cjs/defaults/ask/phrases.js +1 -1
- package/dist/cjs/defaults/ask/templates.js +14 -4
- package/dist/cjs/element/role/index.js +7 -0
- package/dist/cjs/element/role/miso-affiliation.js +20 -0
- package/dist/cjs/layout/affiliation/affiliation.js +330 -0
- package/dist/cjs/layout/banner/banner.js +1 -1
- package/dist/cjs/layout/container/container.js +1 -1
- package/dist/cjs/layout/error/error.js +1 -1
- package/dist/cjs/layout/index.js +7 -0
- package/dist/cjs/layout/input/option-list.js +35 -50
- package/dist/cjs/layout/input/search-box.js +17 -5
- package/dist/cjs/layout/list/cards.js +1 -1
- package/dist/cjs/layout/list/carousel.js +5 -3
- package/dist/cjs/layout/list/collection.js +38 -48
- package/dist/cjs/layout/list/list.js +1 -1
- package/dist/cjs/layout/radio/feedback.js +1 -1
- package/dist/cjs/layout/radio/radio.js +1 -1
- package/dist/cjs/layout/raf.js +1 -1
- package/dist/cjs/layout/template.js +1 -1
- package/dist/cjs/layout/templates.js +135 -44
- package/dist/cjs/layout/text/text.js +1 -1
- package/dist/cjs/layout/text/typewriter/index.js +3 -3
- package/dist/cjs/layout/trackable.js +124 -0
- package/dist/cjs/plugin.js +1 -1
- package/dist/cjs/util/bindings.js +58 -110
- package/dist/cjs/util/states.js +31 -24
- package/dist/cjs/util/trackers.js +75 -0
- package/dist/cjs/util/viewables.js +55 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/ask.js +14 -5
- package/dist/cjs/workflow/asks.js +1 -1
- package/dist/cjs/workflow/base.js +5 -5
- package/dist/cjs/workflow/explore.js +1 -1
- package/dist/cjs/workflow/options.js +6 -1
- package/dist/cjs/workflow/recommendation.js +2 -0
- package/package.json +2 -2
- package/src/actor/tracker.js +39 -62
- package/src/actor/trackers.js +3 -1
- package/src/actor/utils.js +6 -2
- package/src/actor/view.js +12 -1
- package/src/actor/views.js +11 -0
- package/src/affiliation/index.js +108 -0
- package/src/constants.js +10 -1
- package/src/defaults/ask/phrases.js +1 -1
- package/src/defaults/ask/templates.js +13 -2
- package/src/element/role/index.js +1 -0
- package/src/element/role/miso-affiliation.js +16 -0
- package/src/layout/affiliation/affiliation.js +295 -0
- package/src/layout/index.js +1 -0
- package/src/layout/input/option-list.js +35 -43
- package/src/layout/input/search-box.js +7 -2
- package/src/layout/list/carousel.js +4 -2
- package/src/layout/list/collection.js +37 -43
- package/src/layout/templates.js +101 -26
- package/src/layout/text/typewriter/index.js +2 -2
- package/src/layout/trackable.js +106 -0
- package/src/util/bindings.js +47 -103
- package/src/util/states.js +26 -20
- package/src/util/trackers.js +69 -0
- package/src/util/viewables.js +47 -0
- package/src/version.js +1 -1
- package/src/workflow/ask.js +7 -3
- package/src/workflow/base.js +1 -1
- package/src/workflow/options.js +5 -1
- package/src/workflow/recommendation.js +1 -0
- package/dist/cjs/util/tracker.js +0 -348
- package/src/util/tracker.js +0 -318
|
@@ -3,131 +3,79 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function tuple(keys, values, elements) {
|
|
8
|
+
const k2b = new Map();
|
|
9
|
+
const e2b = new Map();
|
|
10
|
+
const entries = [];
|
|
11
|
+
for (let index = 0; index < keys.length; index++) {
|
|
12
|
+
const key = keys[index];
|
|
13
|
+
const element = elements[index];
|
|
14
|
+
const value = values[index];
|
|
15
|
+
const entry = Object.freeze({
|
|
16
|
+
index,
|
|
17
|
+
key,
|
|
18
|
+
value,
|
|
19
|
+
element
|
|
20
|
+
});
|
|
21
|
+
k2b.set(key, entry);
|
|
22
|
+
e2b.set(element, entry);
|
|
23
|
+
entries.push(entry);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
k2b,
|
|
27
|
+
e2b,
|
|
28
|
+
entries
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function diff(from, to) {
|
|
32
|
+
const entries = [];
|
|
33
|
+
for (const entry of to.entries) {
|
|
34
|
+
const f = from.e2b.get(entry.element);
|
|
35
|
+
if (!f || f.key !== entry.key) {
|
|
36
|
+
entries.push(entry);
|
|
14
37
|
}
|
|
15
|
-
}
|
|
38
|
+
}
|
|
39
|
+
return entries;
|
|
16
40
|
}
|
|
17
41
|
class Bindings {
|
|
18
42
|
constructor() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
23
|
-
this._list = list || fallbackListFunction(keyAttrName);
|
|
24
|
-
this._bindings = new Map();
|
|
25
|
-
this._e2b = new WeakMap();
|
|
43
|
+
this._k2b = new Map();
|
|
44
|
+
this._e2b = new Map();
|
|
45
|
+
this._entries = [];
|
|
26
46
|
}
|
|
27
|
-
|
|
28
|
-
return [...this.
|
|
47
|
+
get entries() {
|
|
48
|
+
return [...this._entries];
|
|
29
49
|
}
|
|
30
|
-
get(
|
|
31
|
-
|
|
32
|
-
throw new Error(`Value or element is required.`);
|
|
33
|
-
}
|
|
34
|
-
if (!this._root) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
if (!(0, _commons.isElement)(ref)) {
|
|
38
|
-
return this._bindings.get(ref);
|
|
39
|
-
}
|
|
40
|
-
return (0, _commons.findInAncestors)(ref, element => this._e2b.get(element) || undefined, {
|
|
41
|
-
root: this._root
|
|
42
|
-
});
|
|
50
|
+
get(element) {
|
|
51
|
+
return this._e2b.get(element) || undefined;
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
bounds.push(binding);
|
|
57
|
-
}
|
|
58
|
-
for (const u of ubs) {
|
|
59
|
-
unbounds.push(u);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
53
|
+
update(keys, values, elements) {
|
|
54
|
+
const newTuple = tuple(keys, values, elements);
|
|
55
|
+
const oldTuple = {
|
|
56
|
+
k2b: this._k2b,
|
|
57
|
+
e2b: this._e2b,
|
|
58
|
+
entries: this._entries
|
|
59
|
+
};
|
|
60
|
+
const bounds = diff(oldTuple, newTuple);
|
|
61
|
+
const unbounds = diff(newTuple, oldTuple);
|
|
62
|
+
this._k2b = newTuple.k2b;
|
|
63
|
+
this._e2b = newTuple.e2b;
|
|
64
|
+
this._entries = newTuple.entries;
|
|
62
65
|
return {
|
|
63
66
|
bounds,
|
|
64
67
|
unbounds
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
|
-
|
|
68
|
-
const unbounds = this.
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
70
|
+
clear() {
|
|
71
|
+
const unbounds = this._entries;
|
|
72
|
+
this._k2b = new Map();
|
|
73
|
+
this._e2b = new Map();
|
|
74
|
+
this._entries = [];
|
|
71
75
|
return {
|
|
72
76
|
bounds: [],
|
|
73
77
|
unbounds
|
|
74
78
|
};
|
|
75
79
|
}
|
|
76
|
-
_bind(_ref) {
|
|
77
|
-
let {
|
|
78
|
-
element,
|
|
79
|
-
key,
|
|
80
|
-
value
|
|
81
|
-
} = _ref;
|
|
82
|
-
key = key || value;
|
|
83
|
-
if (!key) {
|
|
84
|
-
throw new Error(`Key or value is required.`);
|
|
85
|
-
}
|
|
86
|
-
if (!element) {
|
|
87
|
-
throw new Error(`Element is required.`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// check if binding already exist
|
|
91
|
-
const oldBinding = this._bindings.get(key);
|
|
92
|
-
if (oldBinding && oldBinding.element === element) {
|
|
93
|
-
return [];
|
|
94
|
-
}
|
|
95
|
-
const unbound0 = this._unbind(this.get(key));
|
|
96
|
-
const unbound1 = this._unbind(this.get(element));
|
|
97
|
-
const binding = Object.freeze({
|
|
98
|
-
key,
|
|
99
|
-
value,
|
|
100
|
-
element
|
|
101
|
-
});
|
|
102
|
-
this._bindings.set(key, binding);
|
|
103
|
-
this._e2b.set(element, binding);
|
|
104
|
-
const results = [binding];
|
|
105
|
-
unbound0 && results.push(unbound0);
|
|
106
|
-
unbound1 && results.push(unbound1);
|
|
107
|
-
return results;
|
|
108
|
-
}
|
|
109
|
-
_purge() {
|
|
110
|
-
const purged = [];
|
|
111
|
-
for (const binding of this._bindings.values()) {
|
|
112
|
-
const {
|
|
113
|
-
element
|
|
114
|
-
} = binding;
|
|
115
|
-
if ((0, _commons.isInDocument)(element)) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
purged.push(this._unbind(binding));
|
|
119
|
-
}
|
|
120
|
-
return purged;
|
|
121
|
-
}
|
|
122
|
-
_unbind(binding) {
|
|
123
|
-
if (binding) {
|
|
124
|
-
this._bindings.delete(binding.key);
|
|
125
|
-
this._e2b.delete(binding.element);
|
|
126
|
-
}
|
|
127
|
-
return binding;
|
|
128
|
-
}
|
|
129
|
-
_destroy() {
|
|
130
|
-
this.unbindAll();
|
|
131
|
-
}
|
|
132
80
|
}
|
|
133
|
-
exports.
|
|
81
|
+
exports.default = Bindings;
|
package/dist/cjs/util/states.js
CHANGED
|
@@ -15,55 +15,62 @@ const {
|
|
|
15
15
|
UNTRACKED,
|
|
16
16
|
TRIGGERED
|
|
17
17
|
} = _constants.TRACKING_STATUS;
|
|
18
|
+
|
|
19
|
+
/*
|
|
18
20
|
const STATES = {
|
|
19
21
|
NEW: Object.freeze({
|
|
20
22
|
[IMPRESSION]: UNTRACKED,
|
|
21
|
-
[VIEWABLE]: UNTRACKED
|
|
23
|
+
[VIEWABLE]: UNTRACKED,
|
|
22
24
|
}),
|
|
23
25
|
UNTRACKED: Object.freeze({
|
|
24
26
|
[IMPRESSION]: UNTRACKED,
|
|
25
27
|
[VIEWABLE]: UNTRACKED,
|
|
26
|
-
[CLICK]: UNTRACKED
|
|
27
|
-
})
|
|
28
|
+
[CLICK]: UNTRACKED,
|
|
29
|
+
}),
|
|
28
30
|
};
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const UNTRACKED_STATES = Object.freeze({
|
|
34
|
+
[IMPRESSION]: UNTRACKED,
|
|
35
|
+
[VIEWABLE]: UNTRACKED,
|
|
36
|
+
[CLICK]: UNTRACKED
|
|
37
|
+
});
|
|
29
38
|
|
|
30
39
|
/**
|
|
31
40
|
* Tracking states for a session to keep track of the tracking status of each product.
|
|
32
|
-
* For each entry there are status of impression, viewable, and click events.
|
|
33
|
-
* The actual click tracking status depends on the presence of root element, which is not respected in this object.
|
|
41
|
+
* For each entry there are status of impression, viewable, and click events.
|
|
34
42
|
*/
|
|
35
43
|
class States {
|
|
36
44
|
constructor(sessionId) {
|
|
37
45
|
this.sessionId = sessionId;
|
|
38
|
-
this._states = new Map(); //
|
|
46
|
+
this._states = new Map(); // item key -> {impression, viewable, click}
|
|
39
47
|
}
|
|
40
|
-
getFullState(
|
|
48
|
+
getFullState(item) {
|
|
41
49
|
// when we receive a bind event, impression is trigger, making an entry here
|
|
42
50
|
// so if the state is not found, the product is not present yet => all untracked
|
|
43
|
-
const state = this._states.get(
|
|
44
|
-
return state ? Object.assign({}, state) :
|
|
51
|
+
const state = this._states.get(this._getKey(item));
|
|
52
|
+
return state ? Object.assign({}, state) : UNTRACKED_STATES;
|
|
45
53
|
}
|
|
46
|
-
get(
|
|
47
|
-
const state = this._states.get(
|
|
54
|
+
get(item, type) {
|
|
55
|
+
const state = this._states.get(this._getKey(item));
|
|
48
56
|
return state && state[type] || UNTRACKED;
|
|
49
57
|
}
|
|
50
|
-
set(
|
|
58
|
+
set(items, type, status) {
|
|
51
59
|
(0, _constants.validateEventType)(type);
|
|
52
60
|
(0, _constants.validateTrackingStatus)(status);
|
|
53
|
-
for (const
|
|
54
|
-
this._setOne(
|
|
61
|
+
for (const item of (0, _commons.asArray)(items)) {
|
|
62
|
+
this._setOne(item, type, status);
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
untriggered(items, type) {
|
|
66
|
+
return items.filter(item => this.get(item, type) !== TRIGGERED);
|
|
67
|
+
}
|
|
68
|
+
_getKey(item) {
|
|
69
|
+
// TODO: ad-hoc! should move away to higher level
|
|
70
|
+
return item.product_id || item.text || item.id || item;
|
|
60
71
|
}
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
_setOne(item, type, status) {
|
|
73
|
+
(0, _commons.computeIfAbsent)(this._states, this._getKey(item), () => Object.assign({}, UNTRACKED_STATES))[type] = status;
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
|
-
exports.default = States;
|
|
66
|
-
function getKey(value) {
|
|
67
|
-
// TODO: ad-hoc!
|
|
68
|
-
return value.product_id || value.text || value;
|
|
69
|
-
}
|
|
76
|
+
exports.default = States;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normalizeTrackerOptions = normalizeTrackerOptions;
|
|
7
|
+
exports.validateClick = validateClick;
|
|
8
|
+
var _commons = require("@miso.ai/commons");
|
|
9
|
+
const _excluded = ["impression", "viewable", "click"];
|
|
10
|
+
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; }
|
|
11
|
+
const DEFAULT_TRACKER_OPTIONS = Object.freeze({
|
|
12
|
+
impression: Object.freeze({}),
|
|
13
|
+
viewable: Object.freeze({
|
|
14
|
+
area: 0.5,
|
|
15
|
+
duration: 1000
|
|
16
|
+
}),
|
|
17
|
+
click: Object.freeze({
|
|
18
|
+
lenient: false
|
|
19
|
+
}),
|
|
20
|
+
watch: false
|
|
21
|
+
});
|
|
22
|
+
function mergeOptions(def, opt) {
|
|
23
|
+
// if opt is falsy then return false, merge otherwise
|
|
24
|
+
return !!opt && Object.assign({}, def, opt);
|
|
25
|
+
}
|
|
26
|
+
function normalizeTrackerOptions(options) {
|
|
27
|
+
if (options === false) {
|
|
28
|
+
return false; // turn off all tracking
|
|
29
|
+
}
|
|
30
|
+
if (options === true) {
|
|
31
|
+
options = {};
|
|
32
|
+
}
|
|
33
|
+
if (typeof options !== 'object') {
|
|
34
|
+
throw new Error(`Invalid options: ${options}`);
|
|
35
|
+
}
|
|
36
|
+
const {
|
|
37
|
+
impression = {},
|
|
38
|
+
viewable = {},
|
|
39
|
+
click = {}
|
|
40
|
+
} = options,
|
|
41
|
+
rest = _objectWithoutPropertiesLoose(options, _excluded);
|
|
42
|
+
return (0, _commons.trimObj)(Object.assign({}, DEFAULT_TRACKER_OPTIONS, rest, {
|
|
43
|
+
impression: mergeOptions(DEFAULT_TRACKER_OPTIONS.impression, impression),
|
|
44
|
+
viewable: mergeOptions(DEFAULT_TRACKER_OPTIONS.viewable, viewable),
|
|
45
|
+
click: mergeOptions(DEFAULT_TRACKER_OPTIONS.click, click)
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
function validateClick() {
|
|
49
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
50
|
+
let event = arguments.length > 1 ? arguments[1] : undefined;
|
|
51
|
+
if (!options) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
if (typeof options.validate === 'function') {
|
|
55
|
+
return options.validate(event);
|
|
56
|
+
}
|
|
57
|
+
if (options.lenient) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// standard criteria
|
|
62
|
+
// 1. it must be a left click
|
|
63
|
+
if (event.button !== 0) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
// 2. event default must not be prevented
|
|
67
|
+
if (event.defaultPrevented) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
// 3. must go through a real link
|
|
71
|
+
if (!(0, _commons.findInAncestors)(event.target, element => element.tagName === 'A' && element.href || undefined)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _commons = require("@miso.ai/commons");
|
|
8
|
+
class Viewables {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._entries = new WeakMap();
|
|
11
|
+
}
|
|
12
|
+
isTracked(element) {
|
|
13
|
+
return this._entries.has(element);
|
|
14
|
+
}
|
|
15
|
+
async track(element) {
|
|
16
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17
|
+
if (!options) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const entry = this._entries.get(element);
|
|
21
|
+
if (entry) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const ac = new AbortController();
|
|
25
|
+
const {
|
|
26
|
+
signal
|
|
27
|
+
} = ac;
|
|
28
|
+
this._entries.set(element, {
|
|
29
|
+
ac
|
|
30
|
+
});
|
|
31
|
+
let result = false;
|
|
32
|
+
try {
|
|
33
|
+
await (0, _commons.viewable)(element, Object.assign({}, options, {
|
|
34
|
+
signal
|
|
35
|
+
}));
|
|
36
|
+
result = true;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
if (e.name !== 'AbortError') {
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
} finally {
|
|
42
|
+
this._entries.delete(element);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
untrack(element) {
|
|
47
|
+
const entry = this._entries.get(element);
|
|
48
|
+
if (!entry) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
entry.ac.abort();
|
|
52
|
+
this._entries.delete(element);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.default = Viewables;
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/workflow/ask.js
CHANGED
|
@@ -11,11 +11,12 @@ var sources = _interopRequireWildcard(require("../source/index.js"));
|
|
|
11
11
|
var _index2 = require("../actor/index.js");
|
|
12
12
|
var _constants = require("../constants.js");
|
|
13
13
|
var _index3 = require("../layout/index.js");
|
|
14
|
+
var _index4 = require("../affiliation/index.js");
|
|
14
15
|
const _excluded = ["q", "qs"];
|
|
15
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
19
|
+
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; }
|
|
19
20
|
const DEFAULT_API_OPTIONS = Object.freeze({
|
|
20
21
|
group: _commons.API.GROUP.ASK,
|
|
21
22
|
name: _commons.API.NAME.QUESTIONS,
|
|
@@ -54,14 +55,20 @@ const DEFAULT_LAYOUTS = Object.freeze({
|
|
|
54
55
|
incremental: true,
|
|
55
56
|
itemType: 'article'
|
|
56
57
|
}],
|
|
57
|
-
[_constants.ROLE.QUERY_SUGGESTIONS]: _index3.OptionListLayout.type
|
|
58
|
+
[_constants.ROLE.QUERY_SUGGESTIONS]: _index3.OptionListLayout.type,
|
|
59
|
+
[_constants.ROLE.AFFILIATION]: [_index3.AffiliationLayout.type, {
|
|
60
|
+
incremental: true,
|
|
61
|
+
itemType: 'affiliation',
|
|
62
|
+
link: {
|
|
63
|
+
rel: 'noopener nofollow'
|
|
64
|
+
}
|
|
65
|
+
}]
|
|
58
66
|
});
|
|
59
67
|
const DEFAULT_TRACKERS = Object.freeze({
|
|
60
68
|
[_constants.ROLE.SOURCES]: {},
|
|
61
69
|
[_constants.ROLE.RELATED_RESOURCES]: {},
|
|
70
|
+
[_constants.ROLE.AFFILIATION]: {},
|
|
62
71
|
[_constants.ROLE.QUERY_SUGGESTIONS]: {
|
|
63
|
-
active: true,
|
|
64
|
-
// we are tracking events at initial stage, when session is not active yet
|
|
65
72
|
click: {
|
|
66
73
|
validate: event => event.button === 0 // left click only
|
|
67
74
|
}
|
|
@@ -251,6 +258,9 @@ class Ask extends _base.default {
|
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
260
|
|
|
261
|
+
// affiliation
|
|
262
|
+
data = (0, _index4.processData)(data);
|
|
263
|
+
|
|
254
264
|
// 1. put answer_stage to meta
|
|
255
265
|
// 2. mark ongoing flag
|
|
256
266
|
return Object.assign({}, data, {
|
|
@@ -358,7 +368,6 @@ class Ask extends _base.default {
|
|
|
358
368
|
this._context._byQid.delete(questionId);
|
|
359
369
|
}
|
|
360
370
|
this._feedback._destroy();
|
|
361
|
-
this._autocomplete._destroy();
|
|
362
371
|
super._destroy(options);
|
|
363
372
|
}
|
|
364
373
|
}
|
|
@@ -8,7 +8,7 @@ var _context = _interopRequireDefault(require("./context.js"));
|
|
|
8
8
|
var _ask = _interopRequireDefault(require("./ask.js"));
|
|
9
9
|
const _excluded = ["root", "events"];
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
11
|
+
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; }
|
|
12
12
|
class Asks extends _context.default {
|
|
13
13
|
constructor(plugin, client) {
|
|
14
14
|
super('asks', plugin, client);
|
|
@@ -16,7 +16,7 @@ const _excluded = ["layouts", "interactions"],
|
|
|
16
16
|
_excluded3 = ["context"];
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
19
|
+
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; }
|
|
20
20
|
const DEFAULT_LAYOUTS = Object.freeze({
|
|
21
21
|
[_constants.ROLE.CONTAINER]: _index3.ContainerLayout.type,
|
|
22
22
|
[_constants.ROLE.ERROR]: _index3.ErrorLayout.type
|
|
@@ -72,14 +72,14 @@ class Workflow extends _commons.Component {
|
|
|
72
72
|
options,
|
|
73
73
|
workflow: name
|
|
74
74
|
});
|
|
75
|
-
this._interactions = new _index.InteractionsActor(hub, {
|
|
76
|
-
client,
|
|
77
|
-
options
|
|
78
|
-
});
|
|
79
75
|
this._trackers = new _index.Trackers(hub, {
|
|
80
76
|
views,
|
|
81
77
|
options
|
|
82
78
|
});
|
|
79
|
+
this._interactions = new _index.InteractionsActor(hub, {
|
|
80
|
+
client,
|
|
81
|
+
options
|
|
82
|
+
});
|
|
83
83
|
this._unsubscribes = [this._hub.on(_index.fields.response(), data => this.updateData(data))];
|
|
84
84
|
}
|
|
85
85
|
get uuid() {
|
|
@@ -12,7 +12,7 @@ var _constants = require("../constants.js");
|
|
|
12
12
|
var _index2 = require("../layout/index.js");
|
|
13
13
|
const _excluded = ["value"];
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
15
|
+
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; }
|
|
16
16
|
const DEFAULT_API_OPTIONS = Object.freeze({
|
|
17
17
|
group: _commons.API.GROUP.ASK,
|
|
18
18
|
name: _commons.API.NAME.RELATED_QUESTIONS
|
|
@@ -19,7 +19,7 @@ exports.normalizeLayoutsOptions = normalizeLayoutsOptions;
|
|
|
19
19
|
exports.normalizeTrackers = normalizeTrackers;
|
|
20
20
|
var _commons = require("@miso.ai/commons");
|
|
21
21
|
var _constants = require("../constants.js");
|
|
22
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.
|
|
22
|
+
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; }
|
|
23
23
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
24
24
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
25
25
|
// normalize //
|
|
@@ -35,10 +35,15 @@ function normalizeApiOptions() {
|
|
|
35
35
|
payload = name;
|
|
36
36
|
name = undefined;
|
|
37
37
|
}
|
|
38
|
+
let group = undefined;
|
|
39
|
+
if (name && name.indexOf('/') !== -1) {
|
|
40
|
+
[group, name] = name.split('/');
|
|
41
|
+
}
|
|
38
42
|
if (name && typeof name !== 'string' || payload !== undefined && typeof payload !== 'object') {
|
|
39
43
|
throw new Error(`Invalid arguments for useApi(): ${name}, ${payload}`);
|
|
40
44
|
}
|
|
41
45
|
return (0, _commons.trimObj)({
|
|
46
|
+
group,
|
|
42
47
|
name,
|
|
43
48
|
payload
|
|
44
49
|
});
|
package/package.json
CHANGED