@miso.ai/client-sdk-ui 1.11.4-beta.0 → 1.11.4-beta.2
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/fields.js +0 -4
- package/dist/cjs/actor/filters.js +57 -11
- package/dist/cjs/actor/tracker.js +1 -6
- package/dist/cjs/actor/view.js +6 -8
- package/dist/cjs/actor/views.js +10 -26
- package/dist/cjs/constants.js +12 -2
- package/dist/cjs/element/role/index.js +7 -0
- package/dist/cjs/element/role/miso-sort.js +20 -0
- package/dist/cjs/layout/affiliation/affiliation.js +1 -1
- package/dist/cjs/layout/container/container.js +2 -2
- package/dist/cjs/layout/index.js +7 -0
- package/dist/cjs/layout/input/facets.js +2 -2
- package/dist/cjs/layout/input/search-box.js +1 -1
- package/dist/cjs/layout/input/select.js +150 -0
- package/dist/cjs/layout/raf.js +2 -4
- package/dist/cjs/layout/text/typewriter/index.js +3 -2
- package/dist/cjs/layout/trackable.js +3 -3
- package/dist/cjs/layout/triggerable.js +1 -1
- package/dist/cjs/util/trackers.js +2 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/answer-based.js +19 -3
- package/dist/cjs/workflow/ask.js +4 -1
- package/dist/cjs/workflow/base.js +27 -4
- package/dist/cjs/workflow/context.js +3 -3
- package/dist/cjs/workflow/explore.js +2 -2
- package/dist/cjs/workflow/hybrid-search-answer.js +9 -7
- package/dist/cjs/workflow/hybrid-search-results.js +18 -16
- package/dist/cjs/workflow/hybrid-search-views.js +5 -12
- package/dist/cjs/workflow/hybrid-search.js +9 -1
- package/dist/cjs/workflow/options/api.js +56 -0
- package/dist/cjs/workflow/options/configurable.js +49 -0
- package/dist/cjs/workflow/options/data-processor.js +23 -0
- package/dist/cjs/workflow/options/filters.js +18 -0
- package/dist/cjs/workflow/options/index.js +115 -0
- package/dist/cjs/workflow/options/interactions.js +44 -0
- package/dist/cjs/workflow/options/layouts.js +83 -0
- package/dist/cjs/workflow/options/options.js +154 -0
- package/dist/cjs/workflow/options/pagination.js +28 -0
- package/dist/cjs/workflow/options/roles.js +17 -0
- package/dist/cjs/workflow/options/trackers.js +39 -0
- package/dist/cjs/workflow/options/utils.js +33 -0
- package/dist/cjs/workflow/processors.js +39 -33
- package/dist/cjs/workflow/recommendation.js +2 -2
- package/dist/cjs/workflow/search-based.js +59 -22
- package/package.json +2 -2
- package/src/actor/fields.js +0 -4
- package/src/actor/filters.js +53 -12
- package/src/actor/tracker.js +1 -6
- package/src/actor/view.js +7 -8
- package/src/actor/views.js +9 -30
- package/src/constants.js +11 -0
- package/src/element/role/index.js +1 -0
- package/src/element/role/miso-sort.js +16 -0
- package/src/layout/affiliation/affiliation.js +1 -1
- package/src/layout/container/container.js +2 -2
- package/src/layout/index.js +1 -0
- package/src/layout/input/facets.js +3 -2
- package/src/layout/input/search-box.js +1 -1
- package/src/layout/input/select.js +142 -0
- package/src/layout/raf.js +2 -2
- package/src/layout/text/typewriter/index.js +3 -2
- package/src/layout/trackable.js +3 -3
- package/src/layout/triggerable.js +1 -1
- package/src/util/trackers.js +2 -0
- package/src/version.js +1 -1
- package/src/workflow/answer-based.js +16 -2
- package/src/workflow/ask.js +4 -1
- package/src/workflow/base.js +22 -1
- package/src/workflow/context.js +1 -1
- package/src/workflow/explore.js +1 -1
- package/src/workflow/hybrid-search-answer.js +8 -3
- package/src/workflow/hybrid-search-results.js +21 -7
- package/src/workflow/hybrid-search-views.js +4 -12
- package/src/workflow/hybrid-search.js +12 -1
- package/src/workflow/options/api.js +46 -0
- package/src/workflow/options/configurable.js +48 -0
- package/src/workflow/options/data-processor.js +15 -0
- package/src/workflow/options/filters.js +10 -0
- package/src/workflow/options/index.js +10 -0
- package/src/workflow/options/interactions.js +36 -0
- package/src/workflow/options/layouts.js +73 -0
- package/src/workflow/options/options.js +169 -0
- package/src/workflow/options/pagination.js +18 -0
- package/src/workflow/options/roles.js +12 -0
- package/src/workflow/options/trackers.js +32 -0
- package/src/workflow/options/utils.js +26 -0
- package/src/workflow/processors.js +30 -34
- package/src/workflow/recommendation.js +1 -1
- package/src/workflow/search-based.js +58 -13
- package/dist/cjs/workflow/options.js +0 -448
- package/src/workflow/options.js +0 -433
|
@@ -10,7 +10,7 @@ var _index = require("../actor/index.js");
|
|
|
10
10
|
var _constants = require("../constants.js");
|
|
11
11
|
var _index2 = require("../layout/index.js");
|
|
12
12
|
var _index3 = require("../affiliation/index.js");
|
|
13
|
-
var
|
|
13
|
+
var _index4 = require("./options/index.js");
|
|
14
14
|
var _processors = require("./processors.js");
|
|
15
15
|
var _useLink = require("./use-link.js");
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -65,7 +65,7 @@ const DEFAULT_OPTIONS = Object.freeze(Object.assign({}, _base.default.DEFAULT_OP
|
|
|
65
65
|
layouts: DEFAULT_LAYOUTS,
|
|
66
66
|
trackers: DEFAULT_TRACKERS
|
|
67
67
|
}));
|
|
68
|
-
const ROLES_OPTIONS = (0,
|
|
68
|
+
const ROLES_OPTIONS = (0, _index4.mergeRolesOptions)(_base.default.ROLES_OPTIONS, {
|
|
69
69
|
main: _constants.ROLE.ANSWER,
|
|
70
70
|
members: Object.keys(DEFAULT_LAYOUTS)
|
|
71
71
|
});
|
|
@@ -94,6 +94,9 @@ class AnswerBasedWorkflow extends _base.default {
|
|
|
94
94
|
// restart
|
|
95
95
|
super.restart();
|
|
96
96
|
}
|
|
97
|
+
_shallEmitLifecycleEvent(name, event) {
|
|
98
|
+
return name === 'answer-stage' || super._shallEmitLifecycleEvent(name, event);
|
|
99
|
+
}
|
|
97
100
|
_emitInterruptEventIfNecessary() {
|
|
98
101
|
const state = this._hub.states[_index.fields.view(this._roles.main)] || {};
|
|
99
102
|
if (state.session && state.status !== _constants.STATUS.INITIAL && (state.status !== _constants.STATUS.READY || state.ongoing)) {
|
|
@@ -104,13 +107,26 @@ class AnswerBasedWorkflow extends _base.default {
|
|
|
104
107
|
}
|
|
105
108
|
_onMainViewUpdate(state) {
|
|
106
109
|
const {
|
|
107
|
-
status
|
|
110
|
+
status,
|
|
111
|
+
session
|
|
108
112
|
} = state;
|
|
109
113
|
const done = status === _constants.STATUS.READY && !state.ongoing;
|
|
110
114
|
const erroneous = status === _constants.STATUS.ERRONEOUS;
|
|
111
115
|
const eventName = done ? 'done' : erroneous ? 'error' : status;
|
|
116
|
+
// answer-stage
|
|
117
|
+
const context = this._getSessionContext(session);
|
|
118
|
+
const oldAnswerStage = context.answerStage;
|
|
119
|
+
const newAnswerStage = state.meta && state.meta.answer_stage;
|
|
120
|
+
if (newAnswerStage && newAnswerStage !== oldAnswerStage) {
|
|
121
|
+
this._emitLifecycleEvent('answer-stage', Object.freeze(Object.assign({}, state, {
|
|
122
|
+
answer_stage: newAnswerStage
|
|
123
|
+
})));
|
|
124
|
+
context.answerStage = newAnswerStage;
|
|
125
|
+
}
|
|
126
|
+
// ready, done, or error
|
|
112
127
|
this._emitLifecycleEvent(eventName, state);
|
|
113
128
|
if (done || erroneous) {
|
|
129
|
+
// finally
|
|
114
130
|
this._emitLifecycleEvent('finally', state);
|
|
115
131
|
}
|
|
116
132
|
}
|
package/dist/cjs/workflow/ask.js
CHANGED
|
@@ -10,6 +10,7 @@ var _index = require("../actor/index.js");
|
|
|
10
10
|
var _constants = require("../constants.js");
|
|
11
11
|
var _index2 = require("../layout/index.js");
|
|
12
12
|
var _processors = require("./processors.js");
|
|
13
|
+
var _index3 = require("./options/index.js");
|
|
13
14
|
const _excluded = ["q", "qs"];
|
|
14
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
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; }
|
|
@@ -44,7 +45,9 @@ const DEFAULT_OPTIONS = Object.freeze(Object.assign({}, _answerBased.default.DEF
|
|
|
44
45
|
layouts: DEFAULT_LAYOUTS,
|
|
45
46
|
trackers: DEFAULT_TRACKERS
|
|
46
47
|
}));
|
|
47
|
-
const ROLES_OPTIONS = _answerBased.default.ROLES_OPTIONS
|
|
48
|
+
const ROLES_OPTIONS = (0, _index3.mergeRolesOptions)(_answerBased.default.ROLES_OPTIONS, {
|
|
49
|
+
members: Object.keys(DEFAULT_LAYOUTS)
|
|
50
|
+
});
|
|
48
51
|
class Ask extends _answerBased.default {
|
|
49
52
|
constructor(context, parentQuestionId) {
|
|
50
53
|
super({
|
|
@@ -9,7 +9,7 @@ var _index = require("../actor/index.js");
|
|
|
9
9
|
var sources = _interopRequireWildcard(require("../source.js"));
|
|
10
10
|
var _constants = require("../constants.js");
|
|
11
11
|
var _index2 = require("../layout/index.js");
|
|
12
|
-
var
|
|
12
|
+
var _index3 = require("./options/index.js");
|
|
13
13
|
var _processors = require("./processors.js");
|
|
14
14
|
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); }
|
|
15
15
|
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; }
|
|
@@ -72,10 +72,11 @@ class Workflow extends _commons.Component {
|
|
|
72
72
|
this._roles = args.roles;
|
|
73
73
|
this._extensions = plugin._getExtensions(client);
|
|
74
74
|
this._defaults = args.defaults;
|
|
75
|
-
this._options = options || new
|
|
75
|
+
this._options = options || new _index3.WorkflowOptions(context && context._options, args.defaults);
|
|
76
76
|
this._hub = injectLogger(new _index.Hub(), function () {
|
|
77
77
|
return _this._log(...arguments);
|
|
78
78
|
});
|
|
79
|
+
this._sessionContext = new WeakMap();
|
|
79
80
|
this._initProperties(args);
|
|
80
81
|
this._initActors(args);
|
|
81
82
|
this._initSubscriptions(args);
|
|
@@ -121,6 +122,15 @@ class Workflow extends _commons.Component {
|
|
|
121
122
|
_initSession() {
|
|
122
123
|
this.restart();
|
|
123
124
|
}
|
|
125
|
+
_getSessionContext(session) {
|
|
126
|
+
let context = this._sessionContext.get(session);
|
|
127
|
+
if (!context) {
|
|
128
|
+
this._sessionContext.set(session, context = {});
|
|
129
|
+
}
|
|
130
|
+
return context;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// properties //
|
|
124
134
|
get uuid() {
|
|
125
135
|
return this.session && this.session.uuid;
|
|
126
136
|
}
|
|
@@ -173,7 +183,20 @@ class Workflow extends _commons.Component {
|
|
|
173
183
|
this._emitLifecycleEvent('finally', state);
|
|
174
184
|
}
|
|
175
185
|
}
|
|
186
|
+
_shallEmitLifecycleEvent(name, _ref3) {
|
|
187
|
+
let {
|
|
188
|
+
session
|
|
189
|
+
} = _ref3;
|
|
190
|
+
const context = this._getSessionContext(session);
|
|
191
|
+
const events = context.lifecycleEvents || (context.lifecycleEvents = new Set());
|
|
192
|
+
const emitted = events.has(name);
|
|
193
|
+
events.add(name);
|
|
194
|
+
return !emitted;
|
|
195
|
+
}
|
|
176
196
|
_emitLifecycleEvent(name, event) {
|
|
197
|
+
if (!this._shallEmitLifecycleEvent(name, event)) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
177
200
|
this._emit(name, event);
|
|
178
201
|
}
|
|
179
202
|
|
|
@@ -183,7 +206,7 @@ class Workflow extends _commons.Component {
|
|
|
183
206
|
const {
|
|
184
207
|
session
|
|
185
208
|
} = this;
|
|
186
|
-
const event = (0,
|
|
209
|
+
const event = (0, _index3.mergeApiOptions)(this._options.resolved.api, Object.assign({}, options, {
|
|
187
210
|
session
|
|
188
211
|
}));
|
|
189
212
|
this._hub.update(_index.fields.request(), event);
|
|
@@ -338,7 +361,7 @@ class Workflow extends _commons.Component {
|
|
|
338
361
|
}
|
|
339
362
|
}
|
|
340
363
|
exports.default = Workflow;
|
|
341
|
-
(0,
|
|
364
|
+
(0, _index3.makeConfigurable)(Workflow.prototype);
|
|
342
365
|
Object.assign(Workflow, {
|
|
343
366
|
DEFAULT_API_OPTIONS,
|
|
344
367
|
DEFAULT_LAYOUTS,
|
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _commons = require("@miso.ai/commons");
|
|
8
|
-
var
|
|
8
|
+
var _index = require("./options/index.js");
|
|
9
9
|
class WorkflowContext extends _commons.Component {
|
|
10
10
|
constructor(name, plugin, client) {
|
|
11
11
|
super(name, plugin);
|
|
12
12
|
this._plugin = plugin;
|
|
13
13
|
this._client = client;
|
|
14
|
-
this._options = new
|
|
14
|
+
this._options = new _index.WorkflowContextOptions();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.default = WorkflowContext;
|
|
18
|
-
(0,
|
|
18
|
+
(0, _index.makeConfigurable)(WorkflowContext.prototype);
|
|
@@ -9,7 +9,7 @@ var _base = _interopRequireDefault(require("./base.js"));
|
|
|
9
9
|
var _index = require("../actor/index.js");
|
|
10
10
|
var _constants = require("../constants.js");
|
|
11
11
|
var _index2 = require("../layout/index.js");
|
|
12
|
-
var
|
|
12
|
+
var _index3 = require("./options/index.js");
|
|
13
13
|
var _useLink = require("./use-link.js");
|
|
14
14
|
const _excluded = ["value"];
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -41,7 +41,7 @@ const DEFAULT_OPTIONS = Object.freeze(Object.assign({}, _base.default.DEFAULT_OP
|
|
|
41
41
|
layouts: DEFAULT_LAYOUTS,
|
|
42
42
|
trackers: DEFAULT_TRACKERS
|
|
43
43
|
}));
|
|
44
|
-
const ROLES_OPTIONS = (0,
|
|
44
|
+
const ROLES_OPTIONS = (0, _index3.mergeRolesOptions)(_base.default.ROLES_OPTIONS, {
|
|
45
45
|
main: _constants.ROLE.RELATED_QUESTIONS,
|
|
46
46
|
members: Object.keys(DEFAULT_LAYOUTS)
|
|
47
47
|
});
|
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _answerBased = _interopRequireDefault(require("./answer-based.js"));
|
|
8
8
|
var _constants = require("../constants.js");
|
|
9
|
-
var
|
|
9
|
+
var _index = require("./options/index.js");
|
|
10
10
|
var _processors = require("./processors.js");
|
|
11
11
|
var _autocompletable = require("./autocompletable.js");
|
|
12
|
-
const _excluded = ["
|
|
12
|
+
const _excluded = ["qs"];
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
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; }
|
|
15
|
-
const ROLES_OPTIONS = (0,
|
|
15
|
+
const ROLES_OPTIONS = (0, _index.mergeRolesOptions)(_answerBased.default.ROLES_OPTIONS, {
|
|
16
16
|
mappings: {
|
|
17
17
|
[_constants.ROLE.QUESTION]: _constants.ROLE.KEYWORDS
|
|
18
18
|
}
|
|
@@ -46,16 +46,18 @@ class HybridSearchAnswer extends _answerBased.default {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// query //
|
|
49
|
-
_buildPayload() {
|
|
49
|
+
_buildPayload(payload) {
|
|
50
|
+
payload = this._writeQuestionSourceToPayload(payload);
|
|
51
|
+
payload = this._superworkflow._results._writeFiltersToPayload(payload);
|
|
52
|
+
return payload;
|
|
53
|
+
}
|
|
54
|
+
_writeQuestionSourceToPayload() {
|
|
50
55
|
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
51
56
|
let {
|
|
52
|
-
q,
|
|
53
57
|
qs
|
|
54
58
|
} = _ref,
|
|
55
59
|
payload = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
56
60
|
return Object.assign({}, payload, {
|
|
57
|
-
q,
|
|
58
|
-
// q, not question
|
|
59
61
|
_meta: Object.assign({}, payload._meta, {
|
|
60
62
|
question_source: qs || _constants.ORGANIC_QUESTION_SOURCE // might be null, not undefined
|
|
61
63
|
})
|
|
@@ -8,12 +8,10 @@ var _commons = require("@miso.ai/commons");
|
|
|
8
8
|
var _searchBased = _interopRequireDefault(require("./search-based.js"));
|
|
9
9
|
var _index = require("../actor/index.js");
|
|
10
10
|
var _constants = require("../constants.js");
|
|
11
|
-
var _options = require("./options.js");
|
|
12
|
-
const _excluded = ["filters"];
|
|
13
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
|
|
15
|
-
const ROLES_OPTIONS = (
|
|
16
|
-
members: [_constants.ROLE.PRODUCTS, _constants.ROLE.KEYWORDS, _constants.ROLE.TOTAL, _constants.ROLE.FACETS, _constants.ROLE.MORE]
|
|
12
|
+
// we want to override members, not adding to it
|
|
13
|
+
const ROLES_OPTIONS = Object.assign({}, _searchBased.default.ROLES_OPTIONS, {
|
|
14
|
+
members: [_constants.ROLE.PRODUCTS, _constants.ROLE.KEYWORDS, _constants.ROLE.TOTAL, _constants.ROLE.FACETS, _constants.ROLE.SORT, _constants.ROLE.MORE, _constants.ROLE.ERROR]
|
|
17
15
|
});
|
|
18
16
|
class HybridSearchResults extends _searchBased.default {
|
|
19
17
|
constructor(superworkflow) {
|
|
@@ -44,22 +42,23 @@ class HybridSearchResults extends _searchBased.default {
|
|
|
44
42
|
// get stored query from sibling
|
|
45
43
|
return this._superworkflow._answer._hub.states[_index.fields.query()];
|
|
46
44
|
}
|
|
47
|
-
_buildPayload() {
|
|
48
|
-
let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
49
|
-
let {
|
|
50
|
-
filters
|
|
51
|
-
} = _ref,
|
|
52
|
-
payload = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
45
|
+
_buildPayload(payload) {
|
|
53
46
|
// borrow the work from the sibling
|
|
54
|
-
payload = this._superworkflow._answer.
|
|
55
|
-
payload =
|
|
56
|
-
|
|
57
|
-
}, payload));
|
|
47
|
+
payload = this._superworkflow._answer._writeQuestionSourceToPayload(payload);
|
|
48
|
+
payload = this._writeFiltersToPayload(payload);
|
|
49
|
+
payload = this._writePageInfoToPayload(payload);
|
|
58
50
|
payload = this._writeQuestionIdToPayload(payload);
|
|
59
51
|
return Object.assign({}, payload, {
|
|
60
52
|
answer: false
|
|
61
53
|
});
|
|
62
54
|
}
|
|
55
|
+
_buildOrderBy(sort) {
|
|
56
|
+
if (!sort) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
// works differently than search
|
|
60
|
+
return sort.field;
|
|
61
|
+
}
|
|
63
62
|
_writeQuestionIdToPayload(payload) {
|
|
64
63
|
return Object.assign({}, payload, {
|
|
65
64
|
_meta: (0, _commons.trimObj)(Object.assign({}, payload._meta, {
|
|
@@ -68,4 +67,7 @@ class HybridSearchResults extends _searchBased.default {
|
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
|
-
exports.default = HybridSearchResults;
|
|
70
|
+
exports.default = HybridSearchResults;
|
|
71
|
+
Object.assign(HybridSearchResults, {
|
|
72
|
+
ROLES_OPTIONS
|
|
73
|
+
});
|
|
@@ -5,18 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _constants = require("../constants.js");
|
|
8
|
+
var _hybridSearchResults = _interopRequireDefault(require("./hybrid-search-results.js"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
10
|
function getSubworkflowByRole(role) {
|
|
9
11
|
// TODO: ROLE.ERROR
|
|
10
|
-
|
|
11
|
-
case _constants.ROLE.PRODUCTS:
|
|
12
|
-
case _constants.ROLE.TOTAL:
|
|
13
|
-
case _constants.ROLE.FACETS:
|
|
14
|
-
case _constants.ROLE.KEYWORDS:
|
|
15
|
-
case _constants.ROLE.MORE:
|
|
16
|
-
return 'results';
|
|
17
|
-
default:
|
|
18
|
-
return 'answer';
|
|
19
|
-
}
|
|
12
|
+
return _hybridSearchResults.default.ROLES_OPTIONS.members.includes(role) ? 'results' : 'answer';
|
|
20
13
|
}
|
|
21
14
|
class HybridSearchViewsActor {
|
|
22
15
|
constructor(workflow) {
|
|
@@ -101,10 +94,10 @@ class HybridSearchViewsActor {
|
|
|
101
94
|
// find the conflicting element
|
|
102
95
|
for (const component of container.components) {
|
|
103
96
|
if (otherSubviews.containsElement(component)) {
|
|
104
|
-
throw new Error(`<${container.tagName}> cannot contain both <${component.tagName}> and <${child.tagName}>, for they don't share the same data lifecycle.`);
|
|
97
|
+
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.`);
|
|
105
98
|
}
|
|
106
99
|
}
|
|
107
|
-
throw new Error(`Failed to add container <${container.tagName}> with child component <${child.tagName}>.`);
|
|
100
|
+
throw new Error(`Failed to add container <${container.tagName.toLowerCase()}> with child component <${child.tagName.toLowerCase()}>.`);
|
|
108
101
|
}
|
|
109
102
|
}
|
|
110
103
|
// add the container to the subviews
|
|
@@ -14,6 +14,7 @@ var _index2 = require("../layout/index.js");
|
|
|
14
14
|
var _hybridSearchAnswer = _interopRequireDefault(require("./hybrid-search-answer.js"));
|
|
15
15
|
var _hybridSearchResults = _interopRequireDefault(require("./hybrid-search-results.js"));
|
|
16
16
|
var _hybridSearchViews = _interopRequireDefault(require("./hybrid-search-views.js"));
|
|
17
|
+
var _index3 = require("./options/index.js");
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
const DEFAULT_API_OPTIONS = Object.freeze({
|
|
19
20
|
group: _commons.API.GROUP.ASK,
|
|
@@ -101,6 +102,12 @@ class HybridSearch extends _base.default {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
// properties //
|
|
105
|
+
get answer() {
|
|
106
|
+
return this._answer;
|
|
107
|
+
}
|
|
108
|
+
get results() {
|
|
109
|
+
return this._results;
|
|
110
|
+
}
|
|
104
111
|
get questionId() {
|
|
105
112
|
return this._answer.questionId;
|
|
106
113
|
}
|
|
@@ -132,4 +139,5 @@ class HybridSearch extends _base.default {
|
|
|
132
139
|
super._destroy();
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
|
-
exports.default = HybridSearch;
|
|
142
|
+
exports.default = HybridSearch;
|
|
143
|
+
(0, _index3.makeConfigurable)(HybridSearch.prototype, [_constants.WORKFLOW_CONFIGURABLE.PAGINATION, _constants.WORKFLOW_CONFIGURABLE.FILTERS]);
|
|
@@ -0,0 +1,56 @@
|
|
|
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() {
|
|
11
|
+
let [name, payload] = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
12
|
+
// TODO: take object form as well
|
|
13
|
+
if (name === false) {
|
|
14
|
+
return {
|
|
15
|
+
actor: false
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (typeof name === 'object' && payload === undefined) {
|
|
19
|
+
payload = name;
|
|
20
|
+
name = undefined;
|
|
21
|
+
}
|
|
22
|
+
let group = undefined;
|
|
23
|
+
if (name && name.indexOf('/') !== -1) {
|
|
24
|
+
[group, name] = name.split('/');
|
|
25
|
+
}
|
|
26
|
+
if (name && typeof name !== 'string' || payload !== undefined && typeof payload !== 'object') {
|
|
27
|
+
throw new Error(`Invalid arguments for useApi(): ${name}, ${payload}`);
|
|
28
|
+
}
|
|
29
|
+
return (0, _commons.trimObj)({
|
|
30
|
+
group,
|
|
31
|
+
name,
|
|
32
|
+
payload
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function mergeApiOptions() {
|
|
36
|
+
for (var _len = arguments.length, optionsList = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
37
|
+
optionsList[_key] = arguments[_key];
|
|
38
|
+
}
|
|
39
|
+
if (optionsList[optionsList.length - 1] === false) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return (0, _utils.mergeOptions)(optionsList, (merged, options) => Object.assign(merged, Object.assign({}, options, {
|
|
43
|
+
payload: mergeApiPayloads(merged.payload, options.payload)
|
|
44
|
+
})));
|
|
45
|
+
}
|
|
46
|
+
function mergeApiPayloads(base, overrides) {
|
|
47
|
+
return Object.assign({}, base, overrides, mergeObjectValueIfPresent('_meta', base, overrides));
|
|
48
|
+
}
|
|
49
|
+
function mergeObjectValueIfPresent(key, base, overrides) {
|
|
50
|
+
const baseValue = base && base[key];
|
|
51
|
+
const overridesValue = overrides && overrides[key];
|
|
52
|
+
const value = baseValue ? overridesValue ? Object.assign({}, baseValue, overridesValue) : baseValue : overridesValue;
|
|
53
|
+
return value !== undefined ? {
|
|
54
|
+
[key]: value
|
|
55
|
+
} : {};
|
|
56
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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) {
|
|
10
|
+
let features = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FEATURES;
|
|
11
|
+
for (const feature of features) {
|
|
12
|
+
injectConfigurableFeature(prototype, feature);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function injectConfigurableFeature(prototype, feature) {
|
|
16
|
+
if (feature === 'api') {
|
|
17
|
+
Object.assign(prototype, {
|
|
18
|
+
useApi() {
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
this._options.api.merge(args);
|
|
23
|
+
return this;
|
|
24
|
+
},
|
|
25
|
+
clearApi() {
|
|
26
|
+
this._options.api.set();
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
const upperCased = upperCase(feature);
|
|
32
|
+
Object.assign(prototype, {
|
|
33
|
+
[`use${upperCased}`](value) {
|
|
34
|
+
this._options[feature].merge(value);
|
|
35
|
+
return this;
|
|
36
|
+
},
|
|
37
|
+
[`clear${upperCased}`]() {
|
|
38
|
+
this._options[feature].set();
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// helpers //
|
|
46
|
+
// TODO: move to commons
|
|
47
|
+
function upperCase(str) {
|
|
48
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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() {
|
|
19
|
+
for (var _len = arguments.length, optionsList = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
optionsList[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
return optionsList.flat().filter(Boolean);
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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() {
|
|
11
|
+
for (var _len = arguments.length, optionsList = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
|
+
optionsList[_key] = arguments[_key];
|
|
13
|
+
}
|
|
14
|
+
if (optionsList[optionsList.length - 1] === false) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return (0, _utils.mergeOptions)(optionsList, (merged, options) => Object.assign(merged, options));
|
|
18
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _roles = require("./roles.js");
|
|
7
|
+
Object.keys(_roles).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _roles[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _roles[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _api = require("./api.js");
|
|
18
|
+
Object.keys(_api).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _api[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _api[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _layouts = require("./layouts.js");
|
|
29
|
+
Object.keys(_layouts).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _layouts[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _layouts[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _dataProcessor = require("./data-processor.js");
|
|
40
|
+
Object.keys(_dataProcessor).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _dataProcessor[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _dataProcessor[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _trackers = require("./trackers.js");
|
|
51
|
+
Object.keys(_trackers).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _trackers[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _trackers[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _interactions = require("./interactions.js");
|
|
62
|
+
Object.keys(_interactions).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _interactions[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _interactions[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _filters = require("./filters.js");
|
|
73
|
+
Object.keys(_filters).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _filters[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _filters[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _pagination = require("./pagination.js");
|
|
84
|
+
Object.keys(_pagination).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _pagination[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _pagination[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _options = require("./options.js");
|
|
95
|
+
Object.keys(_options).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _options[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _options[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _configurable = require("./configurable.js");
|
|
106
|
+
Object.keys(_configurable).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _configurable[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _configurable[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mergeInteractionsOptions = mergeInteractionsOptions;
|
|
7
|
+
exports.normalizeInteractionsOptions = normalizeInteractionsOptions;
|
|
8
|
+
var _commons = require("@miso.ai/commons");
|
|
9
|
+
var _utils = require("./utils.js");
|
|
10
|
+
function normalizeInteractionsOptions(options) {
|
|
11
|
+
if (options === undefined) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
if (options === false) {
|
|
15
|
+
return {
|
|
16
|
+
handle: () => {}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// preprocess
|
|
20
|
+
const preprocess = (0, _commons.asArray)(options.preprocess);
|
|
21
|
+
for (const p of preprocess) {
|
|
22
|
+
if (typeof p !== 'function') {
|
|
23
|
+
throw new Error(`Expect preprocess options to be a function: ${p}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// handle
|
|
27
|
+
if (options.handle && typeof options.handle !== 'function') {
|
|
28
|
+
throw new Error(`Expect handle options to be a function: ${options.handle}`);
|
|
29
|
+
}
|
|
30
|
+
return Object.assign({}, options, {
|
|
31
|
+
preprocess
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function mergeInteractionsOptions() {
|
|
35
|
+
for (var _len = arguments.length, optionsList = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
+
optionsList[_key] = arguments[_key];
|
|
37
|
+
}
|
|
38
|
+
if (optionsList[optionsList.length - 1] === false) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return (0, _utils.mergeOptions)(optionsList, (merged, options) => Object.assign(merged, Object.assign({}, options, {
|
|
42
|
+
preprocess: concatArrays(merged.preprocess, options.preprocess)
|
|
43
|
+
})));
|
|
44
|
+
}
|