Comparing version 5.5.1 to 5.6.0
@@ -0,1 +1,2 @@ | ||
/** @format */ | ||
export declare const methods: { | ||
@@ -2,0 +3,0 @@ staticMethods: {}; |
"use strict"; | ||
/** @format */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -9,4 +10,4 @@ exports.methods = { staticMethods: {}, instanceMethods: {} }; | ||
exports.plugins = {}; | ||
// tslint:disable-next-line:ban-types | ||
// tslint:disable-next-line: ban-types | ||
exports.constructors = {}; | ||
//# sourceMappingURL=data.js.map | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxjQUFjOztBQUVELFFBQUEsT0FBTyxHQUFHLEVBQUUsYUFBYSxFQUFFLEVBQUUsRUFBRSxlQUFlLEVBQUUsRUFBRSxFQUFFLENBQUM7QUFDckQsUUFBQSxNQUFNLEdBQUcsRUFBRSxDQUFDO0FBQ1osUUFBQSxNQUFNLEdBQUcsRUFBRSxDQUFDO0FBQ1osUUFBQSxRQUFRLEdBQUcsRUFBRSxDQUFDO0FBQ2QsUUFBQSxLQUFLLEdBQUcsRUFBRSxDQUFDO0FBQ1gsUUFBQSxPQUFPLEdBQUcsRUFBRSxDQUFDO0FBQzFCLHNDQUFzQztBQUN6QixRQUFBLFlBQVksR0FBZ0MsRUFBRSxDQUFDIn0= |
@@ -0,3 +1,4 @@ | ||
/** @format */ | ||
export declare class InvalidPropError extends Error { | ||
constructor(typeName: any, key: string); | ||
constructor(typeName: string, key: string); | ||
} | ||
@@ -4,0 +5,0 @@ export declare class NotNumberTypeError extends Error { |
"use strict"; | ||
/** @format */ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class InvalidPropError extends Error { | ||
constructor(typeName, key) { | ||
super(`In property ${key}: ${typeName} is not a primitive type nor a Typegoose schema (Not extending it).`); | ||
var InvalidPropError = /** @class */ (function (_super) { | ||
__extends(InvalidPropError, _super); | ||
function InvalidPropError(typeName, key) { | ||
return _super.call(this, "In property " + key + ": " + typeName + " is not a primitive type nor a Typegoose schema (Not extending it).") || this; | ||
} | ||
} | ||
return InvalidPropError; | ||
}(Error)); | ||
exports.InvalidPropError = InvalidPropError; | ||
class NotNumberTypeError extends Error { | ||
constructor(key) { | ||
super(`Type of ${key} property is not a number.`); | ||
var NotNumberTypeError = /** @class */ (function (_super) { | ||
__extends(NotNumberTypeError, _super); | ||
function NotNumberTypeError(key) { | ||
return _super.call(this, "Type of " + key + " property is not a number.") || this; | ||
} | ||
} | ||
return NotNumberTypeError; | ||
}(Error)); | ||
exports.NotNumberTypeError = NotNumberTypeError; | ||
class NotStringTypeError extends Error { | ||
constructor(key) { | ||
super(`Type of ${key} property is not a string.`); | ||
var NotStringTypeError = /** @class */ (function (_super) { | ||
__extends(NotStringTypeError, _super); | ||
function NotStringTypeError(key) { | ||
return _super.call(this, "Type of " + key + " property is not a string.") || this; | ||
} | ||
} | ||
return NotStringTypeError; | ||
}(Error)); | ||
exports.NotStringTypeError = NotStringTypeError; | ||
class NoMetadataError extends Error { | ||
constructor(key) { | ||
super(`There is no metadata for the "${key}" property. ` + | ||
var NoMetadataError = /** @class */ (function (_super) { | ||
__extends(NoMetadataError, _super); | ||
function NoMetadataError(key) { | ||
return _super.call(this, "There is no metadata for the \"" + key + "\" property. " + | ||
'Check if emitDecoratorMetadata is enabled in tsconfig.json ' + | ||
'or check if you\'ve declared a sub document\'s class after usage.'); | ||
"or check if you've declared a sub document's class after usage.") || this; | ||
} | ||
} | ||
return NoMetadataError; | ||
}(Error)); | ||
exports.NoMetadataError = NoMetadataError; | ||
//# sourceMappingURL=errors.js.map | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2Vycm9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsY0FBYzs7Ozs7Ozs7Ozs7O0FBRWQ7SUFBc0Msb0NBQUs7SUFDekMsMEJBQVksUUFBZ0IsRUFBRSxHQUFXO2VBQ3ZDLGtCQUFNLGlCQUFlLEdBQUcsVUFBSyxRQUFRLHdFQUFxRSxDQUFDO0lBQzdHLENBQUM7SUFDSCx1QkFBQztBQUFELENBQUMsQUFKRCxDQUFzQyxLQUFLLEdBSTFDO0FBSlksNENBQWdCO0FBTTdCO0lBQXdDLHNDQUFLO0lBQzNDLDRCQUFZLEdBQVc7ZUFDckIsa0JBQU0sYUFBVyxHQUFHLCtCQUE0QixDQUFDO0lBQ25ELENBQUM7SUFDSCx5QkFBQztBQUFELENBQUMsQUFKRCxDQUF3QyxLQUFLLEdBSTVDO0FBSlksZ0RBQWtCO0FBTS9CO0lBQXdDLHNDQUFLO0lBQzNDLDRCQUFZLEdBQVc7ZUFDckIsa0JBQU0sYUFBVyxHQUFHLCtCQUE0QixDQUFDO0lBQ25ELENBQUM7SUFDSCx5QkFBQztBQUFELENBQUMsQUFKRCxDQUF3QyxLQUFLLEdBSTVDO0FBSlksZ0RBQWtCO0FBTS9CO0lBQXFDLG1DQUFLO0lBQ3hDLHlCQUFZLEdBQVc7ZUFDckIsa0JBQ0Usb0NBQWlDLEdBQUcsa0JBQWM7WUFDaEQsNkRBQTZEO1lBQzdELGlFQUFpRSxDQUNwRTtJQUNILENBQUM7SUFDSCxzQkFBQztBQUFELENBQUMsQUFSRCxDQUFxQyxLQUFLLEdBUXpDO0FBUlksMENBQWUifQ== |
@@ -0,1 +1,2 @@ | ||
/** @format */ | ||
import { MongooseDocument } from 'mongoose'; | ||
@@ -9,3 +10,3 @@ declare type DocumentMethod = 'init' | 'validate' | 'save' | 'remove'; | ||
declare type DocumentPreParallelFn<T> = (this: TypegooseDoc<T>, next: HookNextFn, done: PreDoneFn) => void; | ||
declare type SimplePreSerialFn<T> = (next: HookNextFn) => void; | ||
declare type SimplePreSerialFn<T> = (next: HookNextFn, docs?: any[]) => void; | ||
declare type SimplePreParallelFn<T> = (next: HookNextFn, done: PreDoneFn) => void; | ||
@@ -12,0 +13,0 @@ declare type ModelPostFn<T> = (result: any, next?: HookNextFn) => void; |
"use strict"; | ||
/** @format */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const data_1 = require("./data"); | ||
const hooks = { | ||
pre(...args) { | ||
return (constructor) => { | ||
var data_1 = require("./data"); | ||
var hooks = { | ||
pre: function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return function (constructor) { | ||
addToHooks(constructor.name, 'pre', args); | ||
}; | ||
}, | ||
post(...args) { | ||
return (constructor) => { | ||
post: function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return function (constructor) { | ||
addToHooks(constructor.name, 'post', args); | ||
@@ -16,3 +25,3 @@ }; | ||
}; | ||
const addToHooks = (name, hookType, args) => { | ||
var addToHooks = function (name, hookType, args) { | ||
if (!data_1.hooks[name]) { | ||
@@ -25,2 +34,2 @@ data_1.hooks[name] = { pre: [], post: [] }; | ||
exports.post = hooks.post; | ||
//# sourceMappingURL=hooks.js.map | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9va3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyI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9 |
@@ -1,4 +0,2 @@ | ||
/** | ||
* copy-paste from mongodb package (should be same as IndexOptions from 'mongodb') | ||
*/ | ||
/** @format */ | ||
export interface IndexOptions { | ||
@@ -5,0 +3,0 @@ /** |
"use strict"; | ||
/** @format */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -7,9 +8,9 @@ /** | ||
*/ | ||
exports.index = (fields, options) => { | ||
return (constructor) => { | ||
const indices = Reflect.getMetadata('typegoose:indices', constructor) || []; | ||
indices.push({ fields, options }); | ||
exports.index = function (fields, options) { | ||
return function (constructor) { | ||
var indices = Reflect.getMetadata('typegoose:indices', constructor) || []; | ||
indices.push({ fields: fields, options: options }); | ||
Reflect.defineMetadata('typegoose:indices', indices, constructor); | ||
}; | ||
}; | ||
//# sourceMappingURL=index.js.map | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGNBQWM7O0FBOERkOzs7R0FHRztBQUNVLFFBQUEsS0FBSyxHQUFHLFVBQUMsTUFBVyxFQUFFLE9BQXNCO0lBQ3ZELE9BQU8sVUFBQyxXQUFnQjtRQUN0QixJQUFNLE9BQU8sR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLG1CQUFtQixFQUFFLFdBQVcsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUM1RSxPQUFPLENBQUMsSUFBSSxDQUFDLEVBQUUsTUFBTSxRQUFBLEVBQUUsT0FBTyxTQUFBLEVBQUUsQ0FBQyxDQUFDO1FBQ2xDLE9BQU8sQ0FBQyxjQUFjLENBQUMsbUJBQW1CLEVBQUUsT0FBTyxFQUFFLFdBQVcsQ0FBQyxDQUFDO0lBQ3BFLENBQUMsQ0FBQztBQUNKLENBQUMsQ0FBQyJ9 |
@@ -0,2 +1,3 @@ | ||
/** @format */ | ||
export declare const staticMethod: (target: any, key: string, descriptor: TypedPropertyDescriptor<any>) => void; | ||
export declare const instanceMethod: (target: any, key: string, descriptor: TypedPropertyDescriptor<any>) => void; |
"use strict"; | ||
/** @format */ | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const data_1 = require("./data"); | ||
const baseMethod = (target, key, descriptor, methodType) => { | ||
var data_1 = require("./data"); | ||
var baseMethod = function (target, key, descriptor, methodType) { | ||
var _a; | ||
if (descriptor === undefined) { | ||
descriptor = Object.getOwnPropertyDescriptor(target, key); | ||
} | ||
let name; | ||
var name; | ||
if (methodType === 'instanceMethods') { | ||
@@ -18,7 +28,11 @@ name = target.constructor.name; | ||
} | ||
const method = descriptor.value; | ||
data_1.methods[methodType][name] = Object.assign({}, data_1.methods[methodType][name], { [key]: method }); | ||
var method = descriptor.value; | ||
data_1.methods[methodType][name] = __assign({}, data_1.methods[methodType][name], (_a = {}, _a[key] = method, _a)); | ||
}; | ||
exports.staticMethod = (target, key, descriptor) => baseMethod(target, key, descriptor, 'staticMethods'); | ||
exports.instanceMethod = (target, key, descriptor) => baseMethod(target, key, descriptor, 'instanceMethods'); | ||
//# sourceMappingURL=method.js.map | ||
exports.staticMethod = function (target, key, descriptor) { | ||
return baseMethod(target, key, descriptor, 'staticMethods'); | ||
}; | ||
exports.instanceMethod = function (target, key, descriptor) { | ||
return baseMethod(target, key, descriptor, 'instanceMethods'); | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0aG9kLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL21ldGhvZC50cyJdLCJuYW1lcyI6W10sIm1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GVBQWUsQ0FBQztBQUFwRCxDQUFvRCxDQUFDO0FBRTFDLFFBQUEsY0FBYyxHQUFHLFVBQUMsTUFBVyxFQUFFLEdBQVcsRUFBRSxVQUF3QztJQUMvRixPQUFBLFVBQVUsQ0FBQyxNQUFNLEVBQUUsR0FBRyxFQUFFLFVBQVUsRUFBRSxpQkFBaUIsQ0FBQztBQUF0RCxDQUFzRCxDQUFDIn0= |
@@ -0,1 +1,2 @@ | ||
/** @format */ | ||
export declare const plugin: (mongoosePlugin: any, options?: any) => (constructor: any) => void; |
"use strict"; | ||
/** @format */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const data_1 = require("./data"); | ||
exports.plugin = (mongoosePlugin, options) => (constructor) => { | ||
const name = constructor.name; | ||
var data_1 = require("./data"); | ||
exports.plugin = function (mongoosePlugin, options) { return function (constructor) { | ||
var name = constructor.name; | ||
if (!data_1.plugins[name]) { | ||
data_1.plugins[name] = []; | ||
} | ||
data_1.plugins[name].push({ mongoosePlugin, options }); | ||
}; | ||
//# sourceMappingURL=plugin.js.map | ||
data_1.plugins[name].push({ mongoosePlugin: mongoosePlugin, options: options }); | ||
}; }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2luLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3BsdWdpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsY0FBYzs7QUFFZCwrQkFBaUM7QUFFcEIsUUFBQSxNQUFNLEdBQUcsVUFBQyxjQUFtQixFQUFFLE9BQWEsSUFBSyxPQUFBLFVBQUMsV0FBZ0I7SUFDN0UsSUFBTSxJQUFJLEdBQVcsV0FBVyxDQUFDLElBQUksQ0FBQztJQUN0QyxJQUFJLENBQUMsY0FBTyxDQUFDLElBQUksQ0FBQyxFQUFFO1FBQ2xCLGNBQU8sQ0FBQyxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUM7S0FDcEI7SUFDRCxjQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsSUFBSSxDQUFDLEVBQUUsY0FBYyxnQkFBQSxFQUFFLE9BQU8sU0FBQSxFQUFFLENBQUMsQ0FBQztBQUNsRCxDQUFDLEVBTjZELENBTTdELENBQUMifQ== |
@@ -0,1 +1,2 @@ | ||
/** @format */ | ||
import { ObjectID } from 'bson'; | ||
@@ -2,0 +3,0 @@ export declare type Func = (...args: any[]) => any; |
109
lib/prop.js
"use strict"; | ||
/** @format */ | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) | ||
t[p[i]] = s[p[i]]; | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const mongoose = require("mongoose"); | ||
const _ = require("lodash"); | ||
const data_1 = require("./data"); | ||
const utils_1 = require("./utils"); | ||
const errors_1 = require("./errors"); | ||
const isWithStringValidate = (options) => (options.minlength || options.maxlength || options.match); | ||
const isWithStringTransform = (options) => (options.lowercase || options.uppercase || options.trim); | ||
const isWithNumberValidate = (options) => (options.min || options.max); | ||
const baseProp = (rawOptions, Type, target, key, isArray = false) => { | ||
const name = target.constructor.name; | ||
const isGetterSetter = Object.getOwnPropertyDescriptor(target, key); | ||
var mongoose = require("mongoose"); | ||
var data_1 = require("./data"); | ||
var utils_1 = require("./utils"); | ||
var errors_1 = require("./errors"); | ||
var isWithStringValidate = function (options) { | ||
return options.minlength || options.maxlength || options.match; | ||
}; | ||
var isWithStringTransform = function (options) { | ||
return options.lowercase || options.uppercase || options.trim; | ||
}; | ||
var isWithNumberValidate = function (options) { return options.min || options.max; }; | ||
var baseProp = function (rawOptions, Type, target, key, isArray) { | ||
if (isArray === void 0) { isArray = false; } | ||
var name = target.constructor.name; | ||
var isGetterSetter = Object.getOwnPropertyDescriptor(target, key); | ||
if (isGetterSetter) { | ||
@@ -22,3 +44,3 @@ if (isGetterSetter.get) { | ||
} | ||
data_1.virtuals[name][key] = Object.assign({}, data_1.virtuals[name][key], { get: isGetterSetter.get }); | ||
data_1.virtuals[name][key] = __assign({}, data_1.virtuals[name][key], { get: isGetterSetter.get }); | ||
} | ||
@@ -32,3 +54,3 @@ if (isGetterSetter.set) { | ||
} | ||
data_1.virtuals[name][key] = Object.assign({}, data_1.virtuals[name][key], { set: isGetterSetter.set }); | ||
data_1.virtuals[name][key] = __assign({}, data_1.virtuals[name][key], { set: isGetterSetter.set }); | ||
} | ||
@@ -43,20 +65,20 @@ return; | ||
} | ||
const ref = rawOptions.ref; | ||
var ref = rawOptions.ref; | ||
if (typeof ref === 'string') { | ||
data_1.schema[name][key] = Object.assign({}, data_1.schema[name][key], { type: mongoose.Schema.Types.ObjectId, ref }); | ||
data_1.schema[name][key] = __assign({}, data_1.schema[name][key], { type: mongoose.Schema.Types.ObjectId, ref: ref }); | ||
return; | ||
} | ||
else if (ref) { | ||
data_1.schema[name][key] = Object.assign({}, data_1.schema[name][key], { type: mongoose.Schema.Types.ObjectId, ref: ref.name }); | ||
data_1.schema[name][key] = __assign({}, data_1.schema[name][key], { type: mongoose.Schema.Types.ObjectId, ref: ref.name }); | ||
return; | ||
} | ||
const itemsRef = rawOptions.itemsRef; | ||
var itemsRef = rawOptions.itemsRef; | ||
if (itemsRef) { | ||
data_1.schema[name][key][0] = Object.assign({}, data_1.schema[name][key][0], { type: mongoose.Schema.Types.ObjectId, ref: itemsRef.name }); | ||
data_1.schema[name][key][0] = __assign({}, data_1.schema[name][key][0], { type: mongoose.Schema.Types.ObjectId, ref: itemsRef.name }); | ||
return; | ||
} | ||
const enumOption = rawOptions.enum; | ||
var enumOption = rawOptions.enum; | ||
if (enumOption) { | ||
if (!Array.isArray(enumOption)) { | ||
rawOptions.enum = Object.keys(enumOption).map((propKey) => enumOption[propKey]); | ||
rawOptions.enum = Object.keys(enumOption).map(function (propKey) { return enumOption[propKey]; }); | ||
} | ||
@@ -75,14 +97,14 @@ } | ||
} | ||
const instance = new Type(); | ||
const subSchema = data_1.schema[instance.constructor.name]; | ||
var instance = new Type(); | ||
var subSchema = data_1.schema[instance.constructor.name]; | ||
if (!subSchema && !utils_1.isPrimitive(Type) && !utils_1.isObject(Type)) { | ||
throw new errors_1.InvalidPropError(Type.name, key); | ||
} | ||
const options = _.omit(rawOptions, ['ref', 'items']); | ||
var r = rawOptions["ref"], i = rawOptions["items"], options = __rest(rawOptions, ['ref', 'items']); | ||
if (utils_1.isPrimitive(Type)) { | ||
if (isArray) { | ||
data_1.schema[name][key] = Object.assign({}, data_1.schema[name][key][0], options, { type: [Type] }); | ||
data_1.schema[name][key] = __assign({}, data_1.schema[name][key][0], options, { type: [Type] }); | ||
return; | ||
} | ||
data_1.schema[name][key] = Object.assign({}, data_1.schema[name][key], options, { type: Type }); | ||
data_1.schema[name][key] = __assign({}, data_1.schema[name][key], options, { type: Type }); | ||
return; | ||
@@ -93,30 +115,33 @@ } | ||
if (utils_1.isObject(Type) && !subSchema) { | ||
data_1.schema[name][key] = Object.assign({}, data_1.schema[name][key], options, { type: Object }); | ||
data_1.schema[name][key] = __assign({}, data_1.schema[name][key], options, { type: Object }); | ||
return; | ||
} | ||
if (isArray) { | ||
data_1.schema[name][key][0] = Object.assign({}, data_1.schema[name][key][0], options, subSchema); | ||
data_1.schema[name][key][0] = __assign({}, data_1.schema[name][key][0], options, subSchema); | ||
return; | ||
} | ||
const Schema = mongoose.Schema; | ||
const supressSubschemaId = rawOptions._id === false; | ||
const virtualSchema = new Schema(Object.assign({}, subSchema), supressSubschemaId ? { _id: false } : {}); | ||
const schemaInstanceMethods = data_1.methods.instanceMethods[instance.constructor.name]; | ||
var Schema = mongoose.Schema; | ||
var supressSubschemaId = rawOptions._id === false; | ||
var virtualSchema = new Schema(__assign({}, subSchema), supressSubschemaId ? { _id: false } : {}); | ||
var schemaInstanceMethods = data_1.methods.instanceMethods[instance.constructor.name]; | ||
if (schemaInstanceMethods) { | ||
virtualSchema.methods = schemaInstanceMethods; | ||
} | ||
data_1.schema[name][key] = Object.assign({}, data_1.schema[name][key], options, { type: virtualSchema }); | ||
data_1.schema[name][key] = __assign({}, data_1.schema[name][key], options, { type: virtualSchema }); | ||
return; | ||
}; | ||
exports.prop = (options = {}) => (target, key) => { | ||
const Type = Reflect.getMetadata('design:type', target, key); | ||
if (!Type) { | ||
throw new errors_1.NoMetadataError(key); | ||
} | ||
baseProp(options, Type, target, key); | ||
exports.prop = function (options) { | ||
if (options === void 0) { options = {}; } | ||
return function (target, key) { | ||
var Type = Reflect.getMetadata('design:type', target, key); | ||
if (!Type) { | ||
throw new errors_1.NoMetadataError(key); | ||
} | ||
baseProp(options, Type, target, key); | ||
}; | ||
}; | ||
exports.arrayProp = (options) => (target, key) => { | ||
const Type = options.items; | ||
exports.arrayProp = function (options) { return function (target, key) { | ||
var Type = options.items; | ||
baseProp(options, Type, target, key, true); | ||
}; | ||
//# sourceMappingURL=prop.js.map | ||
}; }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9wcm9wLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxjQUFjOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBRWQsbUNBQXFDO0FBRXJDLCtCQUFtRDtBQUNuRCxpQ0FBK0Y7QUFDL0YsbUNBQXFHO0FBcURyRyxJQUFNLG9CQ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eUIsSUFBSyxPQUFBLFVBQUMsTUFBVyxFQUFFLEdBQVc7SUFDL0UsSUFBTSxJQUFJLEdBQUcsT0FBTyxDQUFDLEtBQUssQ0FBQztJQUMzQixRQUFRLENBQUMsT0FBTyxFQUFFLElBQUksRUFBRSxNQUFNLEVBQUUsR0FBRyxFQUFFLElBQUksQ0FBQyxDQUFDO0FBQzdDLENBQUMsRUFIdUQsQ0FHdkQsQ0FBQyJ9 |
@@ -0,1 +1,2 @@ | ||
/** @format */ | ||
import 'reflect-metadata'; | ||
@@ -2,0 +3,0 @@ import * as mongoose from 'mongoose'; |
"use strict"; | ||
/** @format */ | ||
function __export(m) { | ||
@@ -7,6 +8,5 @@ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
require("reflect-metadata"); | ||
const mongoose = require("mongoose"); | ||
const _ = require("lodash"); | ||
var mongoose = require("mongoose"); | ||
mongoose.Promise = global.Promise; | ||
const data_1 = require("./data"); | ||
var data_1 = require("./data"); | ||
__export(require("./method")); | ||
@@ -19,16 +19,24 @@ __export(require("./prop")); | ||
exports.getClassForDocument = utils_1.getClassForDocument; | ||
class Typegoose { | ||
getModelForClass(t, { existingMongoose, schemaOptions, existingConnection } = {}) { | ||
const name = this.constructor.name; | ||
var Typegoose = /** @class */ (function () { | ||
function Typegoose() { | ||
} | ||
Typegoose.prototype.getModelForClass = function (t, _a) { | ||
var _b = _a === void 0 ? {} : _a, existingMongoose = _b.existingMongoose, schemaOptions = _b.schemaOptions, existingConnection = _b.existingConnection; | ||
var name = this.constructor.name; | ||
if (!data_1.models[name]) { | ||
this.setModelForClass(t, { existingMongoose, schemaOptions, existingConnection }); | ||
this.setModelForClass(t, { | ||
existingMongoose: existingMongoose, | ||
schemaOptions: schemaOptions, | ||
existingConnection: existingConnection, | ||
}); | ||
} | ||
return data_1.models[name]; | ||
} | ||
setModelForClass(t, { existingMongoose, schemaOptions, existingConnection } = {}) { | ||
const name = this.constructor.name; | ||
}; | ||
Typegoose.prototype.setModelForClass = function (t, _a) { | ||
var _b = _a === void 0 ? {} : _a, existingMongoose = _b.existingMongoose, schemaOptions = _b.schemaOptions, existingConnection = _b.existingConnection; | ||
var name = this.constructor.name; | ||
// get schema of current model | ||
let sch = this.buildSchema(t, name, schemaOptions); | ||
var sch = this.buildSchema(t, name, schemaOptions); | ||
// get parents class name | ||
let parentCtor = Object.getPrototypeOf(this.constructor.prototype).constructor; | ||
var parentCtor = Object.getPrototypeOf(this.constructor.prototype).constructor; | ||
// iterate trough all parents | ||
@@ -41,3 +49,3 @@ while (parentCtor && parentCtor.name !== 'Typegoose' && parentCtor.name !== 'Object') { | ||
} | ||
let model = mongoose.model.bind(mongoose); | ||
var model = mongoose.model.bind(mongoose); | ||
if (existingConnection) { | ||
@@ -52,9 +60,7 @@ model = existingConnection.model.bind(existingConnection); | ||
return data_1.models[name]; | ||
} | ||
buildSchema(t, name, schemaOptions, sch) { | ||
const Schema = mongoose.Schema; | ||
}; | ||
Typegoose.prototype.buildSchema = function (t, name, schemaOptions, sch) { | ||
var Schema = mongoose.Schema; | ||
if (!sch) { | ||
sch = schemaOptions ? | ||
new Schema(data_1.schema[name], schemaOptions) : | ||
new Schema(data_1.schema[name]); | ||
sch = schemaOptions ? new Schema(data_1.schema[name], schemaOptions) : new Schema(data_1.schema[name]); | ||
} | ||
@@ -64,3 +70,3 @@ else { | ||
} | ||
const staticMethods = data_1.methods.staticMethods[name]; | ||
var staticMethods = data_1.methods.staticMethods[name]; | ||
if (staticMethods) { | ||
@@ -72,3 +78,3 @@ sch.statics = Object.assign(staticMethods, sch.statics || {}); | ||
} | ||
const instanceMethods = data_1.methods.instanceMethods[name]; | ||
var instanceMethods = data_1.methods.instanceMethods[name]; | ||
if (instanceMethods) { | ||
@@ -81,33 +87,41 @@ sch.methods = Object.assign(instanceMethods, sch.methods || {}); | ||
if (data_1.hooks[name]) { | ||
const preHooks = data_1.hooks[name].pre; | ||
preHooks.forEach((preHookArgs) => { | ||
sch.pre(...preHookArgs); | ||
var preHooks = data_1.hooks[name].pre; | ||
preHooks.forEach(function (preHookArgs) { | ||
var _a; | ||
(_a = sch).pre.apply(_a, preHookArgs); | ||
}); | ||
const postHooks = data_1.hooks[name].post; | ||
postHooks.forEach((postHookArgs) => { | ||
sch.post(...postHookArgs); | ||
var postHooks = data_1.hooks[name].post; | ||
postHooks.forEach(function (postHookArgs) { | ||
var _a; | ||
(_a = sch).post.apply(_a, postHookArgs); | ||
}); | ||
} | ||
if (data_1.plugins[name]) { | ||
_.forEach(data_1.plugins[name], (plugin) => { | ||
for (var _i = 0, _a = data_1.plugins[name]; _i < _a.length; _i++) { | ||
var plugin = _a[_i]; | ||
sch.plugin(plugin.mongoosePlugin, plugin.options); | ||
}); | ||
} | ||
} | ||
const getterSetters = data_1.virtuals[name]; | ||
_.forEach(getterSetters, (value, key) => { | ||
if (value.get) { | ||
sch.virtual(key).get(value.get); | ||
var getterSetters = data_1.virtuals[name]; | ||
if (getterSetters) { | ||
for (var _b = 0, _c = Object.keys(getterSetters); _b < _c.length; _b++) { | ||
var key = _c[_b]; | ||
if (getterSetters[key].get) { | ||
sch.virtual(key).get(getterSetters[key].get); | ||
} | ||
if (getterSetters[key].set) { | ||
sch.virtual(key).set(getterSetters[key].set); | ||
} | ||
} | ||
if (value.set) { | ||
sch.virtual(key).set(value.set); | ||
} | ||
}); | ||
const indices = Reflect.getMetadata('typegoose:indices', t) || []; | ||
for (const index of indices) { | ||
} | ||
var indices = Reflect.getMetadata('typegoose:indices', t) || []; | ||
for (var _d = 0, indices_1 = indices; _d < indices_1.length; _d++) { | ||
var index = indices_1[_d]; | ||
sch.index(index.fields, index.options); | ||
} | ||
return sch; | ||
} | ||
} | ||
}; | ||
return Typegoose; | ||
}()); | ||
exports.Typegoose = Typegoose; | ||
//# sourceMappingURL=typegoose.js.map | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZWdvb3NlLmpzIiwic291cmNlUm9vdCI6Ii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imitive: (Type: any) => boolean; |
"use strict"; | ||
/** @format */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const _ = require("lodash"); | ||
const data_1 = require("./data"); | ||
exports.isPrimitive = (Type) => _.includes(['String', 'Number', 'Boolean', 'Date', 'Decimal128'], Type.name); | ||
exports.isObject = (Type) => { | ||
let prototype = Type.prototype; | ||
let name = Type.name; | ||
var data_1 = require("./data"); | ||
exports.isPrimitive = function (Type) { | ||
return ['String', 'Number', 'Boolean', 'Date'].includes(Type.name); | ||
}; | ||
exports.isObject = function (Type) { | ||
var prototype = Type.prototype; | ||
var name = Type.name; | ||
while (name) { | ||
@@ -18,5 +20,5 @@ if (name === 'Object') { | ||
}; | ||
exports.isNumber = (Type) => Type.name === 'Number'; | ||
exports.isString = (Type) => Type.name === 'String'; | ||
exports.initAsObject = (name, key) => { | ||
exports.isNumber = function (Type) { return Type.name === 'Number'; }; | ||
exports.isString = function (Type) { return Type.name === 'String'; }; | ||
exports.initAsObject = function (name, key) { | ||
if (!data_1.schema[name]) { | ||
@@ -29,3 +31,3 @@ data_1.schema[name] = {}; | ||
}; | ||
exports.initAsArray = (name, key) => { | ||
exports.initAsArray = function (name, key) { | ||
if (!data_1.schema[name]) { | ||
@@ -38,6 +40,7 @@ data_1.schema[name] = {}; | ||
}; | ||
exports.getClassForDocument = (document) => { | ||
const modelName = document.constructor.modelName; | ||
exports.getClassForDocument = function (document) { | ||
var modelName = document.constructor | ||
.modelName; | ||
return data_1.constructors[modelName]; | ||
}; | ||
//# sourceMappingURL=utils.js.map | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGNBQWM7O0FBSWQsK0JBQThDO0FBRWpDLFFBQUEsV0FBVyxHQUFHLFVBQUMsSUFBUztJQUNuQy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LElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxFQUFFO1FBQ3RCLGFBQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxHQUFHLENBQUMsR0FBRyxFQUFFLENBQUM7S0FDeEI7QUFDSCxDQUFDLENBQUM7QUFFVyxRQUFBLFdBQVcsR0FBRyxVQUFDLElBQVMsRUFBRSxHQUFRO0lBQzdDLElBQUksQ0FBQyxhQUFNLENBQUMsSUFBSSxDQUFDLEVBQUU7UUFDakIsYUFBTSxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQztLQUNuQjtJQUNELElBQUksQ0FBQyxhQUFNLENBQUMsSUFBSSxDQUFDLENBQUMsR0FBRyxDQUFDLEVBQUU7UUFDdEIsYUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLENBQUM7S0FDMUI7QUFDSCxDQUFDLENBQUM7QUFFVyxRQUFBLG1CQUFtQixHQUFHLFVBQUMsUUFBMkI7SUFDN0QsSUFBTSxTQUFTLEdBQUksUUFBUSxDQUFDLFdBQStDO1NBQ3hFLFNBQVMsQ0FBQztJQUNiLE9BQU8sbUJBQVksQ0FBQyxTQUFTLENBQUMsQ0FBQztBQUNqQyxDQUFDLENBQUMifQ== |
{ | ||
"name": "typegoose", | ||
"version": "5.5.1", | ||
"version": "5.6.0", | ||
"description": "Define Mongoose models using TypeScript classes.", | ||
@@ -14,6 +14,5 @@ "main": "lib/typegoose.js", | ||
"lint": "tslint --project tsconfig.json", | ||
"test": "npm run lint && npm run cover", | ||
"test": "npm run lint && nyc npm run mocha", | ||
"mocha": "npm run build && mocha ./lib --recursive --exit", | ||
"cover": "npm run build && istanbul cover _mocha -- lib --recursive --exit -R spec", | ||
"coveralls": "cat ./coverage/lcov.info | coveralls" | ||
"coverage": "nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
@@ -28,10 +27,4 @@ "repository": { | ||
"license": "MIT", | ||
"dependencies": { | ||
"lodash": "~4.17.11", | ||
"mongoose": "^5.4.15", | ||
"reflect-metadata": "^0.1.13" | ||
}, | ||
"peerDependencies": { | ||
"mongoose": "^5.0.0", | ||
"reflect-metadata": "^0.1.12" | ||
"mongoose": "5.4.15" | ||
}, | ||
@@ -41,3 +34,2 @@ "devDependencies": { | ||
"@types/dotenv": "4.0.3", | ||
"@types/lodash": "4.14.108", | ||
"@types/mocha": "5.2.0", | ||
@@ -47,11 +39,19 @@ "@types/mongoose": "5.0.10", | ||
"chai": "4.1.2", | ||
"coveralls": "^3.0.3", | ||
"coveralls": "3.0.3", | ||
"dotenv": "5.0.1", | ||
"istanbul": "0.4.5", | ||
"mocha": "^5.2.0", | ||
"mocha": "5.2.0", | ||
"mocha-lcov-reporter": "1.3.0", | ||
"mongoose": "^5.0.0", | ||
"mongoose-findorcreate": "3.0.0", | ||
"nyc": "13.3.0", | ||
"prettier": "1.16.4", | ||
"prettier-tslint": "0.4.2", | ||
"rimraf": "2.6.2", | ||
"tslint": "5.9.1", | ||
"typescript": "^2.9.2" | ||
"tslint": "5.13.0", | ||
"tslint-config-prettier": "1.18.0", | ||
"typescript": "2.9.2" | ||
}, | ||
"dependencies": { | ||
"reflect-metadata": "^0.1.12" | ||
} | ||
} |
# Typegoose | ||
[![Build Status](https://travis-ci.org/szokodiakos/typegoose.svg?branch=master)](https://travis-ci.org/szokodiakos/typegoose) | ||
[![Coverage Status](https://coveralls.io/repos/github/szokodiakos/typegoose/badge.svg?branch=master)](https://coveralls.io/github/szokodiakos/typegoose?branch=master) | ||
[![Coverage Status](https://coveralls.io/repos/github/szokodiakos/typegoose/badge.svg?branch=master#feb282019)](https://coveralls.io/github/szokodiakos/typegoose?branch=master) | ||
[![npm](https://img.shields.io/npm/dt/typegoose.svg)]() | ||
@@ -278,4 +278,4 @@ | ||
@prop({ validate: { | ||
validator: val => isEmail(val), | ||
@prop({ validate: { | ||
validator: val => isEmail(val), | ||
message: `{VALUE} is not a valid email` | ||
@@ -292,10 +292,10 @@ }}) | ||
@prop({ validate: | ||
@prop({ validate: | ||
[ | ||
{ | ||
validator: val => isEmail(val), | ||
{ | ||
validator: val => isEmail(val), | ||
message: `{VALUE} is not a valid email` | ||
}, | ||
}, | ||
{ | ||
validator: val => isBlacklisted(val), | ||
validator: val => isBlacklisted(val), | ||
message: `{VALUE} is blacklisted` | ||
@@ -302,0 +302,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
64692
2
657
19
+ Addedasync@2.6.1(transitive)
+ Addedkareem@2.3.0(transitive)
+ Addedmongodb@3.1.13(transitive)
+ Addedmongodb-core@3.1.11(transitive)
+ Addedmongoose@5.4.15(transitive)
+ Addedmpath@0.5.1(transitive)
+ Addedmquery@3.2.0(transitive)
+ Addedms@2.1.1(transitive)
+ Addedregexp-clone@0.0.1(transitive)
+ Addedrequire_optional@1.0.1(transitive)
+ Addedresolve-from@2.0.0(transitive)
+ Addedsemver@5.7.2(transitive)
- Removedlodash@~4.17.11
- Removedmongoose@^5.4.15
- Removed@types/bson@4.0.5(transitive)
- Removed@types/mongodb@3.6.20(transitive)
- Removed@types/node@22.10.0(transitive)
- Removedbl@2.2.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddenque@1.5.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@1.0.0(transitive)
- Removedkareem@2.3.2(transitive)
- Removedmongodb@3.7.4(transitive)
- Removedmongoose@5.13.22(transitive)
- Removedmpath@0.8.4(transitive)
- Removedmquery@3.2.5(transitive)
- Removedms@2.1.2(transitive)
- Removedoptional-require@1.0.31.1.8(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedregexp-clone@1.0.0(transitive)
- Removedrequire-at@1.0.6(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsift@13.5.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedundici-types@6.20.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedreflect-metadata@^0.1.12