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

mongorito-tcomb

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongorito-tcomb - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0-alpha.1

examples/simple.js

103

lib/extract_lists.js

@@ -1,58 +0,53 @@

// Generated by CoffeeScript 1.10.0
(function() {
var extractLists, get;
'use strict';
get = require('get-value');
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
module.exports = extractLists = function(attrs, paths) {
var after, arr, before, elt, i, j, k, l, len, len1, len2, len3, len4, lists, m, n, newAttrs, newPaths, noLists, path, ref, ref1, ref2, test, type;
noLists = [];
lists = [];
for (j = 0, len = paths.length; j < len; j++) {
ref = paths[j], path = ref.path, type = ref.type;
test = path.split('.0')[0];
if (test !== path) {
lists.push({
path: path,
type: type
});
} else {
noLists.push({
path: path,
type: type
});
}
var get = require('get-value');
function extractLists(attrs, paths) {
var noLists = [];
var lists = [];
for (var _ref of paths) {
var path = _ref.path;
var type = _ref.type;
var _path$split = path.split('.0');
var _path$split2 = _slicedToArray(_path$split, 1);
var test = _path$split2[0];
if (test !== path) lists.push({ path: path, type: type });else noLists.push({ path: path, type: type });
}
for (var _ref2 of lists) {
var path = _ref2.path;
var type = _ref2.type;
var _path$split3 = path.split('.0', 2);
var _path$split4 = _slicedToArray(_path$split3, 2);
var before = _path$split4[0];
var after = _path$split4[1];
var arr = get(attrs, before);
var newPaths = [];
var newAttrs = [];
for (var i = 0, len_ = arr.length; i < len_; ++i) {
var elt = arr[i];
newPaths.push({ path: `${ before }.${ i }`, type: type });
newAttrs.push(elt);
}
for (k = 0, len1 = lists.length; k < len1; k++) {
ref1 = lists[k], path = ref1.path, type = ref1.type;
ref2 = path.split('.0', 2), before = ref2[0], after = ref2[1];
arr = get(attrs, before);
newPaths = [];
newAttrs = [];
for (i = l = 0, len2 = arr.length; l < len2; i = ++l) {
elt = arr[i];
newPaths.push({
path: before + "." + i,
type: type
});
newAttrs.push(elt);
}
if (!after) {
for (m = 0, len3 = newPaths.length; m < len3; m++) {
path = newPaths[m];
noLists.push(path);
}
} else {
for (n = 0, len4 = newAttrs.length; n < len4; n++) {
elt = newAttrs[n];
noLists = noLists.concat(extractLists(elt, {
path: after,
type: type
}));
}
}
}
return noLists;
};
}).call(this);
if (!after) for (var path of newPaths) noLists.push(path);else for (var elt of newAttrs) noLists = noLists.concat(extractLists(elt, [{ path: after, type: type }]));
}
return noLists;
}
module.exports = extractLists;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9leHRyYWN0X2xpc3RzLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxJQUFJLE1BQU0sUUFBUSxXQUFSLENBQU47O0FBRUosU0FBUyxZQUFULENBQXNCLEtBQXRCLEVBQTZCLEtBQTdCLEVBQW9DO0FBQ2xDLE1BQUksVUFBVSxFQUFWLENBRDhCO0FBRWxDLE1BQUksUUFBVSxFQUFWLENBRjhCOztBQUlsQyxtQkFBeUIsS0FBekIsRUFBZ0M7UUFBdEIsaUJBQXNCO1FBQWhCLGlCQUFnQjs7c0JBQ2pCLEtBQUssS0FBTCxDQUFXLElBQVgsRUFEaUI7Ozs7UUFDekIsdUJBRHlCOztBQUU5QixRQUFJLFNBQVMsSUFBVCxFQUNGLE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IGVsc2VcbiAgICAgIGZvciAodmFyIGVsdCBvZiBuZXdBdHRycylcbiAgICAgICAgbm9MaXN0cyA9IG5vTGlzdHMuY29uY2F0KGV4dHJhY3RMaXN0cyhlbHQsIFt7cGF0aDogYWZ0ZXIsIHR5cGV9XSkpXG4gIH1cblxuICByZXR1cm4gbm9MaXN0c1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IGV4dHJhY3RMaXN0c1xuIl19

@@ -1,42 +0,38 @@

// Generated by CoffeeScript 1.10.0
(function() {
var getPathForType;
'use strict';
module.exports = getPathForType = function(type, name, currentPath) {
var currentKind, dot, k, paths, ref, v;
if (currentPath == null) {
currentPath = '';
}
currentKind = type.meta.kind;
switch (currentKind) {
case 'struct':
paths = [];
ref = type.meta.props;
for (k in ref) {
v = ref[k];
dot = currentPath.concat((currentPath ? '.' : ''));
paths = paths.concat(getPathForType(v, name, dot.concat(k)));
}
return paths;
case 'maybe':
return getPathForType(type.meta.type, name, "".concat(currentPath));
case 'list':
dot = currentPath.concat((currentPath ? '.' : ''));
return getPathForType(type.meta.type, name, dot.concat('0'));
case 'irreducible':
case 'subtype':
if (type.meta.name === name) {
return [
{
path: "" + currentPath,
type: type
}
];
}
return [];
default:
return [];
}
};
function getPathForType(type, name) {
let currentPath = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
}).call(this);
var currentKind = type.meta.kind;
var dot = '';
if (currentPath) dot = currentPath.concat('.');
switch (currentKind) {
case 'struct':
var paths = [];
for (var key in type.meta.props) {
var value = type.meta.props[key];
paths = paths.concat(getPathForType(value, name, dot.concat(key)));
}
return paths;
case 'maybe':
return getPathForType(type.meta.type, name, "".concat(currentPath));
case 'list':
return getPathForType(type.meta.type, name, dot.concat('0'));
case 'irreducible':
case 'subtype':
if (type.meta.name === name) return [{ path: "" + currentPath, type: type }];else return [];
default:
throw new Error(`Type unsupported ${ currentKind }`);
}
}
module.exports = getPathForType;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIj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oKSlcblxuICAgIGNhc2UgJ2xpc3QnOlxuICAgICAgcmV0dXJuIGdldFBhdGhGb3JUeXBlKHR5cGUubWV0YS50eXBlLCBuYW1lLCAoZG90LmNvbmNhdCgnMCcpKSlcblxuICAgIGNhc2UgJ2lycmVkdWNpYmxlJzpcbiAgICBjYXNlICdzdWJ0eXBlJzpcbiAgICAgIGlmICh0eXBlLm1ldGEubmFtZSA9PT0gbmFtZSlcbiAgICAgICAgcmV0dXJuIFt7cGF0aDogXCJcIiArIGN1cnJlbnRQYXRoLCB0eXBlfV1cbiAgICAgIGVsc2VcbiAgICAgICAgcmV0dXJuIFtdXG5cbiAgICBkZWZhdWx0OlxuICAgICAgdGhyb3cgbmV3IEVycm9yKGBUeXBlIHVuc3VwcG9ydGVkICR7Y3VycmVudEtpbmR9YClcbiAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IGdldFBhdGhGb3JUeXBlXG4iXX0=

@@ -1,136 +0,66 @@

// Generated by CoffeeScript 1.10.0
(function() {
var ID, Mongorito, co, extractLists, getPathForType, patch, regexID, t, unique,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice;
"use strict";
require('colors');
require('colors');
t = require('tcomb-validation');
var _tcombValidation = require('tcomb-validation');
getPathForType = require('./get_path_for_type');
var _tcombValidation2 = _interopRequireDefault(_tcombValidation);
extractLists = require('./extract_lists');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
co = require('co');
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { 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 { return Promise.resolve(value).then(function (value) { return step("next", value); }, function (err) { return step("throw", err); }); } } return step("next"); }); }; }
patch = function(Model) {
var Son;
Son = (function(superClass) {
extend(Son, superClass);
function patch(Model) {
class Son extends Model {
constructor() {
super(...arguments);
this.haveShemama = Boolean(this.Schema);
if (!this.haveShema) console.warn("[Warning] No Schema!".yellow);
if (this.haveShema && (!this.Schema.meta || this.Schema.meta.kind !== 'struct')) throw new Error('The Schema need to be of kind struct');
}
function Son() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
this.haveSchema = Boolean(this.Schema);
if (!this.haveSchema) {
console.warn("[Warning] No Schema!".yellow);
}
if (this.haveSchema && (!this.Schema.meta || this.Schema.meta.kind !== 'struct')) {
throw new Error('The Schema need to be of kind Struct');
}
if (this.haveSchema) {
this.ids = getPathForType(this.Schema, 'ID');
}
Son.__super__.constructor.apply(this, args);
}
configure() {
super.configure();
if (!this.Schema) return;
this.before('save', 'validate');
}
Son.prototype.configure = function() {
Son.__super__.configure.call(this);
if (!this.Schema) {
return;
}
this.before('save', 'validate');
return this.before('save', 'ensureUnique');
};
validate() {
var _this = this;
Son.prototype.validateIDs = co.wrap(function*() {
var id, ids, j, len, path, ref1, results, type;
ids = extractLists(this.attributes, this.ids);
results = [];
for (j = 0, len = ids.length; j < len; j++) {
ref1 = ids[j], path = ref1.path, type = ref1.type;
id = this.get(path);
if (id && !((yield type.meta.Model.findById("" + id)))) {
throw new Error(path + " have not a valid id");
} else {
results.push(void 0);
}
}
return results;
});
return _asyncToGenerator(function* () {
_this.asyncValidations = [];
var val = _tcombValidation2.default.validate(_this.get(), _this.Schema);
if (!val.isValid()) throw val.errors;
Son.prototype.ensureUnique = co.wrap(function*() {
var hook, i, j, k, len, len1, path, ref1, ref2, results, type, uniques;
uniques = getPathForType(this.Schema, 'unique');
for (j = 0, len = uniques.length; j < len; j++) {
ref1 = uniques[j], path = ref1.path, type = ref1.type;
(yield this.constructor.index(path, {
unique: true
}));
for (var validator of _this.asyncValidations) {
yield validator();
}
ref2 = this._hooks.before.save;
results = [];
for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
hook = ref2[i];
if (hook === this.ensureUnique) {
delete this._hooks.before.save[i];
break;
} else {
results.push(void 0);
}
}
return results;
});
})();
}
}
Son.prototype.validate = co.wrap(function*() {
var val;
val = t.validate(this.get(), this.Schema);
if (!val.isValid()) {
throw val.errors;
}
return (yield this.validateIDs());
});
return Son;
}
return Son;
})(Model);
return Son;
};
unique = function(Type) {
return t.refinement(Type, (function() {
var regexID = /^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)/i;
function ID(ctx, Model) {
return _tcombValidation2.default.refinement(_tcombValidation2.default.String, str => {
if (!regexID.test(str)) return false;
ctx.asyncValidations.push(_asyncToGenerator(function* () {
const res = yield Model.findById('' + str);
if (!res) throw new Error(`${ str } is not a valid ID for ${ Model.name }`);
return true;
}), 'unique');
};
}));
return true;
}, 'ID');
}
regexID = /^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)/i;
var Mongorito = require('mongorito');
Mongorito.Model = patch(Mongorito.Model);
Mongorito.patch = patch;
Mongorito.t = require('tcomb');
Mongorito.t.ID = ID;
ID = function(Model) {
var ref;
ref = t.refinement(t.String, function(str) {
if (!regexID.test(str)) {
return false;
}
return true;
}, "ID");
ref.meta.Model = Model;
return ref;
};
Mongorito = require('mongorito');
Mongorito.Model = patch(Mongorito.Model);
Mongorito.patch = patch;
Mongorito.t = require('tcomb');
Mongorito.t.unique = unique;
Mongorito.t.ID = ID;
module.exports = Mongorito;
}).call(this);
module.exports = Mongorito;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7QUFDQTs7QUFDQTs7Ozs7Ozs7QUFFQSxTQUFTLEtBQVQsQ0FBZSxLQUFmLEVBQXNCO0FBQ3BCLFFBQU0sR0FBTixTQUFrQixLQUFsQixDQUF3QjtBQUN0QixrQkFBcUI7QUFDbkIsWUFBTSxZ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yaW5nLCAoc3RyKSA9PiB7XG4gICAgaWYgKCFyZWdleElELnRlc3Qoc3RyKSlcbiAgICAgIHJldHVybiBmYWxzZVxuICAgIGN0eC5hc3luY1ZhbGlkYXRpb25zLnB1c2goYXN5bmMgKCkgPT4ge1xuICAgICAgY29uc3QgcmVzID0gYXdhaXQgTW9kZWwuZmluZEJ5SWQoJycgKyBzdHIpXG4gICAgICBpZiAoIXJlcylcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGAke3N0cn0gaXMgbm90IGEgdmFsaWQgSUQgZm9yICR7TW9kZWwubmFtZX1gKVxuICAgICAgcmV0dXJuIHRydWVcbiAgICB9KVxuICAgIHJldHVybiB0cnVlXG4gIH0sICdJRCcpXG59XG5cbnZhciBNb25nb3JpdG8gICAgICA9IHJlcXVpcmUoJ21vbmdvcml0bycpXG5Nb25nb3JpdG8uTW9kZWwgICAgPSBwYXRjaChNb25nb3JpdG8uTW9kZWwpXG5Nb25nb3JpdG8ucGF0Y2ggICAgPSBwYXRjaFxuTW9uZ29yaXRvLnQgICAgICAgID0gcmVxdWlyZSgndGNvbWInKVxuTW9uZ29yaXRvLnQuSUQgICAgID0gSURcblxubW9kdWxlLmV4cG9ydHMgPSBNb25nb3JpdG9cbiJdfQ==
{
"name": "mongorito-tcomb",
"version": "1.0.0",
"version": "2.0.0-alpha.1",
"description": "Bring schema validation to Mongorito thanks to tcomb",
"main": "./lib/index.js",
"scripts": {
"build": "./node_modules/coffee-script/bin/coffee -o lib -c src",
"test": "nyc ava tests.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"prepublish": "npm run build"
"build": "babel src -d lib",
"pretest": "npm run build",
"prepublish": "npm run build",
"test": "nyc ava",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},

@@ -30,3 +31,22 @@ "repository": {

"homepage": "https://github.com/xouabita/mongorito-tcomb#readme",
"babel": {
"presets": [
"es2015-node5",
"stage-0"
],
"env": {
"development": {
"sourceMaps": "inline"
}
}
},
"publishConfig": {
"tag": "next"
},
"ava": {
"babel": "inherit"
},
"dependencies": {
"babel-preset-es2015-node5": "^1.2.0",
"babel-preset-stage-0": "^6.5.0",
"co": "^4.6.0",

@@ -42,6 +62,6 @@ "colors": "^1.1.2",

"ava": "^0.13.0",
"co": "^4.6.0",
"coffee-script": "^1.10.0",
"coveralls": "^2.11.6"
"babel-cli": "^6.6.5",
"coveralls": "^2.11.6",
"nyc": "^6.1.1"
}
}

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