@miso.ai/client-sdk-ui 1.13.2-beta.1 → 1.14.0-beta.3
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/asset/svgs.js +17 -4
- package/dist/cjs/combo/ask/index.js +2 -2
- package/dist/cjs/constants.js +120 -98
- package/dist/cjs/defaults/ask/controls.js +1 -1
- package/dist/cjs/defaults/hybrid-search/answer-box.js +4 -4
- package/dist/cjs/defaults.js +259 -0
- package/dist/cjs/element/container/index.js +28 -0
- package/dist/cjs/element/container/miso-ask.js +3 -3
- package/dist/cjs/element/container/miso-conversation.js +21 -0
- package/dist/cjs/element/container/miso-explore.js +1 -1
- package/dist/cjs/element/container/miso-history.js +21 -0
- package/dist/cjs/element/container/miso-hybrid-search.js +1 -1
- package/dist/cjs/element/container/miso-message-item.js +91 -0
- package/dist/cjs/element/container/miso-recommendation.js +1 -1
- package/dist/cjs/element/container/miso-search.js +1 -1
- package/dist/cjs/element/container/miso-thread-item.js +91 -0
- package/dist/cjs/element/context/miso-follow-ups.js +1 -1
- package/dist/cjs/element/role/index.js +49 -0
- package/dist/cjs/element/role/miso-delete.js +20 -0
- package/dist/cjs/element/role/miso-messages.js +20 -0
- package/dist/cjs/element/role/miso-new-thread.js +20 -0
- package/dist/cjs/element/role/miso-rename.js +20 -0
- package/dist/cjs/element/role/miso-subscription.js +20 -0
- package/dist/cjs/element/role/miso-threads.js +20 -0
- package/dist/cjs/element/role/miso-title.js +20 -0
- package/dist/cjs/layout/affiliation/affiliation.js +1 -1
- package/dist/cjs/layout/banner/banner.js +2 -1
- package/dist/cjs/layout/button/button.js +170 -0
- package/dist/cjs/layout/button/checkbox.js +116 -0
- package/dist/cjs/layout/button/more-button.js +3 -3
- package/dist/cjs/layout/container/container.js +1 -1
- package/dist/cjs/layout/container/item-container.js +99 -0
- package/dist/cjs/layout/error/error.js +2 -1
- package/dist/cjs/layout/index.js +42 -0
- package/dist/cjs/layout/input/facets.js +4 -3
- package/dist/cjs/layout/input/option-list.js +3 -2
- package/dist/cjs/layout/input/search-box.js +50 -12
- package/dist/cjs/layout/input/select.js +2 -1
- package/dist/cjs/layout/list/cards.js +2 -1
- package/dist/cjs/layout/list/carousel.js +2 -1
- package/dist/cjs/layout/list/collection.js +13 -1
- package/dist/cjs/layout/list/gallery.js +2 -1
- package/dist/cjs/layout/list/horizontal.js +2 -1
- package/dist/cjs/layout/list/list.js +2 -1
- package/dist/cjs/layout/list/messages.js +359 -0
- package/dist/cjs/layout/list/threads.js +199 -0
- package/dist/cjs/layout/mixin/trackable.js +4 -5
- package/dist/cjs/layout/mixin/triggerable.js +2 -2
- package/dist/cjs/layout/radio/feedback.js +4 -3
- package/dist/cjs/layout/templates.js +97 -0
- package/dist/cjs/layout/text/question.js +71 -0
- package/dist/cjs/layout/text/text.js +2 -1
- package/dist/cjs/layout/text/typewriter/index.js +18 -23
- package/dist/cjs/plugin.js +43 -104
- package/dist/cjs/util/confirm.js +33 -0
- package/dist/cjs/util/dom.js +21 -0
- package/dist/cjs/util/modal.js +48 -0
- package/dist/cjs/util/prompt.js +47 -0
- package/dist/cjs/version.js +1 -1
- package/package.json +5 -4
- package/src/CLAUDE.md +51 -104
- package/src/asset/svgs.js +16 -3
- package/src/combo/ask/index.js +2 -2
- package/src/constants.js +39 -147
- package/src/defaults/ask/controls.js +1 -1
- package/src/defaults/hybrid-search/answer-box.js +2 -2
- package/src/defaults.js +174 -0
- package/src/element/container/index.js +4 -0
- package/src/element/container/miso-ask.js +3 -3
- package/src/element/container/miso-conversation.js +19 -0
- package/src/element/container/miso-explore.js +1 -1
- package/src/element/container/miso-history.js +19 -0
- package/src/element/container/miso-hybrid-search.js +1 -1
- package/src/element/container/miso-message-item.js +94 -0
- package/src/element/container/miso-recommendation.js +1 -1
- package/src/element/container/miso-search.js +1 -1
- package/src/element/container/miso-thread-item.js +94 -0
- package/src/element/context/miso-follow-ups.js +1 -1
- package/src/element/role/index.js +7 -0
- package/src/element/role/miso-delete.js +16 -0
- package/src/element/role/miso-messages.js +16 -0
- package/src/element/role/miso-new-thread.js +16 -0
- package/src/element/role/miso-rename.js +16 -0
- package/src/element/role/miso-subscription.js +16 -0
- package/src/element/role/miso-threads.js +16 -0
- package/src/element/role/miso-title.js +16 -0
- package/src/layout/affiliation/affiliation.js +2 -2
- package/src/layout/banner/banner.js +2 -1
- package/src/layout/button/button.js +152 -0
- package/src/layout/button/checkbox.js +92 -0
- package/src/layout/button/more-button.js +3 -3
- package/src/layout/container/container.js +2 -2
- package/src/layout/container/item-container.js +99 -0
- package/src/layout/error/error.js +2 -1
- package/src/layout/index.js +6 -0
- package/src/layout/input/facets.js +3 -2
- package/src/layout/input/option-list.js +3 -2
- package/src/layout/input/search-box.js +45 -8
- package/src/layout/input/select.js +2 -1
- package/src/layout/list/cards.js +2 -1
- package/src/layout/list/carousel.js +2 -1
- package/src/layout/list/collection.js +15 -2
- package/src/layout/list/gallery.js +2 -1
- package/src/layout/list/horizontal.js +2 -1
- package/src/layout/list/list.js +2 -1
- package/src/layout/list/messages.js +316 -0
- package/src/layout/list/threads.js +166 -0
- package/src/layout/mixin/trackable.js +2 -3
- package/src/layout/mixin/triggerable.js +1 -1
- package/src/layout/radio/feedback.js +3 -2
- package/src/layout/templates.js +97 -0
- package/src/layout/text/question.js +58 -0
- package/src/layout/text/text.js +2 -1
- package/src/layout/text/typewriter/index.js +15 -18
- package/src/plugin.js +31 -117
- package/src/util/confirm.js +28 -0
- package/src/util/dom.js +16 -0
- package/src/util/modal.js +49 -0
- package/src/util/prompt.js +42 -0
- package/src/version.js +1 -1
- package/dist/cjs/actor/data.js +0 -132
- package/dist/cjs/actor/feedback.js +0 -29
- package/dist/cjs/actor/fields.js +0 -57
- package/dist/cjs/actor/filters.js +0 -161
- package/dist/cjs/actor/hub.js +0 -57
- package/dist/cjs/actor/index.js +0 -73
- package/dist/cjs/actor/interactions.js +0 -36
- package/dist/cjs/actor/sessions.js +0 -25
- package/dist/cjs/actor/tracker-states.js +0 -61
- package/dist/cjs/actor/tracker.js +0 -109
- package/dist/cjs/actor/trackers.js +0 -52
- package/dist/cjs/actor/utils.js +0 -15
- package/dist/cjs/actor/view.js +0 -294
- package/dist/cjs/actor/views.js +0 -209
- package/dist/cjs/source.js +0 -27
- package/dist/cjs/util/proxy.js +0 -88
- package/dist/cjs/util/trackers.js +0 -88
- package/dist/cjs/workflow/affiliations.js +0 -140
- package/dist/cjs/workflow/answer-based.js +0 -337
- package/dist/cjs/workflow/ask.js +0 -319
- package/dist/cjs/workflow/asks.js +0 -150
- package/dist/cjs/workflow/autocompletable.js +0 -63
- package/dist/cjs/workflow/autocomplete.js +0 -120
- package/dist/cjs/workflow/base.js +0 -418
- package/dist/cjs/workflow/context.js +0 -19
- package/dist/cjs/workflow/explore.js +0 -210
- package/dist/cjs/workflow/explores.js +0 -21
- package/dist/cjs/workflow/hybrid-search-answer.js +0 -88
- package/dist/cjs/workflow/hybrid-search-views.js +0 -109
- package/dist/cjs/workflow/hybrid-search.js +0 -213
- package/dist/cjs/workflow/index.js +0 -41
- package/dist/cjs/workflow/options/api.js +0 -41
- package/dist/cjs/workflow/options/auto-query.js +0 -97
- package/dist/cjs/workflow/options/configurable.js +0 -45
- package/dist/cjs/workflow/options/data-processor.js +0 -20
- package/dist/cjs/workflow/options/filters.js +0 -15
- package/dist/cjs/workflow/options/index.js +0 -126
- package/dist/cjs/workflow/options/interactions.js +0 -41
- package/dist/cjs/workflow/options/layouts.js +0 -79
- package/dist/cjs/workflow/options/options.js +0 -156
- package/dist/cjs/workflow/options/pagination.js +0 -25
- package/dist/cjs/workflow/options/roles.js +0 -15
- package/dist/cjs/workflow/options/templates.js +0 -30
- package/dist/cjs/workflow/options/trackers.js +0 -83
- package/dist/cjs/workflow/options/utils.js +0 -33
- package/dist/cjs/workflow/processors.js +0 -607
- package/dist/cjs/workflow/recommendation.js +0 -57
- package/dist/cjs/workflow/recommendations.js +0 -18
- package/dist/cjs/workflow/search-based.js +0 -337
- package/dist/cjs/workflow/search.js +0 -64
- package/dist/cjs/workflow/unit.js +0 -57
- package/dist/cjs/workflow/units.js +0 -42
- package/dist/cjs/workflow/use-link.js +0 -49
- package/src/actor/data.js +0 -106
- package/src/actor/feedback.js +0 -28
- package/src/actor/fields.js +0 -51
- package/src/actor/filters.js +0 -149
- package/src/actor/hub.js +0 -47
- package/src/actor/index.js +0 -10
- package/src/actor/interactions.js +0 -32
- package/src/actor/sessions.js +0 -21
- package/src/actor/tracker-states.js +0 -57
- package/src/actor/tracker.js +0 -104
- package/src/actor/trackers.js +0 -45
- package/src/actor/utils.js +0 -7
- package/src/actor/view.js +0 -272
- package/src/actor/views.js +0 -224
- package/src/source.js +0 -17
- package/src/util/proxy.js +0 -81
- package/src/util/trackers.js +0 -84
- package/src/workflow/affiliations.js +0 -121
- package/src/workflow/answer-based.js +0 -312
- package/src/workflow/ask.js +0 -284
- package/src/workflow/asks.js +0 -143
- package/src/workflow/autocompletable.js +0 -67
- package/src/workflow/autocomplete.js +0 -114
- package/src/workflow/base.js +0 -396
- package/src/workflow/context.js +0 -16
- package/src/workflow/explore.js +0 -194
- package/src/workflow/explores.js +0 -18
- package/src/workflow/hybrid-search-answer.js +0 -73
- package/src/workflow/hybrid-search-views.js +0 -116
- package/src/workflow/hybrid-search.js +0 -230
- package/src/workflow/index.js +0 -5
- package/src/workflow/options/api.js +0 -31
- package/src/workflow/options/auto-query.js +0 -70
- package/src/workflow/options/configurable.js +0 -48
- package/src/workflow/options/data-processor.js +0 -15
- package/src/workflow/options/filters.js +0 -10
- package/src/workflow/options/index.js +0 -11
- package/src/workflow/options/interactions.js +0 -36
- package/src/workflow/options/layouts.js +0 -73
- package/src/workflow/options/options.js +0 -175
- package/src/workflow/options/pagination.js +0 -18
- package/src/workflow/options/roles.js +0 -12
- package/src/workflow/options/templates.js +0 -27
- package/src/workflow/options/trackers.js +0 -80
- package/src/workflow/options/utils.js +0 -26
- package/src/workflow/processors.js +0 -490
- package/src/workflow/recommendation.js +0 -63
- package/src/workflow/recommendations.js +0 -14
- package/src/workflow/search-based.js +0 -329
- package/src/workflow/search.js +0 -73
- package/src/workflow/unit.js +0 -51
- package/src/workflow/units.js +0 -43
- package/src/workflow/use-link.js +0 -41
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _answerBased = _interopRequireDefault(require("./answer-based.js"));
|
|
8
|
-
var _index = require("../actor/index.js");
|
|
9
|
-
var _processors = require("./processors.js");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const ROLES_OPTIONS = _answerBased.default.ROLES_OPTIONS;
|
|
12
|
-
class HybridSearchAnswer extends _answerBased.default {
|
|
13
|
-
constructor(superworkflow) {
|
|
14
|
-
super({
|
|
15
|
-
name: 'hybrid-search/answer',
|
|
16
|
-
plugin: superworkflow._plugin,
|
|
17
|
-
client: superworkflow._client,
|
|
18
|
-
options: superworkflow._options,
|
|
19
|
-
defaults: superworkflow._defaults,
|
|
20
|
-
roles: ROLES_OPTIONS,
|
|
21
|
-
superworkflow
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
_initProperties(args) {
|
|
25
|
-
super._initProperties(args);
|
|
26
|
-
this._superworkflow = args.superworkflow;
|
|
27
|
-
}
|
|
28
|
-
_initSession() {} // no reset here, will manually reset later
|
|
29
|
-
|
|
30
|
-
_doLoading(data) {
|
|
31
|
-
const {
|
|
32
|
-
session
|
|
33
|
-
} = this;
|
|
34
|
-
this.updateData(Object.assign({}, data, {
|
|
35
|
-
session
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
_queryWithQuestionId(data) {
|
|
39
|
-
const {
|
|
40
|
-
session
|
|
41
|
-
} = this;
|
|
42
|
-
const {
|
|
43
|
-
request,
|
|
44
|
-
value
|
|
45
|
-
} = data;
|
|
46
|
-
this.updateData(Object.assign({}, data, {
|
|
47
|
-
session
|
|
48
|
-
}));
|
|
49
|
-
// start query with question_id
|
|
50
|
-
const {
|
|
51
|
-
question_id
|
|
52
|
-
} = value;
|
|
53
|
-
if (!question_id) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
// forge the request
|
|
57
|
-
const payload = Object.assign({}, request.payload, {
|
|
58
|
-
question_id
|
|
59
|
-
});
|
|
60
|
-
if (payload.metadata.page !== undefined) {
|
|
61
|
-
delete payload.metadata.page;
|
|
62
|
-
}
|
|
63
|
-
this._hub.update(_index.fields.request(), Object.assign({}, request, {
|
|
64
|
-
payload,
|
|
65
|
-
session
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// data //
|
|
70
|
-
_defaultProcessData(data, oldData) {
|
|
71
|
-
data = super._defaultProcessData(data, oldData);
|
|
72
|
-
data = (0, _processors.writeKeywordsToData)(data);
|
|
73
|
-
data = (0, _processors.writeMisoIdFromSession)(data);
|
|
74
|
-
data = (0, _processors.writeUnanswerableToMeta)(data);
|
|
75
|
-
return data;
|
|
76
|
-
}
|
|
77
|
-
_handleHeadResponse(data) {
|
|
78
|
-
super._handleHeadResponse(data);
|
|
79
|
-
// keep track of miso_id in session
|
|
80
|
-
(0, _processors.writeMisoIdToSession)(data);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// interactions //
|
|
84
|
-
_onTracker(args) {
|
|
85
|
-
this._superworkflow._onTracker(args);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.default = HybridSearchAnswer;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _searchBased = _interopRequireDefault(require("./search-based.js"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const RESULTS_ROLE_MEMBERS = _searchBased.default.ROLES_OPTIONS.members;
|
|
10
|
-
function getSubworkflowByRole(role) {
|
|
11
|
-
// TODO: ROLE.ERROR
|
|
12
|
-
return RESULTS_ROLE_MEMBERS.includes(role) ? 'results' : 'answer';
|
|
13
|
-
}
|
|
14
|
-
class HybridSearchViewsActor {
|
|
15
|
-
constructor(subviews) {
|
|
16
|
-
this._subviews = subviews;
|
|
17
|
-
this._containers = new Set();
|
|
18
|
-
}
|
|
19
|
-
get filters() {
|
|
20
|
-
return this._subviews.results.filters;
|
|
21
|
-
}
|
|
22
|
-
on(role, event, callback) {
|
|
23
|
-
return this._getSubviews(role).on(role, event, callback);
|
|
24
|
-
}
|
|
25
|
-
get(role) {
|
|
26
|
-
return this._getSubviews(role).get(role);
|
|
27
|
-
}
|
|
28
|
-
getAll(role) {
|
|
29
|
-
return this._getSubviews(role).getAll(role);
|
|
30
|
-
}
|
|
31
|
-
addContainer(element) {
|
|
32
|
-
if (this._containers.has(element)) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this._containers.add(element);
|
|
36
|
-
const {
|
|
37
|
-
components
|
|
38
|
-
} = element;
|
|
39
|
-
for (const component of components) {
|
|
40
|
-
this.addComponent(component);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
removeContainer(element) {
|
|
44
|
-
for (const subviews of this._getAllSubviews()) {
|
|
45
|
-
subviews.removeContainer(element);
|
|
46
|
-
}
|
|
47
|
-
this._containers.delete(element);
|
|
48
|
-
}
|
|
49
|
-
addComponent(element) {
|
|
50
|
-
this._getSubviews(element.role).addComponent(element);
|
|
51
|
-
this._addContainerToSubviews(element._container, element);
|
|
52
|
-
}
|
|
53
|
-
removeComponent(element) {
|
|
54
|
-
this._getSubviews(element.role).removeComponent(element);
|
|
55
|
-
this._removeContainerFromSubviewsIfNecessary(element._container);
|
|
56
|
-
}
|
|
57
|
-
updateComponentRole(element, oldRole, newRole) {
|
|
58
|
-
// TODO
|
|
59
|
-
}
|
|
60
|
-
refreshElement(element) {
|
|
61
|
-
this._getSubviews(element.role).refreshElement(element);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// helpers //
|
|
65
|
-
_getAllSubviews() {
|
|
66
|
-
return Object.values(this._subviews);
|
|
67
|
-
}
|
|
68
|
-
_getSubviews(role) {
|
|
69
|
-
return this._subviews[getSubworkflowByRole(role)];
|
|
70
|
-
}
|
|
71
|
-
_addContainerToSubviews(container, child) {
|
|
72
|
-
if (!container) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const {
|
|
76
|
-
role
|
|
77
|
-
} = child;
|
|
78
|
-
const subviews = this._getSubviews(role);
|
|
79
|
-
if (subviews._containers.has(container)) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
// check if the container is in other subviews
|
|
83
|
-
for (const otherSubviews of this._getAllSubviews()) {
|
|
84
|
-
if (otherSubviews === subviews) {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
if (otherSubviews._containers.has(container)) {
|
|
88
|
-
// find the conflicting element
|
|
89
|
-
for (const component of container.components) {
|
|
90
|
-
if (otherSubviews.containsElement(component)) {
|
|
91
|
-
throw new Error(`<${container.tagName.toLowerCase()}> cannot contain both <${component.tagName.toLowerCase()}> and <${child.tagName.toLowerCase()}>, for they don't share the same data lifecycle.`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
throw new Error(`Failed to add container <${container.tagName.toLowerCase()}> with child component <${child.tagName.toLowerCase()}>.`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// add the container to the subviews
|
|
98
|
-
subviews.addContainer(container);
|
|
99
|
-
}
|
|
100
|
-
_removeContainerFromSubviewsIfNecessary(container) {
|
|
101
|
-
if (!container || container.components.length > 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
for (const subviews of this._getAllSubviews()) {
|
|
105
|
-
subviews.removeContainer(container);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.default = HybridSearchViewsActor;
|
|
@@ -1,213 +0,0 @@
|
|
|
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
|
-
var _searchBased = _interopRequireDefault(require("./search-based.js"));
|
|
9
|
-
var _answerBased = _interopRequireDefault(require("./answer-based.js"));
|
|
10
|
-
var _constants = require("../constants.js");
|
|
11
|
-
var _index = require("../layout/index.js");
|
|
12
|
-
var _templates = require("../layout/templates.js");
|
|
13
|
-
var _hybridSearchAnswer = _interopRequireDefault(require("./hybrid-search-answer.js"));
|
|
14
|
-
var _hybridSearchViews = _interopRequireDefault(require("./hybrid-search-views.js"));
|
|
15
|
-
var _index2 = require("./options/index.js");
|
|
16
|
-
var _processors = require("./processors.js");
|
|
17
|
-
var _autocompletable = require("./autocompletable.js");
|
|
18
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
-
const DEFAULT_API_OPTIONS = Object.freeze({
|
|
20
|
-
group: _commons.API.GROUP.ASK,
|
|
21
|
-
name: _commons.API.NAME.SEARCH,
|
|
22
|
-
payload: Object.assign({}, _answerBased.default.DEFAULT_API_OPTIONS.payload, _searchBased.default.DEFAULT_API_OPTIONS.payload, {
|
|
23
|
-
source_fl: ['cover_image', 'url', 'created_at', 'updated_at', 'published_at', 'title', 'authors']
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _answerBased.default.DEFAULT_LAYOUTS, _searchBased.default.DEFAULT_LAYOUTS, {
|
|
27
|
-
[_constants.ROLE.QUERY]: [_index.SearchBoxLayout.type, {
|
|
28
|
-
placeholder: ''
|
|
29
|
-
}],
|
|
30
|
-
[_constants.ROLE.QUESTION]: [_index.TextLayout.type, {
|
|
31
|
-
raw: true
|
|
32
|
-
}],
|
|
33
|
-
[_constants.ROLE.SOURCES]: [_index.HorizontalLayout.type, {
|
|
34
|
-
incremental: true,
|
|
35
|
-
itemType: 'article',
|
|
36
|
-
templates: {
|
|
37
|
-
ordered: true,
|
|
38
|
-
article: _templates.compactArticle,
|
|
39
|
-
articleInfoBlock: _templates.compactArticleInfoBlock
|
|
40
|
-
}
|
|
41
|
-
}]
|
|
42
|
-
}));
|
|
43
|
-
const DEFAULT_TRACKERS = Object.freeze(Object.assign({}, _answerBased.default.DEFAULT_TRACKERS, _searchBased.default.DEFAULT_TRACKERS));
|
|
44
|
-
const DEFAULT_PAGINATION = Object.freeze(Object.assign({}, _searchBased.default.DEFAULT_PAGINATION, {
|
|
45
|
-
active: true
|
|
46
|
-
}));
|
|
47
|
-
const DEFAULT_AUTOCOMPLETE_OPTIONS = Object.freeze({
|
|
48
|
-
api: {
|
|
49
|
-
group: _commons.API.GROUP.ASK,
|
|
50
|
-
name: _commons.API.NAME.SEARCH_AUTOCOMPLETE,
|
|
51
|
-
payload: {
|
|
52
|
-
completion_fields: ['suggested_queries']
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
const DEFAULT_FILTERS_OPTIONS = Object.freeze({
|
|
57
|
-
sort: {
|
|
58
|
-
options: [{
|
|
59
|
-
field: 'relevance',
|
|
60
|
-
text: 'Relevance',
|
|
61
|
-
default: true
|
|
62
|
-
}, {
|
|
63
|
-
field: 'published_at',
|
|
64
|
-
text: 'Date'
|
|
65
|
-
}]
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const DEFAULT_OPTIONS = Object.freeze(Object.assign({}, _answerBased.default.DEFAULT_OPTIONS, _searchBased.default.DEFAULT_OPTIONS, {
|
|
69
|
-
api: DEFAULT_API_OPTIONS,
|
|
70
|
-
layouts: DEFAULT_LAYOUTS,
|
|
71
|
-
trackers: DEFAULT_TRACKERS,
|
|
72
|
-
autocomplete: DEFAULT_AUTOCOMPLETE_OPTIONS,
|
|
73
|
-
pagination: DEFAULT_PAGINATION,
|
|
74
|
-
filters: DEFAULT_FILTERS_OPTIONS
|
|
75
|
-
}));
|
|
76
|
-
const ROLES_OPTIONS = Object.freeze({
|
|
77
|
-
main: _constants.ROLE.PRODUCTS,
|
|
78
|
-
members: Object.keys(DEFAULT_LAYOUTS),
|
|
79
|
-
mappings: Object.freeze(Object.assign({}, _answerBased.default.ROLES_OPTIONS.mappings, _searchBased.default.ROLES_OPTIONS.mappings))
|
|
80
|
-
});
|
|
81
|
-
const EXTRA_OPTIONS = Object.freeze({
|
|
82
|
-
api: Object.freeze({
|
|
83
|
-
polling: false
|
|
84
|
-
})
|
|
85
|
-
});
|
|
86
|
-
class HybridSearch extends _searchBased.default {
|
|
87
|
-
constructor(plugin, client) {
|
|
88
|
-
super({
|
|
89
|
-
name: 'hybrid-search',
|
|
90
|
-
plugin,
|
|
91
|
-
client,
|
|
92
|
-
roles: ROLES_OPTIONS,
|
|
93
|
-
defaults: DEFAULT_OPTIONS,
|
|
94
|
-
extraOptions: EXTRA_OPTIONS
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
_initProperties(args) {
|
|
98
|
-
super._initProperties(args);
|
|
99
|
-
this._initAutocomplete(args);
|
|
100
|
-
this._answer = new _hybridSearchAnswer.default(this);
|
|
101
|
-
}
|
|
102
|
-
_initActors(args) {
|
|
103
|
-
super._initActors(args);
|
|
104
|
-
this._views = new _hybridSearchViews.default({
|
|
105
|
-
results: this._views,
|
|
106
|
-
answer: this._answer._views
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
restart({
|
|
110
|
-
type
|
|
111
|
-
} = {}) {
|
|
112
|
-
super.restart();
|
|
113
|
-
if (!type || type === _constants.REQUEST_TYPE.QUERY) {
|
|
114
|
-
this._answer.restart();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// properties //
|
|
119
|
-
get answer() {
|
|
120
|
-
return this._answer;
|
|
121
|
-
}
|
|
122
|
-
get questionId() {
|
|
123
|
-
return this._answer.questionId;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// query //
|
|
127
|
-
_buildPayload(payload, type) {
|
|
128
|
-
payload = super._buildPayload(payload, type);
|
|
129
|
-
// borrow the work from the sibling
|
|
130
|
-
payload = (0, _processors.disableAnswerForNonQueryRequest)(payload, type);
|
|
131
|
-
payload = (0, _processors.writeQuestionSourceToPayload)(payload);
|
|
132
|
-
payload = this._writeQuestionIdToPayload(payload, type);
|
|
133
|
-
if (payload.answer !== false) {
|
|
134
|
-
// uses autoQuery params, so we want to apply to this workflow
|
|
135
|
-
payload = _answerBased.default.prototype._writeWikiLinkTemplateToPayload.call(this, payload);
|
|
136
|
-
}
|
|
137
|
-
return payload;
|
|
138
|
-
}
|
|
139
|
-
_buildOrderBy(sort) {
|
|
140
|
-
if (!sort) {
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
// works differently than search
|
|
144
|
-
return sort.field;
|
|
145
|
-
}
|
|
146
|
-
_writeQuestionIdToPayload(payload, type) {
|
|
147
|
-
if (type === _constants.REQUEST_TYPE.QUERY) {
|
|
148
|
-
return payload;
|
|
149
|
-
}
|
|
150
|
-
const question_id = this._answer.questionId;
|
|
151
|
-
if (!question_id) {
|
|
152
|
-
return payload;
|
|
153
|
-
}
|
|
154
|
-
return (0, _commons.mergeApiPayloads)(payload, {
|
|
155
|
-
metadata: {
|
|
156
|
-
question_id
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// data //
|
|
162
|
-
_defaultProcessData(data, oldData) {
|
|
163
|
-
data = super._defaultProcessData(data, oldData);
|
|
164
|
-
(0, _processors.writeMisoIdToSession)(data);
|
|
165
|
-
return data;
|
|
166
|
-
}
|
|
167
|
-
_updateDataInHub(data, oldData) {
|
|
168
|
-
this._dispatchDataToAnswerWorkflow(data);
|
|
169
|
-
data = (0, _processors.carryOverQuestionIdToData)(data, oldData); // TODO: may as well move to process data
|
|
170
|
-
super._updateDataInHub(data, oldData);
|
|
171
|
-
}
|
|
172
|
-
_dispatchDataToAnswerWorkflow(data) {
|
|
173
|
-
const {
|
|
174
|
-
request
|
|
175
|
-
} = data;
|
|
176
|
-
if (!request) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const {
|
|
180
|
-
type,
|
|
181
|
-
payload
|
|
182
|
-
} = request;
|
|
183
|
-
if (type !== _constants.REQUEST_TYPE.QUERY || !payload || payload.answer === false) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
switch (data.status) {
|
|
187
|
-
case _constants.STATUS.LOADING:
|
|
188
|
-
// share the loading status with its sibling
|
|
189
|
-
this._answer._doLoading(data);
|
|
190
|
-
break;
|
|
191
|
-
case _constants.STATUS.READY:
|
|
192
|
-
// start a query with retrieved question ID, if any
|
|
193
|
-
this._answer._queryWithQuestionId(data);
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// interactions //
|
|
199
|
-
_defaultProcessInteraction(payload, args) {
|
|
200
|
-
payload = super._defaultProcessInteraction(payload, args);
|
|
201
|
-
payload = (0, _processors.writeAnswerInfoToInteraction)(payload, args);
|
|
202
|
-
return payload;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// destroy //
|
|
206
|
-
_destroy() {
|
|
207
|
-
this._answer.destroy();
|
|
208
|
-
super._destroy();
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
exports.default = HybridSearch;
|
|
212
|
-
(0, _index2.makeConfigurable)(HybridSearch.prototype, [_constants.WORKFLOW_CONFIGURABLE.PAGINATION, _constants.WORKFLOW_CONFIGURABLE.FILTERS]);
|
|
213
|
-
(0, _autocompletable.makeAutocompletable)(HybridSearch.prototype);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Asks", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _asks.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "Explores", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _explores.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "HybridSearch", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _hybridSearch.default;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "Recommendations", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _recommendations.default;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "Search", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _search.default;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
var _asks = _interopRequireDefault(require("./asks.js"));
|
|
37
|
-
var _hybridSearch = _interopRequireDefault(require("./hybrid-search.js"));
|
|
38
|
-
var _search = _interopRequireDefault(require("./search.js"));
|
|
39
|
-
var _recommendations = _interopRequireDefault(require("./recommendations.js"));
|
|
40
|
-
var _explores = _interopRequireDefault(require("./explores.js"));
|
|
41
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mergeApiOptions = mergeApiOptions;
|
|
7
|
-
exports.normalizeApiOptions = normalizeApiOptions;
|
|
8
|
-
var _commons = require("@miso.ai/commons");
|
|
9
|
-
var _utils = require("./utils.js");
|
|
10
|
-
function normalizeApiOptions([name, payload] = []) {
|
|
11
|
-
// TODO: take object form as well
|
|
12
|
-
if (name === false) {
|
|
13
|
-
return {
|
|
14
|
-
actor: false
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (typeof name === 'object' && payload === undefined) {
|
|
18
|
-
payload = name;
|
|
19
|
-
name = undefined;
|
|
20
|
-
}
|
|
21
|
-
let group = undefined;
|
|
22
|
-
if (name && name.indexOf('/') !== -1) {
|
|
23
|
-
[group, name] = name.split('/');
|
|
24
|
-
}
|
|
25
|
-
if (name && typeof name !== 'string' || payload !== undefined && typeof payload !== 'object') {
|
|
26
|
-
throw new Error(`Invalid arguments for useApi(): ${name}, ${payload}`);
|
|
27
|
-
}
|
|
28
|
-
return (0, _commons.trimObj)({
|
|
29
|
-
group,
|
|
30
|
-
name,
|
|
31
|
-
payload
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function mergeApiOptions(...optionsList) {
|
|
35
|
-
if (optionsList[optionsList.length - 1] === false) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return (0, _utils.mergeOptions)(optionsList, (merged, options) => Object.assign(merged, Object.assign({}, options, {
|
|
39
|
-
payload: (0, _commons.mergeApiPayloads)(merged.payload, options.payload)
|
|
40
|
-
})));
|
|
41
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DEFAULT_AUTO_QUERY_SOURCE_PARAM = exports.DEFAULT_AUTO_QUERY_PARAM = void 0;
|
|
7
|
-
exports.autoQuery = autoQuery;
|
|
8
|
-
exports.normalizeAutoQueryOptions = normalizeAutoQueryOptions;
|
|
9
|
-
exports.updateQueryParametersInUrl = updateQueryParametersInUrl;
|
|
10
|
-
var _commons = require("@miso.ai/commons");
|
|
11
|
-
var _constants = require("../../constants.js");
|
|
12
|
-
const _excluded = ["setValue", "focus", "updateUrl", "param", "sourceParam"];
|
|
13
|
-
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; }
|
|
14
|
-
// TODO: eliminate browser dependency?
|
|
15
|
-
|
|
16
|
-
const DEFAULT_AUTO_QUERY_PARAM = exports.DEFAULT_AUTO_QUERY_PARAM = 'q';
|
|
17
|
-
const DEFAULT_AUTO_QUERY_SOURCE_PARAM = exports.DEFAULT_AUTO_QUERY_SOURCE_PARAM = 'qs';
|
|
18
|
-
function normalizeAutoQueryOptions(_ref = {}) {
|
|
19
|
-
let {
|
|
20
|
-
setValue = true,
|
|
21
|
-
focus = true,
|
|
22
|
-
updateUrl = true,
|
|
23
|
-
param = DEFAULT_AUTO_QUERY_PARAM,
|
|
24
|
-
sourceParam = DEFAULT_AUTO_QUERY_SOURCE_PARAM
|
|
25
|
-
} = _ref,
|
|
26
|
-
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
27
|
-
return Object.assign({
|
|
28
|
-
setValue,
|
|
29
|
-
focus,
|
|
30
|
-
updateUrl,
|
|
31
|
-
param,
|
|
32
|
-
sourceParam
|
|
33
|
-
}, options);
|
|
34
|
-
}
|
|
35
|
-
function autoQuery(options = {}) {
|
|
36
|
-
// TODO: support getting value from URL path
|
|
37
|
-
const {
|
|
38
|
-
setValue,
|
|
39
|
-
focus,
|
|
40
|
-
param,
|
|
41
|
-
sourceParam
|
|
42
|
-
} = this._autoQuery = normalizeAutoQueryOptions(options);
|
|
43
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
44
|
-
const q = searchParams.get(param);
|
|
45
|
-
const qs = searchParams.get(sourceParam) || undefined;
|
|
46
|
-
|
|
47
|
-
// because it's probably not there yet, but this is an ad-hoc solution
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
for (const view of this._views.getAll(_constants.ROLE.QUERY)) {
|
|
50
|
-
const {
|
|
51
|
-
layout
|
|
52
|
-
} = view;
|
|
53
|
-
if (q && setValue) {
|
|
54
|
-
layout.value = q;
|
|
55
|
-
}
|
|
56
|
-
if (!q && focus) {
|
|
57
|
-
layout.focus();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
if (q) {
|
|
62
|
-
this.query((0, _commons.trimObj)({
|
|
63
|
-
q,
|
|
64
|
-
qs
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function updateQueryParametersInUrl({
|
|
69
|
-
value,
|
|
70
|
-
request
|
|
71
|
-
}) {
|
|
72
|
-
if (!this._autoQuery || !this._autoQuery.updateUrl) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const {
|
|
76
|
-
param,
|
|
77
|
-
sourceParam
|
|
78
|
-
} = this._autoQuery;
|
|
79
|
-
const query = value && (value.question || value.keyword) || request && request.payload && (request.payload.question || request.payload.q);
|
|
80
|
-
const querySource = request && request.payload && request.payload.metadata && request.payload.metadata.question_source;
|
|
81
|
-
if (!query) {
|
|
82
|
-
return; // at initial phase
|
|
83
|
-
}
|
|
84
|
-
const url = new URL(window.location);
|
|
85
|
-
const currentQuery = url.searchParams.get(param);
|
|
86
|
-
const currentQuerySource = url.searchParams.get(sourceParam) || _constants.QUESTION_SOURCE.ORGANIC;
|
|
87
|
-
if (query === currentQuery && querySource === currentQuerySource) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
url.searchParams.set(param, query);
|
|
91
|
-
if (querySource === _constants.QUESTION_SOURCE.ORGANIC) {
|
|
92
|
-
url.searchParams.delete(sourceParam);
|
|
93
|
-
} else {
|
|
94
|
-
url.searchParams.set(sourceParam, querySource);
|
|
95
|
-
}
|
|
96
|
-
window.history.replaceState({}, '', url);
|
|
97
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.makeConfigurable = makeConfigurable;
|
|
7
|
-
var _constants = require("../../constants.js");
|
|
8
|
-
const DEFAULT_FEATURES = [_constants.WORKFLOW_CONFIGURABLE.API, _constants.WORKFLOW_CONFIGURABLE.LAYOUTS, _constants.WORKFLOW_CONFIGURABLE.DATA_PROCESSOR, _constants.WORKFLOW_CONFIGURABLE.TRACKERS, _constants.WORKFLOW_CONFIGURABLE.INTERACTIONS];
|
|
9
|
-
function makeConfigurable(prototype, features = DEFAULT_FEATURES) {
|
|
10
|
-
for (const feature of features) {
|
|
11
|
-
injectConfigurableFeature(prototype, feature);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function injectConfigurableFeature(prototype, feature) {
|
|
15
|
-
if (feature === 'api') {
|
|
16
|
-
Object.assign(prototype, {
|
|
17
|
-
useApi(...args) {
|
|
18
|
-
this._options.api.merge(args);
|
|
19
|
-
return this;
|
|
20
|
-
},
|
|
21
|
-
clearApi() {
|
|
22
|
-
this._options.api.set();
|
|
23
|
-
return this;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
const upperCased = upperCase(feature);
|
|
28
|
-
Object.assign(prototype, {
|
|
29
|
-
[`use${upperCased}`](value) {
|
|
30
|
-
this._options[feature].merge(value);
|
|
31
|
-
return this;
|
|
32
|
-
},
|
|
33
|
-
[`clear${upperCased}`]() {
|
|
34
|
-
this._options[feature].set();
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// helpers //
|
|
42
|
-
// TODO: move to commons
|
|
43
|
-
function upperCase(str) {
|
|
44
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
45
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mergeDataProcessorOptions = mergeDataProcessorOptions;
|
|
7
|
-
exports.normalizeDataProcessorOptions = normalizeDataProcessorOptions;
|
|
8
|
-
var _commons = require("@miso.ai/commons");
|
|
9
|
-
function normalizeDataProcessorOptions(fns) {
|
|
10
|
-
fns = (0, _commons.asArray)(fns);
|
|
11
|
-
for (const fn of fns) {
|
|
12
|
-
if (typeof fn !== 'function') {
|
|
13
|
-
throw new Error(`Expect data processor options to be a function: ${fn}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return fns;
|
|
17
|
-
}
|
|
18
|
-
function mergeDataProcessorOptions(...optionsList) {
|
|
19
|
-
return optionsList.flat().filter(Boolean);
|
|
20
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mergeFiltersOptions = mergeFiltersOptions;
|
|
7
|
-
exports.normalizeFiltersOptions = void 0;
|
|
8
|
-
var _utils = require("./utils.js");
|
|
9
|
-
const normalizeFiltersOptions = exports.normalizeFiltersOptions = _utils.normalizeOptions;
|
|
10
|
-
function mergeFiltersOptions(...optionsList) {
|
|
11
|
-
if (optionsList[optionsList.length - 1] === false) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return (0, _utils.mergeOptions)(optionsList, (merged, options) => Object.assign(merged, options));
|
|
15
|
-
}
|