UNPKG

@atlaskit/global-search

Version:

A cross-product search component (batteries included)

36 lines (30 loc) 2.56 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } import CachingConfluenceClient from './CachingConfluenceClient'; import { CachingPeopleSearchClient } from './CachingPeopleSearchClient'; import CachingCrossProductSearchClientImpl from './CrossProductSearchClient'; import JiraClientImpl from './JiraClient'; import { AutocompleteClientImpl } from './AutocompleteClient'; import memoizeOne from 'memoize-one'; import deepEqual from 'deep-equal'; var defaultConfig = { activityServiceUrl: '/gateway/api/activity', searchAggregatorServiceUrl: '/gateway/api/xpsearch-aggregator', directoryServiceUrl: '/gateway/api/directory', confluenceUrl: '/wiki', jiraUrl: '', autocompleteUrl: '/gateway/api/ccsearch-autocomplete' }; function configureSearchClients(cloudId, partialConfig, isUserAnonymous, prefetchedResults) { var config = _objectSpread(_objectSpread({}, defaultConfig), partialConfig); var confluencePrefetchedResults = prefetchedResults && prefetchedResults.confluenceRecentItemsPromise ? prefetchedResults.confluenceRecentItemsPromise : undefined; return { crossProductSearchClient: new CachingCrossProductSearchClientImpl(config.searchAggregatorServiceUrl, cloudId, isUserAnonymous, prefetchedResults), peopleSearchClient: new CachingPeopleSearchClient(config.directoryServiceUrl, cloudId), confluenceClient: new CachingConfluenceClient(config.confluenceUrl, confluencePrefetchedResults), autocompleteClient: new AutocompleteClientImpl(config.autocompleteUrl, cloudId), jiraClient: new JiraClientImpl(config.jiraUrl, cloudId, isUserAnonymous) }; } export default memoizeOne(configureSearchClients, deepEqual);