Giter VIP home page Giter VIP logo

reactivecore's Introduction

reactivecore

npm version

This is the platform agnostic core architecture of reactive UI libraries.

Installation

yarn add @appbaseio/reactivecore

Usage and documentation

Create store:

import configureStore from "@appbaseio/reactivecore";

Supported actions:

Import via:

import { <actionName> } from "@appbaseio/reactivecore/lib/actions"
Action Usage
addComponent to register a component in the store
removeComponent to remove a component from the store
watchComponent to set up component subscription
setQuery to set the component query in the store
setQueryOptions to add external query options
logQuery Executed automatically to log query for gatekeeping
executeQuery Executed automatically (whenever necessary, based on the dependency tree) when the query of a component is updated
updateHits updates results from elasticsearch query
updateQuery to update the query in the store - called when a change is triggered in the component
loadMore for infinte loading and pagination

Utility methods

Import via:

import { <methodName> } from "@appbaseio/reactivecore/lib/utils"
Method Usage
isEqual Compare two objects/arrays
debounce Standard debounce
getQueryOptions returns applied query options (supports size & from)
pushToAndClause Pushes component to leaf and node. Handy for internal component registration
checkValueChange checks and executes before/onValueChange for sensors
getAggsOrder returns aggs order query based on sortBy prop
checkPropChange checks for props changes that would need to update the query via callback
checkSomePropChange checks for any prop change in the propsList and invokes the callback

Changelog

Check the Changelog doc

reactivecore's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

reactivecore's Issues

Suggestion filtering hides synonyms

I've enabled synonym support in my elasticsearch, which means, for example, end users might search for "trousers" and get back results that do not contain "trousers" but do contain "pants". I think that getSuggestions is hiding these results. Have you put any thought into this scenario? I think I understand what the filtering here is trying to do, which is handle when the user has changed their search term by the time results come back ( right? ), but in my case it's hiding results I'd still like to see.

TypeError: i.toLowerCase is not a function

Auto suggest throws TypeError: i.toLowerCase is not a function when parseField hits a null label. label checking in parseField needs to be more defensive and force value to string before performing a toLowerCase()

autosuggest fails on null values

We are utilizing reactivesearch to query some Elastic data. We are utilizing the showMissing prop option on several filters that are using MultiList. Our understanding is that missing/null data is necessary for showMissing to function and this is all working.

There is also a DataSearch. Today, I was asked to connect the DataSearch to more dataFields and some of those fields are null for some records. For the showMissing to function, I can't (as far as I know) avoid having these null values. When I added the additional fields to the DataSearch's dataFields, the app would crash as soon as I typed anything into the input.

Stack trace showed it was crashing at the str.replace in replaceDiacritics (in suggestions.js) because str had a value of null:

function replaceDiacritics(s) {
	let str = s ? String(s) : s;

	const diacritics = [
		/[\300-\306]/g, /[\340-\346]/g, // A, a
		/[\310-\313]/g, /[\350-\353]/g, // E, e
		/[\314-\317]/g, /[\354-\357]/g, // I, i
		/[\322-\330]/g, /[\362-\370]/g, // O, o
		/[\331-\334]/g, /[\371-\374]/g, // U, u
		/[\321]/g, /[\361]/g, // N, n
		/[\307]/g, /[\347]/g, // C, c
	];

	const chars = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u', 'N', 'n', 'C', 'c'];

	for (let i = 0; i < diacritics.length; i += 1) {
		str = str.replace(diacritics[i], chars[i]); // crash here
	}

	return str;
}

I won't say this is the best fix, but I put a band-aid on the issue by changing

const populateSuggestionsList = (val, parsedSource, source) => {
		// check if the suggestion includes the current value
		// and not already included in other suggestions
		const isWordMatch = skipWordMatch || currentValue
                .....

into

const populateSuggestionsList = (val, parsedSource, source) => {
		// check if the suggestion includes the current value
		// and not already included in other suggestions
                val = val ? val : ''; // new
		const isWordMatch = skipWordMatch || currentValue
                .....

There may be reasons I'm not aware of that you wouldn't want to support the possibility of autosuggest encountering null values, but I thought I would open the issue to inquire if this was the intended behavior.

Multiple Queries

Hi

I have a ReactiveComponent in the form of an single input that sets a custom query, a RangeSlider with a custom query and a ReactiveList. When the page loads the query from the reactive component loads into the search results and then the same query loads but with the addition of the custom query from the RangeSlider.

I would rather the ReactiveList didnt do anything until it considered what was coming from the RangeSlider. I cant see any way of using the react prop to stop this happening?

Suggestion filtering ignores+removes 'highlight' from ElasticSearch hits

ReactiveSearch.DataSearch component provides properties for customHighlight and parseSuggestion to customise suggestions for current search input. Unfortunately it appears the highlight entry of the returned ES hits are being neglected/discarded during the query result processing here. (the customHighlight query configuration is properly included in the query sent to ES though!)

Maybe I miss something but it seems to be caused by calling getSuggestions of this packages utils/suggestions.js module as can be seen in onSuggestions( query.result ) call here for WEB Version or Vue.js Version.

If the above is true, would it be possible to add/maintain highlight either as new field in suggestions option dict, e.g. suggestion.highlight or as entry in the suggestion.source field e.g. suggestion.source._highlight?

NOTE: highlight may? not be present in hits/query result if customHighlight is not configured

ReactiveSearch is now requiring Vue.js dependency

Not sure if I should post this here or on the ReactiveSearch repo.

I have had ReactiveSearch running great. Two days ago I started getting errors because it is requiring Vue.js as a dependency. I'm using this on a React app, and though I have things working now that I have installed Vue, but I really don't want to have to include Vue unnecessarily.

Can someone explain why Vue is a dependency

Mutation of returned _source data in results by highlightResults function

When a user specifies they want their data to be highlighted the highlighted data returns a truncated portion in the _source.

Please see my comments below. I didn't think a pull request was appropriate as all I would be doing is deleting a function.

Is there a reason for mutating the source of the highlighted data?

Best,
Ryan

// src/utils/helper.js


// Why are we mutating the original _source object here?  
// This takes away information for the end-user given by elasticsearch

// My use case of ElasticSearch is to store parsed pdfs as strings 
// These contain 1000+ chars each

// The highlighted information given by elasticsearch have many fewer characters than this. 
// Around 100 chars 

// I want to be able to send the whole of the information to the end-user in the results

// If you remove this function (highlightResults)
// the user still retains the highlighted information in the main result object
//  and the original _source information

const highlightResults = (result) => {
	const data = { ...result };
	if (data.highlight) {
		Object.keys(data.highlight).forEach((highlightItem) => {
			const highlightValue = data.highlight[highlightItem][0];
			data._source = Object.assign({}, data._source, { [highlightItem]: highlightValue });
		});
	}
	return data;
};

export const parseHits = (hits) => {
	let results = null;
	if (hits) {
		results = [...hits].map((item) => {
			const streamProps = {};

			if (item._updated) {
				streamProps._updated = item._updated;
			} else if (item._deleted) {
				streamProps._deleted = item._deleted;
			}



                        // no need to mutate the data! below

			const data = highlightResults(item);

			return {
				_id: data._id,
				_index: data._index,
				...data._source,
				...streamProps,
			};
		});
	}
	return results;
};

isLoading property is not maintained properly.

Expected behavior:
isLoading property must be true while executing a request & set to false when it's completed.

Current behavior:
Initially isLoading is undefined, after making request it turned out to be false & remains the same.

Error on response after modifying request API from _msearch to _search

Affected Projects: Reactivesearch / ReactiveCore

Library Version: 3.0.1

Describe the bug
Using the Reactivesearch documentation as a baseline, I changed the request API endpoint as follow:
image
The request was processed nicely by Elasticsearch. However, the following error was thrown while the library was processing the response:
image
As I checked, the problem is that the handleResponse method tries to directly access a "responses" property from the body, and the search API doesn't return an array of responses - it returns a single response.
image

To Reproduce
Steps to reproduce the behavior:
Just modify any request using transformRequest as described above.

Expected behavior
The single response from the _search API should be processed succesfully.

Bug: DataSearch suggestions crashes the app

How I am using DataSearch:

<DataSearch
                className="datasearch"
                componentId="q"
                dataField={["Vendor_Short", "Vendor_Short.raw", "Vendor_Short.search", "P21_Part_#", "P21_Part_#.search", "P21_Part_#.raw", "Description", "Description.raw", "Description.search", "Description_2", "Description_2.raw", "Description_2.search", "Description_3", "Description_3.raw", "Description_3.search", "Description_4", "Description_4.raw", "Description_4.search"]}
                placeholder="Search by Part No or Manufacturer"
                innerClass={{
                  "input": "searchbox",
                  "list": "suggestionlist"
                }}
                defaultSuggestions={[{
                  "label": "Ge Mao Rubber",
                  "value": "Ge Mao Rubber"
                }, {
                  "label": "VOR232",
                  "value": "VOR232"
                }, {
                  "label": "Les Joints",
                  "value": "les joints"
                }]}
                autosuggest={true}
                iconPosition="left"
                filterLabel="search"
                URLParams={true}
              />

All the fields in the dataField array of Text / Keyword / Search / Autosuggest type (no nesting of fields anywhere).

Console Error I see:

Allow customization of GraphQL fetch

The GraphQL fetch should allow for more custumization:

  • Currently the fetch call is fixed to query elastic50, feels weird to have to use elastic50 as my query name even if I'm using 7.2

  • enforces the usage of a host parameter(which I dont use as the graphql proxy takes care of the host + credentials, therefore resulting in an error for me)

  • Uses content type application/graphql while lots of implementations like Apollo seem to prefer application/json

  • ReactiveBase could take a transformRequest parameter, which seems to be ignored in case graphQLUrl is used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.