@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
71 lines • 3.01 kB
JavaScript
import { __awaiter } from "tslib";
import { rcsbRequestClient } from "../RcsbRequest/RcsbRequestClient";
import { SearchQueryTools as SQT } from "./SearchQueryTools";
class SearchRequestProperty {
constructor(getClient) {
this.getClient = getClient;
}
_requestFacets(config) {
return __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 __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 __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: SQT.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 __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: SQT.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 __awaiter(this, void 0, void 0, function* () {
return yield this.getClient().request(query);
});
}
}
export const searchRequestProperty = new SearchRequestProperty(() => rcsbRequestClient.arches);
//# sourceMappingURL=SearchRequestProperty.js.map