@miso.ai/client-sdk-ui 1.11.5 → 1.11.6-beta.1

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 (117) hide show
  1. package/dist/cjs/actor/data.js +5 -7
  2. package/dist/cjs/actor/feedback.js +1 -2
  3. package/dist/cjs/actor/filters.js +20 -21
  4. package/dist/cjs/actor/hub.js +34 -8
  5. package/dist/cjs/actor/index.js +1 -2
  6. package/dist/cjs/actor/interactions.js +5 -7
  7. package/dist/cjs/actor/sessions.js +1 -2
  8. package/dist/cjs/actor/tracker.js +9 -12
  9. package/dist/cjs/actor/view.js +11 -20
  10. package/dist/cjs/actor/views.js +16 -21
  11. package/dist/cjs/affiliation/index.js +1 -2
  12. package/dist/cjs/combo/ask/elements.js +3 -4
  13. package/dist/cjs/combo/ask/index.js +1 -2
  14. package/dist/cjs/combo/ask/options.js +2 -6
  15. package/dist/cjs/defaults/ask/controls.js +1 -2
  16. package/dist/cjs/defaults/ask/index.js +1 -2
  17. package/dist/cjs/defaults/ask/templates.js +3 -6
  18. package/dist/cjs/defaults/common/templates.js +30 -41
  19. package/dist/cjs/defaults/hybrid-search/answer-box.js +9 -11
  20. package/dist/cjs/defaults/hybrid-search/controls.js +1 -2
  21. package/dist/cjs/defaults/hybrid-search/index.js +1 -2
  22. package/dist/cjs/defaults/hybrid-search/templates.js +2 -4
  23. package/dist/cjs/defaults/index.js +1 -2
  24. package/dist/cjs/element/container/miso-explore.js +7 -7
  25. package/dist/cjs/element/container/miso-hybrid-search.js +3 -3
  26. package/dist/cjs/element/container/miso-recommendation.js +3 -38
  27. package/dist/cjs/element/container/miso-search.js +3 -3
  28. package/dist/cjs/element/container/miso-unit.js +52 -0
  29. package/dist/cjs/element/index.js +1 -2
  30. package/dist/cjs/element/role/miso-component.js +3 -4
  31. package/dist/cjs/element/utils.js +6 -9
  32. package/dist/cjs/layout/affiliation/affiliation.js +4 -6
  33. package/dist/cjs/layout/banner/banner.js +1 -2
  34. package/dist/cjs/layout/button/more-button.js +1 -2
  35. package/dist/cjs/layout/container/container.js +7 -12
  36. package/dist/cjs/layout/error/error.js +1 -2
  37. package/dist/cjs/layout/input/facets.js +28 -41
  38. package/dist/cjs/layout/input/option-list.js +1 -2
  39. package/dist/cjs/layout/input/search-box.js +31 -40
  40. package/dist/cjs/layout/input/select.js +1 -2
  41. package/dist/cjs/layout/list/cards.js +1 -2
  42. package/dist/cjs/layout/list/carousel.js +1 -2
  43. package/dist/cjs/layout/list/collection.js +12 -16
  44. package/dist/cjs/layout/list/gallery.js +18 -26
  45. package/dist/cjs/layout/list/list.js +1 -2
  46. package/dist/cjs/layout/mixin/swipeable.js +3 -4
  47. package/dist/cjs/layout/mixin/trackable.js +3 -6
  48. package/dist/cjs/layout/progressive.js +1 -2
  49. package/dist/cjs/layout/radio/feedback.js +6 -8
  50. package/dist/cjs/layout/radio/radio.js +5 -6
  51. package/dist/cjs/layout/raf.js +6 -10
  52. package/dist/cjs/layout/template.js +7 -10
  53. package/dist/cjs/layout/templates.js +51 -71
  54. package/dist/cjs/layout/text/text.js +6 -8
  55. package/dist/cjs/layout/text/typewriter/index.js +14 -18
  56. package/dist/cjs/layout/text/typewriter/plaintext.js +8 -10
  57. package/dist/cjs/layout/text/typewriter/utils.js +12 -15
  58. package/dist/cjs/plugin.js +13 -3
  59. package/dist/cjs/source.js +6 -7
  60. package/dist/cjs/util/dom.js +1 -2
  61. package/dist/cjs/util/proxy.js +3 -4
  62. package/dist/cjs/util/trackers.js +1 -3
  63. package/dist/cjs/util/viewables.js +1 -2
  64. package/dist/cjs/version.js +1 -1
  65. package/dist/cjs/workflow/answer-based.js +17 -24
  66. package/dist/cjs/workflow/ask.js +1 -2
  67. package/dist/cjs/workflow/asks.js +4 -6
  68. package/dist/cjs/workflow/autocomplete.js +3 -4
  69. package/dist/cjs/workflow/base.js +56 -54
  70. package/dist/cjs/workflow/explore.js +18 -22
  71. package/dist/cjs/workflow/explores.js +18 -0
  72. package/dist/cjs/workflow/hybrid-search-answer.js +4 -3
  73. package/dist/cjs/workflow/index.js +3 -3
  74. package/dist/cjs/workflow/options/api.js +2 -6
  75. package/dist/cjs/workflow/options/auto-query.js +2 -4
  76. package/dist/cjs/workflow/options/configurable.js +2 -6
  77. package/dist/cjs/workflow/options/data-processor.js +1 -4
  78. package/dist/cjs/workflow/options/filters.js +1 -4
  79. package/dist/cjs/workflow/options/interactions.js +1 -4
  80. package/dist/cjs/workflow/options/layouts.js +2 -6
  81. package/dist/cjs/workflow/options/options.js +5 -8
  82. package/dist/cjs/workflow/options/pagination.js +1 -4
  83. package/dist/cjs/workflow/options/roles.js +1 -3
  84. package/dist/cjs/workflow/options/trackers.js +6 -16
  85. package/dist/cjs/workflow/processors.js +16 -22
  86. package/dist/cjs/workflow/recommendation.js +9 -52
  87. package/dist/cjs/workflow/recommendations.js +3 -23
  88. package/dist/cjs/workflow/search-based.js +12 -8
  89. package/dist/cjs/workflow/search.js +1 -5
  90. package/dist/cjs/workflow/unit.js +58 -0
  91. package/dist/cjs/workflow/units.js +37 -0
  92. package/dist/cjs/workflow/use-link.js +3 -6
  93. package/package.json +2 -2
  94. package/src/actor/filters.js +4 -2
  95. package/src/actor/hub.js +26 -5
  96. package/src/element/container/miso-explore.js +8 -8
  97. package/src/element/container/miso-hybrid-search.js +4 -4
  98. package/src/element/container/miso-recommendation.js +3 -45
  99. package/src/element/container/miso-search.js +4 -4
  100. package/src/element/container/miso-unit.js +55 -0
  101. package/src/layout/input/search-box.js +1 -1
  102. package/src/layout/radio/radio.js +1 -0
  103. package/src/layout/templates.js +3 -2
  104. package/src/plugin.js +15 -2
  105. package/src/version.js +1 -1
  106. package/src/workflow/autocomplete.js +1 -0
  107. package/src/workflow/base.js +33 -23
  108. package/src/workflow/explore.js +13 -12
  109. package/src/workflow/explores.js +14 -0
  110. package/src/workflow/hybrid-search-answer.js +1 -1
  111. package/src/workflow/index.js +1 -1
  112. package/src/workflow/processors.js +2 -2
  113. package/src/workflow/recommendation.js +9 -47
  114. package/src/workflow/recommendations.js +3 -23
  115. package/src/workflow/search-based.js +4 -0
  116. package/src/workflow/unit.js +52 -0
  117. package/src/workflow/units.js +37 -0
@@ -11,31 +11,7 @@ var _constants = require("../constants.js");
11
11
  var _index2 = require("../layout/index.js");
12
12
  var _index3 = require("./options/index.js");
13
13
  var _processors = require("./processors.js");
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
- 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; }
16
- // TODO: just bury this into hub
17
- function injectLogger(hub, callback) {
18
- const {
19
- update,
20
- trigger
21
- } = hub;
22
- hub.update = (name, state, options) => {
23
- const result = update.call(hub, name, state, options);
24
- if (!options || !options.silent) {
25
- callback('update', name, state, options);
26
- }
27
- return result;
28
- };
29
- hub.trigger = function () {
30
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
31
- args[_key] = arguments[_key];
32
- }
33
- const result = trigger.apply(hub, args);
34
- callback('trigger', ...args);
35
- return result;
36
- };
37
- return hub;
38
- }
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
39
15
  const DEFAULT_API_OPTIONS = Object.freeze({});
40
16
  const DEFAULT_LAYOUTS = Object.freeze({
41
17
  [_constants.ROLE.CONTAINER]: _index2.ContainerLayout.type,
@@ -54,9 +30,7 @@ const ROLES_OPTIONS = Object.freeze({
54
30
  });
55
31
  class Workflow extends _commons.Component {
56
32
  constructor(args) {
57
- var _this;
58
33
  super(args.name || 'workflow', args.plugin);
59
- _this = this;
60
34
  let {
61
35
  context,
62
36
  plugin,
@@ -76,21 +50,22 @@ class Workflow extends _commons.Component {
76
50
  this._extensions = plugin._getExtensions(client);
77
51
  this._defaults = defaults;
78
52
  this._options = options || new _index3.WorkflowOptions(context && context._options, defaults);
79
- this._hub = injectLogger(new _index.Hub(), function () {
80
- return _this._log(...arguments);
53
+ this._hub = new _index.Hub({
54
+ onUpdate: event => this._onHubUpdate(event),
55
+ onEmit: event => this._onHubEmit(event)
81
56
  });
82
57
  this._sessionContext = new WeakMap();
58
+ client._events.emit('workflow', this);
83
59
  this._initProperties(args);
84
60
  this._initActors(args);
85
61
  this._initSubscriptions(args);
86
62
  this._initSession(args);
87
63
  }
88
64
  _initProperties() {}
89
- _initActors(_ref) {
90
- let {
91
- name,
92
- roles
93
- } = _ref;
65
+ _initActors({
66
+ name,
67
+ roles
68
+ }) {
94
69
  const hub = this._hub;
95
70
  const client = this._client;
96
71
  const options = this._options;
@@ -113,10 +88,9 @@ class Workflow extends _commons.Component {
113
88
  options
114
89
  });
115
90
  }
116
- _initSubscriptions(_ref2) {
117
- let {
118
- roles
119
- } = _ref2;
91
+ _initSubscriptions({
92
+ roles
93
+ }) {
120
94
  this._unsubscribes = [this._hub.on(_index.fields.response(), data => this.updateData(data)), this._hub.on(_index.fields.tracker(), args => this._onTracker(args))];
121
95
  if (roles.main) {
122
96
  this._unsubscribes.push(this._hub.on(_index.fields.view(roles.main), state => this._onMainViewUpdate(state)));
@@ -133,8 +107,30 @@ class Workflow extends _commons.Component {
133
107
  return context;
134
108
  }
135
109
 
110
+ // hub //
111
+ _onHubUpdate(event) {
112
+ this._runCallbacks(this._client.meta.parent._hubUpdateCallbacks, event);
113
+ }
114
+ _onHubEmit(event) {
115
+ this._runCallbacks(this._client.meta.parent._hubEmitCallbacks, event);
116
+ this._emitAsWorkflowEvent(event);
117
+ }
118
+ _emitAsWorkflowEvent({
119
+ action: _action,
120
+ name,
121
+ state,
122
+ silent
123
+ }) {
124
+ if (!silent) {
125
+ this._emit(name, Object.assign({
126
+ _action
127
+ }, state));
128
+ }
129
+ }
130
+
136
131
  // properties //
137
132
  get uuid() {
133
+ // TODO: review this
138
134
  return this.session && this.session.uuid;
139
135
  }
140
136
  get session() {
@@ -186,10 +182,9 @@ class Workflow extends _commons.Component {
186
182
  this._emitLifecycleEvent('finally', state);
187
183
  }
188
184
  }
189
- _shallEmitLifecycleEvent(name, _ref3) {
190
- let {
191
- session
192
- } = _ref3;
185
+ _shallEmitLifecycleEvent(name, {
186
+ session
187
+ }) {
193
188
  const context = this._getSessionContext(session);
194
189
  const events = context.lifecycleEvents || (context.lifecycleEvents = new Set());
195
190
  const emitted = events.has(name);
@@ -204,8 +199,7 @@ class Workflow extends _commons.Component {
204
199
  }
205
200
 
206
201
  // request //
207
- _request() {
208
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
202
+ _request(options = {}) {
209
203
  const {
210
204
  session
211
205
  } = this;
@@ -334,10 +328,9 @@ class Workflow extends _commons.Component {
334
328
  this._events.emit('destroy');
335
329
  this._destroy(options);
336
330
  }
337
- _destroy() {
338
- let {
339
- dom
340
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
331
+ _destroy({
332
+ dom
333
+ } = {}) {
341
334
  for (const unsubscribe of this._unsubscribes || []) {
342
335
  unsubscribe();
343
336
  }
@@ -349,16 +342,25 @@ class Workflow extends _commons.Component {
349
342
  }
350
343
 
351
344
  // helper //
352
- _log(action, name, data) {
353
- this._emit(name, Object.assign({
354
- _action: action
355
- }, data));
345
+ _runCallbacks(callbacks, event) {
346
+ for (const callback of callbacks) {
347
+ try {
348
+ callback(Object.assign({
349
+ workflow: this
350
+ }, event));
351
+ } catch (e) {
352
+ this._error(e);
353
+ }
354
+ }
356
355
  }
357
356
  _emit(name, data) {
358
- this._events.emit(name, data);
357
+ this._events.emit(name, Object.assign({
358
+ _event: name
359
+ }, data));
359
360
  if (this._context) {
360
361
  this._context._events.emit(name, Object.assign({
361
- workflow: this
362
+ workflow: this,
363
+ _event: name
362
364
  }, data));
363
365
  }
364
366
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _commons = require("@miso.ai/commons");
8
- var _base = _interopRequireDefault(require("./base.js"));
8
+ var _unit = _interopRequireDefault(require("./unit.js"));
9
9
  var _index = require("../actor/index.js");
10
10
  var _constants = require("../constants.js");
11
11
  var _index2 = require("../layout/index.js");
@@ -14,11 +14,11 @@ var _useLink = require("./use-link.js");
14
14
  const _excluded = ["value"];
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
16
  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; }
17
- const DEFAULT_API_OPTIONS = Object.freeze(Object.assign({}, _base.default.DEFAULT_API_OPTIONS, {
17
+ const DEFAULT_API_OPTIONS = Object.freeze(Object.assign({}, _unit.default.DEFAULT_API_OPTIONS, {
18
18
  group: _commons.API.GROUP.ASK,
19
19
  name: _commons.API.NAME.RELATED_QUESTIONS
20
20
  }));
21
- const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _base.default.DEFAULT_LAYOUTS, {
21
+ const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _unit.default.DEFAULT_LAYOUTS, {
22
22
  [_constants.ROLE.RELATED_QUESTIONS]: [_index2.ListLayout.type, {
23
23
  itemType: 'question',
24
24
  link: {
@@ -29,7 +29,7 @@ const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _base.default.DEFAULT_LA
29
29
  placeholder: 'Ask a question'
30
30
  }]
31
31
  }));
32
- const DEFAULT_TRACKERS = Object.freeze(Object.assign({}, _base.default.DEFAULT_TRACKERS, {
32
+ const DEFAULT_TRACKERS = Object.freeze(Object.assign({}, _unit.default.DEFAULT_TRACKERS, {
33
33
  [_constants.ROLE.RELATED_QUESTIONS]: _index3.DEFAULT_TRACKER_OPTIONS,
34
34
  [_constants.ROLE.CONTAINER]: Object.assign({}, _index3.DEFAULT_TRACKER_OPTIONS, {
35
35
  itemless: true
@@ -40,23 +40,23 @@ const DEFAULT_TRACKERS = Object.freeze(Object.assign({}, _base.default.DEFAULT_T
40
40
  }
41
41
  }
42
42
  }));
43
- const DEFAULT_OPTIONS = Object.freeze(Object.assign({}, _base.default.DEFAULT_OPTIONS, {
43
+ const DEFAULT_OPTIONS = Object.freeze(Object.assign({}, _unit.default.DEFAULT_OPTIONS, {
44
44
  api: DEFAULT_API_OPTIONS,
45
45
  layouts: DEFAULT_LAYOUTS,
46
46
  trackers: DEFAULT_TRACKERS
47
47
  }));
48
- const ROLES_OPTIONS = (0, _index3.mergeRolesOptions)(_base.default.ROLES_OPTIONS, {
48
+ const ROLES_OPTIONS = (0, _index3.mergeRolesOptions)(_unit.default.ROLES_OPTIONS, {
49
49
  main: _constants.ROLE.RELATED_QUESTIONS,
50
50
  members: Object.keys(DEFAULT_LAYOUTS)
51
51
  });
52
- class Explore extends _base.default {
53
- constructor(plugin, client) {
52
+ class Explore extends _unit.default {
53
+ constructor(context, id) {
54
54
  super({
55
55
  name: 'explore',
56
- plugin,
57
- client,
56
+ context,
58
57
  roles: ROLES_OPTIONS,
59
- defaults: DEFAULT_OPTIONS
58
+ defaults: DEFAULT_OPTIONS,
59
+ id
60
60
  });
61
61
  }
62
62
  _initProperties(args) {
@@ -76,14 +76,15 @@ class Explore extends _base.default {
76
76
  product_id: value
77
77
  });
78
78
  }
79
- useApi(options) {
79
+ useApi(...args) {
80
+ const options = (typeof args[0] === 'object' ? args[0] : args[1]) || {};
80
81
  const {
81
82
  product_id
82
83
  } = options;
83
84
  if (product_id) {
84
85
  this._productId = product_id;
85
86
  }
86
- return super.useApi(options);
87
+ return super.useApi(...args);
87
88
  }
88
89
  useLink(fn, options) {
89
90
  _useLink.UseLinkMixin.prototype.useLink.call(this, fn, options);
@@ -99,10 +100,9 @@ class Explore extends _base.default {
99
100
  }
100
101
 
101
102
  // lifecycle //
102
- start() {
103
- let {
104
- relatedQuestions = true
105
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
103
+ start({
104
+ relatedQuestions = true
105
+ } = {}) {
106
106
  if (this._linkFn === undefined) {
107
107
  throw new Error('Must define link mapping function with useLink(fn) before calling start()');
108
108
  }
@@ -125,11 +125,7 @@ class Explore extends _base.default {
125
125
  }
126
126
  return this;
127
127
  }
128
- notifyViewUpdate() {
129
- let role = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.ROLE.RELATED_QUESTIONS;
130
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
131
- args[_key - 1] = arguments[_key];
132
- }
128
+ notifyViewUpdate(role = _constants.ROLE.RELATED_QUESTIONS, ...args) {
133
129
  super.notifyViewUpdate(role, ...args);
134
130
  return this;
135
131
  }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _units = _interopRequireDefault(require("./units.js"));
8
+ var _explore = _interopRequireDefault(require("./explore.js"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ class Explores extends _units.default {
11
+ constructor(plugin, client) {
12
+ super('explores', plugin, client);
13
+ }
14
+ _create(unitId) {
15
+ return new _explore.default(this, unitId);
16
+ }
17
+ }
18
+ exports.default = Explores;
@@ -40,7 +40,9 @@ class HybridSearchAnswer extends _answerBased.default {
40
40
  super.restart();
41
41
  // cascade restart to the sibling
42
42
  const results = this._superworkflow._results;
43
- results._views.filters.reset();
43
+ results._views.filters.reset({
44
+ silent: true
45
+ });
44
46
  results.restart();
45
47
  this._resultsSession = results.session; // keep track of the session
46
48
  }
@@ -52,8 +54,7 @@ class HybridSearchAnswer extends _answerBased.default {
52
54
  payload = this._superworkflow._results._writeFiltersToPayload(payload);
53
55
  return payload;
54
56
  }
55
- _writeQuestionSourceToPayload() {
56
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
57
+ _writeQuestionSourceToPayload(_ref = {}) {
57
58
  let {
58
59
  qs
59
60
  } = _ref,
@@ -9,10 +9,10 @@ Object.defineProperty(exports, "Asks", {
9
9
  return _asks.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "Explore", {
12
+ Object.defineProperty(exports, "Explores", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _explore.default;
15
+ return _explores.default;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "HybridSearch", {
@@ -35,7 +35,7 @@ Object.defineProperty(exports, "Search", {
35
35
  });
36
36
  var _asks = _interopRequireDefault(require("./asks.js"));
37
37
  var _hybridSearch = _interopRequireDefault(require("./hybrid-search.js"));
38
- var _explore = _interopRequireDefault(require("./explore.js"));
39
38
  var _search = _interopRequireDefault(require("./search.js"));
40
39
  var _recommendations = _interopRequireDefault(require("./recommendations.js"));
40
+ var _explores = _interopRequireDefault(require("./explores.js"));
41
41
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -7,8 +7,7 @@ exports.mergeApiOptions = mergeApiOptions;
7
7
  exports.normalizeApiOptions = normalizeApiOptions;
8
8
  var _commons = require("@miso.ai/commons");
9
9
  var _utils = require("./utils.js");
10
- function normalizeApiOptions() {
11
- let [name, payload] = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
10
+ function normalizeApiOptions([name, payload] = []) {
12
11
  // TODO: take object form as well
13
12
  if (name === false) {
14
13
  return {
@@ -32,10 +31,7 @@ function normalizeApiOptions() {
32
31
  payload
33
32
  });
34
33
  }
35
- function mergeApiOptions() {
36
- for (var _len = arguments.length, optionsList = new Array(_len), _key = 0; _key < _len; _key++) {
37
- optionsList[_key] = arguments[_key];
38
- }
34
+ function mergeApiOptions(...optionsList) {
39
35
  if (optionsList[optionsList.length - 1] === false) {
40
36
  return false;
41
37
  }
@@ -12,8 +12,7 @@ const _excluded = ["setValue", "focus", "updateUrl", "param", "sourceParam"];
12
12
  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; }
13
13
  const DEFAULT_AUTO_QUERY_PARAM = exports.DEFAULT_AUTO_QUERY_PARAM = 'q';
14
14
  const DEFAULT_AUTO_QUERY_SOURCE_PARAM = exports.DEFAULT_AUTO_QUERY_SOURCE_PARAM = 'qs';
15
- function normalizeAutoQueryOptions() {
16
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15
+ function normalizeAutoQueryOptions(_ref = {}) {
17
16
  let {
18
17
  setValue = true,
19
18
  focus = true,
@@ -30,8 +29,7 @@ function normalizeAutoQueryOptions() {
30
29
  sourceParam
31
30
  }, options);
32
31
  }
33
- function autoQuery() {
34
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32
+ function autoQuery(options = {}) {
35
33
  // TODO: support getting value from URL path
36
34
  const {
37
35
  setValue,
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.makeConfigurable = makeConfigurable;
7
7
  var _constants = require("../../constants.js");
8
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;
9
+ function makeConfigurable(prototype, features = DEFAULT_FEATURES) {
11
10
  for (const feature of features) {
12
11
  injectConfigurableFeature(prototype, feature);
13
12
  }
@@ -15,10 +14,7 @@ function makeConfigurable(prototype) {
15
14
  function injectConfigurableFeature(prototype, feature) {
16
15
  if (feature === 'api') {
17
16
  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
- }
17
+ useApi(...args) {
22
18
  this._options.api.merge(args);
23
19
  return this;
24
20
  },
@@ -15,9 +15,6 @@ function normalizeDataProcessorOptions(fns) {
15
15
  }
16
16
  return fns;
17
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
- }
18
+ function mergeDataProcessorOptions(...optionsList) {
22
19
  return optionsList.flat().filter(Boolean);
23
20
  }
@@ -7,10 +7,7 @@ exports.mergeFiltersOptions = mergeFiltersOptions;
7
7
  exports.normalizeFiltersOptions = void 0;
8
8
  var _utils = require("./utils.js");
9
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
- }
10
+ function mergeFiltersOptions(...optionsList) {
14
11
  if (optionsList[optionsList.length - 1] === false) {
15
12
  return false;
16
13
  }
@@ -31,10 +31,7 @@ function normalizeInteractionsOptions(options) {
31
31
  preprocess
32
32
  });
33
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
- }
34
+ function mergeInteractionsOptions(...optionsList) {
38
35
  if (optionsList[optionsList.length - 1] === false) {
39
36
  return false;
40
37
  }
@@ -10,8 +10,7 @@ var _constants = require("../../constants.js");
10
10
  var _utils = require("./utils.js");
11
11
  const _excluded = ["results"];
12
12
  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; }
13
- function normalizeLayoutsOptions() {
14
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
13
+ function normalizeLayoutsOptions(options = {}) {
15
14
  if (options === false) {
16
15
  return false;
17
16
  }
@@ -54,10 +53,7 @@ function normalizeLayoutOptions(args) {
54
53
  }
55
54
  return [name, options];
56
55
  }
57
- function mergeLayoutsOptions() {
58
- for (var _len = arguments.length, optionsList = new Array(_len), _key = 0; _key < _len; _key++) {
59
- optionsList[_key] = arguments[_key];
60
- }
56
+ function mergeLayoutsOptions(...optionsList) {
61
57
  if (optionsList[optionsList.length - 1] === false) {
62
58
  return false;
63
59
  }
@@ -56,9 +56,7 @@ class WorkflowContextOptions {
56
56
  }
57
57
  exports.WorkflowContextOptions = WorkflowContextOptions;
58
58
  class WorkflowOptions {
59
- constructor() {
60
- let context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
61
- let defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
59
+ constructor(context = {}, defaults = {}) {
62
60
  this._events = new _commons.EventEmitter({
63
61
  target: this
64
62
  });
@@ -93,11 +91,10 @@ class ResolvedWorkflowOptions {
93
91
  _invalidate(key) {
94
92
  this._cache[key] = undefined;
95
93
  }
96
- _get(_ref) {
97
- let {
98
- key,
99
- merge
100
- } = _ref;
94
+ _get({
95
+ key,
96
+ merge
97
+ }) {
101
98
  if (this._cache[key] === undefined) {
102
99
  const options = this._options;
103
100
  const contextFeature = options._context[key];
@@ -17,10 +17,7 @@ function normalizePaginationOptions(options) {
17
17
  }
18
18
  return options;
19
19
  }
20
- function mergePaginationOptions() {
21
- for (var _len = arguments.length, optionsList = new Array(_len), _key = 0; _key < _len; _key++) {
22
- optionsList[_key] = arguments[_key];
23
- }
20
+ function mergePaginationOptions(...optionsList) {
24
21
  if (optionsList[optionsList.length - 1] === false) {
25
22
  return false;
26
23
  }
@@ -10,8 +10,6 @@ function mergeRolesOptions(base, overrides) {
10
10
  mappings: Object.freeze(Object.assign({}, base.mappings, overrides.mappings))
11
11
  }));
12
12
  }
13
- function mergeRolesMembers() {
14
- let base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
15
- let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
13
+ function mergeRolesMembers(base = [], overrides = []) {
16
14
  return [...new Set([...base, ...overrides])];
17
15
  }
@@ -26,8 +26,7 @@ const DEFAULT_TRACKER_OPTIONS = exports.DEFAULT_TRACKER_OPTIONS = Object.freeze(
26
26
  lenient: false
27
27
  })
28
28
  });
29
- function normalizeTrackersOptions() {
30
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
29
+ function normalizeTrackersOptions(options = {}) {
31
30
  options = (0, _utils.normalizeOptions)(options);
32
31
  const {
33
32
  active
@@ -41,8 +40,7 @@ function normalizeTrackersOptions() {
41
40
  active
42
41
  }, normalized);
43
42
  }
44
- function normalizeTrackerOptions() {
45
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
43
+ function normalizeTrackerOptions(options = {}) {
46
44
  options = (0, _utils.normalizeOptions)(options);
47
45
  const rest = _objectWithoutPropertiesLoose(options, _excluded2);
48
46
  const normalized = {};
@@ -51,15 +49,11 @@ function normalizeTrackerOptions() {
51
49
  }
52
50
  return options;
53
51
  }
54
- function normalizeTrackerEventOptions() {
55
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
52
+ function normalizeTrackerEventOptions(options = {}) {
56
53
  options = (0, _utils.normalizeOptions)(options);
57
54
  return options;
58
55
  }
59
- function mergeTrackersOptions() {
60
- for (var _len = arguments.length, optionsList = new Array(_len), _key = 0; _key < _len; _key++) {
61
- optionsList[_key] = arguments[_key];
62
- }
56
+ function mergeTrackersOptions(...optionsList) {
63
57
  // TODO: should be able to remove this
64
58
  if (optionsList[optionsList.length - 1] === false) {
65
59
  return false;
@@ -74,9 +68,7 @@ function mergeTrackersOptions() {
74
68
  return merged;
75
69
  });
76
70
  }
77
- function mergeTrackerOptions() {
78
- let base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
79
- let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
71
+ function mergeTrackerOptions(base = {}, overrides = {}) {
80
72
  const merged = Object.assign({}, base);
81
73
  for (const [key, args] of Object.entries(overrides)) {
82
74
  if (args === undefined) {
@@ -86,8 +78,6 @@ function mergeTrackerOptions() {
86
78
  }
87
79
  return merged;
88
80
  }
89
- function mergeTrackerEventOptions() {
90
- let base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
91
- let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
81
+ function mergeTrackerEventOptions(base = {}, overrides = {}) {
92
82
  return Object.assign({}, base, overrides);
93
83
  }
@@ -23,11 +23,10 @@ var _commons = require("@miso.ai/commons");
23
23
  var _constants = require("../constants.js");
24
24
  var _index = require("../actor/index.js");
25
25
  // role mappings //
26
- function mappingSortData(_) {
27
- let {
28
- hub,
29
- workflowOptions = {}
30
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26
+ function mappingSortData(_, {
27
+ hub,
28
+ workflowOptions = {}
29
+ } = {}) {
31
30
  const {
32
31
  sort: {
33
32
  options = []
@@ -209,10 +208,9 @@ function retainFacetCountsInData(data, currentFacetCounts) {
209
208
  })
210
209
  });
211
210
  }
212
- function concatItemsFromMoreResponse(oldData, newData) {
213
- let {
214
- role = _constants.ROLE.PRODUCTS
215
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
211
+ function concatItemsFromMoreResponse(oldData, newData, {
212
+ role = _constants.ROLE.PRODUCTS
213
+ } = {}) {
216
214
  if (!newData.value) {
217
215
  return oldData;
218
216
  }
@@ -229,17 +227,16 @@ function concatItemsFromMoreResponse(oldData, newData) {
229
227
 
230
228
  // use old values of facet_counts and total, for they are affected by product_id exclusion
231
229
  return Object.assign({}, newData, {
232
- facet_counts,
233
- total,
234
230
  value: Object.assign({}, newData.value, {
231
+ facet_counts,
232
+ total,
235
233
  [role]: [...oldProducts, ...newProducts]
236
234
  })
237
235
  });
238
236
  }
239
- function writeExhaustionToData(data) {
240
- let {
241
- role = _constants.ROLE.PRODUCTS
242
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
237
+ function writeExhaustionToData(data, {
238
+ role = _constants.ROLE.PRODUCTS
239
+ } = {}) {
243
240
  const {
244
241
  status,
245
242
  request,
@@ -324,10 +321,9 @@ function writeAffiliationInfoToInteraction(payload, args) {
324
321
  }
325
322
  });
326
323
  }
327
- function writeEventTargetToInteraction(payload) {
328
- let {
329
- event_target
330
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
324
+ function writeEventTargetToInteraction(payload, {
325
+ event_target
326
+ } = {}) {
331
327
  if (!event_target) {
332
328
  return payload;
333
329
  }
@@ -339,9 +335,7 @@ function writeEventTargetToInteraction(payload) {
339
335
  }
340
336
  });
341
337
  }
342
- function mergeInteraction() {
343
- let base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
344
- let patch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
338
+ function mergeInteraction(base = {}, patch = {}) {
345
339
  return (0, _commons.trimObj)(Object.assign({}, base, patch, {
346
340
  context: (0, _commons.trimObj)(Object.assign({}, base.context, patch.context, {
347
341
  custom_context: (0, _commons.trimObj)(Object.assign({}, base.context && base.context.custom_context, patch.context && patch.context.custom_context))