UNPKG

@sanity/form-builder

Version:
26 lines (24 loc) 900 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.search = search; var _operators = require("rxjs/operators"); var _internal = require("@sanity/base/_internal"); // eslint-disable-next-line camelcase function search(client, textTerm, type, options) { var searchWeighted = (0, _internal.createWeightedSearch)(type.to.map(crossDatasetType => ({ name: crossDatasetType.type, // eslint-disable-next-line camelcase __experimental_search: crossDatasetType.__experimental_search })), client, options); return searchWeighted(textTerm, { includeDrafts: false }).pipe( // pick the 100 best matches (0, _operators.map)(results => results.map(result => result.hit)), (0, _operators.map)(_internal.collate), (0, _operators.map)(collated => collated.map(entry => ({ id: entry.id, type: entry.type, published: entry.published })))); }