@rcsb/rcsb-search-tools 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { SearchBucketFacetType } from "./SearchFacetInterface";
|
|
2
|
-
import { QueryResult } from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchResultInterface";
|
|
2
|
+
import { BucketFacet, QueryResult, SingleValueMetricsFacet } from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchResultInterface";
|
|
3
3
|
export declare function getFacetsFromSearch(searchResult: QueryResult): SearchBucketFacetType[];
|
|
4
|
+
export declare function getBucketsFromFacets(searchResultFacets: (BucketFacet | SingleValueMetricsFacet)[], labelList?: string[], recursiveOut?: SearchBucketFacetType[]): SearchBucketFacetType[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFacetsFromSearch = void 0;
|
|
3
|
+
exports.getBucketsFromFacets = exports.getFacetsFromSearch = void 0;
|
|
4
4
|
function getFacetsFromSearch(searchResult) {
|
|
5
5
|
if (!searchResult.facets)
|
|
6
6
|
return [];
|
|
@@ -11,7 +11,8 @@ function getBucketsFromFacets(searchResultFacets, labelList, recursiveOut) {
|
|
|
11
11
|
const out = recursiveOut !== null && recursiveOut !== void 0 ? recursiveOut : [];
|
|
12
12
|
const facets = collectFacets(searchResultFacets);
|
|
13
13
|
facets.forEach(bucketFacet => {
|
|
14
|
-
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const innerFacets = (_b = (_a = bucketFacet.buckets) === null || _a === void 0 ? void 0 : _a.filter(g => Array.isArray(g.facets))) !== null && _b !== void 0 ? _b : [];
|
|
15
16
|
if (innerFacets.length > 0) {
|
|
16
17
|
innerFacets.forEach(g => {
|
|
17
18
|
if (g.facets)
|
|
@@ -34,6 +35,7 @@ function getBucketsFromFacets(searchResultFacets, labelList, recursiveOut) {
|
|
|
34
35
|
});
|
|
35
36
|
return out;
|
|
36
37
|
}
|
|
38
|
+
exports.getBucketsFromFacets = getBucketsFromFacets;
|
|
37
39
|
function collectFacets(facets) {
|
|
38
40
|
return facets.map(f => ('value' in f ? {
|
|
39
41
|
name: f.name,
|