UNPKG

@rcsb/rcsb-saguaro-app

Version:
74 lines (73 loc) 3.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.searchRequestProperty = void 0; const tslib_1 = require("tslib"); const RcsbRequestClient_1 = require("../RcsbRequest/RcsbRequestClient"); const SearchQueryTools_1 = require("./SearchQueryTools"); class SearchRequestProperty { constructor(getClient) { this.getClient = getClient; } _requestFacets(config) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const facet = config.facets.shift(); return yield this.getClient().request({ query: config.query, request_options: facet ? { paginate: { start: 0, rows: 0 }, facets: [facet, ...config.facets], results_content_type: config.resultsContentType } : { paginate: { start: 0, rows: 0 }, results_content_type: config.resultsContentType }, return_type: config.returnType }); }); } requestFacets(query, facets, returnType, resultsContentType) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return this._requestFacets({ query: query, facets: facets, returnType: returnType, resultsContentType: resultsContentType }); }); } //TODO this should be part of `SearchQueryTools` requestMembers(query) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b, _c; return (_c = (_b = (_a = (yield this.getClient().request({ query: query.query, request_options: { return_all_hits: true, results_content_type: SearchQueryTools_1.SearchQueryTools.searchContentType(query) }, return_type: query.return_type }))) === null || _a === void 0 ? void 0 : _a.result_set) === null || _b === void 0 ? void 0 : _b.map(item => typeof item === "string" ? item : item.identifier)) !== null && _c !== void 0 ? _c : []; }); } //TODO this should be part of `SearchQueryTools` requestCount(query) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b; return (_b = (_a = (yield this.getClient().request({ query: query.query, request_options: { return_counts: true, results_content_type: SearchQueryTools_1.SearchQueryTools.searchContentType(query) }, return_type: query.return_type }))) === null || _a === void 0 ? void 0 : _a.total_count) !== null && _b !== void 0 ? _b : -1; }); } request(query) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield this.getClient().request(query); }); } } exports.searchRequestProperty = new SearchRequestProperty(() => RcsbRequestClient_1.rcsbRequestClient.arches);