@arranger/mapping-utils
Advanced tools
Comparing version 0.1.41 to 0.2.0
@@ -10,10 +10,6 @@ "use strict"; | ||
var _buildAggregations2 = _interopRequireDefault(require("./buildAggregations")); | ||
var _middleware = require("@arranger/middleware"); | ||
var _pruneAggregations = _interopRequireDefault(require("./pruneAggregations")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _next(value) { step("next", value); } function _throw(err) { step("throw", err); } _next(); }); }; } | ||
@@ -48,3 +44,3 @@ | ||
regeneratorRuntime.mark(function _callee(obj, _ref3, _ref4, info) { | ||
var es, _ref3$offset, offset, args, graphql_fields, fields, nested_fields, _buildAggregations, query, aggs, body, _ref6, aggregations, _ref7, pruned; | ||
var _ref3$offset, offset, filters, aggregations_filter_themselves, es, nestedFields, query, aggs, body, response, aggregations; | ||
@@ -55,16 +51,17 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 0: | ||
_ref3$offset = _ref3.offset, offset = _ref3$offset === void 0 ? 0 : _ref3$offset, filters = _ref3.filters, aggregations_filter_themselves = _ref3.aggregations_filter_themselves; | ||
es = _ref4.es; | ||
_ref3$offset = _ref3.offset, offset = _ref3$offset === void 0 ? 0 : _ref3$offset, args = _objectWithoutProperties(_ref3, ["offset"]); | ||
graphql_fields = (0, _graphqlFields.default)(info); | ||
fields = Object.keys(graphql_fields); | ||
nested_fields = type.nested_fields; | ||
_buildAggregations = (0, _buildAggregations2.default)({ | ||
type: type, | ||
args: args, | ||
fields: fields, | ||
graphql_fields: graphql_fields, | ||
nested_fields: nested_fields | ||
}), query = _buildAggregations.query, aggs = _buildAggregations.aggs; | ||
body = query && Object.keys(query).length ? { | ||
nestedFields = type.nested_fields; | ||
query = (0, _middleware.buildQuery)({ | ||
nestedFields: nestedFields, | ||
filters: filters | ||
}); | ||
aggs = (0, _middleware.buildAggregations)({ | ||
query: query, | ||
graphqlFields: (0, _graphqlFields.default)(info), | ||
nestedFields: nestedFields, | ||
aggregationsFilterThemselves: aggregations_filter_themselves | ||
}); | ||
body = Object.keys(query || {}).length ? { | ||
query: query, | ||
aggs: aggs | ||
@@ -74,3 +71,3 @@ } : { | ||
}; | ||
_context.next = 9; | ||
_context.next = 8; | ||
return es.search({ | ||
@@ -84,17 +81,8 @@ index: type.index, | ||
case 9: | ||
_ref6 = _context.sent; | ||
aggregations = _ref6.aggregations; | ||
_context.next = 13; | ||
return (0, _pruneAggregations.default)({ | ||
aggs: aggregations, | ||
nested_fields: nested_fields | ||
}); | ||
case 8: | ||
response = _context.sent; | ||
aggregations = (0, _middleware.flattenAggregations)(response.aggregations); | ||
return _context.abrupt("return", Object.entries(aggregations).reduce(toGraphqlField, {})); | ||
case 13: | ||
_ref7 = _context.sent; | ||
pruned = _ref7.pruned; | ||
return _context.abrupt("return", Object.entries(pruned).reduce(toGraphqlField, {})); | ||
case 16: | ||
case 11: | ||
case "end": | ||
@@ -101,0 +89,0 @@ return _context.stop(); |
@@ -10,3 +10,3 @@ "use strict"; | ||
var _buildQuery = _interopRequireDefault(require("./buildQuery")); | ||
var _middleware = require("@arranger/middleware"); | ||
@@ -39,3 +39,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var node = _ref.node, | ||
nested_fields = _ref.nested_fields, | ||
nestedFields = _ref.nestedFields, | ||
_ref$parent = _ref.parent, | ||
@@ -51,3 +51,3 @@ parent = _ref$parent === void 0 ? '' : _ref$parent; | ||
var fullPath = joinParent(parent, field); | ||
return _objectSpread({}, acc, _defineProperty({}, field, nested_fields.includes(fullPath) ? { | ||
return _objectSpread({}, acc, _defineProperty({}, field, nestedFields.includes(fullPath) ? { | ||
hits: { | ||
@@ -58,3 +58,3 @@ edges: hits.map(function (node) { | ||
node: node, | ||
nested_fields: nested_fields, | ||
nestedFields: nestedFields, | ||
parent: fullPath | ||
@@ -68,7 +68,7 @@ })) | ||
node: hits, | ||
nested_fields: nested_fields, | ||
nestedFields: nestedFields, | ||
parent: fullPath | ||
})) : resolveNested({ | ||
node: hits, | ||
nested_fields: nested_fields, | ||
nestedFields: nestedFields, | ||
parent: fullPath | ||
@@ -86,3 +86,3 @@ }))); | ||
regeneratorRuntime.mark(function _callee(obj, _ref4, _ref5, info) { | ||
var _ref4$first, first, _ref4$offset, offset, filters, score, sort, es, fields, nested_fields, query, body, _ref9, hits, nodes; | ||
var _ref4$first, first, _ref4$offset, offset, filters, score, sort, es, fields, nestedFields, query, body, _ref9, hits, nodes; | ||
@@ -96,11 +96,10 @@ return regeneratorRuntime.wrap(function _callee$(_context) { | ||
fields = (0, _graphqlFields.default)(info); | ||
nested_fields = type.nested_fields; | ||
nestedFields = type.nested_fields; | ||
query = filters; | ||
if (filters || score) { | ||
query = (0, _buildQuery.default)({ | ||
type: type, | ||
filters: filters, | ||
score: score, | ||
nested_fields: nested_fields | ||
// TODO: something with score? | ||
query = (0, _middleware.buildQuery)({ | ||
nestedFields: nestedFields, | ||
filters: filters | ||
}); | ||
@@ -120,3 +119,3 @@ } | ||
var nested_path = nested_fields.find(function (nestedField) { | ||
var nested_path = nestedFields.find(function (nestedField) { | ||
return field.indexOf(nestedField) === 0; | ||
@@ -150,3 +149,3 @@ }); | ||
node: source, | ||
nested_fields: nested_fields | ||
nestedFields: nestedFields | ||
}); | ||
@@ -153,0 +152,0 @@ return _objectSpread({ |
{ | ||
"name": "@arranger/mapping-utils", | ||
"version": "0.1.41", | ||
"version": "0.2.0", | ||
"description": "Transform Elasticsearch mappings", | ||
@@ -25,3 +25,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@arranger/middleware": "^0.1.36", | ||
"@arranger/middleware": "^0.2.0", | ||
"babel-polyfill": "^6.26.0", | ||
@@ -28,0 +28,0 @@ "elasticsearch": "^14.0.0", |
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
61548
25
1197
+ Added@arranger/middleware@0.2.4(transitive)
- Removed@arranger/middleware@0.1.36(transitive)
Updated@arranger/middleware@^0.2.0