@arranger/mapping-utils
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -10,2 +10,4 @@ "use strict"; | ||
var _columnsToGraphql = require("./utils/columnsToGraphql"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -15,14 +17,2 @@ | ||
function toQuery(path) { | ||
return path.split('.').reverse().reduce(function (acc, segment, i, arr) { | ||
if (segment === 'hits') { | ||
return "".concat(segment, "(first: 5) { total, ").concat(acc, " }"); | ||
} else if (i === 0) { | ||
return segment; | ||
} else { | ||
return "".concat(segment.indexOf('edges[') === 0 ? 'edges' : segment, " { ").concat(acc, " }"); | ||
} | ||
}, ''); | ||
} | ||
var _default = function _default(mapping) { | ||
@@ -40,3 +30,5 @@ return (0, _mappingToColumnsType.default)(mapping).map(function (_ref) { | ||
}, type === 'list' ? { | ||
query: toQuery(field), | ||
query: (0, _columnsToGraphql.toQuery)({ | ||
accessor: field | ||
}), | ||
listAccessor: field.split(/\[\d*\].node/)[0], | ||
@@ -43,0 +35,0 @@ totalAccessor: "".concat(field.split(/edges\[\d*\].node/)[0], "total"), |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.toQuery = toQuery; | ||
exports.default = columnsToGraphql; | ||
@@ -11,2 +12,12 @@ | ||
function toQuery(column) { | ||
return column.query || column.accessor.split('.').reverse().reduce(function (acc, segment, i, arr) { | ||
if (i === 0) { | ||
return segment; | ||
} else { | ||
return "".concat(segment.indexOf('edges[') === 0 ? 'edges' : segment, " {\n ").concat(acc, "\n }"); | ||
} | ||
}, ''); | ||
} | ||
function columnsToGraphql(_ref) { | ||
@@ -20,17 +31,2 @@ var _ref$config = _ref.config, | ||
first = _ref.first; | ||
function toQuery(column) { | ||
return column.query || column.accessor.split('.').reverse().reduce(function (acc, segment, i, arr) { | ||
if (segment === 'hits') { | ||
var _first = (0, _lodash.get)(arr[i - 1].match(/edges\[(\d+)\]/), '[1]', 0); | ||
return "".concat(segment, "(first: ").concat(_first, ") {\n ").concat(acc, "\n }"); | ||
} else if (i === 0) { | ||
return segment; | ||
} else { | ||
return "".concat(segment.indexOf('edges[') === 0 ? 'edges' : segment, " {\n ").concat(acc, "\n }"); | ||
} | ||
}, ''); | ||
} | ||
var fields = config.columns.filter(function (column) { | ||
@@ -37,0 +33,0 @@ return !(column.accessor && column.accessor === config.keyField) && (column.fetch || column.show); |
{ | ||
"name": "@arranger/mapping-utils", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "Transform Elasticsearch mappings", | ||
@@ -25,3 +25,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@arranger/middleware": "^0.1.10", | ||
"@arranger/middleware": "^0.1.11", | ||
"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
54094
1122
Updated@arranger/middleware@^0.1.11