Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kfarranger/mapping-utils

Package Overview
Dependencies
Maintainers
5
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kfarranger/mapping-utils - npm Package Compare versions

Comparing version 1.12.3 to 1.12.4

307

dist/resolveSets.js

@@ -53,65 +53,15 @@ "use strict";

var userOwnedSaveSets = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(userId, setIds, es) {
var _esResponse$hits, _esResponse$hits$hits;
var esResponse;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return es.search({
index: _middleware.CONSTANTS.ES_ARRANGER_SET_INDEX,
type: _middleware.CONSTANTS.ES_ARRANGER_SET_TYPE,
body: {
query: {
bool: {
must: [{
terms: {
setId: setIds
}
}],
filter: {
term: {
userId: userId
}
}
}
}
}
});
case 2:
esResponse = _context.sent;
return _context.abrupt("return", ((_esResponse$hits = esResponse.hits) === null || _esResponse$hits === void 0 ? void 0 : (_esResponse$hits$hits = _esResponse$hits.hits) === null || _esResponse$hits$hits === void 0 ? void 0 : _esResponse$hits$hits.map(function (h) {
return h._source.setId;
})) || []);
case 4:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function userOwnedSaveSets(_x, _x2, _x3) {
return _ref.apply(this, arguments);
};
}();
var retrieveSetIds = /*#__PURE__*/function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref2) {
var es, index, type, query, path, sort, _ref2$BULK_SIZE, BULK_SIZE, search, handleResult;
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref) {
var es, index, type, query, path, sort, _ref$BULK_SIZE, BULK_SIZE, search, handleResult;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context3.prev = _context3.next) {
case 0:
es = _ref2.es, index = _ref2.index, type = _ref2.type, query = _ref2.query, path = _ref2.path, sort = _ref2.sort, _ref2$BULK_SIZE = _ref2.BULK_SIZE, BULK_SIZE = _ref2$BULK_SIZE === void 0 ? 1000 : _ref2$BULK_SIZE;
es = _ref.es, index = _ref.index, type = _ref.type, query = _ref.query, path = _ref.path, sort = _ref.sort, _ref$BULK_SIZE = _ref.BULK_SIZE, BULK_SIZE = _ref$BULK_SIZE === void 0 ? 1000 : _ref$BULK_SIZE;
search = /*#__PURE__*/function () {
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var _ref5,
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var _ref4,
searchAfter,

@@ -122,9 +72,9 @@ body,

nextSearchAfter,
_args2 = arguments;
_args = arguments;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context2.prev = _context2.next) {
switch (_context.prev = _context.next) {
case 0:
_ref5 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, searchAfter = _ref5.searchAfter;
_ref4 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, searchAfter = _ref4.searchAfter;
body = _extends({}, !(0, _lodash.isEmpty)(query) && {

@@ -135,9 +85,9 @@ query: query

});
_context2.next = 4;
_context.next = 4;
return es.search({
index: index,
type: type,
sort: sort.map(function (_ref6) {
var field = _ref6.field,
order = _ref6.order;
sort: sort.map(function (_ref5) {
var field = _ref5.field,
order = _ref5.order;
return "".concat(field, ":").concat(order || 'asc');

@@ -150,8 +100,8 @@ }),

case 4:
response = _context2.sent;
response = _context.sent;
ids = response.hits.hits.map(function (x) {
return (0, _lodash.get)(x, "_source.".concat(path.split('__').join('.')), x._id || '');
});
nextSearchAfter = sort.map(function (_ref7) {
var field = _ref7.field;
nextSearchAfter = sort.map(function (_ref6) {
var field = _ref6.field;
return response.hits.hits.map(function (x) {

@@ -163,3 +113,3 @@ return x._source[field] || x[field];

}, []);
return _context2.abrupt("return", {
return _context.abrupt("return", {
ids: ids,

@@ -172,10 +122,10 @@ searchAfter: nextSearchAfter,

case "end":
return _context2.stop();
return _context.stop();
}
}
}, _callee2);
}, _callee);
}));
return function search() {
return _ref4.apply(this, arguments);
return _ref3.apply(this, arguments);
};

@@ -185,20 +135,20 @@ }();

handleResult = /*#__PURE__*/function () {
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref8) {
var searchAfter, total, _ref8$ids, ids, _ref10, newIds, response;
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref7) {
var searchAfter, total, _ref7$ids, ids, _ref9, newIds, response;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context3.prev = _context3.next) {
switch (_context2.prev = _context2.next) {
case 0:
searchAfter = _ref8.searchAfter, total = _ref8.total, _ref8$ids = _ref8.ids, ids = _ref8$ids === void 0 ? [] : _ref8$ids;
searchAfter = _ref7.searchAfter, total = _ref7.total, _ref7$ids = _ref7.ids, ids = _ref7$ids === void 0 ? [] : _ref7$ids;
if (!(ids.length === total)) {
_context3.next = 3;
_context2.next = 3;
break;
}
return _context3.abrupt("return", (0, _lodash.uniq)(ids));
return _context2.abrupt("return", (0, _lodash.uniq)(ids));
case 3:
_context3.next = 5;
_context2.next = 5;
return search({

@@ -209,6 +159,6 @@ searchAfter: searchAfter

case 5:
_ref10 = _context3.sent;
newIds = _ref10.ids;
response = _objectWithoutProperties(_ref10, ["ids"]);
return _context3.abrupt("return", handleResult(_extends({}, response, {
_ref9 = _context2.sent;
newIds = _ref9.ids;
response = _objectWithoutProperties(_ref9, ["ids"]);
return _context2.abrupt("return", handleResult(_extends({}, response, {
ids: [].concat(_toConsumableArray(ids), _toConsumableArray(newIds))

@@ -219,50 +169,50 @@ })));

case "end":
return _context3.stop();
return _context2.stop();
}
}
}, _callee3);
}, _callee2);
}));
return function handleResult(_x5) {
return _ref9.apply(this, arguments);
return function handleResult(_x2) {
return _ref8.apply(this, arguments);
};
}();
_context4.t0 = handleResult;
_context4.next = 6;
_context3.t0 = handleResult;
_context3.next = 6;
return search();
case 6:
_context4.t1 = _context4.sent;
return _context4.abrupt("return", (0, _context4.t0)(_context4.t1));
_context3.t1 = _context3.sent;
return _context3.abrupt("return", (0, _context3.t0)(_context3.t1));
case 8:
case "end":
return _context4.stop();
return _context3.stop();
}
}
}, _callee4);
}, _callee3);
}));
return function retrieveSetIds(_x4) {
return _ref3.apply(this, arguments);
return function retrieveSetIds(_x) {
return _ref2.apply(this, arguments);
};
}();
var saveSet = function saveSet(_ref11) {
var types = _ref11.types,
callback = _ref11.callback;
var saveSet = function saveSet(_ref10) {
var types = _ref10.types,
callback = _ref10.callback;
return (/*#__PURE__*/function () {
var _ref14 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(obj, _ref12, _ref13) {
var type, userId, sqon, path, sort, _ref12$refresh, refresh, tag, es, _types$find$, nestedFields, es_type, index, query, ids, body;
var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(obj, _ref11, _ref12) {
var type, userId, sqon, path, sort, _ref11$refresh, refresh, tag, es, _types$find$, nestedFields, es_type, index, query, ids, body;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context4.prev = _context4.next) {
case 0:
type = _ref12.type, userId = _ref12.userId, sqon = _ref12.sqon, path = _ref12.path, sort = _ref12.sort, _ref12$refresh = _ref12.refresh, refresh = _ref12$refresh === void 0 ? 'WAIT_FOR' : _ref12$refresh, tag = _ref12.tag;
es = _ref13.es;
type = _ref11.type, userId = _ref11.userId, sqon = _ref11.sqon, path = _ref11.path, sort = _ref11.sort, _ref11$refresh = _ref11.refresh, refresh = _ref11$refresh === void 0 ? 'WAIT_FOR' : _ref11$refresh, tag = _ref11.tag;
es = _ref12.es;
if (!tag) {
_context5.next = 9;
_context4.next = 9;
break;

@@ -272,3 +222,3 @@ }

if ((0, _sets.isTagValid)(tag)) {
_context5.next = 7;
_context4.next = 7;
break;

@@ -281,3 +231,3 @@ }

if ((0, _lodash.isFunction)(callback)) {
_context5.next = 9;
_context4.next = 9;
break;

@@ -289,5 +239,5 @@ }

case 9:
_types$find$ = types.find(function (_ref15) {
var _ref16 = _slicedToArray(_ref15, 2),
x = _ref16[1];
_types$find$ = types.find(function (_ref14) {
var _ref15 = _slicedToArray(_ref14, 2),
x = _ref15[1];

@@ -300,3 +250,3 @@ return x.name === type;

});
_context5.next = 13;
_context4.next = 13;
return retrieveSetIds({

@@ -315,3 +265,3 @@ es: es,

case 13:
ids = _context5.sent;
ids = _context4.sent;
body = {

@@ -328,3 +278,3 @@ setId: (0, _v["default"])(),

};
_context5.next = 17;
_context4.next = 17;
return es.index({

@@ -340,7 +290,7 @@ index: _middleware.CONSTANTS.ES_ARRANGER_SET_INDEX,

if (!tag) {
_context5.next = 20;
_context4.next = 20;
break;
}
_context5.next = 20;
_context4.next = 20;
return callback({

@@ -352,14 +302,14 @@ actionType: ActionTypes.CREATE,

case 20:
return _context5.abrupt("return", body);
return _context4.abrupt("return", body);
case 21:
case "end":
return _context5.stop();
return _context4.stop();
}
}
}, _callee5);
}, _callee4);
}));
return function (_x6, _x7, _x8) {
return _ref14.apply(this, arguments);
return function (_x3, _x4, _x5) {
return _ref13.apply(this, arguments);
};

@@ -372,14 +322,14 @@ }()

var deleteSaveSets = function deleteSaveSets(_ref17) {
var callback = _ref17.callback;
var deleteSaveSets = function deleteSaveSets(_ref16) {
var callback = _ref16.callback;
return (/*#__PURE__*/function () {
var _ref20 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(obj, _ref18, _ref19) {
var _ref19 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(obj, _ref17, _ref18) {
var setIds, userId, es, esResponse;
return regeneratorRuntime.wrap(function _callee6$(_context6) {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context6.prev = _context6.next) {
switch (_context5.prev = _context5.next) {
case 0:
setIds = _ref18.setIds, userId = _ref18.userId;
es = _ref19.es;
_context6.next = 4;
setIds = _ref17.setIds, userId = _ref17.userId;
es = _ref18.es;
_context5.next = 4;
return es.deleteByQuery({

@@ -390,4 +340,13 @@ index: _middleware.CONSTANTS.ES_ARRANGER_SET_INDEX,

query: {
terms: {
setId: userOwnedSaveSets(userId, setIds, es)
bool: {
filter: {
term: {
userId: userId
}
},
must: {
terms: {
setId: setIds
}
}
}

@@ -399,10 +358,10 @@ }

case 4:
esResponse = _context6.sent;
esResponse = _context5.sent;
if (!(0, _lodash.isFunction)(callback)) {
_context6.next = 8;
_context5.next = 8;
break;
}
_context6.next = 8;
_context5.next = 8;
return callback({

@@ -417,14 +376,14 @@ actionType: ActionTypes.DELETE,

case 8:
return _context6.abrupt("return", esResponse.deleted);
return _context5.abrupt("return", esResponse.deleted);
case 9:
case "end":
return _context6.stop();
return _context5.stop();
}
}
}, _callee6);
}, _callee5);
}));
return function (_x9, _x10, _x11) {
return _ref20.apply(this, arguments);
return function (_x6, _x7, _x8) {
return _ref19.apply(this, arguments);
};

@@ -437,26 +396,38 @@ }()

var renameSaveSetTag = function renameSaveSetTag(_ref21) {
var callback = _ref21.callback;
var renameSaveSetTag = function renameSaveSetTag(_ref20) {
var callback = _ref20.callback;
return (/*#__PURE__*/function () {
var _ref24 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(obj, _ref22, _ref23) {
var setId, tag, userId, es, ownSaveSet, esResponse;
return regeneratorRuntime.wrap(function _callee7$(_context7) {
var _ref23 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(obj, _ref21, _ref22) {
var setId, tag, userId, es, esResponse;
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context7.prev = _context7.next) {
switch (_context6.prev = _context6.next) {
case 0:
setId = _ref22.setId, tag = _ref22.tag, userId = _ref22.userId;
es = _ref23.es;
_context7.next = 4;
return userOwnedSaveSets(userId, [setId], es);
case 4:
ownSaveSet = _context7.sent;
_context7.next = 7;
return es.update({
setId = _ref21.setId, tag = _ref21.tag, userId = _ref21.userId;
es = _ref22.es;
_context6.next = 4;
return es.updateByQuery({
index: _middleware.CONSTANTS.ES_ARRANGER_SET_INDEX,
type: _middleware.CONSTANTS.ES_ARRANGER_SET_TYPE,
id: ownSaveSet[0] || '',
refresh: true,
body: {
doc: {
tag: tag
script: {
lang: 'painless',
source: "ctx._source['tag'] = '".concat(tag, "'")
},
query: {
bool: {
filter: {
term: {
userId: userId
}
},
must: {
term: {
setId: {
value: setId
}
}
}
}
}

@@ -466,11 +437,11 @@ }

case 7:
esResponse = _context7.sent;
case 4:
esResponse = _context6.sent;
if (!(0, _lodash.isFunction)(callback)) {
_context7.next = 11;
_context6.next = 8;
break;
}
_context7.next = 11;
_context6.next = 8;
return callback({

@@ -486,15 +457,15 @@ actionType: ActionTypes.UPDATE,

case 11:
return _context7.abrupt("return", esResponse.result);
case 8:
return _context6.abrupt("return", esResponse.updated);
case 12:
case 9:
case "end":
return _context7.stop();
return _context6.stop();
}
}
}, _callee7);
}, _callee6);
}));
return function (_x12, _x13, _x14) {
return _ref24.apply(this, arguments);
return function (_x9, _x10, _x11) {
return _ref23.apply(this, arguments);
};

@@ -501,0 +472,0 @@ }()

{
"name": "@kfarranger/mapping-utils",
"version": "1.12.3",
"version": "1.12.4",
"description": "Transform Elasticsearch mappings",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc