@appbaseio/reactivesearch-vue 1.23.4 → 1.24.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 (49) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +248 -35
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -5
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/DataSearch.js +1 -1
  6. package/dist/cjs/{DropDown-59a7971b.js → DropDown-6815b9b6.js} +1 -1
  7. package/dist/cjs/DynamicRangeSlider.js +1 -1
  8. package/dist/cjs/MultiDropdownList.js +2 -2
  9. package/dist/cjs/MultiList.js +1 -1
  10. package/dist/cjs/MultiRange.js +1 -1
  11. package/dist/cjs/RangeInput.js +1 -1
  12. package/dist/cjs/RangeSlider.js +1 -1
  13. package/dist/cjs/ReactiveBase.js +13 -7
  14. package/dist/cjs/ReactiveComponent.js +1 -1
  15. package/dist/cjs/ReactiveList.js +1 -1
  16. package/dist/cjs/ResultCard.js +1 -1
  17. package/dist/cjs/ResultList.js +1 -1
  18. package/dist/cjs/SelectedFilters.js +1 -1
  19. package/dist/cjs/SingleDropdownList.js +2 -2
  20. package/dist/cjs/SingleList.js +1 -1
  21. package/dist/cjs/SingleRange.js +1 -1
  22. package/dist/cjs/ToggleButton.js +1 -1
  23. package/dist/cjs/index.js +2 -2
  24. package/dist/cjs/install.js +2 -2
  25. package/dist/cjs/version.js +1 -1
  26. package/dist/cjs/{vueTypes-22b4fd3a.js → vueTypes-4c19b4c8.js} +5 -1
  27. package/dist/es/DataSearch.js +1 -1
  28. package/dist/es/{DropDown-db7fe433.js → DropDown-035c804f.js} +1 -1
  29. package/dist/es/DynamicRangeSlider.js +1 -1
  30. package/dist/es/MultiDropdownList.js +2 -2
  31. package/dist/es/MultiList.js +1 -1
  32. package/dist/es/MultiRange.js +1 -1
  33. package/dist/es/RangeInput.js +1 -1
  34. package/dist/es/RangeSlider.js +1 -1
  35. package/dist/es/ReactiveBase.js +13 -7
  36. package/dist/es/ReactiveComponent.js +1 -1
  37. package/dist/es/ReactiveList.js +1 -1
  38. package/dist/es/ResultCard.js +1 -1
  39. package/dist/es/ResultList.js +1 -1
  40. package/dist/es/SelectedFilters.js +1 -1
  41. package/dist/es/SingleDropdownList.js +2 -2
  42. package/dist/es/SingleList.js +1 -1
  43. package/dist/es/SingleRange.js +1 -1
  44. package/dist/es/ToggleButton.js +1 -1
  45. package/dist/es/index.js +2 -2
  46. package/dist/es/install.js +2 -2
  47. package/dist/es/version.js +1 -1
  48. package/dist/es/{vueTypes-e89c8a3c.js → vueTypes-fb61bb7b.js} +5 -1
  49. package/package.json +3 -3
@@ -8398,6 +8398,11 @@
8398
8398
  var value = internalValue && internalValue.value || '';
8399
8399
 
8400
8400
  if (isAppbaseEnabled && (componentProps.enablePopularSuggestions || componentProps.enableQuerySuggestions)) {
8401
+ if (config.mongodb) {
8402
+ dispatch((0, misc.setDefaultPopularSuggestions)([], componentId.split('__internal')[0]));
8403
+ return;
8404
+ }
8405
+
8401
8406
  var suggQuery = (0, utils.getSuggestionQuery)(getState, componentId);
8402
8407
  appbaseRef.getQuerySuggestions(suggQuery).then(function (suggestions) {
8403
8408
  var querySuggestion = suggestions[(0, utils.getQuerySuggestionsId)(componentId)];
@@ -9128,7 +9133,8 @@
9128
9133
  protocol = _getState$appbaseRef.protocol,
9129
9134
  credentials = _getState$appbaseRef.credentials;
9130
9135
 
9131
- var app = config.app;
9136
+ var app = config.app,
9137
+ mongodb = config.mongodb;
9132
9138
  var esURL = protocol + '://' + url;
9133
9139
  var parsedURL = (esURL || '').replace(/\/+$/, '');
9134
9140
  var requestOptions = {
@@ -9175,7 +9181,14 @@
9175
9181
  }
9176
9182
  }
9177
9183
 
9178
- fetch(parsedURL + '/_analytics/' + app + '/recent-searches?' + queryString, requestOptions).then(function (res) {
9184
+ if (mongodb) {
9185
+ return dispatch({
9186
+ type: constants.RECENT_SEARCHES_SUCCESS,
9187
+ data: []
9188
+ });
9189
+ }
9190
+
9191
+ return fetch(parsedURL + '/_analytics/' + app + '/recent-searches?' + queryString, requestOptions).then(function (res) {
9179
9192
  if (res.status >= 500 || res.status >= 400) {
9180
9193
  return dispatch({
9181
9194
  type: constants.RECENT_SEARCHES_ERROR,
@@ -12780,7 +12793,11 @@
12780
12793
  userId: VueTypes.string,
12781
12794
  customEvents: VueTypes.object,
12782
12795
  enableTelemetry: VueTypes.bool.def(true)
12783
- }).def({})
12796
+ }).def({}),
12797
+ mongodb: VueTypes.shape({
12798
+ db: VueTypes.string,
12799
+ collection: VueTypes.string
12800
+ })
12784
12801
  };
12785
12802
 
12786
12803
  var getClassName = lib_8.getClassName,
@@ -15405,8 +15422,33 @@
15405
15422
  return encodedHeaders;
15406
15423
  }
15407
15424
 
15408
- function getTelemetryHeaders(enableTelemetry) {
15425
+ function getMongoRequest(app, mongo) {
15426
+ var mongodb = {};
15427
+
15428
+ if (app) {
15429
+ mongodb.index = app;
15430
+ }
15431
+
15432
+ if (mongo) {
15433
+ if (mongo.db) {
15434
+ mongodb.db = mongo.db;
15435
+ }
15436
+
15437
+ if (mongo.collection) {
15438
+ mongodb.collection = mongo.collection;
15439
+ }
15440
+ }
15441
+
15442
+ return mongodb;
15443
+ }
15444
+
15445
+ function getTelemetryHeaders(enableTelemetry, shouldSetHeaders) {
15409
15446
  var headers = {};
15447
+
15448
+ if (!shouldSetHeaders) {
15449
+ return headers;
15450
+ }
15451
+
15410
15452
  Object.assign(headers, {
15411
15453
  'X-Search-Client': 'Appbase JS'
15412
15454
  });
@@ -15419,6 +15461,133 @@
15419
15461
 
15420
15462
  return headers;
15421
15463
  }
15464
+
15465
+ var backendAlias = {
15466
+ MONGODB: 'mongodb',
15467
+ // mongodb
15468
+ ELASTICSEARCH: 'elasticsearch' // elasticsearch
15469
+
15470
+ };
15471
+ var dataTypes = {
15472
+ ARRAY: 'array',
15473
+ FUNCTION: 'function',
15474
+ OBJECT: 'object',
15475
+ NUMBER: 'number',
15476
+ BOOLEAN: 'boolean',
15477
+ STRING: 'string'
15478
+ };
15479
+
15480
+ var checkDataType = function checkDataType(temp) {
15481
+ // eslint-disable-next-line
15482
+ if ((typeof temp === 'undefined' ? 'undefined' : _typeof$1(temp)) === dataTypes.OBJECT) {
15483
+ if (Array.isArray(temp)) {
15484
+ return dataTypes.ARRAY;
15485
+ }
15486
+
15487
+ return dataTypes.OBJECT;
15488
+ }
15489
+
15490
+ return typeof temp === 'undefined' ? 'undefined' : _typeof$1(temp);
15491
+ };
15492
+
15493
+ function validateSchema() {
15494
+ var passedProperties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15495
+ var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15496
+ var backendName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
15497
+ var passedPropertiesKeys = Object.keys(passedProperties).filter(function (propertyKey) {
15498
+ return !!passedProperties[propertyKey];
15499
+ });
15500
+ var acceptedProperties = Object.keys(schema);
15501
+ var requiredProperties = []; // fetch required properties
15502
+
15503
+ acceptedProperties.forEach(function (propName) {
15504
+ var currentProperty = schema[propName];
15505
+
15506
+ if (currentProperty.required) {
15507
+ requiredProperties.push(propName);
15508
+ }
15509
+ }); // check for required properties
15510
+
15511
+ requiredProperties.forEach(function (requiredProperty) {
15512
+ if (!passedPropertiesKeys.includes(requiredProperty)) {
15513
+ throw new Error(requiredProperty + ' is required when using the ' + backendName + ' Search backend.');
15514
+ }
15515
+ }); // check for accepted properties
15516
+
15517
+ passedPropertiesKeys.forEach(function (passedPropertyKey) {
15518
+ if (!acceptedProperties.includes(passedPropertyKey)) {
15519
+ throw new Error(passedPropertyKey + ' property isn\'t accepted property by ' + backendName + ' backend.');
15520
+ }
15521
+
15522
+ var acceptedTypes = Array.isArray(schema[passedPropertyKey].type) ? schema[passedPropertyKey].type : [].concat(schema[passedPropertyKey].type);
15523
+ var receivedPropertyType = checkDataType(passedProperties[passedPropertyKey]);
15524
+
15525
+ if (!acceptedTypes.includes(receivedPropertyType)) {
15526
+ throw new Error('The property ' + passedPropertyKey + ' is expected with type(s) [' + acceptedTypes.join(', ') + '], but type was set as ' + receivedPropertyType + '.');
15527
+ }
15528
+ });
15529
+ }
15530
+
15531
+ var mongodb = {
15532
+ url: {
15533
+ type: dataTypes.STRING,
15534
+ required: true
15535
+ },
15536
+ app: {
15537
+ type: dataTypes.STRING,
15538
+ required: false
15539
+ },
15540
+ credentials: {
15541
+ type: dataTypes.STRING,
15542
+ required: false
15543
+ },
15544
+ enableTelemetry: {
15545
+ type: dataTypes.BOOLEAN,
15546
+ required: false
15547
+ },
15548
+ mongodb: {
15549
+ type: dataTypes.OBJECT,
15550
+ required: true
15551
+ },
15552
+ username: {
15553
+ type: dataTypes.STRING,
15554
+ required: false
15555
+ },
15556
+ password: {
15557
+ type: dataTypes.STRING,
15558
+ required: false
15559
+ }
15560
+ };
15561
+ var elasticsearch = {
15562
+ url: {
15563
+ type: dataTypes.STRING,
15564
+ required: true
15565
+ },
15566
+ app: {
15567
+ type: dataTypes.STRING,
15568
+ required: true
15569
+ },
15570
+ credentials: {
15571
+ type: dataTypes.STRING,
15572
+ required: false
15573
+ },
15574
+ enableTelemetry: {
15575
+ type: dataTypes.BOOLEAN,
15576
+ required: false
15577
+ },
15578
+ username: {
15579
+ type: dataTypes.STRING,
15580
+ required: false
15581
+ },
15582
+ password: {
15583
+ type: dataTypes.STRING,
15584
+ required: false
15585
+ }
15586
+ };
15587
+ var SCHEMA = {
15588
+ mongodb: mongodb,
15589
+ elasticsearch: elasticsearch
15590
+ };
15422
15591
  /**
15423
15592
  * Returns an instance of Appbase client
15424
15593
  * @param {Object} config To configure properties
@@ -15428,10 +15597,10 @@
15428
15597
  * @param {String} config.username
15429
15598
  * @param {String} config.password
15430
15599
  * @param {Boolean} config.enableTelemetry
15600
+ * @param {Object} config.mongodb
15431
15601
  * A callback function which will be invoked before a fetch request made
15432
15602
  */
15433
15603
 
15434
-
15435
15604
  function AppBase(config) {
15436
15605
  var _URL = urlParserLite(config.url || ''),
15437
15606
  _URL$auth = _URL.auth,
@@ -15443,30 +15612,42 @@
15443
15612
  _URL$protocol = _URL.protocol,
15444
15613
  protocol = _URL$protocol === undefined ? '' : _URL$protocol;
15445
15614
 
15446
- var url = host + path; // Validate config and throw appropriate error
15615
+ var url = config.url;
15616
+ url = host + path; // Parse url
15447
15617
 
15448
- if (typeof url !== 'string' || url === '') {
15449
- throw new Error('URL not present in options.');
15618
+ if (url.slice(-1) === '/') {
15619
+ url = url.slice(0, -1);
15450
15620
  }
15451
15621
 
15452
- if (typeof config.app !== 'string' || config.app === '') {
15453
- throw new Error('App name is not present in options.');
15454
- }
15622
+ var backendName = backendAlias[config.mongodb ? 'MONGODB' : 'ELASTICSEARCH']; // eslint-disable-next-line
15623
+
15624
+ var schema = SCHEMA[backendName];
15625
+ validateSchema({
15626
+ url: config.url,
15627
+ app: config.app,
15628
+ credentials: config.credentials,
15629
+ username: config.username,
15630
+ password: config.password,
15631
+ enableTelemetry: config.enableTelemetry,
15632
+ mongodb: config.mongodb
15633
+ }, schema, backendName);
15455
15634
 
15456
15635
  if (typeof protocol !== 'string' || protocol === '') {
15457
15636
  throw new Error('Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io');
15458
- } // Parse url
15459
-
15460
-
15461
- if (url.slice(-1) === '/') {
15462
- url = url.slice(0, -1);
15463
15637
  }
15464
15638
 
15465
15639
  var credentials = auth || null;
15640
+
15641
+ if (!config.mongodb) {
15642
+ if (isAppbase(url) && credentials === null) {
15643
+ throw new Error('Authentication information is not present. Did you add credentials?');
15644
+ }
15645
+ }
15466
15646
  /**
15467
15647
  * Credentials can be provided as a part of the URL,
15468
15648
  * as username, password args or as a credentials argument directly */
15469
15649
 
15650
+
15470
15651
  if (typeof config.credentials === 'string' && config.credentials !== '') {
15471
15652
  // eslint-disable-next-line
15472
15653
  credentials = config.credentials;
@@ -15474,15 +15655,15 @@
15474
15655
  credentials = config.username + ':' + config.password;
15475
15656
  }
15476
15657
 
15477
- if (isAppbase(url) && credentials === null) {
15478
- throw new Error('Authentication information is not present. Did you add credentials?');
15479
- }
15480
-
15481
15658
  this.url = url;
15482
15659
  this.protocol = protocol;
15483
15660
  this.app = config.app;
15484
15661
  this.credentials = credentials;
15485
15662
 
15663
+ if (config.mongodb) {
15664
+ this.mongodb = config.mongodb;
15665
+ }
15666
+
15486
15667
  if (typeof config.enableTelemetry === 'boolean') {
15487
15668
  this.enableTelemetry = config.enableTelemetry;
15488
15669
  }
@@ -15511,7 +15692,9 @@
15511
15692
  params = parsedArgs.params,
15512
15693
  body = parsedArgs.body,
15513
15694
  isRSAPI = parsedArgs.isRSAPI,
15514
- isSuggestionsAPI = parsedArgs.isSuggestionsAPI;
15695
+ isSuggestionsAPI = parsedArgs.isSuggestionsAPI,
15696
+ _parsedArgs$isMongoRe = parsedArgs.isMongoRequest,
15697
+ isMongoRequest = _parsedArgs$isMongoRe === undefined ? false : _parsedArgs$isMongoRe;
15515
15698
  var app = isSuggestionsAPI ? '.suggestions' : _this.app;
15516
15699
  var bodyCopy = body;
15517
15700
  var contentType = path.endsWith('msearch') || path.endsWith('bulk') ? 'application/x-ndjson' : 'application/json';
@@ -15562,7 +15745,7 @@
15562
15745
  paramsString = '?' + querystring.stringify(params);
15563
15746
  }
15564
15747
 
15565
- var finalURL = _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString;
15748
+ var finalURL = _this.mongodb ? _this.protocol + '://' + _this.url : _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString;
15566
15749
  return handleTransformRequest(Object.assign({}, {
15567
15750
  url: finalURL
15568
15751
  }, requestOptions)).then(function (ts) {
@@ -15571,7 +15754,7 @@
15571
15754
  delete transformedRequest.url;
15572
15755
  return browserPonyfill$1(url || finalURL, Object.assign({}, transformedRequest, {
15573
15756
  // apply timestamp header for RS API
15574
- headers: isRSAPI ? Object.assign({}, transformedRequest.headers, {
15757
+ headers: isRSAPI && !isMongoRequest ? Object.assign({}, transformedRequest.headers, {
15575
15758
  'x-timestamp': new Date().getTime()
15576
15759
  }) : transformedRequest.headers
15577
15760
  })).then(function (res) {
@@ -15936,12 +16119,20 @@
15936
16119
  settings: parsedSettings,
15937
16120
  query: query
15938
16121
  };
16122
+
16123
+ if (this.mongodb) {
16124
+ Object.assign(body, {
16125
+ mongodb: getMongoRequest(this.app, this.mongodb)
16126
+ });
16127
+ }
16128
+
15939
16129
  return this.performFetchRequest({
15940
16130
  method: 'POST',
15941
16131
  path: '_reactivesearch',
15942
16132
  body: body,
15943
- headers: getTelemetryHeaders(this.enableTelemetry),
15944
- isRSAPI: true
16133
+ headers: getTelemetryHeaders(this.enableTelemetry, !this.mongodb),
16134
+ isRSAPI: true,
16135
+ isMongoRequest: !!this.mongodb
15945
16136
  });
15946
16137
  }
15947
16138
  /**
@@ -15968,12 +16159,20 @@
15968
16159
  settings: parsedSettings,
15969
16160
  query: query
15970
16161
  };
16162
+
16163
+ if (this.mongodb) {
16164
+ Object.assign(body, {
16165
+ mongodb: getMongoRequest(this.app, this.mongodb)
16166
+ });
16167
+ }
16168
+
15971
16169
  return this.performFetchRequest({
15972
16170
  method: 'POST',
15973
16171
  path: '_reactivesearch.v3',
15974
16172
  body: body,
15975
- headers: getTelemetryHeaders(this.enableTelemetry),
15976
- isRSAPI: true
16173
+ headers: getTelemetryHeaders(this.enableTelemetry, !this.mongodb),
16174
+ isRSAPI: true,
16175
+ isMongoRequest: !!this.mongodb
15977
16176
  });
15978
16177
  }
15979
16178
  /**
@@ -16011,13 +16210,21 @@
16011
16210
  settings: parsedSettings,
16012
16211
  query: query
16013
16212
  };
16213
+
16214
+ if (this.mongodb) {
16215
+ Object.assign(body, {
16216
+ mongodb: getMongoRequest(this.app, this.mongodb)
16217
+ });
16218
+ }
16219
+
16014
16220
  return this.performFetchRequest({
16015
16221
  method: 'POST',
16016
16222
  path: '_reactivesearch.v3',
16017
16223
  body: body,
16018
16224
  headers: getTelemetryHeaders(this.enableTelemetry),
16019
16225
  isRSAPI: true,
16020
- isSuggestionsAPI: true
16226
+ isSuggestionsAPI: true,
16227
+ isMongoRequest: !!this.mongodb
16021
16228
  });
16022
16229
  }
16023
16230
 
@@ -16749,7 +16956,7 @@
16749
16956
  }
16750
16957
  },
16751
16958
  props: {
16752
- app: types.stringRequired,
16959
+ app: types.string,
16753
16960
  analytics: VueTypes.bool,
16754
16961
  analyticsConfig: types.analyticsConfig,
16755
16962
  appbaseConfig: types.appbaseConfig,
@@ -16769,7 +16976,8 @@
16769
16976
  transformResponse: types.func,
16770
16977
  as: VueTypes.string.def('div'),
16771
16978
  getSearchParams: types.func,
16772
- setSearchParams: types.func
16979
+ setSearchParams: types.func,
16980
+ mongodb: types.mongodb
16773
16981
  },
16774
16982
  provide: function provide() {
16775
16983
  return {
@@ -16809,6 +17017,9 @@
16809
17017
  this.store.dispatch(analytics_3$1(newVal));
16810
17018
  }
16811
17019
  }
17020
+ },
17021
+ mongodb: function mongodb() {
17022
+ this.updateState(this.$props);
16812
17023
  }
16813
17024
  },
16814
17025
  computed: {
@@ -16816,12 +17027,13 @@
16816
17027
  var _this$$props = this.$props,
16817
17028
  enableAppbase = _this$$props.enableAppbase,
16818
17029
  headers = _this$$props.headers,
16819
- appbaseConfig = _this$$props.appbaseConfig;
17030
+ appbaseConfig = _this$$props.appbaseConfig,
17031
+ mongodb = _this$$props.mongodb;
16820
17032
 
16821
17033
  var _ref = appbaseConfig || {},
16822
17034
  enableTelemetry = _ref.enableTelemetry;
16823
17035
 
16824
- return _extends({}, enableAppbase && _extends({
17036
+ return _extends({}, enableAppbase && !mongodb && _extends({
16825
17037
  'X-Search-Client': X_SEARCH_CLIENT
16826
17038
  }, enableTelemetry === false && {
16827
17039
  'X-Enable-Telemetry': false
@@ -16839,7 +17051,7 @@
16839
17051
  var appbaseConfig = _extends({}, props.analyticsConfig, props.appbaseConfig);
16840
17052
 
16841
17053
  var config = {
16842
- url: props.url && props.url.trim() !== '' ? props.url : 'https://scalr.api.appbase.io',
17054
+ url: props.url && props.url.trim() !== '' ? props.url : '',
16843
17055
  app: props.app,
16844
17056
  credentials: credentials,
16845
17057
  type: props.type ? props.type : '*',
@@ -16847,7 +17059,8 @@
16847
17059
  transformResponse: props.transformResponse,
16848
17060
  enableAppbase: props.enableAppbase,
16849
17061
  analytics: props.appbaseConfig ? props.appbaseConfig.recordAnalytics : props.analytics,
16850
- analyticsConfig: appbaseConfig
17062
+ analyticsConfig: appbaseConfig,
17063
+ mongodb: props.mongodb
16851
17064
  };
16852
17065
  var queryParams = '';
16853
17066
 
@@ -26095,7 +26308,7 @@
26095
26308
  });
26096
26309
  }
26097
26310
 
26098
- var version = "1.23.4";
26311
+ var version = "1.24.0";
26099
26312
 
26100
26313
  var _templateObject$n, _templateObject2$a;
26101
26314