@ferlab/next
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -15,3 +15,3 @@ import normalizeFilters from '../buildQuery/normalizeFilters'; | ||
else { | ||
const { content: { field: sqonFieldName, fieldNames: sqonFieldNames }, } = sqon; | ||
const { content: { field: sqonFieldName, fields: sqonFieldNames }, } = sqon; | ||
const fieldNames = sqonFieldNames || [sqonFieldName]; | ||
@@ -18,0 +18,0 @@ fieldNames.forEach((field) => { |
@@ -80,3 +80,3 @@ import get from 'lodash/get'; | ||
: c.content?.field?.startsWith(nestedPaths) && c.content?.field !== field); | ||
const termFilters = contentsFiltered.map((filter) => opSwitch({ nestedFieldNames: [], filter })); | ||
const termFilters = contentsFiltered.map((filter) => opSwitch({ nestedFieldNames, filter })); | ||
const fieldAggregation = createFieldAggregation({ | ||
@@ -83,0 +83,0 @@ field, |
@@ -1,2 +0,5 @@ | ||
import _ from 'lodash'; | ||
import flatMap from 'lodash/flatMap'; | ||
import get from 'lodash/get'; | ||
import max from 'lodash/max'; | ||
import min from 'lodash/min'; | ||
import { ALL_OP, AND_OP, BETWEEN_OP, ES_ARRANGER_SET_INDEX, ES_ARRANGER_SET_TYPE, ES_BOOL, ES_MUST, ES_MUST_NOT, ES_NESTED, ES_QUERY, ES_WILDCARD, FILTER_OP, GT_OP, GTE_OP, IN_OP, LT_OP, LTE_OP, MISSING, NOT_IN_OP, NOT_OP, OR_OP, REGEX, SET_ID, SOME_NOT_IN_OP, } from '../constants'; | ||
@@ -11,3 +14,3 @@ import { isNested, mergePath, readPath, toEsRangeValue, wrapMust, wrapMustNot, wrapNested, wrapShould, } from '../utils/esFilter'; | ||
.reverse() | ||
?.reduce((esFilter, path, i) => wrapNested(esFilter, path), isNot ? wrapMustNot(esFilter) : esFilter); | ||
?.reduce((esFilter, path) => wrapNested(esFilter, path), isNot ? wrapMustNot(esFilter) : esFilter); | ||
function getRegexFilter({ nestedFieldNames, filter }) { | ||
@@ -35,6 +38,6 @@ const { op, content: { field, value: [value], }, } = filter; | ||
const { content } = filter; | ||
const { value, fieldNames } = content; | ||
const { value, fields } = content; | ||
// group queries by their nesting level | ||
const sortedNested = nestedFieldNames?.slice().sort((a, b) => b.length - a.length); | ||
const nestedMap = fieldNames?.reduce((acc, field) => { | ||
const nestedMap = fields?.reduce((acc, field) => { | ||
const group = sortedNested?.find((y) => field?.includes?.(y)) || ''; | ||
@@ -81,3 +84,3 @@ if (acc[group]) { | ||
boost: 0, | ||
[op]: toEsRangeValue([GT_OP, GTE_OP]?.includes?.(op) ? _.max(value) : _.min(value)), | ||
[op]: toEsRangeValue([GT_OP, GTE_OP]?.includes?.(op) ? max(value) : min(value)), | ||
}, | ||
@@ -91,4 +94,4 @@ }, | ||
const basePath = [...(filterIsNested ? [ES_NESTED, ES_QUERY] : []), ES_BOOL]; | ||
const path = [ES_MUST, ES_MUST_NOT].map((p) => [...basePath, p]).find((path) => _.get(esFilter, path)); | ||
const found = path && bools.find((bool) => (filterIsNested ? readPath(bool) === readPath(esFilter) : _.get(bool, path))); | ||
const path = [ES_MUST, ES_MUST_NOT].map((p) => [...basePath, p]).find((path) => get(esFilter, path)); | ||
const found = path && bools.find((bool) => (filterIsNested ? readPath(bool) === readPath(esFilter) : get(bool, path))); | ||
return [ | ||
@@ -99,6 +102,6 @@ ...bools.filter((bool) => bool !== found), | ||
? collapseNestedFilters({ | ||
esFilter: _.get(esFilter, path)[0], | ||
bools: _.get(found, path, []), | ||
esFilter: get(esFilter, path)[0], | ||
bools: get(found, path, []), | ||
}) | ||
: [..._.get(found, path), ..._.get(esFilter, path)]) | ||
: [...get(found, path), ...get(esFilter, path)]) | ||
: esFilter, | ||
@@ -135,3 +138,3 @@ ]; | ||
type: ES_ARRANGER_SET_TYPE, | ||
id: _.flatMap([content.value])[0].replace('set_id:', ''), | ||
id: flatMap([content.value])[0].replace('set_id:', ''), | ||
path: 'ids', | ||
@@ -152,4 +155,4 @@ }, | ||
boost: 0, | ||
[GTE_OP]: _.min(value), | ||
[LTE_OP]: _.max(value), | ||
[GTE_OP]: min(value), | ||
[LTE_OP]: max(value), | ||
}, | ||
@@ -156,0 +159,0 @@ }, |
import get from 'lodash/get'; | ||
import { CARDINALITY, HISTOGRAM, MISSING, STATS } from '#src/legacy/constants'; | ||
import { CARDINALITY, HISTOGRAM, MISSING, STATS } from './constants'; | ||
const flattenAggregations = ({ aggregations, includeMissing = true }) => { | ||
@@ -4,0 +4,0 @@ return Object.entries(aggregations).reduce((prunedAggs, [key, value]) => { |
{ | ||
"name": "@ferlab/next", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Shared library for our wrappers GraphQL APIs", | ||
@@ -19,4 +19,5 @@ "main": "src/index.ts", | ||
"scripts": { | ||
"build": "tsc --build", | ||
"clean": "tsc --build --clean", | ||
"dev": "npm run clean && npm install && npm run build", | ||
"build": "tsc -p tsconfig.build.json", | ||
"clean": "rm -rf node_modules lib package-lock.json", | ||
"test": "jest", | ||
@@ -46,3 +47,2 @@ "test:watch": "jest --watch", | ||
"express": "^4.19.2", | ||
"graphql": "16.8.1", | ||
"graphql-fields": "^2.0.3", | ||
@@ -57,4 +57,8 @@ "jest": "^29.7.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.3.3", | ||
"node-fetch": "^3.3.2" | ||
}, | ||
"peerDependencies": { | ||
"graphql": "16.8.1" | ||
}, | ||
"directories": { | ||
@@ -72,6 +76,3 @@ "lib": "lib" | ||
}, | ||
"homepage": "https://github.com/Ferlab-Ste-Justine/ferlab-next#readme", | ||
"dependencies": { | ||
"node-fetch": "^3.3.2" | ||
} | ||
"homepage": "https://github.com/Ferlab-Ste-Justine/ferlab-next#readme" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
326786
149
3376
+ Addedgraphql@16.8.1(transitive)
- Removednode-fetch@^3.3.2
- Removeddata-uri-to-buffer@4.0.1(transitive)
- Removedfetch-blob@3.2.0(transitive)
- Removedformdata-polyfill@4.0.10(transitive)
- Removednode-domexception@1.0.0(transitive)
- Removednode-fetch@3.3.2(transitive)
- Removedweb-streams-polyfill@3.3.3(transitive)