@miso.ai/client-sdk-ui 1.11.0-beta.6 → 1.11.0-beta.7

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.
@@ -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.11.0-beta.6';
7
+ var _default = exports.default = '1.11.0-beta.7';
@@ -57,7 +57,8 @@ const DEFAULT_LAYOUTS = Object.freeze({
57
57
  });
58
58
  const DEFAULT_TRACKERS = Object.freeze({
59
59
  [_constants.ROLE.SOURCES]: {},
60
- [_constants.ROLE.AFFILIATION]: {}
60
+ [_constants.ROLE.AFFILIATION]: {},
61
+ [_constants.ROLE.PRODUCTS]: {}
61
62
  });
62
63
  const DEFAULT_OPTIONS = Object.freeze({
63
64
  api: DEFAULT_API_OPTIONS,
@@ -26,7 +26,6 @@ class HybridSearchAnswer extends _answerBased.default {
26
26
  rolesConfig: ROLES_CONFIG,
27
27
  superworkflow
28
28
  });
29
- this.useInteractions(false);
30
29
  }
31
30
  _initProperties(args) {
32
31
  super._initProperties(args);
@@ -38,6 +37,7 @@ class HybridSearchAnswer extends _answerBased.default {
38
37
  super.restart();
39
38
  // cascade restart to the sibling
40
39
  const results = this._superworkflow._results;
40
+ results._views.filters.reset();
41
41
  results.restart();
42
42
  this._resultsSession = results.session; // keep track of the session
43
43
  }
@@ -30,7 +30,6 @@ class HybridSearchResults extends _base.default {
30
30
  rolesConfig: ROLES_CONFIG,
31
31
  superworkflow
32
32
  });
33
- this.useInteractions(false);
34
33
  }
35
34
  _initProperties(args) {
36
35
  super._initProperties(args);
@@ -75,7 +74,7 @@ class HybridSearchResults extends _base.default {
75
74
  payload = _objectWithoutPropertiesLoose(_ref, _excluded);
76
75
  // borrow the work from the sibling
77
76
  payload = this._superworkflow._answer._buildPayload(payload);
78
- payload = this._writeFqToPayload(Object.assign({}, payload, {
77
+ payload = this._writeFiltersToPayload(Object.assign({}, payload, {
79
78
  filters
80
79
  }));
81
80
  payload = this._writeQuestionIdToPayload(payload);
@@ -83,16 +82,13 @@ class HybridSearchResults extends _base.default {
83
82
  answer: false
84
83
  });
85
84
  }
86
- _writeFqToPayload() {
85
+ _writeFiltersToPayload() {
87
86
  let _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
88
87
  let {
89
88
  filters
90
89
  } = _ref2,
91
90
  payload = _objectWithoutPropertiesLoose(_ref2, _excluded2);
92
- const fq = (0, _processors.composeFq)(filters); // TODO: combine with fq in payload?
93
- return (0, _commons.trimObj)(Object.assign({}, payload, {
94
- fq
95
- }));
91
+ return (0, _commons.trimObj)(Object.assign({}, payload, (0, _processors.composeFiltersPayload)(filters)));
96
92
  }
97
93
  _writeQuestionIdToPayload(payload) {
98
94
  return Object.assign({}, payload, {
@@ -16,7 +16,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
16
16
  const DEFAULT_API_OPTIONS = Object.freeze(Object.assign({}, _answerBased.default.DEFAULT_API_OPTIONS, {
17
17
  name: _commons.API.NAME.SEARCH,
18
18
  payload: Object.assign({}, _answerBased.default.DEFAULT_API_OPTIONS.payload, {
19
- fl: ['cover_image', 'url', 'created_at', 'updated_at', 'published_at']
19
+ source_fl: ['cover_image', 'url', 'created_at', 'updated_at', 'published_at', 'title'],
20
+ fl: ['cover_image', 'url', 'created_at', 'updated_at', 'published_at', 'title']
20
21
  })
21
22
  }));
22
23
  const DEFAULT_LAYOUTS = Object.freeze(Object.assign({}, _answerBased.default.DEFAULT_LAYOUTS, {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.composeFq = composeFq;
6
+ exports.composeFiltersPayload = composeFiltersPayload;
7
7
  exports.writeAnswerStageToMeta = writeAnswerStageToMeta;
8
8
  exports.writeDataStatus = writeDataStatus;
9
9
  exports.writeKeywordsToData = writeKeywordsToData;
@@ -94,21 +94,30 @@ function writeAnswerStageToMeta(data) {
94
94
  })
95
95
  });
96
96
  }
97
- function composeFq(filters) {
97
+ function composeFiltersPayload(filters) {
98
98
  if (!filters) {
99
99
  return undefined;
100
100
  }
101
- const clauses = [];
102
101
  const {
103
102
  facets
104
103
  } = filters;
104
+ return (0, _commons.trimObj)({
105
+ facet_filters: composeFacetFilters(facets)
106
+ });
107
+ }
108
+ function composeFacetFilters(facets) {
109
+ if (!facets) {
110
+ return undefined;
111
+ }
112
+ const filters = {};
105
113
  for (const field in facets) {
106
114
  const values = facets[field];
107
115
  if (!values || !values.length) {
108
116
  continue; // just in case
109
117
  }
110
- const vstr = values.length === 1 ? `"${values[0]}"` : `(${values.map(v => `"${v}"`).join(' OR ')})`;
111
- clauses.push(`${field}:${vstr}`);
118
+ filters[field] = {
119
+ terms: values
120
+ };
112
121
  }
113
- return clauses.map(c => `(${c})`).join(' AND ') || undefined;
122
+ return Object.keys(filters).length ? filters : undefined;
114
123
  }
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@miso.ai/commons": "1.11.0-beta.6"
29
+ "@miso.ai/commons": "1.11.0-beta.7"
30
30
  },
31
- "version": "1.11.0-beta.6"
31
+ "version": "1.11.0-beta.7"
32
32
  }
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.11.0-beta.6';
1
+ export default '1.11.0-beta.7';
@@ -38,6 +38,7 @@ const DEFAULT_LAYOUTS = Object.freeze({
38
38
  const DEFAULT_TRACKERS = Object.freeze({
39
39
  [ROLE.SOURCES]: {},
40
40
  [ROLE.AFFILIATION]: {},
41
+ [ROLE.PRODUCTS]: {},
41
42
  });
42
43
 
43
44
  const DEFAULT_OPTIONS = Object.freeze({
@@ -20,7 +20,6 @@ export default class HybridSearchAnswer extends AnswerBasedWorkflow {
20
20
  rolesConfig: ROLES_CONFIG,
21
21
  superworkflow,
22
22
  });
23
- this.useInteractions(false);
24
23
  }
25
24
 
26
25
  _initProperties(args) {
@@ -34,6 +33,7 @@ export default class HybridSearchAnswer extends AnswerBasedWorkflow {
34
33
  super.restart();
35
34
  // cascade restart to the sibling
36
35
  const results = this._superworkflow._results;
36
+ results._views.filters.reset();
37
37
  results.restart();
38
38
  this._resultsSession = results.session; // keep track of the session
39
39
  }
@@ -3,7 +3,7 @@ import Workflow from './base.js';
3
3
  import { fields } from '../actor/index.js';
4
4
  import { ROLE, STATUS } from '../constants.js';
5
5
  import { mergeApiOptions } from './options.js';
6
- import { writeKeywordsToData, composeFq } from './processors.js';
6
+ import { writeKeywordsToData, composeFiltersPayload } from './processors.js';
7
7
 
8
8
  const ROLES_CONFIG = Object.freeze({
9
9
  [ROLE.FACETS]: {
@@ -23,7 +23,6 @@ export default class HybridSearchResults extends Workflow {
23
23
  rolesConfig: ROLES_CONFIG,
24
24
  superworkflow,
25
25
  });
26
- this.useInteractions(false);
27
26
  }
28
27
 
29
28
  _initProperties(args) {
@@ -62,16 +61,15 @@ export default class HybridSearchResults extends Workflow {
62
61
  _buildPayload({ filters, ...payload } = {}) {
63
62
  // borrow the work from the sibling
64
63
  payload = this._superworkflow._answer._buildPayload(payload);
65
- payload = this._writeFqToPayload({ ...payload, filters });
64
+ payload = this._writeFiltersToPayload({ ...payload, filters });
66
65
  payload = this._writeQuestionIdToPayload(payload);
67
66
  return { ...payload, answer: false };
68
67
  }
69
68
 
70
- _writeFqToPayload({ filters, ...payload } = {}) {
71
- const fq = composeFq(filters); // TODO: combine with fq in payload?
69
+ _writeFiltersToPayload({ filters, ...payload } = {}) {
72
70
  return trimObj({
73
71
  ...payload,
74
- fq,
72
+ ...composeFiltersPayload(filters),
75
73
  });
76
74
  }
77
75
 
@@ -12,7 +12,8 @@ const DEFAULT_API_OPTIONS = Object.freeze({
12
12
  name: API.NAME.SEARCH,
13
13
  payload: {
14
14
  ...AnswerBasedWorkflow.DEFAULT_API_OPTIONS.payload,
15
- fl: ['cover_image', 'url', 'created_at', 'updated_at', 'published_at'],
15
+ source_fl: ['cover_image', 'url', 'created_at', 'updated_at', 'published_at', 'title'],
16
+ fl: ['cover_image', 'url', 'created_at', 'updated_at', 'published_at', 'title'],
16
17
  },
17
18
  });
18
19
 
@@ -74,19 +74,29 @@ export function writeAnswerStageToMeta(data) {
74
74
  };
75
75
  }
76
76
 
77
- export function composeFq(filters) {
77
+ export function composeFiltersPayload(filters) {
78
78
  if (!filters) {
79
79
  return undefined;
80
80
  }
81
- const clauses = [];
82
81
  const { facets } = filters;
82
+ return trimObj({
83
+ facet_filters: composeFacetFilters(facets),
84
+ });
85
+ }
86
+
87
+ function composeFacetFilters(facets) {
88
+ if (!facets) {
89
+ return undefined;
90
+ }
91
+ const filters = {};
83
92
  for (const field in facets) {
84
93
  const values = facets[field];
85
94
  if (!values || !values.length) {
86
95
  continue; // just in case
87
96
  }
88
- const vstr = values.length === 1 ? `"${values[0]}"` : `(${values.map(v => `"${v}"`).join(' OR ')})`;
89
- clauses.push(`${field}:${vstr}`);
97
+ filters[field] = {
98
+ terms: values,
99
+ };
90
100
  }
91
- return clauses.map(c => `(${c})`).join(' AND ') || undefined;
101
+ return Object.keys(filters).length ? filters : undefined;
92
102
  }