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

@orion-js/schema

Package Overview
Dependencies
Maintainers
2
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orion-js/schema - npm Package Compare versions

Comparing version 0.0.38 to 0.0.39

8

lib/clean/index.js

@@ -21,2 +21,6 @@ 'use strict';

var _isUndefined = require('lodash/isUndefined');
var _isUndefined2 = _interopRequireDefault(_isUndefined);
var _isNil = require('lodash/isNil');

@@ -74,3 +78,3 @@

if (!(0, _isNil2.default)(newValue)) {
if (!(0, _isUndefined2.default)(newValue)) {
items.push(newValue);

@@ -121,3 +125,3 @@ }

if (!(0, _isNil2.default)(_newValue)) {
if (!(0, _isUndefined2.default)(_newValue)) {
fields[key] = _newValue;

@@ -124,0 +128,0 @@ }

@@ -97,4 +97,4 @@ 'use strict';

test('cleans boolean correctly', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
var type, schema, doc, cleaned;
test('dont remove null values', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
var schema, doc, cleaned;
return regeneratorRuntime.wrap(function _callee3$(_context3) {

@@ -104,2 +104,34 @@ while (1) {

case 0:
schema = {
string: {
type: String
}
};
doc = {
string: null
};
_context3.next = 4;
return (0, _index2.default)(schema, doc);
case 4:
cleaned = _context3.sent;
expect(cleaned).toEqual({
string: null
});
case 6:
case 'end':
return _context3.stop();
}
}
}, _callee3, undefined);
})));
test('cleans boolean correctly', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
var type, schema, doc, cleaned;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
type = { type: Boolean };

@@ -121,7 +153,7 @@ schema = {

};
_context3.next = 5;
_context4.next = 5;
return (0, _index2.default)(schema, doc);
case 5:
cleaned = _context3.sent;
cleaned = _context4.sent;

@@ -138,13 +170,13 @@ expect(cleaned).toEqual({

case 'end':
return _context3.stop();
return _context4.stop();
}
}
}, _callee3, undefined);
}, _callee4, undefined);
})));
test('trims strings and filter them', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
test('trims strings and filter them', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
var type, schema, doc, cleaned;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context5.prev = _context5.next) {
case 0:

@@ -160,7 +192,7 @@ type = { type: String };

};
_context4.next = 5;
_context5.next = 5;
return (0, _index2.default)(schema, doc);
case 5:
cleaned = _context4.sent;
cleaned = _context5.sent;

@@ -173,13 +205,13 @@ expect(cleaned).toEqual({

case 'end':
return _context4.stop();
return _context5.stop();
}
}
}, _callee4, undefined);
}, _callee5, undefined);
})));
test('filter fields not in schema', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
test('filter fields not in schema', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
var type, schema, doc, cleaned;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context6.prev = _context6.next) {
case 0:

@@ -195,7 +227,7 @@ type = { type: String };

};
_context5.next = 5;
_context6.next = 5;
return (0, _index2.default)(schema, doc);
case 5:
cleaned = _context5.sent;
cleaned = _context6.sent;

@@ -208,13 +240,13 @@ expect(cleaned).toEqual({

case 'end':
return _context5.stop();
return _context6.stop();
}
}
}, _callee5, undefined);
}, _callee6, undefined);
})));
test('runs autovalues with arrays', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
test('runs autovalues with arrays', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
var schema, doc, cleaned;
return regeneratorRuntime.wrap(function _callee6$(_context6) {
return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {
switch (_context6.prev = _context6.next) {
switch (_context7.prev = _context7.next) {
case 0:

@@ -234,7 +266,7 @@ schema = {

};
_context6.next = 4;
_context7.next = 4;
return (0, _index2.default)(schema, doc);
case 4:
cleaned = _context6.sent;
cleaned = _context7.sent;

@@ -247,13 +279,13 @@ expect(cleaned).toEqual({

case 'end':
return _context6.stop();
return _context7.stop();
}
}
}, _callee6, undefined);
}, _callee7, undefined);
})));
test('run autovalue when field is not present', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
test('run autovalue when field is not present', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
var schema, doc, cleaned;
return regeneratorRuntime.wrap(function _callee7$(_context7) {
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context7.prev = _context7.next) {
switch (_context8.prev = _context8.next) {
case 0:

@@ -269,7 +301,7 @@ schema = {

doc = {};
_context7.next = 4;
_context8.next = 4;
return (0, _index2.default)(schema, doc);
case 4:
cleaned = _context7.sent;
cleaned = _context8.sent;

@@ -280,13 +312,13 @@ expect(cleaned).toEqual({ text: 'a value' });

case 'end':
return _context7.stop();
return _context8.stop();
}
}
}, _callee7, undefined);
}, _callee8, undefined);
})));
test('returns the default values', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
test('returns the default values', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
var schema, doc, cleaned;
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:

@@ -320,7 +352,7 @@ schema = {

doc = { text1: 'pass' };
_context8.next = 4;
_context9.next = 4;
return (0, _index2.default)(schema, doc);
case 4:
cleaned = _context8.sent;
cleaned = _context9.sent;

@@ -336,13 +368,13 @@ expect(cleaned).toEqual({

case 'end':
return _context8.stop();
return _context9.stop();
}
}
}, _callee8, undefined);
}, _callee9, undefined);
})));
test('run deep autovalues', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
test('run deep autovalues', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
var deep, schema, doc, cleaned;
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:

@@ -375,7 +407,7 @@ deep = {

};
_context9.next = 5;
_context10.next = 5;
return (0, _index2.default)(schema, doc);
case 5:
cleaned = _context9.sent;
cleaned = _context10.sent;

@@ -389,13 +421,13 @@ expect(cleaned).toEqual({

case 'end':
return _context9.stop();
return _context10.stop();
}
}
}, _callee9, undefined);
}, _callee10, undefined);
})));
test('perform custom cleaning', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
test('perform custom cleaning', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
var person, schema, cleaned;
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:

@@ -409,23 +441,23 @@ person = {

return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
return regeneratorRuntime.wrap(function _callee10$(_context10) {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
switch (_context10.prev = _context10.next) {
switch (_context11.prev = _context11.next) {
case 0:
if (!(value.name === 'Joaquin')) {
_context10.next = 4;
_context11.next = 4;
break;
}
return _context10.abrupt('return', { name: 'Roberto' });
return _context11.abrupt('return', { name: 'Roberto' });
case 4:
return _context10.abrupt('return', value);
return _context11.abrupt('return', value);
case 5:
case 'end':
return _context10.stop();
return _context11.stop();
}
}
}, _callee10, _this);
}, _callee11, _this);
}))();

@@ -439,3 +471,3 @@ }

};
_context11.next = 4;
_context12.next = 4;
return (0, _index2.default)(schema, {

@@ -446,3 +478,3 @@ persons: [{ name: 'Nicolás' }, { name: 'Joaquin' }]

case 4:
cleaned = _context11.sent;
cleaned = _context12.sent;

@@ -455,13 +487,13 @@ expect(cleaned).toEqual({

case 'end':
return _context11.stop();
return _context12.stop();
}
}
}, _callee11, undefined);
}, _callee12, undefined);
})));
test('perform non deep custom cleaning', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
test('perform non deep custom cleaning', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() {
var schema, cleaned;
return regeneratorRuntime.wrap(function _callee13$(_context13) {
return regeneratorRuntime.wrap(function _callee14$(_context14) {
while (1) {
switch (_context13.prev = _context13.next) {
switch (_context14.prev = _context14.next) {
case 0:

@@ -475,31 +507,31 @@ schema = {

return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
return regeneratorRuntime.wrap(function _callee12$(_context12) {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
return regeneratorRuntime.wrap(function _callee13$(_context13) {
while (1) {
switch (_context12.prev = _context12.next) {
switch (_context13.prev = _context13.next) {
case 0:
if (!(value.name === 'Joaquin')) {
_context12.next = 4;
_context13.next = 4;
break;
}
return _context12.abrupt('return', { name: 'Roberto' });
return _context13.abrupt('return', { name: 'Roberto' });
case 4:
return _context12.abrupt('return', value);
return _context13.abrupt('return', value);
case 5:
case 'end':
return _context12.stop();
return _context13.stop();
}
}
}, _callee12, _this2);
}, _callee13, _this2);
}))();
}
};
_context13.next = 3;
_context14.next = 3;
return (0, _index2.default)(schema, { name: 'Joaquin' });
case 3:
cleaned = _context13.sent;
cleaned = _context14.sent;

@@ -510,13 +542,13 @@ expect(cleaned).toEqual({ name: 'Roberto' });

case 'end':
return _context13.stop();
return _context14.stop();
}
}
}, _callee13, undefined);
}, _callee14, undefined);
})));
test('pass currentDoc cleaning arrays', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() {
test('pass currentDoc cleaning arrays', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() {
var aItem, doc, item, schema;
return regeneratorRuntime.wrap(function _callee16$(_context16) {
return regeneratorRuntime.wrap(function _callee17$(_context17) {
while (1) {
switch (_context16.prev = _context16.next) {
switch (_context17.prev = _context17.next) {
case 0:

@@ -528,10 +560,10 @@ aItem = { name: 'Nicolás' };

type: String,
autoValue: function autoValue(name, _ref13) {
autoValue: function autoValue(name, _ref14) {
var _this3 = this;
var currentDoc = _ref13.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() {
return regeneratorRuntime.wrap(function _callee14$(_context14) {
var currentDoc = _ref14.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() {
return regeneratorRuntime.wrap(function _callee15$(_context15) {
while (1) {
switch (_context14.prev = _context14.next) {
switch (_context15.prev = _context15.next) {
case 0:

@@ -542,6 +574,6 @@ expect(currentDoc).toBe(aItem);

case 'end':
return _context14.stop();
return _context15.stop();
}
}
}, _callee14, _this3);
}, _callee15, _this3);
}))();

@@ -554,10 +586,10 @@ }

type: [item],
autoValue: function autoValue(items, _ref14) {
autoValue: function autoValue(items, _ref15) {
var _this4 = this;
var currentDoc = _ref14.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() {
return regeneratorRuntime.wrap(function _callee15$(_context15) {
var currentDoc = _ref15.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() {
return regeneratorRuntime.wrap(function _callee16$(_context16) {
while (1) {
switch (_context15.prev = _context15.next) {
switch (_context16.prev = _context16.next) {
case 0:

@@ -568,6 +600,6 @@ expect(currentDoc).toBe(doc);

case 'end':
return _context15.stop();
return _context16.stop();
}
}
}, _callee15, _this4);
}, _callee16, _this4);
}))();

@@ -580,3 +612,3 @@ }

expect.assertions(2);
_context16.next = 7;
_context17.next = 7;
return (0, _index2.default)(schema, doc);

@@ -586,13 +618,13 @@

case 'end':
return _context16.stop();
return _context17.stop();
}
}
}, _callee16, undefined);
}, _callee17, undefined);
})));
test('pass currentDoc cleaning complex schemas', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24() {
test('pass currentDoc cleaning complex schemas', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25() {
var aCar, aMom, aItem, doc, car, mom, item, schema;
return regeneratorRuntime.wrap(function _callee24$(_context24) {
return regeneratorRuntime.wrap(function _callee25$(_context25) {
while (1) {
switch (_context24.prev = _context24.next) {
switch (_context25.prev = _context25.next) {
case 0:

@@ -606,21 +638,21 @@ aCar = { brand: 'Jeep' };

type: String,
autoValue: function autoValue(value, _ref16) {
autoValue: function autoValue(value, _ref17) {
var _this5 = this;
var currentDoc = _ref16.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() {
return regeneratorRuntime.wrap(function _callee17$(_context17) {
var currentDoc = _ref17.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() {
return regeneratorRuntime.wrap(function _callee18$(_context18) {
while (1) {
switch (_context17.prev = _context17.next) {
switch (_context18.prev = _context18.next) {
case 0:
expect(value).toEqual(aCar.brand);
expect(currentDoc).toEqual(aCar);
return _context17.abrupt('return', value);
return _context18.abrupt('return', value);
case 3:
case 'end':
return _context17.stop();
return _context18.stop();
}
}
}, _callee17, _this5);
}, _callee18, _this5);
}))();

@@ -632,17 +664,17 @@ }

return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() {
return regeneratorRuntime.wrap(function _callee18$(_context18) {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() {
return regeneratorRuntime.wrap(function _callee19$(_context19) {
while (1) {
switch (_context18.prev = _context18.next) {
switch (_context19.prev = _context19.next) {
case 0:
expect(value).toEqual(aMom.car);
expect(info.currentDoc).toEqual(aMom);
return _context18.abrupt('return', value);
return _context19.abrupt('return', value);
case 3:
case 'end':
return _context18.stop();
return _context19.stop();
}
}
}, _callee18, _this6);
}, _callee19, _this6);
}))();

@@ -654,21 +686,21 @@ }

type: String,
autoValue: function autoValue(value, _ref17) {
autoValue: function autoValue(value, _ref18) {
var _this7 = this;
var currentDoc = _ref17.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() {
return regeneratorRuntime.wrap(function _callee19$(_context19) {
var currentDoc = _ref18.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() {
return regeneratorRuntime.wrap(function _callee20$(_context20) {
while (1) {
switch (_context19.prev = _context19.next) {
switch (_context20.prev = _context20.next) {
case 0:
expect(value).toEqual(aMom.name);
expect(currentDoc).toEqual(aMom);
return _context19.abrupt('return', value);
return _context20.abrupt('return', value);
case 3:
case 'end':
return _context19.stop();
return _context20.stop();
}
}
}, _callee19, _this7);
}, _callee20, _this7);
}))();

@@ -679,22 +711,22 @@ }

type: car,
autoValue: function autoValue(value, _ref18) {
autoValue: function autoValue(value, _ref19) {
var _this8 = this;
var currentDoc = _ref18.currentDoc,
doc = _ref18.doc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() {
return regeneratorRuntime.wrap(function _callee20$(_context20) {
var currentDoc = _ref19.currentDoc,
doc = _ref19.doc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {
return regeneratorRuntime.wrap(function _callee21$(_context21) {
while (1) {
switch (_context20.prev = _context20.next) {
switch (_context21.prev = _context21.next) {
case 0:
expect(value).toEqual(aMom.car);
expect(currentDoc).toEqual(aMom);
return _context20.abrupt('return', value);
return _context21.abrupt('return', value);
case 3:
case 'end':
return _context20.stop();
return _context21.stop();
}
}
}, _callee20, _this8);
}, _callee21, _this8);
}))();

@@ -707,21 +739,21 @@ }

type: String,
autoValue: function autoValue(value, _ref19) {
autoValue: function autoValue(value, _ref20) {
var _this9 = this;
var currentDoc = _ref19.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {
return regeneratorRuntime.wrap(function _callee21$(_context21) {
var currentDoc = _ref20.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
return regeneratorRuntime.wrap(function _callee22$(_context22) {
while (1) {
switch (_context21.prev = _context21.next) {
switch (_context22.prev = _context22.next) {
case 0:
expect(value).toEqual(aItem.name);
expect(currentDoc).toEqual(aItem);
return _context21.abrupt('return', value);
return _context22.abrupt('return', value);
case 3:
case 'end':
return _context21.stop();
return _context22.stop();
}
}
}, _callee21, _this9);
}, _callee22, _this9);
}))();

@@ -732,21 +764,21 @@ }

type: mom,
autoValue: function autoValue(value, _ref20) {
autoValue: function autoValue(value, _ref21) {
var _this10 = this;
var currentDoc = _ref20.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
return regeneratorRuntime.wrap(function _callee22$(_context22) {
var currentDoc = _ref21.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23() {
return regeneratorRuntime.wrap(function _callee23$(_context23) {
while (1) {
switch (_context22.prev = _context22.next) {
switch (_context23.prev = _context23.next) {
case 0:
expect(value).toEqual(aItem.mom);
expect(currentDoc).toEqual(aItem);
return _context22.abrupt('return', value);
return _context23.abrupt('return', value);
case 3:
case 'end':
return _context22.stop();
return _context23.stop();
}
}
}, _callee22, _this10);
}, _callee23, _this10);
}))();

@@ -759,21 +791,21 @@ }

type: [item],
autoValue: function autoValue(value, _ref21) {
autoValue: function autoValue(value, _ref22) {
var _this11 = this;
var currentDoc = _ref21.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23() {
return regeneratorRuntime.wrap(function _callee23$(_context23) {
var currentDoc = _ref22.currentDoc;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24() {
return regeneratorRuntime.wrap(function _callee24$(_context24) {
while (1) {
switch (_context23.prev = _context23.next) {
switch (_context24.prev = _context24.next) {
case 0:
expect(value).toEqual(doc.items);
expect(currentDoc).toEqual(doc);
return _context23.abrupt('return', value);
return _context24.abrupt('return', value);
case 3:
case 'end':
return _context23.stop();
return _context24.stop();
}
}
}, _callee23, _this11);
}, _callee24, _this11);
}))();

@@ -786,3 +818,3 @@ }

expect.assertions(14);
_context24.next = 11;
_context25.next = 11;
return (0, _index2.default)(schema, doc);

@@ -792,6 +824,6 @@

case 'end':
return _context24.stop();
return _context25.stop();
}
}
}, _callee24, undefined);
}, _callee25, undefined);
})));
{
"name": "@orion-js/schema",
"version": "0.0.38",
"version": "0.0.39",
"main": "index.js",

@@ -5,0 +5,0 @@ "author": "nicolaslopezj",

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