Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/graphql / src / endpoints / search / transform.ts
Size: Mime:
import get from 'lodash/get'
import { isSafe } from 'uxui-modules/exotic'
import { defaultSuggestionList } from './fixture'

function processFeatureNotBugPipes(data) {
  // data.split('|||')
  console.warn('processFeatureNotBugPipes @todo')
}
// data.properties.suggestion[0].value
const searchSuggestionMap = {
  label: 'properties.suggestion.0.label',
  value: 'properties.suggestion.0.value',
}
function flattenSnap(snapshot = {}) {
  Object.keys(searchSuggestionMap).forEach(key => {
    // here would do toDefault(get(types[key])) for fallback
    // defaulting to empty string for now though
    const longPath = searchSuggestionMap[key]
    snapshot[key] = get(snapshot, longPath, '')
  })

  // hot reloader really messes with toArray ;-(
  snapshot.value = Array.prototype.concat.apply([], [snapshot.value])

  const isEmptyResult = snapshot.value.length === 0 || snapshot.value[0] === ''
  if (isEmptyResult) {
    snapshot.value = defaultSuggestionList
  }
  return snapshot
}

export { flattenSnap, processFeatureNotBugPipes }
export default flattenSnap