@miso.ai/client-sdk-ui 1.12.3-beta.6 → 1.12.4-beta.0

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.
Files changed (37) hide show
  1. package/dist/cjs/actor/data.js +15 -11
  2. package/dist/cjs/defaults/ask/controls.js +3 -6
  3. package/dist/cjs/defaults/ask/templates.js +1 -0
  4. package/dist/cjs/defaults/common/templates.js +4 -2
  5. package/dist/cjs/element/container/miso-ask.js +48 -6
  6. package/dist/cjs/element/container/miso-container.js +2 -0
  7. package/dist/cjs/version.js +1 -1
  8. package/dist/cjs/workflow/answer-based.js +2 -88
  9. package/dist/cjs/workflow/ask.js +13 -9
  10. package/dist/cjs/workflow/asks.js +36 -1
  11. package/dist/cjs/workflow/base.js +14 -9
  12. package/dist/cjs/workflow/hybrid-search-answer.js +40 -68
  13. package/dist/cjs/workflow/hybrid-search-views.js +12 -11
  14. package/dist/cjs/workflow/hybrid-search.js +99 -46
  15. package/dist/cjs/workflow/options/auto-query.js +31 -0
  16. package/dist/cjs/workflow/processors.js +107 -0
  17. package/dist/cjs/workflow/search-based.js +16 -30
  18. package/package.json +2 -2
  19. package/src/actor/data.js +10 -7
  20. package/src/defaults/ask/controls.js +3 -6
  21. package/src/defaults/ask/templates.js +1 -1
  22. package/src/defaults/common/templates.js +2 -2
  23. package/src/element/container/miso-ask.js +53 -5
  24. package/src/element/container/miso-container.js +3 -0
  25. package/src/version.js +1 -1
  26. package/src/workflow/answer-based.js +4 -83
  27. package/src/workflow/ask.js +11 -10
  28. package/src/workflow/asks.js +39 -2
  29. package/src/workflow/base.js +13 -9
  30. package/src/workflow/hybrid-search-answer.js +25 -62
  31. package/src/workflow/hybrid-search-views.js +14 -12
  32. package/src/workflow/hybrid-search.js +93 -47
  33. package/src/workflow/options/auto-query.js +36 -2
  34. package/src/workflow/processors.js +86 -2
  35. package/src/workflow/search-based.js +14 -27
  36. package/dist/cjs/workflow/hybrid-search-results.js +0 -87
  37. package/src/workflow/hybrid-search-results.js +0 -91
@@ -12,11 +12,13 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
12
12
  class DataActor {
13
13
  constructor(hub, {
14
14
  source,
15
- options
15
+ options,
16
+ polling = true
16
17
  }) {
17
18
  this._hub = hub;
18
19
  this._source = source;
19
20
  this._options = options;
21
+ this._polling = polling;
20
22
  this._unsubscribes = [hub.on(fields.session(), session => this._handleSession(session)), hub.on(fields.request(), event => this._handleRequest(event))];
21
23
  }
22
24
  get active() {
@@ -74,17 +76,19 @@ class DataActor {
74
76
  value: response._response
75
77
  });
76
78
  }
77
- let value;
78
- for await (value of response) {
79
- // A new session invalidates ongoing data fetch for the old session, terminating the loop
80
- if (!(0, _utils.isCurrentSession)(this._hub, session)) {
81
- break;
79
+ if (this._polling) {
80
+ let value;
81
+ for await (value of response) {
82
+ // A new session invalidates ongoing data fetch for the old session, terminating the loop
83
+ if (!(0, _utils.isCurrentSession)(this._hub, session)) {
84
+ break;
85
+ }
86
+ this._emitResponse({
87
+ session,
88
+ request,
89
+ value
90
+ });
82
91
  }
83
- this._emitResponse({
84
- session,
85
- request,
86
- value
87
- });
88
92
  }
89
93
  } else {
90
94
  this._emitResponseWithSessionCheck({
@@ -53,10 +53,7 @@ function wireRelatedResources(client, element) {
53
53
  if (!element) {
54
54
  return;
55
55
  }
56
- client.ui.asks.on('loading', event => {
57
- // When a new query starts, associate the last section container (for related resources) to that workflow
58
- for (const container of element.querySelectorAll('miso-ask')) {
59
- container.workflow = event.workflow;
60
- }
61
- });
56
+ for (const container of element.querySelectorAll('miso-ask')) {
57
+ container.setAttribute('workflow', 'active');
58
+ }
62
59
  }
@@ -125,6 +125,7 @@ class Sections extends _templates.Sections {
125
125
  const body = features.relatedResources === false ? '' : container(options, {
126
126
  name: 'related-resources',
127
127
  visibleWhen: 'nonempty',
128
+ workflow: 'active',
128
129
  logo
129
130
  }, [phrase(options, {
130
131
  name: 'related-resources',
@@ -164,7 +164,8 @@ class Helpers {
164
164
  container({
165
165
  classPrefix,
166
166
  circledCitationIndex,
167
- parentQuestionId
167
+ parentQuestionId,
168
+ workflow
168
169
  }, {
169
170
  name,
170
171
  extraNames = [],
@@ -179,7 +180,8 @@ class Helpers {
179
180
  visibleWhen,
180
181
  trait,
181
182
  logo,
182
- parentQuestionId
183
+ parentQuestionId,
184
+ workflow
183
185
  }, body);
184
186
  }
185
187
  element(tag, attributes = {}, body = '') {
@@ -7,8 +7,9 @@ exports.default = void 0;
7
7
  var _misoContainer = _interopRequireDefault(require("./miso-container.js"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
9
  const TAG_NAME = 'miso-ask';
10
+ const ATTR_WORKFLOW = 'workflow';
10
11
  const ATTR_PARENT_QUESTION_ID = 'parent-question-id';
11
- const OBSERVED_ATTRIBUTES = Object.freeze([..._misoContainer.default.observedAttributes, ATTR_PARENT_QUESTION_ID]);
12
+ const OBSERVED_ATTRIBUTES = Object.freeze([..._misoContainer.default.observedAttributes, ATTR_WORKFLOW, ATTR_PARENT_QUESTION_ID]);
12
13
  class MisoAskElement extends _misoContainer.default {
13
14
  static get tagName() {
14
15
  return TAG_NAME;
@@ -17,6 +18,9 @@ class MisoAskElement extends _misoContainer.default {
17
18
  return OBSERVED_ATTRIBUTES;
18
19
  }
19
20
  _getWorkflow(client) {
21
+ if (this.boundToActiveWorkflow) {
22
+ return client.ui.asks.active;
23
+ }
20
24
  return this._getWorkflowByParentQuestionId(client, this.parentQuestionId);
21
25
  }
22
26
  _getWorkflowByParentQuestionId(client, id) {
@@ -40,24 +44,62 @@ class MisoAskElement extends _misoContainer.default {
40
44
  this.removeAttribute(ATTR_PARENT_QUESTION_ID);
41
45
  }
42
46
  }
43
- get workflow() {
44
- return this._workflow;
47
+ get boundToActiveWorkflow() {
48
+ return this.getAttribute(ATTR_WORKFLOW) === 'active';
45
49
  }
46
- set workflow(workflow) {
47
- this._setWorkflow(workflow);
48
- this.parentQuestionId = workflow && workflow.parentQuestionId;
50
+ _setWorkflow(workflow) {
51
+ if (this._workflow === workflow) {
52
+ return;
53
+ }
54
+ super._setWorkflow(workflow);
55
+ if (workflow) {
56
+ this.parentQuestionId = workflow.parentQuestionId;
57
+ }
49
58
  }
50
59
 
51
60
  // lifecycle //
61
+ async connectedCallback() {
62
+ await super.connectedCallback();
63
+ if (document.body.contains(this)) {
64
+ // in case already disconnected
65
+ const context = this._client.ui.asks;
66
+ this._unsubscribes = [...(this._unsubscribes || []), context.on('active', event => {
67
+ if (!this.boundToActiveWorkflow) {
68
+ return;
69
+ }
70
+ this.workflow = event.workflow;
71
+ })];
72
+ }
73
+ }
74
+ disconnectedCallback() {
75
+ for (const unsubscribe of this._unsubscribes || []) {
76
+ unsubscribe();
77
+ }
78
+ this._unsubscribes = [];
79
+ super.disconnectedCallback();
80
+ }
52
81
  attributeChangedCallback(attr, oldValue, newValue) {
53
82
  switch (attr) {
54
83
  case ATTR_PARENT_QUESTION_ID:
55
84
  this._handleParentQuestionIdUpdate(oldValue, newValue);
56
85
  break;
86
+ case ATTR_WORKFLOW:
87
+ this._handleQuestionUpdate(oldValue, newValue);
88
+ break;
57
89
  default:
58
90
  super.attributeChangedCallback(attr, oldValue, newValue);
59
91
  }
60
92
  }
93
+ _handleQuestionUpdate(oldValue, newValue) {
94
+ oldValue = oldValue || undefined; // null -> undefined
95
+ newValue = newValue || undefined;
96
+ if (oldValue === newValue || !this._client) {
97
+ return;
98
+ }
99
+ if (newValue === ATTR_VALUE_ACTIVE) {
100
+ this._setWorkflow(this._getWorkflow(this._client));
101
+ }
102
+ }
61
103
  _handleParentQuestionIdUpdate(oldId, newId) {
62
104
  oldId = oldId || undefined; // null -> undefined
63
105
  newId = newId || undefined;
@@ -77,12 +77,14 @@ class MisoContainerElement extends _misoStub.default {
77
77
  if (document.body.contains(this)) {
78
78
  // in case already disconnected
79
79
  this._setWorkflow(this._getWorkflow(client));
80
+ this._onConnected(client);
80
81
  }
81
82
  }
82
83
  disconnectedCallback() {
83
84
  this._setWorkflow(undefined);
84
85
  super.disconnectedCallback();
85
86
  }
87
+ _onConnected(client) {}
86
88
  _getWorkflow(client) {
87
89
  throw new Error('Unimplemented');
88
90
  }
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '1.12.3-beta.6';
7
+ var _default = exports.default = '1.12.4-beta.0';
@@ -210,7 +210,7 @@ class AnswerBasedWorkflow extends _base.default {
210
210
  super._updateData(data);
211
211
 
212
212
  // update URL if autoQuery.updateUrl is not false
213
- this._updateUrlIfNecessary(data);
213
+ _index4.updateQueryParametersInUrl.call(this, data);
214
214
  }
215
215
  _handleHeadResponse(data) {}
216
216
  _defaultProcessData(data, oldData) {
@@ -224,99 +224,13 @@ class AnswerBasedWorkflow extends _base.default {
224
224
  }) {
225
225
  value && this._writeQuestionId(value.question_id);
226
226
  }
227
- _updateUrlIfNecessary({
228
- value,
229
- request
230
- }) {
231
- if (!this._autoQuery || !this._autoQuery.updateUrl) {
232
- return;
233
- }
234
- const {
235
- param,
236
- sourceParam
237
- } = this._autoQuery;
238
- const question = value && value.question || request && request.payload && request.payload.question;
239
- const questionSource = request && request.payload && request.payload.metadata && request.payload.metadata.question_source;
240
- if (!question) {
241
- return; // at initial phase
242
- }
243
- const url = new URL(window.location);
244
- const currentQuestion = url.searchParams.get(param);
245
- const currentQuestionSource = url.searchParams.get(sourceParam) || _constants.QUESTION_SOURCE.ORGANIC;
246
- if (question === currentQuestion && questionSource === currentQuestionSource) {
247
- return;
248
- }
249
- url.searchParams.set(param, question);
250
- if (questionSource === _constants.QUESTION_SOURCE.ORGANIC) {
251
- url.searchParams.delete(sourceParam);
252
- } else {
253
- url.searchParams.set(sourceParam, questionSource);
254
- }
255
- window.history.replaceState({}, '', url);
256
- }
257
227
 
258
228
  // interactions //
259
229
  _defaultProcessInteraction(payload, args) {
260
230
  payload = super._defaultProcessInteraction(payload, args);
261
- payload = this._writeAskPropertiesToInteraction(payload, args);
262
- payload = this._writeAnswerClickInteraction(payload, args);
263
- payload = (0, _processors.writeEventTargetToInteraction)(payload, args);
231
+ payload = (0, _processors.writeAnswerInfoToInteraction)(payload, args);
264
232
  return payload;
265
233
  }
266
- _writeRequestInfoToInteraction(payload, args) {
267
- const {
268
- data
269
- } = args;
270
- if (!data) {
271
- return payload;
272
- }
273
- const requestPayload = data.request && data.request.payload;
274
- if (!requestPayload) {
275
- return payload;
276
- }
277
- const {
278
- question,
279
- fq
280
- } = requestPayload;
281
- return (0, _commons.mergeInteractions)(payload, {
282
- context: {
283
- custom_context: {
284
- question,
285
- fq
286
- }
287
- }
288
- });
289
- }
290
- _writeAskPropertiesToInteraction(payload = {}, args) {
291
- const question_source = this._getQuestionSourceFromViewState(args);
292
- const question_id = this.questionId;
293
- return (0, _commons.mergeInteractions)(payload, {
294
- context: {
295
- custom_context: {
296
- question_source,
297
- question_id
298
- }
299
- }
300
- });
301
- }
302
- _writeAnswerClickInteraction(payload, args) {
303
- if (args.role !== _constants.ROLE.ANSWER) {
304
- return payload;
305
- }
306
- const {
307
- items = []
308
- } = args;
309
- return (0, _commons.mergeInteractions)(payload, {
310
- context: {
311
- custom_context: {
312
- urls: items.map(item => item.url),
313
- texts: items.map(item => item.text),
314
- class_names: items.map(item => item.className),
315
- attributes: items.map(item => item.attributes)
316
- }
317
- }
318
- });
319
- }
320
234
  _getQuestionSourceFromViewState(args) {
321
235
  const {
322
236
  request
@@ -146,10 +146,10 @@ class Ask extends _answerBased.default {
146
146
  let payload = (0, _commons.trimObj)(Object.assign({}, options, {
147
147
  question: q,
148
148
  // question, not q
149
- parent_question_id: parentQuestionId,
150
- metadata: Object.assign({}, options.metadata, {
151
- question_source: qs || _constants.QUESTION_SOURCE.ORGANIC // might be null, not undefined
152
- })
149
+ parent_question_id: parentQuestionId
150
+ }));
151
+ payload = (0, _processors.writeQuestionSourceToPayload)(Object.assign({}, payload, {
152
+ qs
153
153
  }));
154
154
  payload = this._writeWikiLinkTemplateToPayload(payload);
155
155
  return payload;
@@ -184,7 +184,12 @@ class Ask extends _answerBased.default {
184
184
  }
185
185
 
186
186
  // interactions //
187
- _writeAskPropertiesToInteraction(payload, args) {
187
+ _defaultProcessInteraction(payload, args) {
188
+ payload = super._defaultProcessInteraction(payload, args);
189
+ payload = this._writeAdditionalAskPropertiesToInteraction(payload, args);
190
+ return payload;
191
+ }
192
+ _writeAdditionalAskPropertiesToInteraction(payload, args) {
188
193
  const root_question_id = this.rootQuestionId;
189
194
  let {
190
195
  property
@@ -199,18 +204,17 @@ class Ask extends _answerBased.default {
199
204
  question_source = this.previous && this.previous.session.meta.question_source;
200
205
  } else {
201
206
  parent_question_id = this.parentQuestionId;
202
- question_id = this.questionId;
203
- question_source = this._getQuestionSourceFromViewState(args);
204
207
  }
205
208
  return (0, _commons.mergeInteractions)(payload, {
206
209
  context: {
207
- custom_context: {
210
+ custom_context: (0, _commons.trimObj)({
211
+ // question_id, question_source can be undefined
208
212
  property,
209
213
  root_question_id,
210
214
  parent_question_id,
211
215
  question_id,
212
216
  question_source
213
- }
217
+ })
214
218
  }
215
219
  });
216
220
  }
@@ -26,7 +26,7 @@ function autoNextOptionsAsPredicate(options = DEFAULT_AUTO_NEXT_OPTIONS) {
26
26
  switch (typeof options) {
27
27
  case 'object':
28
28
  // TODO: support more options
29
- return event => options.event === event._event;
29
+ return event => event && options.event === event._event;
30
30
  case 'function':
31
31
  return options;
32
32
  default:
@@ -40,7 +40,11 @@ class Asks extends _context.default {
40
40
  this._byPqid = new Map();
41
41
  this._root = new _ask.default(this); // initialize with default workflow
42
42
  this._events.on('*', event => this._createNextIfNecessary(event));
43
+ this._events.on('loading', event => this._setActive(event.workflow));
44
+ this._events.on('destroy', () => this._requestEmitAfterDestroy());
45
+ this._events.on('after-destroy', () => this._syncActiveOnAfterDestroy());
43
46
  this._autoNextFn = undefined;
47
+ this._active = this._root;
44
48
  }
45
49
  get root() {
46
50
  return this._root;
@@ -48,6 +52,9 @@ class Asks extends _context.default {
48
52
  get workflows() {
49
53
  return [this._root, ...this._byPqid.values()];
50
54
  }
55
+ get active() {
56
+ return this._active;
57
+ }
51
58
  getByQuestionId(questionId) {
52
59
  if (typeof questionId !== 'string') {
53
60
  throw new Error(`Required ID to be a string: ${questionId}`);
@@ -105,6 +112,34 @@ class Asks extends _context.default {
105
112
  } = event;
106
113
  workflow && workflow.getOrCreateNext();
107
114
  }
115
+ _requestEmitAfterDestroy() {
116
+ if (this._emitAfterDestroyRequested) {
117
+ return;
118
+ }
119
+ this._emitAfterDestroyRequested = true;
120
+ setTimeout(() => {
121
+ this._emitAfterDestroyRequested = false;
122
+ this._events.emit('after-destroy', {});
123
+ }, 0);
124
+ }
125
+ _syncActiveOnAfterDestroy() {
126
+ if (!this._active.destroyed) {
127
+ return;
128
+ }
129
+ // find last non-initial workflow or root
130
+ let workflow = this._root;
131
+ for (; workflow.next && workflow.next.status !== _constants.STATUS.INITIAL; workflow = workflow.next) {}
132
+ this._setActive(workflow);
133
+ }
134
+ _setActive(workflow) {
135
+ if (workflow === this._active) {
136
+ return;
137
+ }
138
+ this._active = workflow;
139
+ this._events.emit('active', {
140
+ workflow
141
+ });
142
+ }
108
143
  }
109
144
  exports.default = Asks;
110
145
  (0, _index.makeConfigurable)(Asks.prototype, [_constants.WORKFLOW_CONFIGURABLE.TEMPLATES]);
@@ -36,7 +36,8 @@ class Workflow extends _commons.Component {
36
36
  plugin,
37
37
  client,
38
38
  defaults,
39
- options
39
+ options,
40
+ extraOptions
40
41
  } = args;
41
42
  this._context = context;
42
43
  this._plugin = plugin = plugin || context._plugin;
@@ -50,6 +51,7 @@ class Workflow extends _commons.Component {
50
51
  this._extensions = plugin._getExtensions(client);
51
52
  this._defaults = defaults;
52
53
  this._options = options || new _index3.WorkflowOptions(context && context._options, defaults);
54
+ this._extraOptions = extraOptions || {};
53
55
  this._hub = new _index.Hub({
54
56
  onUpdate: event => this._onHubUpdate(event),
55
57
  onEmit: event => this._onHubEmit(event)
@@ -71,10 +73,10 @@ class Workflow extends _commons.Component {
71
73
  const extensions = this._extensions;
72
74
  const layouts = this._plugin.layouts;
73
75
  this._sessions = new _index.SessionMaker(hub);
74
- this._data = new _index.DataActor(hub, {
76
+ this._data = new _index.DataActor(hub, Object.assign({
75
77
  source: sources.api(client),
76
78
  options
77
- });
79
+ }, this._extraOptions.api));
78
80
  this._views = new _index.ViewsActor(hub, {
79
81
  extensions,
80
82
  layouts,
@@ -281,9 +283,11 @@ class Workflow extends _commons.Component {
281
283
  return this._views.trackers;
282
284
  }
283
285
  _onTracker(args) {
286
+ const workflow = this;
284
287
  const data = this._hub.states[_index.fields.data()];
285
288
  const payload = this._buildInteraction(Object.assign({}, args, {
286
- data
289
+ data,
290
+ workflow
287
291
  }));
288
292
  this._sendInteraction(payload);
289
293
  }
@@ -299,10 +303,10 @@ class Workflow extends _commons.Component {
299
303
  return payload;
300
304
  }
301
305
  _defaultProcessInteraction(payload, args) {
302
- payload = (0, _processors.writeRequestMetadataToInteraction)(payload, args);
303
306
  payload = this._writeApiInfoToInteraction(payload, args);
304
- payload = this._writeRequestInfoToInteraction(payload, args);
305
307
  payload = this._writeMisoIdToInteraction(payload, args);
308
+ payload = (0, _processors.writeRequestInfoToInteraction)(payload, args);
309
+ payload = (0, _processors.writeRequestMetadataToInteraction)(payload, args);
306
310
  payload = (0, _processors.writeAffiliationInfoToInteraction)(payload, args);
307
311
  return payload;
308
312
  }
@@ -320,9 +324,6 @@ class Workflow extends _commons.Component {
320
324
  }
321
325
  });
322
326
  }
323
- _writeRequestInfoToInteraction(payload, args) {
324
- return payload;
325
- }
326
327
  _writeMisoIdToInteraction(payload, args) {
327
328
  // TODO: ad-hoc, try to pass info from tracker
328
329
  const state = this._hub.states[_index.fields.view(args.role)] || {};
@@ -347,6 +348,9 @@ class Workflow extends _commons.Component {
347
348
  this._emit('destroy');
348
349
  this._destroy(options);
349
350
  }
351
+ get destroyed() {
352
+ return !!this._destroyed;
353
+ }
350
354
  _destroy({
351
355
  dom
352
356
  } = {}) {
@@ -358,6 +362,7 @@ class Workflow extends _commons.Component {
358
362
  dom
359
363
  });
360
364
  this._data._destroy();
365
+ this._destroyed = true;
361
366
  }
362
367
 
363
368
  // helper //
@@ -4,20 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _commons = require("@miso.ai/commons");
8
7
  var _answerBased = _interopRequireDefault(require("./answer-based.js"));
9
- var _constants = require("../constants.js");
10
- var _index = require("./options/index.js");
8
+ var _index = require("../actor/index.js");
11
9
  var _processors = require("./processors.js");
12
- var _autocompletable = require("./autocompletable.js");
13
- const _excluded = ["qs"];
14
10
  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 (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
16
- const ROLES_OPTIONS = (0, _index.mergeRolesOptions)(_answerBased.default.ROLES_OPTIONS, {
17
- mappings: {
18
- [_constants.ROLE.QUESTION]: _constants.ROLE.KEYWORDS
19
- }
20
- });
11
+ const ROLES_OPTIONS = _answerBased.default.ROLES_OPTIONS;
21
12
  class HybridSearchAnswer extends _answerBased.default {
22
13
  constructor(superworkflow) {
23
14
  super({
@@ -32,39 +23,47 @@ class HybridSearchAnswer extends _answerBased.default {
32
23
  }
33
24
  _initProperties(args) {
34
25
  super._initProperties(args);
35
- this._initAutocomplete(args);
36
26
  this._superworkflow = args.superworkflow;
37
27
  }
38
28
  _initSession() {} // no reset here, will manually reset later
39
29
 
40
- restart() {
41
- super.restart();
42
- // cascade restart to the sibling
43
- const results = this._superworkflow._results;
44
- results._views.filters.reset({
45
- silent: true
46
- });
47
- results.restart();
48
- this._resultsSession = results.session; // keep track of the session
49
- }
50
-
51
- // query //
52
- _buildPayload(payload) {
53
- payload = this._writeQuestionSourceToPayload(payload);
54
- payload = this._writeWikiLinkTemplateToPayload(payload);
55
- payload = this._superworkflow._results._writeFiltersToPayload(payload);
56
- return payload;
30
+ _doLoading(data) {
31
+ const {
32
+ session
33
+ } = this;
34
+ this.updateData(Object.assign({}, data, {
35
+ session
36
+ }));
57
37
  }
58
- _writeQuestionSourceToPayload(_ref = {}) {
59
- let {
60
- qs
61
- } = _ref,
62
- payload = _objectWithoutPropertiesLoose(_ref, _excluded);
63
- return (0, _commons.mergeApiPayloads)(payload, {
64
- metadata: {
65
- question_source: qs || _constants.QUESTION_SOURCE.ORGANIC // might be null, not undefined
66
- }
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
67
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
+ }));
68
67
  }
69
68
 
70
69
  // data //
@@ -75,42 +74,15 @@ class HybridSearchAnswer extends _answerBased.default {
75
74
  data = (0, _processors.writeUnanswerableToMeta)(data);
76
75
  return data;
77
76
  }
78
- _updateDataInHub(data) {
79
- switch (data.status) {
80
- case _constants.STATUS.INITIAL:
81
- case _constants.STATUS.LOADING:
82
- // share the initial/loading status with its sibling
83
- this._dispatchDataToSibling(data);
84
- break;
85
- }
86
- super._updateDataInHub(data);
87
- }
88
77
  _handleHeadResponse(data) {
89
78
  super._handleHeadResponse(data);
90
79
  // keep track of miso_id in session
91
80
  (0, _processors.writeMisoIdToSession)(data);
92
- // share the search results with its sibling
93
- this._dispatchDataToSibling(data);
94
- }
95
- _dispatchDataToSibling(data) {
96
- this._resultsSession && this._superworkflow._results.updateData(Object.assign({}, data, {
97
- session: this._resultsSession
98
- }));
99
81
  }
100
82
 
101
83
  // interactions //
102
- _defaultProcessInteraction(payload, args) {
103
- return this._superworkflow._defaultProcessInteraction(payload, args);
104
- }
105
- _defaultProcessInteraction0(payload, args) {
106
- return super._defaultProcessInteraction(payload, args);
107
- }
108
-
109
- // destroy //
110
- _destroy(options) {
111
- this._destroyAutocomplete();
112
- super._destroy(options);
84
+ _onTracker(args) {
85
+ this._superworkflow._onTracker(args);
113
86
  }
114
87
  }
115
- exports.default = HybridSearchAnswer;
116
- (0, _autocompletable.makeAutocompletable)(HybridSearchAnswer.prototype);
88
+ exports.default = HybridSearchAnswer;