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

parse-utils

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-utils - npm Package Compare versions

Comparing version 2.7.0 to 2.7.1

241

lib/index.js

@@ -291,66 +291,59 @@ 'use strict';

var deleteAllByQuery = exports.deleteAllByQuery = function () {
var _ref6 = _asyncToGenerator(regeneratorRuntime.mark(function _callee7(parseQuery, options) {
var deleteChunk, count;
return regeneratorRuntime.wrap(function _callee7$(_context7) {
var _ref6 = _asyncToGenerator(regeneratorRuntime.mark(function _callee6(parseQuery, options) {
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context7.prev = _context7.next) {
switch (_context6.prev = _context6.next) {
case 0:
deleteChunk = function () {
var _ref7 = _asyncToGenerator(regeneratorRuntime.mark(function _callee6(query) {
var objectsToDelete, deletedObjects;
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return query.find(options);
_context6.next = 2;
return _destroyAll(parseQuery.limit(500));
case 2:
objectsToDelete = _context6.sent;
_context6.next = 5;
return Parse.Object.destroyAll(objectsToDelete, options);
case 2:
return _context6.abrupt('return', _context6.sent);
case 5:
deletedObjects = _context6.sent;
return _context6.abrupt('return', deletedObjects.length);
case 3:
case 'end':
return _context6.stop();
}
}
}, _callee6, undefined);
}));
case 7:
case 'end':
return _context6.stop();
}
}
}, _callee6, undefined);
}));
return function deleteAllByQuery(_x8, _x9) {
return _ref6.apply(this, arguments);
};
}();
return function deleteChunk(_x10) {
return _ref7.apply(this, arguments);
};
}();
var _destroyAll = function () {
var _ref7 = _asyncToGenerator(regeneratorRuntime.mark(function _callee7(parseQuery, options) {
var count;
return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_context7.next = 2;
return _deleteChunk(parseQuery);
_context7.next = 3;
return deleteChunk(parseQuery);
case 3:
case 2:
count = _context7.sent;
if (!count) {
_context7.next = 10;
_context7.next = 9;
break;
}
_context7.next = 7;
return deleteAllByQuery(parseQuery);
_context7.next = 6;
return _destroyAll(parseQuery);
case 7:
case 6:
_context7.t0 = _context7.sent;
_context7.next = 11;
_context7.next = 10;
break;
case 10:
case 9:
_context7.t0 = Parse.Promise.as();
case 11:
case 10:
return _context7.abrupt('return', _context7.t0);
case 12:
case 11:
case 'end':

@@ -363,7 +356,39 @@ return _context7.stop();

return function deleteAllByQuery(_x8, _x9) {
return _ref6.apply(this, arguments);
return function _destroyAll(_x10, _x11) {
return _ref7.apply(this, arguments);
};
}();
var _deleteChunk = function () {
var _ref8 = _asyncToGenerator(regeneratorRuntime.mark(function _callee8(parseQuery, options) {
var objectsToDelete, deletedObjects;
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.next = 2;
return parseQuery.find(options);
case 2:
objectsToDelete = _context8.sent;
_context8.next = 5;
return Parse.Object.destroyAll(objectsToDelete, options);
case 5:
deletedObjects = _context8.sent;
return _context8.abrupt('return', deletedObjects.length);
case 7:
case 'end':
return _context8.stop();
}
}
}, _callee8, undefined);
}));
return function _deleteChunk(_x12, _x13) {
return _ref8.apply(this, arguments);
};
}();
/**

@@ -378,11 +403,11 @@ * Execute a "saveAll" Parse Query splitting in chunks the saveAll instructions.

var saveAllInChunks = exports.saveAllInChunks = function () {
var _ref8 = _asyncToGenerator(regeneratorRuntime.mark(function _callee8(parseObjects, saveOptions) {
var _ref9 = _asyncToGenerator(regeneratorRuntime.mark(function _callee9(parseObjects, saveOptions) {
var chunkSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
var objectsChunks;
return regeneratorRuntime.wrap(function _callee8$(_context8) {
return regeneratorRuntime.wrap(function _callee9$(_context9) {
while (1) {
switch (_context8.prev = _context8.next) {
switch (_context9.prev = _context9.next) {
case 0:
objectsChunks = (0, _lodash.chunk)(parseObjects, chunkSize);
_context8.next = 3;
_context9.next = 3;
return Promise.all(objectsChunks.map(function (obj) {

@@ -393,14 +418,14 @@ return Parse.Object.saveAll(obj, saveOptions);

case 3:
return _context8.abrupt('return', _context8.sent);
return _context9.abrupt('return', _context9.sent);
case 4:
case 'end':
return _context8.stop();
return _context9.stop();
}
}
}, _callee8, undefined);
}, _callee9, undefined);
}));
return function saveAllInChunks(_x11, _x12, _x13) {
return _ref8.apply(this, arguments);
return function saveAllInChunks(_x14, _x15, _x16) {
return _ref9.apply(this, arguments);
};

@@ -417,21 +442,21 @@ }();

var createRoleIfNotExists = exports.createRoleIfNotExists = function () {
var _ref9 = _asyncToGenerator(regeneratorRuntime.mark(function _callee9(roleName, saveOptions) {
var _ref10 = _asyncToGenerator(regeneratorRuntime.mark(function _callee10(roleName, saveOptions) {
var Role, doesRoleExists, role, acl;
return regeneratorRuntime.wrap(function _callee9$(_context9) {
return regeneratorRuntime.wrap(function _callee10$(_context10) {
while (1) {
switch (_context9.prev = _context9.next) {
switch (_context10.prev = _context10.next) {
case 0:
Role = Parse.Object.extend('_Role');
_context9.next = 3;
_context10.next = 3;
return new Parse.Query(Role).equalTo('name', roleName).first();
case 3:
doesRoleExists = _context9.sent;
doesRoleExists = _context10.sent;
if (!doesRoleExists) {
_context9.next = 8;
_context10.next = 8;
break;
}
return _context9.abrupt('return', undefined);
return _context10.abrupt('return', undefined);

@@ -447,18 +472,18 @@ case 8:

role.setACL(acl);
_context9.next = 16;
_context10.next = 16;
return role.save({}, saveOptions);
case 16:
return _context9.abrupt('return', _context9.sent);
return _context10.abrupt('return', _context10.sent);
case 17:
case 'end':
return _context9.stop();
return _context10.stop();
}
}
}, _callee9, undefined);
}, _callee10, undefined);
}));
return function createRoleIfNotExists(_x15, _x16) {
return _ref9.apply(this, arguments);
return function createRoleIfNotExists(_x18, _x19) {
return _ref10.apply(this, arguments);
};

@@ -475,22 +500,22 @@ }();

var isUserInRole = exports.isUserInRole = function () {
var _ref10 = _asyncToGenerator(regeneratorRuntime.mark(function _callee10(userId, roleName) {
var _ref11 = _asyncToGenerator(regeneratorRuntime.mark(function _callee11(userId, roleName) {
var user, isInRole;
return regeneratorRuntime.wrap(function _callee10$(_context10) {
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
switch (_context10.prev = _context10.next) {
switch (_context11.prev = _context11.next) {
case 0:
user = createPointerFromId('_User', userId);
isInRole = new Parse.Query(Parse.Role).equalTo('name', roleName).equalTo('users', user).first();
return _context10.abrupt('return', !(0, _lodash.isEmpty)(isInRole));
return _context11.abrupt('return', !(0, _lodash.isEmpty)(isInRole));
case 3:
case 'end':
return _context10.stop();
return _context11.stop();
}
}
}, _callee10, undefined);
}, _callee11, undefined);
}));
return function isUserInRole(_x17, _x18) {
return _ref10.apply(this, arguments);
return function isUserInRole(_x20, _x21) {
return _ref11.apply(this, arguments);
};

@@ -507,42 +532,42 @@ }();

var loadClassesFromSchemas = exports.loadClassesFromSchemas = function () {
var _ref11 = _asyncToGenerator(regeneratorRuntime.mark(function _callee12(parseServerDb) {
var _ref12 = _asyncToGenerator(regeneratorRuntime.mark(function _callee13(parseServerDb) {
var schemas = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var shouldUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var parseServerDbSchema, loadClass, getSchemaChanges;
return regeneratorRuntime.wrap(function _callee12$(_context12) {
return regeneratorRuntime.wrap(function _callee13$(_context13) {
while (1) {
switch (_context12.prev = _context12.next) {
switch (_context13.prev = _context13.next) {
case 0:
_context12.next = 2;
_context13.next = 2;
return parseServerDb.loadSchema();
case 2:
parseServerDbSchema = _context12.sent;
parseServerDbSchema = _context13.sent;
// Function that load a class in Parse Server
loadClass = function () {
var _ref12 = _asyncToGenerator(regeneratorRuntime.mark(function _callee11(className, classSchema, classPermissions) {
var _ref13 = _asyncToGenerator(regeneratorRuntime.mark(function _callee12(className, classSchema, classPermissions) {
var mergedClassSchema;
return regeneratorRuntime.wrap(function _callee11$(_context11) {
return regeneratorRuntime.wrap(function _callee12$(_context12) {
while (1) {
switch (_context11.prev = _context11.next) {
switch (_context12.prev = _context12.next) {
case 0:
_context11.prev = 0;
_context11.next = 3;
_context12.prev = 0;
_context12.next = 3;
return parseServerDbSchema.addClassIfNotExists(className, classSchema);
case 3:
_context11.next = 5;
_context12.next = 5;
return parseServerDbSchema.updateClass(className, {}, classPermissions);
case 5:
_context11.next = 17;
_context12.next = 17;
break;
case 7:
_context11.prev = 7;
_context11.t0 = _context11['catch'](0);
_context12.prev = 7;
_context12.t0 = _context12['catch'](0);
if (!(_context11.t0.code === 103)) {
_context11.next = 16;
if (!(_context12.t0.code === 103)) {
_context12.next = 16;
break;

@@ -552,3 +577,3 @@ }

if (!shouldUpdate) {
_context11.next = 14;
_context12.next = 14;
break;

@@ -558,22 +583,22 @@ }

mergedClassSchema = getSchemaChanges(className, classSchema);
_context11.next = 14;
_context12.next = 14;
return parseServerDbSchema.updateClass(className, mergedClassSchema, classPermissions, parseServerDb);
case 14:
_context11.next = 17;
_context12.next = 17;
break;
case 16:
throw _context11.t0;
throw _context12.t0;
case 17:
case 'end':
return _context11.stop();
return _context12.stop();
}
}
}, _callee11, undefined, [[0, 7]]);
}, _callee12, undefined, [[0, 7]]);
}));
return function loadClass(_x24, _x25, _x26) {
return _ref12.apply(this, arguments);
return function loadClass(_x27, _x28, _x29) {
return _ref13.apply(this, arguments);
};

@@ -642,7 +667,7 @@ }();

_context12.next = 7;
return Promise.all(schemas.map(function (_ref13) {
var name = _ref13.name,
schema = _ref13.schema,
permissions = _ref13.permissions;
_context13.next = 7;
return Promise.all(schemas.map(function (_ref14) {
var name = _ref14.name,
schema = _ref14.schema,
permissions = _ref14.permissions;
return loadClass(name, schema, permissions);

@@ -653,10 +678,10 @@ }));

case 'end':
return _context12.stop();
return _context13.stop();
}
}
}, _callee12, undefined);
}, _callee13, undefined);
}));
return function loadClassesFromSchemas(_x19, _x20, _x21) {
return _ref11.apply(this, arguments);
return function loadClassesFromSchemas(_x22, _x23, _x24) {
return _ref12.apply(this, arguments);
};

@@ -663,0 +688,0 @@ }();

{
"name": "parse-utils",
"version": "2.7.0",
"version": "2.7.1",
"description": "Parse JS SDK and Parse-Server utilities",

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

Sorry, the diff of this file is not supported yet

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