diff --git a/package.json b/package.json
index a47b8e2..19155f4 100644
--- a/package.json
+++ b/package.json
@@ -8,8 +8,8 @@
"url": "https://github.com/divyanshu013"
},
"dependencies": {
- "@appbaseio/reactivemaps": "3.0.0",
- "@appbaseio/reactivesearch": "3.42.1",
+ "@appbaseio/reactivemaps": "4.0.0-rc",
+ "@appbaseio/reactivesearch": "^4.0.0",
"@emotion/core": "^10.0.35",
"antd": "3.26.20",
"babel-eslint": "^10.1.0",
diff --git a/src/components/Filters.js b/src/components/Filters.js
index 9ef1b10..664f943 100644
--- a/src/components/Filters.js
+++ b/src/components/Filters.js
@@ -8,7 +8,10 @@ import {
Checkbox,
} from '@appbaseio/reactivesearch/lib/styles/FormControlList';
import { Collapse, Tooltip } from 'antd';
-import { ReactiveComponent, componentTypes } from '@appbaseio/reactivesearch';
+import {
+ ReactiveComponentPrivate as ReactiveComponent,
+ componentTypes,
+} from '@appbaseio/reactivesearch';
import createDOMPurify from 'dompurify';
import {
getReactDependenciesFromPreferences,
diff --git a/src/components/Search.js b/src/components/Search.js
index d4ed7a0..d6d9b15 100644
--- a/src/components/Search.js
+++ b/src/components/Search.js
@@ -6,7 +6,8 @@ import {
ReactiveBase,
SelectedFilters,
componentTypes,
- ReactiveComponent,
+ ReactiveComponentPrivate as ReactiveComponent,
+ AIAnswer,
} from '@appbaseio/reactivesearch';
import get from 'lodash.get';
import { string, bool } from 'prop-types';
@@ -704,7 +705,14 @@ class Search extends Component {
: null
}
/> */}
-
+ {this.resultSettings.showAIAnswer ? (
+
+ ) : null}
{
@@ -17,7 +17,7 @@ const SearchPage = () => {
credentials={credentials}
preferences={preferences}
>
-
diff --git a/src/utils/index.js b/src/utils/index.js
index 2f3360c..702f172 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -471,6 +471,7 @@ function normalizePreferences(preferences) {
return clonePreferences;
}
+
function transformPreferences(preferences) {
const normalizedPreferences = normalizePreferences(preferences);
if (
@@ -526,9 +527,8 @@ function transformPreferences(preferences) {
resultComponent.fields.userDefinedFields[field]
.dataField
) {
- const {
- dataField,
- } = resultComponent.fields.userDefinedFields[field];
+ const { dataField } =
+ resultComponent.fields.userDefinedFields[field];
highlightConfig.fields[dataField] = {};
}
});
@@ -540,9 +540,8 @@ function transformPreferences(preferences) {
resultComponent.fields[field].highlight &&
resultComponent.fields[field].dataField
) {
- const { dataField } = resultComponent.fields[
- field
- ];
+ const { dataField } =
+ resultComponent.fields[field];
highlightConfig.fields[dataField] = {};
}
});
@@ -568,14 +567,46 @@ function transformPreferences(preferences) {
}
if (resultComponent) {
- resultComponent.rsConfig.highlightConfig = resultComponent.resultHighlight
- ? highlightConfig
- : undefined;
+ resultComponent.rsConfig.highlightConfig =
+ resultComponent.resultHighlight
+ ? highlightConfig
+ : undefined;
+ resultComponent.rsConfig.dataField =
+ resultComponent.fields.title.dataField || 'title';
}
if (searchComponent) {
- searchComponent.rsConfig.highlightConfig = searchComponent.highlight
- ? highlightConfig
- : undefined;
+ searchComponent.rsConfig.highlightConfig =
+ searchComponent.highlight ? highlightConfig : undefined;
+ searchComponent.rsConfig.dataField =
+ searchComponent.fields.title.dataField || 'title';
+
+ if (
+ searchComponent.rsConfig &&
+ searchComponent.rsConfig.AIUIConfig
+ ) {
+ let { AIUIConfig } = searchComponent.rsConfig;
+ try {
+ AIUIConfig = {
+ ...AIUIConfig,
+ renderSourceDocument:
+ AIUIConfig &&
+ AIUIConfig.sourceDocumentLabel &&
+ !AIUIConfig.renderSourceDocument
+ ? // eslint-disable-next-line no-new-func
+ new Function(
+ 'source',
+ `return ${AIUIConfig.sourceDocumentLabel}`,
+ )
+ : AIUIConfig.renderSourceDocument,
+ };
+ delete AIUIConfig.sourceDocumentLabel;
+ } catch {
+ console.error(
+ 'Invalid string passed to renderSourceDocument function',
+ );
+ }
+ searchComponent.rsConfig.AIUIConfig = AIUIConfig;
+ }
}
},
);
@@ -584,6 +615,7 @@ function transformPreferences(preferences) {
return normalizedPreferences;
}
+
export const getDataFieldValue = (value) => {
if (value && typeof value === 'object') {
return value.dataField;
diff --git a/yarn.lock b/yarn.lock
index b90fe1e..a90d2b7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -42,22 +42,30 @@
resolved "https://registry.yarnpkg.com/@ant-design/icons/-/icons-2.1.1.tgz#7b9c08dffd4f5d41db667d9dbe5e0107d0bd9a4a"
integrity sha512-jCH+k2Vjlno4YWl6g535nHR09PwCEmTBKAG6VqF+rhkrSPRLfgpU2maagwbZPLjaHuU5Jd1DFQ2KJpQuI6uG8w==
-"@appbaseio/reactivecore@9.14.29":
- version "9.14.29"
- resolved "https://registry.yarnpkg.com/@appbaseio/reactivecore/-/reactivecore-9.14.29.tgz#fe75b9a9394f65fef4dbc06ff8c2fce301dab6e0"
- integrity sha512-zdBALqZ91y1lZCKoVLekA7sc0x1qCPaXdJG9PiUawGZG+KojizNz9rZZoXSRoJCZ36q47rj+qcKzWKma6oHKyQ==
+"@appbaseio/analytics@^1.2.0-alpha.1":
+ version "1.2.0-alpha.1"
+ resolved "https://registry.yarnpkg.com/@appbaseio/analytics/-/analytics-1.2.0-alpha.1.tgz#786fce19ac03930aa8698aaf6929856c208778d6"
+ integrity sha512-IoRR71bah4w7LwgdokL7RVa67CX/CDmusNacupqOtFo8o81tA2w91Lq8NIpT1EVn3Cm3RD2TxzRJBs3Ls1nmGg==
dependencies:
cross-fetch "^3.0.4"
+
+"@appbaseio/reactivecore@10.0.0":
+ version "10.0.0"
+ resolved "https://registry.yarnpkg.com/@appbaseio/reactivecore/-/reactivecore-10.0.0.tgz#c1d510b33345907498347fadd3854dc20843c2e8"
+ integrity sha512-j22qeXlcjzp2hgJ5ProVv39tvMHbXfFmFLEqKJGuel2xRnLg+LzaNrLYDo6Bhfcf1TYOy3Rf0b8A3g+tjMGvPg==
+ dependencies:
+ cross-fetch "^3.0.4"
+ dayjs "^1.11.7"
prop-types "^15.6.0"
redux "^4.0.0"
redux-thunk "^2.3.0"
- xdate "^0.8.2"
-"@appbaseio/reactivemaps@3.0.0":
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/@appbaseio/reactivemaps/-/reactivemaps-3.0.0.tgz#71fe187708800b0b7264b0de3edff232443afea9"
- integrity sha512-hMEu5skihuVrMBcjgv7SC05IbbQtlT8w7vgjoNquRRY4Dd2HWIjuHtv3bZz6/cCYR2QsYWVFe0gdEoMKrIAjSg==
+"@appbaseio/reactivemaps@4.0.0-rc":
+ version "4.0.0-rc"
+ resolved "https://registry.yarnpkg.com/@appbaseio/reactivemaps/-/reactivemaps-4.0.0-rc.tgz#f410820e3a9e38595e4e9f434cb95bfd4ca78d9f"
+ integrity sha512-4ZZtTrjC+2H1rEnwHNBPhRNMwsGHY7mDtnBj0SvLp8+G+LIzvy0A547K563vKhpM8zp8SnmNJeEHnrGF3XRXaA==
dependencies:
+ "@appbaseio/rheostat" "^1.0.0-alpha.15"
"@emotion/core" "^10.0.28"
"@emotion/styled" "^10.0.27"
"@react-google-maps/api" "^2.7.0"
@@ -68,18 +76,20 @@
ngeohash "^0.6.3"
prop-types "^15.6.0"
react-leaflet "^2.1.3"
- rheostat "^2.1.1"
-"@appbaseio/reactivesearch@3.42.1":
- version "3.42.1"
- resolved "https://registry.yarnpkg.com/@appbaseio/reactivesearch/-/reactivesearch-3.42.1.tgz#5f02dc967f5a6448b6f665eb0415e6a0f75d411e"
- integrity sha512-6oR6Y/c6XRIOI/T2EbKwEBUEFO3AydjrHybaD6Ehu+ob2SIkWz0DidI41oPno0C1ltF/DEIlSi1EpSPQ6lRxvw==
+"@appbaseio/reactivesearch@^4.0.0":
+ version "4.0.1"
+ resolved "https://registry.yarnpkg.com/@appbaseio/reactivesearch/-/reactivesearch-4.0.1.tgz#f2d8b49e570b7b8d472131bfafeb68c9894a7e00"
+ integrity sha512-xcc26jAi5ELfPfjYX+D+heBfrTRRpLDosbX6behyG+bbupRVFqldesEAJNHEG1P09FOwwFcpAj5q8RJnuwMhyA==
dependencies:
- "@appbaseio/reactivecore" "9.14.29"
+ "@appbaseio/analytics" "^1.2.0-alpha.1"
+ "@appbaseio/reactivecore" "10.0.0"
+ "@appbaseio/rheostat" "^1.0.0-alpha.15"
"@emotion/core" "^10.0.28"
"@emotion/styled" "^10.0.27"
- appbase-js "^5.2.0"
+ appbase-js "^5.3.3"
cross-env "^5.2.0"
+ dayjs "^1.11.7"
downshift "^1.31.2"
echarts "^5.3.3"
echarts-for-react "^3.0.2"
@@ -90,11 +100,18 @@
prop-types "^15.6.0"
react-day-picker "^7.0.5"
react-redux "^6.0.1"
- rheostat "^2.1.1"
+ remarkable "^2.0.1"
url-search-params-polyfill "^7.0.0"
- xdate "^0.8.2"
xss "^1.0.11"
+"@appbaseio/rheostat@^1.0.0-alpha.15":
+ version "1.0.0-alpha.15"
+ resolved "https://registry.yarnpkg.com/@appbaseio/rheostat/-/rheostat-1.0.0-alpha.15.tgz#c4db000c7e0adf973aaf95951ab9b4e90d806b26"
+ integrity sha512-dFDWv8SGGLRv5yGcQ5/3zYhVRDq2iIYmmU5v6s4/R0XRj2zCwld5O9DWi8WBZiDQJWQ7/7YUWTzqEgtxbYMOJA==
+ dependencies:
+ object.assign "^4.0.4"
+ prop-types "^15.5.10"
+
"@babel/code-frame@7.10.4":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a"
@@ -2553,10 +2570,10 @@ anymatch@^3.0.0, anymatch@^3.0.3, anymatch@~3.1.2:
normalize-path "^3.0.0"
picomatch "^2.0.4"
-appbase-js@^5.2.0:
- version "5.2.0"
- resolved "https://registry.yarnpkg.com/appbase-js/-/appbase-js-5.2.0.tgz#990da7227ae89cd0a002fdfc85428a001306ac27"
- integrity sha512-4B/xXivn7i6CATxcRZauDplCL3m9imOmbLH7j+cW4xwkqSN3aHDtj/OuvJDQqaMG0Awon8HUiiuwdh0+yY9DAw==
+appbase-js@^5.3.3:
+ version "5.3.4"
+ resolved "https://registry.yarnpkg.com/appbase-js/-/appbase-js-5.3.4.tgz#c30add29133fcfd7cc938a710a347cb89377670e"
+ integrity sha512-rbjCC7jmcPh1cjnW3W7TjTugQpLOB8SrPIdnkKwrNDdsl8d0nzPTJH4/082UTnkvlMkjm4WYY2HYCRl2vpDlpw==
dependencies:
cross-fetch "^3.1.5"
querystring "^0.2.0"
@@ -2567,7 +2584,7 @@ aproba@^1.1.1:
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"
integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==
-argparse@^1.0.7:
+argparse@^1.0.10, argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
@@ -2755,6 +2772,13 @@ atob@^2.1.2:
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
+autolinker@^3.11.0:
+ version "3.16.2"
+ resolved "https://registry.yarnpkg.com/autolinker/-/autolinker-3.16.2.tgz#6bb4f32432fc111b65659336863e653973bfbcc9"
+ integrity sha512-JiYl7j2Z19F9NdTmirENSUUIIL/9MytEWtmzhfmsKPCp9E+G35Y0UNCMoM9tFigxT59qSc8Ml2dlZXOCVTYwuA==
+ dependencies:
+ tslib "^2.3.0"
+
autoprefixer@^9.6.1:
version "9.8.8"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.8.8.tgz#fd4bd4595385fa6f06599de749a4d5f7a474957a"
@@ -4290,6 +4314,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
+dayjs@^1.11.7:
+ version "1.11.7"
+ resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.7.tgz#4b296922642f70999544d1144a2c25730fce63e2"
+ integrity sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==
+
debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -4369,6 +4398,14 @@ define-properties@^1.1.2, define-properties@^1.1.3:
has-property-descriptors "^1.0.0"
object-keys "^1.1.1"
+define-properties@^1.1.4:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5"
+ integrity sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==
+ dependencies:
+ has-property-descriptors "^1.0.0"
+ object-keys "^1.1.1"
+
define-property@^0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116"
@@ -8446,6 +8483,16 @@ object-visit@^1.0.0:
dependencies:
isobject "^3.0.0"
+object.assign@^4.0.4:
+ version "4.1.4"
+ resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f"
+ integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==
+ dependencies:
+ call-bind "^1.0.2"
+ define-properties "^1.1.4"
+ has-symbols "^1.0.3"
+ object-keys "^1.1.1"
+
object.assign@^4.1.0, object.assign@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940"
@@ -10750,6 +10797,14 @@ relateurl@^0.2.7:
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
integrity sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=
+remarkable@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/remarkable/-/remarkable-2.0.1.tgz#280ae6627384dfb13d98ee3995627ca550a12f31"
+ integrity sha512-YJyMcOH5lrR+kZdmB0aJJ4+93bEojRZ1HGDn9Eagu6ibg7aVZhc3OWbbShRid+Q5eAfsEqWxpe+g5W5nYNfNiA==
+ dependencies:
+ argparse "^1.0.10"
+ autolinker "^3.11.0"
+
remove-trailing-separator@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
@@ -10919,14 +10974,6 @@ rgba-regex@^1.0.0:
resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3"
integrity sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=
-rheostat@^2.1.1:
- version "2.2.0"
- resolved "https://registry.yarnpkg.com/rheostat/-/rheostat-2.2.0.tgz#d6b388e21f9c6bf5753a8e9518a8eea3467287d2"
- integrity sha512-cO6MvZ3fXtgP7NH7smWZhZczropunZJ50cdCLdlXR5Rhw0FNRaMM23Wx4NJjs5TGta3jOec39A/L0Lg8h8bPRQ==
- dependencies:
- object.assign "^4.1.0"
- prop-types "^15.6.0"
-
rimraf@2.6.3:
version "2.6.3"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
@@ -12132,6 +12179,11 @@ tslib@^2.0.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==
+tslib@^2.3.0:
+ version "2.5.0"
+ resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
+ integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
+
tsutils@^3.17.1, tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
@@ -12956,11 +13008,6 @@ ws@^7.4.6:
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.7.tgz#9e0ac77ee50af70d58326ecff7e85eb3fa375e67"
integrity sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==
-xdate@^0.8.2:
- version "0.8.2"
- resolved "https://registry.yarnpkg.com/xdate/-/xdate-0.8.2.tgz#d7b033c00485d02695baf0044f4eacda3fc961a3"
- integrity sha1-17AzwASF0CaVuvAET06s2j/JYaM=
-
xml-name-validator@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"